Every supervised driver owes the device manager a hello at startup, and the retry-lookup-call-check for it had been copied into five drivers: usb.helloManager (misfiled in the USB client) plus hand-rolled twins in display, virtio-gpu, pci-bus, and usb-xhci-bus. Extract it once as a runtime client, runtime.device_manager.hello(role, device_id) ?Handle — returns the manager endpoint (bus drivers keep it to report children through), null when there is no manager or it refused the handshake, and logs the outcome itself so each call site is one line. Also correct two roles while collapsing their calls: virtio-gpu and the display driver each claim one PCI function and report no children, so they are Role.device, not Role.bus. The manager ignores role today, so this is cosmetic, but it matches the protocol's own definition (bus = reports children via child_added). Behavior-preserving otherwise: pci-bus and usb-xhci-bus move their hello logging from raw serial writes to std.log, which the kernel renders with the same "<path>: " prefix, so driver-restart still matches "usb-xhci-bus: hello acknowledged". zig build clean; 8 QEMU cases pass (driver-restart, pci-scan, usb-hid, usb-storage, virtio-gpu, display-reattach, device-list, device-manager).
87 lines
4.5 KiB
Zig
87 lines
4.5 KiB
Zig
//! danos user-space runtime library — a nascent libc. Every user binary (init,
|
|
//! and later the VFS server + device drivers) imports this as `@import("runtime")`:
|
|
//! system_call wrappers, the C-convention heap, IPC helpers, and the process start
|
|
//! shim. It is compiled into each binary (inheriting its `.large` code model and
|
|
//! freestanding target), so all user programs share one implementation.
|
|
//!
|
|
//! A user binary only defines a `pub fn main() void` or
|
|
//! `pub fn main(init: runtime.process.Init) void` (arguments arrive via `init`).
|
|
//! The panic handler and the `_start` entry pull live in the shared compilation
|
|
//! root, library/runtime/root.zig, which build.zig wires around every program —
|
|
//! nothing to declare per source file.
|
|
|
|
pub const system = @import("system.zig");
|
|
pub const log = @import("log.zig");
|
|
/// Monotonic time, delays, and deadlines over the kernel clock/sleep/timer syscalls
|
|
/// — an `Instant`/`Duration` front door, no time service (docs/timers.md).
|
|
pub const time = @import("time.zig");
|
|
pub const heap = @import("heap.zig");
|
|
pub const ipc = @import("ipc.zig");
|
|
pub const start = @import("start.zig");
|
|
/// The VFS wire protocol (shared with the VFS server).
|
|
pub const vfs_protocol = @import("vfs-protocol");
|
|
|
|
/// The device-manager protocol: hello + tree reports (docs/device-manager.md).
|
|
pub const device_manager_protocol = @import("device-manager-protocol");
|
|
/// Client for talking to the device manager (the hello handshake a supervised
|
|
/// driver owes at startup). See library/runtime/device-manager.zig.
|
|
pub const device_manager = @import("device-manager.zig");
|
|
|
|
/// The power protocol: events (button, lid, battery) + shutdown (docs/power.md).
|
|
pub const power_protocol = @import("power-protocol");
|
|
/// Keyboard-event listening (subscribe/next) and broadcasting (publish), over the input
|
|
/// service. See library/runtime/input.zig and system/services/input/.
|
|
pub const input = @import("input.zig");
|
|
/// The input wire protocol (shared with the input service and its clients).
|
|
pub const input_protocol = @import("input-protocol");
|
|
/// POSIX-style file API: open/read/write/lseek/stat/close.
|
|
/// C stdio: fopen/fread/fwrite/fseek/ftell/fclose over unistd.
|
|
/// Device access for drivers: enumerate/claim/mmioMap.
|
|
pub const device = @import("device.zig");
|
|
/// DMA-capable memory for drivers: contiguous, pinned, uncacheable buffers.
|
|
pub const dma = @import("dma.zig");
|
|
|
|
/// Shared cacheable memory: create a region + capability, pass the capability to another
|
|
/// process (an `ipc_call` send_cap), map the same pages there. See library/runtime/shared-memory.zig
|
|
/// and docs/display-v2.md.
|
|
pub const shared_memory = @import("shared-memory.zig");
|
|
|
|
/// USB class-driver client: open a device on the xHCI bus and drive it
|
|
/// (control / interrupt / bulk transfers). See library/runtime/usb.zig.
|
|
pub const usb = @import("usb.zig");
|
|
|
|
/// Block-device client: read/write a block device (a USB stick, via
|
|
/// usb-storage). See library/runtime/block.zig.
|
|
pub const block = @import("block.zig");
|
|
|
|
/// Display-service client: query the mode, and (from D3) create layers, draw, and
|
|
/// present frames. See library/runtime/display.zig and system/services/display/.
|
|
pub const display = @import("display.zig");
|
|
/// The display wire protocol (shared with the display service and its clients).
|
|
pub const display_protocol = @import("display-protocol");
|
|
/// The scanout wire protocol: the compositor's present channel to a native scanout driver
|
|
/// (virtio-gpu). See system/services/display/scanout-protocol.zig and docs/display-v2.md.
|
|
pub const scanout_protocol = @import("scanout-protocol");
|
|
|
|
/// The danos-native file API (open/read/write/list over the user-space VFS) — the
|
|
/// layer danos programs use directly, and where the operations that later become
|
|
/// `std.os.danos` are staged. See docs/zig-self-hosting.md.
|
|
pub const fs = @import("fs.zig");
|
|
|
|
/// Re-exported so the root shim (root.zig) can install it as the panic handler.
|
|
pub const panic = start.panic;
|
|
|
|
/// Process entry types: the `Init` handed to `main`, and its `Arguments`.
|
|
pub const process = @import("process.zig");
|
|
|
|
/// Threads: `runtime.Thread`, std.Thread-shaped, over the private thread ABI
|
|
/// (docs/threading.md). A binary must be built multi-threaded to spawn.
|
|
pub const Thread = @import("thread.zig").Thread;
|
|
|
|
/// The service harness: one replyWait loop folding requests, signals, and
|
|
/// notifications into callbacks (docs/process-lifecycle.md).
|
|
pub const service = @import("service.zig");
|
|
|
|
/// The heap as a `std.mem.Allocator`, for Zig `std` containers in user code.
|
|
pub const allocator = heap.allocator;
|