hmm GDT..I forgot this..Help?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Tom

hmm GDT..I forgot this..Help?

Post 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
GertFaller

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

Post by GertFaller »

I think problem comes from your gdtr

Code: Select all

gdtr
    dw gdt_end-gdt-1
    dd gdt

Friend

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

Post 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.
Ozguxxx

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

Post 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.
Tom

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

Post by Tom »

well, I do know that I need to set a value of 1000h somewhere.
Tom

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

Post by Tom »

[attachment deleted by admin]
GertFaller

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

Post 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.
Duncan

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

Post 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)
User avatar
Pype.Clicker
Member
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?

Post 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 ?
Post Reply