/** * @file keyboard.h * @brief PS/2 keyboard driver. * * Handles IRQ1 keyboard interrupts, translates scancodes to ASCII, * and provides a ring buffer for user-space reading via SYS_READ. */ #ifndef KEYBOARD_H #define KEYBOARD_H #include #include "isr.h" /** Keyboard input buffer size. */ #define KB_BUFFER_SIZE 256 /** * Initialize the keyboard driver. */ void keyboard_init(void); /** * Handle a keyboard IRQ (called from isr_handler for IRQ1). * * @param regs Register state (may be used to wake blocked processes). */ void keyboard_irq(registers_t *regs); /** * Read characters from the keyboard buffer. * Non-blocking: returns whatever is available, 0 if empty. * * @param buf Destination buffer. * @param count Maximum bytes to read. * @return Number of bytes read. */ uint32_t keyboard_read(char *buf, uint32_t count); /** * Check if there is data available in the keyboard buffer. * * @return Non-zero if data is available. */ int keyboard_has_data(void); /** * Block the given process until keyboard data is available. * Sets the process to BLOCKED state and records it as waiting for keyboard. * When data arrives, the process will be unblocked. * * @param regs Current interrupt frame (for saving process state). */ void keyboard_block_for_input(registers_t *regs); #endif /* KEYBOARD_H */