annotate target-utils/dspdump/dumpops.c @ 890:76cc910c508e

document fc-imy2pwt
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 03 Apr 2022 05:29:17 +0000
parents 451d8b545b11
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
540
27b5526ba1a8 dspdump target program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 #include <sys/types.h>
27b5526ba1a8 dspdump target program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 #include "types.h"
27b5526ba1a8 dspdump target program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 #include "leadapi.h"
27b5526ba1a8 dspdump target program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
27b5526ba1a8 dspdump target program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 void
27b5526ba1a8 dspdump target program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 cmd_dump(argbulk)
27b5526ba1a8 dspdump target program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 char *argbulk;
27b5526ba1a8 dspdump target program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 {
27b5526ba1a8 dspdump target program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 char *argv[4];
27b5526ba1a8 dspdump target program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 u_long mode, addr, len;
27b5526ba1a8 dspdump target program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 int rc;
27b5526ba1a8 dspdump target program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 volatile u16 *api;
27b5526ba1a8 dspdump target program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 unsigned n;
27b5526ba1a8 dspdump target program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14
27b5526ba1a8 dspdump target program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 if (parse_args(argbulk, 3, 3, argv, 0) < 0)
27b5526ba1a8 dspdump target program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 return;
27b5526ba1a8 dspdump target program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 if (parse_hexarg(argv[0], 4, &mode) < 0) {
27b5526ba1a8 dspdump target program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 printf("ERROR: mode must be a valid 16-bit hex value\n");
27b5526ba1a8 dspdump target program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 return;
27b5526ba1a8 dspdump target program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 }
27b5526ba1a8 dspdump target program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 if (parse_hexarg(argv[1], 8, &addr) < 0) {
27b5526ba1a8 dspdump target program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 printf("ERROR: addr must be a valid 32-bit hex value\n");
27b5526ba1a8 dspdump target program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 return;
27b5526ba1a8 dspdump target program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 }
27b5526ba1a8 dspdump target program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 if (parse_hexarg(argv[2], 4, &len) < 0) {
27b5526ba1a8 dspdump target program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 printf("ERROR: len must be a valid 16-bit hex value\n");
27b5526ba1a8 dspdump target program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 return;
27b5526ba1a8 dspdump target program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 }
27b5526ba1a8 dspdump target program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 rc = boot_dsp_dump_agent();
27b5526ba1a8 dspdump target program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 if (rc < 0)
27b5526ba1a8 dspdump target program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 return; /* error msg already printed */
27b5526ba1a8 dspdump target program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 rc = dsp_read_op((u16)mode, (u32)addr, (u16)len);
27b5526ba1a8 dspdump target program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 if (rc < 0) {
27b5526ba1a8 dspdump target program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 printf("ERROR: DSP timeout on read operation\n");
27b5526ba1a8 dspdump target program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 return;
27b5526ba1a8 dspdump target program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 }
27b5526ba1a8 dspdump target program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 api = (volatile u16 *) APIF_ADDR;
27b5526ba1a8 dspdump target program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 for (n = 0; n < len; n++)
27b5526ba1a8 dspdump target program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 printf("%04X\n", *api++);
27b5526ba1a8 dspdump target program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 }
542
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
41
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
42 dump_large_section(mode, addr, len)
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
43 u16 mode;
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
44 u32 addr, len;
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
45 {
543
947c6a443a9c dspdump: bugfix in bigdump command
Mychaela Falconia <falcon@freecalypso.org>
parents: 542
diff changeset
46 u32 chunk, remain, n;
542
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
47 volatile u16 *api;
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
48 int rc;
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
49
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
50 for (remain = len; remain; remain -= chunk) {
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
51 chunk = remain;
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
52 if (chunk > MAX_BLOCK_SIZE)
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
53 chunk = MAX_BLOCK_SIZE;
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
54 rc = dsp_read_op(mode, addr, chunk);
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
55 if (rc < 0) {
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
56 printf("ERROR: DSP timeout on read operation\n");
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
57 return(rc);
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
58 }
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
59 api = (volatile u16 *) APIF_ADDR;
543
947c6a443a9c dspdump: bugfix in bigdump command
Mychaela Falconia <falcon@freecalypso.org>
parents: 542
diff changeset
60 for (n = chunk; n; n--) {
542
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
61 if (!(addr & 0xF))
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
62 printf("%05x : ", addr);
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
63 printf("%04x%c", *api++, ((addr&15)==15)?'\n':' ');
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
64 addr++;
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
65 }
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
66 }
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
67 putchar('\n');
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
68 return(0);
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
69 }
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
70
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
71 void
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
72 cmd_bigdump(argbulk)
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
73 char *argbulk;
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
74 {
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
75 char *argv[4];
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
76 u_long mode, addr, len;
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
77 int rc;
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
78
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
79 if (parse_args(argbulk, 3, 3, argv, 0) < 0)
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
80 return;
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
81 if (parse_hexarg(argv[0], 4, &mode) < 0) {
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
82 printf("ERROR: mode must be a valid 16-bit hex value\n");
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
83 return;
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
84 }
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
85 if (parse_hexarg(argv[1], 8, &addr) < 0) {
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
86 printf("ERROR: addr must be a valid 32-bit hex value\n");
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
87 return;
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
88 }
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
89 if (parse_hexarg(argv[2], 8, &len) < 0) {
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
90 printf("ERROR: len must be a valid 32-bit hex value\n");
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
91 return;
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
92 }
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
93 rc = boot_dsp_dump_agent();
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
94 if (rc < 0)
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
95 return; /* error msg already printed */
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
96 dump_large_section((u16)mode, (u32)addr, (u32)len);
b95b251b33eb dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 540
diff changeset
97 }
544
451d8b545b11 dspdump: fulldump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 543
diff changeset
98
451d8b545b11 dspdump: fulldump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 543
diff changeset
99 static struct rom_section {
451d8b545b11 dspdump: fulldump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 543
diff changeset
100 char *name;
451d8b545b11 dspdump: fulldump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 543
diff changeset
101 u32 addr;
451d8b545b11 dspdump: fulldump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 543
diff changeset
102 u32 size;
451d8b545b11 dspdump: fulldump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 543
diff changeset
103 int mode;
451d8b545b11 dspdump: fulldump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 543
diff changeset
104 } rom_sections[] = {
451d8b545b11 dspdump: fulldump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 543
diff changeset
105 { "Registers", 0x00000, 0x0060, BL_MODE_DATA_READ },
451d8b545b11 dspdump: fulldump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 543
diff changeset
106 { "DROM", 0x09000, 0x5000, BL_MODE_DROM_READ },
451d8b545b11 dspdump: fulldump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 543
diff changeset
107 { "PDROM", 0x0e000, 0x2000, BL_MODE_PROM_READ },
451d8b545b11 dspdump: fulldump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 543
diff changeset
108 { "PROM0", 0x07000, 0x7000, BL_MODE_PROM_READ },
451d8b545b11 dspdump: fulldump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 543
diff changeset
109 { "PROM1", 0x18000, 0x8000, BL_MODE_PROM_READ },
451d8b545b11 dspdump: fulldump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 543
diff changeset
110 { "PROM2", 0x28000, 0x8000, BL_MODE_PROM_READ },
451d8b545b11 dspdump: fulldump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 543
diff changeset
111 { "PROM3", 0x38000, 0x2000, BL_MODE_PROM_READ },
451d8b545b11 dspdump: fulldump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 543
diff changeset
112 { 0, 0, 0, -1 }
451d8b545b11 dspdump: fulldump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 543
diff changeset
113 };
451d8b545b11 dspdump: fulldump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 543
diff changeset
114
451d8b545b11 dspdump: fulldump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 543
diff changeset
115 void
451d8b545b11 dspdump: fulldump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 543
diff changeset
116 cmd_fulldump()
451d8b545b11 dspdump: fulldump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 543
diff changeset
117 {
451d8b545b11 dspdump: fulldump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 543
diff changeset
118 struct rom_section *tp;
451d8b545b11 dspdump: fulldump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 543
diff changeset
119 int rc;
451d8b545b11 dspdump: fulldump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 543
diff changeset
120
451d8b545b11 dspdump: fulldump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 543
diff changeset
121 rc = boot_dsp_dump_agent();
451d8b545b11 dspdump: fulldump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 543
diff changeset
122 if (rc < 0)
451d8b545b11 dspdump: fulldump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 543
diff changeset
123 return; /* error msg already printed */
451d8b545b11 dspdump: fulldump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 543
diff changeset
124 for (tp = rom_sections; tp->name; tp++) {
451d8b545b11 dspdump: fulldump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 543
diff changeset
125 printf("DSP dump: %s [%05x-%05x]\n", tp->name, tp->addr,
451d8b545b11 dspdump: fulldump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 543
diff changeset
126 tp->addr + tp->size - 1);
451d8b545b11 dspdump: fulldump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 543
diff changeset
127 rc = dump_large_section(tp->mode, tp->addr, tp->size);
451d8b545b11 dspdump: fulldump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 543
diff changeset
128 if (rc < 0)
451d8b545b11 dspdump: fulldump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 543
diff changeset
129 return; /* error msg already printed */
451d8b545b11 dspdump: fulldump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 543
diff changeset
130 }
451d8b545b11 dspdump: fulldump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 543
diff changeset
131 }