Handle local APIC exceptions

This commit is contained in:
Josh Holtrop 2022-12-07 23:24:01 -05:00
parent 9b52ae58e8
commit b1a8f8d348
2 changed files with 23 additions and 10 deletions

View File

@ -6,6 +6,7 @@ module hulk.apic;
import hulk.klog;
import hulk.hurl;
import hulk.acpi;
import hulk.idt;
struct apic
{
@ -63,9 +64,9 @@ struct apic
/* Enable local APIC to receive interrupts and set spurious interrupt
* vector to 0xFF. */
apic_registers.spurious_interrupt_vector.value = 0x1FFu;
apic_registers.lvt_timer.value = 0x70u | PERIODIC_MODE;
apic_registers.lvt_lint[0].value = 0x71u;
apic_registers.lvt_lint[1].value = 0x72u;
apic_registers.lvt_timer.value = idt.EXCEPTION_LAPIC_TIMER | PERIODIC_MODE;
apic_registers.lvt_lint[0].value = idt.EXCEPTION_LAPIC_LINT0;
apic_registers.lvt_lint[1].value = idt.EXCEPTION_LAPIC_LINT1;
apic_registers.divide_configuration.value = 3u;
}
@ -74,7 +75,7 @@ struct apic
apic_registers.eoi.value = 0u;
}
public static void isr()
public static void isr(ulong vector)
{
eoi();
}

View File

@ -8,9 +8,14 @@ import ldc.llvmasm;
import hulk.fb;
import hulk.console;
import hulk.klog;
import hulk.apic;
struct idt
{
public static enum ulong EXCEPTION_LAPIC_TIMER = 0x70u;
public static enum ulong EXCEPTION_LAPIC_LINT0 = 0x71u;
public static enum ulong EXCEPTION_LAPIC_LINT1 = 0x72u;
struct idtr_t
{
ushort limit;
@ -94,12 +99,19 @@ struct idt
public extern(C) void isr(ulong vector, ulong arg)
{
console.clear();
fb.clear(0xFF8000u);
klog.writefln("ISR %u, 0x%x", vector, arg);
__asm("cli", "");
for (;;)
if ((idt.EXCEPTION_LAPIC_TIMER <= vector) && (vector <= idt.EXCEPTION_LAPIC_LINT1))
{
__asm("hlt", "");
apic.isr(vector);
}
else
{
console.clear();
fb.clear(0xFF8000u);
klog.writefln("ISR %u, 0x%x", vector, arg);
__asm("cli", "");
for (;;)
{
__asm("hlt", "");
}
}
}