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