blob: 572aa4f5677cb7c6034a72e040a6c0b9bd4fcb34 [file] [log] [blame]
Jason Wessel53197fc2010-04-02 11:48:03 -05001/*
2 * Created by: Jason Wessel <jason.wessel@windriver.com>
3 *
4 * Copyright (c) 2009 Wind River Systems, Inc. All Rights Reserved.
5 *
6 * This file is licensed under the terms of the GNU General Public
7 * License version 2. This program is licensed "as is" without any
8 * warranty of any kind, whether express or implied.
9 */
10
11#ifndef _DEBUG_CORE_H_
12#define _DEBUG_CORE_H_
13/*
14 * These are the private implementation headers between the kernel
15 * debugger core and the debugger front end code.
16 */
17
18/* kernel debug core data structures */
19struct kgdb_state {
20 int ex_vector;
21 int signo;
22 int err_code;
23 int cpu;
24 int pass_exception;
25 unsigned long thr_query;
26 unsigned long threadid;
27 long kgdb_usethreadid;
28 struct pt_regs *linux_regs;
Mike Travis8daaa5f2013-10-02 10:14:18 -050029 atomic_t *send_ready;
Jason Wessel53197fc2010-04-02 11:48:03 -050030};
31
32/* Exception state values */
33#define DCPU_WANT_MASTER 0x1 /* Waiting to become a master kgdb cpu */
34#define DCPU_NEXT_MASTER 0x2 /* Transition from one master cpu to another */
35#define DCPU_IS_SLAVE 0x4 /* Slave cpu enter exception */
36#define DCPU_SSTEP 0x8 /* CPU is single stepping */
37
38struct debuggerinfo_struct {
39 void *debuggerinfo;
40 struct task_struct *task;
41 int exception_state;
Jason Wesseldcc78712010-05-20 21:04:21 -050042 int ret_state;
43 int irq_depth;
Jason Wesseldfee3a72010-05-21 08:46:00 -050044 int enter_kgdb;
Jason Wessel53197fc2010-04-02 11:48:03 -050045};
46
47extern struct debuggerinfo_struct kgdb_info[];
48
49/* kernel debug core break point routines */
50extern int dbg_remove_all_break(void);
51extern int dbg_set_sw_break(unsigned long addr);
52extern int dbg_remove_sw_break(unsigned long addr);
53extern int dbg_activate_sw_breakpoints(void);
Jason Wesseldcc78712010-05-20 21:04:21 -050054extern int dbg_deactivate_sw_breakpoints(void);
55
56/* polled character access to i/o module */
57extern int dbg_io_get_char(void);
58
59/* stub return value for switching between the gdbstub and kdb */
60#define DBG_PASS_EVENT -12345
61/* Switch from one cpu to another */
62#define DBG_SWITCH_CPU_EVENT -123456
63extern int dbg_switch_cpu;
Jason Wessel53197fc2010-04-02 11:48:03 -050064
65/* gdbstub interface functions */
66extern int gdb_serial_stub(struct kgdb_state *ks);
67extern void gdbstub_msg_write(const char *s, int len);
68
Jason Wesseldcc78712010-05-20 21:04:21 -050069/* gdbstub functions used for kdb <-> gdbstub transition */
70extern int gdbstub_state(struct kgdb_state *ks, char *cmd);
Jason Wessela0de0552010-05-20 21:04:24 -050071extern int dbg_kdb_mode;
Jason Wesseldcc78712010-05-20 21:04:21 -050072
73#ifdef CONFIG_KGDB_KDB
74extern int kdb_stub(struct kgdb_state *ks);
Jason Wessela0de0552010-05-20 21:04:24 -050075extern int kdb_parse(const char *cmdstr);
Matt Klein00370b82013-01-02 13:20:49 -080076extern int kdb_common_init_state(struct kgdb_state *ks);
77extern int kdb_common_deinit_state(void);
Mike Travis8daaa5f2013-10-02 10:14:18 -050078#define KGDB_KDB_REASON_SYSTEM_NMI KDB_REASON_SYSTEM_NMI
Jason Wesseldcc78712010-05-20 21:04:21 -050079#else /* ! CONFIG_KGDB_KDB */
80static inline int kdb_stub(struct kgdb_state *ks)
81{
82 return DBG_PASS_EVENT;
83}
Mike Travis8daaa5f2013-10-02 10:14:18 -050084#define KGDB_KDB_REASON_SYSTEM_NMI 0
Jason Wesseldcc78712010-05-20 21:04:21 -050085#endif /* CONFIG_KGDB_KDB */
86
Jason Wessel53197fc2010-04-02 11:48:03 -050087#endif /* _DEBUG_CORE_H_ */