kdb: Remove KDB_REPEAT_NONE flag
[deliverable/linux.git] / include / linux / kdb.h
CommitLineData
5d5314d6
JW
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
729043e8 16typedef enum {
04bb171e
AV
17 KDB_REPEAT_NO_ARGS = 0x1, /* Repeat the command w/o arguments */
18 KDB_REPEAT_WITH_ARGS = 0x2, /* Repeat the command w/ its arguments */
15a42a9b 19} kdb_cmdflags_t;
729043e8
AV
20
21typedef int (*kdb_func_t)(int, const char **);
22
5d5314d6
JW
23#ifdef CONFIG_KGDB_KDB
24#include <linux/init.h>
25#include <linux/sched.h>
60063497 26#include <linux/atomic.h>
5d5314d6
JW
27
28#define KDB_POLL_FUNC_MAX 5
f5316b4a 29extern int kdb_poll_idx;
5d5314d6
JW
30
31/*
32 * kdb_initial_cpu is initialized to -1, and is set to the cpu
33 * number whenever the kernel debugger is entered.
34 */
35extern int kdb_initial_cpu;
36extern atomic_t kdb_event;
37
f7030bbc
JW
38/* Types and messages used for dynamically added kdb shell commands */
39
40#define KDB_MAXARGS 16 /* Maximum number of arguments to a function */
41
f7030bbc
JW
42/* KDB return codes from a command or internal kdb function */
43#define KDB_NOTFOUND (-1)
44#define KDB_ARGCOUNT (-2)
45#define KDB_BADWIDTH (-3)
46#define KDB_BADRADIX (-4)
47#define KDB_NOTENV (-5)
48#define KDB_NOENVVALUE (-6)
49#define KDB_NOTIMP (-7)
50#define KDB_ENVFULL (-8)
51#define KDB_ENVBUFFULL (-9)
52#define KDB_TOOMANYBPT (-10)
53#define KDB_TOOMANYDBREGS (-11)
54#define KDB_DUPBPT (-12)
55#define KDB_BPTNOTFOUND (-13)
56#define KDB_BADMODE (-14)
57#define KDB_BADINT (-15)
58#define KDB_INVADDRFMT (-16)
59#define KDB_BADREG (-17)
60#define KDB_BADCPUNUM (-18)
61#define KDB_BADLENGTH (-19)
62#define KDB_NOBP (-20)
63#define KDB_BADADDR (-21)
64
5d5314d6
JW
65/*
66 * kdb_diemsg
67 *
68 * Contains a pointer to the last string supplied to the
69 * kernel 'die' panic function.
70 */
71extern const char *kdb_diemsg;
72
73#define KDB_FLAG_EARLYKDB (1 << 0) /* set from boot parameter kdb=early */
74#define KDB_FLAG_CATASTROPHIC (1 << 1) /* A catastrophic event has occurred */
75#define KDB_FLAG_CMD_INTERRUPT (1 << 2) /* Previous command was interrupted */
76#define KDB_FLAG_NOIPI (1 << 3) /* Do not send IPIs */
5d5314d6
JW
77#define KDB_FLAG_NO_CONSOLE (1 << 5) /* No console is available,
78 * kdb is disabled */
79#define KDB_FLAG_NO_VT_CONSOLE (1 << 6) /* No VT console is available, do
80 * not use keyboard */
81#define KDB_FLAG_NO_I8042 (1 << 7) /* No i8042 chip is available, do
82 * not use keyboard */
83
84extern int kdb_flags; /* Global flags, see kdb_state for per cpu state */
85
86extern void kdb_save_flags(void);
87extern void kdb_restore_flags(void);
88
89#define KDB_FLAG(flag) (kdb_flags & KDB_FLAG_##flag)
90#define KDB_FLAG_SET(flag) ((void)(kdb_flags |= KDB_FLAG_##flag))
91#define KDB_FLAG_CLEAR(flag) ((void)(kdb_flags &= ~KDB_FLAG_##flag))
92
93/*
94 * External entry point for the kernel debugger. The pt_regs
95 * at the time of entry are supplied along with the reason for
96 * entry to the kernel debugger.
97 */
98
99typedef enum {
100 KDB_REASON_ENTER = 1, /* KDB_ENTER() trap/fault - regs valid */
101 KDB_REASON_ENTER_SLAVE, /* KDB_ENTER_SLAVE() trap/fault - regs valid */
102 KDB_REASON_BREAK, /* Breakpoint inst. - regs valid */
103 KDB_REASON_DEBUG, /* Debug Fault - regs valid */
104 KDB_REASON_OOPS, /* Kernel Oops - regs valid */
105 KDB_REASON_SWITCH, /* CPU switch - regs valid*/
106 KDB_REASON_KEYBOARD, /* Keyboard entry - regs valid */
107 KDB_REASON_NMI, /* Non-maskable interrupt; regs valid */
108 KDB_REASON_RECURSE, /* Recursive entry to kdb;
109 * regs probably valid */
110 KDB_REASON_SSTEP, /* Single Step trap. - regs valid */
8daaa5f8 111 KDB_REASON_SYSTEM_NMI, /* In NMI due to SYSTEM cmd; regs valid */
5d5314d6
JW
112} kdb_reason_t;
113
d37d39ae 114extern int kdb_trap_printk;
b9075fa9
JP
115extern __printf(1, 0) int vkdb_printf(const char *fmt, va_list args);
116extern __printf(1, 2) int kdb_printf(const char *, ...);
117typedef __printf(1, 2) int (*kdb_printf_t)(const char *, ...);
5d5314d6
JW
118
119extern void kdb_init(int level);
120
121/* Access to kdb specific polling devices */
122typedef int (*get_char_func)(void);
123extern get_char_func kdb_poll_funcs[];
124extern int kdb_get_kbd_char(void);
125
126static inline
127int kdb_process_cpu(const struct task_struct *p)
128{
129 unsigned int cpu = task_thread_info(p)->cpu;
130 if (cpu > num_possible_cpus())
131 cpu = 0;
132 return cpu;
133}
134
135/* kdb access to register set for stack dumping */
136extern struct pt_regs *kdb_current_regs;
91b152aa
JW
137#ifdef CONFIG_KALLSYMS
138extern const char *kdb_walk_kallsyms(loff_t *pos);
139#else /* ! CONFIG_KALLSYMS */
140static inline const char *kdb_walk_kallsyms(loff_t *pos)
141{
142 return NULL;
143}
144#endif /* ! CONFIG_KALLSYMS */
5d5314d6 145
f7030bbc
JW
146/* Dynamic kdb shell command registration */
147extern int kdb_register(char *, kdb_func_t, char *, char *, short);
42c884c1
AV
148extern int kdb_register_flags(char *, kdb_func_t, char *, char *,
149 short, kdb_cmdflags_t);
f7030bbc 150extern int kdb_unregister(char *);
5d5314d6 151#else /* ! CONFIG_KGDB_KDB */
729043e8
AV
152static inline __printf(1, 2) int kdb_printf(const char *fmt, ...) { return 0; }
153static inline void kdb_init(int level) {}
154static inline int kdb_register(char *cmd, kdb_func_t func, char *usage,
155 char *help, short minlen) { return 0; }
42c884c1
AV
156static inline int kdb_register_flags(char *cmd, kdb_func_t func, char *usage,
157 char *help, short minlen,
158 kdb_cmdflags_t flags) { return 0; }
729043e8 159static inline int kdb_unregister(char *cmd) { return 0; }
5d5314d6
JW
160#endif /* CONFIG_KGDB_KDB */
161enum {
162 KDB_NOT_INITIALIZED,
163 KDB_INIT_EARLY,
164 KDB_INIT_FULL,
165};
81d44507
JW
166
167extern int kdbgetintenv(const char *, int *);
168extern int kdb_set(int, const char **);
169
5d5314d6 170#endif /* !_KDB_H */
This page took 0.397129 seconds and 5 git commands to generate.