]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
91447636 | 2 | * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved. |
1c79356b | 3 | * |
8ad349bb | 4 | * @APPLE_LICENSE_OSREFERENCE_HEADER_START@ |
1c79356b | 5 | * |
8ad349bb A |
6 | * This file contains Original Code and/or Modifications of Original Code |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. The rights granted to you under the | |
10 | * License may not be used to create, or enable the creation or | |
11 | * redistribution of, unlawful or unlicensed copies of an Apple operating | |
12 | * system, or to circumvent, violate, or enable the circumvention or | |
13 | * violation of, any terms of an Apple operating system software license | |
14 | * agreement. | |
15 | * | |
16 | * Please obtain a copy of the License at | |
17 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
18 | * file. | |
19 | * | |
20 | * The Original Code and all software distributed under the License are | |
21 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
22 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
23 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
24 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
25 | * Please see the License for the specific language governing rights and | |
26 | * limitations under the License. | |
27 | * | |
28 | * @APPLE_LICENSE_OSREFERENCE_HEADER_END@ | |
1c79356b A |
29 | */ |
30 | /* | |
31 | * @OSF_FREE_COPYRIGHT@ | |
32 | */ | |
33 | /* | |
34 | * @APPLE_FREE_COPYRIGHT@ | |
35 | */ | |
36 | ||
37 | /* | |
38 | * Author: Bill Angell, Apple | |
39 | * Date: 6/97 | |
40 | * | |
41 | * exceptions and certain C functions write into a trace table which | |
42 | * can be examined via the machine 'lt' command under kdb | |
43 | */ | |
44 | ||
45 | ||
46 | #include <string.h> /* For strcpy() */ | |
47 | #include <mach/boolean.h> | |
48 | #include <machine/db_machdep.h> | |
49 | ||
50 | #include <ddb/db_access.h> | |
51 | #include <ddb/db_lex.h> | |
52 | #include <ddb/db_output.h> | |
53 | #include <ddb/db_command.h> | |
54 | #include <ddb/db_sym.h> | |
55 | #include <ddb/db_task_thread.h> | |
56 | #include <ddb/db_command.h> /* For db_option() */ | |
57 | #include <ddb/db_examine.h> | |
58 | #include <ddb/db_expr.h> | |
59 | #include <kern/thread.h> | |
60 | #include <kern/task.h> | |
61 | #include <mach/vm_param.h> | |
62 | #include <mach/kmod.h> | |
63 | #include <ppc/Firmware.h> | |
64 | #include <ppc/low_trace.h> | |
65 | #include <ppc/db_low_trace.h> | |
66 | #include <ppc/mappings.h> | |
67 | #include <ppc/pmap.h> | |
68 | #include <ppc/mem.h> | |
1c79356b | 69 | #include <ppc/savearea.h> |
9bccf70c | 70 | #include <ppc/vmachmon.h> |
1c79356b | 71 | |
55e303ae | 72 | void db_dumppca(unsigned int ptegindex); |
1c79356b | 73 | void db_dumpmapping(struct mapping *mp); /* Dump out a mapping */ |
1c79356b A |
74 | extern kmod_info_t *kmod; /* Find the kmods */ |
75 | ||
76 | db_addr_t db_low_trace_prev = 0; | |
77 | ||
78 | /* | |
79 | * Print out the low level trace table: | |
80 | * | |
81 | * Displays the entry and 15 before it in newest to oldest order | |
82 | * | |
83 | * lt [entaddr] | |
84 | ||
85 | * If entaddr is omitted, it starts with the most current | |
86 | * If entaddr = 0, it starts with the most current and does the whole table | |
87 | */ | |
88 | void db_low_trace(db_expr_t addr, int have_addr, db_expr_t count, char * modif) { | |
89 | ||
90 | int c, i; | |
91 | unsigned int tempx, cnt; | |
55e303ae | 92 | unsigned int xTraceCurr, xTraceStart, xTraceEnd, cxltr; |
1c79356b A |
93 | db_addr_t next_addr; |
94 | LowTraceRecord xltr; | |
95 | unsigned char cmark; | |
55e303ae | 96 | addr64_t xxltr; |
1c79356b A |
97 | |
98 | cnt = 16; /* Default to 16 entries */ | |
99 | ||
100 | xTraceCurr = trcWork.traceCurr; /* Transfer current pointer */ | |
101 | xTraceStart = trcWork.traceStart; /* Transfer start of table */ | |
102 | xTraceEnd = trcWork.traceEnd; /* Transfer end of table */ | |
103 | ||
104 | if(addr == -1) cnt = 0x7FFFFFFF; /* Max the count */ | |
105 | ||
106 | if(!addr || (addr == -1)) { | |
107 | addr=xTraceCurr-sizeof(LowTraceRecord); /* Start at the newest */ | |
108 | if((unsigned int)addr<xTraceStart) addr=xTraceEnd-sizeof(LowTraceRecord); /* Wrap low back to high */ | |
109 | } | |
110 | ||
111 | if((unsigned int)addr<xTraceStart||(unsigned int)addr>=xTraceEnd) { /* In the table? */ | |
112 | db_printf("address not in low memory trace table\n"); /* Tell the fool */ | |
113 | return; /* Leave... */ | |
114 | } | |
115 | ||
55e303ae A |
116 | if((unsigned int)addr&0x0000007F) { /* Proper alignment? */ |
117 | db_printf("address not aligned on trace entry boundary (0x80)\n"); /* Tell 'em */ | |
1c79356b A |
118 | return; /* Leave... */ |
119 | } | |
120 | ||
55e303ae A |
121 | xxltr = addr; /* Set the start */ |
122 | cxltr = ((xTraceCurr == xTraceStart ? xTraceEnd : xTraceCurr) - sizeof(LowTraceRecord)); /* Get address of newest entry */ | |
1c79356b A |
123 | |
124 | db_low_trace_prev = addr; /* Starting point */ | |
125 | ||
126 | for(i=0; i < cnt; i++) { /* Dump the 16 (or all) entries */ | |
127 | ||
55e303ae A |
128 | ReadReal((addr64_t)xxltr, (unsigned int *)&xltr); /* Get the first half */ |
129 | ReadReal((addr64_t)xxltr + 32, &(((unsigned int *)&xltr)[8])); /* Get the second half */ | |
130 | ReadReal((addr64_t)xxltr + 64, &(((unsigned int *)&xltr)[16])); /* Get the second half */ | |
131 | ReadReal((addr64_t)xxltr + 96, &(((unsigned int *)&xltr)[24])); /* Get the second half */ | |
1c79356b | 132 | |
a3d08fcd | 133 | db_printf("\n%s%08llX %1X %08X %08X - %04X", (xxltr != cxltr ? " " : "*"), |
1c79356b | 134 | xxltr, |
a3d08fcd | 135 | (xltr.LTR_cpu & 0xFF), xltr.LTR_timeHi, xltr.LTR_timeLo, |
55e303ae | 136 | (xltr.LTR_excpt & 0x8000 ? 0xFFFF : xltr.LTR_excpt * 64)); /* Print the first line */ |
a3d08fcd A |
137 | |
138 | if(xltr.LTR_cpu & 0xFF00) db_printf(", sflgs = %02X\n", ((xltr.LTR_cpu >> 8) & 0xFF)); | |
139 | else db_printf("\n"); | |
55e303ae A |
140 | |
141 | db_printf(" DAR/DSR/CR: %016llX %08X %08X\n", xltr.LTR_dar, xltr.LTR_dsisr, xltr.LTR_cr); | |
142 | ||
143 | db_printf(" SRR0/SRR1 %016llX %016llX\n", xltr.LTR_srr0, xltr.LTR_srr1); | |
144 | db_printf(" LR/CTR %016llX %016llX\n", xltr.LTR_lr, xltr.LTR_ctr); | |
145 | ||
146 | db_printf(" R0/R1/R2 %016llX %016llX %016llX\n", xltr.LTR_r0, xltr.LTR_r1, xltr.LTR_r2); | |
147 | db_printf(" R3/R4/R5 %016llX %016llX %016llX\n", xltr.LTR_r3, xltr.LTR_r4, xltr.LTR_r5); | |
148 | db_printf(" R6/sv/rsv %016llX %016llX %08X\n", xltr.LTR_r6, xltr.LTR_save, xltr.LTR_rsvd0); | |
1c79356b A |
149 | |
150 | if((cnt != 16) && (xxltr == xTraceCurr)) break; /* If whole table dump, exit when we hit start again... */ | |
151 | ||
152 | xxltr-=sizeof(LowTraceRecord); /* Back it on up */ | |
153 | if(xxltr<xTraceStart) | |
154 | xxltr=(xTraceEnd-sizeof(LowTraceRecord)); /* Wrap low back to high */ | |
155 | ||
156 | } | |
157 | db_next = (db_expr_t)(xxltr); | |
158 | return; | |
159 | } | |
160 | ||
161 | ||
162 | /* | |
163 | * Print out 256 bytes | |
164 | * | |
165 | * | |
166 | * dl [entaddr] | |
167 | */ | |
168 | void db_display_long(db_expr_t addr, int have_addr, db_expr_t count, char * modif) { | |
169 | ||
170 | int i; | |
171 | ||
172 | for(i=0; i<8; i++) { /* Print 256 bytes */ | |
55e303ae | 173 | db_printf("%016llX %08X %08X %08X %08X %08X %08X %08X %08X\n", addr, /* Print a line */ |
1c79356b A |
174 | ((unsigned long *)addr)[0], ((unsigned long *)addr)[1], ((unsigned long *)addr)[2], ((unsigned long *)addr)[3], |
175 | ((unsigned long *)addr)[4], ((unsigned long *)addr)[5], ((unsigned long *)addr)[6], ((unsigned long *)addr)[7]); | |
55e303ae | 176 | addr=(db_expr_t)(addr+0x00000020); /* Point to next address */ |
1c79356b A |
177 | } |
178 | db_next = addr; | |
179 | ||
180 | ||
55e303ae A |
181 | } |
182 | ||
183 | unsigned char xtran[256] = { | |
184 | /* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF */ | |
185 | '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', /* 0x */ | |
186 | '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', /* 1x */ | |
187 | ' ', '!', '"', '#', '$', '%', '&',0x27, '(', ')', '*', '+', ',', '-', '.', '/', /* 2x */ | |
188 | '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', /* 3x */ | |
189 | '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', /* 4x */ | |
190 | 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[',0x5C, ']', '^', '_', /* 5x */ | |
191 | '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', /* 6x */ | |
192 | 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~', '.', /* 7x */ | |
193 | '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', /* 8x */ | |
194 | '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', /* 9x */ | |
195 | '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', /* Ax */ | |
196 | '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', /* Bx */ | |
197 | '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', /* Cx */ | |
198 | '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', /* Dx */ | |
199 | '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', /* Ex */ | |
200 | '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', /* Fx */ | |
201 | }; | |
202 | ||
203 | /* | |
204 | * Print out 256 bytes in characters | |
205 | * | |
206 | * | |
207 | * dc [entaddr] | |
208 | */ | |
209 | void db_display_char(db_expr_t addr, int have_addr, db_expr_t count, char * modif) { | |
210 | ||
211 | int i, j, k; | |
212 | unsigned char xlt[256], *xaddr; | |
213 | ||
214 | xaddr = (unsigned char *)addr; | |
215 | ||
216 | ||
217 | for(i = 0; i < 8; i++) { /* Print 256 bytes */ | |
218 | j = 0; | |
219 | for(k = 0; k < 32; k++) { | |
220 | xlt[j] = xtran[*xaddr]; | |
221 | xaddr++; | |
222 | j++; | |
223 | if((k & 3) == 3) { | |
224 | xlt[j] = ' '; | |
225 | j++; | |
226 | } | |
227 | } | |
228 | xlt[j] = 0; | |
229 | ||
230 | db_printf("%016llX %s\n", (addr64_t)(xaddr - 32), xlt); /* Print a line */ | |
231 | } | |
232 | ||
233 | db_next = (db_expr_t)xaddr; | |
234 | ||
235 | ||
1c79356b A |
236 | } |
237 | ||
238 | /* | |
239 | * Print out 256 bytes of real storage | |
240 | * | |
241 | * Displays the entry and 15 before it in newest to oldest order | |
242 | * | |
243 | * dr [entaddr] | |
244 | */ | |
245 | void db_display_real(db_expr_t addr, int have_addr, db_expr_t count, char * modif) { | |
246 | ||
247 | int i; | |
248 | unsigned int xbuf[8]; | |
249 | ||
250 | for(i=0; i<8; i++) { /* Print 256 bytes */ | |
55e303ae A |
251 | ReadReal(addr, &xbuf[0]); /* Get the real storage data */ |
252 | db_printf("%016llX %08X %08X %08X %08X %08X %08X %08X %08X\n", addr, /* Print a line */ | |
1c79356b A |
253 | xbuf[0], xbuf[1], xbuf[2], xbuf[3], |
254 | xbuf[4], xbuf[5], xbuf[6], xbuf[7]); | |
55e303ae | 255 | addr = addr + 0x00000020; /* Point to next address */ |
1c79356b A |
256 | } |
257 | db_next = addr; | |
1c79356b A |
258 | } |
259 | ||
260 | unsigned int dvspace = 0; | |
261 | ||
262 | /* | |
263 | * Print out virtual to real translation information | |
264 | * | |
265 | * | |
266 | * dm vaddr [space] (defaults to last entered) | |
267 | */ | |
268 | void db_display_mappings(db_expr_t addr, int have_addr, db_expr_t count, char * modif) { | |
269 | ||
55e303ae A |
270 | db_expr_t xspace; |
271 | pmap_t pmap; | |
272 | addr64_t lnextva; | |
1c79356b | 273 | |
91447636 | 274 | mapping_t *mp; |
55e303ae A |
275 | |
276 | if (db_expression(&xspace)) { /* Get the address space requested */ | |
277 | if(xspace >= maxAdrSp) { | |
278 | db_printf("requested address space (%llX) larger than max (%X)\n", xspace, maxAdrSp - 1); | |
279 | return; | |
280 | } | |
281 | dvspace = xspace; /* Get the space or set default */ | |
282 | } | |
1c79356b | 283 | |
55e303ae A |
284 | db_printf("mapping information for %016llX in space %8X:\n", addr, dvspace); |
285 | ||
286 | pmap = pmapTrans[dvspace].pmapVAddr; /* Find the pmap address */ | |
287 | if(!pmap) { /* The pmap is not in use */ | |
288 | db_printf("The space %X is not assigned to a pmap\n", dvspace); /* Say we are wrong */ | |
289 | return; | |
290 | } | |
291 | ||
292 | mp = hw_find_map(pmap, (addr64_t)addr, &lnextva); /* Try to find the mapping for this address */ | |
293 | if((unsigned int)mp == mapRtBadLk) { /* Did we lock up ok? */ | |
294 | db_printf("Timeout locking physical entry for virtual address %016ll8X\n", addr); | |
295 | return; | |
296 | } | |
1c79356b | 297 | |
1c79356b A |
298 | if(!mp) { /* Did we find one? */ |
299 | db_printf("Not mapped\n"); | |
300 | return; /* Didn't find any, return FALSE... */ | |
301 | } | |
55e303ae A |
302 | |
303 | mapping_drop_busy(mp); /* The mapping shouldn't be changing */ | |
304 | ||
305 | db_dumpmapping(mp); /* Dump it all out */ | |
306 | ||
307 | return; /* Tell them we did it */ | |
308 | ||
309 | ||
310 | } | |
311 | ||
312 | /* | |
313 | * Print out hash table data | |
314 | * | |
315 | * | |
316 | * dh vaddr [space] (defaults to last entered) | |
317 | */ | |
318 | void db_display_hash(db_expr_t addr, int have_addr, db_expr_t count, char * modif) { | |
319 | ||
320 | db_expr_t xspace; | |
321 | unsigned int seg, vsid, ptegindex, htsize; | |
322 | pmap_t pmap; | |
323 | addr64_t lnextva, llva, vpn, esid; | |
324 | uint64_t hash; | |
325 | int s4bit; | |
326 | ||
327 | llva = (addr64_t)((unsigned int)addr); /* Make sure we are 64-bit now */ | |
328 | ||
91447636 | 329 | s4bit = !((PerProcTable[0].ppe_vaddr->pf.Available & pf64Bit) == 0); /* Are we a big guy? */ |
55e303ae A |
330 | if (db_expression(&xspace)) { /* Get the address space requested */ |
331 | if(xspace >= maxAdrSp) { | |
332 | db_printf("requested address space (%llX) larger than max (%X)\n", xspace, maxAdrSp - 1); | |
333 | return; | |
334 | } | |
335 | dvspace = xspace; /* Get the space or set default */ | |
1c79356b | 336 | } |
55e303ae A |
337 | |
338 | pmap = pmapTrans[dvspace].pmapVAddr; /* Find the pmap address */ | |
339 | if(!pmap) { /* The pmap is not in use */ | |
340 | db_printf("The space %X is not assigned to a pmap\n", dvspace); /* Say we are wrong */ | |
341 | return; | |
1c79356b | 342 | } |
55e303ae A |
343 | |
344 | hash = (uint64_t)pmap->space | ((uint64_t)pmap->space << maxAdrSpb) | ((uint64_t)pmap->space << (2 * maxAdrSpb)); /* Get hash value */ | |
345 | hash = hash & 0x0000001FFFFFFFFF; /* Make sure we stay within supported ranges */ | |
346 | ||
347 | esid = ((llva >> 14) & -maxAdrSp) ^ hash; /* Get ESID */ | |
348 | llva = ((llva >> 12) & 0xFFFF) ^ esid; /* Get index into hash table */ | |
349 | ||
350 | if(s4bit) htsize = hash_table_size >> 7; /* Get number of entries in hash table for 64-bit */ | |
351 | else htsize = hash_table_size >> 6; /* get number of entries in hash table for 32-bit */ | |
352 | ||
353 | ptegindex = llva & (htsize - 1); /* Get the index to the pteg and pca */ | |
354 | db_dumppca(ptegindex); /* dump the info */ | |
355 | ||
1c79356b A |
356 | return; /* Tell them we did it */ |
357 | ||
358 | ||
359 | } | |
360 | ||
361 | /* | |
362 | * Displays all of the in-use pmaps in the system. | |
363 | * | |
364 | * dp | |
365 | */ | |
366 | void db_display_pmap(db_expr_t addr, int have_addr, db_expr_t count, char * modif) { | |
367 | ||
368 | pmap_t pmap; | |
55e303ae A |
369 | int i; |
370 | unsigned int v0, v1, st0, st1; | |
1c79356b | 371 | |
55e303ae A |
372 | pmap = (pmap_t)addr; |
373 | if(!have_addr) pmap = kernel_pmap; /* Start at the beginning */ | |
1c79356b | 374 | |
55e303ae A |
375 | db_printf("PMAP (real) Next Prev Space Flags Ref spaceNum Resident Wired\n"); |
376 | // xxxxxxxx rrrrrrrrrrrrrrrr xxxxxxxx pppppppp ssssssss cccccccc vvvvvvvv nnnnnnnn rrrrrrrr wwwwwwwww | |
1c79356b | 377 | while(1) { /* Do them all */ |
55e303ae A |
378 | db_printf("%08X %016llX %08X %08X %08X %08X %08X %08X %08X %08X\n", |
379 | pmap, (addr64_t)pmap ^ pmap->pmapvr, | |
380 | pmap->pmap_link.next, pmap->pmap_link.prev, | |
381 | pmap->space, pmap->pmapFlags, pmap->ref_count, pmap->spaceNum, | |
1c79356b A |
382 | pmap->stats.resident_count, |
383 | pmap->stats.wired_count); | |
384 | ||
55e303ae A |
385 | db_printf("lists = %d, rand = %08X, visits = %016llX, searches = %08X\n", |
386 | pmap->pmapCurLists, pmap->pmapRandNum, | |
387 | pmap->pmapSearchVisits, pmap->pmapSearchCnt); | |
1c79356b | 388 | |
55e303ae A |
389 | db_printf("cctl = %08X, SCSubTag = %016llX\n", |
390 | pmap->pmapCCtl, pmap->pmapSCSubTag); | |
391 | ||
392 | for(i = 0; i < 16; i +=2) { | |
393 | v0 = (pmap->pmapCCtl >> (31 - i) & 1); /* Get high order bit */ | |
394 | v1 = (pmap->pmapCCtl >> (30 - i) & 1); /* Get high order bit */ | |
395 | st0 = (pmap->pmapSCSubTag >> (60 - (4 * i))) & 0xF; /* Get the sub-tag */ | |
396 | st1 = (pmap->pmapSCSubTag >> (56 - (4 * i))) & 0xF; /* Get the sub-tag */ | |
397 | ||
398 | db_printf(" %01X %01X %016llX/%016llX %01X %01X %016llX/%016llX\n", | |
399 | v0, st0, pmap->pmapSegCache[i].sgcESID, pmap->pmapSegCache[i].sgcVSID, | |
400 | v1, st1, pmap->pmapSegCache[i+1].sgcESID, pmap->pmapSegCache[i+1].sgcVSID); | |
401 | } | |
1c79356b | 402 | |
de355530 | 403 | db_printf("\n"); |
55e303ae A |
404 | if(have_addr) break; /* Do only one if address supplied */ |
405 | pmap = (pmap_t)pmap->pmap_link.next; /* Skip to the next */ | |
1c79356b A |
406 | if(pmap == kernel_pmap) break; /* We've wrapped, we're done */ |
407 | } | |
408 | return; | |
409 | } | |
410 | ||
1c79356b | 411 | |
55e303ae A |
412 | /* |
413 | * Checks the pmap skip lists | |
414 | * | |
415 | * | |
416 | * cp pmap | |
417 | */ | |
418 | void db_check_pmaps(db_expr_t addr, int have_addr, db_expr_t count, char * modif) { | |
de355530 | 419 | |
55e303ae A |
420 | int i; |
421 | unsigned int ret; | |
422 | uint64_t dumpa[32]; | |
423 | pmap_t pmap; | |
424 | ||
425 | pmap = (pmap_t)addr; | |
426 | if(!have_addr) pmap = kernel_pmap; /* If no map supplied, start with kernel */ | |
427 | ||
428 | while(1) { /* Do them all */ | |
429 | ret = mapSkipListVerifyC(pmap, &dumpa); /* Check out the map */ | |
430 | if(!ret) db_printf("Skiplists verified ok, pmap = %08X\n", pmap); | |
431 | else { | |
432 | db_printf("Verification failure at %08X, pmap = %08X\n", ret, pmap); | |
433 | for(i = 0; i < 32; i += 4) { | |
434 | db_printf("R%02d %016llX %016llX %016llX %016llX\n", i, | |
435 | dumpa[i], dumpa[i + 1], dumpa[i + 2], dumpa[i + 3]); | |
436 | } | |
437 | } | |
438 | if(have_addr) break; /* Do only one if address supplied */ | |
439 | pmap = (pmap_t)pmap->pmap_link.next; /* Skip to the next */ | |
440 | if(pmap == kernel_pmap) break; /* We've wrapped, we're done */ | |
441 | } | |
442 | ||
1c79356b A |
443 | return; |
444 | ||
445 | } | |
446 | ||
55e303ae | 447 | |
1c79356b | 448 | /* |
55e303ae | 449 | * Displays iokit junk |
1c79356b | 450 | * |
3a60a9f5 | 451 | * di |
1c79356b | 452 | */ |
1c79356b | 453 | |
55e303ae A |
454 | void db_piokjunk(void); |
455 | ||
456 | void db_display_iokit(db_expr_t addr, int have_addr, db_expr_t count, char * modif) { | |
457 | ||
458 | db_piokjunk(); | |
459 | ||
1c79356b A |
460 | return; |
461 | } | |
462 | ||
463 | /* | |
55e303ae | 464 | * Prints out a mapping control block |
1c79356b A |
465 | * |
466 | */ | |
467 | ||
55e303ae A |
468 | void db_dumpmapping(struct mapping *mp) { /* Dump out a mapping */ |
469 | ||
470 | pmap_t pmap; | |
471 | int i; | |
472 | ||
473 | db_printf("Dump of mapping block: %08X, pmap: %08X (%016llX)\n", mp, pmapTrans[mp->mpSpace].pmapVAddr, | |
474 | pmapTrans[mp->mpSpace].pmapPAddr); /* Header */ | |
475 | db_printf(" mpFlags: %08X\n", mp->mpFlags); | |
476 | db_printf(" mpSpace: %04X\n", mp->mpSpace); | |
91447636 | 477 | db_printf(" mpBSize: %04X\n", mp->u.mpBSize); |
55e303ae A |
478 | db_printf(" mpPte: %08X\n", mp->mpPte); |
479 | db_printf(" mpPAddr: %08X\n", mp->mpPAddr); | |
480 | db_printf(" mpVAddr: %016llX\n", mp->mpVAddr); | |
481 | db_printf(" mpAlias: %016llX\n", mp->mpAlias); | |
482 | db_printf(" mpList00: %016llX\n", mp->mpList0); | |
483 | ||
484 | for(i = 1; i < (mp->mpFlags & mpLists); i++) { /* Dump out secondary physical skip lists */ | |
485 | db_printf(" mpList%02d: %016llX\n", i, mp->mpList[i - 1]); | |
486 | } | |
487 | ||
1c79356b A |
488 | return; |
489 | } | |
490 | ||
491 | /* | |
55e303ae A |
492 | * Prints out a PTEG and PCA |
493 | * | |
1c79356b A |
494 | */ |
495 | ||
55e303ae A |
496 | void db_dumppca(unsigned int ptegindex) { |
497 | ||
498 | addr64_t pteg, pca, llva; | |
499 | unsigned int xpteg[32], xpca[8], space, hash, pva, seg, api, va; | |
500 | int i, s4bit; | |
501 | unsigned long long llslot, llseg, llhash; | |
502 | ||
91447636 | 503 | s4bit = !((PerProcTable[0].ppe_vaddr->pf.Available & pf64Bit) == 0); /* Are we a big guy? */ |
55e303ae A |
504 | |
505 | pteg = hash_table_base + (ptegindex << 6); /* Point to the PTEG */ | |
506 | if(s4bit) pteg = hash_table_base + (ptegindex << 7); /* Point to the PTEG */ | |
507 | pca = hash_table_base - ((ptegindex + 1) * 4); /* Point to the PCA */ | |
508 | db_printf("PTEG = %016llX, PCA = %016llX (index = %08X)\n", pteg, pca, ptegindex); | |
de355530 | 509 | |
55e303ae A |
510 | ReadReal(pteg, &xpteg[0]); /* Get first half of the pteg */ |
511 | ReadReal(pteg + 0x20, &xpteg[8]); /* Get second half of the pteg */ | |
512 | ReadReal(pca, &xpca[0]); /* Get pca */ | |
513 | ||
514 | db_printf("PCA: free = %02X, steal = %02X, auto = %02X, misc = %02X\n", | |
515 | ((xpca[0] >> 24) & 255), ((xpca[0] >> 16) & 255), ((xpca[0] >> 8) & 255), xpca[0] & 255); | |
516 | ||
517 | if(!s4bit) { /* Little guy? */ | |
518 | ||
519 | for(i = 0; i < 16; i += 2) { /* Step through pteg */ | |
520 | db_printf("%08X %08X - ", xpteg[i], xpteg[i + 1]); /* Dump the pteg slot */ | |
521 | ||
522 | if(xpteg[i] & 0x80000000) db_printf(" valid - "); /* Is it valid? */ | |
523 | else db_printf("invalid - "); /* Nope, invalid */ | |
524 | ||
525 | space = (xpteg[i] >> 7) & (maxAdrSp - 1); /* Extract the space */ | |
526 | hash = space | (space << maxAdrSpb) | (space << (2 * maxAdrSpb)); /* Get the hash */ | |
527 | pva = ptegindex ^ hash; /* Get part of the vaddr */ | |
528 | seg = (xpteg[i] >> 7) ^ hash; /* Get the segment number */ | |
529 | api = (xpteg[i] & 0x3F); /* Get the API */ | |
530 | va = ((seg << (28 - maxAdrSpb)) & 0xF0000000) | (api << 22) | ((pva << 12) & 0x003FF000); /* Get the vaddr */ | |
531 | db_printf("va = %08X\n", va); | |
532 | } | |
533 | } | |
534 | else { | |
535 | ReadReal(pteg + 0x40, &xpteg[16]); /* Get third half of the pteg */ | |
536 | ReadReal(pteg + 0x60, &xpteg[24]); /* Get fourth half of the pteg */ | |
537 | ||
538 | for(i = 0; i < 32; i += 4) { /* Step through pteg */ | |
539 | db_printf("%08X%08X %08X%08X - ", xpteg[i], xpteg[i + 1], xpteg[i + 2], xpteg[i + 3]); /* Dump the pteg slot */ | |
540 | ||
541 | if(xpteg[i + 1] & 1) db_printf(" valid - "); /* Is it valid? */ | |
542 | else db_printf("invalid - "); /* Nope, invalid */ | |
543 | ||
544 | llslot = ((long long)xpteg[i] << 32) | (long long)xpteg[i + 1]; /* Make a long long version of this */ | |
545 | space = (llslot >> 12) & (maxAdrSp - 1); /* Extract the space */ | |
546 | llhash = (unsigned long long)space | ((unsigned long long)space << maxAdrSpb) | ((unsigned long long)space << (2 * maxAdrSpb)); /* Get the hash */ | |
a3d08fcd | 547 | llhash = llhash & 0x0000001FFFFFFFFFULL; /* Make sure we stay within supported ranges */ |
55e303ae A |
548 | pva = (unsigned long long)ptegindex ^ llhash; /* Get part of the vaddr */ |
549 | llseg = (llslot >> 12) ^ llhash; /* Get the segment number */ | |
550 | api = (llslot >> 7) & 0x1F; /* Get the API */ | |
551 | llva = ((llseg << (28 - maxAdrSpb)) & 0xFFFFFFFFF0000000ULL) | (api << 23) | ((pva << 12) & 0x007FF000); /* Get the vaddr */ | |
552 | db_printf("va = %016llX\n", llva); | |
553 | } | |
554 | } | |
555 | ||
1c79356b A |
556 | return; |
557 | } | |
558 | ||
559 | ||
560 | /* | |
561 | * Print out 256 bytes of virtual storage | |
562 | * | |
563 | * | |
564 | * dv [entaddr] [space] | |
565 | * address must be on 32-byte boundary. It will be rounded down if not | |
566 | */ | |
567 | void db_display_virtual(db_expr_t addr, int have_addr, db_expr_t count, char * modif) { | |
568 | ||
55e303ae | 569 | int i, size, lines, rlines; |
1c79356b | 570 | unsigned int xbuf[8]; |
55e303ae A |
571 | db_expr_t xspace; |
572 | pmap_t pmap; | |
1c79356b | 573 | |
91447636 | 574 | mapping_t *mp, *mpv; |
55e303ae A |
575 | addr64_t pa; |
576 | ppnum_t pnum; | |
577 | ||
578 | if (db_expression(&xspace)) { /* Parse the space ID */ | |
579 | if(xspace >= (1 << maxAdrSpb)) { /* Check if they gave us a sane space number */ | |
580 | db_printf("Invalid space ID: %llX - max is %X\n", xspace, (1 << maxAdrSpb) - 1); | |
581 | return; | |
582 | } | |
583 | dvspace = xspace; /* Get the space or set default */ | |
584 | } | |
1c79356b | 585 | |
55e303ae A |
586 | pmap = (pmap_t)pmapTrans[dvspace].pmapVAddr; /* Find the pmap address */ |
587 | if((unsigned int)pmap == 0) { /* Is there actually a pmap here? */ | |
588 | db_printf("Address space not found: %X\n", dvspace); /* Complain */ | |
589 | return; | |
590 | } | |
1c79356b | 591 | |
55e303ae | 592 | addr &= -32; |
1c79356b A |
593 | |
594 | size = 4096 - (addr & 0x00000FFF); /* Bytes left on page */ | |
595 | lines = size / 32; /* Number of lines in first or only part */ | |
596 | if(lines > 8) lines = 8; | |
597 | rlines = 8 - lines; | |
598 | if(rlines < 0) lines = 0; | |
599 | ||
55e303ae A |
600 | db_printf("Dumping %016llX (pmap = %08X, space = %X); ", addr, pmap, dvspace); |
601 | ||
602 | pnum = pmap_find_phys(pmap, (addr64_t)addr); /* Phynd the Physical */ | |
603 | if(!pnum) { /* Did we find one? */ | |
1c79356b A |
604 | db_printf("Not mapped\n"); |
605 | return; /* Didn't find any, return FALSE... */ | |
606 | } | |
55e303ae A |
607 | |
608 | pa = (addr64_t)(pnum << 12) | (addr64_t)(addr & 0xFFF); /* Get the physical address */ | |
609 | db_printf("phys = %016llX\n", pa); | |
610 | ||
1c79356b | 611 | for(i=0; i<lines; i++) { /* Print n bytes */ |
55e303ae A |
612 | ReadReal(pa, &xbuf[0]); /* Get the real storage data */ |
613 | db_printf("%016llX %08X %08X %08X %08X %08X %08X %08X %08X\n", addr, /* Print a line */ | |
1c79356b A |
614 | xbuf[0], xbuf[1], xbuf[2], xbuf[3], |
615 | xbuf[4], xbuf[5], xbuf[6], xbuf[7]); | |
91447636 | 616 | addr = (db_expr_t)(addr + 0x00000020); /* Point to next address */ |
55e303ae | 617 | pa = pa + 0x00000020; /* Point to next address */ |
1c79356b A |
618 | } |
619 | db_next = addr; | |
620 | ||
621 | if(!rlines) return; | |
622 | ||
55e303ae A |
623 | db_printf("Dumping %016llX (pmap = %08X, space = %X); ", addr, pmap, dvspace); |
624 | ||
625 | pnum = pmap_find_phys(pmap, (addr64_t)((unsigned int)addr)); /* Phynd the Physical */ | |
626 | if(!pnum) { /* Did we find one? */ | |
1c79356b A |
627 | db_printf("Not mapped\n"); |
628 | return; /* Didn't find any, return FALSE... */ | |
629 | } | |
55e303ae A |
630 | |
631 | pa = (addr64_t)(pnum << 12) | (addr64_t)((unsigned int)addr & 0xFFF); /* Get the physical address */ | |
632 | db_printf("phys = %016llX\n", pa); | |
633 | ||
1c79356b | 634 | for(i=0; i<rlines; i++) { /* Print n bytes */ |
55e303ae A |
635 | ReadReal(pa, &xbuf[0]); /* Get the real storage data */ |
636 | db_printf("%016llX %08X %08X %08X %08X %08X %08X %08X %08X\n", addr, /* Print a line */ | |
1c79356b A |
637 | xbuf[0], xbuf[1], xbuf[2], xbuf[3], |
638 | xbuf[4], xbuf[5], xbuf[6], xbuf[7]); | |
55e303ae A |
639 | addr = (db_expr_t)(addr + 0x00000020); /* Point to next address */ |
640 | pa = pa + 0x00000020; /* Point to next address */ | |
1c79356b A |
641 | } |
642 | db_next = addr; | |
643 | ||
644 | ||
645 | } | |
646 | ||
647 | ||
648 | /* | |
649 | * Print out savearea stuff | |
650 | * | |
651 | * | |
652 | * ds | |
653 | */ | |
654 | ||
655 | #define chainmax 32 | |
656 | ||
657 | void db_display_save(db_expr_t addr, int have_addr, db_expr_t count, char * modif) { | |
658 | ||
9bccf70c | 659 | int i, j, totsaves, tottasks, taskact, chainsize, vmid, didvmhead; |
1c79356b A |
660 | processor_set_t pset = &default_pset; |
661 | task_t task; | |
662 | thread_act_t act; | |
663 | savearea *save; | |
9bccf70c | 664 | vmmCntrlTable *CTable; |
1c79356b A |
665 | |
666 | tottasks = 0; | |
667 | totsaves = 0; | |
668 | ||
669 | for(task = (task_t)pset->tasks.next; task != (task_t)&pset->tasks.next; task = (task_t)task->pset_tasks.next) { /* Go through the tasks */ | |
670 | taskact = 0; /* Reset activation count */ | |
671 | db_printf("\nTask %4d @%08X:\n", tottasks, task); /* Show where we're at */ | |
55e303ae | 672 | for(act = (thread_act_t)task->threads.next; act != (thread_act_t)&task->threads; act = (thread_act_t)act->task_threads.next) { /* Go through activations */ |
9bccf70c | 673 | db_printf(" Act %4d @%08X - p: %08X current context: %08X\n", |
91447636 | 674 | taskact, act, act->machine.pcb, act->machine.curctx); |
1c79356b | 675 | |
91447636 | 676 | save = (savearea *)act->machine.pcb; /* Set the start of the normal chain */ |
1c79356b | 677 | chainsize = 0; |
9bccf70c A |
678 | |
679 | db_printf(" General context - fp: %08X fl: %08X fc: %d vp: %08X vl: %08X vp: %d\n", | |
91447636 A |
680 | act->machine.facctx.FPUsave, act->machine.facctx.FPUlevel, act->machine.facctx.FPUcpu, |
681 | act->machine.facctx.VMXsave, act->machine.facctx.VMXlevel, act->machine.facctx.VMXcpu); | |
9bccf70c | 682 | |
1c79356b A |
683 | while(save) { /* Do them all */ |
684 | totsaves++; /* Count savearea */ | |
55e303ae A |
685 | db_printf(" Norm %08X: %016llX %016llX - tot = %d\n", save, save->save_srr0, save->save_srr1, totsaves); |
686 | save = (savearea *)save->save_hdr.save_prev; /* Next one */ | |
1c79356b | 687 | if(chainsize++ > chainmax) { /* See if we might be in a loop */ |
9bccf70c | 688 | db_printf(" Chain terminated by count (%d) before %08X\n", chainmax, save); |
1c79356b A |
689 | break; |
690 | } | |
691 | } | |
692 | ||
91447636 | 693 | save = (savearea *)act->machine.facctx.FPUsave; /* Set the start of the floating point chain */ |
1c79356b A |
694 | chainsize = 0; |
695 | while(save) { /* Do them all */ | |
9bccf70c A |
696 | totsaves++; /* Count savearea */ |
697 | db_printf(" FPU %08X: %08X - tot = %d\n", save, save->save_hdr.save_level, totsaves); | |
55e303ae | 698 | save = (savearea *)save->save_hdr.save_prev; /* Next one */ |
1c79356b | 699 | if(chainsize++ > chainmax) { /* See if we might be in a loop */ |
9bccf70c | 700 | db_printf(" Chain terminated by count (%d) before %08X\n", chainmax, save); |
1c79356b A |
701 | break; |
702 | } | |
703 | } | |
704 | ||
91447636 | 705 | save = (savearea *)act->machine.facctx.VMXsave; /* Set the start of the floating point chain */ |
1c79356b A |
706 | chainsize = 0; |
707 | while(save) { /* Do them all */ | |
9bccf70c A |
708 | totsaves++; /* Count savearea */ |
709 | db_printf(" Vec %08X: %08X - tot = %d\n", save, save->save_hdr.save_level, totsaves); | |
55e303ae | 710 | save = (savearea *)save->save_hdr.save_prev; /* Next one */ |
1c79356b | 711 | if(chainsize++ > chainmax) { /* See if we might be in a loop */ |
9bccf70c | 712 | db_printf(" Chain terminated by count (%d) before %08X\n", chainmax, save); |
1c79356b A |
713 | break; |
714 | } | |
715 | } | |
9bccf70c | 716 | |
91447636 | 717 | if(CTable = act->machine.vmmControl) { /* Are there virtual machines? */ |
9bccf70c | 718 | |
55e303ae | 719 | for(vmid = 0; vmid < kVmmMaxContexts; vmid++) { |
9bccf70c A |
720 | |
721 | if(!(CTable->vmmc[vmid].vmmFlags & vmmInUse)) continue; /* Skip if vm is not in use */ | |
722 | ||
723 | if(!CTable->vmmc[vmid].vmmFacCtx.FPUsave && !CTable->vmmc[vmid].vmmFacCtx.VMXsave) continue; /* If neither types, skip this vm */ | |
724 | ||
725 | db_printf(" VMachine ID %3d - fp: %08X fl: %08X fc: %d vp: %08X vl: %08X vp: %d\n", vmid, /* Title it */ | |
726 | CTable->vmmc[vmid].vmmFacCtx.FPUsave, CTable->vmmc[vmid].vmmFacCtx.FPUlevel, CTable->vmmc[vmid].vmmFacCtx.FPUcpu, | |
727 | CTable->vmmc[vmid].vmmFacCtx.VMXsave, CTable->vmmc[vmid].vmmFacCtx.VMXlevel, CTable->vmmc[vmid].vmmFacCtx.VMXcpu | |
728 | ); | |
729 | ||
730 | save = (savearea *)CTable->vmmc[vmid].vmmFacCtx.FPUsave; /* Set the start of the floating point chain */ | |
731 | chainsize = 0; | |
732 | while(save) { /* Do them all */ | |
733 | totsaves++; /* Count savearea */ | |
734 | db_printf(" FPU %08X: %08X - tot = %d\n", save, save->save_hdr.save_level, totsaves); | |
55e303ae | 735 | save = (savearea *)save->save_hdr.save_prev; /* Next one */ |
9bccf70c A |
736 | if(chainsize++ > chainmax) { /* See if we might be in a loop */ |
737 | db_printf(" Chain terminated by count (%d) before %08X\n", chainmax, save); | |
738 | break; | |
739 | } | |
740 | } | |
741 | ||
742 | save = (savearea *)CTable->vmmc[vmid].vmmFacCtx.VMXsave; /* Set the start of the floating point chain */ | |
743 | chainsize = 0; | |
744 | while(save) { /* Do them all */ | |
745 | totsaves++; /* Count savearea */ | |
746 | db_printf(" Vec %08X: %08X - tot = %d\n", save, save->save_hdr.save_level, totsaves); | |
55e303ae | 747 | save = (savearea *)save->save_hdr.save_prev; /* Next one */ |
9bccf70c A |
748 | if(chainsize++ > chainmax) { /* See if we might be in a loop */ |
749 | db_printf(" Chain terminated by count (%d) before %08X\n", chainmax, save); | |
750 | break; | |
751 | } | |
752 | } | |
753 | } | |
754 | } | |
1c79356b A |
755 | taskact++; |
756 | } | |
757 | tottasks++; | |
758 | } | |
759 | ||
760 | db_printf("Total saveareas accounted for: %d\n", totsaves); | |
761 | return; | |
762 | } | |
763 | ||
764 | /* | |
765 | * Print out extra registers | |
766 | * | |
767 | * | |
768 | * dx | |
769 | */ | |
770 | ||
771 | extern unsigned int dbfloats[33][2]; | |
772 | extern unsigned int dbvecs[33][4]; | |
91447636 | 773 | extern unsigned int dbspecrs[336]; |
1c79356b A |
774 | |
775 | void db_display_xregs(db_expr_t addr, int have_addr, db_expr_t count, char * modif) { | |
776 | ||
777 | int i, j, pents; | |
778 | ||
779 | stSpecrs(dbspecrs); /* Save special registers */ | |
91447636 | 780 | if(PerProcTable[0].ppe_vaddr->pf.Available & pf64Bit) { |
a3d08fcd A |
781 | db_printf("PIR: %08X\n", dbspecrs[0]); |
782 | db_printf("PVR: %08X\n", dbspecrs[1]); | |
783 | db_printf("SDR1: %08X.%08X\n", dbspecrs[26], dbspecrs[27]); | |
784 | db_printf("HID0: %08X.%08X\n", dbspecrs[28], dbspecrs[29]); | |
785 | db_printf("HID1: %08X.%08X\n", dbspecrs[30], dbspecrs[31]); | |
786 | db_printf("HID4: %08X.%08X\n", dbspecrs[32], dbspecrs[33]); | |
787 | db_printf("HID5: %08X.%08X\n", dbspecrs[34], dbspecrs[35]); | |
788 | db_printf("SPRG0: %08X.%08X %08X.%08X\n", dbspecrs[18], dbspecrs[19], dbspecrs[20], dbspecrs[21]); | |
789 | db_printf("SPRG2: %08X.%08X %08X.%08X\n", dbspecrs[22], dbspecrs[23], dbspecrs[24], dbspecrs[25]); | |
790 | db_printf("\n"); | |
791 | for(i = 0; i < (64 * 4); i += 4) { | |
792 | db_printf("SLB %02d: %08X.%08X %08X.%08X\n", i / 4, dbspecrs[80 + i], dbspecrs[81 + i], dbspecrs[82 + i], dbspecrs[83 + i]); | |
793 | } | |
794 | } | |
795 | else { | |
796 | db_printf("PIR: %08X\n", dbspecrs[0]); | |
797 | db_printf("PVR: %08X\n", dbspecrs[1]); | |
798 | db_printf("SDR1: %08X\n", dbspecrs[22]); | |
799 | db_printf("HID0: %08X\n", dbspecrs[39]); | |
800 | db_printf("HID1: %08X\n", dbspecrs[40]); | |
801 | db_printf("L2CR: %08X\n", dbspecrs[41]); | |
802 | db_printf("MSSCR0: %08X\n", dbspecrs[42]); | |
803 | db_printf("MSSCR1: %08X\n", dbspecrs[43]); | |
804 | db_printf("THRM1: %08X\n", dbspecrs[44]); | |
805 | db_printf("THRM2: %08X\n", dbspecrs[45]); | |
806 | db_printf("THRM3: %08X\n", dbspecrs[46]); | |
807 | db_printf("ICTC: %08X\n", dbspecrs[47]); | |
808 | db_printf("L2CR2: %08X\n", dbspecrs[48]); | |
809 | db_printf("DABR: %08X\n", dbspecrs[49]); | |
810 | ||
811 | db_printf("DBAT: %08X %08X %08X %08X\n", dbspecrs[2], dbspecrs[3], dbspecrs[4], dbspecrs[5]); | |
812 | db_printf(" %08X %08X %08X %08X\n", dbspecrs[6], dbspecrs[7], dbspecrs[8], dbspecrs[9]); | |
813 | db_printf("IBAT: %08X %08X %08X %08X\n", dbspecrs[10], dbspecrs[11], dbspecrs[12], dbspecrs[13]); | |
814 | db_printf(" %08X %08X %08X %08X\n", dbspecrs[14], dbspecrs[15], dbspecrs[16], dbspecrs[17]); | |
815 | db_printf("SPRG: %08X %08X %08X %08X\n", dbspecrs[18], dbspecrs[19], dbspecrs[20], dbspecrs[21]); | |
816 | db_printf("\n"); | |
817 | for(i = 0; i < 16; i += 8) { /* Print 8 at a time */ | |
818 | db_printf("SR%02d: %08X %08X %08X %08X %08X %08X %08X %08X\n", i, | |
819 | dbspecrs[23+i], dbspecrs[24+i], dbspecrs[25+i], dbspecrs[26+i], | |
820 | dbspecrs[27+i], dbspecrs[28+i], dbspecrs[29+i], dbspecrs[30+i]); | |
821 | } | |
1c79356b A |
822 | } |
823 | ||
824 | db_printf("\n"); | |
825 | ||
826 | stFloat(dbfloats); /* Save floating point registers */ | |
827 | for(i = 0; i < 32; i += 4) { /* Print 4 at a time */ | |
828 | db_printf("F%02d: %08X %08X %08X %08X %08X %08X %08X %08X\n", i, | |
829 | dbfloats[i][0], dbfloats[i][1], dbfloats[i+1][0], dbfloats[i+1][1], | |
830 | dbfloats[i+2][0], dbfloats[i+2][1], dbfloats[i+3][0], dbfloats[i+3][1]); | |
831 | } | |
832 | db_printf("FCR: %08X %08X\n", dbfloats[32][0], dbfloats[32][1]); /* Print FSCR */ | |
833 | ||
834 | if(!stVectors(dbvecs)) return; /* Return if not Altivec capable */ | |
835 | ||
836 | db_printf("\n"); | |
837 | ||
838 | for(i = 0; i < 32; i += 2) { /* Print 2 at a time */ | |
839 | db_printf("V%02d: %08X %08X %08X %08X %08X %08X %08X %08X\n", i, | |
840 | dbvecs[i][0], dbvecs[i][1], dbvecs[i][2], dbvecs[i][3], | |
841 | dbvecs[i+1][0], dbvecs[i+1][1], dbvecs[i+1][2], dbvecs[i+1][3]); | |
842 | } | |
843 | db_printf("VCR: %08X %08X %08X %08X\n", dbvecs[32][0], dbvecs[32][1], dbvecs[32][2], dbvecs[32][3]); /* Print VSCR */ | |
844 | ||
845 | return; /* Tell them we did it */ | |
846 | ||
847 | ||
848 | } | |
849 | ||
55e303ae A |
850 | /* |
851 | * Check check mappings and hash table for consistency | |
852 | * | |
853 | * cm | |
854 | */ | |
855 | void db_check_mappings(db_expr_t addr, int have_addr, db_expr_t count, char * modif) { | |
856 | ||
857 | addr64_t pteg, pca, llva, lnextva; | |
858 | unsigned int xpteg[32], xpca[8], space, hash, pva, seg, api, va, free, free2, xauto, PTEGcnt, wimgkk, wimgxx, slotoff; | |
859 | int i, j, fnderr, slot, slot2, k, s4bit; | |
860 | pmap_t pmap; | |
91447636 | 861 | mapping_t *mp; |
55e303ae A |
862 | ppnum_t ppn, pa, aoff; |
863 | unsigned long long llslot, llseg, llhash; | |
864 | ||
865 | s4bit = 0; /* Assume dinky? */ | |
91447636 | 866 | if(PerProcTable[0].ppe_vaddr->pf.Available & pf64Bit) s4bit = 1; /* Are we a big guy? */ |
55e303ae A |
867 | |
868 | PTEGcnt = hash_table_size / 64; /* Get the number of PTEGS */ | |
869 | if(s4bit) PTEGcnt = PTEGcnt / 2; /* PTEGs are twice as big */ | |
870 | ||
871 | pteg = hash_table_base; /* Start of hash table */ | |
872 | pca = hash_table_base - 4; /* Start of PCA */ | |
873 | ||
874 | for(i = 0; i < PTEGcnt; i++) { /* Step through them all */ | |
875 | ||
876 | fnderr = 0; | |
877 | ||
878 | ReadReal(pteg, &xpteg[0]); /* Get first half of the pteg */ | |
879 | ReadReal(pteg + 0x20, &xpteg[8]); /* Get second half of the pteg */ | |
880 | if(s4bit) { /* See if we need the other half */ | |
881 | ReadReal(pteg + 0x40, &xpteg[16]); /* Get third half of the pteg */ | |
882 | ReadReal(pteg + 0x60, &xpteg[24]); /* Get fourth half of the pteg */ | |
883 | } | |
884 | ReadReal(pca, &xpca[0]); /* Get pca */ | |
885 | ||
886 | if(xpca[0] & 0x00000001) { /* Is PCA locked? */ | |
887 | db_printf("Unexpected locked PCA\n"); /* Yeah, this may be bad */ | |
888 | fnderr = 1; /* Remember to print the pca/pteg pair later */ | |
889 | } | |
890 | ||
891 | free = 0x80000000; | |
892 | ||
893 | for(j = 0; j < 7; j++) { /* Search for duplicates */ | |
894 | slot = j * 2; /* Point to the slot */ | |
895 | if(s4bit) slot = slot * 2; /* Adjust for bigger slots */ | |
896 | if(!(xpca[0] & free)) { /* Check more if slot is allocated */ | |
897 | for(k = j + 1; k < 8; k++) { /* Search remaining slots */ | |
898 | slot2 = k * 2; /* Point to the slot */ | |
899 | if(s4bit) slot2 = slot2 * 2; /* Adjust for bigger slots */ | |
900 | if((xpteg[slot] == xpteg[slot2]) | |
901 | && (!s4bit || (xpteg[slot + 1] == xpteg[slot2 + 1]))) { /* Do we have duplicates? */ | |
902 | db_printf("Duplicate tags in pteg, slot %d and slot %d\n", j, k); | |
903 | fnderr = 1; | |
904 | } | |
905 | } | |
906 | } | |
907 | free = free >> 1; /* Move slot over */ | |
908 | } | |
909 | ||
910 | free = 0x80000000; | |
911 | xauto = 0x00008000; | |
912 | ||
913 | for(j = 0; j < 8; j++) { /* Step through the slots */ | |
914 | ||
915 | slot = j * 2; /* Point to the slot */ | |
916 | if(s4bit) slot = slot * 2; /* Hagfish? */ | |
917 | if(xpca[0] & free) { /* Check if marked free */ | |
918 | if((!s4bit && (xpteg[slot] & 0x80000000)) /* Is a supposedly free slot valid? */ | |
919 | || (s4bit && (xpteg[slot + 1] & 1))) { | |
920 | db_printf("Free slot still valid - %d\n", j); | |
921 | fnderr = 1; | |
922 | } | |
923 | } | |
924 | else { /* We have an in use slot here */ | |
925 | ||
926 | if(!(!s4bit && (xpteg[slot] & 0x80000000)) /* Is a supposedly in use slot valid? */ | |
927 | && !(s4bit && (xpteg[slot + 1] & 1))) { | |
928 | db_printf("Inuse slot not valid - %d\n", j); | |
929 | fnderr = 1; | |
930 | } | |
931 | else { /* Slot is valid, check mapping */ | |
932 | if(!s4bit) { /* Not Hagfish? */ | |
933 | space = (xpteg[slot] >> 7) & (maxAdrSp - 1); /* Extract the space */ | |
934 | hash = space | (space << maxAdrSpb) | (space << (2 * maxAdrSpb)); /* Get the hash */ | |
935 | pva = i ^ hash; /* Get part of the vaddr */ | |
936 | seg = (xpteg[slot] >> 7) ^ hash; /* Get the segment number */ | |
937 | api = (xpteg[slot] & 0x3F); /* Get the API */ | |
938 | va = ((seg << (28 - maxAdrSpb)) & 0xF0000000) | (api << 22) | ((pva << 12) & 0x003FF000); /* Get the vaddr */ | |
939 | llva = (addr64_t)va; /* Make this a long long */ | |
940 | wimgxx = xpteg[slot + 1] & 0x7F; /* Get the wimg and pp */ | |
941 | ppn = xpteg[slot + 1] >> 12; /* Get physical page number */ | |
942 | slotoff = (i * 64) + (j * 8) | 1; /* Get offset to slot and valid bit */ | |
943 | } | |
944 | else { /* Yes, Hagfish */ | |
945 | llslot = ((long long)xpteg[slot] << 32) | (long long)xpteg[slot + 1]; /* Make a long long version of this */ | |
946 | space = (llslot >> 12) & (maxAdrSp - 1); /* Extract the space */ | |
947 | llhash = (unsigned long long)space | ((unsigned long long)space << maxAdrSpb) | ((unsigned long long)space << (2 * maxAdrSpb)); /* Get the hash */ | |
a3d08fcd | 948 | llhash = llhash & 0x0000001FFFFFFFFFULL; /* Make sure we stay within supported ranges */ |
55e303ae A |
949 | pva = i ^ llhash; /* Get part of the vaddr */ |
950 | llseg = ((llslot >> 12) ^ llhash); /* Get the segment number */ | |
951 | api = (llslot >> 7) & 0x1F; /* Get the API */ | |
952 | llva = ((llseg << (28 - maxAdrSpb)) & 0xFFFFFFFFF0000000ULL) | (api << 23) | ((pva << 12) & 0x007FF000); /* Get the vaddr */ | |
953 | wimgxx = xpteg[slot + 3] & 0x7F; /* Get the wimg and pp */ | |
954 | ppn = (xpteg[slot + 2] << 20) | (xpteg[slot + 3] >> 12); /* Get physical page number */ | |
955 | slotoff = (i * 128) + (j * 16) | 1; /* Get offset to slot and valid bit */ | |
956 | } | |
957 | ||
958 | pmap = pmapTrans[space].pmapVAddr; /* Find the pmap address */ | |
959 | if(!pmap) { /* The pmap is not in use */ | |
960 | db_printf("The space %08X is not assigned to a pmap, slot = %d\n", space, slot); /* Say we are wrong */ | |
961 | fnderr = 1; | |
962 | goto dcmout; | |
963 | } | |
91447636 A |
964 | |
965 | if (pmap->pmapFlags & pmapVMgsaa) { | |
966 | unsigned int ret; | |
967 | mapping_t mpcopy; | |
968 | ret = hw_find_map_gv(pmap, llva, &mpcopy); | |
969 | } else { | |
970 | mp = hw_find_map(pmap, llva, &lnextva); /* Try to find the mapping for this address */ | |
971 | // db_printf("%08X - %017llX\n", mp, llva); | |
972 | if((unsigned int)mp == mapRtBadLk) { /* Did we lock up ok? */ | |
973 | db_printf("Timeout locking mapping for for virtual address %016ll8X, slot = %d\n", llva, j); | |
974 | return; | |
55e303ae | 975 | } |
91447636 A |
976 | |
977 | if(!mp) { /* Did we find one? */ | |
978 | db_printf("Not mapped, slot = %d, va = %08X\n", j, (unsigned int)llva); | |
55e303ae | 979 | fnderr = 1; |
91447636 | 980 | goto dcmout; |
55e303ae | 981 | } |
91447636 A |
982 | |
983 | if((mp->mpFlags & 0xFF000000) > 0x01000000) { /* Is busy count too high? */ | |
984 | db_printf("Busy count too high, slot = %d\n", j); | |
55e303ae A |
985 | fnderr = 1; |
986 | } | |
91447636 A |
987 | |
988 | if((mp->mpFlags & mpType) == mpBlock) { /* Is this a block map? */ | |
989 | if(!(xpca[0] & xauto)) { /* Is it marked as such? */ | |
990 | db_printf("mapping marked as block, PCA is not, slot = %d\n", j); | |
991 | fnderr = 1; | |
992 | } | |
993 | } | |
994 | else { /* Is a block */ | |
995 | if(xpca[0] & xauto) { /* Is it marked as such? */ | |
996 | db_printf("mapping not marked as block, PCA is, slot = %d\n", j); | |
997 | fnderr = 1; | |
998 | } | |
999 | if(mp->mpPte != slotoff) { /* See if mapping PTEG offset is us */ | |
1000 | db_printf("mapping does not point to PTE, slot = %d\n", j); | |
1001 | fnderr = 1; | |
1002 | } | |
1003 | } | |
55e303ae | 1004 | |
91447636 A |
1005 | wimgkk = (unsigned int)mp->mpVAddr; /* Get last half of vaddr where keys, etc are */ |
1006 | wimgkk = (wimgkk ^ wimgxx) & 0x7F; /* XOR to find differences from PTE */ | |
1007 | if(wimgkk) { /* See if key in PTE is what we want */ | |
1008 | db_printf("key or WIMG does not match, slot = %d\n", j); | |
1009 | fnderr = 1; | |
1010 | } | |
1011 | ||
1012 | aoff = (ppnum_t)((llva >> 12) - (mp->mpVAddr >> 12)); /* Get the offset from vaddr */ | |
1013 | pa = aoff + mp->mpPAddr; /* Get the physical page number we expect */ | |
1014 | if(pa != ppn) { /* Is physical address expected? */ | |
1015 | db_printf("Physical address does not match, slot = %d\n", j); | |
1016 | fnderr = 1; | |
1017 | } | |
1018 | ||
1019 | mapping_drop_busy(mp); /* We're done with the mapping */ | |
55e303ae | 1020 | } |
55e303ae A |
1021 | } |
1022 | ||
1023 | } | |
1024 | dcmout: | |
1025 | free = free >> 1; | |
1026 | xauto = xauto >> 1; | |
1027 | } | |
1028 | ||
1029 | ||
1030 | if(fnderr)db_dumppca(i); /* Print if error */ | |
1031 | ||
1032 | pteg = pteg + 64; /* Go to the next one */ | |
1033 | if(s4bit) pteg = pteg + 64; /* Hagfish? */ | |
1034 | pca = pca - 4; /* Go to the next one */ | |
1035 | ||
1036 | ||
1037 | } | |
1038 | ||
1039 | return; | |
1040 | } | |
1041 | ||
1c79356b A |
1042 | /* |
1043 | * Displays all of the kmods in the system. | |
1044 | * | |
1045 | * dp | |
1046 | */ | |
1047 | void db_display_kmod(db_expr_t addr, int have_addr, db_expr_t count, char * modif) { | |
1048 | ||
1049 | kmod_info_t *kmd; | |
1050 | unsigned int strt, end; | |
1051 | ||
1052 | kmd = kmod; /* Start at the start */ | |
1053 | ||
1054 | db_printf("info addr start - end name ver\n"); | |
1055 | ||
1056 | while(kmd) { /* Dump 'em all */ | |
1057 | strt = (unsigned int)kmd->address + kmd->hdr_size; /* Get start of kmod text */ | |
1058 | end = (unsigned int)kmd->address + kmd->size; /* Get end of kmod */ | |
1059 | db_printf("%08X %08X %08X - %08X: %s, %s\n", kmd, kmd->address, strt, end, | |
1060 | kmd->name, kmd->version); | |
1061 | kmd = kmd->next; /* Step to it */ | |
1062 | } | |
1063 | ||
1064 | return; | |
1065 | } | |
1066 | ||
1067 | /* | |
1068 | * Displays stuff | |
1069 | * | |
1070 | * gs | |
1071 | */ | |
1072 | unsigned char xxgpo[36] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; | |
1073 | ||
1074 | void db_gsnoop(db_expr_t addr, int have_addr, db_expr_t count, char * modif) { | |
1075 | ||
1076 | int i, j; | |
1077 | unsigned char *gp, gpn[36]; | |
1078 | #define ngpr 34 | |
1079 | ||
1080 | gp = (unsigned char *)0x8000005C; | |
1081 | ||
1082 | for(i = 0; i < ngpr; i++) gpn[i] = gp[i]; /* Copy 'em */ | |
1083 | ||
1084 | for(i = 0; i < ngpr; i++) { | |
1085 | db_printf("%02X ", gpn[i]); | |
1086 | } | |
1087 | db_printf("\n"); | |
1088 | ||
1089 | for(i = 0; i < ngpr; i++) { | |
1090 | if(gpn[i] != xxgpo[i]) db_printf("^^ "); | |
1091 | else db_printf(" "); | |
1092 | } | |
1093 | db_printf("\n"); | |
1094 | ||
1095 | for(i = 0; i < ngpr; i++) xxgpo[i] = gpn[i]; /* Save 'em */ | |
1096 | ||
1097 | return; | |
1098 | } | |
1099 | ||
1100 | ||
1101 | void Dumbo(void); | |
1102 | void Dumbo(void){ | |
1103 | } |