35 lines
900 B
C
35 lines
900 B
C
#include "interrupts.h"
|
|
#include "mem.h"
|
|
#include "types.h"
|
|
|
|
void setup_idt_entry(u32 t_idx, u32 base, u16 sel, u8 type_attrs) {
|
|
// Configuring a single given entry in the IDT table
|
|
IDT[t_idx].offset_low = (base & 0xffff);
|
|
IDT[t_idx].offset_high = ((base >> 16) & 0xffff);
|
|
|
|
IDT[t_idx].type_attrs = type_attrs;
|
|
IDT[t_idx].selector = sel;
|
|
}
|
|
|
|
void load_idt() {
|
|
asm("lidt [idt_ptr]");
|
|
return;
|
|
}
|
|
|
|
// Generic interrupt handler to be used later on
|
|
//void interrupt_handler(struct cpu_reg_state cpu, struct stack_state stack, u32 interrupt_code) {
|
|
//}
|
|
|
|
void init_idt() {
|
|
// setup special idt pointer
|
|
idt_ptr.address = (u32)(&IDT);
|
|
idt_ptr.limit = sizeof(struct IDT_Entry) * IDT_SIZE;
|
|
// clear table
|
|
memset((u8*)IDT, 0x00, (sizeof(struct IDT_Entry) * IDT_SIZE) - 1);
|
|
// add interrupt service routines here
|
|
// TODO
|
|
|
|
// Load IDT with all the new information in place, ready to use
|
|
load_idt();
|
|
}
|