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