summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arch/arm/imx-common/cmd_bmode.c11
-rw-r--r--arch/avr32/lib/board.c4
-rw-r--r--arch/m68k/lib/board.c4
-rw-r--r--arch/mips/lib/board.c4
-rw-r--r--arch/nds32/lib/board.c4
-rw-r--r--arch/sparc/lib/board.c4
-rw-r--r--common/cmd_help.c8
-rw-r--r--common/command.c17
-rw-r--r--doc/README.commands10
-rw-r--r--include/command.h26
10 files changed, 50 insertions, 42 deletions
diff --git a/arch/arm/imx-common/cmd_bmode.c b/arch/arm/imx-common/cmd_bmode.c
index 02fe72e..ddc14b0 100644
--- a/arch/arm/imx-common/cmd_bmode.c
+++ b/arch/arm/imx-common/cmd_bmode.c
@@ -24,6 +24,7 @@
#include <asm/io.h>
#include <asm/imx-common/boot_mode.h>
#include <malloc.h>
+#include <command.h>
static const struct boot_mode *modes[2];
@@ -103,9 +104,11 @@ void add_board_boot_modes(const struct boot_mode *p)
int size;
char *dest;
- if (__u_boot_cmd_bmode.usage) {
- free(__u_boot_cmd_bmode.usage);
- __u_boot_cmd_bmode.usage = NULL;
+ cmd_tbl_t *entry = ll_entry_get(cmd_tbl_t, bmode, cmd);
+
+ if (entry->usage) {
+ free(entry->usage);
+ entry->usage = NULL;
}
modes[0] = p;
@@ -114,6 +117,6 @@ void add_board_boot_modes(const struct boot_mode *p)
dest = malloc(size);
if (dest) {
create_usage(dest);
- __u_boot_cmd_bmode.usage = dest;
+ entry->usage = dest;
}
}
diff --git a/arch/avr32/lib/board.c b/arch/avr32/lib/board.c
index 9d3b76e..e3287c4 100644
--- a/arch/avr32/lib/board.c
+++ b/arch/avr32/lib/board.c
@@ -272,8 +272,8 @@ void board_init_r(gd_t *new_gd, ulong dest_addr)
/*
* We have to relocate the command table manually
*/
- fixup_cmdtable(&__u_boot_cmd_start,
- (ulong)(&__u_boot_cmd_end - &__u_boot_cmd_start));
+ fixup_cmdtable(ll_entry_start(cmd_tbl_t, cmd),
+ ll_entry_count(cmd_tbl_t, cmd));
#endif /* defined(CONFIG_NEEDS_MANUAL_RELOC) */
/* there are some other pointer constants we must deal with */
diff --git a/arch/m68k/lib/board.c b/arch/m68k/lib/board.c
index 92f935b..02d73fd 100644
--- a/arch/m68k/lib/board.c
+++ b/arch/m68k/lib/board.c
@@ -416,8 +416,8 @@ void board_init_r (gd_t *id, ulong dest_addr)
/*
* We have to relocate the command table manually
*/
- fixup_cmdtable(&__u_boot_cmd_start,
- (ulong)(&__u_boot_cmd_end - &__u_boot_cmd_start));
+ fixup_cmdtable(ll_entry_start(cmd_tbl_t, cmd),
+ ll_entry_count(cmd_tbl_t, cmd));
#endif /* defined(CONFIG_NEEDS_MANUAL_RELOC) */
/* there are some other pointer constants we must deal with */
diff --git a/arch/mips/lib/board.c b/arch/mips/lib/board.c
index b14b33e..7ddd778 100644
--- a/arch/mips/lib/board.c
+++ b/arch/mips/lib/board.c
@@ -266,8 +266,8 @@ void board_init_r(gd_t *id, ulong dest_addr)
/*
* We have to relocate the command table manually
*/
- fixup_cmdtable(&__u_boot_cmd_start,
- (ulong)(&__u_boot_cmd_end - &__u_boot_cmd_start));
+ fixup_cmdtable(ll_entry_start(cmd_tbl_t, cmd),
+ ll_entry_count(cmd_tbl_t, cmd));
#endif /* defined(CONFIG_NEEDS_MANUAL_RELOC) */
/* there are some other pointer constants we must deal with */
diff --git a/arch/nds32/lib/board.c b/arch/nds32/lib/board.c
index 875f220..91395ca 100644
--- a/arch/nds32/lib/board.c
+++ b/arch/nds32/lib/board.c
@@ -320,8 +320,8 @@ void board_init_r(gd_t *id, ulong dest_addr)
/*
* We have to relocate the command table manually
*/
- fixup_cmdtable(&__u_boot_cmd_start,
- (ulong)(&__u_boot_cmd_end - &__u_boot_cmd_start));
+ fixup_cmdtable(ll_entry_start(cmd_tbl_t, cmd),
+ ll_entry_count(cmd_tbl_t, cmd));
#endif /* defined(CONFIG_NEEDS_MANUAL_RELOC) */
serial_initialize();
diff --git a/arch/sparc/lib/board.c b/arch/sparc/lib/board.c
index ff0e0f2..32d025a 100644
--- a/arch/sparc/lib/board.c
+++ b/arch/sparc/lib/board.c
@@ -246,8 +246,8 @@ void board_init_f(ulong bootflag)
/*
* We have to relocate the command table manually
*/
- fixup_cmdtable(&__u_boot_cmd_start,
- (ulong)(&__u_boot_cmd_end - &__u_boot_cmd_start));
+ fixup_cmdtable(ll_entry_start(cmd_tbl_t, cmd),
+ ll_entry_count(cmd_tbl_t, cmd));
#endif /* defined(CONFIG_NEEDS_MANUAL_RELOC) */
#if defined(CONFIG_CMD_AMBAPP) && defined(CONFIG_SYS_AMBAPP_PRINT_ON_STARTUP)
diff --git a/common/cmd_help.c b/common/cmd_help.c
index 8c8178e..3178a1a 100644
--- a/common/cmd_help.c
+++ b/common/cmd_help.c
@@ -26,9 +26,9 @@
int do_help(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
{
- return _do_help(&__u_boot_cmd_start,
- &__u_boot_cmd_end - &__u_boot_cmd_start,
- cmdtp, flag, argc, argv);
+ cmd_tbl_t *start = ll_entry_start(cmd_tbl_t, cmd);
+ const int len = ll_entry_count(cmd_tbl_t, cmd);
+ return _do_help(start, len, cmdtp, flag, argc, argv);
}
U_BOOT_CMD(
@@ -41,7 +41,7 @@ U_BOOT_CMD(
);
/* This does not use the U_BOOT_CMD macro as ? can't be used in symbol names */
-cmd_tbl_t __u_boot_cmd_question_mark Struct_Section = {
+ll_entry_declare(cmd_tbl_t, question_mark, cmd, cmd) = {
"?", CONFIG_SYS_MAXARGS, 1, do_help,
"alias for 'help'",
#ifdef CONFIG_SYS_LONGHELP
diff --git a/common/command.c b/common/command.c
index aa0fb0a..50c8429 100644
--- a/common/command.c
+++ b/common/command.c
@@ -137,8 +137,9 @@ cmd_tbl_t *find_cmd_tbl (const char *cmd, cmd_tbl_t *table, int table_len)
cmd_tbl_t *find_cmd (const char *cmd)
{
- int len = &__u_boot_cmd_end - &__u_boot_cmd_start;
- return find_cmd_tbl(cmd, &__u_boot_cmd_start, len);
+ cmd_tbl_t *start = ll_entry_start(cmd_tbl_t, cmd);
+ const int len = ll_entry_count(cmd_tbl_t, cmd);
+ return find_cmd_tbl(cmd, start, len);
}
int cmd_usage(const cmd_tbl_t *cmdtp)
@@ -181,7 +182,9 @@ int var_complete(int argc, char * const argv[], char last_char, int maxv, char *
static int complete_cmdv(int argc, char * const argv[], char last_char, int maxv, char *cmdv[])
{
- cmd_tbl_t *cmdtp;
+ cmd_tbl_t *cmdtp = ll_entry_start(cmd_tbl_t, cmd);
+ const int count = ll_entry_count(cmd_tbl_t, cmd);
+ const cmd_tbl_t *cmdend = cmdtp + count;
const char *p;
int len, clen;
int n_found = 0;
@@ -195,12 +198,12 @@ static int complete_cmdv(int argc, char * const argv[], char last_char, int maxv
if (argc == 0) {
/* output full list of commands */
- for (cmdtp = &__u_boot_cmd_start; cmdtp != &__u_boot_cmd_end; cmdtp++) {
+ for (; cmdtp != cmdend; cmdtp++) {
if (n_found >= maxv - 2) {
- cmdv[n_found++] = "...";
+ cmdv[n_found] = "...";
break;
}
- cmdv[n_found++] = cmdtp->name;
+ cmdv[n_found] = cmdtp->name;
}
cmdv[n_found] = NULL;
return n_found;
@@ -228,7 +231,7 @@ static int complete_cmdv(int argc, char * const argv[], char last_char, int maxv
len = p - cmd;
/* return the partial matches */
- for (cmdtp = &__u_boot_cmd_start; cmdtp != &__u_boot_cmd_end; cmdtp++) {
+ for (; cmdtp != cmdend; cmdtp++) {
clen = strlen(cmdtp->name);
if (clen < len)
diff --git a/doc/README.commands b/doc/README.commands
index 125f077..923418b 100644
--- a/doc/README.commands
+++ b/doc/README.commands
@@ -15,12 +15,12 @@ help: Long description. This is a string
**** Behind the scene ******
-The structure created is named with a special prefix (__u_boot_cmd_)
+The structure created is named with a special prefix (__u_boot_list_cmd_)
and placed by the linker in a special section.
This makes it possible for the final link to extract all commands
compiled into any object code and construct a static array so the
-command can be found in an array starting at __u_boot_cmd_start.
+command can be found in an array starting at _u_boot_list_cmd__start.
To ensure that the linker does not discard these symbols when linking
full U-Boot we generate a list of all the commands we have built (based
@@ -33,6 +33,6 @@ If a new board is defined do not forget to define the command section
by writing in u-boot.lds ($(TOPDIR)/board/boardname/u-boot.lds) these
3 lines:
- __u_boot_cmd_start = .;
- .u_boot_cmd : { *(.u_boot_cmd) }
- __u_boot_cmd_end = .;
+ .u_boot_list : {
+ #include "u-boot.lst";
+ }
diff --git a/include/command.h b/include/command.h
index 1f06aa1..24864d5 100644
--- a/include/command.h
+++ b/include/command.h
@@ -28,6 +28,7 @@
#define __COMMAND_H
#include <config.h>
+#include <linker_lists.h>
#ifndef NULL
#define NULL 0
@@ -153,9 +154,6 @@ int cmd_process(int flag, int argc, char * const argv[],
#define CMD_FLAG_REPEAT 0x0001 /* repeat last command */
#define CMD_FLAG_BOOTD 0x0002 /* command is from bootd */
-#define Struct_Section __attribute__((unused, section(".u_boot_cmd"), \
- aligned(4)))
-
#ifdef CONFIG_AUTO_COMPLETE
# define _CMD_COMPLETE(x) x,
#else
@@ -167,18 +165,22 @@ int cmd_process(int flag, int argc, char * const argv[],
# define _CMD_HELP(x)
#endif
-#define U_BOOT_CMD_MKENT_COMPLETE(name,maxargs,rep,cmd,usage,help,comp) \
- {#name, maxargs, rep, cmd, usage, _CMD_HELP(help) _CMD_COMPLETE(comp)}
+#define U_BOOT_CMD_MKENT_COMPLETE(_name, _maxargs, _rep, _cmd, \
+ _usage, _help, _comp) \
+ { #_name, _maxargs, _rep, _cmd, _usage, \
+ _CMD_HELP(_help) _CMD_COMPLETE(_comp) }
-#define U_BOOT_CMD_MKENT(name,maxargs,rep,cmd,usage,help) \
- U_BOOT_CMD_MKENT_COMPLETE(name,maxargs,rep,cmd,usage,help,NULL)
+#define U_BOOT_CMD_MKENT(_name, _maxargs, _rep, _cmd, _usage, _help) \
+ U_BOOT_CMD_MKENT_COMPLETE(_name, _maxargs, _rep, _cmd, \
+ _usage, _help, NULL)
-#define U_BOOT_CMD_COMPLETE(name,maxargs,rep,cmd,usage,help,comp) \
- cmd_tbl_t __u_boot_cmd_##name Struct_Section = \
- U_BOOT_CMD_MKENT_COMPLETE(name,maxargs,rep,cmd,usage,help,comp)
+#define U_BOOT_CMD_COMPLETE(_name, _maxargs, _rep, _cmd, _usage, _help, _comp) \
+ ll_entry_declare(cmd_tbl_t, _name, cmd, cmd) = \
+ U_BOOT_CMD_MKENT_COMPLETE(_name, _maxargs, _rep, _cmd, \
+ _usage, _help, _comp);
-#define U_BOOT_CMD(name,maxargs,rep,cmd,usage,help) \
- U_BOOT_CMD_COMPLETE(name,maxargs,rep,cmd,usage,help,NULL)
+#define U_BOOT_CMD(_name, _maxargs, _rep, _cmd, _usage, _help) \
+ U_BOOT_CMD_COMPLETE(_name, _maxargs, _rep, _cmd, _usage, _help, NULL)
#if defined(CONFIG_NEEDS_MANUAL_RELOC)
void fixup_cmdtable(cmd_tbl_t *cmdtp, int size);