lkml.org 
[lkml]   [1997]   [Jul]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectFix for sysrq.c
Hi,

The following patch should fix all problems with the SysRq code
in 2.1.45. It also contains a few changes allowing SysRq things
to be implemented to serial consoles and similar drivers not using
any key codes.

Have a nice fortnight
--
Martin `MJ' Mares <mj@gts.cz> http://atrey.karlin.mff.cuni.cz/~mj/
Faculty of Math and Physics, Charles University, Prague, Czech Rep., Earth
"The best way to accelerate Windows is at 9.8 m / sec^2"



--- ./drivers/char/sysrq.c.mj Thu Jul 17 12:05:41 1997
+++ ./drivers/char/sysrq.c Thu Jul 17 13:55:48 1997
@@ -1,6 +1,6 @@
/* -*- linux-c -*-
*
- * $Id: sysrq.c,v 1.3 1997/06/18 09:42:12 mj Exp $
+ * $Id: sysrq.c,v 1.4 1997/07/17 11:54:15 mj Exp $
*
* Linux Magic System Request Key Hacks
*
@@ -63,72 +63,72 @@
console_loglevel = 7;
printk(KERN_INFO "SysRq: ");
switch (key) {
- case 19: /* R -- Reset raw mode */
- kbd->kbdmode = VC_XLATE;
- printk("Keyboard mode set to XLATE\n");
+ case 'r': /* R -- Reset raw mode */
+ if (kbd) {
+ kbd->kbdmode = VC_XLATE;
+ printk("Keyboard mode set to XLATE\n");
+ }
break;
- case 30: /* A -- SAK */
+ case 'a': /* A -- SAK */
printk("SAK\n");
- do_SAK(tty);
+ if (tty)
+ do_SAK(tty);
reset_vc(fg_console);
break;
- case 48: /* B -- boot immediately */
+ case 'b': /* B -- boot immediately */
printk("Resetting\n");
machine_restart(NULL);
break;
#ifdef __sparc__
- case 35: /* H -- halt immediately */
+ case 'h': /* H -- halt immediately */
printk("Halting\n");
halt_now();
break;
#endif
#ifdef CONFIG_APM
- case 24: /* O -- power off */
+ case 'o': /* O -- power off */
printk("Power off\n");
apm_set_power_state(APM_STATE_OFF);
break;
#endif
- case 31: /* S -- emergency sync */
+ case 's': /* S -- emergency sync */
printk("Emergency Sync\n");
emergency_sync_scheduled = EMERG_SYNC;
wakeup_bdflush(0);
break;
- case 22: /* U -- emergency remount R/O */
+ case 'u': /* U -- emergency remount R/O */
printk("Emergency Remount R/O\n");
emergency_sync_scheduled = EMERG_REMOUNT;
wakeup_bdflush(0);
break;
- case 25: /* P -- show PC */
+ case 'p': /* P -- show PC */
printk("Show Regs\n");
if (pt_regs)
show_regs(pt_regs);
break;
- case 20: /* T -- show task info */
+ case 't': /* T -- show task info */
printk("Show State\n");
show_state();
break;
- case 50: /* M -- show memory info */
+ case 'm': /* M -- show memory info */
printk("Show Memory\n");
show_mem();
break;
- case 2 ... 11: /* 0-9 -- set console logging level */
- key--;
- if (key == 10)
- key = 0;
- orig_log_level = key;
- printk("Log level set to %d\n", key);
+ case '0' ... '9': /* 0-9 -- set console logging level */
+ orig_log_level = key - '0';
+ printk("Log level set to %d\n", orig_log_level);
break;
- case 18: /* E -- terminate all user processes */
+ case 'e': /* E -- terminate all user processes */
printk("Terminate All Tasks\n");
send_sig_all(SIGTERM, 0);
orig_log_level = 8; /* We probably have killed syslogd */
break;
- case 37: /* K -- kill all user processes */
+ case 'k': /* K -- kill all user processes */
printk("Kill All Tasks\n");
send_sig_all(SIGKILL, 0);
orig_log_level = 8;
break;
- case 38: /* L -- kill all processes including init */
+ case 'l': /* L -- kill all processes including init */
printk("Kill ALL Tasks (even init)\n");
send_sig_all(SIGKILL, 1);
orig_log_level = 8;
@@ -154,7 +154,7 @@
struct file *file;

for (file = inuse_filps; file; file = file->f_next)
- if (file->f_inode && file->f_count && S_ISREG(file->f_inode->i_mode))
+ if (file->f_dentry && file->f_count && S_ISREG(file->f_dentry->d_inode->i_mode))
file->f_mode &= ~2;
}

--- ./drivers/char/keyboard.c.mj Thu Jul 17 13:05:00 1997
+++ ./drivers/char/keyboard.c Thu Jul 17 13:29:54 1997
@@ -37,6 +37,7 @@
#include <linux/kbd_diacr.h>
#include <linux/vt_kern.h>
#include <linux/kbd_ll.h>
+#include <linux/sysrq.h>

#define SIZE(x) (sizeof(x)/sizeof((x)[0]))

@@ -148,8 +149,6 @@
struct pt_regs * kbd_pt_regs;

#ifdef CONFIG_MAGIC_SYSRQ
-#define SYSRQ_KEY 0x54
-extern void handle_sysrq(int, struct pt_regs *, struct kbd_struct *, struct tty_struct *);
static int sysrq_pressed;
#endif

@@ -239,7 +238,7 @@
return;
} else if (sysrq_pressed) {
if (!up_flag)
- handle_sysrq(keycode, kbd_pt_regs, kbd, tty);
+ handle_sysrq(kbd_sysrq_xlate[keycode], kbd_pt_regs, kbd, tty);
return;
}
#endif
--- ./drivers/char/pc_keyb.c.mj Thu Jul 17 13:05:04 1997
+++ ./drivers/char/pc_keyb.c Thu Jul 17 13:32:02 1997
@@ -25,6 +25,19 @@

#include "pc_keyb.h"

+/* Simple translation table for the SysRq keys */
+
+#ifdef CONFIG_MAGIC_SYSRQ
+unsigned char pckbd_sysrq_xlate[128] =
+ "\000\0331234567890-=\177\t" /* 0x00 - 0x0f */
+ "qwertyuiop[]\r\000as" /* 0x10 - 0x1f */
+ "dfghjkl;'`\000\\zxcv" /* 0x20 - 0x2f */
+ "bnm,./\000*\000 \000\201\202\203\204\205" /* 0x30 - 0x3f */
+ "\206\207\210\211\212\000\000789-456+1" /* 0x40 - 0x4f */
+ "230\177\000\000\213\214\000\000\000\000\000\000\000\000\000\000" /* 0x50 - 0x5f */
+ "\r\000/"; /* 0x60 - 0x6f */
+#endif
+
/*
* In case we run on a non-x86 hardware we need to initialize both the keyboard
* controller and the keyboard. On a x86, the BIOS will already have initialized
--- ./include/asm-alpha/keyboard.h.mj Thu Jul 17 13:06:08 1997
+++ ./include/asm-alpha/keyboard.h Thu Jul 17 13:18:36 1997
@@ -24,6 +24,7 @@
extern char pckbd_unexpected_up(unsigned char keycode);
extern void pckbd_leds(unsigned char leds);
extern void pckbd_init_hw(void);
+extern unsigned char pckbd_sysrq_xlate[128];

#define kbd_setkeycode pckbd_setkeycode
#define kbd_getkeycode pckbd_getkeycode
@@ -32,8 +33,11 @@
#define kbd_unexpected_up pckbd_unexpected_up
#define kbd_leds pckbd_leds
#define kbd_init_hw pckbd_init_hw
+#define kbd_sysrq_xlate pckbd_sysrq_xlate

#define INIT_KBD
+
+#define SYSRQ_KEY 0x54

#endif /* __KERNEL__ */

