reorg: extract library/device/pci — the claimed-function view
New pci logic module (library/device/pci/pci.zig): a device driver's view of the one PCI function it has claimed — Function.map (config space = resource 0), vendorId/deviceId/command/status, enableMemoryAndBusMaster, mapBar (BAR decode + resource correlation + mmio_map, cached), and a capabilities() iterator. The generic PCI mechanics every leaf PCI driver used to re-derive inline. The config-space layout it needs — header offsets, the command MEM|bus-master bits, the status capabilities-list bit, the capability-pointer mask, and the BAR bit fields — is named in the pci-class data module (a "Configuration-space layout" section), so the bus enumerator can share the same constants later. virtio-gpu is the first consumer: its inline mapBar + walkCapabilities + config header reads are gone, replaced by pci.Function; only the virtio-specific cfg_type dispatch (and the virtio common-config cfgRead/cfgWrite, which are NOT PCI config space) stay in the driver. The generic display driver will use the same module. pci-bus's enumerator (arbitrary-function probing) is untouched. zig build + test green; virtio-gpu, display-native, display-reattach, pci-scan pass.
This commit is contained in:
@@ -436,6 +436,19 @@ pub fn build(b: *std.Build) void {
|
||||
.root_source_file = b.path("library/mmio/mmio.zig"),
|
||||
});
|
||||
|
||||
// A device driver's view of its claimed PCI function: config-space header fields, BAR
|
||||
// decode + map, and the capability walk (library/device/pci/pci.zig). The generic PCI
|
||||
// mechanics every leaf PCI driver used to re-derive inline. Imports runtime (device
|
||||
// access) + mmio + the pci-class data module (config-space layout constants).
|
||||
const pci_module = b.addModule("pci", .{
|
||||
.root_source_file = b.path("library/device/pci/pci.zig"),
|
||||
.imports = &.{
|
||||
.{ .name = "runtime", .module = runtime_module },
|
||||
.{ .name = "mmio", .module = mmio_module },
|
||||
.{ .name = "pci-class", .module = pci_class_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.
|
||||
@@ -550,6 +563,7 @@ pub fn build(b: *std.Build) void {
|
||||
const display_exe = addThreadedUserBinary(b, kernel_target, runtime_module, mmio_module, xkeyboard_config_module, acpi_ids_module, "display", "system/services/display/display.zig");
|
||||
const display_demo_exe = addUserBinary(b, kernel_target, runtime_module, mmio_module, xkeyboard_config_module, acpi_ids_module, "display-demo", "system/services/display-demo/display-demo.zig");
|
||||
const virtio_gpu_exe = addUserBinary(b, kernel_target, runtime_module, mmio_module, xkeyboard_config_module, acpi_ids_module, "virtio-gpu", "system/drivers/virtio-gpu/virtio-gpu.zig");
|
||||
programModule(virtio_gpu_exe).addImport("pci", pci_module); // library/device/pci — the claimed-function view
|
||||
const shared_memory_server_exe = addUserBinary(b, kernel_target, runtime_module, mmio_module, xkeyboard_config_module, acpi_ids_module, "shared-memory-server", "system/services/shared-memory-server/shared-memory-server.zig");
|
||||
const shared_memory_client_exe = addUserBinary(b, kernel_target, runtime_module, mmio_module, xkeyboard_config_module, acpi_ids_module, "shared-memory-client", "system/services/shared-memory-client/shared-memory-client.zig");
|
||||
const fat_test_exe = addUserBinary(b, kernel_target, runtime_module, mmio_module, xkeyboard_config_module, acpi_ids_module, "fat-test", "system/services/fat/fat-test.zig");
|
||||
|
||||
Reference in New Issue
Block a user