xref: /openbmc/u-boot/doc/README.commands (revision 0d4983930a3559be92452761cfa268ee9d0f2773)
1*0d498393Swdenk
2*0d498393SwdenkCommands are added to U-Boot by creating a new command structure.
3*0d498393SwdenkThis is done by first including command.h
4*0d498393Swdenk
5*0d498393SwdenkThen using the U_BOOT_CMD() macro to fill in a cmd_tbl_t struct.
6*0d498393Swdenk
7*0d498393SwdenkU_BOOT_CMD(name,maxargs,repeatable,command,"usage","help")
8*0d498393Swdenk
9*0d498393Swdenkname:	 is the name of the commad. THIS IS NOT a string.
10*0d498393Swdenkmaxargs: the maximumn numbers of arguments this function takes
11*0d498393Swdenkcommand: Function pointer (*cmd)(struct cmd_tbl_s *, int, int, char *[]);
12*0d498393Swdenkusage:	 Short description. This is a string
13*0d498393Swdenkhelp:	 long description. This is a string
14*0d498393Swdenk
15*0d498393Swdenk
16*0d498393Swdenk**** Behinde the scene ******
17*0d498393Swdenk
18*0d498393SwdenkThe structure created is named with a special prefix (__u_boot_cmd_)
19*0d498393Swdenkand placed by the linker in a special section.
20*0d498393Swdenk
21*0d498393SwdenkThis makes it possible for the final link to extract all commands
22*0d498393Swdenkcompiled into any object code and construct a static array so the
23*0d498393Swdenkcommand can be found in an array starting at __u_boot_cmd_start.
24*0d498393Swdenk
25*0d498393SwdenkIf a new board is defined do not forget to define the command section
26*0d498393Swdenkby writing in u-boot.lds ($(TOPDIR)/board/boardname/u-boot.lds) these
27*0d498393Swdenk3 lines:
28*0d498393Swdenk
29*0d498393Swdenk	__u_boot_cmd_start = .;
30*0d498393Swdenk	.u_boot_cmd : { *(.u_boot_cmd) }
31*0d498393Swdenk	__u_boot_cmd_end = .;
32