M10: IO passthrough (MMIO grants) + first real driver (hpetd)
A user-space process can now touch real hardware directly, capability-gated by the device tree — the microkernel driver model. - src/kernel/devsvc.zig: flattens the discovered device tree into an id-indexed snapshot + a claim table at boot (devsvc.init from main.zig). - Syscalls 11-13: dev_enumerate (snapshot the table), dev_claim (take exclusive ownership), mmio_map (map a claimed device's MMIO window into the caller's AS and return the register base). The claim is the capability: mmio_map refuses any device the caller doesn't own. - paging.mapUserDeviceInto: maps device MMIO strong-uncacheable (PCD|PWT) and marks each leaf with a device_grant PTE bit; freeSubtree skips pmm.free on those leaves, so tearing down a driver never returns MMIO frames to the RAM pool (the teardown hazard). MMIO grants live in a distinct arena, PML4[226] (Task.dev_map_next), so device pages widen no kernel mapping. - lib/dev.zig: user enumerate/claim/mmioMap wrappers; shared DeviceDesc/ResDesc in danos (root.zig). sbin/hpetd.zig: finds the HPET, claims it, maps its registers, enables the counter (an MMIO write) and reads it (0xF0) — proving read+write passthrough to real hardware. - Tests: `hpet` (driver reads the counter advancing from ring 3) and `iopass` (device-granted frame survives address-space teardown). Suite 33/33. irq_bind/irq_ack (IRQ-as-message) are stubbed (-1) pending; notifyFromIsr (M7) is the hook they'll use.
This commit is contained in:
@@ -188,6 +188,16 @@ CASES = [
|
||||
{"name": "vfs",
|
||||
"expect": r"DANOS-TEST-RESULT: PASS",
|
||||
"fail": r"DANOS-TEST-RESULT: FAIL"},
|
||||
# IO passthrough: a user-space HPET driver maps device MMIO into its own
|
||||
# address space and reads the counter advancing.
|
||||
{"name": "hpet",
|
||||
"expect": r"DANOS-TEST-RESULT: PASS",
|
||||
"fail": r"DANOS-TEST-RESULT: FAIL"},
|
||||
# The MMIO-grant teardown fix: a device-granted frame must not be reclaimed
|
||||
# as RAM when its address space is destroyed.
|
||||
{"name": "iopass",
|
||||
"expect": r"DANOS-TEST-RESULT: PASS",
|
||||
"fail": r"DANOS-TEST-RESULT: FAIL"},
|
||||
# The ACPI power path succeeds by QEMU *exiting* (S5 off / reset), so match the
|
||||
# pre-transition marker; the FAIL line only appears if the transition didn't take.
|
||||
{"name": "poweroff",
|
||||
|
||||
Reference in New Issue
Block a user