diff --git a/.zig-version b/.zig-version deleted file mode 100644 index 04a373e..0000000 --- a/.zig-version +++ /dev/null @@ -1 +0,0 @@ -0.16.0 diff --git a/system/drivers/ps2-bus/mouse.zig b/system/drivers/ps2-bus/mouse.zig index 0d7736e..fa12d35 100644 --- a/system/drivers/ps2-bus/mouse.zig +++ b/system/drivers/ps2-bus/mouse.zig @@ -60,7 +60,7 @@ pub fn main(init: runtime.process.Init) void { _ = runtime.system.write("/system/drivers/ps2-bus/mouse: out of memory\n"); return; }; - if (device.findDeviceDescriptorByHid(buffer, hid) == null) { + if (ps2.findMouseDescriptor(buffer) == null) { writeLine("/system/drivers/ps2-bus/mouse: no device for hid {s}\n", .{hid}); return; } diff --git a/system/drivers/ps2-bus/ps2-bus.zig b/system/drivers/ps2-bus/ps2-bus.zig index d363e1c..1ed6ee1 100644 --- a/system/drivers/ps2-bus/ps2-bus.zig +++ b/system/drivers/ps2-bus/ps2-bus.zig @@ -244,7 +244,7 @@ pub fn main() void { // to the *port*, whatever device identify found on it. var maybe_auxiliary_interrupt: ?struct { device_id: u64, interrupt_index: u64, gsi: u64 } = null; if (port_device_types[@intFromEnum(ps2.Port.two)] != null) { - if (device.findDeviceDescriptorByHid(buffer, acpi_ids.HardwareId.ps2_mouse.hid())) |descriptor| { + if (ps2.findMouseDescriptor(buffer)) |descriptor| { if (findInterruptResourceIndex(descriptor)) |auxiliary_index| { if (device.claim(descriptor.id) and device.irqBind(descriptor.id, auxiliary_index, endpoint)) { maybe_auxiliary_interrupt = .{ diff --git a/system/drivers/ps2-bus/ps2-library.zig b/system/drivers/ps2-bus/ps2-library.zig index 0eeac4d..616814d 100644 --- a/system/drivers/ps2-bus/ps2-library.zig +++ b/system/drivers/ps2-bus/ps2-library.zig @@ -270,6 +270,22 @@ pub const DeviceType = enum(u32) { } }; +/// The `_HID`s a PS/2 pointing device (the controller's aux channel) can enumerate +/// under. It is the same 8042 mouse channel whichever id the firmware chose: +/// QEMU/OVMF report the generic `.ps2_mouse` (PNP0F13), VirtualBox reports +/// `.microsoft_ps2_mouse` (PNP0F03). Both mean "the mouse on port two". +pub const mouse_hardware_ids = [_]acpi_ids.HardwareId{ .ps2_mouse, .microsoft_ps2_mouse }; + +/// Find the aux (mouse) device's ACPI node, whichever of the PS/2-mouse `_HID`s the +/// firmware used — the bus needs it to bind IRQ12, and the mouse driver to confirm +/// its device is present. Returns the first match, or null if none is reported. +pub fn findMouseDescriptor(buffer: []device.DeviceDescriptor) ?device.DeviceDescriptor { + for (mouse_hardware_ids) |id| { + if (device.findDeviceDescriptorByHid(buffer, id.hid())) |descriptor| return descriptor; + } + return null; +} + // --- the bus <-> child-driver forwarding protocol ----------------------------- // // The 8042's ports and IRQ1 live on the PNP0303 node that only the ps2-bus driver