OSDN Git Service

2013.10.24
[uclinux-h8/uClinux-dist.git] / tools / misc / ng5100.gdb
1 #
2 #       CyberGuard/SE5100 (aka ATT/NG5100) target gdbinit script.
3 #
4
5 #
6 #       UART functions
7 #
8
9 define uart-init
10 set *((long*) 0xc800000c) = 0x83
11 set *((long*) 0xc8000000) = 0x08
12 set *((long*) 0xc8000004) = 0x00
13 set *((long*) 0xc800000c) = 0x03
14 set *((long*) 0xc8000004) = 0x40
15 end
16
17 define uart-print
18 set *((long*) 0xc8000000) = $arg0
19 end
20
21
22 #
23 #       Memory functions
24 #
25
26 define mem-init
27 # set for 64MB (3CAS, 3RAS)
28 set *((long*) 0xcc000000) = 0x1a
29
30 # disable refresh
31 set *((long*) 0xcc000004) = 0
32
33 # send NOP command
34 set *((long*) 0xcc000008) = 0x03
35 shell sleep 1
36
37 # set refresh count
38 set *((long*) 0xcc000004) = 0x384
39 shell sleep 1
40
41 # send PRECHARGE-ALL command
42 set *((long*) 0xcc000008) = 0x02
43 shell sleep 1
44
45 # send AUTO-REFRESH command
46 set $num = 8
47 while ($num > 0)
48         set *((long*) 0xcc000008) = 0x04
49         shell sleep 1
50         set $num = $num - 1
51 end
52
53 # send MODE (CAS3) command
54 set *((long*) 0xcc000008) = 0x01
55 shell sleep 1
56
57 # send NORMAL-OPERATION command
58 set *((long*) 0xcc000008) = 0x06
59 shell sleep 1
60
61 end
62
63
64
65 #
66 #       Switch memory and expansion regions
67 #
68 define mem-switch
69 set *((unsigned long *) 0x10000000) = 0xe3a01331
70 set *((unsigned long *) 0x10000004) = 0xe3811020
71 set *((unsigned long *) 0x10000008) = 0xe5912000
72 set *((unsigned long *) 0x1000000c) = 0xe3c22102
73 set *((unsigned long *) 0x10000010) = 0xe5812000
74 set $pc = 0x10000000
75 stepi 5
76 end
77
78
79 define mem-fill
80 set $num = 0
81 set $addr = $arg0
82 set $val = $arg1
83 while ($num < 0x1000)
84         set *((unsigned long *) $addr) = $val
85         set $addr = $addr + 4
86         set $num = $num + 1
87 end
88 end
89
90
91 define mem-check
92 set $num = 0
93 set $addr = $arg0
94 set $val = $arg1
95 while ($num < 0x1000)
96         set $rd = *((unsigned long *) $addr)
97         if ($rd != $val)
98                 print $addr
99         end
100         set $addr = $addr + 4
101         set $num = $num + 1
102 end
103 end
104
105
106 #
107 #       Set BIG endian mode
108 #
109 define big
110 set *((unsigned long *) 0x10000000) = 0xee110f10
111 set *((unsigned long *) 0x10000004) = 0xe3800080
112 set *((unsigned long *) 0x10000008) = 0xee010f10
113 set *((unsigned long *) 0x1000000c) = 0xee120f10
114 set *((unsigned long *) 0x10000010) = 0xe1a00000
115 set *((unsigned long *) 0x10000010) = 0xe24ff004
116 set $pc = 0x10000000
117 stepi 6
118 end
119
120 #
121 #       Enable the caches.
122 #
123 define cache
124 set *((unsigned long *) 0x10000000) = 0xee110f10
125 set *((unsigned long *) 0x10000004) = 0xe3800a01
126 set *((unsigned long *) 0x10000008) = 0xe380000c
127 set *((unsigned long *) 0x1000000c) = 0xee010f10
128 set *((unsigned long *) 0x10000010) = 0xee120f10
129 set *((unsigned long *) 0x10000014) = 0xe1a00000
130 set *((unsigned long *) 0x10000018) = 0xe24ff004
131 set *((unsigned long *) 0x1000001c) = 0xee071f15
132 set *((unsigned long *) 0x10000020) = 0xee120f10
133 set *((unsigned long *) 0x10000024) = 0xe1a00000
134 set *((unsigned long *) 0x10000028) = 0xe24ff004
135 set $pc = 0x10000000
136 stepi 0xb
137 end
138
139 #
140 #       Enable the PCI clock (which is on GPIO14)
141 #
142 define pci-clock
143 set *((unsigned long *) 0xc8004004) = 0x00003fff
144 set *((unsigned long *) 0xc8004018) = 0x000001ff
145 set *((unsigned long *) 0xc8004000) = 0x00004000
146 end
147
148 #
149 #       Configure the flash region to be writable.
150 #
151 define writable
152 set *((unsigned long *) 0x10000000) = 0xe3a01331
153 set *((unsigned long *) 0x10000004) = 0xe5912000
154 set *((unsigned long *) 0x10000008) = 0xe3822002
155 set *((unsigned long *) 0x1000000c) = 0xe5812000
156 set $pc = 0x10000000
157 stepi 4
158 end
159
160 #
161 #       Initialize the LEDs
162 #
163 define set-led
164 set *((unsigned long *) 0x10000000) = 0xe59f1004
165 set *((unsigned long *) 0x10000004) = 0xe59f2004
166 set *((unsigned long *) 0x10000008) = 0xe5812000
167 set *((unsigned long *) 0x1000000c) = 0xc4000008
168 set *((unsigned long *) 0x10000010) = 0xbfff0003
169 set $pc = 0x10000000
170 stepi 3
171 set *((unsigned char *) 0x52000000) = $arg0
172 end
173
174 #
175 #       FLASH writing code (16bit functions)
176 #
177 define flash-erase
178 set $r1 = $arg0
179 set *((unsigned long *) 0x10000004) = 0xe3a02020
180 set *((unsigned long *) 0x10000008) = 0xe3822a02
181 set *((unsigned long *) 0x1000000c) = 0xe1c120b0
182 set *((unsigned long *) 0x10000010) = 0xe3a020d0
183 set *((unsigned long *) 0x10000014) = 0xe3822a0d
184 set *((unsigned long *) 0x10000018) = 0xe1c120b0
185 set $pc = 0x10000004
186 stepi 6
187 shell sleep 2
188 set *((unsigned long *) 0x10000000) = 0xe3a020ff
189 set *((unsigned long *) 0x10000004) = 0xe3822cff
190 set *((unsigned long *) 0x10000008) = 0xe1c120b0
191 set $pc = 0x10000000
192 stepi 3
193 end
194
195 define flash-erase1
196 set *((unsigned long *) 0x10000000) = 0xe3a01205
197 set *((unsigned long *) 0x10000004) = 0xe3a02020
198 set *((unsigned long *) 0x10000008) = 0xe3822a02
199 set *((unsigned long *) 0x1000000c) = 0xe1c120b0
200 set *((unsigned long *) 0x10000010) = 0xe3a020d0
201 set *((unsigned long *) 0x10000014) = 0xe3822a0d
202 set *((unsigned long *) 0x10000018) = 0xe1c120b0
203 set $pc = 0x10000000
204 stepi 7
205 shell sleep 2
206 set *((unsigned long *) 0x10000000) = 0xe3a020ff
207 set *((unsigned long *) 0x10000004) = 0xe3822cff
208 set *((unsigned long *) 0x10000008) = 0xe1c120b0
209 set $pc = 0x10000000
210 stepi 3
211 end
212
213 define flash-erase2
214 set *((unsigned long *) 0x10000000) = 0xe3a01205
215 set *((unsigned long *) 0x10000004) = 0xe3811802
216 set *((unsigned long *) 0x10000008) = 0xe3a02020
217 set *((unsigned long *) 0x1000000c) = 0xe3822a02
218 set *((unsigned long *) 0x10000010) = 0xe1c120b0
219 set *((unsigned long *) 0x10000014) = 0xe3a020d0
220 set *((unsigned long *) 0x10000018) = 0xe3822a0d
221 set *((unsigned long *) 0x1000001c) = 0xe1c120b0
222 set $pc = 0x10000000
223 stepi 8
224 shell sleep 2
225 set *((unsigned long *) 0x10000000) = 0xe3a020ff
226 set *((unsigned long *) 0x10000004) = 0xe3822cff
227 set *((unsigned long *) 0x10000008) = 0xe1c120b0
228 set $pc = 0x10000000
229 stepi 3
230 end
231
232 define flash-unlock
233 set $r1 = $arg0
234 set *((unsigned long *) 0x10000004) = 0xe3a02060
235 set *((unsigned long *) 0x10000008) = 0xe3822a06
236 set *((unsigned long *) 0x1000000c) = 0xe1c120b0
237 set *((unsigned long *) 0x10000010) = 0xe3a020d0
238 set *((unsigned long *) 0x10000014) = 0xe3822a0d
239 set *((unsigned long *) 0x10000018) = 0xe1c120b0
240 set *((unsigned long *) 0x1000001c) = 0xe3a020ff
241 set *((unsigned long *) 0x10000020) = 0xe3822cff
242 set *((unsigned long *) 0x10000024) = 0xe1c120b0
243 set $pc = 0x10000004
244 stepi 9
245 end
246
247 define flash-unlock1
248 set *((unsigned long *) 0x10000000) = 0xe3a01205
249 set *((unsigned long *) 0x10000004) = 0xe3a02060
250 set *((unsigned long *) 0x10000008) = 0xe3822a06
251 set *((unsigned long *) 0x1000000c) = 0xe1c120b0
252 set *((unsigned long *) 0x10000010) = 0xe3a020d0
253 set *((unsigned long *) 0x10000014) = 0xe3822a0d
254 set *((unsigned long *) 0x10000018) = 0xe1c120b0
255 set *((unsigned long *) 0x1000001c) = 0xe3a020ff
256 set *((unsigned long *) 0x10000020) = 0xe3822cff
257 set *((unsigned long *) 0x10000024) = 0xe1c120b0
258 set $pc = 0x10000000
259 stepi 10
260 end
261
262 define flash-unlock2
263 set *((unsigned long *) 0x10000000) = 0xe3a01205
264 set *((unsigned long *) 0x10000004) = 0xe3811802
265 set *((unsigned long *) 0x10000008) = 0xe3a02060
266 set *((unsigned long *) 0x1000000c) = 0xe3822a06
267 set *((unsigned long *) 0x10000010) = 0xe1c120b0
268 set *((unsigned long *) 0x10000014) = 0xe3a020d0
269 set *((unsigned long *) 0x10000018) = 0xe3822a0d
270 set *((unsigned long *) 0x1000001c) = 0xe1c120b0
271 set *((unsigned long *) 0x10000020) = 0xe3a020ff
272 set *((unsigned long *) 0x10000024) = 0xe3822cff
273 set *((unsigned long *) 0x10000028) = 0xe1c120b0
274 set $pc = 0x10000000
275 stepi 11
276 end
277
278 define flash-id
279 set *((unsigned long *) 0x10000000) = 0xe3a01205
280 set *((unsigned long *) 0x10000004) = 0xe3a02090
281 set *((unsigned long *) 0x10000008) = 0xe3822a09
282 set *((unsigned long *) 0x1000000c) = 0xe1c120b0
283 set $pc = 0x10000000
284 stepi 4
285 end
286
287 define flash-program
288 set *((unsigned long *) 0x10100000) = 0xe3a01205
289 set *((unsigned long *) 0x10100004) = 0xe3a02040
290 set *((unsigned long *) 0x10100008) = 0xe3822901
291 set *((unsigned long *) 0x1010000c) = 0xe3a03080
292 set *((unsigned long *) 0x10100010) = 0xe3a040ff
293 set *((unsigned long *) 0x10100014) = 0xe3844cff
294 set *((unsigned long *) 0x10100018) = 0xe3a05000
295 set *((unsigned long *) 0x1010001c) = 0xe3a06701
296 set *((unsigned long *) 0x10100020) = 0xe1c120b0
297 set *((unsigned long *) 0x10100024) = 0xe1d570b0
298 set *((unsigned long *) 0x10100028) = 0xe1c170b0
299 set *((unsigned long *) 0x1010002c) = 0xe1d170b0
300 set *((unsigned long *) 0x10100030) = 0xe1170003
301 set *((unsigned long *) 0x10100034) = 0x0afffffc
302 set *((unsigned long *) 0x10100038) = 0xe1c140b0
303 set *((unsigned long *) 0x1010003c) = 0xe2811002
304 set *((unsigned long *) 0x10100040) = 0xe2855002
305 set *((unsigned long *) 0x10100044) = 0xe1550006
306 set *((unsigned long *) 0x10100048) = 0x1afffff4
307 set *((unsigned long *) 0x1010004c) = 0xe1a00000
308 set *((unsigned long *) 0x10100050) = 0xe1a00000
309 set *((unsigned long *) 0x10100054) = 0xeafffffe
310 set $pc = 0x10100000
311 end
312
313 define flash-ready-to-write
314 flash-unlock 0x50000000
315 flash-erase  0x50000000
316 flash-unlock 0x50008000
317 flash-erase  0x50008000
318 flash-unlock 0x50010000
319 flash-erase  0x50010000
320 flash-unlock 0x50018000
321 flash-erase  0x50018000
322 flash-unlock 0x50020000
323 flash-erase  0x50020000
324 flash-unlock 0x50028000
325 flash-erase  0x50028000
326 flash-unlock 0x50030000
327 flash-erase  0x50030000
328 flash-unlock 0x50038000
329 flash-erase  0x50038000
330 end
331
332 define flash-redboot
333 mem-init
334 mem-switch
335 writable
336 flash-unlock
337 flash-erase1
338 flash-unlock2
339 flash-erase2
340 load boot/redboot/images/redboot-swap.elf
341 flash-program
342 c
343 end
344
345 define flash-boot
346 mem-init
347 mem-switch
348 writable
349 # flash-unlock1
350 # flash-erase1
351 # flash-unlock2
352 # flash-erase2
353 flash-ready-to-write
354 load boot/boot-swap.elf
355 mem-setmac
356 flash-program
357 c
358 end
359
360 #
361 #       FLASH writing code (8bit functions)
362 #
363 define flash8-erase1
364 set *((unsigned long *) 0x10000000) = 0xe3a01205
365 set *((unsigned long *) 0x10000004) = 0xe3a02020
366 set *((unsigned long *) 0x10000008) = 0xe5c12000
367 set *((unsigned long *) 0x1000000c) = 0xe3a020d0
368 set *((unsigned long *) 0x10000010) = 0xe5c12000
369 set $pc = 0x10000000
370 stepi 5
371 shell sleep 2
372 set *((unsigned long *) 0x10000000) = 0xe3a020ff
373 set *((unsigned long *) 0x10000004) = 0xe5c12000
374 set $pc = 0x10000000
375 stepi 2
376 end
377
378 define flash8-erase2
379 set *((unsigned long *) 0x10000000) = 0xe3a01205
380 set *((unsigned long *) 0x10000004) = 0xe3811802
381 set *((unsigned long *) 0x10000008) = 0xe3a02020
382 set *((unsigned long *) 0x1000000c) = 0xe5c12000
383 set *((unsigned long *) 0x10000010) = 0xe3a020d0
384 set *((unsigned long *) 0x10000014) = 0xe5c12000
385 set $pc = 0x10000000
386 stepi 6
387 shell sleep 2
388 set *((unsigned long *) 0x10000000) = 0xe3a020ff
389 set *((unsigned long *) 0x10000004) = 0xe5c12000
390 set $pc = 0x10000000
391 stepi 2
392 end
393
394 define flash8-unlock1
395 set *((unsigned long *) 0x10000000) = 0xe3a01205
396 set *((unsigned long *) 0x10000004) = 0xe3a02060
397 set *((unsigned long *) 0x10000008) = 0xe5c12000
398 set *((unsigned long *) 0x1000000c) = 0xe3a020d0
399 set *((unsigned long *) 0x10000010) = 0xe5c12000
400 set *((unsigned long *) 0x10000014) = 0xe3a020ff
401 set *((unsigned long *) 0x10000018) = 0xe5c12000
402 set $pc = 0x10000000
403 stepi 7
404 end
405
406 define flash8-unlock2
407 set *((unsigned long *) 0x10000000) = 0xe3a01205
408 set *((unsigned long *) 0x10000004) = 0xe3811802
409 set *((unsigned long *) 0x10000008) = 0xe3a02060
410 set *((unsigned long *) 0x1000000c) = 0xe5c12000
411 set *((unsigned long *) 0x10000010) = 0xe3a020d0
412 set *((unsigned long *) 0x10000014) = 0xe5c12000
413 set *((unsigned long *) 0x10000018) = 0xe3a020ff
414 set *((unsigned long *) 0x1000001c) = 0xe5c12000
415 set $pc = 0x10000000
416 stepi 8
417 end
418
419 define flash8-program
420 set *((unsigned long *) 0x10100000) = 0xe3a01205
421 set *((unsigned long *) 0x10100004) = 0xe3a02040
422 set *((unsigned long *) 0x10100008) = 0xe3a03080
423 set *((unsigned long *) 0x1010000c) = 0xe3a040ff
424 set *((unsigned long *) 0x10100010) = 0xe3a05000
425 set *((unsigned long *) 0x10100014) = 0xe3a06701
426 set *((unsigned long *) 0x10100018) = 0xe5c12000
427 set *((unsigned long *) 0x1010001c) = 0xe5d57000
428 set *((unsigned long *) 0x10100020) = 0xe5c17000
429 set *((unsigned long *) 0x10100024) = 0xe5d17000
430 set *((unsigned long *) 0x10100028) = 0xe1170003
431 set *((unsigned long *) 0x1010002c) = 0x0afffffc
432 set *((unsigned long *) 0x10100030) = 0xe5c14000
433 set *((unsigned long *) 0x10100034) = 0xe2811001
434 set *((unsigned long *) 0x10100038) = 0xe2855001
435 set *((unsigned long *) 0x1010003c) = 0xe1550006
436 set *((unsigned long *) 0x10100040) = 0x1afffff4
437 set *((unsigned long *) 0x10100044) = 0xe1a00000
438 set *((unsigned long *) 0x10100048) = 0xe1a00000
439 set *((unsigned long *) 0x1010004c) = 0xeafffffe
440 set $pc = 0x10100000
441 end
442
443 define flash8-redboot
444 mem-init
445 mem-switch
446 writable
447 flash8-unlock1
448 flash8-erase1
449 flash8-unlock2
450 flash8-erase2
451 load boot/redboot/images/redboot-swap.elf
452 flash8-program
453 c
454 end
455
456 define flash8-boot
457 mem-init
458 mem-switch
459 writable
460 #flash8-unlock1
461 flash8-erase1
462 #flash8-unlock2
463 flash8-erase2
464 load boot/boot-swap.elf
465 mem-setmac
466 flash8-program
467 c
468 end
469
470
471 #
472 #       Set MAC addresses in the appropriate place. Makes it easier
473 #       for redboot to work right...
474 #
475 define mem-setmac2
476 set *((unsigned char *) 0x1c000) = 0x00
477 set *((unsigned char *) 0x1c001) = 0xcf
478 set *((unsigned char *) 0x1c002) = 0xd0
479 set *((unsigned char *) 0x1c003) = 0x00
480 set *((unsigned char *) 0x1c004) = 0x00
481 set *((unsigned char *) 0x1c005) = 0x00
482 set *((unsigned char *) 0x1c006) = 0x01
483 set *((unsigned char *) 0x1c007) = 0x00
484 end
485
486 define mem-setmac
487 set *((unsigned char *) 0x20000) = 0x00
488 set *((unsigned char *) 0x20001) = 0xcf
489 set *((unsigned char *) 0x20002) = 0xd0
490 set *((unsigned char *) 0x20003) = 0x00
491 set *((unsigned char *) 0x20004) = 0xd0
492 set *((unsigned char *) 0x20005) = 0x00
493 set *((unsigned char *) 0x20006) = 0x01
494 set *((unsigned char *) 0x20007) = 0x00
495 set *((unsigned char *) 0x20008) = 0x02
496 set *((unsigned char *) 0x20009) = 0x00
497 set *((unsigned char *) 0x2000a) = 0x00
498 set *((unsigned char *) 0x2000b) = 0xcf
499 end
500
501
502 #
503 #       Set debugger into big endian mode.
504 #
505 define gdb-big
506 set endian big
507 monitor endian big
508 end
509
510
511 #
512 #       DoC programming macros. We rely on the modified boot loader to
513 #       program the DoC. It is just a little too compiicated to script
514 #       here.
515 #
516 define doc-programipl
517 mem-init
518 mem-switch
519 writable
520 big
521 load boot/ixp425/boot.elf
522 load boot/loadipl.elf
523 set $pc = 0x3fc0028
524 c
525 end
526
527 define doc-programboot
528 mem-init
529 mem-switch
530 writable
531 big
532 load boot/boot-jtag.elf
533 load boot/loadboot.elf
534 set $pc = 0x3fc0028
535 c
536 end
537
538 define doc-runipl
539 mem-init
540 mem-switch
541 load boot/ixp425/boot.elf
542 set $pc = 0x1000
543 c
544 end
545
546 define doc-runboot
547 mem-init
548 mem-switch
549 writable
550 big
551 load boot/boot.elf
552 set $pc = 0x1fe0028
553 end
554
555 #
556 #       Startup commands...
557 #
558 set output-radix 16
559 set input-radix 16
560
561 target remote localhost:8888
562
563 set print pretty
564 set print asm-demangle
565 display/i $pc
566