From 2bc8a824fd424aa3e21bc394fd0be3191b830888 Mon Sep 17 00:00:00 2001 From: Richard Qin Date: Mon, 9 Nov 2026 23:42:19 +0800 Subject: [mubios] Initialize the 8042 keyboard controller POST only unmasked IRQ1 in the PIC and never configured the 8042 itself, so the keyboard stayed in its post-reset disabled state: the clock was inhibited and no scan code ever reached the output buffer. IRQ1 never fired, the BDA keyboard buffer stayed empty, and GRUB polling INT 16h AH=01h never saw a key. Add kbd_init() to disable both ports, drain the output buffer, clear the clock inhibit bits in the command byte, enable the keyboard and auxiliary IRQs and select set 1 translation, then enable scanning with 0xF4. The IRQ1 handler now checks the status register for a pending output byte before reading the data port and drops auxiliary port bytes. The set 2 break prefix tracking is gone because translation is enabled. --- mubios/arch/irq.S | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) (limited to 'mubios/arch') diff --git a/mubios/arch/irq.S b/mubios/arch/irq.S index 99eb9b3..b22578b 100644 --- a/mubios/arch/irq.S +++ b/mubios/arch/irq.S @@ -25,8 +25,6 @@ .equ BDA_BASE, 0x0400 .equ BDA_KBD_BUFFER_START, 0x001E .equ BDA_KBD_BUFFER_END, 0x003E - .equ BDA_KBD_BREAK_PREFIX, 0x0497 - .equ TIMER_TICKS_PER_DAY_LOW, 0x00B0 .equ TIMER_TICKS_PER_DAY_HIGH, 0x0018 @@ -80,26 +78,24 @@ irq1_entry: push ds push si - # Read the PS/2 scan code before sending EOI. - in al, 0x60 - mov dl, al - xor ax, ax mov ds, ax - # Ignore a PS/2 set-2 break prefix and its following release code. - cmp dl, 0xF0 - jne irq1_check_break_prefix - mov byte ptr [BDA_KBD_BREAK_PREFIX], 1 - jmp irq1_send_eoi + # Only read the data port when the controller holds a byte for the CPU. + in al, 0x64 + test al, 0x01 + jz irq1_send_eoi + + mov ah, al -irq1_check_break_prefix: - cmp byte ptr [BDA_KBD_BREAK_PREFIX], 0 - je irq1_check_set1_break - mov byte ptr [BDA_KBD_BREAK_PREFIX], 0 - jmp irq1_send_eoi + in al, 0x60 + mov dl, al + + # Drop bytes that belong to the auxiliary port. + test ah, 0x20 + jnz irq1_send_eoi -irq1_check_set1_break: + # Set 1 break codes carry bit 7 in the scan code itself. test dl, 0x80 jnz irq1_send_eoi -- cgit v1.2.3