2011-01-16 06:11:17 +03:00
|
|
|
#include <system.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* IDT Entry
|
|
|
|
*/
|
|
|
|
struct idt_entry {
|
|
|
|
unsigned short base_low;
|
|
|
|
unsigned short sel;
|
|
|
|
unsigned char zero;
|
|
|
|
unsigned char flags;
|
|
|
|
unsigned short base_high;
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
struct idt_ptr {
|
|
|
|
unsigned short limit;
|
2011-01-18 03:34:50 +03:00
|
|
|
uintptr_t base;
|
2011-01-16 06:11:17 +03:00
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
struct idt_entry idt[256];
|
|
|
|
struct idt_ptr idtp;
|
|
|
|
|
|
|
|
extern void idt_load();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* idt_set_gate
|
|
|
|
* Set an IDT gate
|
|
|
|
*/
|
|
|
|
void
|
2011-01-16 06:41:17 +03:00
|
|
|
idt_set_gate(
|
2011-01-16 06:11:17 +03:00
|
|
|
unsigned char num,
|
|
|
|
unsigned long base,
|
|
|
|
unsigned short sel,
|
|
|
|
unsigned char flags
|
|
|
|
) {
|
|
|
|
idt[num].base_low = (base & 0xFFFF);
|
|
|
|
idt[num].base_high = (base >> 16) & 0xFFFF;
|
|
|
|
idt[num].sel = sel;
|
|
|
|
idt[num].zero = 0;
|
|
|
|
idt[num].flags = flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* idt_install
|
|
|
|
* Install the IDTs
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
idt_install() {
|
|
|
|
idtp.limit = (sizeof(struct idt_entry) * 256) - 1;
|
2011-01-18 03:22:48 +03:00
|
|
|
idtp.base = (uintptr_t)&idt;
|
2011-01-16 06:11:17 +03:00
|
|
|
memset(&idt, 0, sizeof(struct idt_entry) * 256);
|
|
|
|
|
|
|
|
idt_load();
|
|
|
|
}
|