USB Keyboard Protocol in Pre-Boot UEFI

During the pre-boot Unified Extensible Firmware Interface (UEFI) phase, USB keyboard input relies on two interconnected mechanisms: the hardware-level USB Human Interface Device (HID) Boot Protocol and the firmware-level EFI_SIMPLE_TEXT_INPUT_PROTOCOL. This article examines how these protocols interact to facilitate user keystrokes before an operating system initializes.

The USB HID Boot Protocol

At the device and bus layer, keyboard input is governed by the USB HID Boot Protocol defined in the USB-IF Human Interface Device specification. Under normal operating system conditions, USB keyboards use dynamic "Report Protocols" that require complex parsing engines to interpret device capabilities.

Because firmware environments need to remain lightweight and minimize code complexity, the USB HID specification defines a simplified fallback: the Boot Interface. When a keyboard is queried during the pre-boot phase, the UEFI USB host stack sets the device's protocol to the Boot Protocol using a standard control transfer (SET_PROTOCOL). In this mode, the keyboard transmits keystrokes using a standardized, fixed 8-byte input report format:

  • Byte 0: Modifier keys (Ctrl, Shift, Alt, GUI).
  • Byte 1: Reserved.
  • Bytes 2–7: Up to six simultaneous keycodes representing pressed keys (6-key rollover).

This fixed format allows firmware to parse keystrokes directly without loading a full, resource-intensive HID descriptor parser.

The UEFI Console Protocol Stack

Within the UEFI firmware architecture itself, keyboard events are managed through a layered driver model:

  1. EFI_USB_IO_PROTOCOL: The underlying UEFI USB bus driver detects the keyboard and provides this protocol instance, enabling low-level USB transfers (control and interrupt endpoints).
  2. UEFI USB Keyboard Driver: This driver binds to the EFI_USB_IO_PROTOCOL of any USB device advertising a Boot Interface class code. It sets up an interrupt transfer polling loop to periodically fetch the 8-byte boot reports.
  3. EFI_SIMPLE_TEXT_INPUT_PROTOCOL: The USB keyboard driver translates the raw USB scancodes into UEFI scan codes and Unicode characters. It then installs the EFI_SIMPLE_TEXT_INPUT_PROTOCOL (or the enhanced EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL for extended modifier key support) onto the console input handle (ConIn).

Boot managers, setup utilities, and pre-boot applications interact exclusively with the EFI_SIMPLE_TEXT_INPUT_PROTOCOL to read characters and check key states, remaining entirely abstracted from the underlying USB transport.