IDT help
Posted: Fri Jul 21, 2006 7:13 pm
I'm having troubles setting up my IDT. I have read the manuals and the pages in the faq but still have some questions:
1. What are the differences between Trap, Interrupt and Task gates? From my understanding the task gate switches the task for you. But I don't get the difference between intterupt and trap gates.
2. I understand that when you load the IDTR you must give a 16bit size, and then the 32bit memory location. What I don't understand is what is the size measured in? The number of bits of the table, bytes, or is it the number of entries?
3. For interrupt and trap gates what do I put in the two 16bit offsets? Do I put the first 16bits of the address in the first offset field and the other 16bits in the other offset field?
4. Also what would I put for the segment value? Since grub sets the segment size to 4gb I should just fill this value with 0 right?
Here is the code I have written so far regarding interrupts
Thanks
1. What are the differences between Trap, Interrupt and Task gates? From my understanding the task gate switches the task for you. But I don't get the difference between intterupt and trap gates.
2. I understand that when you load the IDTR you must give a 16bit size, and then the 32bit memory location. What I don't understand is what is the size measured in? The number of bits of the table, bytes, or is it the number of entries?
3. For interrupt and trap gates what do I put in the two 16bit offsets? Do I put the first 16bits of the address in the first offset field and the other 16bits in the other offset field?
4. Also what would I put for the segment value? Since grub sets the segment size to 4gb I should just fill this value with 0 right?
Here is the code I have written so far regarding interrupts
Code: Select all
struct idt_entry{
unsigned offset:16;
unsigned segment:16; //0?
unsigned reserved:8; //always 0
unsigned flags:8; // 0x8E for 32bit interrupt gate
unsigned offset2:16;
};
struct idt_pointer{
unsigned table_size:16;
unsigned base_location:32;
};
struct idt_entry idt[256];
struct idt_pointer idt_p;
void kernel_entry(){
int i;
idt_p.table_size = 16383 // (256 * 65) - 1
idt_p.base_location = &idt;
for(i = 0; i < 256; i ++){ //fill the table
//put other values here
idt[i].reserved = 0;
idt[i].flags = 0x8E;
}
...
Thanks