FreeCalypso > hg > freecalypso-tools
comparison 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 |
comparison
equal
deleted
inserted
replaced
541:a58563d16e1d | 542:b95b251b33eb |
---|---|
1 #include <sys/types.h> | |
2 #include "types.h" | |
3 #include "leadapi.h" | |
4 | |
5 void | |
6 cmd_dump(argbulk) | |
7 char *argbulk; | |
8 { | |
9 char *argv[4]; | |
10 u_long mode, addr, len; | |
11 int rc; | |
12 volatile u16 *api; | |
13 unsigned n; | |
14 | |
15 if (parse_args(argbulk, 3, 3, argv, 0) < 0) | |
16 return; | |
17 if (parse_hexarg(argv[0], 4, &mode) < 0) { | |
18 printf("ERROR: mode must be a valid 16-bit hex value\n"); | |
19 return; | |
20 } | |
21 if (parse_hexarg(argv[1], 8, &addr) < 0) { | |
22 printf("ERROR: addr must be a valid 32-bit hex value\n"); | |
23 return; | |
24 } | |
25 if (parse_hexarg(argv[2], 4, &len) < 0) { | |
26 printf("ERROR: len must be a valid 16-bit hex value\n"); | |
27 return; | |
28 } | |
29 rc = boot_dsp_dump_agent(); | |
30 if (rc < 0) | |
31 return; /* error msg already printed */ | |
32 rc = dsp_read_op((u16)mode, (u32)addr, (u16)len); | |
33 if (rc < 0) { | |
34 printf("ERROR: DSP timeout on read operation\n"); | |
35 return; | |
36 } | |
37 api = (volatile u16 *) APIF_ADDR; | |
38 for (n = 0; n < len; n++) | |
39 printf("%04X\n", *api++); | |
40 } | |
41 | |
42 dump_large_section(mode, addr, len) | |
43 u16 mode; | |
44 u32 addr, len; | |
45 { | |
46 u32 chunk, remain; | |
47 volatile u16 *api; | |
48 int rc; | |
49 | |
50 for (remain = len; remain; remain -= chunk) { | |
51 chunk = remain; | |
52 if (chunk > MAX_BLOCK_SIZE) | |
53 chunk = MAX_BLOCK_SIZE; | |
54 rc = dsp_read_op(mode, addr, chunk); | |
55 if (rc < 0) { | |
56 printf("ERROR: DSP timeout on read operation\n"); | |
57 return(rc); | |
58 } | |
59 api = (volatile u16 *) APIF_ADDR; | |
60 for (; chunk; chunk--) { | |
61 if (!(addr & 0xF)) | |
62 printf("%05x : ", addr); | |
63 printf("%04x%c", *api++, ((addr&15)==15)?'\n':' '); | |
64 addr++; | |
65 } | |
66 } | |
67 putchar('\n'); | |
68 return(0); | |
69 } | |
70 | |
71 void | |
72 cmd_bigdump(argbulk) | |
73 char *argbulk; | |
74 { | |
75 char *argv[4]; | |
76 u_long mode, addr, len; | |
77 int rc; | |
78 | |
79 if (parse_args(argbulk, 3, 3, argv, 0) < 0) | |
80 return; | |
81 if (parse_hexarg(argv[0], 4, &mode) < 0) { | |
82 printf("ERROR: mode must be a valid 16-bit hex value\n"); | |
83 return; | |
84 } | |
85 if (parse_hexarg(argv[1], 8, &addr) < 0) { | |
86 printf("ERROR: addr must be a valid 32-bit hex value\n"); | |
87 return; | |
88 } | |
89 if (parse_hexarg(argv[2], 8, &len) < 0) { | |
90 printf("ERROR: len must be a valid 32-bit hex value\n"); | |
91 return; | |
92 } | |
93 rc = boot_dsp_dump_agent(); | |
94 if (rc < 0) | |
95 return; /* error msg already printed */ | |
96 dump_large_section((u16)mode, (u32)addr, (u32)len); | |
97 } |