Added code to initialize PS/2 keyboards

This commit is contained in:
Peter Weingartner 2025-01-05 20:24:24 -05:00
parent dbe1fd298b
commit 97cedc8659
2 changed files with 21 additions and 2 deletions

View file

@ -29,6 +29,9 @@
// Constants // Constants
// //
#define KBD_TIMEOUT 10
#define KBD_RETRIES 10
/* /*
* Modifier bit flags * Modifier bit flags
*/ */
@ -406,7 +409,7 @@ static void kbd_process_set2_bytecode(uint8_t byte_code) {
*/ */
SYSTEMCALL void kbd_handle_irq() { SYSTEMCALL void kbd_handle_irq() {
// Check to see if there is a keyboard bytecode waiting... process it if so // Check to see if there is a keyboard bytecode waiting... process it if so
if ((*PS2_STAT & PS2_STAT_KBD_EMP) == 0) { while ((*PS2_STAT & PS2_STAT_KBD_EMP) == 0) {
kbd_process_set2_bytecode(*PS2_KBD_IN); kbd_process_set2_bytecode(*PS2_KBD_IN);
} }
} }
@ -445,6 +448,9 @@ bool kbd_break() {
* *
*/ */
short kbd_sc_init() { short kbd_sc_init() {
// Make sure the keyboard interrupt is disabled
int_disable(INT_KBD_PS2);
// Initialize the keyboard buffers // Initialize the keyboard buffers
rb_word_init(&scan_code_buffer); rb_word_init(&scan_code_buffer);
rb_word_init(&char_buffer); rb_word_init(&char_buffer);
@ -454,6 +460,19 @@ short kbd_sc_init() {
modifiers = 0; modifiers = 0;
break_pressed = false; break_pressed = false;
// Disable scanning
kbd_send_cmd(0xf5);
INFO("kbd_sc_init: ps/2 scanning disabled");
// Set scan code set #1
kbd_send_cmd(0xf0);
kbd_send_cmd(0x02);
INFO("kbd_sc_init: ps/2 scan code set #1 selected");
// Enable scanning
kbd_send_cmd(0xf4);
INFO("kbd_sc_init: ps/2 scanning enabled");
// Register and enable the PS/2 interrupt handler // Register and enable the PS/2 interrupt handler
int_register(INT_KBD_PS2, (p_int_handler)kbd_handle_irq); int_register(INT_KBD_PS2, (p_int_handler)kbd_handle_irq);
int_enable(INT_KBD_PS2); int_enable(INT_KBD_PS2);

View file

@ -7,6 +7,6 @@
#define VER_MAJOR 1 #define VER_MAJOR 1
#define VER_MINOR 1 #define VER_MINOR 1
#define VER_BUILD 13 #define VER_BUILD 20
#endif #endif