diff options
| author | salmonik <salmonik@tuta.io> | 2026-11-01 16:33:09 +0100 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-11-01 16:33:09 +0100 |
| commit | 363e24bcd18a28948f63fa78ac8a4eaa8784fe59 (patch) | |
| tree | 6b74ab993ff42e3bf15b01f4cfd09bcb3f0d5ea6 /DEBUG_NOTES.md | |
| parent | usb: real-hardware rework — hubs, both EHCI controllers, keyboard, xHCI har... (diff) | |
| download | rs-dos-363e24bcd18a28948f63fa78ac8a4eaa8784fe59.tar.gz rs-dos-363e24bcd18a28948f63fa78ac8a4eaa8784fe59.zip | |
scripts: add test-usb; fix duplicate -bios in the test harness
- test-usb boots an EHCI and an xHCI controller with a mouse + keyboard and
asserts enumeration, report decoding, and input reaching the shell. The
EHCI case asserts one key end-to-end (QEMU's EHCI model delivers only the
first report through root-port split transactions); the xHCI case asserts a
whole typed command.
- lib.sh: qemu_args() already supplies -bios, so the fresh OVMF varstore copy
was silently overridden by the system firmware. Pass the copy last (QEMU
honours the last -bios) so tests really boot clean NVRAM.
- DEBUG_NOTES: document why USB never worked on the OptiPlex (EHCI shipped
with DEBUG_MATRIX enabled, no RMH/hub support, only the first controller,
no boot protocol, unbounded DMA), the success/failure log to look for on
hardware, and the QEMU coverage limits.
- Makefile: add test-usb and include it in `make test`.
Diffstat (limited to '')
| -rw-r--r-- | DEBUG_NOTES.md | 90 |
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 | ||
| 543 | Periodic schedule: 2200+ EXECUTEs/frame with 0 qtd halts; idle mouse NAKs. | 543 | Periodic 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 | |||
| 551 | 1. **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. | ||
| 555 | 2. **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). | ||
| 560 | 3. **Only the first EHCI was initialized** (`find_ehci()` returned the first | ||
| 561 | match). The 7010 has two: `00:1a.0` and `00:1d.0`. | ||
| 562 | 4. **No `SET_PROTOCOL(boot)`** on EHCI/xHCI; UHCI asked for report protocol | ||
| 563 | (`wValue=1`). Report protocol layouts are device-defined. | ||
| 564 | 5. **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. | ||
| 566 | 6. **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 | ``` | ||
| 588 | ehci: 00:1a.0 mmio=… ports=… 64-bit-caps=… | ||
| 589 | ehci: USB legacy handed over by BIOS | ||
| 590 | ehci: controller up (… ports) | ||
| 591 | ehci: port N connected (high-speed) | ||
| 592 | ehci: dev 8087:0024 class=0x9 … addr=1 ← rate matching hub | ||
| 593 | ehci: hub addr=1 ports=8 | ||
| 594 | ehci: hub port K: full-speed device (split) | ||
| 595 | ehci: dev …:… class=0x0 … addr=2 sp=0 (split) | ||
| 596 | ehci: HID mouse armed (addr 2 ep0x81 mps … ) | ||
| 597 | ehci: periodic schedule enabled (1 device(s) on ctrl 0) | ||
| 598 | ehci: mouse report dx=… dy=… b=0x… | ||
| 599 | ``` | ||
| 600 | |||
| 601 | Then the same on `00:1d.0` for the keyboard, and `> ` followed by typed keys. | ||
| 602 | Failure 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). | ||