--- ./include/asm-i386/keyboard.h.mj Thu Jul 17 13:05:46 1997
+++ ./include/asm-i386/keyboard.h Thu Jul 17 13:18:30 1997
@@ -24,6 +24,7 @@
extern char pckbd_unexpected_up(unsigned char keycode);
extern void pckbd_leds(unsigned char leds);
extern void pckbd_init_hw(void);
+extern unsigned char pckbd_sysrq_xlate[128];

#define kbd_setkeycode pckbd_setkeycode
#define kbd_getkeycode pckbd_getkeycode
@@ -32,6 +33,9 @@
#define kbd_unexpected_up pckbd_unexpected_up
#define kbd_leds pckbd_leds
#define kbd_init_hw pckbd_init_hw
+#define kbd_sysrq_xlate pckbd_sysrq_xlate
+
+#define SYSRQ_KEY 0x54

#endif /* __KERNEL__ */

--- ./include/linux/sysrq.h.mj Thu Jul 17 13:07:28 1997
+++ ./include/linux/sysrq.h Thu Jul 17 13:56:04 1997
@@ -1,6 +1,6 @@
/* -*- linux-c -*-
*
- * $Id: sysrq.h,v 1.2 1997/05/31 18:33:41 mj Exp $
+ * $Id: sysrq.h,v 1.3 1997/07/17 11:54:33 mj Exp $
*
* Linux Magic System Request Key Hacks
*
@@ -9,12 +9,25 @@

#include <linux/config.h>

+struct pt_regs;
+struct kbd_struct;
+struct tty_struct;
+
+/* Generic SysRq interface -- you may call it from any device driver, supplying
+ * ASCII code of the key, pointer to registers and kbd/tty structs (if they
+ * are available -- else NULL's).
+ */
+
+void handle_sysrq(int, struct pt_regs *, struct kbd_struct *, struct tty_struct *);
+
+/* Deferred actions */
+
extern int emergency_sync_scheduled;

#define EMERG_SYNC 1
#define EMERG_REMOUNT 2

-extern void do_emergency_sync(void);
+void do_emergency_sync(void);

#ifdef CONFIG_MAGIC_SYSRQ
#define CHECK_EMERGENCY_SYNC \
\
 
 \ /
  Last update: 2005-03-22 13:39    [W:0.037 / U:0.060 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site