diff options
Diffstat (limited to 'include/linux/kdb.h')
-rw-r--r-- | include/linux/kdb.h | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/include/linux/kdb.h b/include/linux/kdb.h new file mode 100644 index 000000000000..ccb2b3ec0fe8 --- /dev/null +++ b/include/linux/kdb.h | |||
@@ -0,0 +1,117 @@ | |||
1 | #ifndef _KDB_H | ||
2 | #define _KDB_H | ||
3 | |||
4 | /* | ||
5 | * Kernel Debugger Architecture Independent Global Headers | ||
6 | * | ||
7 | * This file is subject to the terms and conditions of the GNU General Public | ||
8 | * License. See the file "COPYING" in the main directory of this archive | ||
9 | * for more details. | ||
10 | * | ||
11 | * Copyright (c) 2000-2007 Silicon Graphics, Inc. All Rights Reserved. | ||
12 | * Copyright (C) 2000 Stephane Eranian <eranian@hpl.hp.com> | ||
13 | * Copyright (C) 2009 Jason Wessel <jason.wessel@windriver.com> | ||
14 | */ | ||
15 | |||
16 | #ifdef CONFIG_KGDB_KDB | ||
17 | #include <linux/init.h> | ||
18 | #include <linux/sched.h> | ||
19 | #include <asm/atomic.h> | ||
20 | |||
21 | #define KDB_POLL_FUNC_MAX 5 | ||
22 | extern int kdb_poll_idx; | ||
23 | |||
24 | /* | ||
25 | * kdb_initial_cpu is initialized to -1, and is set to the cpu | ||
26 | * number whenever the kernel debugger is entered. | ||
27 | */ | ||
28 | extern int kdb_initial_cpu; | ||
29 | extern atomic_t kdb_event; | ||
30 | |||
31 | /* | ||
32 | * kdb_diemsg | ||
33 | * | ||
34 | * Contains a pointer to the last string supplied to the | ||
35 | * kernel 'die' panic function. | ||
36 | */ | ||
37 | extern const char *kdb_diemsg; | ||
38 | |||
39 | #define KDB_FLAG_EARLYKDB (1 << 0) /* set from boot parameter kdb=early */ | ||
40 | #define KDB_FLAG_CATASTROPHIC (1 << 1) /* A catastrophic event has occurred */ | ||
41 | #define KDB_FLAG_CMD_INTERRUPT (1 << 2) /* Previous command was interrupted */ | ||
42 | #define KDB_FLAG_NOIPI (1 << 3) /* Do not send IPIs */ | ||
43 | #define KDB_FLAG_ONLY_DO_DUMP (1 << 4) /* Only do a dump, used when | ||
44 | * kdb is off */ | ||
45 | #define KDB_FLAG_NO_CONSOLE (1 << 5) /* No console is available, | ||
46 | * kdb is disabled */ | ||
47 | #define KDB_FLAG_NO_VT_CONSOLE (1 << 6) /* No VT console is available, do | ||
48 | * not use keyboard */ | ||
49 | #define KDB_FLAG_NO_I8042 (1 << 7) /* No i8042 chip is available, do | ||
50 | * not use keyboard */ | ||
51 | |||
52 | extern int kdb_flags; /* Global flags, see kdb_state for per cpu state */ | ||
53 | |||
54 | extern void kdb_save_flags(void); | ||
55 | extern void kdb_restore_flags(void); | ||
56 | |||
57 | #define KDB_FLAG(flag) (kdb_flags & KDB_FLAG_##flag) | ||
58 | #define KDB_FLAG_SET(flag) ((void)(kdb_flags |= KDB_FLAG_##flag)) | ||
59 | #define KDB_FLAG_CLEAR(flag) ((void)(kdb_flags &= ~KDB_FLAG_##flag)) | ||
60 | |||
61 | /* | ||
62 | * External entry point for the kernel debugger. The pt_regs | ||
63 | * at the time of entry are supplied along with the reason for | ||
64 | * entry to the kernel debugger. | ||
65 | */ | ||
66 | |||
67 | typedef enum { | ||
68 | KDB_REASON_ENTER = 1, /* KDB_ENTER() trap/fault - regs valid */ | ||
69 | KDB_REASON_ENTER_SLAVE, /* KDB_ENTER_SLAVE() trap/fault - regs valid */ | ||
70 | KDB_REASON_BREAK, /* Breakpoint inst. - regs valid */ | ||
71 | KDB_REASON_DEBUG, /* Debug Fault - regs valid */ | ||
72 | KDB_REASON_OOPS, /* Kernel Oops - regs valid */ | ||
73 | KDB_REASON_SWITCH, /* CPU switch - regs valid*/ | ||
74 | KDB_REASON_KEYBOARD, /* Keyboard entry - regs valid */ | ||
75 | KDB_REASON_NMI, /* Non-maskable interrupt; regs valid */ | ||
76 | KDB_REASON_RECURSE, /* Recursive entry to kdb; | ||
77 | * regs probably valid */ | ||
78 | KDB_REASON_SSTEP, /* Single Step trap. - regs valid */ | ||
79 | } kdb_reason_t; | ||
80 | |||
81 | extern int kdb_trap_printk; | ||
82 | extern int vkdb_printf(const char *fmt, va_list args) | ||
83 | __attribute__ ((format (printf, 1, 0))); | ||
84 | extern int kdb_printf(const char *, ...) | ||
85 | __attribute__ ((format (printf, 1, 2))); | ||
86 | typedef int (*kdb_printf_t)(const char *, ...) | ||
87 | __attribute__ ((format (printf, 1, 2))); | ||
88 | |||
89 | extern void kdb_init(int level); | ||
90 | |||
91 | /* Access to kdb specific polling devices */ | ||
92 | typedef int (*get_char_func)(void); | ||
93 | extern get_char_func kdb_poll_funcs[]; | ||
94 | extern int kdb_get_kbd_char(void); | ||
95 | |||
96 | static inline | ||
97 | int kdb_process_cpu(const struct task_struct *p) | ||
98 | { | ||
99 | unsigned int cpu = task_thread_info(p)->cpu; | ||
100 | if (cpu > num_possible_cpus()) | ||
101 | cpu = 0; | ||
102 | return cpu; | ||
103 | } | ||
104 | |||
105 | /* kdb access to register set for stack dumping */ | ||
106 | extern struct pt_regs *kdb_current_regs; | ||
107 | |||
108 | #else /* ! CONFIG_KGDB_KDB */ | ||
109 | #define kdb_printf(...) | ||
110 | #define kdb_init(x) | ||
111 | #endif /* CONFIG_KGDB_KDB */ | ||
112 | enum { | ||
113 | KDB_NOT_INITIALIZED, | ||
114 | KDB_INIT_EARLY, | ||
115 | KDB_INIT_FULL, | ||
116 | }; | ||
117 | #endif /* !_KDB_H */ | ||