diff options
| author | Richard Qin <richard.qin.x@gmail.com> | 2026-11-09 23:42:19 +0800 |
|---|---|---|
| committer | Richard Qin <richard.qin.x@gmail.com> | 2026-11-09 23:42:19 +0800 |
| commit | 2bc8a824fd424aa3e21bc394fd0be3191b830888 (patch) | |
| tree | 4b6fcfc27e6caa1d80c4f35dbb410620815ae262 /mubios/arch | |
| parent | 06cb46aa0236352554f23697e17bed378083be1a (diff) | |
| download | rcc-project-2bc8a824fd424aa3e21bc394fd0be3191b830888.tar.gz rcc-project-2bc8a824fd424aa3e21bc394fd0be3191b830888.tar.xz | |
[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.
Diffstat (limited to 'mubios/arch')
| -rw-r--r-- | mubios/arch/irq.S | 30 |
1 files changed, 13 insertions, 17 deletions
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 |
