feat(usb): a USB keyboard -- a full one -- and no hang on a PC without PS/2

boards/BRINGUP.md A3 and S3, FABRIC-3 SXLI.  A HID boot keyboard is
configured (interrupt IN endpoint, SET_PROTOCOL boot) and its reports
become the same Linux-keycode events as PS/2 and virtio (usb_kbd.c): the
full layout -- F-keys, navigation block, arrows, Num Lock, keypad.  The
console treats Caps and Num Lock as toggles shown on the keyboard's
lights, and the keypad as digits or navigation.  While a USB keyboard
runs, its event ring is serviced every tick, not once a second.

Found on the way: with no i8042 (port 0x64 reads 0xFF) the kernel hung at
boot in an endless drain -- a legacy-free PC would stop there.  Detected
and skipped now; drains bounded.

QEMU, amd64 with the USB keyboard the only one: 1 2 + . on main keys and
keypad, Caps Lock, Num Lock all right; aarch64/riscv64 configure it too.
Acceptance on three ISAs unchanged; identities hot-plug.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rajames
2026-10-14 14:04:33 -04:00
co-authored by Claude Opus 5.5
parent 080b7012ba
commit 739cb9c163
30 changed files with 82072 additions and 14 deletions
+6
View File
@@ -23,6 +23,7 @@
#if defined(__STARKERNEL__)
#include "starkernel/console.h"
#include "starkernel/usb_kbd.h" /* usb_kbd_pop_event() -- A3 */
#endif
/* KBD-SCAN ( -- c -1 | 0 ) */
@@ -129,6 +130,11 @@ static void kbw_vdebug(VM *vm)
* codes set bit 7 instead of carrying a separate field). */
int sk_key_event_poll(uint16_t *keycode, int *pressed)
{
#if defined(__STARKERNEL__)
/* A USB boot keyboard, on any architecture (2026-10-14,
* boards/BRINGUP.md A3): already in Linux keycodes (usb_kbd.c). */
if (usb_kbd_pop_event(keycode, pressed)) return 1;
#endif
#if defined(__STARKERNEL__) && defined(ARCH_AMD64)
uint8_t sc;
if (i8042_pop_scancode(&sc)) {