Reboot when Ctrl+Alt+Del is pressed.
[pintos-anon] / src / devices / kbd.c
index 4d7dfdf1a315df6cd3b92564c2719bc815d694de..1aa71f5a3062c1888b3d3342d9a2d6675765b4e6 100644 (file)
@@ -4,6 +4,7 @@
 #include <stdio.h>
 #include <string.h>
 #include "devices/input.h"
 #include <stdio.h>
 #include <string.h>
 #include "devices/input.h"
+#include "threads/init.h"
 #include "threads/interrupt.h"
 #include "threads/io.h"
 
 #include "threads/interrupt.h"
 #include "threads/io.h"
 
@@ -53,7 +54,7 @@ struct keymap
    that we handle elsewhere.  */
 static const struct keymap invariant_keymap[] = 
   {
    that we handle elsewhere.  */
 static const struct keymap invariant_keymap[] = 
   {
-    {0x01, "\033"},
+    {0x01, "\033"},             /* Escape. */
     {0x0e, "\b"},
     {0x0f, "\tQWERTYUIOP"},
     {0x1c, "\r"},
     {0x0e, "\b"},
     {0x0f, "\tQWERTYUIOP"},
     {0x1c, "\r"},
@@ -61,6 +62,7 @@ static const struct keymap invariant_keymap[] =
     {0x2c, "ZXCVBNM"},
     {0x37, "*"},
     {0x39, " "},
     {0x2c, "ZXCVBNM"},
     {0x37, "*"},
     {0x39, " "},
+    {0x53, "\177"},             /* Delete. */
     {0, NULL},
   };
 
     {0, NULL},
   };
 
@@ -131,6 +133,10 @@ keyboard_interrupt (struct intr_frame *args UNUSED)
       /* Ordinary character. */
       if (!release) 
         {
       /* Ordinary character. */
       if (!release) 
         {
+          /* Reboot if Ctrl+Alt+Del pressed. */
+          if (c == 0177 && ctrl && alt)
+            reboot ();
+
           /* Handle Ctrl, Shift.
              Note that Ctrl overrides Shift. */
           if (ctrl && c >= 0x40 && c < 0x60) 
           /* Handle Ctrl, Shift.
              Note that Ctrl overrides Shift. */
           if (ctrl && c >= 0x40 && c < 0x60)