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