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