MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / include / linux / sysrq.h
blob7fe8012f79f9823e83e0bb266a54e6d3e1eecd2c
1 /* -*- linux-c -*-
3 * $Id: sysrq.h,v 1.3 1997/07/17 11:54:33 mj Exp $
5 * Linux Magic System Request Key Hacks
7 * (c) 1997 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
9 * (c) 2000 Crutcher Dunnavant <crutcher+kernel@datastacks.com>
10 * overhauled to use key registration
11 * based upon discusions in irc://irc.openprojects.net/#kernelnewbies
14 #include <linux/config.h>
16 struct pt_regs;
17 struct tty_struct;
19 struct sysrq_key_op {
20 void (*handler)(int, struct pt_regs *, struct tty_struct *);
21 char *help_msg;
22 char *action_msg;
25 #ifdef CONFIG_MAGIC_SYSRQ
27 /* Generic SysRq interface -- you may call it from any device driver, supplying
28 * ASCII code of the key, pointer to registers and kbd/tty structs (if they
29 * are available -- else NULL's).
32 void handle_sysrq(int, struct pt_regs *, struct tty_struct *);
33 void __handle_sysrq(int, struct pt_regs *, struct tty_struct *);
36 * Sysrq registration manipulation functions
39 void __sysrq_lock_table (void);
40 void __sysrq_unlock_table (void);
41 struct sysrq_key_op *__sysrq_get_key_op (int key);
42 void __sysrq_put_key_op (int key, struct sysrq_key_op *op_p);
44 extern __inline__ int
45 __sysrq_swap_key_ops_nolock(int key, struct sysrq_key_op *insert_op_p,
46 struct sysrq_key_op *remove_op_p)
48 int retval;
49 if (__sysrq_get_key_op(key) == remove_op_p) {
50 __sysrq_put_key_op(key, insert_op_p);
51 retval = 0;
52 } else {
53 retval = -1;
55 return retval;
58 extern __inline__ int
59 __sysrq_swap_key_ops(int key, struct sysrq_key_op *insert_op_p,
60 struct sysrq_key_op *remove_op_p) {
61 int retval;
62 __sysrq_lock_table();
63 retval = __sysrq_swap_key_ops_nolock(key, insert_op_p, remove_op_p);
64 __sysrq_unlock_table();
65 return retval;
68 static inline int register_sysrq_key(int key, struct sysrq_key_op *op_p)
70 return __sysrq_swap_key_ops(key, op_p, NULL);
73 static inline int unregister_sysrq_key(int key, struct sysrq_key_op *op_p)
75 return __sysrq_swap_key_ops(key, NULL, op_p);
78 #else
80 static inline int __reterr(void)
82 return -EINVAL;
85 #define register_sysrq_key(ig,nore) __reterr()
86 #define unregister_sysrq_key(ig,nore) __reterr()
88 #endif