riscv64: PLIC bring-up, external-interrupt substrate (item 4.3.5b)

Punch list §25 item 4.3.5b complete.

sie.SEIE enabled, PLIC threshold/claim/complete wired into the trap
handler. Verified with a UART-loopback synthetic interrupt (PLIC has no
software set-pending register, unlike GICv2): claim_count=1, last_irq=10,
IIR confirms genuine receive-data cause, byte matched exactly. Self-test
code run once for evidence then fully reverted, per Captain Bob's ruling;
only the permanent substrate remains, no source enabled by default.
Three-arch acceptance boot clean, zero exceptions.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Robert Allan James
2026-08-08 11:24:47 -04:00
co-authored by Claude Sonnet 5
parent 36965cf812
commit 5f4df673c1
19 changed files with 73317 additions and 88 deletions
+13 -7
View File
@@ -6,14 +6,17 @@
/**
* apic.c (riscv64) - APIC stub. No Local APIC on RISC-V; interrupt
* controller is PLIC (Platform-Level Interrupt Controller). These stubs
* satisfy the common kernel interface; PLIC wiring is a later milestone.
* controller is PLIC (Platform-Level Interrupt Controller). apic_init()
* calls into plic.c for the real PLIC bring-up (item 4.3.5b); apic_eoi()
* stays a no-op since PLIC completion happens per-source in the trap
* handler (claim/complete), not via a single shared EOI register.
*/
#include "apic.h"
#include "uefi.h"
#include "console.h"
#include "timer.h"
#include "starkernel/plic.h"
#include <stdint.h>
static uint64_t s_timer_period_tsc = 0;
@@ -149,20 +152,23 @@ void riscv64_timer_rearm(void)
}
/*
* @brief Initialise the interrupt controller (RISC-V PLIC stub).
* @brief Initialise the interrupt controller: PLIC bring-up (item 4.3.5b).
*
* On x86-64 this function configures the Local APIC. On RISC-V the
* Platform-Level Interrupt Controller (PLIC) handles external interrupt
* routing; PLIC bring-up is deferred to a later milestone. This stub
* satisfies the common @c apic_init() call site in @c kernel_main()
* and always returns success.
* routing -- @c plic_init() (arch/riscv64/plic.c) maps it, sets the S-mode
* context's threshold, and enables @c sie.SEIE. No source is enabled here;
* that is each future consumer's own job (4.3.5c for virtio-keyboard).
*
* @param boot_info Kernel boot information (ACPI/PLIC base address); unused.
* @param boot_info Kernel boot information; unused (PLIC base is a verified
* constant, not discovered from @c boot_info->dtb -- see
* plic.c's file header for why).
* @return 0 always.
*/
int apic_init(BootInfo *boot_info)
{
(void)boot_info;
plic_init();
return 0;
}