reorg: move the USB client to library/device/usb (drop runtime.usb)
The USB class-driver transfer client was library/runtime/usb.zig, re-exported as runtime.usb — which compiled the USB client and usb-transfer-protocol into every user binary (init, fat, the compositor…), none of which speak USB. It is bus-family logic, not core runtime. Move it to its domain home, library/device/usb/usb.zig (module "usb"), alongside the usb-abi and usb-ids data modules; fix its internal imports to go through the runtime module; and re-export usb.abi / usb.ids so a class driver reaches the whole USB domain through one import. runtime.usb and runtime's usb-transfer-protocol import are removed; the three class drivers (usb-hid keyboard/mouse, usb-storage) import module "usb" directly. zig build + test green; usb-hid, usb-storage pass.
This commit is contained in:
@@ -403,9 +403,6 @@ pub fn build(b: *std.Build) void {
|
||||
.root_source_file = b.path("system/services/device-manager/device-manager-protocol.zig"),
|
||||
});
|
||||
runtime_module.addImport("device-manager-protocol", device_manager_protocol_module);
|
||||
// The USB transfer protocol, so runtime.usb (the class-driver client) can speak
|
||||
// it, the way runtime.input speaks the input protocol.
|
||||
runtime_module.addImport("usb-transfer-protocol", usb_transfer_protocol_module);
|
||||
// The block protocol, so runtime.block (the block-device client) can speak it.
|
||||
runtime_module.addImport("block-protocol", block_protocol_module);
|
||||
|
||||
@@ -449,6 +446,20 @@ pub fn build(b: *std.Build) void {
|
||||
},
|
||||
});
|
||||
|
||||
// The USB class-driver transfer client (library/device/usb/usb.zig): open a device on
|
||||
// the xHCI bus and drive it (control / interrupt / bulk). Bus-family logic a class
|
||||
// driver imports directly — no longer funnelled through runtime. Re-exports usb-abi /
|
||||
// usb-ids as usb.abi / usb.ids for a single USB import.
|
||||
const usb_module = b.addModule("usb", .{
|
||||
.root_source_file = b.path("library/device/usb/usb.zig"),
|
||||
.imports = &.{
|
||||
.{ .name = "runtime", .module = runtime_module },
|
||||
.{ .name = "usb-transfer-protocol", .module = usb_transfer_protocol_module },
|
||||
.{ .name = "usb-abi", .module = usb_abi_module },
|
||||
.{ .name = "usb-ids", .module = usb_ids_module },
|
||||
},
|
||||
});
|
||||
|
||||
// Keyboard layouts compiled from the X11 xkeyboard-config database into native Zig
|
||||
// (keycode + modifiers -> keysym/character). The `layouts` tables are generated by
|
||||
// tools/make-xkeyboard-config.py; `xkeyboard-config` is the hand-written API over them.
|
||||
@@ -548,12 +559,15 @@ pub fn build(b: *std.Build) void {
|
||||
// opens its device through runtime.usb (the transfer protocol) and publishes to
|
||||
// the input service. They build chapter-9 class requests from usb-abi.
|
||||
const usb_hid_keyboard_exe = addUserBinary(b, kernel_target, runtime_module, mmio_module, xkeyboard_config_module, acpi_ids_module, "usb-hid-keyboard", "system/drivers/usb-hid/keyboard.zig");
|
||||
programModule(usb_hid_keyboard_exe).addImport("usb", usb_module);
|
||||
programModule(usb_hid_keyboard_exe).addImport("usb-abi", usb_abi_module);
|
||||
const usb_hid_mouse_exe = addUserBinary(b, kernel_target, runtime_module, mmio_module, xkeyboard_config_module, acpi_ids_module, "usb-hid-mouse", "system/drivers/usb-hid/mouse.zig");
|
||||
programModule(usb_hid_mouse_exe).addImport("usb", usb_module);
|
||||
programModule(usb_hid_mouse_exe).addImport("usb-abi", usb_abi_module);
|
||||
// The USB mass-storage class driver: opens its device via runtime.usb, drives it
|
||||
// with Bulk-Only Transport + SCSI, and serves the block protocol under `.block`.
|
||||
const usb_storage_exe = addUserBinary(b, kernel_target, runtime_module, mmio_module, xkeyboard_config_module, acpi_ids_module, "usb-storage", "system/drivers/usb-storage/usb-storage.zig");
|
||||
programModule(usb_storage_exe).addImport("usb", usb_module);
|
||||
programModule(usb_storage_exe).addImport("block-protocol", block_protocol_module);
|
||||
// The FAT filesystem server: mounts the block device and serves it into the VFS
|
||||
// at /mnt/usb. Its engine (engine.zig / on-disk.zig) is imported relatively.
|
||||
|
||||
Reference in New Issue
Block a user