public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Stateful Magic SysRq
@ 2001-09-22 15:37 Crutcher Dunnavant
  0 siblings, 0 replies; only message in thread
From: Crutcher Dunnavant @ 2001-09-22 15:37 UTC (permalink / raw)
  To: linux-kernel

This is NOT A PATCH YET! This is a question. The patch is coming.

I'm reworking a patch (ultimately) from Amazon which makes the Magic
SysRq system stateful. It is a good, solid approach they have taken, and
it makes SysRq really usable over all KVMs and crappy keyboards.

Here is the core part of the patch.

+#ifdef CONFIG_MAGIC_SYSRQ               /* Handle the SysRq Hack */
+	/*
+	  Pressing magic + command key acts as a chorded command
+	  Pressing and releasing magic without a command key acts sticky, using the next non-magic key as a command key
+	  Pressing magic twice without a command key passes the magic key through
+
+	  The sysrq_pressed states:
+	  0 = not pressed
+	  1 = pressed now but no command has been issued
+	  2 = pressed now and command has been issued
+	  3 = pressed and released, waiting for command key
+
+	    action   MgcDown   MgcUp   keyDown    keyUp
+	  State  +---------------------------------------
+	    0    |     1         0     normal     normal
+            1    |     1         3    2+action      1
+            2    |     2         0    2+action      2
+            3    |   3+pass    0+pass 3+action      0
+
+	    pass = pass key through to remainder of code
+	    action = perform magic action
+	    normal = standard action
+	 */
+
+        if (sysrq_ctls.enabled && keycode == sysrq_ctls.keycode) {
+	  switch(sysrq_pressed) {
+	  case 0:
+	    sysrq_pressed = up_flag ? 0 : 1;
+	    goto out;
+	  case 1:
+	    sysrq_pressed = up_flag ? 3 : 1;
+	    goto out;
+	  case 2:
+	    sysrq_pressed = up_flag ? 0 : 2;
+	    goto out;
+	  case 3:
+	    sysrq_pressed = up_flag ? 0 : 3;
+	    break;  // two magics in a row, pass the keycode through
+	  }
+        } else if (sysrq_pressed) {
+	  if (!up_flag) {
+	    handle_sysrq(kbd_sysrq_xlate[keycode], kbd_pt_regs, kbd, tty);
+	    if (sysrq_pressed == 1) { sysrq_pressed = 2; }
+	    goto out;
+	  } else {  // up_flag
+	    if (sysrq_pressed == 3) {
+	      sysrq_pressed = 0;
+	    }
+	  }
+        }
 #endif


The question is, is this good enough? If the magic key becomes stateful,
then a more advanced key entry mode could be setup. A 'readline'
function could collect keys for a handler until enter was pressed, and
we could get real string entry into sysrq handlers.

I am not suggesting writting that function now, but rather making it
possible to write later. If this is where we want to go, then the
behaviour shown in this code snippit needs to be split between this
function and handle_sysrq().

I will post both versions of this later tonight, but I wanted some
feedback.

-- 
Crutcher        <crutcher@datastacks.com>
GCS d--- s+:>+:- a-- C++++$ UL++++$ L+++$>++++ !E PS+++ PE Y+ PGP+>++++
    R-(+++) !tv(+++) b+(++++) G+ e>++++ h+>++ r* y+>*$

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-09-22 15:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-09-22 15:37 Stateful Magic SysRq Crutcher Dunnavant

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox