Full USB stack implementation with interrupt-driven host controllers,
HID class drivers, mass storage, hotplug support, and HID layer
restructuring.
USB Host Controllers:
UHCI, OHCI, EHCI, XHCI drivers moved to src/driver/bus/usb/ with
full initialization, transfer queuing, and interrupt-driven completion
Each HC registers a PCI ISR, acknowledges hardware status in the
handler, and uses a re-entrancy guard to prevent ISR/poll races
Hardware interrupt handlers on all four HC types
USB Core & Hub:
New usbcore unit: device enumeration, control/bulk transfers with
timer-based timeouts, completion hook system, stall recovery
(usb_clear_halt), device tracking via per-HC linked lists,
usb_remove_device cleanup, hotplug detection (usb_check_hotplug)
New usbtypes unit: shared descriptors, constants, HC abstraction,
aligned allocation helpers
New usbhub unit: hub descriptor parsing, port power/reset/status
USB Class Drivers:
usb_keyboard: USB HID boot keyboard with HID-to-ASCII translation,
completion-hook-driven polling, 3-strike self-deactivation, disconnect
handler, dynamic device list
usb_mouse: USB HID boot mouse with delta/scroll/button processing,
completion-hook-driven polling, disconnect handler, dynamic device list
usb_storage: USB Mass Storage BOT driver with CBW/CSW transport,
SCSI INQUIRY/READ_CAPACITY/READ10/WRITE10, storagemanagement
integration via read/write callbacks, disconnect handler
HID Layer Restructuring:
keyboard.pas stripped to abstract API (hook + reportKeyEvent),
removing PS/2 dependency
mouse.pas absorbed mousestate.pas; now owns position, buttons,
scroll, and hooks directly
Moved ps2_keyboard.pas and ps2_mouse.pas units under
/driver/hid/ps2/
'USB' terminal command showing HC info, devices, speeds, and endpoints
Full USB stack implementation with interrupt-driven host controllers,
HID class drivers, mass storage, hotplug support, and HID layer
restructuring.
**USB Host Controllers:**
- UHCI, OHCI, EHCI, XHCI drivers moved to src/driver/bus/usb/ with
full initialization, transfer queuing, and interrupt-driven completion
- Each HC registers a PCI ISR, acknowledges hardware status in the
handler, and uses a re-entrancy guard to prevent ISR/poll races
- Hardware interrupt handlers on all four HC types
**USB Core & Hub:**
- New usbcore unit: device enumeration, control/bulk transfers with
timer-based timeouts, completion hook system, stall recovery
(usb_clear_halt), device tracking via per-HC linked lists,
usb_remove_device cleanup, hotplug detection (usb_check_hotplug)
- New usbtypes unit: shared descriptors, constants, HC abstraction,
aligned allocation helpers
- New usbhub unit: hub descriptor parsing, port power/reset/status
**USB Class Drivers:**
- usb_keyboard: USB HID boot keyboard with HID-to-ASCII translation,
completion-hook-driven polling, 3-strike self-deactivation, disconnect
handler, dynamic device list
- usb_mouse: USB HID boot mouse with delta/scroll/button processing,
completion-hook-driven polling, disconnect handler, dynamic device list
- usb_storage: USB Mass Storage BOT driver with CBW/CSW transport,
SCSI INQUIRY/READ_CAPACITY/READ10/WRITE10, storagemanagement
integration via read/write callbacks, disconnect handler
**HID Layer Restructuring:**
- keyboard.pas stripped to abstract API (hook + reportKeyEvent),
removing PS/2 dependency
- mouse.pas absorbed mousestate.pas; now owns position, buttons,
scroll, and hooks directly
- Moved ps2_keyboard.pas and ps2_mouse.pas units under
/driver/hid/ps2/
- PS/2 keyboard fix: properly report key-up events for break codes
(bit 7 detection, modifier release handling)
**Hotplug & Kernel Integration:**
- Disconnect callbacks (fnDisconnect) on TUSBDevice for safe unplug
- HotplugArmed/PortChangePending flags for deferred ISR-context hotplug
(OHCI RHSC, EHCI PCD, xHCI PSC)
- 'USB' terminal command showing HC info, devices, speeds, and endpoints
- New units: usbtypes, usbcore, usbhub, UHCI, OHCI, usb_keyboard,
usb_mouse
- usbtypes: shared USB descriptors, constants, HC abstraction,
aligned alloc, unit tests
- usb_keyboard: USB HID boot keyboard driver with HID-to-ASCII
translation, polling, unit tests
- usb_mouse: USB HID boot mouse driver with delta/scroll/button
processing, polling, unit tests
HID Layer Restructure:
- keyboard.pas: stripped to abstract API (hook + reportKeyEvent),
no PS/2 dependency
- mouse.pas: absorbed mousestate.pas, now owns
position/buttons/scroll/hooks directly
- mousestate.pas: deleted (merged into mouse.pas)
- New ps2_keyboard.pas: PS/2 scan code translation,
calls keyboard.reportKeyEvent
- New ps2_mouse.pas: PS/2 packet handling, calls
mouse.setMousePos/fireMouseEvent
LVGL Integration:
- lvgl.pas: updated to use mouse.pas directly (was mousestate),
improved keyboard input handling with proper key held/release tracking
- vterminal.pas: removed serial debug logging, dropped serial dependency
Kernel:
- kernel.pas: added USB units, USB polling in main loop, unit test
calls, ps2_keyboard/ps2_mouse init
Replace main-loop polling (poll_all, poll_keyboards, poll_mice) with
hardware interrupt handlers for all four USB host controller drivers.
Each HC driver (XHCI, EHCI, OHCI, UHCI) now:
- Registers an ISR on its PCI interrupt line via isrmanager
- Enables hardware interrupts after HC initialization
- Acknowledges interrupt status in the ISR before calling poll,
preventing interrupt storms on level-triggered PCI lines
- Uses a PollBusy re-entrancy guard to prevent ISR/inline poll races
usbcore gains a completion hook system (register_completion_hook /
fire_completion_hooks) so HID drivers (keyboard, mouse) are notified
directly from the ISR after transfer completion.
Files changed:
- usbcore.pas: completion hook infrastructure
- XHCI.pas: ISR, enable_interrupts, submit ordering fix
- EHCI.pas: ISR, enable_interrupts, status ack in ISR
- OHCI.pas: ISR, enable_interrupts, status ack in ISR
- UHCI.pas: ISR, enable_interrupts, status ack in ISR
- usb_keyboard.pas: register completion hook
- usb_mouse.pas: register completion hook
The PS/2 keyboard callback hardcoded is_down_code := true for every
scancode, so key releases were never reported. This caused keys to
repeat endlessly until the next key was pressed.
In PS/2 scancode set 1, bit 7 indicates a break (release) code.
The callback now:
- Detects break codes via (scancode AND $80)
- Masks to base code (scancode AND $7F) for key matrix lookup
- Sets is_down_code := false for break codes
- Updates modifier state (shift/ctrl/alt) before building the
key event, so modifier releases take effect immediately
Files changed:
- ps2_keyboard.pas: rewrite callback to handle make/break codes
- Track enumerated devices per-HC via linked list (hc^.Devices)
- Add usb_clear_halt() for endpoint stall recovery (CLEAR_FEATURE)
- Add usb_remove_device() to clean up and free device records
- Add get_hc() for indexed host controller access
- Implement 'USB' terminal command showing HC info, connected devices,
speeds, class descriptors, and endpoint details
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Full USB stack implementation with interrupt-driven host controllers,
HID class drivers, mass storage, hotplug support, and HID layer
restructuring.
USB Host Controllers:
full initialization, transfer queuing, and interrupt-driven completion
handler, and uses a re-entrancy guard to prevent ISR/poll races
USB Core & Hub:
timer-based timeouts, completion hook system, stall recovery
(usb_clear_halt), device tracking via per-HC linked lists,
usb_remove_device cleanup, hotplug detection (usb_check_hotplug)
aligned allocation helpers
USB Class Drivers:
completion-hook-driven polling, 3-strike self-deactivation, disconnect
handler, dynamic device list
completion-hook-driven polling, disconnect handler, dynamic device list
SCSI INQUIRY/READ_CAPACITY/READ10/WRITE10, storagemanagement
integration via read/write callbacks, disconnect handler
HID Layer Restructuring:
removing PS/2 dependency
scroll, and hooks directly
/driver/hid/ps2/
(bit 7 detection, modifier release handling)
Hotplug & Kernel Integration:
(OHCI RHSC, EHCI PCD, xHCI PSC)