Hello,
I have been working on hurd-xhci, an experimental native userspace USB 3.0
(xHCI) driver stack for GNU Hurd (tested on Debian GNU/Hurd x86_64),
and would appreciate feedback from the Hurd developers.
The stack is split into three modular libtrivfs-based translators that
communicate over a binary URB protocol carried by io_write/io_read:
1. xhci (/dev/xhci0) -- host controller driver:
- Discovers xHCI controllers (class 0x0c0330) and maps BAR0 MMIO via
libpciaccess (pci-arbiter), without direct port I/O.
- Allocates physically contiguous DMA memory for DCBAA, controller
rings, device contexts and scratchpad buffers via GNU Mach
(vm_allocate_contiguous).
- Masks MSI/MSI-X in PCI config space and handles legacy INTx
interrupts via IO-APIC GSI (device_open("irq") +
device_intr_register + device_intr_ack in a dedicated pthread loop).
- Performs root hub port enumeration and serves device listings on
plain io_read while handling binary URB requests (Control, Bulk,
Interrupt, Add Endpoint) on io_write/io_read.
2. umass (/dev/usb0) -- USB Mass Storage class driver:
- Implements Bulk-Only Transport and basic SCSI commands (INQUIRY,
TEST UNIT READY, REQUEST SENSE, READ CAPACITY (10), READ/WRITE 10)
with stall and phase-error recovery.
- Exposes a file-backed block node supporting arbitrary byte offsets
and lengths, tested with mkfs.ext2 and /hurd/ext2fs -T file.
3. usbhid (/dev/usbhid0, /dev/usbmouse0) -- USB HID class driver:
- Implements USB HID Boot Protocol for keyboards (ASCII/ANSI escape
sequences) and mice (3-byte PS/2 packets), supporting blocking/
non-blocking reads, io_readable, and select/poll.
Source code and build/test instructions (GPLv2+):
https://git.disroot.org/slavagnu/hurd-xhci
Example session under QEMU (-device qemu-xhci):
$ cat /dev/xhci0
xhci 1.00 slots 64 ports 8
slot 1 port 1 speed super 46f4:0001 class 00/00/00
slot 2 port 6 speed high 0627:0001 class 00/00/00
slot 3 port 7 speed high 0627:0001 class 00/00/00
I understand that the primary driver direction in Hurd has been the
NetBSD rump kernel approach, so I would like to ask:
- Does a lightweight native userspace xHCI/USB stack make sense alongside
rump, or could parts of it be useful in hurd / incubator?
- Are there any subtleties in Mach port reference counting, DMA memory
cleanup, or GSI interrupt acknowledgement that should be tightened up?
I am happy to complete the FSF copyright assignment if any part of this
code is suitable for upstream inclusion.
Best regards,
slavagnu