From 794a8b5782056b619a9773f70fe206230794e569 Mon Sep 17 00:00:00 2001 From: Daniel Samson <12231216+daniel-samson@users.noreply.github.com> Date: Wed, 22 Jul 2026 20:36:24 +0100 Subject: [PATCH] reorg: move device data modules into library/device// MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit First step of the device-code reorganization (plan: group device code by domain, split each domain into a shareable data module + a logic module). This moves the pure-data modules — the enums, wire types, and taxonomies that any layer including the kernel can import cheaply — out of system/devices/ and into their domain home: device-abi -> library/device/model/device-abi.zig pci-class -> library/device/pci/pci-class.zig usb-abi -> library/device/usb/usb-abi.zig usb-ids -> library/device/usb/usb-ids.zig acpi-ids -> library/device/acpi/acpi-ids.zig aml/ -> library/device/acpi/aml/ Module names are unchanged, so this is a pure file move: only the b.addModule paths and the host-test file list in build.zig change; no importer is touched. system/devices/ now holds only the kernel-internal device model (device-model, platform, acpi, device-tree, power). The device *logic* (the pci Function helper, the usb transfer client) and the kernel's cosmetic taxonomy dependency are handled in following commits. zig build + zig build test green. --- build.zig | 24 +++++++++---------- .../device/acpi}/acpi-ids.zig | 0 .../device/acpi}/aml/aml.zig | 0 .../device/acpi}/aml/interpreter.zig | 0 .../device/acpi}/aml/namespace.zig | 0 .../device/acpi}/aml/opcodes.zig | 0 .../device/acpi}/aml/parser.zig | 0 .../device/model}/device-abi.zig | 0 .../device/pci}/pci-class.zig | 0 .../device/usb}/usb-abi.zig | 0 .../device/usb}/usb-ids.zig | 0 11 files changed, 12 insertions(+), 12 deletions(-) rename {system/devices => library/device/acpi}/acpi-ids.zig (100%) rename {system/devices => library/device/acpi}/aml/aml.zig (100%) rename {system/devices => library/device/acpi}/aml/interpreter.zig (100%) rename {system/devices => library/device/acpi}/aml/namespace.zig (100%) rename {system/devices => library/device/acpi}/aml/opcodes.zig (100%) rename {system/devices => library/device/acpi}/aml/parser.zig (100%) rename {system/devices => library/device/model}/device-abi.zig (100%) rename {system/devices => library/device/pci}/pci-class.zig (100%) rename {system/devices => library/device/usb}/usb-abi.zig (100%) rename {system/devices => library/device/usb}/usb-ids.zig (100%) diff --git a/build.zig b/build.zig index 038fa16..2df21ca 100644 --- a/build.zig +++ b/build.zig @@ -280,12 +280,12 @@ pub fn build(b: *std.Build) void { // its own module like vfs-protocol — importable by user space, unlike the // kernel-internal device model it also feeds (system/devices/device-model.zig). const device_abi_module = b.addModule("device-abi", .{ - .root_source_file = b.path("system/devices/device-abi.zig"), + .root_source_file = b.path("library/device/model/device-abi.zig"), }); // PCI class-code decoding (class/subclass/prog-IF -> names). Pure reference data, // shared by kernel discovery (the device-tree dump) and any user-space PCI tool. const pci_class_module = b.addModule("pci-class", .{ - .root_source_file = b.path("system/devices/pci-class.zig"), + .root_source_file = b.path("library/device/pci/pci-class.zig"), }); // ACPI/PnP hardware-ID (_HID) names — the flat analog of pci-class for acpi_device // nodes. Also shared reference data. @@ -293,11 +293,11 @@ pub fn build(b: *std.Build) void { // same parser the kernel does (docs/discovery.md — the shared AML module). // Pure Zig, no kernel imports — one source, two builds. const aml_module = b.addModule("aml", .{ - .root_source_file = b.path("system/devices/aml/aml.zig"), + .root_source_file = b.path("library/device/acpi/aml/aml.zig"), }); const acpi_ids_module = b.addModule("acpi-ids", .{ - .root_source_file = b.path("system/devices/acpi-ids.zig"), + .root_source_file = b.path("library/device/acpi/acpi-ids.zig"), }); // The USB device-framework wire ABI (chapter-9 set-up packets, standard + @@ -305,10 +305,10 @@ pub fn build(b: *std.Build) void { // reference the xHCI bus driver, the USB class drivers, and the device // manager's identity matcher all share. Pure data, like pci-class/acpi-ids. const usb_abi_module = b.addModule("usb-abi", .{ - .root_source_file = b.path("system/devices/usb-abi.zig"), + .root_source_file = b.path("library/device/usb/usb-abi.zig"), }); const usb_ids_module = b.addModule("usb-ids", .{ - .root_source_file = b.path("system/devices/usb-ids.zig"), + .root_source_file = b.path("library/device/usb/usb-ids.zig"), }); // The USB transfer protocol: what a USB class driver says to the xHCI bus // driver to drive its device (open / control / interrupt / bulk). A protocol @@ -919,12 +919,12 @@ pub fn build(b: *std.Build) void { "system/boot-handoff.zig", "system/abi.zig", "system/initial-ramdisk.zig", // v2 path-named entries: find/basename/magic - "system/devices/device-abi.zig", - "system/devices/pci-class.zig", // class/subclass/prog-IF name decoding - "system/devices/acpi-ids.zig", // _HID name decoding - "system/devices/aml/aml.zig", // AML parse + interpret, incl. Notify dispatch (M21) - "system/devices/usb-abi.zig", // wire sizes + bit packings + set-up packet encodings - "system/devices/usb-ids.zig", // class/subclass/protocol code assignments + "library/device/model/device-abi.zig", + "library/device/pci/pci-class.zig", // class/subclass/prog-IF name decoding + "library/device/acpi/acpi-ids.zig", // _HID name decoding + "library/device/acpi/aml/aml.zig", // AML parse + interpret, incl. Notify dispatch (M21) + "library/device/usb/usb-abi.zig", // wire sizes + bit packings + set-up packet encodings + "library/device/usb/usb-ids.zig", // class/subclass/protocol code assignments "library/mmio/mmio.zig", // barriers assemble + registers round-trip "system/drivers/ps2-bus/scancode.zig", // set-2 decode + keyboard state machine "system/drivers/ps2-bus/mouse-packet.zig", // 3-byte mouse packet assembly diff --git a/system/devices/acpi-ids.zig b/library/device/acpi/acpi-ids.zig similarity index 100% rename from system/devices/acpi-ids.zig rename to library/device/acpi/acpi-ids.zig diff --git a/system/devices/aml/aml.zig b/library/device/acpi/aml/aml.zig similarity index 100% rename from system/devices/aml/aml.zig rename to library/device/acpi/aml/aml.zig diff --git a/system/devices/aml/interpreter.zig b/library/device/acpi/aml/interpreter.zig similarity index 100% rename from system/devices/aml/interpreter.zig rename to library/device/acpi/aml/interpreter.zig diff --git a/system/devices/aml/namespace.zig b/library/device/acpi/aml/namespace.zig similarity index 100% rename from system/devices/aml/namespace.zig rename to library/device/acpi/aml/namespace.zig diff --git a/system/devices/aml/opcodes.zig b/library/device/acpi/aml/opcodes.zig similarity index 100% rename from system/devices/aml/opcodes.zig rename to library/device/acpi/aml/opcodes.zig diff --git a/system/devices/aml/parser.zig b/library/device/acpi/aml/parser.zig similarity index 100% rename from system/devices/aml/parser.zig rename to library/device/acpi/aml/parser.zig diff --git a/system/devices/device-abi.zig b/library/device/model/device-abi.zig similarity index 100% rename from system/devices/device-abi.zig rename to library/device/model/device-abi.zig diff --git a/system/devices/pci-class.zig b/library/device/pci/pci-class.zig similarity index 100% rename from system/devices/pci-class.zig rename to library/device/pci/pci-class.zig diff --git a/system/devices/usb-abi.zig b/library/device/usb/usb-abi.zig similarity index 100% rename from system/devices/usb-abi.zig rename to library/device/usb/usb-abi.zig diff --git a/system/devices/usb-ids.zig b/library/device/usb/usb-ids.zig similarity index 100% rename from system/devices/usb-ids.zig rename to library/device/usb/usb-ids.zig