1*4882a593Smuzhiyun 2*4882a593SmuzhiyunCommands are added to U-Boot by creating a new command structure. 3*4882a593SmuzhiyunThis is done by first including command.h, then using the U_BOOT_CMD() macro 4*4882a593Smuzhiyunto fill in a cmd_tbl_t struct. 5*4882a593Smuzhiyun 6*4882a593SmuzhiyunU_BOOT_CMD(name,maxargs,repeatable,command,"usage","help") 7*4882a593Smuzhiyun 8*4882a593Smuzhiyunname: is the name of the commad. THIS IS NOT a string. 9*4882a593Smuzhiyunmaxargs: the maximum number of arguments this function takes 10*4882a593Smuzhiyunrepeatable: either 0 or 1 to indicate if autorepeat is allowed 11*4882a593Smuzhiyuncommand: Function pointer (*cmd)(struct cmd_tbl_s *, int, int, char *[]); 12*4882a593Smuzhiyunusage: Short description. This is a string 13*4882a593Smuzhiyunhelp: Long description. This is a string 14*4882a593Smuzhiyun 15*4882a593Smuzhiyun 16*4882a593Smuzhiyun**** Behind the scene ****** 17*4882a593Smuzhiyun 18*4882a593SmuzhiyunThe structure created is named with a special prefix and placed by 19*4882a593Smuzhiyunthe linker in a special section using the linker lists mechanism 20*4882a593Smuzhiyun(see include/linker_lists.h) 21*4882a593Smuzhiyun 22*4882a593SmuzhiyunThis makes it possible for the final link to extract all commands 23*4882a593Smuzhiyuncompiled into any object code and construct a static array so the 24*4882a593Smuzhiyuncommand array can be iterated over using the linker lists macros. 25*4882a593Smuzhiyun 26*4882a593SmuzhiyunThe linker lists feature ensures that the linker does not discard 27*4882a593Smuzhiyunthese symbols when linking full U-Boot even though they are not 28*4882a593Smuzhiyunreferenced in the source code as such. 29*4882a593Smuzhiyun 30*4882a593SmuzhiyunIf a new board is defined do not forget to define the command section 31*4882a593Smuzhiyunby writing in u-boot.lds ($(srctree)/board/boardname/u-boot.lds) these 32*4882a593Smuzhiyun3 lines: 33*4882a593Smuzhiyun 34*4882a593Smuzhiyun .u_boot_list : { 35*4882a593Smuzhiyun KEEP(*(SORT(.u_boot_list*))); 36*4882a593Smuzhiyun } 37