I have a 2nd stage loader loaded at 1000h
Now, it sets PMode, but I forgot how to make the GDT know it's at 1000h.
Like, when I do a jmp codesel:pmode it reboots.
So, I need to change something in my GDT, but I forgot what...help?
gdt code:
gdtr
dw gdt_end-1
dd gdt
gdt
nullsel equ $-gdt
gdt0
dd 0
dd 0
codesel equ $-gdt ; might need to change this?
dw 0ffffh
dw 0
db 0
db 09ah
db 0cfh
db 0h
datasel equ $-gdt ; might need to change this too?
dw 0ffffh
dw 0h
db 0h
db 092h
db 0cfh
db 0
gdt_end
hmm GDT..I forgot this..Help?
Re:hmm GDT..I forgot this..Help?
I think problem comes from your gdtr
Code: Select all
gdtr
dw gdt_end-gdt-1
dd gdt
Re:hmm GDT..I forgot this..Help?
Hi,
This cannot be the problem because as long as the GDT size is more than what is used it will be ok, and gdt_end-1 will produce a value that is enough to cover what is used.
sorry I cant help further.
This cannot be the problem because as long as the GDT size is more than what is used it will be ok, and gdt_end-1 will produce a value that is enough to cover what is used.
sorry I cant help further.
Re:hmm GDT..I forgot this..Help?
I think you should define two new segments in GDT that describes the code segment that you will jump and the data segment that you will use there, right? I mean:
GDT does not need to know that it is at 1000h. But MPU should know that there is a valid executable segment at 0x1000. Also I could not understand why you defined the base addresses as 0.Now, it sets PMode, but I forgot how to make the GDT know it's at 1000h.
Re:hmm GDT..I forgot this..Help?
well, I do know that I need to set a value of 1000h somewhere.
Re:hmm GDT..I forgot this..Help?
You should load ds with a valid segment
(0 because of your org)
so lgdt will load really gdtr.
Code: Select all
mov ax, 0
mov ds,ax
so lgdt will load really gdtr.
Re:hmm GDT..I forgot this..Help?
I think you have forgotten to load the base addresses into your GDT descriptors before doing the jmp. At the moment, it looks like your jmp will jump to 0:0 and try to execute the IVT.
You know that you needed to load 1000h somewhere - I suspect this is where you need to do so.
Your gdtr base address may be out too. Since you don't have a [BITS 32] directive before specifiying you may not get a 32 bit linear address for the GDT structure itself but rather a 16 bit offset (based at segment 0?) (I am not sure about NASMs behaviour here - I use TASM)
You know that you needed to load 1000h somewhere - I suspect this is where you need to do so.
Your gdtr base address may be out too. Since you don't have a [BITS 32] directive before specifiying you may not get a 32 bit linear address for the GDT structure itself but rather a 16 bit offset (based at segment 0?) (I am not sure about NASMs behaviour here - I use TASM)
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:hmm GDT..I forgot this..Help?
Where is your 2ndstage.asm loaded *effectively* ? at 0x0000:0x1000 ? is this a safe place (ain't you overwriting some stuff ?) is your DS segment set up properly by the first-stage loader ?