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