From de20d7430df08731d9108acb83e1234ba7f1fe16 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Sat, 19 Sep 2020 14:53:29 -0400 Subject: file manager --- src/kernel/kbd.c | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) (limited to 'src/kernel/kbd.c') diff --git a/src/kernel/kbd.c b/src/kernel/kbd.c index f3eb323..c251db7 100644 --- a/src/kernel/kbd.c +++ b/src/kernel/kbd.c @@ -226,19 +226,34 @@ static const uint8_t codes_e0[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; +#include "log.h" + +uint8_t get_code_byte() { + for (uint32_t spin = 0; spin < 10000000; ++spin) + ; + return inb(PS2_DATA); +} + void on_kbd_isr() { while (inb(PS2_CMD) & PS2S_CODE_READY) { - uint8_t code = inb(PS2_DATA); + //char nbuf[11]; + uint8_t code = get_code_byte(); + //logsz("code: 0x"); + //u8_hex(code, nbuf); + //logsz(nbuf); if (code == 0xe1) { - code = inb(PS2_DATA); + code = get_code_byte(); + //logsz(" 0x"); + //u8_hex(code, nbuf); + //logsz(nbuf); if (code == 0x1d) { - if (inb(PS2_DATA) != 0x45) + if (get_code_byte() != 0x45) code = 0; else code = CODE_PAUSE; } else if (code == 0x9d) { - if (inb(PS2_DATA) != 0xc5) + if (get_code_byte() != 0xc5) code = 0; else code = 0xff; @@ -247,17 +262,20 @@ void on_kbd_isr() { code = 0; } else if (code == 0xe0) { - code = inb(PS2_DATA); + code = get_code_byte(); + //logsz(" 0x"); + //u8_hex(code, nbuf); + //logsz(nbuf); if (code == 0x2a) { - if ((inb(PS2_DATA) != 0xe0) || - (inb(PS2_DATA) != 0x37)) + if ((get_code_byte() != 0xe0) || + (get_code_byte() != 0x37)) code = 0; else code = CODE_PRSCR; } else if (code == 0xb7) { - if ((inb(PS2_DATA) != 0xe0) || - (inb(PS2_DATA) != 0xaa)) + if ((get_code_byte() != 0xe0) || + (get_code_byte() != 0xaa)) code = 0; else code = 0xff; @@ -268,6 +286,8 @@ void on_kbd_isr() { else code = codes[code]; + //logch('\n'); + if (!code) PANIC("Unknown scancode."); -- cgit v1.2.3