]> cloudbase.mooo.com Git - z180-stamp.git/blob - avr/command_tbl.c
cmd_attach.c, cmd_boot.c, cmd_loadcpm3.c: use cmd_error()
[z180-stamp.git] / avr / command_tbl.c
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_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"
22
23
24 cmd_tbl_t cmd_tbl[] = {
25
26 CMD_TBL_ITEM(
27 date, 2, 1, do_date,
28 "get/set date & time",
29 "[MMDDhhmm[[CC]YY][.ss]]\n"
30 " - without arguments: print date & time\n"
31 " - with numeric argument: set the system date & time\n"
32 ),
33
34 #ifdef DEBUG
35
36 CMD_TBL_ITEM(
37 !mdr, 3, CTBL_DBG|CTBL_RPT, do_dump_mem,
38 "RAM dump",
39 "address [count]"
40 ),
41 CMD_TBL_ITEM(
42 !mde, 3, CTBL_DBG|CTBL_RPT, do_dump_mem,
43 "EEPROM dump",
44 "address [count]"
45 ),
46 CMD_TBL_ITEM(
47 !mdf, 3, CTBL_DBG|CTBL_RPT, do_dump_mem,
48 "FLASH dump",
49 "address [count]"
50 ),
51 CMD_TBL_ITEM(
52 !cpe, 4, CTBL_DBG, do_eep_cp,
53 "EEPROM copy",
54 "source target count"
55 ),
56 CMD_TBL_ITEM(
57 !mm, 2, CTBL_DBG|CTBL_RPT, do_mem_mm_avr,
58 "avr memory modify (auto-incrementing address)",
59 "address"
60 ),
61 CMD_TBL_ITEM(
62 !nm, 2, CTBL_DBG|CTBL_RPT, do_mem_nm_avr,
63 "avr memory modify (constant address)",
64 "address"
65 ),
66 CMD_TBL_ITEM(
67 !prfree, 1, CTBL_DBG|CTBL_RPT, do_pr_free_avr,
68 "print avr heap free list",
69 ""
70 ),
71 CMD_TBL_ITEM(
72 !prheap, 1, CTBL_DBG, do_pr_heap_avr,
73 "dump avr heap",
74 ""
75 ),
76 #endif
77 CMD_TBL_ITEM(
78 mstep, 2, 1, do_busreq_pulse,
79 "execute one M cycle",
80 "[count]\n"
81 " - repeat count times"
82 ),
83 CMD_TBL_ITEM(
84 echo, CONFIG_SYS_MAXARGS, 1, do_echo,
85 "display a line of text",
86 "[-n] [argument ...]\n"
87 "- echo the argument(s) to console.\n"
88 " -n do not output the trailing newline"
89 ),
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 ),
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 ),
103 CMD_TBL_ITEM(
104 boot, 1, 1, do_bootd,
105 "boot default, i.e., run 'bootcmd'",
106 ""
107 ),
108 CMD_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 ),
115
116 CMD_TBL_ITEM_TOP(
117 env, CONFIG_SYS_MAXARGS, 0, do_env,
118 "environment handling commands",
119 "",
120 cmd_tbl_env
121 ),
122
123 CMD_TBL_ITEM(
124 loadf, 1, 0, do_loadf,
125 "load srec_cat prepared image from controller flash",
126 ""
127 ),
128 CMD_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 ),
149 CMD_TBL_ITEM(
150 loadcpm3, 3, 0, do_loadcpm3,
151 "load CPM3.SYS file",
152 "[filename [common-base [banked-base]]] \n"
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"
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"'"
160 ),
161 CMD_TBL_ITEM(
162 loadi, 2, 0, do_loadihex,
163 "load intel hex file over serial line",
164 "[[-]offset]\n"
165 " - load Intel-Hex-Record file over serial line with offset 'offset'"
166 ),
167
168 #if defined(CONFIG_CMD_LOADB)
169 CMD_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
175 CMD_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
181 CMD_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
188 CMD_TBL_ITEM(
189 go, 2, 0, do_go,
190 "start application at address 'addr'",
191 "addr\n"
192 " - start application at address 'addr'"
193 // "\n"
194 // " passing 'arg' as arguments"
195 ),
196 CMD_TBL_ITEM(
197 reset, 1, 0, do_reset,
198 "Keep CPU in RESET state",
199 ""
200 ),
201 CMD_TBL_ITEM(
202 restart, 1, 1, do_restart,
203 "Perform RESET of the CPU",
204 ""
205 ),
206 CMD_TBL_ITEM(
207 connect, 1, 0, do_console,
208 "Connect to CPU console i/o",
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
214 ),
215
216 CMD_TBL_ITEM(
217 pin, CONFIG_SYS_MAXARGS, 1, do_gpio,
218 "Set or query pin state",
219 "[-s] [<pins>]\n"
220 " - print cofiguration and state or frequency of pins\n"
221 " print all pins, if argument is omitted\n"
222 "pin <pins> h[igh]|l[ow]\n"
223 " - config pins as output and set to level high or low\n"
224 "pin <pins> ts|i[n]|p[ullup]\n"
225 " - config pins as input/tristate or input with pullup\n"
226 "pin <pins> value[K|M][Hz]\n"
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"
231 "<pins> is a comma separated list of numbers or ranges, i.e. \"0,9,3-6\"\n"
232 ),
233
234 CMD_TBL_ITEM(
235 md, 3, CTBL_RPT, do_mem_md,
236 "memory display",
237 "address [# of objects]"
238 ),
239 CMD_TBL_ITEM(
240 mm, 2, CTBL_RPT, do_mem_mm,
241 "memory modify (auto-incrementing address)",
242 "address"
243 ),
244 CMD_TBL_ITEM(
245 nm, 2, CTBL_RPT, do_mem_nm,
246 "memory modify (constant address)",
247 "address"
248 ),
249 CMD_TBL_ITEM(
250 mw, CONFIG_SYS_MAXARGS, CTBL_RPT, do_mem_mw,
251 "memory write (fill)",
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"
255 " -l write value as long (32 bit)"
256 ),
257 CMD_TBL_ITEM(
258 mcp, 4, CTBL_RPT, do_mem_cp,
259 "memory copy",
260 "source target count"
261 ),
262 CMD_TBL_ITEM(
263 mcmp, 4, CTBL_RPT, do_mem_cmp,
264 "memory compare",
265 "addr1 addr2 count"
266 ),
267 CMD_TBL_ITEM(
268 base, 2, 0, do_mem_base,
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 ),
275 CMD_TBL_ITEM(
276 mloop, 3, CTBL_RPT, do_mem_loop,
277 "infinite loop on address range",
278 "address number_of_bytes"
279 ),
280 CMD_TBL_ITEM(
281 mloopw, 4, CTBL_RPT, do_mem_loopw,
282 "infinite write loop on address range",
283 "address number_of_bytes data_to_write"
284 ),
285
286 #ifdef CONFIG_CMD_MEMTEST
287 CMD_TBL_ITEM(
288 mtest, 4, CTBL_RPT, do_mem_mtest,
289 "simple RAM read/write test",
290 "[start [end [iterations]]]"
291 ),
292 #endif /* CONFIG_CMD_MEMTEST */
293
294 #ifdef CONFIG_MX_CYCLIC
295 CMD_TBL_ITEM(
296 mdc, 4, CTBL_RPT, do_mem_mdc,
297 "memory display cyclic",
298 "address count delay(ms)"
299 ),
300 CMD_TBL_ITEM(
301 mwc, CONFIG_SYS_MAXARGS, CTBL_RPT, do_mem_mdc,
302 "memory write cyclic",
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)"
307 ),
308 #endif /* CONFIG_MX_CYCLIC */
309
310 CMD_TBL_ITEM_TOP(
311 sd, CONFIG_SYS_MAXARGS, 0, do_sd,
312 "SD/MMC card handling commands",
313 "<subcommand> args ...\n"
314 "sd help\n"
315 " - print help on subcommands",
316 cmd_tbl_sd
317 ),
318 CMD_TBL_ITEM_TOP(
319 fat, CONFIG_SYS_MAXARGS, 0, do_fat,
320 "fat filesystem commands",
321 "<subcommand> args ...\n"
322 "fat help\n"
323 " - print help on subcommands",
324 cmd_tbl_fat
325 ),
326
327 CMD_TBL_ITEM(
328 attach, CONFIG_SYS_MAXARGS, CTBL_RPT, do_attach,
329 "attach filesystem image file to CP/M drive",
330 "[-rw] [-o options] dsk<n> diskfile\n"
331 " Attach diskfile to dsk<n>, where n in 0.."CONFIG_CPM_MAX_DRNR_STR"\n"
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"
347 "attach\n"
348 " Without arguments, list current assignments"
349 ),
350 CMD_TBL_ITEM(
351 detach, 2, 0, do_attach,
352 "detach file from CP/M drive",
353 "dsk<n>]\n"
354 " - alias for 'attach -d dsk<n>'"
355 ),
356
357 CMD_TBL_ITEM(
358 help, CONFIG_SYS_MAXARGS, 0, do_help,
359 "print command description/usage",
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'"
369 ),
370
371 /* This does not use the CMD_TBL_ITEM macro as ? can't be used in symbol names */
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 */
377 NULL,
378 #ifdef CONFIG_AUTO_COMPLETE
379 NULL,
380 #endif
381 },
382 /* Mark end of table */
383 CMD_TBL_END(cmd_tbl)
384 };