1.8 KiB
1.8 KiB
PS2 keyboard
The PS2 keyboard driver is defined in shelter/lib/include/devs/input/ps2.h and implemented in shelter/lib/src/devs/input/ps2.c. This documentation only describes the public API, the one that is safe to access from external subsystems.
Driver initialization
The PS2 is initialized using sh_ps2_driver_init(). The pre-requirement for this function include the keyboard input subsystem being initialized. Here is the exact procedure:
- Disable interrupts for safety
- Flush output buffer
- Debug log status and config byte initial value
- Disable keyboard and mouse PS2 ports
- Reflush output buffer for safety
- Disable both ports IRQs
- Perform the PS2 controller self test
- Enable port 1
- Enable scancodes translation
- Initialize driver internal state
- Enable IRQ for port 1
- Register interrupt handler for legacy IRQ1
- Enable interrupts
- Disable scanning
- Reset leds state
- Identify keyboard
- Register PS2 keyboard to the keyboard input subsystem
- Enable scanning
For the moments, commands responses handling and scancodes parsing is working but there are a few limitations:
- since we only parsed a few ACPI tables, we are unable to detect with certainty the presence of a PS2 controller. So the system consider that the PS2 controller is available and working and the keyboard device registered to the keyboard input subsystem will always be marked as present
- any error in the driver initialization will be interpreted as a failure of the boot process
- for the moment, we are unable to defer the leds state update when a scancode change the NumLock/CapsLock state, so these leds won't update
API
A few additionnal functions are provided:
sh_ps2_disable_scanning(): disable PS2 keyboard scanningsh_ps2_enable_scanning(): enable PS2 keyboard scanning