starkernel: item 4.3.5 -- amd64 I/O APIC + i8042 keyboard, interrupt-driven
Punch list §25 item 4.3.5 complete. New ioapic.c/i8042.c drivers (MADT-derived I/O APIC base, no hardcoded constants) plus a KBD-SCAN/KBD-DEBUG diagnostic word pair. Three real bugs found and fixed en route, all blocking this item's own acceptance: a fatal LAPIC spurious-vector crash (nothing had driven a real external interrupt through the I/O APIC before), OVMF leaving the keyboard device itself scanning-disabled (0xF4 fix), and isr.S's stub table only having individually-numbered stubs through vector 32 -- everything above that, including our IRQ1 vector 33, silently reported as vector 255 regardless of which IDT slot actually fired. Verified live via QEMU sendkey against KBD-SCAN: correct XT Set-1 make/break codes for two different keys. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
78ff335b97
commit
88eb73cfe8
@@ -28,6 +28,8 @@
|
||||
#include "vmm.h"
|
||||
#include "apic.h"
|
||||
#include "timer.h"
|
||||
#include "starkernel/ioapic.h"
|
||||
#include "starkernel/i8042.h"
|
||||
#include "kmalloc.h"
|
||||
#include "starkernel/kernel_args.h"
|
||||
|
||||
@@ -423,6 +425,20 @@ void kernel_main(BootInfo *boot_info) {
|
||||
apic_init(boot_info);
|
||||
console_println("APIC: init done\n");
|
||||
|
||||
#ifdef ARCH_AMD64
|
||||
/* item 4.3.5 (FABRIC.md §27.5): I/O APIC + i8042 keyboard, interrupt-
|
||||
* driven. Routed masked here; unmasked in kernel_main_deep() at the
|
||||
* same point the APIC timer is started. */
|
||||
console_println("I/O APIC: init...");
|
||||
if (ioapic_init(boot_info->acpi_table) == 0 &&
|
||||
ioapic_route_legacy_irq(1, I8042_KEYBOARD_VECTOR, apic_id()) == 0) {
|
||||
i8042_init();
|
||||
console_println("I/O APIC: keyboard IRQ1 routed (masked)\n");
|
||||
} else {
|
||||
console_println("I/O APIC: keyboard bring-up FAILED\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
/* M5: Timer subsystem */
|
||||
console_println("Timer: init...");
|
||||
timer_init(boot_info);
|
||||
@@ -640,6 +656,11 @@ static void kernel_main_deep(BootInfo *boot_info) {
|
||||
/* Start heartbeat and enable interrupts */
|
||||
console_println("Starting heartbeat...");
|
||||
apic_timer_start();
|
||||
#ifdef ARCH_AMD64
|
||||
i8042_drain_stale();
|
||||
ioapic_unmask_legacy_irq(1);
|
||||
console_println("I/O APIC: keyboard IRQ1 unmasked");
|
||||
#endif
|
||||
arch_enable_interrupts();
|
||||
console_println("Heartbeat running.");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user