README.commands 1.31 KB
Newer Older
1 2

Commands are added to U-Boot by creating a new command structure.
Peter Meerwald's avatar
Peter Meerwald committed
3 4
This is done by first including command.h, then using the U_BOOT_CMD() macro
to fill in a cmd_tbl_t struct.
5 6 7 8

U_BOOT_CMD(name,maxargs,repeatable,command,"usage","help")

name:	 is the name of the commad. THIS IS NOT a string.
Peter Meerwald's avatar
Peter Meerwald committed
9 10
maxargs: the maximum number of arguments this function takes
repeatable: either 0 or 1 to indicate if autorepeat is allowed
11 12
command: Function pointer (*cmd)(struct cmd_tbl_s *, int, int, char *[]);
usage:	 Short description. This is a string
Peter Meerwald's avatar
Peter Meerwald committed
13
help:	 Long description. This is a string
14 15


Peter Meerwald's avatar
Peter Meerwald committed
16
**** Behind the scene ******
17

18 19 20
The structure created is named with a special prefix and placed by
the linker in a special section using the linker lists mechanism
(see include/linker_lists.h)
21 22 23

This makes it possible for the final link to extract all commands
compiled into any object code and construct a static array so the
24
command array can be iterated over using the linker lists macros.
25

26 27 28
The linker lists feature ensures that the linker does not discard
these symbols when linking full U-Boot even though they are not
referenced in the source code as such.
29

30
If a new board is defined do not forget to define the command section
31
by writing in u-boot.lds ($(srctree)/board/boardname/u-boot.lds) these
32 33
3 lines:

34
	.u_boot_list : {
35
		KEEP(*(SORT(.u_boot_list*)));
36
	}