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