summaryrefslogtreecommitdiff
path: root/avr/command_tbl.c
blob: 592858ab452ad501799aa1acbd3dd3e45724470a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
/*
 * (C) Copyright 2014-2016 Leo C. <erbl259-lmu@yahoo.de>
 *
 * SPDX-License-Identifier:	GPL-2.0
 */

#include "common.h"
#include "command.h"
#include "cmd_mem.h"

extern command_ret_t do_help(cmd_tbl_t *, int, int, char * const []);
extern command_ret_t do_echo(cmd_tbl_t *, int, int, char * const []);
extern command_ret_t do_sleep(cmd_tbl_t *, int, int, char * const []);
extern command_ret_t do_env_print(cmd_tbl_t *, int, int, char * const []);
extern command_ret_t do_env_default(cmd_tbl_t *, int, int, char * const []);
extern command_ret_t do_env_set(cmd_tbl_t *, int, int, char * const []);
extern command_ret_t do_env_save(cmd_tbl_t *, int, int, char * const []);
extern command_ret_t do_loadf(cmd_tbl_t *, int, int, char * const []);
extern command_ret_t do_bootcf(cmd_tbl_t *, int, int, char * const []);
extern command_ret_t do_loadcpm3(cmd_tbl_t *, int, int, char * const []);
extern command_ret_t do_loadihex(cmd_tbl_t *, int, int, char * const []);
#if defined(CONFIG_CMD_LOADB)
extern command_ret_t do_load_serial_bin(cmd_tbl_t *, int, int, char * const []);
#endif
extern command_ret_t do_go(cmd_tbl_t *, int, int, char * const []);
extern command_ret_t do_restart(cmd_tbl_t *, int, int, char * const []);
extern command_ret_t do_console(cmd_tbl_t *, int, int, char * const []);
extern command_ret_t do_dump_mem(cmd_tbl_t *, int, int, char * const []);
extern command_ret_t do_mem_mm_avr(cmd_tbl_t *, int, int, char * const []);
extern command_ret_t do_mem_nm_avr(cmd_tbl_t *, int, int, char * const []);
extern command_ret_t do_eep_cp(cmd_tbl_t *, int, int, char * const []);
extern command_ret_t do_busreq_pulse(cmd_tbl_t *, int, int, char * const []);
extern command_ret_t do_date(cmd_tbl_t *, int, int, char * const []);
extern command_ret_t do_gpio(cmd_tbl_t *, int, int, char * const []);
extern command_ret_t do_sd(cmd_tbl_t *, int, int, char * const []);
extern command_ret_t do_fat_stat(cmd_tbl_t *, int, int, char * const []);
extern command_ret_t do_fat_ls(cmd_tbl_t *, int, int, char * const []);
extern command_ret_t do_fat_rw(cmd_tbl_t *, int, int, char * const []);
extern command_ret_t do_run(cmd_tbl_t *, int, int, char * const []);
extern command_ret_t do_source(cmd_tbl_t *, int, int, char * const []);
extern command_ret_t do_attach(cmd_tbl_t *, int, int, char * const []);

#ifdef CONFIG_SYS_LONGHELP
const FLASH char sd_help_text[] =
	"bla \t- do bla\n"
	;
#endif /* CONFIG_SYS_LONGHELP */


