]>
Commit | Line | Data |
---|---|---|
c58bbcfb MF |
1 | # |
2 | # Base settings | |
3 | # | |
4 | ||
5b61754d MF |
5 | set print pretty on |
6 | set prompt \e[30;1m(\e[34;1mgdb\e[30;1m)\e[0m | |
7 | set history save on | |
8 | set pagination off | |
9 | set output-radix 16 | |
10 | set remotetimeout 300 | |
d24159b0 MF |
11 | #handle SIGINT nostop noprint pass |
12 | #handle SIGQUIT stop print nopass | |
5b61754d MF |
13 | #catch fork |
14 | #catch vfork | |
15 | ||
c58bbcfb MF |
16 | |
17 | # | |
18 | # Random helpers. | |
19 | # | |
20 | ||
5b61754d MF |
21 | define exit |
22 | quit | |
23 | end | |
24 | ||
5b61754d MF |
25 | define jtag |
26 | target remote localhost:2000 | |
27 | end | |
b41bdf2b MF |
28 | define kgdboc |
29 | set remotebaud 57600 | |
30 | if $argc == 0 | |
31 | target remote /dev/ttyS0 | |
32 | else | |
33 | target remote /dev/tty$arg0 | |
34 | end | |
35 | end | |
36 | define kgdbocusb | |
37 | kgdboc USB0 | |
38 | end | |
39 | define kgdboe | |
40 | target remote udp:bfin:6443 | |
41 | end | |
22898076 MF |
42 | define vapier |
43 | target remote vapier:2000 | |
44 | end | |
5b61754d MF |
45 | define bfin |
46 | target remote bfin:1234 | |
47 | end | |
48 | ||
1bcd182d | 49 | define di |
5b61754d MF |
50 | if $argc == 0 |
51 | disassemble $pc ($pc + 0x40) | |
52 | end | |
53 | if $argc == 1 | |
54 | disassemble $arg0 ($arg0 + 0x40) | |
55 | end | |
56 | end | |
1bcd182d MF |
57 | define dis |
58 | if $argc == 0 | |
59 | disassemble $pc,+0x40 | |
60 | end | |
61 | if $argc == 1 | |
62 | disassemble $arg0,+0x40 | |
63 | end | |
64 | end | |
63d15f58 MF |
65 | define go |
66 | jump *$arg0 | |
67 | end | |
5b61754d | 68 | |
c58bbcfb MF |
69 | |
70 | # | |
71 | # Misc Blackfin helper functions | |
72 | # | |
73 | ||
74 | define regs | |
75 | printf "R0: %08x %-11i P0: %08x RETS: %08x LC0: %08x %u\n", $r0, $r0, $p0, $rets, $lc0, $lc0 | |
76 | printf "R1: %08x %-11i P1: %08x RETI: %08x LT0: %08x\n", $r1, $r1, $p1, $reti, $lt0 | |
77 | printf "R2: %08x %-11i P2: %08x RETX: %08x LB0: %08x\n", $r2, $r2, $p2, $retx, $lb0 | |
78 | printf "R3: %08x %-11i P3: %08x RETE: %08x LC1: %08x %u\n", $r3, $r3, $p3, $rete, $lc1, $lc1 | |
79 | printf "R4: %08x %-11i P4: %08x RETN: %08x LT1: %08x\n", $r4, $r4, $p4, $retn, $lt1 | |
80 | printf "R5: %08x %-11i P5: %08x ASTAT: %08x LB1: %08x\n", $r5, $r5, $p5, $astat, $lb1 | |
81 | printf "R6: %08x %-11i SP: %08x CC: %08x\n", $r6, $r6, $sp, $cc | |
82 | printf "R7: %08x %-11i USP: %08x CYC1: %08x SEQSTAT: %08x\n", $r7, $r7, $usp, $cycles, $seqstat | |
83 | printf "PC: %08x FP: %08x CYC2: %08x SYSCFG: %08x\n", $pc, $fp, $cycles2, $syscfg | |
84 | end | |
85 | document regs | |
86 | Usage: regs | |
87 | Display the common core registers in a compact format. | |
88 | end | |
89 | ||
90 | define all_regs | |
91 | regs | |
92 | printf " B0 : %08x L0 : %08x M0 : %08x I0 : %08x\n", $b0, $l0, $m0, $i0 | |
93 | printf " B1 : %08x L1 : %08x M1 : %08x I1 : %08x\n", $b1, $l1, $m1, $i1 | |
94 | printf " B2 : %08x L2 : %08x M2 : %08x I2 : %08x\n", $b2, $l2, $m2, $i2 | |
95 | printf " B3 : %08x L3 : %08x M3 : %08x I3 : %08x\n", $b3, $l3, $m3, $i3 | |
96 | printf "A0.w: %08x A0.x: %08x A1.w: %08x A1.x: %08x\n", $a0w, $a0x, $a1w, $a1x | |
97 | end | |
98 | document all_regs | |
99 | Usage: all_regs | |
100 | Display all core registers in a compact format. | |
101 | end | |
102 | ||
103 | define astat | |
104 | printf "ASTAT: %#x ( ", $astat | |
105 | if $astat & (1 << 25) | |
106 | printf "VS " | |
107 | end | |
108 | if $astat & (1 << 24) | |
109 | printf "V " | |
110 | end | |
111 | if $astat & (1 << 19) | |
112 | printf "AV1S " | |
113 | end | |
114 | if $astat & (1 << 18) | |
115 | printf "AV1 " | |
116 | end | |
117 | if $astat & (1 << 17) | |
118 | printf "AV0S " | |
119 | end | |
120 | if $astat & (1 << 16) | |
121 | printf "AV0 " | |
122 | end | |
123 | if $astat & (1 << 13) | |
124 | printf "AC1 " | |
125 | end | |
126 | if $astat & (1 << 12) | |
127 | printf "AC0 " | |
128 | end | |
129 | if $astat & (1 << 8) | |
130 | printf "RND_MOD " | |
131 | end | |
132 | if $astat & (1 << 6) | |
133 | printf "AQ " | |
134 | end | |
135 | if $astat & (1 << 5) | |
136 | printf "CC " | |
137 | end | |
138 | if $astat & (1 << 3) | |
139 | printf "V_COPY " | |
140 | end | |
141 | if $astat & (1 << 2) | |
142 | printf "AC0_COPY " | |
143 | end | |
144 | if $astat & (1 << 1) | |
145 | printf "AN " | |
146 | end | |
147 | if $astat & (1 << 0) | |
148 | printf "AZ " | |
149 | end | |
150 | printf ")\n" | |
151 | set $$inv = $astat & 0xfcf0ce90 | |
152 | if $$inv | |
153 | printf "Invalid bits: %#x\n", $$inv | |
154 | end | |
155 | end | |
156 | ||
157 | define seqstat | |
158 | if $argc == 1 | |
159 | set $$seqstat = $arg0 | |
160 | else | |
161 | set $$seqstat = $seqstat | |
162 | end | |
163 | set $$excause = ($$seqstat & 0x3f) | |
164 | set $$sftreset = ($$seqstat & (0x1 << 13)) >> 13 | |
165 | set $$hwerrcause = ($$seqstat & (0x1f << 14)) >> 14 | |
166 | printf "SEQSTAT: %08x\n", $$seqstat | |
167 | printf " EXCAUSE: 0x%x\t", $$excause | |
168 | if $$excause >= 0x0 && $$excause <= 0xf | |
169 | printf "(custom exception)" | |
170 | end | |
171 | if $$excause == 0x10 | |
172 | printf "(single step)" | |
173 | end | |
174 | if $$excause == 0x11 | |
175 | printf "(trace buffer full)" | |
176 | end | |
177 | if $$excause == 0x21 | |
178 | printf "(undef inst)" | |
179 | end | |
180 | if $$excause == 0x22 | |
181 | printf "(illegal inst)" | |
182 | end | |
183 | if $$excause == 0x23 | |
184 | printf "(dcplb prot violation)" | |
185 | end | |
186 | if $$excause == 0x24 | |
187 | printf "(misaligned data)" | |
188 | end | |
189 | if $$excause == 0x25 | |
190 | printf "(unrecoverable event)" | |
191 | end | |
192 | if $$excause == 0x26 | |
193 | printf "(dcplb miss)" | |
194 | end | |
195 | if $$excause == 0x27 | |
196 | printf "(multiple dcplb hit)" | |
197 | end | |
198 | if $$excause == 0x28 | |
199 | printf "(emulation watchpoint)" | |
200 | end | |
201 | if $$excause == 0x2a | |
202 | printf "(misaligned inst)" | |
203 | end | |
204 | if $$excause == 0x2b | |
205 | printf "(icplb prot violation)" | |
206 | end | |
207 | if $$excause == 0x2c | |
208 | printf "(icplb miss)" | |
209 | end | |
210 | if $$excause == 0x2d | |
211 | printf "(multiple icplb hit)" | |
212 | end | |
213 | if $$excause == 0x2e | |
214 | printf "(illegal use of supervisor resource)" | |
215 | end | |
216 | printf "\n" | |
217 | printf " SFTRESET: 0x%x\t(last reset was ", $$sftreset | |
218 | if $$sftreset == 0 | |
219 | printf "not " | |
220 | end | |
221 | printf "a software reset)\n" | |
222 | printf " HWERRCAUSE: 0x%x\t", $$hwerrcause | |
223 | if $$hwerrcause == 0x2 | |
224 | printf "(system mmr error)" | |
225 | end | |
226 | if $$hwerrcause == 0x3 | |
227 | printf "(external memory addressing error)" | |
228 | end | |
229 | if $$hwerrcause == 0x12 | |
230 | printf "(performance monitor overflow)" | |
231 | end | |
232 | if $$hwerrcause == 0x18 | |
233 | printf "(raise 5 instruction)" | |
234 | end | |
235 | printf "\n" | |
236 | end | |
237 | document seqstat | |
238 | Usage: seqstat [value=$seqstat] | |
239 | Parse the bits of the seqstat [value] into the human readable definitions. | |
240 | end | |
241 | ||
242 | define reset | |
243 | if $argc == 0 | |
244 | set $$l1 = 0xffa00000 | |
245 | else | |
246 | set $$l1 = $arg0 | |
247 | end | |
248 | set $$pc = $$l1 | |
249 | ||
250 | # SSYNC | |
251 | set *(unsigned short *)($$l1) = 0x0024 | |
252 | set $$l1 += 2 | |
253 | ||
254 | # P2.H = 0xffc0 | |
255 | set *(unsigned long *)($$l1) = 0xffc0e14a | |
256 | set $$l1 += 4 | |
257 | ||
258 | # P2.L = 0x100 | |
259 | set *(unsigned long *)($$l1) = 0x0100e10a | |
260 | set $$l1 += 4 | |
261 | ||
262 | # R0 = 0x7 (X) | |
263 | set *(unsigned short *)($$l1) = 0x6038 | |
264 | set $$l1 += 2 | |
265 | ||
266 | # [P2] = R0 | |
267 | set *(unsigned short *)($$l1) = 0x9310 | |
268 | set $$l1 += 2 | |
269 | ||
270 | # SSYNC | |
271 | set *(unsigned short *)($$l1) = 0x0024 | |
272 | set $$l1 += 2 | |
273 | ||
274 | # R0 = 0x0 (X) | |
275 | set *(unsigned short *)($$l1) = 0x6000 | |
276 | set $$l1 += 2 | |
277 | ||
278 | # [P2] = R0 | |
279 | set *(unsigned short *)($$l1) = 0x9310 | |
280 | set $$l1 += 2 | |
281 | ||
282 | # SSYNC | |
283 | set *(unsigned short *)($$l1) = 0x0024 | |
284 | set $$l1 += 2 | |
285 | ||
286 | # RAISE 0x1 | |
287 | set *(unsigned short *)($$l1) = 0x0091 | |
288 | set $$l1 += 2 | |
289 | ||
290 | # JUMP.S -0x18 | |
291 | if ($$l1 - $$pc) != 0x18 | |
292 | echo ERROR: jump.s has wrong offset | |
293 | else | |
294 | set $pc == $$pc | |
295 | end | |
296 | set *(unsigned short *)($$l1) = 0x2ff4 | |
297 | set $$l1 += 2 | |
298 | ||
299 | printf "Continuing.\n" | |
300 | continue | |
301 | end | |
302 | document reset | |
303 | Usage: reset [L1 Instruction address=0xffa00000] | |
304 | Cram the software reset code into [L1 Instruction address] and execute it. | |
305 | This will perform both a system reset and a core reset. | |
306 | end | |
307 | ||
308 | define hwtrace_on | |
309 | set $$TBUFCTL = (unsigned long *)0xFFE06000 | |
310 | set *$$TBUFCTL = 0x3 | |
311 | end | |
312 | define hwtrace_off | |
313 | set $$TBUFCTL = (unsigned long *)0xFFE06000 | |
314 | set *$$TBUFCTL = 0x1 | |
315 | end | |
316 | define hwtrace | |
317 | set $$TBUFSTAT = (unsigned long *)0xFFE06004 | |
318 | set $$TBUF = (unsigned long *)0xFFE06100 | |
319 | set $$i = 0 | |
320 | if (!(*$$TBUFSTAT & 0x1F)) | |
321 | printf "Hardware trace buffer is empty\n" | |
322 | end | |
323 | while (*$$TBUFSTAT & 0x1F) | |
324 | printf "%2i Target: ", $$i | |
325 | output/a *$$TBUF | |
326 | printf "\n" | |
327 | printf " Source: " | |
328 | output/a *$$TBUF | |
329 | printf "\n" | |
330 | set $$i++ | |
331 | end | |
332 | end | |
333 | document hwtrace | |
334 | Usage: hwtrace | |
335 | Dump the hardware trace buffer. Remember, this is a destructive operation, | |
336 | so it can only be dumped once. | |
337 | end | |
338 | ||
339 | define show_clocks | |
340 | printf "PLL_LOCKCNT: 0x%04x\n", *(unsigned short *)0xFFC00010 | |
341 | printf "VR_CTL: 0x%04x\n", *(unsigned short *)0xFFC00008 | |
342 | printf "PLL_DIV: 0x%04x\n", *(unsigned short *)0xFFC00004 | |
343 | printf "PLL_CTL: 0x%04x\n", *(unsigned short *)0xFFC00000 | |
344 | end | |
345 | ||
346 | define show_sdram | |
347 | printf "SDRRC: 0x%04x\n", *(unsigned short *)0xFFC00A18 | |
348 | ||
349 | set $$SDBCTL = *(unsigned short *)0xFFC00A14 | |
350 | set $$EBCAW = ($$SDBCTL & 0x30) >> 4 | |
351 | set $$EBSZ = ($$SDBCTL & 0xe) >> 1 | |
352 | printf "SDBCTL: 0x%04x ", $$SDBCTL | |
353 | if ($$SDBCTL & 0x1) | |
354 | printf "(enabled) " | |
355 | else | |
356 | printf "(disabled) " | |
357 | end | |
358 | if $$EBCAW == 0x0 | |
359 | printf "(8-bit) " | |
360 | end | |
361 | if $$EBCAW == 0x1 | |
362 | printf "(9-bit) " | |
363 | end | |
364 | if $$EBCAW == 0x2 | |
365 | printf "(10-bit) " | |
366 | end | |
367 | if $$EBCAW == 0x3 | |
368 | printf "(11-bit) " | |
369 | end | |
370 | if $$EBSZ == 0x0 | |
371 | printf "(16MB)" | |
372 | end | |
373 | if $$EBSZ == 0x1 | |
374 | printf "(32MB)" | |
375 | end | |
376 | if $$EBSZ == 0x2 | |
377 | printf "(64MB)" | |
378 | end | |
379 | if $$EBSZ == 0x3 | |
380 | printf "(128MB)" | |
381 | end | |
382 | if $$EBSZ == 0x4 | |
383 | printf "(256MB)" | |
384 | end | |
385 | if $$EBSZ == 0x5 | |
386 | printf "(512MB)" | |
387 | end | |
388 | printf "\n" | |
389 | ||
390 | set $$SDSTAT = *(unsigned short *)0xFFC00A1C | |
391 | printf "SDSTAT: 0x%04x ", $$SDSTAT | |
392 | if ($$SDSTAT & (1 << 0)) | |
393 | printf "(idle) " | |
394 | else | |
395 | printf "(busy) " | |
396 | end | |
397 | if ($$SDSTAT & (1 << 1)) | |
398 | printf "(self-refresh) " | |
399 | end | |
400 | if ($$SDSTAT & (1 << 2)) | |
401 | printf "(powerup) " | |
402 | end | |
403 | if ($$SDSTAT & (1 << 3)) | |
404 | printf "(will power up) " | |
405 | end | |
406 | if ($$SDSTAT & (1 << 4)) | |
407 | printf "(EAB error) " | |
408 | end | |
409 | printf "\n" | |
410 | ||
411 | printf "SDGCTL: 0x%08x\n", *(unsigned long *)0xFFC00A10 | |
412 | end | |
413 | ||
414 | define show_ddr | |
415 | printf "DDRCTL0: 0x%08x\n", *(unsigned long *)0xFFC00A20 | |
416 | printf "DDRCTL1: 0x%08x\n", *(unsigned long *)0xFFC00A24 | |
417 | printf "DDRCTL2: 0x%08x\n", *(unsigned long *)0xFFC00A28 | |
418 | printf "DDRCTL3: 0x%08x\n", *(unsigned long *)0xFFC00A2C | |
419 | printf "DDRQUE: 0x%08x\n", *(unsigned long *)0xFFC00A30 | |
420 | printf "ERRADD: " | |
421 | output/a *(unsigned long *)0xFFC00A34 | |
422 | printf "\n" | |
423 | ||
424 | set $$ERRMST = *(unsigned short *)0xFFC00A38 | |
425 | printf "ERRMST: 0x%04x ( ", $$ERRMST | |
426 | if ($$ERRMST & (1 << 7)) | |
427 | printf "core_merror " | |
428 | end | |
429 | if ($$ERRMST & (1 << 6)) | |
430 | printf "deb2_merror " | |
431 | end | |
432 | if ($$ERRMST & (1 << 5)) | |
433 | printf "deb1_merror " | |
434 | end | |
435 | if ($$ERRMST & (1 << 4)) | |
436 | printf "deb0_merror " | |
437 | end | |
438 | if ($$ERRMST & (1 << 3)) | |
439 | printf "core_error " | |
440 | end | |
441 | if ($$ERRMST & (1 << 2)) | |
442 | printf "deb2_error " | |
443 | end | |
444 | if ($$ERRMST & (1 << 1)) | |
445 | printf "deb1_error " | |
446 | end | |
447 | if ($$ERRMST & (1 << 0)) | |
448 | printf "deb0_error " | |
449 | end | |
450 | printf ")\n" | |
451 | ||
452 | set $$RSTCTL = *(unsigned short *)0xFFC00A3C | |
453 | printf "RSTCTL: 0x%04x ( ", $$RSTCTL | |
454 | if ($$RSTCTL & (1 << 4)) | |
455 | printf "srack " | |
456 | end | |
457 | if ($$RSTCTL & (1 << 3)) | |
458 | printf "srreq " | |
459 | end | |
460 | if (!($$RSTCTL & (1 << 1))) | |
461 | printf "!!! ERROR: bit 1 needs to be 1, but it is 0 !!! " | |
462 | end | |
463 | if ($$RSTCTL & (1 << 0)) | |
464 | printf "ddr_sreset " | |
465 | end | |
466 | printf ")\n" | |
467 | end | |
468 | ||
469 | define show_ebiu | |
470 | printf "EBIU_AMGCTL: 0x%04x\n", *(unsigned short *)0xFFC00A00 | |
471 | printf "EBIU_AMBCTL0: 0x%08x\n", *(unsigned long *)0xFFC00A04 | |
472 | printf "EBIU_AMBCTL1: 0x%08x\n", *(unsigned long *)0xFFC00A08 | |
473 | printf "EBIU_MBSCTL: 0x%08x\n", *(unsigned long *)0xFFC00A0C | |
474 | ||
475 | set $$EBIU_ARBSTAT = *(unsigned long *)0xFFC00A10 | |
476 | printf "EBIU_ARBSTAT: 0x%08x ( ", $$EBIU_ARBSTAT | |
477 | if ($$EBIU_ARBSTAT & (1 << 1)) | |
478 | printf "bgstat " | |
479 | end | |
480 | if ($$EBIU_ARBSTAT & (1 << 0)) | |
481 | printf "arbstat " | |
482 | end | |
483 | printf ")\n" | |
484 | ||
485 | printf "EBIU_MODE: 0x%08x\n", *(unsigned long *)0xFFC00A14 | |
486 | printf "EBIU_FCTL: 0x%08x\n", *(unsigned long *)0xFFC00A18 | |
487 | end | |
488 | ||
489 | define _show_cec | |
490 | set $$cec = *(unsigned long *)$arg0 | |
491 | printf "0x%08x: ", $$cec | |
492 | if ($$cec & (1 << 0)) | |
493 | printf "EMU " | |
494 | else | |
495 | printf " " | |
496 | end | |
497 | if ($$cec & (1 << 1)) | |
498 | printf "RST " | |
499 | else | |
500 | printf " " | |
501 | end | |
502 | if ($$cec & (1 << 2)) | |
503 | printf "NMI " | |
504 | else | |
505 | printf " " | |
506 | end | |
507 | if ($$cec & (1 << 3)) | |
508 | printf "EVX " | |
509 | else | |
510 | printf " " | |
511 | end | |
512 | if ($$cec & (1 << 4)) | |
513 | printf "GBL " | |
514 | else | |
515 | printf " " | |
516 | end | |
517 | if ($$cec & (1 << 5)) | |
518 | printf "HW " | |
519 | else | |
520 | printf " " | |
521 | end | |
522 | if ($$cec & (1 << 6)) | |
523 | printf "TMR " | |
524 | else | |
525 | printf " " | |
526 | end | |
527 | set $$ceci = 7 | |
528 | while ($$ceci < 16) | |
529 | if ($$cec & (1 << $$ceci)) | |
530 | printf "G%i ", $$ceci | |
531 | else | |
532 | printf " " | |
533 | if ($$ceci > 9) | |
534 | printf " " | |
535 | end | |
536 | end | |
537 | set $$ceci = $$ceci + 1 | |
538 | end | |
539 | printf "\n" | |
540 | end | |
541 | define show_cec | |
542 | printf "IMASK: " | |
543 | _show_cec 0xFFE02104 | |
544 | printf "IPEND: " | |
545 | _show_cec 0xFFE02108 | |
546 | printf "ILAT: " | |
547 | _show_cec 0xFFE0210C | |
548 | ||
549 | set $$EVT = 0xFFE02000 | |
550 | set $$EVTi = 0 | |
551 | while ($$EVTi < 16) | |
552 | printf "EVT%-2i ", $$EVTi | |
553 | output/a *(unsigned long *)($$EVT + $$EVTi * 4) | |
554 | printf "\n" | |
555 | set $$EVTi = $$EVTi + 1 | |
556 | end | |
557 | end | |
558 | ||
559 | define _show_cplbs | |
560 | set $$addr = $arg0 | |
561 | set $$data = $arg1 | |
562 | set $$i = 0 | |
563 | while ($$i < 16) | |
564 | set $$data_val = *(unsigned long *)($$data + $$i * 4) | |
565 | printf " 0x%08x 0x%08x ( ", *(unsigned long *)($$addr + $$i * 4), $$data_val | |
566 | if (($$data_val & (0x3 << 16)) == (0x0 << 16)) | |
567 | printf "1K " | |
568 | end | |
569 | if (($$data_val & (0x3 << 16)) == (0x1 << 16)) | |
570 | printf "4K " | |
571 | end | |
572 | if (($$data_val & (0x3 << 16)) == (0x2 << 16)) | |
573 | printf "1M " | |
574 | end | |
575 | if (($$data_val & (0x3 << 16)) == (0x3 << 16)) | |
576 | printf "4M " | |
577 | end | |
578 | if ($$data_val & (0x1 << 14)) | |
579 | printf "wt " | |
580 | else | |
581 | printf "wb " | |
582 | end | |
583 | if ($$data_val & (0x1 << 7)) | |
584 | printf "dirty " | |
585 | end | |
586 | if ($$data_val & (0x1 << 4)) | |
587 | printf "supv-wr " | |
588 | end | |
589 | if ($$data_val & (0x1 << 3)) | |
590 | printf "user-wr " | |
591 | end | |
592 | if ($$data_val & (0x1 << 2)) | |
593 | printf "user-rd " | |
594 | end | |
595 | if ($$data_val & (0x1 << 1)) | |
596 | printf "locked " | |
597 | end | |
598 | if ($$data_val & (0x1 << 0)) | |
599 | printf "valid " | |
600 | else | |
601 | printf "invalid " | |
602 | end | |
603 | printf ")\n" | |
604 | set $$i = $$i + 1 | |
605 | end | |
606 | end | |
607 | define show_icplbs | |
608 | set $$IMEM_CONTROL = 0xFFE01004 | |
609 | printf "ICPLBS (0x%08x)\n", *(unsigned long *)$$IMEM_CONTROL | |
610 | _show_cplbs 0xFFE01100 0xFFE01200 | |
611 | end | |
612 | define show_dcplbs | |
613 | set $$DMEM_CONTROL = 0xFFE00004 | |
614 | printf "DCPLBS (0x%08x)\n", *(unsigned long *)$$DMEM_CONTROL | |
615 | _show_cplbs 0xFFE00100 0xFFE00200 | |
616 | end | |
617 | define show_cplbs | |
618 | show_icplbs | |
619 | show_dcplbs | |
620 | end | |
621 | ||
622 | define _show_cplbstatus | |
623 | set $$CPLB_STATUS = *(unsigned long *)$arg0 | |
624 | printf " STATUS = 0x%08x ( ", $$CPLB_STATUS | |
625 | if ($$CPLB_STATUS & (1 << 19)) | |
626 | printf "illaddr " | |
627 | end | |
628 | if ($$CPLB_STATUS & (1 << 18)) | |
629 | printf "dag1 " | |
630 | else | |
631 | printf "dag0 " | |
632 | end | |
633 | if ($$CPLB_STATUS & (1 << 17)) | |
634 | printf "super " | |
635 | else | |
636 | printf "user " | |
637 | end | |
638 | if ($$CPLB_STATUS & (1 << 16)) | |
639 | printf "write " | |
640 | else | |
641 | printf "read " | |
642 | end | |
643 | set $$i = 15 | |
644 | while ($$i >= 0) | |
645 | if ($$CPLB_STATUS & (1 << $$i)) | |
646 | printf "%i ", $$i | |
647 | end | |
648 | set $$i-- | |
649 | end | |
650 | printf ")\n" | |
651 | ||
652 | set $$CPLB_FAULT_ADDR = *(unsigned long *)$arg1 | |
653 | printf " FAULT_ADDR = " | |
654 | output/a $$CPLB_FAULT_ADDR | |
655 | printf "\n" | |
656 | end | |
657 | define show_icplbstatus | |
658 | printf "ICPLB Status\n" | |
659 | _show_cplbstatus 0xFFE01008 0xFFE0100C | |
660 | end | |
661 | define show_dcplbstatus | |
662 | printf "DCPLB Status\n" | |
663 | _show_cplbstatus 0xFFE00008 0xFFE0000C | |
664 | end | |
665 | define show_cplbstatus | |
666 | seqstat | |
667 | show_icplbstatus | |
668 | show_dcplbstatus | |
669 | end | |
670 | ||
671 | define safe_regs | |
672 | set $r0 = $r1 = $r2 = $r3 = $r4 = $r5 = $r6 = $r7 = 0xffb00000 | |
673 | set $sp = $fp = $usp = $r0 + 0x100 | |
674 | set $p0 = $p1 = $p2 = $p3 = $p4 = $p5 = 0xffa00000 | |
675 | set $pc = $rets = $reti = $retx = $retn = $p0 | |
676 | set $lt0 = $lt1 = $lb0 = $lb1 = 1 | |
677 | set $lc0 = $lc1 = 0 | |
678 | set $i0 = $i1 = $i2 = $i3 = $r0 | |
679 | set $b0 = $b1 = $b2 = $b3 = $r0 | |
680 | set $l0 = $l1 = $l2 = $l3 = $r0 | |
681 | set $m0 = $m1 = $m2 = $m3 = $r0 | |
682 | end | |
683 | ||
684 | define _show_dma | |
685 | set $$DMA_BASE = $arg0 | |
686 | set $$NEXT_DESC_PTR = *(unsigned long *) ($$DMA_BASE + 0x00) | |
687 | set $$START_ADDR = *(unsigned long *) ($$DMA_BASE + 0x04) | |
688 | set $$CONFIG = *(unsigned short *) ($$DMA_BASE + 0x08) | |
689 | set $$X_COUNT = *(unsigned short *) ($$DMA_BASE + 0x10) | |
690 | set $$X_MODIFY = *(unsigned short *) ($$DMA_BASE + 0x14) | |
691 | set $$Y_COUNT = *(unsigned short *) ($$DMA_BASE + 0x18) | |
692 | set $$Y_MODIFY = *(unsigned short *) ($$DMA_BASE + 0x1C) | |
693 | set $$CURR_DESC_PTR = *(unsigned long *) ($$DMA_BASE + 0x20) | |
694 | set $$CURR_ADDR = *(unsigned long *) ($$DMA_BASE + 0x24) | |
695 | set $$IRQ_STATUS = *(unsigned short *) ($$DMA_BASE + 0x28) | |
696 | set $$CURR_X_COUNT = *(unsigned short *) ($$DMA_BASE + 0x30) | |
697 | set $$CURR_Y_COUNT = *(unsigned short *) ($$DMA_BASE + 0x38) | |
698 | printf "desc: curr: 0x%08x next: 0x%08x\n", $$CURR_DESC_PTR, $$NEXT_DESC_PTR | |
699 | printf "addr: curr: 0x%08x start: 0x%08x\n", $$CURR_ADDR, $$START_ADDR | |
700 | printf "X: curr: 0x%04x count: 0x%04x mod: 0x%04x (%i)\n", $$CURR_X_COUNT, $$X_COUNT, $$X_MODIFY, (short)$$X_MODIFY | |
701 | printf "Y: curr: 0x%04x count: 0x%04x mod: 0x%04x (%i)\n", $$CURR_Y_COUNT, $$Y_COUNT, $$Y_MODIFY, (short)$$Y_MODIFY | |
702 | printf "dma config: 0x%04x (", $$CONFIG | |
703 | if ($$CONFIG & (1 << 0)) | |
704 | printf "enabled " | |
705 | else | |
706 | printf "disabled " | |
707 | end | |
708 | if ($$CONFIG & (0x1 << 1)) | |
709 | printf "write " | |
710 | else | |
711 | printf "read " | |
712 | end | |
713 | set $$WDSIZE = ($$CONFIG & (0x3 << 2)) >> 2 | |
714 | if ($$WDSIZE == 0x3) | |
715 | printf "WDSIZE:INVALID " | |
716 | end | |
717 | if ($$WDSIZE == 0x2) | |
718 | printf "32-bit " | |
719 | end | |
720 | if ($$WDSIZE == 0x1) | |
721 | printf "16-bit " | |
722 | end | |
723 | if ($$WDSIZE == 0x0) | |
724 | printf "8-bit " | |
725 | end | |
726 | if ($$CONFIG & (0x1 << 4)) | |
727 | printf "2D " | |
728 | else | |
729 | printf "1D " | |
730 | end | |
731 | if ($$CONFIG & (0x1 << 5)) | |
732 | printf "sync " | |
733 | end | |
734 | if ($$CONFIG & (0x1 << 6)) | |
735 | printf "di_sel " | |
736 | end | |
737 | if ($$CONFIG & (0x1 << 7)) | |
738 | printf "interrupt " | |
739 | end | |
740 | set $$NDSIZE = ($$CONFIG & (0xF << 8)) >> 8 | |
741 | if ($$NDSIZE > 0 && $$NDSIZE < 10) | |
742 | printf "NDSIZE_%i ", $$NDSIZE | |
743 | end | |
744 | if ($$NDSIZE >= 10) | |
745 | printf "NDSIZE:INVALID:%i ", $$NDSIZE | |
746 | end | |
747 | set $$FLOW = ($$CONFIG & (0x7 << 12)) >> 12 | |
748 | if ($$FLOW == 0) | |
749 | printf "stop" | |
750 | else | |
751 | if ($$FLOW == 1) | |
752 | printf "autobuffer" | |
753 | else | |
754 | if ($$FLOW == 4) | |
755 | printf "descriptor_array" | |
756 | else | |
757 | if ($$FLOW == 6) | |
758 | printf "descriptor_list_small" | |
759 | else | |
760 | if ($$FLOW == 7) | |
761 | printf "descriptor_list_large" | |
762 | else | |
763 | printf "FLOW:INVALID:%i", $$FLOW | |
764 | end | |
765 | end | |
766 | end | |
767 | end | |
768 | end | |
769 | printf ")\n" | |
770 | printf "irq status: 0x%04x (", $$IRQ_STATUS | |
771 | if ($$IRQ_STATUS & (0x1 << 0)) | |
772 | printf "done " | |
773 | end | |
774 | if ($$IRQ_STATUS & (0x1 << 1)) | |
775 | printf "err " | |
776 | end | |
777 | if ($$IRQ_STATUS & (0x1 << 2)) | |
778 | printf "dfetch " | |
779 | end | |
780 | if ($$IRQ_STATUS & (0x1 << 3)) | |
781 | printf "run " | |
782 | end | |
783 | printf ")\n" | |
784 | end | |
785 | ||
786 | define show_ctimer | |
787 | set $$CTIMER = 0xFFE03000 | |
788 | set $$TCNTL = *(unsigned long *) ($$CTIMER + 0x0) | |
789 | set $$TPERIOD = *(unsigned long *) ($$CTIMER + 0x4) | |
790 | set $$TSCALE = *(unsigned long *) ($$CTIMER + 0x8) | |
791 | set $$TCOUNT = *(unsigned long *) ($$CTIMER + 0xC) | |
792 | printf "TCNTL: %#x ( ", $$TCNTL | |
793 | if ($$TCNTL & (1 << 0)) | |
794 | printf "power " | |
795 | end | |
796 | if ($$TCNTL & (1 << 1)) | |
797 | printf "enable " | |
798 | end | |
799 | if ($$TCNTL & (1 << 2)) | |
800 | printf "autoreload " | |
801 | end | |
802 | if ($$TCNTL & (1 << 3)) | |
803 | printf "int-enabled " | |
804 | end | |
805 | printf ")\n" | |
806 | printf "TPERIOD: %#x\n", $$TPERIOD | |
807 | printf "TSCALE: %#x\n", $$TSCALE | |
808 | printf "TCOUNT: %#x\n", $$TCOUNT | |
809 | end | |
810 | ||
811 | define show_spi | |
812 | if $argc > 0 | |
813 | set $$SPI_BASE = $arg0 | |
814 | else | |
815 | set $$SPI_BASE = 0xFFC00500 | |
816 | end | |
817 | set $$SPI_BAUD = *(unsigned short *) ($$SPI_BASE + 0x14) | |
818 | set $$SPI_CTL = *(unsigned short *) ($$SPI_BASE + 0x00) | |
819 | set $$SPI_FLG = *(unsigned short *) ($$SPI_BASE + 0x04) | |
820 | set $$SPI_STAT = *(unsigned short *) ($$SPI_BASE + 0x08) | |
821 | set $$SPI_TDBR = *(unsigned short *) ($$SPI_BASE + 0x0C) | |
822 | set $$SPI_RDBR = *(unsigned short *) ($$SPI_BASE + 0x10) | |
823 | set $$SPI_SHAD = *(unsigned short *) ($$SPI_BASE + 0x18) | |
824 | printf "BAUD: %04x (%i)\n", $$SPI_BAUD, $$SPI_BAUD | |
825 | printf "CTL: %04x (", $$SPI_CTL | |
826 | set $$TIMOD = $$SPI_CTL & 0x3 | |
827 | printf "timod:%i ", $$TIMOD | |
828 | if ($$SPI_CTL & (1 << 2)) | |
829 | printf "sz " | |
830 | end | |
831 | if ($$SPI_CTL & (1 << 3)) | |
832 | printf "gm " | |
833 | end | |
834 | if ($$SPI_CTL & (1 << 4)) | |
835 | printf "psse " | |
836 | end | |
837 | if ($$SPI_CTL & (1 << 5)) | |
838 | printf "emiso " | |
839 | end | |
840 | if ($$SPI_CTL & (1 << 8)) | |
841 | printf "16bit " | |
842 | else | |
843 | printf "8bit " | |
844 | end | |
845 | if ($$SPI_CTL & (1 << 9)) | |
846 | printf "lsbf " | |
847 | end | |
848 | if ($$SPI_CTL & (1 << 10)) | |
849 | printf "cpol " | |
850 | end | |
851 | if ($$SPI_CTL & (1 << 11)) | |
852 | printf "cpha " | |
853 | end | |
854 | if ($$SPI_CTL & (1 << 12)) | |
855 | printf "mstr " | |
856 | else | |
857 | printf "slave " | |
858 | end | |
859 | if ($$SPI_CTL & (1 << 13)) | |
860 | printf "wom " | |
861 | end | |
862 | if ($$SPI_CTL & (1 << 14)) | |
863 | printf "enabled" | |
864 | else | |
865 | printf "disabled" | |
866 | end | |
867 | printf ")\n" | |
868 | printf "STAT: %04x (", $$SPI_STAT | |
869 | if ($$SPI_STAT & (1 << 0)) | |
870 | printf "spif " | |
871 | end | |
872 | if ($$SPI_STAT & (1 << 1)) | |
873 | printf "modf " | |
874 | end | |
875 | if ($$SPI_STAT & (1 << 2)) | |
876 | printf "txe " | |
877 | end | |
878 | if ($$SPI_STAT & (1 << 3)) | |
879 | printf "txs " | |
880 | end | |
881 | if ($$SPI_STAT & (1 << 4)) | |
882 | printf "rbsy " | |
883 | end | |
884 | if ($$SPI_STAT & (1 << 5)) | |
885 | printf "rxs " | |
886 | end | |
887 | if ($$SPI_STAT & (1 << 6)) | |
888 | printf "txcol " | |
889 | end | |
890 | printf ")\n" | |
891 | printf "FLG: %04x\n", $$SPI_FLG | |
892 | printf "TDBR: %04x RDBR: %04x\n", $$SPI_TDBR, $$SPI_SHAD | |
893 | end | |
894 | ||
895 | define show_uart_lcr | |
896 | set $$LCR = $arg0 | |
897 | printf "LCR: 0x%02x ( ", $$LCR | |
898 | set $$WLS = $$LCR & 0x3 | |
899 | if ($$WLS == 0) | |
900 | printf "5-bit " | |
901 | end | |
902 | if ($$WLS == 1) | |
903 | printf "6-bit " | |
904 | end | |
905 | if ($$WLS == 2) | |
906 | printf "7-bit " | |
907 | end | |
908 | if ($$WLS == 3) | |
909 | printf "8-bit " | |
910 | end | |
911 | if ($$LCR & (1 << 2)) | |
912 | printf "stb " | |
913 | end | |
914 | if ($$LCR & (1 << 3)) | |
915 | printf "pen " | |
916 | end | |
917 | if ($$LCR & (1 << 4)) | |
918 | printf "eps " | |
919 | end | |
920 | if ($$LCR & (1 << 5)) | |
921 | printf "stp " | |
922 | end | |
923 | if ($$LCR & (1 << 6)) | |
924 | printf "sb " | |
925 | end | |
926 | printf ")\n" | |
927 | end | |
928 | ||
929 | define show_uart_lsr | |
930 | set $$LSR = $arg0 | |
931 | printf "LSR: 0x%02x ( ", $$LSR | |
932 | if ($$LSR & (1 << 0)) | |
933 | printf "dr " | |
934 | end | |
935 | if ($$LSR & (1 << 1)) | |
936 | printf "oe " | |
937 | end | |
938 | if ($$LSR & (1 << 2)) | |
939 | printf "pe " | |
940 | end | |
941 | if ($$LSR & (1 << 3)) | |
942 | printf "fe " | |
943 | end | |
944 | if ($$LSR & (1 << 4)) | |
945 | printf "bi " | |
946 | end | |
947 | if ($$LSR & (1 << 5)) | |
948 | printf "thre " | |
949 | end | |
950 | if ($$LSR & (1 << 6)) | |
951 | printf "temt " | |
952 | end | |
953 | if ($$LSR & (1 << 7)) | |
954 | printf "tfi " | |
955 | end | |
956 | printf ")\n" | |
957 | end | |
958 | ||
959 | define show_uart_ier | |
960 | set $$IER = $arg0 | |
961 | printf "IER: 0x%02x ( ", $$IER | |
962 | if ($$IER & (1 << 0)) | |
963 | printf "erbfi " | |
964 | end | |
965 | if ($$IER & (1 << 1)) | |
966 | printf "etbei " | |
967 | end | |
968 | if ($$IER & (1 << 2)) | |
969 | printf "elsi " | |
970 | end | |
971 | if ($$IER & (1 << 3)) | |
972 | printf "edssi " | |
973 | end | |
974 | if ($$IER & (1 << 4)) | |
975 | printf "edtpti " | |
976 | end | |
977 | if ($$IER & (1 << 5)) | |
978 | printf "etfi " | |
979 | end | |
980 | if ($$IER & (1 << 6)) | |
981 | printf "erfci " | |
982 | end | |
983 | printf ")\n" | |
984 | end | |
985 | ||
986 | define show_uart_mcr | |
987 | set $$MCR = $arg0 | |
988 | printf "MCR: 0x%02x ( ", $$MCR | |
989 | if ($$MCR & (1 << 0)) | |
990 | printf "xoff " | |
991 | end | |
992 | if ($$MCR & (1 << 1)) | |
993 | printf "mrts " | |
994 | end | |
995 | if ($$MCR & (1 << 2)) | |
996 | printf "rfit " | |
997 | end | |
998 | if ($$MCR & (1 << 3)) | |
999 | printf "rfrt " | |
1000 | end | |
1001 | if ($$MCR & (1 << 4)) | |
1002 | printf "loop_ena " | |
1003 | end | |
1004 | if ($$MCR & (1 << 5)) | |
1005 | printf "fcpol " | |
1006 | end | |
1007 | if ($$MCR & (1 << 6)) | |
1008 | printf "arts " | |
1009 | end | |
1010 | if ($$MCR & (1 << 7)) | |
1011 | printf "acts " | |
1012 | end | |
1013 | printf ")\n" | |
1014 | end | |
1015 | ||
1016 | define show_uart_msr | |
1017 | set $$MSR = $arg0 | |
1018 | printf "MSR: 0x%02x ( ", $$MSR | |
1019 | if ($$MSR & (1 << 0)) | |
1020 | printf "scts " | |
1021 | end | |
1022 | if ($$MSR & (1 << 4)) | |
1023 | printf "cts " | |
1024 | end | |
1025 | if ($$MSR & (1 << 5)) | |
1026 | printf "rfcs " | |
1027 | end | |
1028 | printf ")\n" | |
1029 | end | |
1030 | ||
1031 | define show_uart_gctl | |
1032 | set $$GCTL = $arg0 | |
1033 | printf "GCTL: 0x%02x ( ", $$GCTL | |
1034 | if ($$GCTL & (1 << 0)) | |
1035 | printf "ucen " | |
1036 | end | |
1037 | if ($$GCTL & (1 << 1)) | |
1038 | printf "iren " | |
1039 | end | |
1040 | if ($$GCTL & (1 << 2)) | |
1041 | printf "tpolc " | |
1042 | end | |
1043 | if ($$GCTL & (1 << 3)) | |
1044 | printf "rpolc " | |
1045 | end | |
1046 | if ($$GCTL & (1 << 4)) | |
1047 | printf "fpe " | |
1048 | end | |
1049 | if ($$GCTL & (1 << 5)) | |
1050 | printf "ffe " | |
1051 | end | |
1052 | if ($$GCTL & (1 << 6)) | |
1053 | printf "edbo " | |
1054 | end | |
1055 | if ($$GCTL & (1 << 7)) | |
1056 | printf "eglsi " | |
1057 | end | |
1058 | printf ")\n" | |
1059 | end | |
1060 | ||
1061 | define show_uart | |
1062 | if $argc > 0 | |
1063 | set $$UART_BASE = $arg0 | |
1064 | else | |
1065 | set $$UART_BASE = 0xffc00400 | |
1066 | end | |
1067 | set $$UART_DLL = (unsigned short *) ($$UART_BASE + 0x00) | |
1068 | set $$UART_RBR = (unsigned short *) ($$UART_BASE + 0x00) | |
1069 | set $$UART_DLH = (unsigned short *) ($$UART_BASE + 0x04) | |
1070 | set $$UART_IER = (unsigned short *) ($$UART_BASE + 0x04) | |
1071 | set $$UART_IIR = (unsigned short *) ($$UART_BASE + 0x08) | |
1072 | set $$UART_LCR = (unsigned short *) ($$UART_BASE + 0x0C) | |
1073 | set $$UART_MCR = (unsigned short *) ($$UART_BASE + 0x10) | |
1074 | set $$UART_LSR = (unsigned short *) ($$UART_BASE + 0x14) | |
1075 | set $$UART_MSR = (unsigned short *) ($$UART_BASE + 0x18) | |
1076 | set $$UART_SCR = (unsigned short *) ($$UART_BASE + 0x1C) | |
1077 | set $$UART_GCTL = (unsigned short *) ($$UART_BASE + 0x24) | |
1078 | ||
1079 | set $$DLAB = (1 << 7) | |
1080 | set $$LCR = *$$UART_LCR | |
1081 | set *$$UART_LCR = ($$LCR | $$DLAB) | |
1082 | printf "DLL: 0x%02x DLH: 0x%02x\n", *$$UART_DLL, *$$UART_DLH | |
1083 | set *$$UART_LCR = $$LCR & ~$$DLAB | |
1084 | printf "RBR: 0x%02x SCR: 0x%02x\n", *$$UART_RBR, *$$UART_SCR | |
1085 | set *$$UART_LCR = $$LCR | |
1086 | ||
1087 | printf "IIR: 0x%02x ", *$$UART_IIR | |
1088 | show_uart_ier *$$UART_IER | |
1089 | show_uart_lcr $$LCR | |
1090 | show_uart_mcr *$$UART_MCR | |
1091 | show_uart_lsr *$$UART_LSR | |
1092 | show_uart_msr *$$UART_MSR | |
1093 | show_uart_gctl *$$UART_GCTL | |
1094 | end | |
1095 | ||
1096 | define show_uart2 | |
1097 | if $argc > 0 | |
1098 | set $$UART_BASE = $arg0 | |
1099 | else | |
1100 | set $$UART_BASE = 0xffc00400 | |
1101 | end | |
1102 | set $$UART_DLL = (unsigned short *) ($$UART_BASE + 0x00) | |
1103 | set $$UART_DLH = (unsigned short *) ($$UART_BASE + 0x04) | |
1104 | set $$UART_GCTL = (unsigned short *) ($$UART_BASE + 0x08) | |
1105 | set $$UART_LCR = (unsigned short *) ($$UART_BASE + 0x0C) | |
1106 | set $$UART_MCR = (unsigned short *) ($$UART_BASE + 0x10) | |
1107 | set $$UART_LSR = (unsigned short *) ($$UART_BASE + 0x14) | |
1108 | set $$UART_MSR = (unsigned short *) ($$UART_BASE + 0x18) | |
1109 | set $$UART_SCR = (unsigned short *) ($$UART_BASE + 0x1C) | |
1110 | set $$UART_IER = (unsigned short *) ($$UART_BASE + 0x20) | |
1111 | set $$UART_RBR = (unsigned short *) ($$UART_BASE + 0x2C) | |
1112 | ||
1113 | printf "DLL: 0x%02x DLH: 0x%02x\n", *$$UART_DLL, *$$UART_DLH | |
1114 | printf "RBR: 0x%02x SCR: 0x%02x\n", *$$UART_RBR, *$$UART_SCR | |
1115 | ||
1116 | printf " " | |
1117 | show_uart_ier *$$UART_IER | |
1118 | show_uart_lcr *$$UART_LCR | |
1119 | show_uart_mcr *$$UART_MCR | |
1120 | show_uart_lsr *$$UART_LSR | |
1121 | show_uart_msr *$$UART_MSR | |
1122 | show_uart_gctl *$$UART_GCTL | |
1123 | end | |
1124 | ||
1125 | define show_uart4 | |
1126 | if $argc > 0 | |
1127 | set $$UART_BASE = $arg0 | |
1128 | else | |
1129 | set $$UART_BASE = 0xffc02000 | |
1130 | end | |
1131 | set $$UART_REVID = (unsigned long *) ($$UART_BASE + 0x00) | |
1132 | set $$UART_CTL = (unsigned long *) ($$UART_BASE + 0x04) | |
1133 | set $$UART_STAT = (unsigned long *) ($$UART_BASE + 0x08) | |
1134 | set $$UART_SCR = (unsigned long *) ($$UART_BASE + 0x0C) | |
1135 | set $$UART_CLK = (unsigned long *) ($$UART_BASE + 0x10) | |
1136 | set $$UART_IMASK = (unsigned long *) ($$UART_BASE + 0x14) | |
1137 | set $$UART_RBR = (unsigned long *) ($$UART_BASE + 0x20) | |
1138 | set $$UART_THR = (unsigned long *) ($$UART_BASE + 0x24) | |
1139 | set $$UART_TAIP = (unsigned long *) ($$UART_BASE + 0x28) | |
1140 | set $$UART_TSR = (unsigned long *) ($$UART_BASE + 0x2C) | |
1141 | set $$UART_RSR = (unsigned long *) ($$UART_BASE + 0x30) | |
1142 | set $$UART_TXCNT = (unsigned long *) ($$UART_BASE + 0x34) | |
1143 | set $$UART_RXCNT = (unsigned long *) ($$UART_BASE + 0x38) | |
1144 | ||
1145 | printf "REVID: 0x%08x SCR: 0x%08x\n", *$$UART_REVID, *$$UART_SCR | |
1146 | printf " CLK: 0x%08x TAIP: 0x%08x\n", *$$UART_CLK, *$$UART_TAIP | |
1147 | ||
1148 | set $$CTL = *$$UART_CTL | |
1149 | printf " CTL: 0x%08x ( ", $$CTL | |
1150 | if ($$CTL & (1 << 0)) | |
1151 | printf "uen " | |
1152 | end | |
1153 | if ($$CTL & (1 << 1)) | |
1154 | printf "loop_ena " | |
1155 | end | |
1156 | set $$UMOD = ($$CTL & (3 << 4)) >> 4 | |
1157 | printf "mode:" | |
1158 | if ($$UMOD == 0) | |
1159 | printf "uart " | |
1160 | end | |
1161 | if ($$UMOD == 1) | |
1162 | printf "mdb " | |
1163 | end | |
1164 | if ($$UMOD == 2) | |
1165 | printf "irda " | |
1166 | end | |
1167 | if ($$UMOD == 3) | |
1168 | printf "reserved " | |
1169 | end | |
1170 | set $$WLS = ($$CTL & (3 << 8)) >> 8 | |
1171 | printf "wls:" | |
1172 | if ($$WLS == 0) | |
1173 | printf "5" | |
1174 | end | |
1175 | if ($$WLS == 1) | |
1176 | printf "6 " | |
1177 | end | |
1178 | if ($$WLS == 2) | |
1179 | printf "7 " | |
1180 | end | |
1181 | if ($$WLS == 3) | |
1182 | printf "8 " | |
1183 | end | |
1184 | if ($$CTL & (1 << 12)) | |
1185 | printf "stb " | |
1186 | end | |
1187 | if ($$CTL & (1 << 13)) | |
1188 | printf "stbh " | |
1189 | end | |
1190 | if ($$CTL & (1 << 14)) | |
1191 | printf "pen " | |
1192 | end | |
1193 | if ($$CTL & (1 << 15)) | |
1194 | printf "eps " | |
1195 | end | |
1196 | if ($$CTL & (1 << 16)) | |
1197 | printf "stp " | |
1198 | end | |
1199 | if ($$CTL & (1 << 17)) | |
1200 | printf "fpe " | |
1201 | end | |
1202 | if ($$CTL & (1 << 18)) | |
1203 | printf "ffe " | |
1204 | end | |
1205 | if ($$CTL & (1 << 19)) | |
1206 | printf "sb " | |
1207 | end | |
1208 | if ($$CTL & (1 << 22)) | |
1209 | printf "fcpol " | |
1210 | end | |
1211 | if ($$CTL & (1 << 23)) | |
1212 | printf "rpolc " | |
1213 | end | |
1214 | if ($$CTL & (1 << 24)) | |
1215 | printf "tpolc " | |
1216 | end | |
1217 | if ($$CTL & (1 << 25)) | |
1218 | printf "mrts " | |
1219 | end | |
1220 | if ($$CTL & (1 << 26)) | |
1221 | printf "xoff " | |
1222 | end | |
1223 | if ($$CTL & (1 << 27)) | |
1224 | printf "arts " | |
1225 | end | |
1226 | if ($$CTL & (1 << 28)) | |
1227 | printf "acts " | |
1228 | end | |
1229 | if ($$CTL & (1 << 29)) | |
1230 | printf "rfit " | |
1231 | end | |
1232 | if ($$CTL & (1 << 30)) | |
1233 | printf "rfrt " | |
1234 | end | |
1235 | printf ")\n" | |
1236 | ||
1237 | set $$STAT = *$$UART_STAT | |
1238 | printf " STAT: 0x%08x ( ", $$STAT | |
1239 | if ($$STAT & (1 << 0)) | |
1240 | printf "dr " | |
1241 | end | |
1242 | if ($$STAT & (1 << 1)) | |
1243 | printf "oe " | |
1244 | end | |
1245 | if ($$STAT & (1 << 2)) | |
1246 | printf "pe " | |
1247 | end | |
1248 | if ($$STAT & (1 << 3)) | |
1249 | printf "fe " | |
1250 | end | |
1251 | if ($$STAT & (1 << 4)) | |
1252 | printf "bi " | |
1253 | end | |
1254 | if ($$STAT & (1 << 5)) | |
1255 | printf "thre " | |
1256 | end | |
1257 | if ($$STAT & (1 << 7)) | |
1258 | printf "temt " | |
1259 | end | |
1260 | if ($$STAT & (1 << 8)) | |
1261 | printf "tfi " | |
1262 | end | |
1263 | if ($$STAT & (1 << 9)) | |
1264 | printf "astky " | |
1265 | end | |
1266 | if ($$STAT & (1 << 10)) | |
1267 | printf "addr " | |
1268 | end | |
1269 | if ($$STAT & (1 << 11)) | |
1270 | printf "ro " | |
1271 | end | |
1272 | if ($$STAT & (1 << 12)) | |
1273 | printf "scts " | |
1274 | end | |
1275 | if ($$STAT & (1 << 16)) | |
1276 | printf "cts " | |
1277 | end | |
1278 | if ($$STAT & (1 << 17)) | |
1279 | printf "rfcs " | |
1280 | end | |
1281 | printf ")\n" | |
1282 | ||
1283 | printf "IMASK: 0x%08x\n", *$$UART_IMASK | |
1284 | printf " RSR: 0x%04x TSR: 0x%04x\n", *$$UART_RSR, *$$UART_TSR | |
1285 | printf " RBR: 0x%02x THR: 0x%02x\n", *$$UART_RBR, *$$UART_THR | |
1286 | printf "RXCNT: 0x%02x TXCNT: 0x%02x\n", *$$UART_RXCNT, *$$UART_TXCNT | |
1287 | end | |
1288 | ||
1289 | define _otp_save | |
1290 | set $$s_pc = $pc | |
1291 | set $$s_r0 = $r0 | |
1292 | set $$s_r1 = $r1 | |
1293 | set $$s_r2 = $r2 | |
1294 | set $$s_mm = (unsigned long *)0xFFB00000 | |
1295 | set $$s_m0 = $$s_mm[0] | |
1296 | set $$s_m1 = $$s_mm[1] | |
1297 | end | |
1298 | define _otp_restore | |
1299 | set $pc = $$s_pc | |
1300 | set $r0 = $$s_r0 | |
1301 | set $r1 = $$s_r1 | |
1302 | set $r2 = $$s_r2 | |
1303 | set $$s_mm[0] = $$s_m0 | |
1304 | set $$s_mm[1] = $$s_m1 | |
1305 | end | |
1306 | ||
1307 | define _otp_read | |
1308 | set $pc = 0xef00001a | |
1309 | set $r0 = $arg0 | |
1310 | set $r1 = $arg1 | |
1311 | set $r2 = 0xFFB00000 | |
1312 | ||
1313 | end | |
1314 | define otp_read | |
1315 | if $argc == 0 | |
1316 | set $$OTP_PAGE = 0 | |
1317 | else | |
1318 | set $$OTP_PAGE = $arg0 | |
1319 | end | |
1320 | ||
1321 | printf "OTP Page 0x%02x: ", $$OTP_PAGE | |
1322 | _otp_save | |
1323 | _otp_read $$OTP_PAGE, 0 | |
1324 | _otp_read $$OTP_PAGE, 1 | |
1325 | _otp_restore | |
1326 | end | |
1327 | ||
1328 | define otp_dump | |
1329 | _otp_save | |
1330 | set $$page = 0 | |
1331 | while $$page < 0xe0 | |
1332 | printf "0x%02x: ", $$page | |
1333 | _otp_read $$page, 0 | |
1334 | printf "%08x %08x ", $$OTP_PAGE_L, $$OTP_PAGE_H | |
1335 | _otp_read $$page, 1 | |
1336 | printf "%08x %08x ", $$OTP_PAGE_L, $$OTP_PAGE_H | |
1337 | $$page++ | |
1338 | end | |
1339 | _otp_restore | |
1340 | end | |
1341 | ||
1342 | ||
1343 | # | |
1344 | # Provide U-Boot-style functions in gdb | |
1345 | # | |
1346 | ||
1347 | define uboot_jtag_load | |
1348 | set remotetimeout 300 | |
1349 | load init.elf | |
1350 | continue | |
1351 | load u-boot | |
1352 | call memset(&_bss_vma, 0, &_bss_len) | |
1353 | continue | |
1354 | end | |
1355 | ||
1356 | ||
1357 | # | |
1358 | # U-Boot style memory display functions | |
1359 | # | |
1360 | ||
1361 | define md | |
1362 | if $argc == 2 | |
1363 | x/64x$arg0 $arg1 | |
1364 | else | |
1365 | if $argc == 3 | |
1366 | x/$arg2x$arg0 $arg1 | |
1367 | else | |
1368 | help md | |
1369 | end | |
1370 | end | |
1371 | end | |
1372 | document md | |
1373 | Usage: md <unit type> <address> [count=64] | |
1374 | Display [count] <unit type> starting at <address>. | |
1375 | end | |
1376 | ||
1377 | define _md | |
1378 | # dummy func for "document" to work | |
1379 | end | |
1380 | document _md | |
1381 | Usage: md[cbwl] <address> [count=64] | |
1382 | Display [count] <chars|bytes|words|longs> starting at <address>. | |
1383 | end | |
1384 | ||
1385 | define mdb | |
1386 | if $argc == 1 | |
1387 | md b $arg0 | |
1388 | else | |
1389 | if $argc == 2 | |
1390 | md b $arg0 $arg1 | |
1391 | else | |
1392 | help _md | |
1393 | end | |
1394 | end | |
1395 | end | |
1396 | document mdb | |
1397 | Use 'help _md' | |
1398 | end | |
1399 | define mdw | |
1400 | if $argc == 1 | |
1401 | md h $arg0 | |
1402 | else | |
1403 | if $argc == 2 | |
1404 | md h $arg0 $arg1 | |
1405 | else | |
1406 | help _md | |
1407 | end | |
1408 | end | |
1409 | end | |
1410 | document mdw | |
1411 | Use 'help _md' | |
1412 | end | |
1413 | define mdl | |
1414 | if $argc == 1 | |
1415 | md w $arg0 | |
1416 | else | |
1417 | if $argc == 2 | |
1418 | md w $arg0 $arg1 | |
1419 | else | |
1420 | help _md | |
1421 | end | |
1422 | end | |
1423 | end | |
1424 | document mdl | |
1425 | Use 'help _md' | |
1426 | end | |
1427 | define mdq | |
1428 | if $argc == 1 | |
1429 | md g $arg0 | |
1430 | else | |
1431 | if $argc == 2 | |
1432 | md g $arg0 $arg1 | |
1433 | else | |
1434 | help _md | |
1435 | end | |
1436 | end | |
1437 | end | |
1438 | document mdq | |
1439 | Use 'help _md' | |
1440 | end | |
1441 | define mdc | |
1442 | set output-radix 10 | |
1443 | if $argc == 1 | |
1444 | md c $arg0 | |
1445 | else | |
1446 | if $argc == 2 | |
1447 | md c $arg0 $arg1 | |
1448 | else | |
1449 | help _md | |
1450 | end | |
1451 | end | |
1452 | set output-radix 16 | |
1453 | end | |
1454 | document mdc | |
1455 | Use 'help _md' | |
1456 | end | |
1457 | ||
1458 | ||
1459 | # | |
1460 | # U-Boot style memory modify functions | |
1461 | # | |
1462 | ||
1463 | define _mw | |
1464 | set $$addr = $arg0 | |
1465 | set $$val = $arg1 | |
1466 | set $$count = $arg2 | |
1467 | while $$count-- > 0 | |
1468 | set *$$addr = $$val | |
1469 | set $$addr += 1 | |
1470 | end | |
1471 | dont-repeat | |
1472 | end | |
1473 | document _mw | |
1474 | Usage: mw[bwl] <address> <value> <count> | |
1475 | Set <count> <bytes|words|longs> at <address> to <value>. | |
1476 | end | |
1477 | ||
1478 | define mwl | |
1479 | if $argc == 3 | |
1480 | set $$addr = (unsigned long *)$arg0 | |
1481 | _mw $$addr $arg1 $arg2 | |
1482 | else | |
1483 | help _mw | |
1484 | end | |
1485 | end | |
1486 | document mwl | |
1487 | Use 'help _mw' | |
1488 | end | |
1489 | define mww | |
1490 | if $argc == 3 | |
1491 | set $$addr = (unsigned short *)$arg0 | |
1492 | _mw $$addr $arg1 $arg2 | |
1493 | else | |
1494 | help _mw | |
1495 | end | |
1496 | end | |
1497 | document mww | |
1498 | Use 'help _mw' | |
1499 | end | |
1500 | define mwb | |
1501 | if $argc == 3 | |
1502 | set $$addr = (unsigned char *)$arg0 | |
1503 | _mw $$addr $arg1 $arg2 | |
1504 | else | |
1505 | help _mw | |
1506 | end | |
1507 | end | |
1508 | document mwb | |
1509 | Use 'help _mw' | |
1510 | end | |
1511 | ||
1512 | ||
1513 | # | |
1514 | # U-Boot style memory compare functions | |
1515 | # | |
1516 | ||
1517 | define _cmp | |
1518 | set $$base = (unsigned long)$arg0 | |
1519 | set $$addr1 = $arg0 | |
1520 | set $$addr2 = $arg1 | |
1521 | set $$count = $arg2 | |
1522 | while $$count-- > 0 | |
1523 | if (*$$addr1 != *$$addr2) | |
1524 | printf "Data mismatch at %#x units (@%#x != @%#x)\n", $arg2, $$addr1, $$addr2 | |
1525 | set $$count = -100 | |
1526 | end | |
1527 | set $$addr1 += 1 | |
1528 | set $$addr2 += 1 | |
1529 | end | |
1530 | if $$count == -1 | |
1531 | printf "Data matches for %#x units\n", $arg2 | |
1532 | end | |
1533 | dont-repeat | |
1534 | end | |
1535 | document _cmp | |
1536 | Usage: cmp[bwl] <address> <address> <count> | |
1537 | Compare <count> <bytes|words|longs> between <address> and <address>. | |
1538 | end | |
1539 | ||
1540 | define cmpb | |
1541 | if $argc == 3 | |
1542 | set $$addr1 = (unsigned char *)$arg0 | |
1543 | set $$addr2 = (unsigned char *)$arg1 | |
1544 | _cmp $$addr1 $$addr2 $arg2 | |
1545 | else | |
1546 | help _cmp | |
1547 | end | |
1548 | end | |
1549 | document cmpb | |
1550 | Use 'help _cmp' | |
1551 | end | |
1552 | define cmpw | |
1553 | if $argc == 3 | |
1554 | set $$addr1 = (unsigned short *)$arg0 | |
1555 | set $$addr2 = (unsigned short *)$arg1 | |
1556 | _cmp $$addr1 $$addr2 $arg2 | |
1557 | else | |
1558 | help _cmp | |
1559 | end | |
1560 | end | |
1561 | document cmpw | |
1562 | Use 'help _cmp' | |
1563 | end | |
1564 | define cmpl | |
1565 | if $argc == 3 | |
1566 | set $$addr1 = (unsigned long *)$arg0 | |
1567 | set $$addr2 = (unsigned long *)$arg1 | |
1568 | _cmp $$addr1 $$addr2 $arg2 | |
1569 | else | |
1570 | help _cmp | |
1571 | end | |
1572 | end | |
1573 | document cmpl | |
1574 | Use 'help _cmp' | |
1575 | end | |
1576 | ||
1577 | ||
1578 | # | |
1579 | # U-Boot style memory copy functions | |
1580 | # | |
1581 | ||
1582 | define _cp | |
1583 | set $$src = $arg0 | |
1584 | set $$dst = $arg1 | |
1585 | set $$count = $arg2 | |
1586 | while $$count-- > 0 | |
1587 | set *$$dst = *$$src | |
1588 | set $$src += 1 | |
1589 | set $$dst += 1 | |
1590 | end | |
1591 | printf "Copied %#x units from %#x to %#x\n", $arg2, $arg0, $arg1 | |
1592 | dont-repeat | |
1593 | end | |
1594 | document _cp | |
1595 | Usage: cp[bwl] <src> <dst> <count> | |
1596 | Copy <count> <bytes|words|longs> from <src> to <dst>. | |
1597 | end | |
1598 | ||
1599 | define cpb | |
1600 | if $argc == 3 | |
1601 | set $$addr1 = (unsigned char *)$arg0 | |
1602 | set $$addr2 = (unsigned char *)$arg1 | |
1603 | _cp $$addr1 $$addr2 $arg2 | |
1604 | else | |
1605 | help _cp | |
1606 | end | |
1607 | end | |
1608 | document cpb | |
1609 | Use 'help _cp' | |
1610 | end | |
1611 | define cpw | |
1612 | if $argc == 3 | |
1613 | set $$addr1 = (unsigned short *)$arg0 | |
1614 | set $$addr2 = (unsigned short *)$arg1 | |
1615 | _cp $$addr1 $$addr2 $arg2 | |
1616 | else | |
1617 | help _cp | |
1618 | end | |
1619 | end | |
1620 | document cpw | |
1621 | Use 'help _cp' | |
1622 | end | |
1623 | define cpl | |
1624 | if $argc == 3 | |
1625 | set $$addr1 = (unsigned long *)$arg0 | |
1626 | set $$addr2 = (unsigned long *)$arg1 | |
1627 | _cp $$addr1 $$addr2 $arg2 | |
1628 | else | |
1629 | help _cp | |
1630 | end | |
1631 | end | |
1632 | document cpl | |
1633 | Use 'help _cp' | |
1634 | end | |
1635 | ||
1636 | ||
1637 | #set extended-prompt \[\e[30;1m\](\[\e[34;1m\]gdb\[\e[30;1m\])\[\e[0m\] |