Page 1 of 1

How to initialize GDT, IDT?

Posted: Thu Aug 19, 2010 6:28 am
by tushs
Hi, All I read is lots of complex information about theory of GDT LDT and paging. But this is not going to work with m (or possibly with anyone) to get 'Clear' picture of Kernel. So I want to write some code and try out the things myself. I have following doubts/plans kindly help m,
1. I am in real mode 16 bit code so I am not able to use c code. OR how can I use 'c'?
2. To initialize GDT I need a 32 bit physical memory address and 16 bit table limit. Now since its 64 bit struct do I need to use DB and init every bits of table in assembly?

please tell some guideline or links for Init of GDT and paging.

Re: How to initialize GDT, IDT?

Posted: Thu Aug 19, 2010 7:10 am
by skyking
Look in the tutorials on the wiki. In order to use C in real mode you may want a compiler that supports 16-bit code, but since it's not much that need to be done in order to get to protected mode it's not worth it IMHO (you could make it to protected mode already from bootsector code).

NB you don't have to setup paging in order to have a 32-bit environment (which is what 32-bit compilers like gcc expects to generate code for).

Re: How to initialize GDT, IDT?

Posted: Thu Aug 19, 2010 8:33 am
by tushs
Ok, I will use assembly I will have
1. NULL Segment
2. Code Segment
3. Data Segment
4. TSS Segment (Assume reserved now)
5. LDT Segment (Assume reserved now)
I am not getting how to declare 8 byte long variable in NASM, Do i need to use GNU GAS?

Re: How to initialize GDT, IDT?

Posted: Thu Aug 19, 2010 8:43 am
by Cjreek
You've to use

dq 0x0000000000000000

for example. But I think it's much easier to split GDT entries into some 8-/16-bit values. This will be much more readable to you (later).