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