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 180d498393SwdenkThe structure created is named with a special prefix (__u_boot_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 230d498393Swdenkcommand can be found in an array starting at __u_boot_cmd_start. 240d498393Swdenk 25*2d1d6583STom RiniTo ensure that the linker does not discard these symbols when linking 26*2d1d6583STom Rinifull U-Boot we generate a list of all the commands we have built (based 27*2d1d6583STom Rinion the sections mentioned above) and use that to force the linker to 28*2d1d6583STom Rinifirst enter the symbol as undefined in the output object so that there 29*2d1d6583STom Riniis then a need for the symbol to be kept (this is the UNDEF_SYM logic in 30*2d1d6583STom Rinithe Makefile). 31*2d1d6583STom 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 360d498393Swdenk __u_boot_cmd_start = .; 370d498393Swdenk .u_boot_cmd : { *(.u_boot_cmd) } 380d498393Swdenk __u_boot_cmd_end = .; 39