How to initialize GDT, IDT?

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
tushs
Member
Member
Posts: 28
Joined: Mon Aug 02, 2010 7:43 am

How to initialize GDT, IDT?

Post 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.
skyking
Member
Member
Posts: 174
Joined: Sun Jan 06, 2008 8:41 am

Re: How to initialize GDT, IDT?

Post 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).
tushs
Member
Member
Posts: 28
Joined: Mon Aug 02, 2010 7:43 am

Re: How to initialize GDT, IDT?

Post 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?
Cjreek
Member
Member
Posts: 70
Joined: Thu May 28, 2009 2:41 pm
Location: Germany

Re: How to initialize GDT, IDT?

Post 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).
Post Reply