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