SYSRQ...(part2)

almesber en lrc.di.epfl.ch almesber en lrc.di.epfl.ch
Lun Ene 24 22:47:46 CST 2000


Mike A. Harris wrote:
> Correct.  I like this approach too.  I'm going to try and
> implement it today.  If I do, I'll send my submission to Martin
> Mares, et al for inclusion in the kernel.

BTW, this is quite similar to something I had to do for the Psion S5:
there is no SysRq key, so I used Ctrl-Alt-Help instead. Also, I
wanted SysRq to be sticky. I implemented a general approach that adds
architecture-specific keys (e.g. on an PDA you have keys for backlight,
contract, etc.), exported the SysRq interface from keyboard.c, and
defined SysRq as an architecture-specific key.

If you make such a SysRq extension, it would be nice if you could
consider implementing the more general concept I'm proposing. This way,
it'll be easier to add architecture-specific hooks for PDAs and such.
(If anybody from LinuxCE is reading this, maybe they could comment too.)

I've attached a pseudo-patch (with large sections containing material
specific to the Psion or linux-7k in general removed) vs. 2.2.1. The
full linux-7k patch is on
ftp://icaftp.epfl.ch/pub/people/almesber/psion/crash+burn-26.patch.gz

> We could claim that the linux kernel also contains
> "accessibility" features for Linux kernel hackers that are
> disabled.

Or using small mobile devices.

- Werner

-- 
  _________________________________________________________________________
 / Werner Almesberger, ICA, EPFL, CH       werner.almesberger en ica.epfl.ch /
/_IN_N_032__Tel_+41_21_693_6621__Fax_+41_21_693_6610_____________________/
------------ próxima parte ------------
--- /dev/null	Tue May  5 22:32:27 1998
+++ work/drivers/char/kbd_7110.c	Tue Oct 26 20:20:57 1999
[ ... Other includes ... ]
+#include <asm/arch/keyboard.h>
[ Lots of hardware-specific things ... ]
+
+
+#if defined(CONFIG_VT) && defined(CONFIG_MAGIC_SYSRQ)
+extern int sysrq_pressed;
+#endif
+
+
+void kbd7110_arch_handler(unsigned char value, char up_flag)
+{
+#if defined(CONFIG_VT) && defined(CONFIG_MAGIC_SYSRQ)
+	if (value == 1) {
+		sysrq_pressed = !up_flag;
+		return;
+	}
+#endif
+	if (up_flag) return;
+	switch (value) {
+#ifdef KBD_ARCHKEY_2
+		case 2:
+			KBD_ARCHKEY_2;
+			break;
+#endif
+#ifdef KBD_ARCHKEY_3
+		case 3:
+			KBD_ARCHKEY_3;
+			break;
+#endif
+#ifdef KBD_ARCHKEY_4
+		case 4:
+			KBD_ARCHKEY_4;
+			break;
+#endif
+#ifdef KBD_ARCHKEY_5
+		case 5:
+			KBD_ARCHKEY_5;
+			break;
+#endif
+#ifdef KBD_ARCHKEY_6
+		case 6:
+			KBD_ARCHKEY_6;
+			break;
+#endif
+#ifdef KBD_ARCHKEY_7
+		case 7:
+			KBD_ARCHKEY_7;
+			break;
+#endif
+#ifdef KBD_ARCHKEY_8
+		case 8:
+			KBD_ARCHKEY_8;
+			break;
+#endif
+#ifdef KBD_ARCHKEY_9
+		case 9:
+			KBD_ARCHKEY_9;
+			break;
+#endif
+#ifdef KBD_ARCHKEY_10
+		case 10:
+			KBD_ARCHKEY_10;
+			break;
+#endif
+#ifdef KBD_ARCHKEY_11
+		case 11:
+			KBD_ARCHKEY_11;
+			break;
+#endif
+		default:
+			return;
+	}
+}
--- ref/drivers/char/keyboard.c	Tue Oct 12 19:05:53 1999
+++ work/drivers/char/keyboard.c	Tue Oct 26 23:13:17 1999
@@ -108,12 +111,12 @@
 static k_handfn
 	do_self, do_fn, do_spec, do_pad, do_dead, do_cons, do_cur, do_shift,
 	do_meta, do_ascii, do_lock, do_lowercase, do_slock, do_dead2,
-	do_ignore;
+	do_ignore, do_arch;
 
 static k_hand key_handler[16] = {
 	do_self, do_fn, do_spec, do_pad, do_dead, do_cons, do_cur, do_shift,
 	do_meta, do_ascii, do_lock, do_lowercase, do_slock, do_dead2,
-	do_ignore, do_ignore
+	do_ignore, do_arch
 };
 
 /* Key types processed even in raw modes */
@@ -155,7 +158,7 @@
 struct pt_regs * kbd_pt_regs;
 
 #ifdef CONFIG_MAGIC_SYSRQ
-static int sysrq_pressed;
+/*static*/ int sysrq_pressed;
 int sysrq_enabled = 1;
 #endif
 
@@ -515,6 +518,13 @@
 static void do_null()
 {
 	compute_shiftstate();
+}
+
+static void do_arch(unsigned char value, char up_flag)
+{
+#ifdef kbd_arch_handler
+	kbd_arch_handler(value,up_flag);
+#endif
 }
 
 static void do_spec(unsigned char value, char up_flag)
