1 /* $NetBSD: kgdb_machdep.c,v 1.11 2005/12/24 22:45:35 perry Exp $ */
4 * Copyright (c) 2004 Marcel Moolenaar
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 * Copyright (c) 1997 The NetBSD Foundation, Inc.
30 * All rights reserved.
32 * This code is derived from software contributed to The NetBSD Foundation
33 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
34 * NASA Ames Research Center.
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
39 * 1. Redistributions of source code must retain the above copyright
40 * notice, this list of conditions and the following disclaimer.
41 * 2. Redistributions in binary form must reproduce the above copyright
42 * notice, this list of conditions and the following disclaimer in the
43 * documentation and/or other materials provided with the distribution.
45 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
46 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
47 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
48 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
49 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
50 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
51 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
52 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
53 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
54 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
55 * POSSIBILITY OF SUCH DAMAGE.
59 * Copyright (c) 1996 Matthias Pfaller.
60 * All rights reserved.
62 * Redistribution and use in source and binary forms, with or without
63 * modification, are permitted provided that the following conditions
65 * 1. Redistributions of source code must retain the above copyright
66 * notice, this list of conditions and the following disclaimer.
67 * 2. Redistributions in binary form must reproduce the above copyright
68 * notice, this list of conditions and the following disclaimer in the
69 * documentation and/or other materials provided with the distribution.
70 * 3. All advertising materials mentioning features or use of this software
71 * must display the following acknowledgement:
72 * This product includes software developed by Matthias Pfaller.
73 * 4. The name of the author may not be used to endorse or promote products
74 * derived from this software without specific prior written permission
76 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
77 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
78 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
79 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
80 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
81 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
82 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
83 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
84 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
85 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
87 * JNPR: gdb_machdep.c,v 1.1 2007/08/09 12:25:25 katta
91 #include <sys/cdefs.h>
93 #include <sys/param.h>
94 #include <sys/systm.h>
96 #include <sys/kernel.h>
97 #include <sys/signal.h>
100 #include <machine/gdb_machdep.h>
101 #include <machine/pcb.h>
102 #include <machine/reg.h>
103 #include <machine/trap.h>
108 gdb_cpu_getreg(int regnum, size_t *regsz)
111 *regsz = gdb_cpu_regsz(regnum);
112 if (kdb_thread == curthread) {
113 register_t *zero_ptr = &kdb_frame->zero;
114 return zero_ptr + regnum;
129 return (&kdb_thrctx->pcb_context[PCB_REG_S0 + regnum - 16]);
131 return (&kdb_thrctx->pcb_context[PCB_REG_GP]);
133 return (&kdb_thrctx->pcb_context[PCB_REG_SP]);
135 return (&kdb_thrctx->pcb_context[PCB_REG_S8]);
137 return (&kdb_thrctx->pcb_context[PCB_REG_RA]);
139 return (&kdb_thrctx->pcb_context[PCB_REG_PC]);
145 gdb_cpu_setreg(int regnum, void *val)
149 kdb_thrctx->pcb_context[10] = *(register_t *)val;
150 if (kdb_thread == curthread)
151 kdb_frame->pc = *(register_t *)val;
156 gdb_cpu_signal(int entry, int code)
160 case T_TLB_MOD+T_USER:
163 case T_TLB_LD_MISS+T_USER:
164 case T_TLB_ST_MISS+T_USER:
165 case T_ADDR_ERR_LD: /* misaligned access */
166 case T_ADDR_ERR_ST: /* misaligned access */
167 case T_BUS_ERR_LD_ST: /* BERR asserted to CPU */
168 case T_ADDR_ERR_LD+T_USER: /* misaligned or kseg access */
169 case T_ADDR_ERR_ST+T_USER: /* misaligned or kseg access */
170 case T_BUS_ERR_IFETCH+T_USER: /* BERR asserted to CPU */
171 case T_BUS_ERR_LD_ST+T_USER: /* BERR asserted to CPU */
178 case T_RES_INST+T_USER:
179 case T_COP_UNUSABLE+T_USER:
183 case T_OVFLOW+T_USER: