/****************************************************************** * idt.h - INTERRUPT DESCRIPTOR TABLE * * Contains structures and function declarations for IDT * ******************************************************************/ #include #include "idt.h" extern void IdtLoad(); /* Declare an IDT of 256 entries. */ struct IdtEntry idt[256]; struct IdtPointer idtp; /* Use this function to set an entry in the IDT. Alot simpler * than twiddling with the GDT ;) */ void IdtSetGate(unsigned char num, unsigned long base, unsigned short sel, unsigned char flags) { /* The interrupt routine's base address */ idt[num].base_lo = (base & 0xFFFF); idt[num].base_hi = (base >> 16) & 0xFFFF; /* The segment or 'selector' that this IDT entry will use * is set here, along with any access flags */ idt[num].sel = sel; idt[num].always0 = 0; idt[num].flags = flags; } struct IdtEntry* IdtGetGate(unsigned char num) { return &idt[num]; } /* Installs the IDT */ void IdtInstall() { /* Sets the special IDT pointer up, just like in 'gdt.c' */ idtp.limit = (sizeof (struct IdtEntry) * 256) - 1; idtp.base = (unsigned int)&idt; /* Clear out the entire IDT, initializing it to zeros */ memset (&idt, 0, sizeof(struct IdtEntry) * 256); /* Points the processor's internal register to the new IDT */ IdtLoad(); }