Code: Select all
void idt_install()
{
idtp.limit = (8 * 256) - 1;
idtp.base = cast(uint)&idt;
memorySet(&idt,0,8 * 256);
isrs_install();
idtFlush(cast(uint)&idtp);
console_print("idt installed");
}
Code: Select all
void isrs_install()
{
idt_setGate(0,cast(ulong)&isr0, 0x08, 0x8E);
/* idt_setGate(1,cast(ulong)&isr1, 0x08, 0x8E);
idt_setGate(2,cast(ulong)&isr2, 0x08, 0x8E);
idt_setGate(3,cast(ulong)&isr3, 0x08, 0x8E);
idt_setGate(4,cast(ulong)&isr4, 0x08, 0x8E);
idt_setGate(5,cast(ulong)&isr5, 0x08, 0x8E);
idt_setGate(6,cast(ulong)&isr6, 0x08, 0x8E);
idt_setGate(7,cast(ulong)&isr7, 0x08, 0x8E);
idt_setGate(8,cast(uint)&isr8, 0x08, 0x8E);
idt_setGate(9,cast(uint)&isr9, 0x08, 0x8E);
idt_setGate(10,cast(uint)&isr10, 0x08, 0x8E);
idt_setGate(11,cast(uint)&isr11, 0x08, 0x8E);
idt_setGate(12,cast(uint)&isr12, 0x08, 0x8E);
idt_setGate(13,cast(uint)&isr13, 0x08, 0x8E);
idt_setGate(14,cast(uint)&isr14, 0x08, 0x8E);
idt_setGate(15,cast(uint)&isr15, 0x08, 0x8E);
idt_setGate(16,cast(uint)&isr16, 0x08, 0x8E);
idt_setGate(17,cast(uint)&isr17, 0x08, 0x8E);
idt_setGate(18,cast(uint)&isr18, 0x08, 0x8E);
idt_setGate(19,cast(uint)&isr19, 0x08, 0x8E);
idt_setGate(20,cast(uint)&isr20, 0x08, 0x8E);
idt_setGate(21,cast(uint)&isr21, 0x08, 0x8E);
idt_setGate(22,cast(uint)&isr22, 0x08, 0x8E);
idt_setGate(23,cast(uint)&isr23, 0x08, 0x8E);
idt_setGate(24,cast(uint)&isr24, 0x08, 0x8E);
idt_setGate(25,cast(uint)&isr25, 0x08, 0x8E);
idt_setGate(26,cast(uint)&isr26, 0x08, 0x8E);
idt_setGate(27,cast(uint)&isr27, 0x08, 0x8E);
idt_setGate(28,cast(uint)&isr28, 0x08, 0x8E);
idt_setGate(29,cast(uint)&isr29, 0x08, 0x8E);
idt_setGate(30,cast(uint)&isr30, 0x08, 0x8E);
idt_setGate(31,cast(uint)&isr31, 0x08, 0x8E);
*/
console_print("isrs installed");
}
Code: Select all
void isr0()
{
console_print("irs0 called");
asm
{
cli;
push 0;
push 0;
}
isr_common();
}
Code: Select all
isr_common:
pusha
mov ax, ds
push eax
mov ax, 0x10
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
call faultHandler
pop eax
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
popa
add esp, 8
sti
iret
Code: Select all
extern(C) void faultHandler(registers r)
{
//if ((*r).int_no < 32)
//{
console_print(exception_messages[r.int_no]);
console_print(" Exception. System Halted!");
while(true){}
//}
}