Annotation of sys/arch/m68k/m68k/kgdb_m68k.c, Revision 1.1.1.1
1.1 nbrk 1: /* $OpenBSD: kgdb_m68k.c,v 1.2 2003/06/02 23:27:48 millert Exp $ */
2: /* $NetBSD: kgdb_m68k.c,v 1.1 1997/02/12 00:58:01 gwr Exp $ */
3:
4: /*
5: * Copyright (c) 1990, 1993
6: * The Regents of the University of California. All rights reserved.
7: *
8: * This software was developed by the Computer Systems Engineering group
9: * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
10: * contributed to Berkeley.
11: *
12: * All advertising materials mentioning features or use of this software
13: * must display the following acknowledgement:
14: * This product includes software developed by the University of
15: * California, Lawrence Berkeley Laboratories.
16: *
17: * Redistribution and use in source and binary forms, with or without
18: * modification, are permitted provided that the following conditions
19: * are met:
20: * 1. Redistributions of source code must retain the above copyright
21: * notice, this list of conditions and the following disclaimer.
22: * 2. Redistributions in binary form must reproduce the above copyright
23: * notice, this list of conditions and the following disclaimer in the
24: * documentation and/or other materials provided with the distribution.
25: * 3. Neither the name of the University nor the names of its contributors
26: * may be used to endorse or promote products derived from this software
27: * without specific prior written permission.
28: *
29: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
30: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
33: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
35: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
38: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39: * SUCH DAMAGE.
40: *
41: * @(#)kgdb_stub.c 8.4 (Berkeley) 1/12/94
42: */
43:
44: /*
45: * Machine-dependent (m68k) part of the KGDB remote "stub"
46: */
47:
48: #include <sys/param.h>
49: #include <sys/kgdb.h>
50:
51: #include <machine/frame.h>
52: #include <machine/trap.h>
53:
54: /*
55: * Translate a trap number into a unix compatible signal value.
56: * (gdb only understands unix signal numbers).
57: */
58: int
59: kgdb_signal(type)
60: int type;
61: {
62: int sigval;
63:
64: switch (type) {
65:
66: case T_ASTFLT:
67: case T_SSIR:
68: sigval = SIGINT;
69: break;
70:
71: case T_ILLINST:
72: case T_PRIVINST:
73: case T_FMTERR:
74: sigval = SIGILL;
75: break;
76:
77: case T_TRACE:
78: case T_TRAP15:
79: sigval = SIGTRAP;
80: break;
81:
82: case T_ZERODIV:
83: case T_CHKINST:
84: case T_TRAPVINST:
85: case T_FPERR:
86: case T_COPERR:
87: sigval = SIGFPE;
88: break;
89:
90: case T_BUSERR:
91: case T_ADDRERR:
92: sigval = SIGBUS;
93: break;
94:
95: case T_MMUFLT:
96: sigval = SIGSEGV;
97: break;
98:
99: default:
100: sigval = SIGEMT;
101: break;
102: }
103: return (sigval);
104: }
105:
106: /*
107: * Definitions exported from gdb.
108: */
109: /* KGDB_NUMREGS == 18 */
110:
111: #define GDB_SR 16
112: #define GDB_PC 17
113:
114:
115: /*
116: * Translate the values stored in the kernel regs struct to/from
117: * the format understood by gdb.
118: *
119: * There is a short pad word between SP (A7) and SR which keeps the
120: * kernel stack long word aligned (note that this is in addition to
121: * the stack adjust short that we treat as the upper half of the SR
122: * (always zero). We must skip this when copying to/from gdb regs.
123: */
124:
125: void
126: kgdb_getregs(regs, gdb_regs)
127: db_regs_t *regs;
128: kgdb_reg_t *gdb_regs;
129: {
130: int i;
131:
132: for (i = 0; i < 16; i++)
133: gdb_regs[i] = regs->tf_regs[i];
134: gdb_regs[GDB_SR] = regs->tf_sr;
135: gdb_regs[GDB_PC] = regs->tf_pc;
136: }
137:
138: void
139: kgdb_setregs(regs, gdb_regs)
140: db_regs_t *regs;
141: kgdb_reg_t *gdb_regs;
142: {
143: int i;
144:
145: for (i = 0; i < 16; i++)
146: regs->tf_regs[i] = gdb_regs[i];
147: regs->tf_sr = gdb_regs[GDB_SR] |
148: (regs->tf_sr & PSL_T);
149: regs->tf_pc = gdb_regs[GDB_PC];
150: }
CVSweb