FreeCalypso > hg > freecalypso-tools
annotate target-utils/dspdump/dumpops.c @ 542:b95b251b33eb
dspdump: bigdump command implemented
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 28 Oct 2019 20:42:06 +0000 |
parents | target-utils/dspdump/mandump.c@27b5526ba1a8 |
children | 947c6a443a9c |
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 { |
b95b251b33eb
dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
540
diff
changeset
|
46 u32 chunk, remain; |
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; |
b95b251b33eb
dspdump: bigdump command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
540
diff
changeset
|
60 for (; chunk; chunk--) { |
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 } |