void idtInit() { static IDTEntry idt[256]; static IDTPointer idtPtr; int i; uint32_t temp; // get distance between irq0 and irq1 temp = (uint32_t)isr1 - (uint32_t)isr0; // Set up the IDT pointer for the CPU idtPtr.limit = sizeof(IDTEntry) * 256 - 1; idtPtr.base = (uint32_t)&idt; // Clear them out so we don't get triple faults.. memset(&idt, 0, sizeof(IDTEntry)*256); // Set up the IDT itself first for(i=0; i<256; i++) { encodeIDTEntry(&idt[i], (uint32_t)isr0+(temp*i), 0x08, IDT_INT32_PL0); } // Now we Set up service handlers for(i=0; i<256; i++) { interruptHandlerRegister(i, unhandledInterrupt); } // Finally, we can push changes to the CPU and enable interrupts idtFlush((uint32_t)&idtPtr); }
void idtInit() { int i; unsigned int temp; // Get distance between isr stubs. temp = (unsigned int)isr1 - (unsigned int)isr0; idt_ptr.limit = sizeof(idt_entry_t) * 256 - 1; idt_ptr.base = (unsigned int)&idt; memset(&idt, 0, sizeof(idt_entry_t)*256); // Initialize the Vector Table with the stubs. for(i=0; i<128; i++) { idtSetGate(i, (unsigned int)isr0 + (temp*i), 0x08, 0x8E); } // Initialize the Function calls to default state for(i=0; i<256; i++) { interruptHandlerRegister(i, unhandledInterrupt); } idt_flush((unsigned int)&idt_ptr); }