Page 1 of 1

hmm GDT..I forgot this..Help?

Posted: Sat Oct 26, 2002 9:26 pm
by Tom
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

Re:hmm GDT..I forgot this..Help?

Posted: Sun Oct 27, 2002 5:05 am
by GertFaller
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?

Posted: Sun Oct 27, 2002 5:41 am
by Friend
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.

Re:hmm GDT..I forgot this..Help?

Posted: Sun Oct 27, 2002 7:31 am
by Ozguxxx
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:
Now, it sets PMode, but I forgot how to make the GDT know it's at 1000h.
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.

Re:hmm GDT..I forgot this..Help?

Posted: Sun Oct 27, 2002 9:32 am
by Tom
well, I do know that I need to set a value of 1000h somewhere.

Re:hmm GDT..I forgot this..Help?

Posted: Sun Oct 27, 2002 10:14 am
by Tom
[attachment deleted by admin]

Re:hmm GDT..I forgot this..Help?

Posted: Sun Oct 27, 2002 4:55 pm
by GertFaller
You should load ds with a valid segment

Code: Select all

   mov ax, 0 
   mov ds,ax
(0 because of your org)

so lgdt will load really gdtr.

Re:hmm GDT..I forgot this..Help?

Posted: Sun Oct 27, 2002 8:40 pm
by Duncan
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)

Re:hmm GDT..I forgot this..Help?

Posted: Mon Oct 28, 2002 3:44 am
by Pype.Clicker
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 ?