xref: /openbmc/u-boot/doc/README.commands (revision 6c7c946cadfafdea80eb930e3181085b907a0362)
10d498393Swdenk
20d498393SwdenkCommands are added to U-Boot by creating a new command structure.
300309c67SPeter MeerwaldThis is done by first including command.h, then using the U_BOOT_CMD() macro
400309c67SPeter Meerwaldto fill in a cmd_tbl_t struct.
50d498393Swdenk
60d498393SwdenkU_BOOT_CMD(name,maxargs,repeatable,command,"usage","help")
70d498393Swdenk
80d498393Swdenkname:	 is the name of the commad. THIS IS NOT a string.
900309c67SPeter Meerwaldmaxargs: the maximum number of arguments this function takes
1000309c67SPeter Meerwaldrepeatable: either 0 or 1 to indicate if autorepeat is allowed
110d498393Swdenkcommand: Function pointer (*cmd)(struct cmd_tbl_s *, int, int, char *[]);
120d498393Swdenkusage:	 Short description. This is a string
1300309c67SPeter Meerwaldhelp:	 Long description. This is a string
140d498393Swdenk
150d498393Swdenk
1600309c67SPeter Meerwald**** Behind the scene ******
170d498393Swdenk
18*6c7c946cSMarek VasutThe structure created is named with a special prefix (__u_boot_list_cmd_)
190d498393Swdenkand placed by the linker in a special section.
200d498393Swdenk
210d498393SwdenkThis makes it possible for the final link to extract all commands
220d498393Swdenkcompiled into any object code and construct a static array so the
23*6c7c946cSMarek Vasutcommand can be found in an array starting at _u_boot_list_cmd__start.
240d498393Swdenk
252d1d6583STom RiniTo ensure that the linker does not discard these symbols when linking
262d1d6583STom Rinifull U-Boot we generate a list of all the commands we have built (based
272d1d6583STom Rinion the sections mentioned above) and use that to force the linker to
282d1d6583STom Rinifirst enter the symbol as undefined in the output object so that there
292d1d6583STom Riniis then a need for the symbol to be kept (this is the UNDEF_SYM logic in
302d1d6583STom Rinithe Makefile).
312d1d6583STom Rini
320d498393SwdenkIf a new board is defined do not forget to define the command section
330d498393Swdenkby writing in u-boot.lds ($(TOPDIR)/board/boardname/u-boot.lds) these
340d498393Swdenk3 lines:
350d498393Swdenk
36*6c7c946cSMarek Vasut	.u_boot_list : {
37*6c7c946cSMarek Vasut	#include "u-boot.lst";
38*6c7c946cSMarek Vasut	}
39