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