Преглед изворни кода

speed up keyboard int handling

speed up by sending complete signals before really handling them

fix the problem that some scan codes may display improperly
greatbridf пре 4 година
родитељ
комит
2900526df3
2 измењених фајлова са 8 додато и 4 уклоњено
  1. 7 2
      src/kernel/hw/keyboard.c
  2. 1 2
      src/kernel/interrupt.c

+ 7 - 2
src/kernel/hw/keyboard.c

@@ -34,9 +34,14 @@ void process_keyboard_data(void)
 {
     char buf[128] = { 0 };
     while (keyboard_has_data()) {
-        char c;
+        // as scan codes may be greater than 127
+        // so we use unsigned char here to prevent
+        // the compiler from automatically filling
+        // 1's in front of the scan codes and cause
+        // codes like '9e' show like 'ffffff9e'
+        unsigned char c;
         c = ring_buffer_read(p_scan_code_buf);
-        snprintf(buf, 128, "%d", (int32_t)c);
+        snprintf(buf, 128, "%x", c);
     }
     vga_printk(buf, 0x0fu);
 }

+ 1 - 2
src/kernel/interrupt.c

@@ -90,9 +90,8 @@ void irq0_handler(void)
 // keyboard interrupt
 void irq1_handler(void)
 {
-    handle_keyboard_interrupt();
-
     asm_outb(PORT_PIC1_COMMAND, PIC_EOI);
+    handle_keyboard_interrupt();
 }
 void irq2_handler(void)
 {