Skip to main content

Module keyboard

Module keyboard 

Source
Expand description

PS/2 Keyboard driver

Handles IRQ1 keyboard interrupts, reads scancodes from port 0x60, and converts them to characters for the VGA console.

Modifier state and scancode processing are shared via keyboard_layout.rs. This module owns the ring buffer, PS/2 port init, and lost-key diagnostics.

Re-exportsยง

pub use super::keyboard_layout::KEY_DOWN;
pub use super::keyboard_layout::KEY_END;
pub use super::keyboard_layout::KEY_HOME;
pub use super::keyboard_layout::KEY_LEFT;
pub use super::keyboard_layout::KEY_RIGHT;
pub use super::keyboard_layout::KEY_UP;

Structsยง

KeyboardBuffer ๐Ÿ”’
KeyboardBufferInner ๐Ÿ”’

Constantsยง

CMD_ENABLE_KBD ๐Ÿ”’
CMD_READ_CFG ๐Ÿ”’
CMD_WRITE_CFG ๐Ÿ”’
KEYBOARD_BUFFER_SIZE ๐Ÿ”’
Keyboard input buffer size
KEYBOARD_DATA_PORT ๐Ÿ”’
PS/2 keyboard data port
PS2_CMD_PORT ๐Ÿ”’
STATUS_INPUT_FULL ๐Ÿ”’
STATUS_OUTPUT_FULL ๐Ÿ”’

Staticsยง

KEYBOARD_BUFFER ๐Ÿ”’
LOST_KEY_COUNT ๐Ÿ”’
Number of characters dropped due to buffer overflow. Incremented atomically in IRQ context, safe to read from any context.

Functionsยง

add_to_buffer
Add a character to the keyboard buffer (called from IRQ context).
flush_output ๐Ÿ”’
has_input
Check if keyboard buffer has data (task context only).
init
Initialize the PS/2 keyboard controller
inject_hid_scancode
Inject a PS/2 scancode from USB HID or other non-PS/2 source.
lost_key_count
Return the total number of characters lost due to buffer overflow since boot.
ps2_read ๐Ÿ”’
ps2_write_cmd ๐Ÿ”’
ps2_write_data ๐Ÿ”’
read_char
Get a character from the keyboard buffer (non-blocking, task context only).
reset_lost_key_count
Reset the lost-key counter to zero.
wait_read ๐Ÿ”’
wait_write ๐Ÿ”’