--- /dev/null	Tue May  5 22:32:27 1998
+++ work/drivers/char/keymap_psion.map	Tue Oct 26 20:20:57 1999
@@ -0,0 +1,233 @@
+# arch/arm/drivers/char/keymap_psion.map - UK (default) keyboard map
+#
[ ... boring stuff ... ]
+altgr	keycode  58 = Find				# Home
+	keycode  59 = comma		slash
+control alt keycode 59 = 0xf01				# SysRq
+	keycode  60 = Up		Scroll_Forward
+altgr	keycode  60 = Next
+	keycode	 61 = space
+altgr	keycode  61 = 0xf03				# Backlight
+	keycode  62 = F14				# STOP
+	keycode  63 = SShift
[...]
--- /dev/null	Tue May  5 22:32:27 1998
+++ work/include/asm-arm/arch-clps7110/kbd_psion.h	Tue Oct 26 20:21:15 1999
@@ -0,0 +1,87 @@
+/*
+ * include/asm-arm/arch-clps7110/kbd_psion.h
+ *
+ * Psion specific defines for it's keyboard.
+ *
+ * Copyright (C) Roger Gammans 1998
+ */
+ 
+
+#ifndef __ASM_ARCH_PSION_H
+#define __ASM_ARCH_PSION_H
+
+#include <asm/arch/clps7110.h>
+#include <asm/arch/hardware.h>
+
+ /*
+  * Arm's keyboard is active high row select...
+  *  (must try to remember)
+  */
+#define KB_ALLCOLS   KBSC_HI 
+#define KB_DISCHARGE KBSC_LO
+#define KB_LASTROW   7
+
+   /*
+    *  Be sure to change the if you increase the
+    *  number of kbd rows...
+    */
+#define KEYCODE(r,c)  ( ((c)<<3) + (r)+1)
+#define NR_KEYCODES 64
+
+#define KB_ROWMASK(r) (1 << (r))
+
+ /*
+  * KB_DELAY is used to allow the matrix 
+  * to stabilize.., value is determined via
+  * experimentation. 
+  */
+
+#define KB_DELAY   {16 ,16 ,16 ,16 ,16 ,16 ,16 ,16 ,16}
+
+ /*
+  * Not sure whether this trick works yet!
+  * 
+  */
+#undef KBD_SUPPORTS_WIREOR
+
+ 
+  /*
+   * treat debounce monostable as 30ms
+   */
+   
+#define KB_DEB_JIFFY (30/HZ)
+ 
+ /*
+  * only read from
+  */
+#define KB_ROW (IO_PADR & 0x7f)
+ 
+ /*
+  * only written to
+  */
+#define KB_COL(n)  IO_SYSCON = ((IO_SYSCON & ~KBDSCAN)  | (KBSC_COL0+n)) 
+
+
+/*
+ * Architecture-specific keys. Value 0 is invalid. 1 is SysRq.
+ */
+
+#define KBD_ARCHKEY_2	psion_off()
+#define KBD_ARCHKEY_3	psion_toggle_backlight()
+#define KBD_ARCHKEY_4	psion_contrast(0)
+#define KBD_ARCHKEY_5	psion_contrast(1)
+
+/* KBD_ARCHKEY_6 to KBD_ARCHKEY_11 reserved for debugging */
+
+#define KBD_ARCHKEY_6	psion_debug_power_led()	/* Ctrl-Alt-Z */
+
+/* #define KBD_ARCHKEY_11	psion_debug_cf() */
+
+void psion_off(void);
+void psion_toggle_backlight(void);
+void psion_contrast(int increase);
+
+void psion_debug_power_led(void);
+void psion_debug_cf(void);
+
+#endif
--- /dev/null	Tue May  5 22:32:27 1998
+++ work/include/asm-arm/arch-clps7110/keyboard.h	Tue Oct 26 20:21:15 1999
@@ -0,0 +1,108 @@
+/*
+ * include/asm-arm/arch-clps7110/keyboard.h
+ *   
+ * Part of the clps7110 keyboard driver.
+ *
+ * Copyright (C) Roger Gammans 1998
+ *
+ */
+
+
+#ifndef __ASM_ARCH_KEYBOARD_H
+#define __ASM_ARCH_KEYBOARD_H
+
+#include <asm/arch/clps7110.h>
+#include <asm/spinlock.h>
+
+#ifdef CONFIG_ARCH_GEOFOX
+#include <asm/arch/kbd_geofox.h>
+#else
+#ifdef CONFIG_ARCH_PSION
+#include <asm/arch/kbd_psion.h>
+#else
+#error Unknown Architecture
+#endif
+#endif
+/*
+ *#warning Keymaps for this architecture haven't been completed yet
+ */
[ ... lots of hardware-specific stuff ... ]
+extern unsigned char kbd7110_sysrq_xlate[NR_KEYCODES];
+#define kbd_sysrq_xlate		((sysrq_pressed = 0), kbd7110_sysrq_xlate)
+#define kbd_pretranslate(x,y)	(1)
+#define kbd_unexpected_up(kc)	(0x80)
+#define kbd_setkeycode(sc,kc)   (-EINVAL)
+#define kbd_getkeycode(sc)      (-EINVAL)
+
+extern void kbd7110_arch_handler(unsigned char value, char up_flag);
+#define kbd_arch_handler	kbd7110_arch_handler
+
+
+#define SYSRQ_KEY 0x100	/* dummy */
+


Más información sobre la lista de distribución Ayuda