Annotation of sys/arch/sparc/sparc/db_interface.c, Revision 1.1.1.1
1.1 nbrk 1: /* $OpenBSD: db_interface.c,v 1.12 2005/04/19 21:30:20 miod Exp $ */
2: /* $NetBSD: db_interface.c,v 1.18 1997/09/01 00:16:31 pk Exp $ */
3:
4: /*
5: * Mach Operating System
6: * Copyright (c) 1991,1990 Carnegie Mellon University
7: * All Rights Reserved.
8: *
9: * Permission to use, copy, modify and distribute this software and its
10: * documentation is hereby granted, provided that both the copyright
11: * notice and this permission notice appear in all copies of the
12: * software, derivative works or modified versions, and any portions
13: * thereof, and that both notices appear in supporting documentation.
14: *
15: * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS
16: * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
17: * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
18: *
19: * Carnegie Mellon requests users of this software to return to
20: *
21: * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
22: * School of Computer Science
23: * Carnegie Mellon University
24: * Pittsburgh PA 15213-3890
25: *
26: * any improvements or extensions that they make and grant Carnegie the
27: * rights to redistribute these changes.
28: *
29: * From: db_interface.c,v 2.4 1991/02/05 17:11:13 mrt (CMU)
30: */
31:
32: /*
33: * Interface to new debugger.
34: */
35: #include <sys/param.h>
36: #include <sys/proc.h>
37: #include <sys/reboot.h>
38: #include <sys/systm.h>
39:
40: #include <uvm/uvm_extern.h>
41:
42: #include <dev/cons.h>
43:
44: #include <machine/autoconf.h>
45: #include <machine/db_machdep.h>
46:
47: #include <ddb/db_access.h>
48: #include <ddb/db_var.h>
49:
50: #if defined(DDB)
51: #include <ddb/db_command.h>
52: #include <ddb/db_sym.h>
53: #include <ddb/db_variables.h>
54: #include <ddb/db_extern.h>
55: #include <ddb/db_output.h>
56: #endif
57:
58: #include <machine/bsd_openprom.h>
59: #include <machine/ctlreg.h>
60: #include <sparc/sparc/asm.h>
61:
62: /*
63: * Read bytes from kernel address space for debugger.
64: */
65: void
66: db_read_bytes(addr, size, data)
67: vaddr_t addr;
68: size_t size;
69: char *data;
70: {
71: char *src;
72:
73: src = (char *)addr;
74: while (size-- > 0)
75: *data++ = *src++;
76: }
77:
78: /*
79: * Write bytes to kernel address space for debugger.
80: */
81: void
82: db_write_bytes(addr, size, data)
83: vaddr_t addr;
84: size_t size;
85: char *data;
86: {
87: extern char etext[];
88: char *dst;
89:
90: dst = (char *)addr;
91: while (size-- > 0) {
92: if ((dst >= (char *)VM_MIN_KERNEL_ADDRESS) && (dst < etext))
93: pmap_writetext(dst, *data);
94: else
95: *dst = *data;
96: dst++, data++;
97: }
98:
99: }
100:
101:
102: #if defined(DDB)
103:
104: /*
105: * Data and functions used by DDB only.
106: */
107: void
108: Debugger()
109: {
110: asm("ta 0x81");
111: }
112:
113: static int nil;
114:
115: struct db_variable db_regs[] = {
116: { "psr", (long *)&DDB_TF->tf_psr, FCN_NULL, },
117: { "pc", (long *)&DDB_TF->tf_pc, FCN_NULL, },
118: { "npc", (long *)&DDB_TF->tf_npc, FCN_NULL, },
119: { "y", (long *)&DDB_TF->tf_y, FCN_NULL, },
120: { "wim", (long *)&DDB_TF->tf_global[0], FCN_NULL, }, /* see reg.h */
121: { "g0", (long *)&nil, FCN_NULL, },
122: { "g1", (long *)&DDB_TF->tf_global[1], FCN_NULL, },
123: { "g2", (long *)&DDB_TF->tf_global[2], FCN_NULL, },
124: { "g3", (long *)&DDB_TF->tf_global[3], FCN_NULL, },
125: { "g4", (long *)&DDB_TF->tf_global[4], FCN_NULL, },
126: { "g5", (long *)&DDB_TF->tf_global[5], FCN_NULL, },
127: { "g6", (long *)&DDB_TF->tf_global[6], FCN_NULL, },
128: { "g7", (long *)&DDB_TF->tf_global[7], FCN_NULL, },
129: { "o0", (long *)&DDB_TF->tf_out[0], FCN_NULL, },
130: { "o1", (long *)&DDB_TF->tf_out[1], FCN_NULL, },
131: { "o2", (long *)&DDB_TF->tf_out[2], FCN_NULL, },
132: { "o3", (long *)&DDB_TF->tf_out[3], FCN_NULL, },
133: { "o4", (long *)&DDB_TF->tf_out[4], FCN_NULL, },
134: { "o5", (long *)&DDB_TF->tf_out[5], FCN_NULL, },
135: { "o6", (long *)&DDB_TF->tf_out[6], FCN_NULL, },
136: { "o7", (long *)&DDB_TF->tf_out[7], FCN_NULL, },
137: { "l0", (long *)&DDB_FR->fr_local[0], FCN_NULL, },
138: { "l1", (long *)&DDB_FR->fr_local[1], FCN_NULL, },
139: { "l2", (long *)&DDB_FR->fr_local[2], FCN_NULL, },
140: { "l3", (long *)&DDB_FR->fr_local[3], FCN_NULL, },
141: { "l4", (long *)&DDB_FR->fr_local[4], FCN_NULL, },
142: { "l5", (long *)&DDB_FR->fr_local[5], FCN_NULL, },
143: { "l6", (long *)&DDB_FR->fr_local[6], FCN_NULL, },
144: { "l7", (long *)&DDB_FR->fr_local[7], FCN_NULL, },
145: { "i0", (long *)&DDB_FR->fr_arg[0], FCN_NULL, },
146: { "i1", (long *)&DDB_FR->fr_arg[1], FCN_NULL, },
147: { "i2", (long *)&DDB_FR->fr_arg[2], FCN_NULL, },
148: { "i3", (long *)&DDB_FR->fr_arg[3], FCN_NULL, },
149: { "i4", (long *)&DDB_FR->fr_arg[4], FCN_NULL, },
150: { "i5", (long *)&DDB_FR->fr_arg[5], FCN_NULL, },
151: { "i6", (long *)&DDB_FR->fr_arg[6], FCN_NULL, },
152: { "i7", (long *)&DDB_FR->fr_arg[7], FCN_NULL, },
153: };
154: struct db_variable *db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]);
155:
156: extern label_t *db_recover;
157:
158: db_regs_t ddb_regs; /* register state */
159:
160: int db_active = 0;
161:
162: extern char *trap_type[];
163:
164: void kdb_kbd_trap(struct trapframe *);
165: void db_prom_cmd(db_expr_t, int, db_expr_t, char *);
166:
167: /*
168: * Received keyboard interrupt sequence.
169: */
170: void
171: kdb_kbd_trap(tf)
172: struct trapframe *tf;
173: {
174: if (db_active == 0 && (boothowto & RB_KDB)) {
175: printf("\n\nkernel: keyboard interrupt\n");
176: kdb_trap(-1, tf);
177: }
178: }
179:
180: /*
181: * kdb_trap - field a TRACE or BPT trap
182: */
183: int
184: kdb_trap(type, tf)
185: int type;
186: struct trapframe *tf;
187: {
188:
189: fb_unblank();
190:
191: switch (type) {
192: case T_BREAKPOINT: /* breakpoint */
193: case -1: /* keyboard interrupt */
194: break;
195: default:
196: if (!db_panic)
197: return (0);
198:
199: printf("kernel: %s trap", trap_type[type & 0xff]);
200: if (db_recover != 0) {
201: db_error("Faulted in DDB; continuing...\n");
202: /*NOTREACHED*/
203: }
204: }
205:
206: /* Should switch to kdb`s own stack here. */
207:
208: ddb_regs.db_tf = *tf;
209: ddb_regs.db_fr = *(struct frame *)tf->tf_out[6];
210:
211: db_active++;
212: cnpollc(TRUE);
213: db_trap(type, 0/*code*/);
214: cnpollc(FALSE);
215: db_active--;
216:
217: *(struct frame *)tf->tf_out[6] = ddb_regs.db_fr;
218: *tf = ddb_regs.db_tf;
219:
220: return (1);
221: }
222:
223: void
224: db_prom_cmd(addr, have_addr, count, modif)
225: db_expr_t addr;
226: int have_addr;
227: db_expr_t count;
228: char *modif;
229: {
230: callrom();
231: }
232:
233: struct db_command sparc_db_command_table[] = {
234: { "prom", db_prom_cmd, 0, 0 },
235: { (char *)0, }
236: };
237:
238: void
239: db_machine_init()
240: {
241: db_machine_commands_install(sparc_db_command_table);
242: }
243: #endif /* DDB */
CVSweb