Sat Jan 22 20:24:48 2011 UTC ()
A couple more registers and their common usage.


(skrll)
diff -r1.25 -r1.26 src/sys/arch/hppa/hppa/db_interface.c

cvs diff -r1.25 -r1.26 src/sys/arch/hppa/hppa/db_interface.c (switch to unified diff)

--- src/sys/arch/hppa/hppa/db_interface.c 2011/01/22 19:35:48 1.25
+++ src/sys/arch/hppa/hppa/db_interface.c 2011/01/22 20:24:48 1.26
@@ -1,204 +1,204 @@ @@ -1,204 +1,204 @@
1/* $NetBSD: db_interface.c,v 1.25 2011/01/22 19:35:48 skrll Exp $ */ 1/* $NetBSD: db_interface.c,v 1.26 2011/01/22 20:24:48 skrll Exp $ */
2 2
3/* $OpenBSD: db_interface.c,v 1.16 2001/03/22 23:31:45 mickey Exp $ */ 3/* $OpenBSD: db_interface.c,v 1.16 2001/03/22 23:31:45 mickey Exp $ */
4 4
5/* 5/*
6 * Copyright (c) 1999-2003 Michael Shalayeff 6 * Copyright (c) 1999-2003 Michael Shalayeff
7 * All rights reserved. 7 * All rights reserved.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the 15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution. 16 * documentation and/or other materials provided with the distribution.
17 * 17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT, 21 * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
22 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 26 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
27 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 27 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
28 * THE POSSIBILITY OF SUCH DAMAGE. 28 * THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31#include <sys/cdefs.h> 31#include <sys/cdefs.h>
32__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.25 2011/01/22 19:35:48 skrll Exp $"); 32__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.26 2011/01/22 20:24:48 skrll Exp $");
33 33
34#include <sys/param.h> 34#include <sys/param.h>
35#include <sys/systm.h> 35#include <sys/systm.h>
36#include <sys/proc.h> 36#include <sys/proc.h>
37 37
38#include <machine/db_machdep.h> 38#include <machine/db_machdep.h>
39#include <machine/frame.h> 39#include <machine/frame.h>
40#include <machine/cpufunc.h> 40#include <machine/cpufunc.h>
41 41
42#include <ddb/db_access.h> 42#include <ddb/db_access.h>
43#include <ddb/db_command.h> 43#include <ddb/db_command.h>
44#include <ddb/db_output.h> 44#include <ddb/db_output.h>
45#include <ddb/db_run.h> 45#include <ddb/db_run.h>
46#include <ddb/db_sym.h> 46#include <ddb/db_sym.h>
47#include <ddb/db_variables.h> 47#include <ddb/db_variables.h>
48#include <ddb/db_extern.h> 48#include <ddb/db_extern.h>
49#include <ddb/db_interface.h> 49#include <ddb/db_interface.h>
50#include <ddb/ddbvar.h> 50#include <ddb/ddbvar.h>
51 51
52#include <dev/cons.h> 52#include <dev/cons.h>
53 53
54void kdbprinttrap(int, int); 54void kdbprinttrap(int, int);
55 55
56extern label_t *db_recover; 56extern label_t *db_recover;
57extern int db_active; 57extern int db_active;
58extern const char *trap_type[]; 58extern const char *trap_type[];
59extern int trap_types; 59extern int trap_types;
60 60
61db_regs_t ddb_regs; 61db_regs_t ddb_regs;
62const struct db_variable db_regs[] = { 62const struct db_variable db_regs[] = {
63 { "flags", (long *)&ddb_regs.tf_flags, FCN_NULL }, 63 { "flags", (long *)&ddb_regs.tf_flags, FCN_NULL },
64 { "r1", (long *)&ddb_regs.tf_r1, FCN_NULL }, 64 { "r1", (long *)&ddb_regs.tf_r1, FCN_NULL },
65 { "rp", (long *)&ddb_regs.tf_rp, FCN_NULL }, 65 { "r2(rp)", (long *)&ddb_regs.tf_rp, FCN_NULL },
66 { "r3", (long *)&ddb_regs.tf_r3, FCN_NULL }, 66 { "r3(fp)", (long *)&ddb_regs.tf_r3, FCN_NULL },
67 { "r4", (long *)&ddb_regs.tf_r4, FCN_NULL }, 67 { "r4", (long *)&ddb_regs.tf_r4, FCN_NULL },
68 { "r5", (long *)&ddb_regs.tf_r5, FCN_NULL }, 68 { "r5", (long *)&ddb_regs.tf_r5, FCN_NULL },
69 { "r6", (long *)&ddb_regs.tf_r6, FCN_NULL }, 69 { "r6", (long *)&ddb_regs.tf_r6, FCN_NULL },
70 { "r7", (long *)&ddb_regs.tf_r7, FCN_NULL }, 70 { "r7", (long *)&ddb_regs.tf_r7, FCN_NULL },
71 { "r8", (long *)&ddb_regs.tf_r8, FCN_NULL }, 71 { "r8", (long *)&ddb_regs.tf_r8, FCN_NULL },
72 { "r9", (long *)&ddb_regs.tf_r9, FCN_NULL }, 72 { "r9", (long *)&ddb_regs.tf_r9, FCN_NULL },
73 { "r10", (long *)&ddb_regs.tf_r10, FCN_NULL }, 73 { "r10", (long *)&ddb_regs.tf_r10, FCN_NULL },
74 { "r11", (long *)&ddb_regs.tf_r11, FCN_NULL }, 74 { "r11", (long *)&ddb_regs.tf_r11, FCN_NULL },
75 { "r12", (long *)&ddb_regs.tf_r12, FCN_NULL }, 75 { "r12", (long *)&ddb_regs.tf_r12, FCN_NULL },
76 { "r13", (long *)&ddb_regs.tf_r13, FCN_NULL }, 76 { "r13", (long *)&ddb_regs.tf_r13, FCN_NULL },
77 { "r14", (long *)&ddb_regs.tf_r14, FCN_NULL }, 77 { "r14", (long *)&ddb_regs.tf_r14, FCN_NULL },
78 { "r15", (long *)&ddb_regs.tf_r15, FCN_NULL }, 78 { "r15", (long *)&ddb_regs.tf_r15, FCN_NULL },
79 { "r16", (long *)&ddb_regs.tf_r16, FCN_NULL }, 79 { "r16", (long *)&ddb_regs.tf_r16, FCN_NULL },
80 { "r17", (long *)&ddb_regs.tf_r17, FCN_NULL }, 80 { "r17", (long *)&ddb_regs.tf_r17, FCN_NULL },
81 { "r18", (long *)&ddb_regs.tf_r18, FCN_NULL }, 81 { "r18", (long *)&ddb_regs.tf_r18, FCN_NULL },
82 { "r19(t4)", (long *)&ddb_regs.tf_t4, FCN_NULL }, 82 { "r19(t4)", (long *)&ddb_regs.tf_t4, FCN_NULL },
83 { "r20(t3)", (long *)&ddb_regs.tf_t3, FCN_NULL }, 83 { "r20(t3)", (long *)&ddb_regs.tf_t3, FCN_NULL },
84 { "r21(t2)", (long *)&ddb_regs.tf_t2, FCN_NULL }, 84 { "r21(t2)", (long *)&ddb_regs.tf_t2, FCN_NULL },
85 { "r22(t1)", (long *)&ddb_regs.tf_t1, FCN_NULL }, 85 { "r22(t1)", (long *)&ddb_regs.tf_t1, FCN_NULL },
86 { "r23(arg3)", (long *)&ddb_regs.tf_arg3, FCN_NULL }, 86 { "r23(arg3)", (long *)&ddb_regs.tf_arg3, FCN_NULL },
87 { "r24(arg2)", (long *)&ddb_regs.tf_arg2, FCN_NULL }, 87 { "r24(arg2)", (long *)&ddb_regs.tf_arg2, FCN_NULL },
88 { "r25(arg1)", (long *)&ddb_regs.tf_arg1, FCN_NULL }, 88 { "r25(arg1)", (long *)&ddb_regs.tf_arg1, FCN_NULL },
89 { "r26(arg0)", (long *)&ddb_regs.tf_arg0, FCN_NULL }, 89 { "r26(arg0)", (long *)&ddb_regs.tf_arg0, FCN_NULL },
90 { "r27(dp)", (long *)&ddb_regs.tf_dp, FCN_NULL }, 90 { "r27(dp)", (long *)&ddb_regs.tf_dp, FCN_NULL },
91 { "r28(ret0)", (long *)&ddb_regs.tf_ret0, FCN_NULL }, 91 { "r28(ret0)", (long *)&ddb_regs.tf_ret0, FCN_NULL },
92 { "r29(ret1)", (long *)&ddb_regs.tf_ret1, FCN_NULL }, 92 { "r29(ret1)", (long *)&ddb_regs.tf_ret1, FCN_NULL },
93 { "r30(sp)", (long *)&ddb_regs.tf_sp, FCN_NULL }, 93 { "r30(sp)", (long *)&ddb_regs.tf_sp, FCN_NULL },
94 { "r31", (long *)&ddb_regs.tf_r31, FCN_NULL }, 94 { "r31", (long *)&ddb_regs.tf_r31, FCN_NULL },
95 95
96 { "sar", (long *)&ddb_regs.tf_sar, FCN_NULL }, 96 { "sar", (long *)&ddb_regs.tf_sar, FCN_NULL },
97 97
98 { "eirr", (long *)&ddb_regs.tf_eirr, FCN_NULL }, 98 { "eirr", (long *)&ddb_regs.tf_eirr, FCN_NULL },
99 { "eiem", (long *)&ddb_regs.tf_eiem, FCN_NULL }, 99 { "eiem", (long *)&ddb_regs.tf_eiem, FCN_NULL },
100 { "iir", (long *)&ddb_regs.tf_iir, FCN_NULL }, 100 { "iir", (long *)&ddb_regs.tf_iir, FCN_NULL },
101 { "isr", (long *)&ddb_regs.tf_isr, FCN_NULL }, 101 { "isr", (long *)&ddb_regs.tf_isr, FCN_NULL },
102 { "ior", (long *)&ddb_regs.tf_ior, FCN_NULL }, 102 { "ior", (long *)&ddb_regs.tf_ior, FCN_NULL },
103 { "ipsw", (long *)&ddb_regs.tf_ipsw, FCN_NULL }, 103 { "ipsw", (long *)&ddb_regs.tf_ipsw, FCN_NULL },
104 { "iisqh", (long *)&ddb_regs.tf_iisq_head, FCN_NULL }, 104 { "iisqh", (long *)&ddb_regs.tf_iisq_head, FCN_NULL },
105 { "iioqh", (long *)&ddb_regs.tf_iioq_head, FCN_NULL }, 105 { "iioqh", (long *)&ddb_regs.tf_iioq_head, FCN_NULL },
106 { "iisqt", (long *)&ddb_regs.tf_iisq_tail, FCN_NULL }, 106 { "iisqt", (long *)&ddb_regs.tf_iisq_tail, FCN_NULL },
107 { "iioqt", (long *)&ddb_regs.tf_iioq_tail, FCN_NULL }, 107 { "iioqt", (long *)&ddb_regs.tf_iioq_tail, FCN_NULL },
108 108
109 { "sr0", (long *)&ddb_regs.tf_sr0, FCN_NULL }, 109 { "sr0", (long *)&ddb_regs.tf_sr0, FCN_NULL },
110 { "sr1", (long *)&ddb_regs.tf_sr1, FCN_NULL }, 110 { "sr1", (long *)&ddb_regs.tf_sr1, FCN_NULL },
111 { "sr2", (long *)&ddb_regs.tf_sr2, FCN_NULL }, 111 { "sr2", (long *)&ddb_regs.tf_sr2, FCN_NULL },
112 { "sr3", (long *)&ddb_regs.tf_sr3, FCN_NULL }, 112 { "sr3", (long *)&ddb_regs.tf_sr3, FCN_NULL },
113 { "sr4", (long *)&ddb_regs.tf_sr4, FCN_NULL }, 113 { "sr4", (long *)&ddb_regs.tf_sr4, FCN_NULL },
114 { "sr5", (long *)&ddb_regs.tf_sr5, FCN_NULL }, 114 { "sr5", (long *)&ddb_regs.tf_sr5, FCN_NULL },
115 { "sr6", (long *)&ddb_regs.tf_sr6, FCN_NULL }, 115 { "sr6", (long *)&ddb_regs.tf_sr6, FCN_NULL },
116 { "sr7", (long *)&ddb_regs.tf_sr7, FCN_NULL }, 116 { "sr7", (long *)&ddb_regs.tf_sr7, FCN_NULL },
117 117
118 { "pidr1", (long *)&ddb_regs.tf_pidr1, FCN_NULL }, 118 { "pidr1", (long *)&ddb_regs.tf_pidr1, FCN_NULL },
119 { "pidr2", (long *)&ddb_regs.tf_pidr2, FCN_NULL }, 119 { "pidr2", (long *)&ddb_regs.tf_pidr2, FCN_NULL },
120#ifdef pbably_not_worth_it 120#ifdef pbably_not_worth_it
121 { "pidr3", (long *)&ddb_regs.tf_pidr3, FCN_NULL }, 121 { "pidr3", (long *)&ddb_regs.tf_pidr3, FCN_NULL },
122 { "pidr4", (long *)&ddb_regs.tf_pidr4, FCN_NULL }, 122 { "pidr4", (long *)&ddb_regs.tf_pidr4, FCN_NULL },
123#endif 123#endif
124 124
125 { "vtop", (long *)&ddb_regs.tf_vtop, FCN_NULL }, 125 { "vtop", (long *)&ddb_regs.tf_vtop, FCN_NULL },
126 { "cr24", (long *)&ddb_regs.tf_cr24, FCN_NULL }, 126 { "cr24", (long *)&ddb_regs.tf_cr24, FCN_NULL },
127 { "cr27", (long *)&ddb_regs.tf_cr27, FCN_NULL }, 127 { "cr27", (long *)&ddb_regs.tf_cr27, FCN_NULL },
128 { "cr28", (long *)&ddb_regs.tf_cr28, FCN_NULL }, 128 { "cr28", (long *)&ddb_regs.tf_cr28, FCN_NULL },
129 { "cr30", (long *)&ddb_regs.tf_cr30, FCN_NULL }, 129 { "cr30", (long *)&ddb_regs.tf_cr30, FCN_NULL },
130}; 130};
131const struct db_variable * const db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]); 131const struct db_variable * const db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]);
132int db_active = 0; 132int db_active = 0;
133 133
134void 134void
135cpu_Debugger(void) 135cpu_Debugger(void)
136{ 136{
137 __asm volatile ("break %0, %1" 137 __asm volatile ("break %0, %1"
138 :: "i" (HPPA_BREAK_KERNEL), "i" (HPPA_BREAK_KGDB)); 138 :: "i" (HPPA_BREAK_KERNEL), "i" (HPPA_BREAK_KGDB));
139} 139}
140 140
141/* 141/*
142 * Print trap reason. 142 * Print trap reason.
143 */ 143 */
144void 144void
145kdbprinttrap(int type, int code) 145kdbprinttrap(int type, int code)
146{ 146{
147 db_printf("kernel: "); 147 db_printf("kernel: ");
148 if (type >= trap_types || type < 0) 148 if (type >= trap_types || type < 0)
149 db_printf("type %d", type); 149 db_printf("type %d", type);
150 else 150 else
151 db_printf("%s", trap_type[type]); 151 db_printf("%s", trap_type[type]);
152 db_printf(" trap, code=%x\n", code); 152 db_printf(" trap, code=%x\n", code);
153} 153}
154 154
155/* 155/*
156 * kdb_trap - field a BPT trap 156 * kdb_trap - field a BPT trap
157 */ 157 */
158int 158int
159kdb_trap(int type, int code, db_regs_t *regs) 159kdb_trap(int type, int code, db_regs_t *regs)
160{ 160{
161 int s; 161 int s;
162 162
163 switch (type) { 163 switch (type) {
164 case T_RECOVERY: 164 case T_RECOVERY:
165 case T_IBREAK: 165 case T_IBREAK:
166 case T_DBREAK: 166 case T_DBREAK:
167 case -1: 167 case -1:
168 break; 168 break;
169 default: 169 default:
170 if (!db_onpanic && db_recover == 0) 170 if (!db_onpanic && db_recover == 0)
171 return 0; 171 return 0;
172 172
173 kdbprinttrap(type, code); 173 kdbprinttrap(type, code);
174 if (db_recover != 0) { 174 if (db_recover != 0) {
175 db_error("Caught exception in DDB; continuing...\n"); 175 db_error("Caught exception in DDB; continuing...\n");
176 /* NOT REACHED */ 176 /* NOT REACHED */
177 } 177 }
178 } 178 }
179 179
180 /* XXX Should switch to kdb`s own stack here. */ 180 /* XXX Should switch to kdb`s own stack here. */
181 181
182 ddb_regs = *regs; 182 ddb_regs = *regs;
183 183
184 s = splhigh(); 184 s = splhigh();
185 db_active++; 185 db_active++;
186 cnpollc(true); 186 cnpollc(true);
187 db_trap(type, code); 187 db_trap(type, code);
188 cnpollc(false); 188 cnpollc(false);
189 db_active--; 189 db_active--;
190 splx(s); 190 splx(s);
191 191
192 *regs = ddb_regs; 192 *regs = ddb_regs;
193 return 1; 193 return 1;
194} 194}
195 195
196/* 196/*
197 * Validate an address for use as a breakpoint. 197 * Validate an address for use as a breakpoint.
198 * Any address is allowed for now. 198 * Any address is allowed for now.
199 */ 199 */
200int 200int
201db_valid_breakpoint(db_addr_t addr) 201db_valid_breakpoint(db_addr_t addr)
202{ 202{
203 return 1; 203 return 1;
204} 204}