WIP: ps2 bus driver

This commit is contained in:
Daniel Samson
2026-07-11 04:19:03 +01:00
parent e499f500c3
commit b42d572d78
8 changed files with 221 additions and 16 deletions
@@ -13,6 +13,7 @@
//! kernel still auto-spawns the whole initial-ramdisk at boot; increment 3 removes
//! that redundancy so the manager is the sole owner of driver spawning.)
const std = @import("std");
const runtime = @import("runtime");
const device = runtime.device;
@@ -20,8 +21,13 @@ const device = runtime.device;
/// this comes from the drivers describing what they bind (or a manifest under
/// /system/drivers); for now it is a small static map, which is enough to prove the
/// manager reads the tree and decides. `null` = no driver for this class yet.
fn driverFor(class: u64) ?[]const u8 {
if (class == @intFromEnum(device.DeviceClass.timer)) return "hpet"; // the HPET
fn driverFor(d: device.DeviceDescriptor) ?[]const u8 {
// detect device via DeviceClass
if (d.class == @intFromEnum(device.DeviceClass.timer)) return "hpet";
// detect device via hid
const hid = d.hid[0..@intCast(d.hid_len)];
if (std.mem.eql(u8, hid, "PNP0303") or std.mem.eql(u8, hid, "PNP0F13")) return "ps2-bus";
return null;
}
@@ -34,10 +40,9 @@ pub fn main() void {
const total = device.enumerate(buffer);
const count = @min(total, buffer.len);
var matched: usize = 0;
for (buffer[0..count]) |descriptor| {
const driver_name = driverFor(descriptor.class) orelse continue;
matched += 1;
const driver_name = driverFor(descriptor) orelse continue;
if (runtime.system.spawn(driver_name)) {
_ = runtime.system.write("device-manager: spawned ");
_ = runtime.system.write(driver_name);
@@ -49,10 +54,6 @@ pub fn main() void {
}
}
if (matched == 0) {
_ = runtime.system.write("device-manager: no matchable devices\n");
return;
}
_ = runtime.system.write("device-manager: ok\n");
while (true) runtime.system.sleep(1000);
}