summaryrefslogtreecommitdiffstats
path: root/DEBUG_NOTES.md
diff options
context:
space:
mode:
Diffstat (limited to 'DEBUG_NOTES.md')
-rw-r--r--DEBUG_NOTES.md90
1 files changed, 90 insertions, 0 deletions
diff --git a/DEBUG_NOTES.md b/DEBUG_NOTES.md
index 5730ca5..b7c0e08 100644
--- a/DEBUG_NOTES.md
+++ b/DEBUG_NOTES.md
@@ -541,3 +541,93 @@ ehci: HID boot mouse armed (device 1)
541``` 541```
542 542
543Periodic schedule: 2200+ EXECUTEs/frame with 0 qtd halts; idle mouse NAKs. 543Periodic schedule: 2200+ EXECUTEs/frame with 0 qtd halts; idle mouse NAKs.
544
545---
546
547## 🔌 USB real-hardware status (OptiPlex 7010 / Q77) — v0.6.x rework
548
549### Why USB "straight out did not work"
550
5511. **EHCI was disabled in the shipped build.** `ehci.rs` had
552 `static DEBUG_MATRIX: bool = true` (since `be868a4`): every boot ran the
553 one-shot transfer-variant bisection matrix and then `return false` before
554 enumerating. No committed build had ever brought an EHCI device up.
5552. **No hub support.** On 7-series PCH the EHCI root port presents the
556 **integrated Rate Matching Hub** (8087:0024, device class 9); FS/LS mice
557 and keyboards sit *behind* it. The driver read the RMH's descriptors,
558 found no HID endpoint and gave up. Split transactions were hardcoded to
559 hub address 0 + root port (the QEMU topology).
5603. **Only the first EHCI was initialized** (`find_ehci()` returned the first
561 match). The 7010 has two: `00:1a.0` and `00:1d.0`.
5624. **No `SET_PROTOCOL(boot)`** on EHCI/xHCI; UHCI asked for report protocol
563 (`wValue=1`). Report protocol layouts are device-defined.
5645. **EHCI DMA had no <4 GiB bound** (32-bit DMA pointers), while the page
565 bitmap spans all RAM. A buffer above 4 GiB silently breaks transfers.
5666. **xHCI**: no scratchpad buffers (HCSPARAMS2), `MaxSlotsEn=1`, and DMA
567 from the heap allocator rather than physical pages.
568
569### What the drivers do now
570
571- `ehci.rs`: both controllers; hub class requests (power / reset / status);
572 TT splits with the hub address + child port; HID mouse **and** keyboard;
573 boot protocol; per-device periodic QH (chained into the frame list);
574 DMA from `alloc_pages_range(16 MiB, 4 GiB)`; 2 ms recovery after
575 `SET_ADDRESS`.
576- `usb.rs` (xHCI): scratchpad buffers, `MaxSlotsEn = min(MaxSlots, 4)`,
577 per-slot EP0 + interrupt rings, page-allocator DMA, boot protocol,
578 mouse + keyboard.
579- `hid.rs`: shared HID boot-keyboard decoding (one scancode FIFO feeding
580 `ps2::feed_scancode`), used by UHCI, EHCI and xHCI.
581- First-report lines are logged (`ehci: mouse report …`, `usb: kbd report …`)
582 and the `usb` shell command lists controller(s) and device(s) with
583 armed/fails/reports counters.
584
585### OptiPlex 7010 — expected serial log (success path)
586
587```
588ehci: 00:1a.0 mmio=… ports=… 64-bit-caps=…
589ehci: USB legacy handed over by BIOS
590ehci: controller up (… ports)
591ehci: port N connected (high-speed)
592ehci: dev 8087:0024 class=0x9 … addr=1 ← rate matching hub
593ehci: hub addr=1 ports=8
594ehci: hub port K: full-speed device (split)
595ehci: dev …:… class=0x0 … addr=2 sp=0 (split)
596ehci: HID mouse armed (addr 2 ep0x81 mps … )
597ehci: periodic schedule enabled (1 device(s) on ctrl 0)
598ehci: mouse report dx=… dy=… b=0x…
599```
600
601Then the same on `00:1d.0` for the keyboard, and `> ` followed by typed keys.
602Failure signatures to report:
603
604- `ehci: no EHCI controller` — PCI probe/class mismatch (should not happen).
605- `ehci: USB legacy claim timed out` — BIOS still owns the controller.
606- `ehci: hub descriptor failed` / `hub port K reset timeout` — hub class
607 request stage; note the code.
608- `ehci: get-dev-desc failed (addr 0 sp 0 tt Some(…))` — split transaction
609 did not reach the child; note the TT tuple.
610- `ehci: no HID mouse/keyboard endpoint in config` — descriptor walk.
611- `ehci: xfer fail stage=…` — transfer engine; the QR band has the state.
612
613### QEMU coverage (make test-usb)
614
615- EHCI root-port FS mouse/keyboard (split path), two devices chained.
616- xHCI mouse/keyboard on two slots.
617- Keyboard report → scancode → WM → shell echo is asserted in both cases.
618- **Not coverable in QEMU**: an EHCI high-speed hub (`usb-hub` is FS-only and
619 refuses a HS EHCI root port), so the RMH code path is hardware-only.
620- **QEMU EHCI split limit**: for full/low-speed devices behind root-port
621 split transactions QEMU delivers only the *first* report (125 NAKs after
622 it, even though the qTD is re-armed). The re-arm shape is the standard one
623 (`qh->next_qtd = qtd`, qTD re-activated; the HC owns the status/toggle
624 overlay), so `test-usb` asserts one key end-to-end on EHCI and a full
625 command on xHCI.
626
627### Known gaps
628
629- EHCI: hub support is one level deep; no hotplug once a device of that kind
630 is armed; no isochronous/other transfer types.
631- xHCI: no hub support; no USB3 warm-reset subtleties beyond the current
632 port-reset sequence.
633- AHCI/PS2 behaviour unchanged (PS/2 remains the fallback input path).