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