wdenk | 0d49839 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 1 | |
| 2 | Commands are added to U-Boot by creating a new command structure. |
Peter Meerwald | 00309c6 | 2012-02-08 05:31:52 +0000 | [diff] [blame] | 3 | This is done by first including command.h, then using the U_BOOT_CMD() macro |
| 4 | to fill in a cmd_tbl_t struct. |
wdenk | 0d49839 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 5 | |
| 6 | U_BOOT_CMD(name,maxargs,repeatable,command,"usage","help") |
| 7 | |
| 8 | name: is the name of the commad. THIS IS NOT a string. |
Peter Meerwald | 00309c6 | 2012-02-08 05:31:52 +0000 | [diff] [blame] | 9 | maxargs: the maximum number of arguments this function takes |
| 10 | repeatable: either 0 or 1 to indicate if autorepeat is allowed |
wdenk | 0d49839 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 11 | command: Function pointer (*cmd)(struct cmd_tbl_s *, int, int, char *[]); |
| 12 | usage: Short description. This is a string |
Peter Meerwald | 00309c6 | 2012-02-08 05:31:52 +0000 | [diff] [blame] | 13 | help: Long description. This is a string |
wdenk | 0d49839 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 14 | |
| 15 | |
Peter Meerwald | 00309c6 | 2012-02-08 05:31:52 +0000 | [diff] [blame] | 16 | **** Behind the scene ****** |
wdenk | 0d49839 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 17 | |
Albert ARIBAUD | ef123c5 | 2013-02-25 00:59:00 +0000 | [diff] [blame] | 18 | The structure created is named with a special prefix and placed by |
| 19 | the linker in a special section using the linker lists mechanism |
| 20 | (see include/linker_lists.h) |
wdenk | 0d49839 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 21 | |
| 22 | This makes it possible for the final link to extract all commands |
| 23 | compiled into any object code and construct a static array so the |
Albert ARIBAUD | ef123c5 | 2013-02-25 00:59:00 +0000 | [diff] [blame] | 24 | command array can be iterated over using the linker lists macros. |
wdenk | 0d49839 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 25 | |
Albert ARIBAUD | ef123c5 | 2013-02-25 00:59:00 +0000 | [diff] [blame] | 26 | The linker lists feature ensures that the linker does not discard |
| 27 | these symbols when linking full U-Boot even though they are not |
| 28 | referenced in the source code as such. |
Tom Rini | 2d1d658 | 2012-09-20 06:02:43 +0000 | [diff] [blame] | 29 | |
wdenk | 0d49839 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 30 | If a new board is defined do not forget to define the command section |
| 31 | by writing in u-boot.lds ($(TOPDIR)/board/boardname/u-boot.lds) these |
| 32 | 3 lines: |
| 33 | |
Marek Vasut | 6c7c946 | 2012-10-12 10:27:04 +0000 | [diff] [blame] | 34 | .u_boot_list : { |
Albert ARIBAUD | ef123c5 | 2013-02-25 00:59:00 +0000 | [diff] [blame] | 35 | KEEP(*(SORT(.u_boot_list*))); |
Marek Vasut | 6c7c946 | 2012-10-12 10:27:04 +0000 | [diff] [blame] | 36 | } |