cmd_tbl_t cmd_tbl[] = {

CMD_TBL_ITEM(
	date,	2,	1,	do_date,
	"get/set date & time",
	"[MMDDhhmm[[CC]YY][.ss]]\n"
	"  - without arguments: print date & time\n"
	"  - with numeric argument: set the system date & time\n"
),

#ifdef DEBUG

CMD_TBL_ITEM(
	!mdr,	3,	1,	do_dump_mem,
	"RAM dump",
	"address [count]"
),
CMD_TBL_ITEM(
	!mde,	3,	1,	do_dump_mem,
	"EEPROM dump",
	"address [count]"
),
CMD_TBL_ITEM(
	!mdf,	3,	1,	do_dump_mem,
	"FLASH dump",
	"address [count]"
),
CMD_TBL_ITEM(
	!cpe,	4,	0,	do_eep_cp,
	"EEPROM copy",
	"source target count"
),
CMD_TBL_ITEM(
	!mm,	2,	1,	do_mem_mm_avr,
	"avr memory modify (auto-incrementing address)",
	"address"
),
CMD_TBL_ITEM(
	!nm,	2,	1,	do_mem_nm_avr,
	"avr memory modify (constant address)",
	"address"
),
#endif
CMD_TBL_ITEM(
	mstep,	2,	1,	do_busreq_pulse,
	"execute one M cycle",
	"[count]\n"
	"     - repeat count times"
),
CMD_TBL_ITEM(
	echo,	CONFIG_SYS_MAXARGS,	1,	do_echo,
	"display a line of text",
	"[-n] [argument ...]\n"
	"- echo the argument(s) to console.\n"
	"  -n  do not output the trailing newline"
),
CMD_TBL_ITEM(
	sleep ,    2,    1,     do_sleep,
	"delay execution for some time",
	"N[m][s]\n"
	"    - delay execution for decimal N (milli) seconds"
),
CMD_TBL_ITEM_COMPLETE(
	run,	CONFIG_SYS_MAXARGS,	1,	do_run,
	"run commands in an environment variable",
	"var [...]\n"
	"    - run the commands in the environment variable(s) 'var'",
	var_complete
),
CMD_TBL_ITEM_COMPLETE(
	source,	CONFIG_SYS_MAXARGS,	1,	do_source,
	"run commands from a file",
	"filename\n"
	"    - run the commands in the script file 'filename'",
	var_complete
),
CMD_TBL_ITEM_COMPLETE(
	printenv, CONFIG_SYS_MAXARGS,	1,	do_env_print,
	"print environment variables",
	"[-s] [name ...]\n"
	"    Print value of environment variable(s) 'name'\n"
	"    If no names are given, print values of all environment variables\n"
	"    -s Print in setenv form",
	var_complete
),
CMD_TBL_ITEM_COMPLETE(
	setenv, CONFIG_SYS_MAXARGS,	0,	do_env_set,
	"set environment variables",
	"name value ...\n"
	"    - set environment variable 'name' to 'value ...'\n"
	"setenv name\n"
	"    - delete environment variable 'name'",
	var_complete
),
CMD_TBL_ITEM(
	saveenv,	1,	0,	do_env_save,
	"save environment variables to persistent storage",
	""
),
CMD_TBL_ITEM(
	defaultenv,	1,	0,	do_env_default,
	"set all environment variables to their default values",
	""
),

CMD_TBL_ITEM(
	loadf,	1,	0,	do_loadf,
	"load srec_cat prepared image from controller flash",
	""
),
CMD_TBL_ITEM(
	bootcf,	CONFIG_SYS_MAXARGS,	0,	do_bootcf,
	"boot from cf card",
	"[options]\n"
	"    Load a number of sectors from the first CP/M partition and jump to\n"
	"    the load address.\n"
	"    -a ADDRESS\n"
	"            Load and start address (default 100 hex)\n"
	"    -s NUM\n"
	"            First sector of partition to load (0..255, default 0)\n"
	"    -c NUM\n"
	"            Number of sectors to load (1..127, default 7)\n"
	"    -i NUM\n"
	"            Partition type to look for (default 52 hex)\n"
	"    -n\n"
	"            Load only, do not execute\n"
	"    -t NUM\n"
	"            Timeout for IDE commands (1..65535, default 10000)\n"
	"    -v verbose\n"
	"            TODO: be verbose"
),
CMD_TBL_ITEM(
	loadcpm3, 3,	0,	do_loadcpm3,
	"load CPM3.SYS file",
	"[filename [common-base [banked-base]]] \n"
	"    - Load CP/M 3 system file from FAT filesystem. This command makes\n"
	"      CPMLDR superfluous. Uses the following environment variables if set:\n"
	"         '"ENV_CPM3_SYSFILE"' File to load. Default is '"CONFIG_CPM3_SYSFILE"'.\n"
	"         '"ENV_CPM3_BANKED_BASE"' Default is '"CONFIG_CPM3_BANKED_BASE_STR"'.\n"
	"      Sets the following environment variables after loading:\n"
	"         '"ENV_CPM3_COMMON_BASE"'\n"
	"         '"ENV_STARTADDRESS"'"
),
CMD_TBL_ITEM(
	loadi,	2,	0,	do_loadihex,
	"load intel hex file over serial line",
	"[[-]offset]\n"
	"    - load Intel-Hex-Record file over serial line with offset 'offset'"
),

#if defined(CONFIG_CMD_LOADB)
CMD_TBL_ITEM(
	loadb, 1, 0,	do_load_serial_bin,
	"load binary file over serial line (kermit mode)",
	"    - load binary file over serial line"
),

CMD_TBL_ITEM(
	loadx, 1, 0,	do_load_serial_bin,
	"load binary file over serial line (xmodem mode)",
	"    - load binary file over serial line"
),

CMD_TBL_ITEM(
	loady, 1, 0,	do_load_serial_bin,
	"load binary file over serial line (ymodem mode)",
	"    - load binary file over serial line"
),
#endif	/* CONFIG_CMD_LOADB */

CMD_TBL_ITEM(
	go,	2,	0,	do_go,
	"start application at address 'addr'",
	"addr\n"
	"    - start application at address 'addr'"
//	"\n"
//	"      passing 'arg' as arguments"
),
CMD_TBL_ITEM(
	reset,	1,	0,	do_reset,
	"Keep CPU in RESET state",
	""
),
CMD_TBL_ITEM(
	restart, 1, 1,	do_restart,
	"Perform RESET of the CPU",
	""
),
CMD_TBL_ITEM(
	connect, 1, 0,	do_console,
	"Connect to CPU console i/o",
	"\n"
	"    - type the escape character followed by Q to close the connection, \n"
	"      or followed by ? to see other options. The default escape character \n"
	"      is Ctrl-^ (0x1E). It can be changed by setting env var '"ENV_ESC_CHAR"'."

),

CMD_TBL_ITEM(
	pin, CONFIG_SYS_MAXARGS, 1,	do_gpio,
	"Set or query pin state",
	"[-s] [<pins>]\n"
	"    - print cofiguration and state or frequency of pins\n"
	"      print all pins, if argument is omitted\n"
	"pin <pins> h[igh]|l[ow]\n"
	"    - config pins as output and set to level high or low\n"
	"pin <pins> ts|i[n]|p[ullup]\n"
	"    - config pins as input/tristate or input with pullup\n"
	"pin <pins> value[K|M][Hz]\n"
	"    - output a clock on pins\n"
	"      value is system clock divider or frequency, if 'Hz' is appended\n"
	"      divider is rounded down to next possible value (depends on pin)\n"
	"\n"
	"<pins> is a comma separated list of numbers or ranges, i.e. \"0,9,3-6\"\n"
),

CMD_TBL_ITEM(
	md,	3,	1,	do_mem_md,
	"memory display",
	"address [# of objects]"
),
CMD_TBL_ITEM(
	mm,	2,	1,	do_mem_mm,
	"memory modify (auto-incrementing address)",
	"address"
),
CMD_TBL_ITEM(
	nm,	2,	1,	do_mem_nm,
	"memory modify (constant address)",
	"address"
),
CMD_TBL_ITEM(
	mw,	CONFIG_SYS_MAXARGS,	1,	do_mem_mw,
	"memory write (fill)",
	"[-bwl] address value [count]\n"
	"   -b  write value as byte (8 bit, default)\n"
	"   -w  write value as word (16 bit)\n"
	"   -l  write value as long (32 bit)"
),
CMD_TBL_ITEM(
	cp,	4,	1,	do_mem_cp,
	"memory copy",
	"source target count"
),
CMD_TBL_ITEM(
	cmp,	4,	1,	do_mem_cmp,
	"memory compare",
	"addr1 addr2 count"
),
CMD_TBL_ITEM(
	base,	2,	0,	do_mem_base,
	"print or set address offset",
	"\n"
	"    - print address offset for memory commands\n"
	"base offset\n"
	"    - set address offset for memory commands to 'offset'"
),
CMD_TBL_ITEM(
	mloop,	3,	1,	do_mem_loop,
	"infinite loop on address range",
	"address number_of_bytes"
),
CMD_TBL_ITEM(
	mloopw,	4,	1,	do_mem_loopw,
	"infinite write loop on address range",
	"address number_of_bytes data_to_write"
),

#ifdef CONFIG_CMD_MEMTEST
CMD_TBL_ITEM(
	mtest,	4,	1,	do_mem_mtest,
	"simple RAM read/write test",
	"[start [end [iterations]]]"
),
#endif	/* CONFIG_CMD_MEMTEST */

#ifdef CONFIG_MX_CYCLIC
CMD_TBL_ITEM(
	mdc,	4,	1,	do_mem_mdc,
	"memory display cyclic",
	"address count delay(ms)"
),
CMD_TBL_ITEM(
	mwc,	CONFIG_SYS_MAXARGS,	1,	do_mem_mdc,
	"memory write cyclic",
	"[-bwl] address value delay(ms)\n"
	"   -b  write value as byte (8 bit, default)\n"
	"   -w  write value as word (16 bit)\n"
	"   -l  write value as long (32 bit)"
),
#endif /* CONFIG_MX_CYCLIC */

CMD_TBL_ITEM(
	sd,   CONFIG_SYS_MAXARGS, 1, do_sd,
	"SD/MMC card handling commands",
	"<subcommand> args ...\n"
	"sd help\n"
	"    - print help on subcommands"
),

CMD_TBL_ITEM(
	fatstat,	2,	1,	do_fat_stat,
	"Show logical drive status",
	"dev"
),
CMD_TBL_ITEM(
	fatls,	2,	1,	do_fat_ls,
	"Directory listing",
	"path"
),
CMD_TBL_ITEM(
	fatload,	5,	0,	do_fat_rw,
	"load binary file from a dos filesystem",
	"<d:/path/filename> <addr> [bytes [pos]]\n"
	"    - Load binary file 'path/filename' on logical drive 'd'\n"
	"      to address 'addr' from dos filesystem.\n"
	"      'pos' gives the file position to start loading from.\n"
	"      If 'pos' is omitted, 0 is used. 'pos' requires 'bytes'.\n"
	"      'bytes' gives the size to load. If 'bytes' is 0 or omitted,\n"
	"      the load stops on end of file."
),
CMD_TBL_ITEM(
	fatwrite,	4,	0,	do_fat_rw,
	"write file into a dos filesystem",
	"<d:/path/filename> <addr> <bytes>\n"
	"    - Write file to 'path/filename' on logical drive 'd' from RAM\n"
	"      starting at address 'addr'.\n"
),
CMD_TBL_ITEM(
	attach,	CONFIG_SYS_MAXARGS,	1,	do_attach,
	"attach filesystem image file to CP/M drive",
	"[-rw] [-o options] dsk<n> diskfile\n"
	"    Attach diskfile to dsk<n>, where n in 0..7\n"
	"    -r      File is read only (write protected)\n"
	"    -w      File is read/write (default)\n"
	"    -o options\n"
	"            Options is a comma-separated list of\n"
	"            ro, rw, debug, nodebug\n"
	"\n"
	"attach [-rw] -o reattach[,other options] dsk<n>\n"
	"    Change options for dsk<n>.\n"
	"    Options as above.\n"
	"\n"
	"attach -d -a|dsk<n>\n"
	"detach -a|dsk<n>\n"
	"    Detach diskfile from dsk<n>.\n"
	"    -a      Detach all.\n"
	"\n"
	"attach\n"
	"    Without arguments, list current assignments\n"
),
CMD_TBL_ITEM(
	detach,	2,	1,	do_attach,
	"detach file from CP/M drive",
	"dsk<n>]\n"
	"    - alias for 'attach -d dsk<n>'"
),

CMD_TBL_ITEM(
	help,	CONFIG_SYS_MAXARGS,	1,	do_help,
	"print command description/usage",
	"\n"
	"       - print brief description of all commands\n"
	"help command ...\n"
	"       - print detailed usage of 'command'"
),

/* This does not use the CMD_TBL_ITEM macro as ? can't be used in symbol names */
	{FSTR("?"),   CONFIG_SYS_MAXARGS, 1, do_help,
	 FSTR("alias for 'help'"),
#ifdef  CONFIG_SYS_LONGHELP
	FSTR(""),
#endif /* CONFIG_SYS_LONGHELP */
#ifdef CONFIG_AUTO_COMPLETE
	0,
#endif
},
/* Mark end of table */
{ 0 },
};