lkml.org 
[lkml]   [2001]   [Sep]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectStateful Magic SysRq
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+>*$
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:03    [W:0.053 / U:0.160 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site