Implement GET/SET_GLOBAL(...) instead of using GET/SET_VAR(CS, ...)
[seabios.git] / src / kbd.c
index 11d11d3aa0da853ca70925bf081a2906d9b28c20..190c9fedc1594f6e144befdece8ee61ad63ec9f2 100644 (file)
--- a/src/kbd.c
+++ b/src/kbd.c
@@ -30,7 +30,7 @@ keyboard_init()
     if (ret)
         return;
     if (param[0] != 0x55) {
-        dprintf(1, "i8042 self test failed (got %x not 0x55\n", param[0]);
+        dprintf(1, "i8042 self test failed (got %x not 0x55)\n", param[0]);
         return;
     }
 
@@ -39,7 +39,7 @@ keyboard_init()
     if (ret)
         return;
     if (param[0] != 0x00) {
-        dprintf(1, "i8042 keyboard test failed (got %x not 0x00\n", param[0]);
+        dprintf(1, "i8042 keyboard test failed (got %x not 0x00)\n", param[0]);
         return;
     }
 
@@ -55,10 +55,10 @@ keyboard_init()
     /* ------------------- keyboard side ------------------------*/
     /* reset keyboard and self test  (keyboard side) */
     ret = kbd_command(ATKBD_CMD_RESET_BAT, param);
-    if (ret < 0)
+    if (ret != 0 && ret != 2)
         return;
     if (param[0] != 0xaa) {
-        dprintf(1, "keyboard self test failed (got %x not 0xaa\n", param[0]);
+        dprintf(1, "keyboard self test failed (got %x not 0xaa)\n", param[0]);
         return;
     }
 
@@ -97,8 +97,7 @@ kbd_setup()
 
     keyboard_init();
 
-    // Enable IRQ1 (handle_09)
-    unmask_pic1(PIC1_IRQ1);
+    enable_hwirq(1, entry_09);
 }
 
 static u8
@@ -436,8 +435,8 @@ static struct scaninfo {
     {   none,   none,   none,   none, none },
     {   none,   none,   none,   none, none },
     { 0x565c, 0x567c,   none,   none, none }, /* \| */
-    { 0x5700, 0x5700,   none,   none, none }, /* F11 */
-    { 0x5800, 0x5800,   none,   none, none }  /* F12 */
+    { 0x8500, 0x8700, 0x8900, 0x8b00, none }, /* F11 */
+    { 0x8600, 0x8800, 0x8a00, 0x8c00, none }, /* F12 */
 };
 
 static void
@@ -567,9 +566,12 @@ process_key(u8 scancode)
         return;
 
     default:
-        if (scancode & 0x80) {
-            break; /* toss key releases ... */
-        }
+        if (scancode & 0x80)
+            // toss key releases
+            break;
+        if (scancode == 0x53 && (shift_flags & 0x0c) == 0x0c)
+            // Ctrl+alt+del - reset machine.
+            reset_vector();
         if (scancode > MAX_SCAN_CODE) {
             dprintf(1, "KBD: int09h_handler(): unknown scancode read: 0x%02x!\n"
                     , scancode);
@@ -578,35 +580,35 @@ process_key(u8 scancode)
         u8 asciicode;
         struct scaninfo *info = &scan_to_scanascii[scancode];
         if (shift_flags & 0x08) { /* ALT */
-            asciicode = GET_VAR(CS, info->alt);
-            scancode = GET_VAR(CS, info->alt) >> 8;
+            asciicode = GET_GLOBAL(info->alt);
+            scancode = GET_GLOBAL(info->alt) >> 8;
         } else if (shift_flags & 0x04) { /* CONTROL */
-            asciicode = GET_VAR(CS, info->control);
-            scancode = GET_VAR(CS, info->control) >> 8;
+            asciicode = GET_GLOBAL(info->control);
+            scancode = GET_GLOBAL(info->control) >> 8;
         } else if ((mf2_state & 0x02) > 0
                    && scancode >= 0x47 && scancode <= 0x53) {
             /* extended keys handling */
             asciicode = 0xe0;
-            scancode = GET_VAR(CS, info->normal) >> 8;
+            scancode = GET_GLOBAL(info->normal) >> 8;
         } else if (shift_flags & 0x03) { /* LSHIFT + RSHIFT */
             /* check if lock state should be ignored
              * because a SHIFT key are pressed */
 
-            if (shift_flags & GET_VAR(CS, info->lock_flags)) {
-                asciicode = GET_VAR(CS, info->normal);
-                scancode = GET_VAR(CS, info->normal) >> 8;
+            if (shift_flags & GET_GLOBAL(info->lock_flags)) {
+                asciicode = GET_GLOBAL(info->normal);
+                scancode = GET_GLOBAL(info->normal) >> 8;
             } else {
-                asciicode = GET_VAR(CS, info->shift);
-                scancode = GET_VAR(CS, info->shift) >> 8;
+                asciicode = GET_GLOBAL(info->shift);
+                scancode = GET_GLOBAL(info->shift) >> 8;
             }
         } else {
             /* check if lock is on */
-            if (shift_flags & GET_VAR(CS, info->lock_flags)) {
-                asciicode = GET_VAR(CS, info->shift);
-                scancode = GET_VAR(CS, info->shift) >> 8;
+            if (shift_flags & GET_GLOBAL(info->lock_flags)) {
+                asciicode = GET_GLOBAL(info->shift);
+                scancode = GET_GLOBAL(info->shift) >> 8;
             } else {
-                asciicode = GET_VAR(CS, info->normal);
-                scancode = GET_VAR(CS, info->normal) >> 8;
+                asciicode = GET_GLOBAL(info->normal);
+                scancode = GET_GLOBAL(info->normal) >> 8;
             }
         }
         if (scancode==0 && asciicode==0) {