[SeaBIOS] alt-sysrq support

Albert Cahalan acahalan at gmail.com
Thu Aug 25 16:48:40 CEST 2016


This is a patch that worked for the Bochs BIOS. The code is similar.

The important part is the keycode. DOSRMX needs this for console switching.

The other part is a hook. I have key presses; key releases should be done too.
I don't know what uses this, but it is a standard BIOS feature.
-------------- next part --------------
diff --git a/machine/x86/x86/bios/rombios.c b/machine/x86/x86/bios/rombios.c
index 64c569e..0690eb9 100644
--- a/machine/x86/x86/bios/rombios.c
+++ b/machine/x86/x86/bios/rombios.c
@@ -1086,7 +1086,7 @@ static struct {
       { 0x342e, 0x343e,   none,   none, none }, /* .> */
       { 0x352f, 0x353f,   none,   none, none }, /* /? */
       {   none,   none,   none,   none, none }, /* R Shift */
-      { 0x372a, 0x372a,   none,   none, none }, /* * */
+      { 0x372a, 0x372a, 0x5400, 0x5400, none }, /* * */
       {   none,   none,   none,   none, none }, /* L Alt */
       { 0x3920, 0x3920, 0x3920, 0x3920, none }, /* space */
       {   none,   none,   none,   none, none }, /* caps lock */
@@ -3934,7 +3934,24 @@ BX_DEBUG_INT15("int15 AX=%04x\n",regs.u.r16.ax);
 
       break;
     }
-
+    case 0x85:
+      // alt + sysrq
+      switch(regs.u.r8.al)
+      {
+      case 0x00:
+        BX_INFO("int15: alt sysrq pressed\n");
+		break;
+      case 0x01:
+        BX_INFO("int15: alt sysrq released\n");
+		break;
+	  default:
+        BX_INFO("int15: alt sysrq 0x%02x\n", regs.u.r8.al);
+		break;
+	  }
+      //regs.u.r8.ah = 0x00;
+      //regs.u.r8.al = 0x85;
+      CLEAR_CF();
+      break;
     case 0x87:
 #if BX_CPU < 3
 #  error "Int15 function 87h not supported on < 80386"
@@ -5091,7 +5107,27 @@ int09_function(DI, SI, BP, SP, BX, DX, CX, AX)
       mf2_flags &= ~0x10;
       write_byte(0x0040, 0x18, mf2_flags);
       break;
-
+    case 0x54: /* Sysrq press */
+      mf2_flags |= 0x04;
+      write_byte(0x0040, 0x18, mf2_flags);
+      if (shift_flags & 0x08) // Alt + sysrq
+      {
+        SET_AH(0x85);
+        SET_AL(0x00); // press
+        ASM_START
+          int 0x15
+        ASM_END
+      }
+      return;
+    case 0xd4: /* Sysrq release */
+      mf2_flags &= ~0x04;
+      write_byte(0x0040, 0x18, mf2_flags);
+      SET_AH(0x85);
+      SET_AL(0x01); // release
+      ASM_START
+        int 0x15
+      ASM_END
+      return;
     default:
       if (scancode & 0x80) {
         break; /* toss key releases ... */
@@ -5134,6 +5170,19 @@ int09_function(DI, SI, BP, SP, BX, DX, CX, AX)
       if (scancode==0 && asciicode==0) {
         BX_INFO("KBD: int09h_handler(): scancode & asciicode are zero?\n");
       }
+	  if (scancode==0x54 && asciicode==0x00)
+      {
+		  mf2_flags |= 0x04;
+		  write_byte(0x0040, 0x18, mf2_flags);
+		  if (shift_flags & 0x08) // Alt + sysrq
+		  {
+			SET_AH(0x85);
+			SET_AL(0x00); // press (FIXME: should do release too, w/ 0x01)
+			ASM_START
+			  int 0x15
+			ASM_END
+		  }
+      }
       enqueue_key(scancode, asciicode);
       break;
   }


More information about the SeaBIOS mailing list