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