]>
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" |
228b1c5f 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( |
82c475ad | 37 | !mdr, 3, CTBL_DBG|CTBL_RPT, do_dump_mem, |
f338df2a L |
38 | "RAM dump", |
39 | "address [count]" | |
40 | ), | |
41 | CMD_TBL_ITEM( | |
82c475ad | 42 | !mde, 3, CTBL_DBG|CTBL_RPT, do_dump_mem, |
323398b1 L |
43 | "EEPROM dump", |
44 | "address [count]" | |
45 | ), | |
c748023e | 46 | CMD_TBL_ITEM( |
82c475ad | 47 | !mdf, 3, CTBL_DBG|CTBL_RPT, do_dump_mem, |
c748023e L |
48 | "FLASH dump", |
49 | "address [count]" | |
50 | ), | |
323398b1 | 51 | CMD_TBL_ITEM( |
82c475ad | 52 | !cpe, 4, CTBL_DBG, do_eep_cp, |
323398b1 L |
53 | "EEPROM copy", |
54 | "source target count" | |
55 | ), | |
ad9bc17c | 56 | CMD_TBL_ITEM( |
82c475ad | 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( | |
82c475ad | 62 | !nm, 2, CTBL_DBG|CTBL_RPT, do_mem_nm_avr, |
ad9bc17c L |
63 | "avr memory modify (constant address)", |
64 | "address" | |
65 | ), | |
c6a1984b | 66 | CMD_TBL_ITEM( |
82c475ad | 67 | !prfree, 1, CTBL_DBG|CTBL_RPT, do_pr_free_avr, |
c6a1984b | 68 | "print avr heap free list", |
8315e7f4 L |
69 | "" |
70 | ), | |
71 | CMD_TBL_ITEM( | |
82c475ad | 72 | !prheap, 1, CTBL_DBG, do_pr_heap_avr, |
8315e7f4 L |
73 | "dump avr heap", |
74 | "" | |
c6a1984b | 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 | ), | |
d684c216 L |
110 | CMD_TBL_ITEM_COMPLETE( |
111 | printenv, CONFIG_SYS_MAXARGS, 1, do_env_print, | |
112 | "print environment variables", | |
72f58822 | 113 | "\n" |
534e1dfc | 114 | " - print values of all environment variables\n" |
d684c216 L |
115 | "printenv name ...\n" |
116 | " - print value of environment variable 'name'", | |
117 | var_complete | |
118 | ), | |
119 | CMD_TBL_ITEM_COMPLETE( | |
120 | setenv, CONFIG_SYS_MAXARGS, 0, do_env_set, | |
121 | "set environment variables", | |
72f58822 L |
122 | "name value ...\n" |
123 | " - set environment variable 'name' to 'value ...'\n" | |
124 | "setenv name\n" | |
125 | " - delete environment variable 'name'", | |
d684c216 L |
126 | var_complete |
127 | ), | |
323398b1 L |
128 | CMD_TBL_ITEM( |
129 | saveenv, 1, 0, do_env_save, | |
130 | "save environment variables to persistent storage", | |
131 | "" | |
132 | ), | |
7e24905c L |
133 | CMD_TBL_ITEM( |
134 | defaultenv, 1, 0, do_env_default, | |
135 | "set all environment variables to their default values", | |
136 | "" | |
137 | ), | |
72f58822 | 138 | |
534e1dfc | 139 | CMD_TBL_ITEM( |
323398b1 | 140 | loadf, 1, 0, do_loadf, |
534e1dfc L |
141 | "load srec_cat prepared image from controller flash", |
142 | "" | |
143 | ), | |
a2907f2e L |
144 | CMD_TBL_ITEM( |
145 | bootcf, CONFIG_SYS_MAXARGS, 0, do_bootcf, | |
146 | "boot from cf card", | |
147 | "[options]\n" | |
148 | " Load a number of sectors from the first CP/M partition and jump to\n" | |
149 | " the load address.\n" | |
150 | " -a ADDRESS\n" | |
151 | " Load and start address (default 100 hex)\n" | |
152 | " -s NUM\n" | |
153 | " First sector of partition to load (0..255, default 0)\n" | |
154 | " -c NUM\n" | |
155 | " Number of sectors to load (1..127, default 7)\n" | |
156 | " -i NUM\n" | |
157 | " Partition type to look for (default 52 hex)\n" | |
158 | " -n\n" | |
159 | " Load only, do not execute\n" | |
160 | " -t NUM\n" | |
161 | " Timeout for IDE commands (1..65535, default 10000)\n" | |
162 | " -v verbose\n" | |
163 | " TODO: be verbose" | |
164 | ), | |
c0abd68b L |
165 | CMD_TBL_ITEM( |
166 | loadcpm3, 3, 0, do_loadcpm3, | |
167 | "load CPM3.SYS file", | |
98aac4d0 | 168 | "[filename [common-base [banked-base]]] \n" |
fa84c3ba L |
169 | " - Load CP/M 3 system file from FAT filesystem. This command makes\n" |
170 | " CPMLDR superfluous. Uses the following environment variables if set:\n" | |
b51d2360 L |
171 | " '"ENV_CPM3_SYSFILE"' File to load. Default is '"CONFIG_CPM3_SYSFILE"'.\n" |
172 | " '"ENV_CPM3_BANKED_BASE"' Default is '"CONFIG_CPM3_BANKED_BASE_STR"'.\n" | |
173 | " Sets the following environment variables after loading:\n" | |
174 | " '"ENV_CPM3_COMMON_BASE"'\n" | |
175 | " '"ENV_STARTADDRESS"'" | |
c0abd68b | 176 | ), |
179bc609 L |
177 | CMD_TBL_ITEM( |
178 | loadi, 2, 0, do_loadihex, | |
bf587043 L |
179 | "load intel hex file over serial line", |
180 | "[[-]offset]\n" | |
181 | " - load Intel-Hex-Record file over serial line with offset 'offset'" | |
179bc609 | 182 | ), |
393b1897 L |
183 | |
184 | #if defined(CONFIG_CMD_LOADB) | |
185 | CMD_TBL_ITEM( | |
186 | loadb, 1, 0, do_load_serial_bin, | |
187 | "load binary file over serial line (kermit mode)", | |
188 | " - load binary file over serial line" | |
189 | ), | |
190 | ||
191 | CMD_TBL_ITEM( | |
192 | loadx, 1, 0, do_load_serial_bin, | |
193 | "load binary file over serial line (xmodem mode)", | |
194 | " - load binary file over serial line" | |
195 | ), | |
196 | ||
197 | CMD_TBL_ITEM( | |
198 | loady, 1, 0, do_load_serial_bin, | |
199 | "load binary file over serial line (ymodem mode)", | |
200 | " - load binary file over serial line" | |
201 | ), | |
202 | #endif /* CONFIG_CMD_LOADB */ | |
203 | ||
534e1dfc | 204 | CMD_TBL_ITEM( |
323398b1 | 205 | go, 2, 0, do_go, |
534e1dfc L |
206 | "start application at address 'addr'", |
207 | "addr\n" | |
208 | " - start application at address 'addr'" | |
209 | // "\n" | |
210 | // " passing 'arg' as arguments" | |
211 | ), | |
212 | CMD_TBL_ITEM( | |
323398b1 | 213 | reset, 1, 0, do_reset, |
534e1dfc L |
214 | "Keep CPU in RESET state", |
215 | "" | |
216 | ), | |
217 | CMD_TBL_ITEM( | |
89adce76 | 218 | restart, 1, 1, do_restart, |
534e1dfc L |
219 | "Perform RESET of the CPU", |
220 | "" | |
221 | ), | |
89adce76 | 222 | CMD_TBL_ITEM( |
2fe44122 | 223 | connect, 1, 0, do_console, |
89adce76 | 224 | "Connect to CPU console i/o", |
98aac4d0 L |
225 | "\n" |
226 | " - type the escape character followed by Q to close the connection, \n" | |
227 | " or followed by ? to see other options. The default escape character \n" | |
228 | " is Ctrl-^ (0x1E). It can be changed by setting env var '"ENV_ESC_CHAR"'." | |
229 | ||
89adce76 | 230 | ), |
41d36f28 | 231 | |
41d36f28 | 232 | CMD_TBL_ITEM( |
05994bd9 | 233 | pin, CONFIG_SYS_MAXARGS, 1, do_gpio, |
cd5ee544 L |
234 | "Set or query pin state", |
235 | "[-s] [<pins>]\n" | |
41d36f28 L |
236 | " - print cofiguration and state or frequency of pins\n" |
237 | " print all pins, if argument is omitted\n" | |
cd5ee544 | 238 | "pin <pins> h[igh]|l[ow]\n" |
41d36f28 | 239 | " - config pins as output and set to level high or low\n" |
cd5ee544 | 240 | "pin <pins> ts|i[n]|p[ullup]\n" |
41d36f28 | 241 | " - config pins as input/tristate or input with pullup\n" |
cd5ee544 | 242 | "pin <pins> value[K|M][Hz]\n" |
41d36f28 L |
243 | " - output a clock on pins\n" |
244 | " value is system clock divider or frequency, if 'Hz' is appended\n" | |
245 | " divider is rounded down to next possible value (depends on pin)\n" | |
246 | "\n" | |
cd5ee544 | 247 | "<pins> is a comma separated list of numbers or ranges, i.e. \"0,9,3-6\"\n" |
6035a17b | 248 | ), |
534e1dfc | 249 | |
72f58822 | 250 | CMD_TBL_ITEM( |
82c475ad | 251 | md, 3, CTBL_RPT, do_mem_md, |
72f58822 L |
252 | "memory display", |
253 | "address [# of objects]" | |
254 | ), | |
255 | CMD_TBL_ITEM( | |
82c475ad | 256 | mm, 2, CTBL_RPT, do_mem_mm, |
72f58822 L |
257 | "memory modify (auto-incrementing address)", |
258 | "address" | |
259 | ), | |
260 | CMD_TBL_ITEM( | |
82c475ad | 261 | nm, 2, CTBL_RPT, do_mem_nm, |
72f58822 L |
262 | "memory modify (constant address)", |
263 | "address" | |
264 | ), | |
265 | CMD_TBL_ITEM( | |
82c475ad | 266 | mw, CONFIG_SYS_MAXARGS, CTBL_RPT, do_mem_mw, |
72f58822 | 267 | "memory write (fill)", |
32154e5a L |
268 | "[-bwl] address value [count]\n" |
269 | " -b write value as byte (8 bit, default)\n" | |
270 | " -w write value as word (16 bit)\n" | |
fcd2239e | 271 | " -l write value as long (32 bit)" |
72f58822 L |
272 | ), |
273 | CMD_TBL_ITEM( | |
82c475ad | 274 | cp, 4, CTBL_RPT, do_mem_cp, |
72f58822 L |
275 | "memory copy", |
276 | "source target count" | |
277 | ), | |
278 | CMD_TBL_ITEM( | |
82c475ad | 279 | cmp, 4, CTBL_RPT, do_mem_cmp, |
72f58822 L |
280 | "memory compare", |
281 | "addr1 addr2 count" | |
282 | ), | |
283 | CMD_TBL_ITEM( | |
c79c80b4 | 284 | base, 2, 0, do_mem_base, |
72f58822 L |
285 | "print or set address offset", |
286 | "\n" | |
287 | " - print address offset for memory commands\n" | |
288 | "base offset\n" | |
289 | " - set address offset for memory commands to 'offset'" | |
290 | ), | |
291 | CMD_TBL_ITEM( | |
82c475ad | 292 | mloop, 3, CTBL_RPT, do_mem_loop, |
72f58822 L |
293 | "infinite loop on address range", |
294 | "address number_of_bytes" | |
295 | ), | |
72f58822 | 296 | CMD_TBL_ITEM( |
82c475ad | 297 | mloopw, 4, CTBL_RPT, do_mem_loopw, |
72f58822 L |
298 | "infinite write loop on address range", |
299 | "address number_of_bytes data_to_write" | |
300 | ), | |
72f58822 L |
301 | |
302 | #ifdef CONFIG_CMD_MEMTEST | |
303 | CMD_TBL_ITEM( | |
82c475ad | 304 | mtest, 4, CTBL_RPT, do_mem_mtest, |
72f58822 | 305 | "simple RAM read/write test", |
5480dc65 | 306 | "[start [end [iterations]]]" |
72f58822 L |
307 | ), |
308 | #endif /* CONFIG_CMD_MEMTEST */ | |
309 | ||
310 | #ifdef CONFIG_MX_CYCLIC | |
311 | CMD_TBL_ITEM( | |
82c475ad | 312 | mdc, 4, CTBL_RPT, do_mem_mdc, |
72f58822 L |
313 | "memory display cyclic", |
314 | "address count delay(ms)" | |
315 | ), | |
316 | CMD_TBL_ITEM( | |
82c475ad | 317 | mwc, CONFIG_SYS_MAXARGS, CTBL_RPT, do_mem_mdc, |
72f58822 | 318 | "memory write cyclic", |
fcd2239e L |
319 | "[-bwl] address value delay(ms)\n" |
320 | " -b write value as byte (8 bit, default)\n" | |
321 | " -w write value as word (16 bit)\n" | |
322 | " -l write value as long (32 bit)" | |
72f58822 L |
323 | ), |
324 | #endif /* CONFIG_MX_CYCLIC */ | |
325 | ||
6c851813 | 326 | CMD_TBL_ITEM_TOP( |
1c62c844 | 327 | sd, CONFIG_SYS_MAXARGS, CTBL_SUBCMDAUTO, do_sd, |
7f552300 L |
328 | "SD/MMC card handling commands", |
329 | "<subcommand> args ...\n" | |
330 | "sd help\n" | |
6c851813 L |
331 | " - print help on subcommands", |
332 | cmd_tbl_sd | |
7f552300 | 333 | ), |
6c851813 | 334 | CMD_TBL_ITEM_TOP( |
1c62c844 | 335 | fat, CONFIG_SYS_MAXARGS, CTBL_SUBCMD|CTBL_SUBCMDAUTO, do_fat, |
b6c04275 L |
336 | "fat filesystem commands", |
337 | "<subcommand> args ...\n" | |
338 | "fat help\n" | |
6c851813 L |
339 | " - print help on subcommands", |
340 | cmd_tbl_fat | |
2f53dd65 | 341 | ), |
b6c04275 | 342 | |
cb4fb1ed | 343 | CMD_TBL_ITEM( |
82c475ad | 344 | attach, CONFIG_SYS_MAXARGS, CTBL_RPT, do_attach, |
cb4fb1ed | 345 | "attach filesystem image file to CP/M drive", |
96798b2c L |
346 | "[-rw] [-o options] dsk<n> diskfile\n" |
347 | " Attach diskfile to dsk<n>, where n in 0..7\n" | |
348 | " -r File is read only (write protected)\n" | |
349 | " -w File is read/write (default)\n" | |
350 | " -o options\n" | |
351 | " Options is a comma-separated list of\n" | |
352 | " ro, rw, debug, nodebug\n" | |
353 | "\n" | |
354 | "attach [-rw] -o reattach[,other options] dsk<n>\n" | |
355 | " Change options for dsk<n>.\n" | |
356 | " Options as above.\n" | |
357 | "\n" | |
358 | "attach -d -a|dsk<n>\n" | |
359 | "detach -a|dsk<n>\n" | |
360 | " Detach diskfile from dsk<n>.\n" | |
361 | " -a Detach all.\n" | |
362 | "\n" | |
cb4fb1ed | 363 | "attach\n" |
6c851813 | 364 | " Without arguments, list current assignments" |
cb4fb1ed L |
365 | ), |
366 | CMD_TBL_ITEM( | |
82c475ad | 367 | detach, 2, 0, do_attach, |
cb4fb1ed L |
368 | "detach file from CP/M drive", |
369 | "dsk<n>]\n" | |
a2907f2e | 370 | " - alias for 'attach -d dsk<n>'" |
cb4fb1ed | 371 | ), |
2f53dd65 | 372 | |
d684c216 | 373 | CMD_TBL_ITEM( |
82c475ad | 374 | help, CONFIG_SYS_MAXARGS, 0, do_help, |
d684c216 L |
375 | "print command description/usage", |
376 | "\n" | |
377 | " - print brief description of all commands\n" | |
378 | "help command ...\n" | |
379 | " - print detailed usage of 'command'" | |
380 | ), | |
381 | ||
72f58822 | 382 | /* This does not use the CMD_TBL_ITEM macro as ? can't be used in symbol names */ |
d684c216 L |
383 | {FSTR("?"), CONFIG_SYS_MAXARGS, 1, do_help, |
384 | FSTR("alias for 'help'"), | |
385 | #ifdef CONFIG_SYS_LONGHELP | |
386 | FSTR(""), | |
387 | #endif /* CONFIG_SYS_LONGHELP */ | |
6c851813 | 388 | NULL, |
d684c216 | 389 | #ifdef CONFIG_AUTO_COMPLETE |
6c851813 | 390 | NULL, |
d684c216 L |
391 | #endif |
392 | }, | |
393 | /* Mark end of table */ | |
6c7c9c2d | 394 | CMD_TBL_END(cmd_tbl) |
d684c216 | 395 | }; |