diff --git a/system/drivers/usb-xhci-bus/usb-xhci-bus.zig b/system/drivers/usb-xhci-bus/usb-xhci-bus.zig index 313a92c..fae9393 100644 --- a/system/drivers/usb-xhci-bus/usb-xhci-bus.zig +++ b/system/drivers/usb-xhci-bus/usb-xhci-bus.zig @@ -200,10 +200,6 @@ fn scanPorts(manager: runtime.ipc.Handle) void { }; std.log.info("{d} root-hub ports", .{engine.max_ports}); - // Diagnostic: the USB2/USB3 root-port map (xECP) + every port's raw PORTSC, - // to find a USB2 companion hub that isn't presenting a connection. - engine.dumpPortTopology(); - var port: u32 = 1; var connected: u32 = 0; while (port <= engine.max_ports) : (port += 1) { @@ -212,7 +208,10 @@ fn scanPorts(manager: runtime.ipc.Handle) void { connected += 1; bringUpPort(manager, engine, port); } - if (connected == 0) _ = runtime.system.write("/system/drivers/usb-xhci-bus: no devices connected\n"); + if (connected == 0) { + _ = runtime.system.write("/system/drivers/usb-xhci-bus: no devices connected\n"); + engine.dumpPortTopology(); // help diagnose an empty scan: the xECP map + raw PORTSC + } } /// Bring up whatever is on `port`: setup + enumerate + register/report one child @@ -272,8 +271,9 @@ fn hubPortKey(hub_slot: u8, port: u16) u32 { fn bringUpBehindHub(manager: runtime.ipc.Handle, engine: *library.Controller, hub: *library.Device, port: u16) void { const status = engine.hubPortStatusAck(hub, port) orelse return; const connected = library.Controller.hubPortConnected(status); - std.log.info("hub slot {d} port {d} status 0x{x:0>8} ({s})", .{ hub.slot_id, port, status, if (connected) "connected" else "empty" }); const existing = engine.deviceOnHubPort(hub, port); + if (connected != (existing != null)) // only when a device appears or leaves — not empty seed-sweep ports + std.log.info("hub slot {d} port {d}: {s} (status 0x{x:0>4})", .{ hub.slot_id, port, if (connected) "device connected" else "device removed", status & 0xFFFF }); if (!connected) { if (existing) |dev| tearDownHubDevice(manager, engine, dev);