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