A question or six about the GDT.
Posted: Sat Jan 26, 2008 1:53 am
First I just wanted to say this site kicks it. Thanks for the info.
I have done many searches and read lots of post about OS Dev, GDT, Protected Mode, etc but I have some questions still un-answered.
I am developing under Linux. Using GCC, NASM and LD. QEMU is this emulator that I am using.
Q1: From what I have seen in the examples, posts and tutorials the GDT entries for code and data just use a base of 0 and a limit of 0xffff with granularity set so that you have 4GB of addressable space. I have seen very few examples with any thing else. So the questions is: Why? Is it better to set up the GDT this way for some reason? If so, what is that reason?
Q2: I have not seen any examples with code and data mapped to different locations. They are always the same. So can the code and data descriptors address different locations instead of the same memory address?
Q3: Is there something wrong with this GDT? According to the documentation and tutorials this should be possible but it hoses up my emulator. I don't get a dump. (Depending on the answers to the questions above, answering this may not be necessary!)
Thanks in advance for any help.
I have done many searches and read lots of post about OS Dev, GDT, Protected Mode, etc but I have some questions still un-answered.
I am developing under Linux. Using GCC, NASM and LD. QEMU is this emulator that I am using.
Q1: From what I have seen in the examples, posts and tutorials the GDT entries for code and data just use a base of 0 and a limit of 0xffff with granularity set so that you have 4GB of addressable space. I have seen very few examples with any thing else. So the questions is: Why? Is it better to set up the GDT this way for some reason? If so, what is that reason?
Q2: I have not seen any examples with code and data mapped to different locations. They are always the same. So can the code and data descriptors address different locations instead of the same memory address?
Q3: Is there something wrong with this GDT? According to the documentation and tutorials this should be possible but it hoses up my emulator. I don't get a dump. (Depending on the answers to the questions above, answering this may not be necessary!)
Code: Select all
gdt:
null:
dd 0
dd 0
kernel_code:
dw 0x0022
dw 0
db 0
db 10011010b
db 11001111b
db 0
kernel_data:
dw 0x0022
dw 0xfff1
db 0x22
db 10010010b
db 11001111b
db 0
isr_code:
dw 0x0022
dw 0xffe2
db 0x45
db 10011010b
db 11001111b
db 0
gdt_end:
gdt_desc:
dw gdt_end - gdt - 1
dd gdt