]>
Commit | Line | Data |
---|---|---|
35edb766 | 1 | /* |
04f84937 | 2 | * (C) Copyright 2014-2016, 2018 Leo C. <erbl259-lmu@yahoo.de> |
35edb766 | 3 | * |
b51d2360 | 4 | * SPDX-License-Identifier: GPL-2.0 |
35edb766 | 5 | */ |
d684c216 L |
6 | |
7 | #include "common.h" | |
d684c216 | 8 | #include "command.h" |
72f58822 | 9 | #include "cmd_mem.h" |
7eecbdac L |
10 | #include "cmd_boot.h" |
11 | #include "cmd_misc.h" | |
12 | #include "cmd_date.h" | |
13 | #include "cmd_run.h" | |
14 | #include "cmd_loadcpm3.h" | |
15 | #include "cmd_loadihex.h" | |
16 | #include "cmd_gpio.h" | |
17 | #include "cmd_sd.h" | |
18 | #include "cmd_fat.h" | |
19 | #include "cmd_attach.h" | |
20 | #include "env.h" | |
21 | #include "debug.h" | |
d684c216 | 22 | |
d684c216 L |
23 | |
24 | cmd_tbl_t cmd_tbl[] = { | |
25 | ||
61b0cfe9 L |
26 | CMD_TBL_ITEM( |
27 | date, 2, 1, do_date, | |
a036b05f | 28 | "get/set date & time", |
85046f8c | 29 | "[MMDDhhmm[[CC]YY][.ss]]\n" |
61b0cfe9 L |
30 | " - without arguments: print date & time\n" |
31 | " - with numeric argument: set the system date & time\n" | |
61b0cfe9 L |
32 | ), |
33 | ||
323398b1 | 34 | #ifdef DEBUG |
4565be9a | 35 | |
323398b1 | 36 | CMD_TBL_ITEM( |
7a1ed620 | 37 | !mdr, 3, CTBL_DBG|CTBL_RPT, do_dump_mem, |
f338df2a L |
38 | "RAM dump", |
39 | "address [count]" | |
40 | ), | |
41 | CMD_TBL_ITEM( | |
7a1ed620 | 42 | !mde, 3, CTBL_DBG|CTBL_RPT, do_dump_mem, |
323398b1 L |
43 | "EEPROM dump", |
44 | "address [count]" | |
45 | ), | |
c748023e | 46 | CMD_TBL_ITEM( |
7a1ed620 | 47 | !mdf, 3, CTBL_DBG|CTBL_RPT, do_dump_mem, |
c748023e L |
48 | "FLASH dump", |
49 | "address [count]" | |
50 | ), | |
323398b1 | 51 | CMD_TBL_ITEM( |
7a1ed620 | 52 | !cpe, 4, CTBL_DBG, do_eep_cp, |
323398b1 L |
53 | "EEPROM copy", |
54 | "source target count" | |
55 | ), | |
ad9bc17c | 56 | CMD_TBL_ITEM( |
7a1ed620 | 57 | !mm, 2, CTBL_DBG|CTBL_RPT, do_mem_mm_avr, |
ad9bc17c L |
58 | "avr memory modify (auto-incrementing address)", |
59 | "address" | |
60 | ), | |
61 | CMD_TBL_ITEM( | |
7a1ed620 | 62 | !nm, 2, CTBL_DBG|CTBL_RPT, do_mem_nm_avr, |
ad9bc17c L |
63 | "avr memory modify (constant address)", |
64 | "address" | |
65 | ), | |
fb9b17a9 | 66 | CMD_TBL_ITEM( |
7a1ed620 | 67 | !prfree, 1, CTBL_DBG|CTBL_RPT, do_pr_free_avr, |
fb9b17a9 | 68 | "print avr heap free list", |
b9aef06e L |
69 | "" |
70 | ), | |
71 | CMD_TBL_ITEM( | |
7a1ed620 | 72 | !prheap, 1, CTBL_DBG, do_pr_heap_avr, |
b9aef06e L |
73 | "dump avr heap", |
74 | "" | |
fb9b17a9 | 75 | ), |
323398b1 | 76 | #endif |
f338df2a L |
77 | CMD_TBL_ITEM( |
78 | mstep, 2, 1, do_busreq_pulse, | |
79 | "execute one M cycle", | |
80 | "[count]\n" | |
81 | " - repeat count times" | |
82 | ), | |
d684c216 L |
83 | CMD_TBL_ITEM( |
84 | echo, CONFIG_SYS_MAXARGS, 1, do_echo, | |
bbd45c46 L |
85 | "display a line of text", |
86 | "[-n] [argument ...]\n" | |
32154e5a L |
87 | "- echo the argument(s) to console.\n" |
88 | " -n do not output the trailing newline" | |
d684c216 | 89 | ), |
8a7decea L |
90 | CMD_TBL_ITEM( |
91 | sleep , 2, 1, do_sleep, | |
92 | "delay execution for some time", | |
93 | "N[m][s]\n" | |
94 | " - delay execution for decimal N (milli) seconds" | |
95 | ), | |
d684c216 L |
96 | CMD_TBL_ITEM_COMPLETE( |
97 | run, CONFIG_SYS_MAXARGS, 1, do_run, | |
98 | "run commands in an environment variable", | |
99 | "var [...]\n" | |
100 | " - run the commands in the environment variable(s) 'var'", | |
101 | var_complete | |
102 | ), | |
04b3ea0e L |
103 | CMD_TBL_ITEM_COMPLETE( |
104 | source, CONFIG_SYS_MAXARGS, 1, do_source, | |
105 | "run commands from a file", | |
106 | "filename\n" | |
107 | " - run the commands in the script file 'filename'", | |
108 | var_complete | |
109 | ), | |
dab74a42 L |
110 | |
111 | CMD_TBL_ITEM_TOP( | |
112 | env, CONFIG_SYS_MAXARGS, 0, do_env, | |
113 | "environment handling commands", | |
114 | "", | |
115 | cmd_tbl_env | |
7e24905c | 116 | ), |
72f58822 | 117 | |
534e1dfc | 118 | CMD_TBL_ITEM( |
323398b1 | 119 | loadf, 1, 0, do_loadf, |
534e1dfc L |
120 | "load srec_cat prepared image from controller flash", |
121 | "" | |
122 | ), | |
a2907f2e L |
123 | CMD_TBL_ITEM( |
124 | bootcf, CONFIG_SYS_MAXARGS, 0, do_bootcf, | |
125 | "boot from cf card", | |
126 | "[options]\n" | |
127 | " Load a number of sectors from the first CP/M partition and jump to\n" | |
128 | " the load address.\n" | |
129 | " -a ADDRESS\n" | |
130 | " Load and start address (default 100 hex)\n" | |
131 | " -s NUM\n" | |
132 | " First sector of partition to load (0..255, default 0)\n" | |
133 | " -c NUM\n" | |
134 | " Number of sectors to load (1..127, default 7)\n" | |
135 | " -i NUM\n" | |
136 | " Partition type to look for (default 52 hex)\n" | |
137 | " -n\n" | |
138 | " Load only, do not execute\n" | |
139 | " -t NUM\n" | |
140 | " Timeout for IDE commands (1..65535, default 10000)\n" | |
141 | " -v verbose\n" | |
142 | " TODO: be verbose" | |
143 | ), | |
c0abd68b L |
144 | CMD_TBL_ITEM( |
145 | loadcpm3, 3, 0, do_loadcpm3, | |
146 | "load CPM3.SYS file", | |
98aac4d0 | 147 | "[filename [common-base [banked-base]]] \n" |
fa84c3ba L |
148 | " - Load CP/M 3 system file from FAT filesystem. This command makes\n" |
149 | " CPMLDR superfluous. Uses the following environment variables if set:\n" | |
b51d2360 L |
150 | " '"ENV_CPM3_SYSFILE"' File to load. Default is '"CONFIG_CPM3_SYSFILE"'.\n" |
151 | " '"ENV_CPM3_BANKED_BASE"' Default is '"CONFIG_CPM3_BANKED_BASE_STR"'.\n" | |
152 | " Sets the following environment variables after loading:\n" | |
153 | " '"ENV_CPM3_COMMON_BASE"'\n" | |
154 | " '"ENV_STARTADDRESS"'" | |
c0abd68b | 155 | ), |
179bc609 L |
156 | CMD_TBL_ITEM( |
157 | loadi, 2, 0, do_loadihex, | |
bf587043 L |
158 | "load intel hex file over serial line", |
159 | "[[-]offset]\n" | |
160 | " - load Intel-Hex-Record file over serial line with offset 'offset'" | |
179bc609 | 161 | ), |
393b1897 L |
162 | |
163 | #if defined(CONFIG_CMD_LOADB) | |
164 | CMD_TBL_ITEM( | |
165 | loadb, 1, 0, do_load_serial_bin, | |
166 | "load binary file over serial line (kermit mode)", | |
167 | " - load binary file over serial line" | |
168 | ), | |
169 | ||
170 | CMD_TBL_ITEM( | |
171 | loadx, 1, 0, do_load_serial_bin, | |
172 | "load binary file over serial line (xmodem mode)", | |
173 | " - load binary file over serial line" | |
174 | ), | |
175 | ||
176 | CMD_TBL_ITEM( | |
177 | loady, 1, 0, do_load_serial_bin, | |
178 | "load binary file over serial line (ymodem mode)", | |
179 | " - load binary file over serial line" | |
180 | ), | |
181 | #endif /* CONFIG_CMD_LOADB */ | |
182 | ||
534e1dfc | 183 | CMD_TBL_ITEM( |
323398b1 | 184 | go, 2, 0, do_go, |
534e1dfc L |
185 | "start application at address 'addr'", |
186 | "addr\n" | |
187 | " - start application at address 'addr'" | |
188 | // "\n" | |
189 | // " passing 'arg' as arguments" | |
190 | ), | |
191 | CMD_TBL_ITEM( | |
323398b1 | 192 | reset, 1, 0, do_reset, |
534e1dfc L |
193 | "Keep CPU in RESET state", |
194 | "" | |
195 | ), | |
196 | CMD_TBL_ITEM( | |
89adce76 | 197 | restart, 1, 1, do_restart, |
534e1dfc L |
198 | "Perform RESET of the CPU", |
199 | "" | |
200 | ), | |
89adce76 | 201 | CMD_TBL_ITEM( |
2fe44122 | 202 | connect, 1, 0, do_console, |
89adce76 | 203 | "Connect to CPU console i/o", |
98aac4d0 L |
204 | "\n" |
205 | " - type the escape character followed by Q to close the connection, \n" | |
206 | " or followed by ? to see other options. The default escape character \n" | |
207 | " is Ctrl-^ (0x1E). It can be changed by setting env var '"ENV_ESC_CHAR"'." | |
208 | ||
89adce76 | 209 | ), |
41d36f28 | 210 | |
41d36f28 | 211 | CMD_TBL_ITEM( |
05994bd9 | 212 | pin, CONFIG_SYS_MAXARGS, 1, do_gpio, |
cd5ee544 L |
213 | "Set or query pin state", |
214 | "[-s] [<pins>]\n" | |
41d36f28 L |
215 | " - print cofiguration and state or frequency of pins\n" |
216 | " print all pins, if argument is omitted\n" | |
cd5ee544 | 217 | "pin <pins> h[igh]|l[ow]\n" |
41d36f28 | 218 | " - config pins as output and set to level high or low\n" |
cd5ee544 | 219 | "pin <pins> ts|i[n]|p[ullup]\n" |
41d36f28 | 220 | " - config pins as input/tristate or input with pullup\n" |
cd5ee544 | 221 | "pin <pins> value[K|M][Hz]\n" |
41d36f28 L |
222 | " - output a clock on pins\n" |
223 | " value is system clock divider or frequency, if 'Hz' is appended\n" | |
224 | " divider is rounded down to next possible value (depends on pin)\n" | |
225 | "\n" | |
cd5ee544 | 226 | "<pins> is a comma separated list of numbers or ranges, i.e. \"0,9,3-6\"\n" |
6035a17b | 227 | ), |
534e1dfc | 228 | |
72f58822 | 229 | CMD_TBL_ITEM( |
7a1ed620 | 230 | md, 3, CTBL_RPT, do_mem_md, |
72f58822 L |
231 | "memory display", |
232 | "address [# of objects]" | |
233 | ), | |
234 | CMD_TBL_ITEM( | |
7a1ed620 | 235 | mm, 2, CTBL_RPT, do_mem_mm, |
72f58822 L |
236 | "memory modify (auto-incrementing address)", |
237 | "address" | |
238 | ), | |
239 | CMD_TBL_ITEM( | |
7a1ed620 | 240 | nm, 2, CTBL_RPT, do_mem_nm, |
72f58822 L |
241 | "memory modify (constant address)", |
242 | "address" | |
243 | ), | |
244 | CMD_TBL_ITEM( | |
7a1ed620 | 245 | mw, CONFIG_SYS_MAXARGS, CTBL_RPT, do_mem_mw, |
72f58822 | 246 | "memory write (fill)", |
32154e5a L |
247 | "[-bwl] address value [count]\n" |
248 | " -b write value as byte (8 bit, default)\n" | |
249 | " -w write value as word (16 bit)\n" | |
fcd2239e | 250 | " -l write value as long (32 bit)" |
72f58822 L |
251 | ), |
252 | CMD_TBL_ITEM( | |
04f84937 | 253 | mcp, 4, CTBL_RPT, do_mem_cp, |
72f58822 L |
254 | "memory copy", |
255 | "source target count" | |
256 | ), | |
257 | CMD_TBL_ITEM( | |
04f84937 | 258 | mcmp, 4, CTBL_RPT, do_mem_cmp, |
72f58822 L |
259 | "memory compare", |
260 | "addr1 addr2 count" | |
261 | ), | |
262 | CMD_TBL_ITEM( | |
c79c80b4 | 263 | base, 2, 0, do_mem_base, |
72f58822 L |
264 | "print or set address offset", |
265 | "\n" | |
266 | " - print address offset for memory commands\n" | |
267 | "base offset\n" | |
268 | " - set address offset for memory commands to 'offset'" | |
269 | ), | |
270 | CMD_TBL_ITEM( | |
7a1ed620 | 271 | mloop, 3, CTBL_RPT, do_mem_loop, |
72f58822 L |
272 | "infinite loop on address range", |
273 | "address number_of_bytes" | |
274 | ), | |
72f58822 | 275 | CMD_TBL_ITEM( |
7a1ed620 | 276 | mloopw, 4, CTBL_RPT, do_mem_loopw, |
72f58822 L |
277 | "infinite write loop on address range", |
278 | "address number_of_bytes data_to_write" | |
279 | ), | |
72f58822 L |
280 | |
281 | #ifdef CONFIG_CMD_MEMTEST | |
282 | CMD_TBL_ITEM( | |
7a1ed620 | 283 | mtest, 4, CTBL_RPT, do_mem_mtest, |
72f58822 | 284 | "simple RAM read/write test", |
5480dc65 | 285 | "[start [end [iterations]]]" |
72f58822 L |
286 | ), |
287 | #endif /* CONFIG_CMD_MEMTEST */ | |
288 | ||
289 | #ifdef CONFIG_MX_CYCLIC | |
290 | CMD_TBL_ITEM( | |
7a1ed620 | 291 | mdc, 4, CTBL_RPT, do_mem_mdc, |
72f58822 L |
292 | "memory display cyclic", |
293 | "address count delay(ms)" | |
294 | ), | |
295 | CMD_TBL_ITEM( | |
7a1ed620 | 296 | mwc, CONFIG_SYS_MAXARGS, CTBL_RPT, do_mem_mdc, |
72f58822 | 297 | "memory write cyclic", |
fcd2239e L |
298 | "[-bwl] address value delay(ms)\n" |
299 | " -b write value as byte (8 bit, default)\n" | |
300 | " -w write value as word (16 bit)\n" | |
301 | " -l write value as long (32 bit)" | |
72f58822 L |
302 | ), |
303 | #endif /* CONFIG_MX_CYCLIC */ | |
304 | ||
8da60ec5 | 305 | CMD_TBL_ITEM_TOP( |
04f84937 | 306 | sd, CONFIG_SYS_MAXARGS, 0, do_sd, |
7f552300 L |
307 | "SD/MMC card handling commands", |
308 | "<subcommand> args ...\n" | |
309 | "sd help\n" | |
8da60ec5 L |
310 | " - print help on subcommands", |
311 | cmd_tbl_sd | |
7f552300 | 312 | ), |
8da60ec5 | 313 | CMD_TBL_ITEM_TOP( |
dab74a42 | 314 | fat, CONFIG_SYS_MAXARGS, 0, do_fat, |
8a2b0da0 L |
315 | "fat filesystem commands", |
316 | "<subcommand> args ...\n" | |
317 | "fat help\n" | |
8da60ec5 L |
318 | " - print help on subcommands", |
319 | cmd_tbl_fat | |
2f53dd65 | 320 | ), |
8a2b0da0 | 321 | |
cb4fb1ed | 322 | CMD_TBL_ITEM( |
7a1ed620 | 323 | attach, CONFIG_SYS_MAXARGS, CTBL_RPT, do_attach, |
cb4fb1ed | 324 | "attach filesystem image file to CP/M drive", |
96798b2c L |
325 | "[-rw] [-o options] dsk<n> diskfile\n" |
326 | " Attach diskfile to dsk<n>, where n in 0..7\n" | |
327 | " -r File is read only (write protected)\n" | |
328 | " -w File is read/write (default)\n" | |
329 | " -o options\n" | |
330 | " Options is a comma-separated list of\n" | |
331 | " ro, rw, debug, nodebug\n" | |
332 | "\n" | |
333 | "attach [-rw] -o reattach[,other options] dsk<n>\n" | |
334 | " Change options for dsk<n>.\n" | |
335 | " Options as above.\n" | |
336 | "\n" | |
337 | "attach -d -a|dsk<n>\n" | |
338 | "detach -a|dsk<n>\n" | |
339 | " Detach diskfile from dsk<n>.\n" | |
340 | " -a Detach all.\n" | |
341 | "\n" | |
cb4fb1ed | 342 | "attach\n" |
8da60ec5 | 343 | " Without arguments, list current assignments" |
cb4fb1ed L |
344 | ), |
345 | CMD_TBL_ITEM( | |
7a1ed620 | 346 | detach, 2, 0, do_attach, |
cb4fb1ed L |
347 | "detach file from CP/M drive", |
348 | "dsk<n>]\n" | |
a2907f2e | 349 | " - alias for 'attach -d dsk<n>'" |
cb4fb1ed | 350 | ), |
2f53dd65 | 351 | |
d684c216 | 352 | CMD_TBL_ITEM( |
7a1ed620 | 353 | help, CONFIG_SYS_MAXARGS, 0, do_help, |
d684c216 L |
354 | "print command description/usage", |
355 | "\n" | |
356 | " - print brief description of all commands\n" | |
357 | "help command ...\n" | |
358 | " - print detailed usage of 'command'" | |
359 | ), | |
360 | ||
72f58822 | 361 | /* This does not use the CMD_TBL_ITEM macro as ? can't be used in symbol names */ |
d684c216 L |
362 | {FSTR("?"), CONFIG_SYS_MAXARGS, 1, do_help, |
363 | FSTR("alias for 'help'"), | |
364 | #ifdef CONFIG_SYS_LONGHELP | |
365 | FSTR(""), | |
366 | #endif /* CONFIG_SYS_LONGHELP */ | |
8da60ec5 | 367 | NULL, |
d684c216 | 368 | #ifdef CONFIG_AUTO_COMPLETE |
8da60ec5 | 369 | NULL, |
d684c216 L |
370 | #endif |
371 | }, | |
372 | /* Mark end of table */ | |
5caa8c2b | 373 | CMD_TBL_END(cmd_tbl) |
d684c216 | 374 | }; |