1 /*
2  * Copyright (C) 2005 Hollis Blanchard <hollisb@us.ibm.com>, IBM Corporation
3  * Copyright (C) 2006 Isaku Yamahata <yamahata at valinux co jp>
4  *                    VA Linux Systems Japan. K.K.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef __XEN_GDBSTUB_H__
21 #define __XEN_GDBSTUB_H__
22 
23 #include <asm/atomic.h>
24 #include <asm/page.h>
25 
26 #ifdef CONFIG_CRASH_DEBUG
27 
28 struct gdb_context {
29     int                 serhnd;           /* handle on our serial line */
30     int                 console_steal_id; /* handle on stolen console */
31     bool_t              currently_attached;
32     atomic_t            running;
33     unsigned long       connected;
34     u8                  signum;
35 
36     char                in_buf[PAGE_SIZE];
37     unsigned long       in_bytes;
38 
39     char                out_buf[PAGE_SIZE];
40     unsigned long       out_offset;
41     u8                  out_csum;
42 };
43 
44 /* interface to arch specific routines */
45 void gdb_write_to_packet(
46     const char *buf, int count, struct gdb_context *ctx);
47 void gdb_write_to_packet_hex(
48     unsigned long x, int int_size, struct gdb_context *ctx);
49     /* ... writes in target native byte order as required by gdb spec. */
50 void gdb_send_packet(struct gdb_context *ctx);
51 void gdb_send_reply(const char *buf, struct gdb_context *ctx);
52 
53 /* gdb stub trap handler: entry point */
54 int __trap_to_gdb(struct cpu_user_regs *regs, unsigned long cookie);
55 
56 /* arch specific routines */
57 u16 gdb_arch_signal_num(
58     struct cpu_user_regs *regs, unsigned long cookie);
59 void gdb_arch_read_reg_array(
60     struct cpu_user_regs *regs, struct gdb_context *ctx);
61 void gdb_arch_write_reg_array(
62     struct cpu_user_regs *regs, const char* buf, struct gdb_context *ctx);
63 void gdb_arch_read_reg(
64     unsigned long regnum, struct cpu_user_regs *regs, struct gdb_context *ctx);
65 void gdb_arch_write_reg(
66     unsigned long regnum, unsigned long val, struct cpu_user_regs *regs,
67     struct gdb_context *ctx);
68 unsigned int gdb_arch_copy_from_user(
69     void *dest, const void *src, unsigned len);
70 unsigned int gdb_arch_copy_to_user(
71     void *dest, const void *src, unsigned len);
72 void gdb_arch_resume(
73     struct cpu_user_regs *regs, unsigned long addr,
74     unsigned long type, struct gdb_context *ctx);
75 void gdb_arch_print_state(struct cpu_user_regs *regs);
76 void gdb_arch_enter(struct cpu_user_regs *regs);
77 void gdb_arch_exit(struct cpu_user_regs *regs);
78 
79 #define GDB_CONTINUE     0
80 #define GDB_STEP         1
81 
82 #define SIGILL           4
83 #define SIGTRAP          5
84 #define SIGBUS           7
85 #define SIGFPE           8
86 #define SIGSEGV         11
87 #define SIGALRM         14
88 #define SIGTERM         15
89 
90 #endif
91 
92 #endif /* __XEN_GDBSTUB_H__ */
93 
94 /*
95  * Local variables:
96  * mode: C
97  * c-file-style: "BSD"
98  * c-basic-offset: 4
99  * tab-width: 4
100  * End:
101  */
102