patch-2.4.10 linux/include/linux/sysrq.h
Next file: linux/include/linux/sysv_fs.h
Previous file: linux/include/linux/sysctl.h
Back to the patch index
Back to the overall index
- Lines: 92
- Date:
Mon Sep 17 22:52:35 2001
- Orig file:
v2.4.9/linux/include/linux/sysrq.h
- Orig date:
Tue Aug 7 12:48:42 2001
diff -u --recursive --new-file v2.4.9/linux/include/linux/sysrq.h linux/include/linux/sysrq.h
@@ -5,6 +5,10 @@
* Linux Magic System Request Key Hacks
*
* (c) 1997 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
+ *
+ * (c) 2000 Crutcher Dunnavant <crutcher+kernel@datastacks.com>
+ * overhauled to use key registration
+ * based upon discusions in irc://irc.openprojects.net/#kernelnewbies
*/
#include <linux/config.h>
@@ -13,12 +17,79 @@
struct kbd_struct;
struct tty_struct;
+struct sysrq_key_op {
+ void (*handler)(int, struct pt_regs *,
+ struct kbd_struct *, struct tty_struct *);
+ char *help_msg;
+ char *action_msg;
+};
+
/* 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 *);
+void handle_sysrq(int, struct pt_regs *,
+ struct kbd_struct *, struct tty_struct *);
+
+
+/*
+ * Nonlocking version of handle sysrq, used by sysrq handlers that need to
+ * call sysrq handlers
+ */
+
+void __handle_sysrq_nolock(int, struct pt_regs *,
+ struct kbd_struct *, struct tty_struct *);
+
+
+#ifdef CONFIG_MAGIC_SYSRQ
+
+/*
+ * Sysrq registration manipulation functions
+ */
+
+void __sysrq_lock_table (void);
+void __sysrq_unlock_table (void);
+struct sysrq_key_op *__sysrq_get_key_op (int key);
+void __sysrq_put_key_op (int key, struct sysrq_key_op *op_p);
+
+extern __inline__ int
+__sysrq_swap_key_ops_nolock(int key, struct sysrq_key_op *insert_op_p,
+ struct sysrq_key_op *remove_op_p) {
+ int retval;
+ if (__sysrq_get_key_op(key) == remove_op_p) {
+ __sysrq_put_key_op(key, insert_op_p);
+ retval = 0;
+ } else {
+ retval = -1;
+ }
+ return retval;
+}
+
+extern __inline__ int
+__sysrq_swap_key_ops(int key, struct sysrq_key_op *insert_op_p,
+ struct sysrq_key_op *remove_op_p) {
+ int retval;
+ __sysrq_lock_table();
+ retval = __sysrq_swap_key_ops_nolock(key, insert_op_p, remove_op_p);
+ __sysrq_unlock_table();
+ return retval;
+}
+
+static inline int register_sysrq_key(int key, struct sysrq_key_op *op_p)
+{
+ return __sysrq_swap_key_ops(key, op_p, NULL);
+}
+
+static inline int unregister_sysrq_key(int key, struct sysrq_key_op *op_p)
+{
+ return __sysrq_swap_key_ops(key, NULL, op_p);
+}
+
+#else
+#define register_sysrq_key(a,b) do {} while(0)
+#define unregister_sysrq_key(a,b) do {} while(0)
+#endif
/* Deferred actions */
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)