Attempt 2 #2

Open
seeseemelk wants to merge 56 commits from attempt-2 into master
Showing only changes of commit 3512e937ae - Show all commits

View File

@@ -101,11 +101,21 @@ void keyboard_init(void) {
kb_waiting_pid = 0;
shift_pressed = 0;
/* Flush any pending data from the keyboard controller */
while (inb(0x64) & 0x01) {
offset_print(" KEYBOARD: flushing controller...\n");
/* Flush any pending data from the keyboard controller.
* Use a timeout to avoid hanging if the controller keeps reporting data
* (some emulators/VMs behave differently). */
int flush_count = 0;
while ((inb(0x64) & 0x01) && flush_count < 1024) {
inb(KB_DATA_PORT);
flush_count++;
}
offset_print(" KEYBOARD: flushed ");
print_hex((uint32_t)flush_count);
offset_print(" KEYBOARD: bytes, unmasking IRQ1...\n");
/* Unmask IRQ1 (keyboard) in the PIC */
pic_clear_mask(1);