Subversion Repositories shark

Rev

Rev 422 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
422 giacomo 1
/* -*- linux-c -*-
2
 *
3
 *      $Id: sysrq.h,v 1.1 2004-01-28 15:26:47 giacomo Exp $
4
 *
5
 *      Linux Magic System Request Key Hacks
6
 *
7
 *      (c) 1997 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
8
 *
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
12
 */
13
 
14
#include <linux/config.h>
15
 
16
struct pt_regs;
17
struct tty_struct;
18
 
19
struct sysrq_key_op {
20
        void (*handler)(int, struct pt_regs *, struct tty_struct *);
21
        char *help_msg;
22
        char *action_msg;
23
};
24
 
25
#ifdef CONFIG_MAGIC_SYSRQ
26
 
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).
30
 */
31
 
32
void handle_sysrq(int, struct pt_regs *, struct tty_struct *);
33
 
34
/*
35
 * Nonlocking version of handle sysrq, used by sysrq handlers that need to
36
 * call sysrq handlers
37
 */
38
 
39
void __handle_sysrq_nolock(int, struct pt_regs *, struct tty_struct *);
40
 
41
/*
42
 * Sysrq registration manipulation functions
43
 */
44
 
45
void __sysrq_lock_table (void);
46
void __sysrq_unlock_table (void);
47
struct sysrq_key_op *__sysrq_get_key_op (int key);
48
void __sysrq_put_key_op (int key, struct sysrq_key_op *op_p);
49
 
50
extern __inline__ int
51
__sysrq_swap_key_ops_nolock(int key, struct sysrq_key_op *insert_op_p,
52
                                struct sysrq_key_op *remove_op_p)
53
{
54
        int retval;
55
        if (__sysrq_get_key_op(key) == remove_op_p) {
56
                __sysrq_put_key_op(key, insert_op_p);
57
                retval = 0;
58
        } else {
59
                retval = -1;
60
        }
61
        return retval;
62
}
63
 
64
extern __inline__ int
65
__sysrq_swap_key_ops(int key, struct sysrq_key_op *insert_op_p,
66
                                struct sysrq_key_op *remove_op_p) {
67
        int retval;
68
        __sysrq_lock_table();
69
        retval = __sysrq_swap_key_ops_nolock(key, insert_op_p, remove_op_p);
70
        __sysrq_unlock_table();
71
        return retval;
72
}
73
 
74
static inline int register_sysrq_key(int key, struct sysrq_key_op *op_p)
75
{
76
        return __sysrq_swap_key_ops(key, op_p, NULL);
77
}
78
 
79
static inline int unregister_sysrq_key(int key, struct sysrq_key_op *op_p)
80
{
81
        return __sysrq_swap_key_ops(key, NULL, op_p);
82
}
83
 
84
#else
85
 
86
static inline int __reterr(void)
87
{
88
        return -EINVAL;
89
}
90
 
91
#define register_sysrq_key(ig,nore) __reterr()
92
#define unregister_sysrq_key(ig,nore) __reterr()
93
 
94
#endif