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