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

View File

@ -8,9 +8,14 @@ import ldc.llvmasm;
import hulk.fb; import hulk.fb;
import hulk.console; import hulk.console;
import hulk.klog; import hulk.klog;
import hulk.apic;
struct idt 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 struct idtr_t
{ {
ushort limit; ushort limit;
@ -93,6 +98,12 @@ struct idt
} }
public extern(C) void isr(ulong vector, ulong arg) public extern(C) void isr(ulong vector, ulong arg)
{
if ((idt.EXCEPTION_LAPIC_TIMER <= vector) && (vector <= idt.EXCEPTION_LAPIC_LINT1))
{
apic.isr(vector);
}
else
{ {
console.clear(); console.clear();
fb.clear(0xFF8000u); fb.clear(0xFF8000u);
@ -103,3 +114,4 @@ public extern(C) void isr(ulong vector, ulong arg)
__asm("hlt", ""); __asm("hlt", "");
} }
} }
}