1 /******************************************************************************
2  * keyhandler.h
3  *
4  * We keep an array of 'handlers' for each key code between 0 and 255;
5  * this is intended to allow very simple debugging routines (toggle
6  * debug flag, dump registers, reboot, etc) to be hooked in in a slightly
7  * nicer fashion than just editing the serial/keyboard drivers.
8  */
9 
10 #ifndef __XEN_KEYHANDLER_H__
11 #define __XEN_KEYHANDLER_H__
12 
13 #include <xen/types.h>
14 
15 /*
16  * Callback type for keyhander.
17  *
18  * Called in softirq context with interrupts enabled.
19  */
20 typedef void (keyhandler_fn_t)(unsigned char key);
21 
22 /*
23  * Callback type for irq_keyhandler.
24  *
25  * Called in hardirq context with interrupts disabled.
26  */
27 typedef void (irq_keyhandler_fn_t)(unsigned char key,
28                                    bool need_context);
29 
30 /* Initialize keytable with default handlers. */
31 void initialize_keytable(void);
32 
33 /*
34  * Regiser a callback handler for key @key for either plain or irq context.
35  * If @diagnostic is set, the handler will be included in the "dump
36  * everything" keyhandler.
37  */
38 void register_keyhandler(unsigned char key,
39                          keyhandler_fn_t *fn,
40                          const char *desc,
41                          bool diagnostic);
42 void register_irq_keyhandler(unsigned char key,
43                              irq_keyhandler_fn_t *fn,
44                              const char *desc,
45                              bool diagnostic);
46 
47 /* Inject a keypress into the key-handling subsystem. */
48 extern void handle_keypress(unsigned char key, bool need_context);
49 
50 enum crash_reason {
51     CRASHREASON_PANIC,
52     CRASHREASON_HWDOM,
53     CRASHREASON_WATCHDOG,
54     CRASHREASON_KEXECCMD,
55     CRASHREASON_DEBUGKEY,
56 };
57 
58 void keyhandler_crash_action(enum crash_reason reason);
59 
60 #endif /* __XEN_KEYHANDLER_H__ */
61