Two driver-model milestones plus a tree-wide naming pass. Suite 35/35 (QEMU) + host tests green. M11 — IRQ-as-IPC. A ring-3 driver now sleeps until its device interrupts it. New src/kernel/irq.zig: per-GSI endpoint bindings, comptime per-vector trampolines, dispatch = mask GSI -> LAPIC EOI -> notifyLocked, all under one lock region. irq_bind/irq_ack syscalls, gated by the device claim like mmio_map. interruptDispatch no longer EOIs — each handler owns its EOI, because a level line must be masked before it is acknowledged (irq_ack is the unmask). Bindings are keyed on the owning task and released on exit (a shared endpoint's siblings survive). hpetd rewritten interrupt-driven. Tests: hpet (rewritten, reads back the I/O APIC routing) and irqfree. M12 — bus drivers. DeviceDesc gains a parent, making the device table a tree. dev_register (device_register) lets a process publish children below a device it claimed; the kernel enforces resource containment (a child's resources must nest in its parent's), so a descriptor can't fabricate a window over kernel RAM. Descriptor copied in via copyFromUser (physmap walk — an unmapped user pointer fails the call instead of faulting the kernel). Per-parent child cap bounds table exhaustion. sbin/busd.zig is a worked bus driver. Test: bus. Naming — per docs/coding-standards.md: non-acronym abbreviations spelled out (message, descriptor, device_service, scheduler, runtime, physical, interpreter, ...); acronyms kept (IPC, MMIO, DMA, HCD, ...); files are kebab-case (ipc-synchronous.zig, device-service.zig, vfs-protocol.zig, ...). Exceptions: POSIX/C ABI names and Zig idioms (init/len/ptr) kept. Module collisions resolved by specific naming (config -> parameters, device.zig alias -> device_model). AML op/Op disambiguated: op = opcode, Op = operation; per-opcode parse handlers renamed opX -> parseX. New driver docs: drivers.md, driver-model.md (bus/class/HCD shapes + the proposed M13–M16 ABI), coding-standards.md.
48 lines
1.4 KiB
Zig
48 lines
1.4 KiB
Zig
//! /sbin/vfstest — a client that proves the VFS round trip end to end: open a
|
|
//! file through the `runtime` file API, write to it, seek back, read it, and compare.
|
|
//! On success it heartbeats "vfstest: ok" so the kernel test can observe it;
|
|
//! on failure it reports what went wrong. Shipped in the initrd alongside vfs.
|
|
|
|
const std = @import("std");
|
|
const runtime = @import("runtime");
|
|
|
|
pub fn main() void {
|
|
const u = runtime.unistd;
|
|
const payload = "hello-vfs";
|
|
|
|
// The VFS server may not have registered yet — retry open until it's up.
|
|
var fd: i32 = -1;
|
|
var tries: u32 = 0;
|
|
while (fd < 0 and tries < 200) : (tries += 1) {
|
|
fd = u.open("greeting", u.O_CREAT);
|
|
if (fd < 0) runtime.system.sleep(20);
|
|
}
|
|
if (fd < 0) {
|
|
_ = runtime.system.write("vfstest: open failed\n");
|
|
return;
|
|
}
|
|
|
|
if (u.write(fd, payload) != @as(isize, payload.len)) {
|
|
_ = runtime.system.write("vfstest: write failed\n");
|
|
return;
|
|
}
|
|
_ = u.lseek(fd, 0, u.SEEK_SET);
|
|
|
|
var buffer: [32]u8 = undefined;
|
|
const n = u.read(fd, &buffer);
|
|
u.close(fd);
|
|
|
|
if (n == @as(isize, payload.len) and std.mem.eql(u8, buffer[0..@intCast(n)], payload)) {
|
|
while (true) {
|
|
_ = runtime.system.write("vfstest: ok\n");
|
|
runtime.system.sleep(1000);
|
|
}
|
|
}
|
|
_ = runtime.system.write("vfstest: mismatch\n");
|
|
}
|
|
|
|
pub const panic = runtime.panic;
|
|
comptime {
|
|
_ = &runtime.start._start;
|
|
}
|