device-manager: data-driven driver matching via /etc/devices.csv

Replace the three hardcoded switch tables (pciDriverForIdentity, hidDriverFor,
usbDriverForIdentity) with an authoritative, human-readable device registry the
manager reads at boot. Matching is most-specific-wins across
base/subclass/prog_if/vendor/device/subsystem/hid, so a precise vendor:device
rule and a generic class rule coexist; an unmatched device is logged, never
guessed. This resolves docs' "matching stays code until the third bus".

- ABI: child_added and DeviceDescriptor gain vendor/device/subsystem; child_added
  gains a bus discriminator (BusKind) so PCI and USB class triples match against
  the right namespace.
- pci-bus reads vendor/device (config 0x00) and subsystem (0x2C, type-0) and
  reports them.
- library/device/registry: freestanding CSV parser + matchDriver() with
  specificity scoring; 5 unit tests wired into `zig build test`.
- etc/devices.csv bundled into the initrd; the kernel serves /etc directly, so
  the manager reads it before any filesystem service is up (fat starts later).
- virtio-gpu: drop the now-redundant post-spawn 1AF4:1050 re-confirm, since the
  registry binds this driver by exact identity.
- Remove the orphaned system/drivers/display driver (unreferenced by build or
  registry).
- docs: new devices-csv.md; device-manager.md "matching stays code" resolved.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KJqSiLLchDUUCoXn5jsiwd
This commit is contained in:
2026-07-26 16:43:13 +01:00
co-authored by Claude Opus 4.8
parent bf0c3fd3e0
commit 203528c8a7
14 changed files with 645 additions and 245 deletions
+33
View File
@@ -0,0 +1,33 @@
# /etc/devices.csv — the device→driver registry.
#
# The device manager reads this at boot and binds each device a bus driver
# reports to the driver named here. It is AUTHORITATIVE: a device that no row
# matches goes unbound (logged), never guessed. Edit this file to teach the
# system new hardware — no recompile of the device manager required.
#
# One rule per line, nine comma-separated fields. '#' starts a comment
# (whole-line or trailing); blank lines are ignored. Whitespace around a field
# is trimmed, so columns may be padded for readability.
#
# bus which bus reported the device: pci | usb | acpi
# base PCI base class / USB class (hex)
# class PCI subclass / USB subclass (hex)
# prog_if PCI prog-IF / USB protocol (hex)
# vendor PCI vendor id / USB idVendor (hex)
# device PCI device id / USB idProduct (hex)
# subsystem PCI subsystem, packed (ssvid<<16)|ssid (hex)
# hid ACPI _HID string (e.g. PNP0303); blank for pci/usb
# driver full ramdisk path of the driver to spawn
#
# '*' or an empty field is a wildcard. When several rows match one device the
# MOST SPECIFIC wins (pinning vendor/device/hid beats pinning only a class), so
# a generic class rule and a precise vendor:device rule can coexist.
#
# bus base class prog_if vendor device subsystem hid driver
pci, 0C, 03, 30, *, *, *, *, /system/drivers/usb-xhci-bus
pci, 03, 80, *, 1AF4, 1050, *, *, /system/drivers/virtio-gpu
usb, 03, 01, 01, *, *, *, *, /system/drivers/usb-hid-keyboard
usb, 03, 01, 02, *, *, *, *, /system/drivers/usb-hid-mouse
usb, 08, 06, 50, *, *, *, *, /system/drivers/usb-storage
acpi, *, *, *, *, *, *, PNP0303, /system/drivers/ps2-bus
acpi, *, *, *, *, *, *, PNP0F13, /system/drivers/ps2-bus
1 # /etc/devices.csv — the device→driver registry.
2 #
3 # The device manager reads this at boot and binds each device a bus driver
4 # reports to the driver named here. It is AUTHORITATIVE: a device that no row
5 # matches goes unbound (logged), never guessed. Edit this file to teach the
6 # system new hardware — no recompile of the device manager required.
7 #
8 # One rule per line, nine comma-separated fields. '#' starts a comment
9 # (whole-line or trailing); blank lines are ignored. Whitespace around a field
10 # is trimmed, so columns may be padded for readability.
11 #
12 # bus which bus reported the device: pci | usb | acpi
13 # base PCI base class / USB class (hex)
14 # class PCI subclass / USB subclass (hex)
15 # prog_if PCI prog-IF / USB protocol (hex)
16 # vendor PCI vendor id / USB idVendor (hex)
17 # device PCI device id / USB idProduct (hex)
18 # subsystem PCI subsystem, packed (ssvid<<16)|ssid (hex)
19 # hid ACPI _HID string (e.g. PNP0303); blank for pci/usb
20 # driver full ramdisk path of the driver to spawn
21 #
22 # '*' or an empty field is a wildcard. When several rows match one device the
23 # MOST SPECIFIC wins (pinning vendor/device/hid beats pinning only a class), so
24 # a generic class rule and a precise vendor:device rule can coexist.
25 #
26 # bus base class prog_if vendor device subsystem hid driver
27 pci, 0C, 03, 30, *, *, *, *, /system/drivers/usb-xhci-bus
28 pci, 03, 80, *, 1AF4, 1050, *, *, /system/drivers/virtio-gpu
29 usb, 03, 01, 01, *, *, *, *, /system/drivers/usb-hid-keyboard
30 usb, 03, 01, 02, *, *, *, *, /system/drivers/usb-hid-mouse
31 usb, 08, 06, 50, *, *, *, *, /system/drivers/usb-storage
32 acpi, *, *, *, *, *, *, PNP0303, /system/drivers/ps2-bus
33 acpi, *, *, *, *, *, *, PNP0F13, /system/drivers/ps2-bus