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