From patchwork Mon Mar 24 15:51:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 333086 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 357D114008E for ; Tue, 25 Mar 2014 02:53:38 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2628C4B631; Mon, 24 Mar 2014 16:53:36 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id uo9lMKJHHdoD; Mon, 24 Mar 2014 16:53:35 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 69C5F4B601; Mon, 24 Mar 2014 16:53:27 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id ACCD74B5FB for ; Mon, 24 Mar 2014 16:53:20 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7vI5hpNrdP5h for ; Mon, 24 Mar 2014 16:53:17 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-oa0-f74.google.com (mail-oa0-f74.google.com [209.85.219.74]) by theia.denx.de (Postfix) with ESMTPS id 181114B5D6 for ; Mon, 24 Mar 2014 16:53:13 +0100 (CET) Received: by mail-oa0-f74.google.com with SMTP id i7so1050509oag.5 for ; Mon, 24 Mar 2014 08:53:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=DGzJuDfnpNpK/HKiWkoSyhxagU98U2EVcCh2anG5VZY=; b=Y7/Qb19FiBbFZwC4u/QLcD9VRg3jeLsGzSh8cnmlNmhBCLn+SC7eTOrfjBwDU4zeTb 1fc8MCGDDX8pUIsUu25GXZqC6370kJtn7Q4MDg79ePfJrx3pNMCByY5NpC3ENv0z80MQ JtDfI9n854+t2eswkeCjPa5yPooNRjlr3rkLG4tkXsF0tlP583ksYTHOhVsKAsBFEb3g ZYg0W0i6Y5h/BkQkEGl+q2/DqPZ//0pSfI9YBBisuZwHzXeUUxvU2ohoe+/uhFNESsbN tg0pqWOrd8vSxM+VTKI6+VkEfrxjApj6IkyMa0fCpLBo4IJyo4koD8pZmzBkFo56iFOb 1iiw== X-Gm-Message-State: ALoCoQmhzYDjrL2pwdlZKc+x2wxoGkdFnGq6VSxRpXMcS7n7tAqvXrQfA+OH2WO23RpJZXnMdytJKPEWS+aIACFCxi2n2YLVIU0gEYKj2tVS/63zn/5SRILSdkZfvruj2AbyJBzV0LUg8hjyQ7r6OmVG0G4MUj6F2Uoqnm4EIVm30b9rYOdyygJYd8RUHA3ryRIfSnxOxUoz X-Received: by 10.182.213.5 with SMTP id no5mr12640069obc.15.1395676392796; Mon, 24 Mar 2014 08:53:12 -0700 (PDT) Received: from corp2gmr1-2.hot.corp.google.com (corp2gmr1-2.hot.corp.google.com [172.24.189.93]) by gmr-mx.google.com with ESMTPS id k45si1915864yhn.4.2014.03.24.08.53.12 for (version=TLSv1.1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 24 Mar 2014 08:53:12 -0700 (PDT) Received: from kaki.bld.corp.google.com (kaki.bld.corp.google.com [172.29.216.32]) by corp2gmr1-2.hot.corp.google.com (Postfix) with ESMTP id 9E9415A41AE; Mon, 24 Mar 2014 08:53:12 -0700 (PDT) Received: by kaki.bld.corp.google.com (Postfix, from userid 121222) id 340FD220EA6; Mon, 24 Mar 2014 09:53:12 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Mon, 24 Mar 2014 09:51:08 -0600 Message-Id: <1395676271-9040-4-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.9.1.423.g4596e3a In-Reply-To: <1395676271-9040-1-git-send-email-sjg@chromium.org> References: <1395676271-9040-1-git-send-email-sjg@chromium.org> Cc: Tom Rini Subject: [U-Boot] [PATCH 3/6] Add CONFIG_CMDLINE to allow removal of all commands X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de A large chunk of the U-Boot code is the command line. For some applications this is not needed, since the boot can be controlled by a board-specific hard-coded boot procedure. This saves a significant amount of space. This makes U-Boot proper look a little more like SPL in terms of size. Signed-off-by: Simon Glass --- README | 8 ++++++++ arch/x86/cpu/u-boot.lds | 4 ++++ common/cmd_cbfs.c | 3 ++- common/cmd_help.c | 4 ++++ common/command.c | 2 ++ common/main.c | 6 ++++++ include/command.h | 30 ++++++++++++++++++++++++++++++ include/config_defaults.h | 2 ++ include/config_fallbacks.h | 7 +++++++ 9 files changed, 65 insertions(+), 1 deletion(-) diff --git a/README b/README index 216f0c7..28c79fb 100644 --- a/README +++ b/README @@ -1035,6 +1035,14 @@ The following options need to be configured: XXX - this list needs to get updated! +- Removal of commands + If no commands are needed to boot, you can undefine + CONFIG_CMDLINE in your board config file to remove them. + In this case, the command line will not be available, and + when U-Boot wants to execute the boot command (on start-up) + it will call board_run_command() instead. This can reduce + image size significantly for very simple boot procedures. + - Regular expression support: CONFIG_REGEX If this variable is defined, U-Boot is linked against diff --git a/arch/x86/cpu/u-boot.lds b/arch/x86/cpu/u-boot.lds index f48bff5..9720286 100644 --- a/arch/x86/cpu/u-boot.lds +++ b/arch/x86/cpu/u-boot.lds @@ -12,6 +12,10 @@ ENTRY(_start) SECTIONS { +#ifndef CONFIG_CMDLINE + /DISCARD/ : { *(.u_boot_list_2_cmd_*) } +#endif + . = CONFIG_SYS_TEXT_BASE; /* Location of bootcode in flash */ __text_start = .; .text : { *(.text*); } diff --git a/common/cmd_cbfs.c b/common/cmd_cbfs.c index 35d8a7a..5f1add8 100644 --- a/common/cmd_cbfs.c +++ b/common/cmd_cbfs.c @@ -44,7 +44,8 @@ U_BOOT_CMD( " CBFS is in. It defaults to 0xFFFFFFFF\n" ); -int do_cbfs_fsload(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) +static int do_cbfs_fsload(cmd_tbl_t *cmdtp, int flag, int argc, + char *const argv[]) { const struct cbfs_cachenode *file; unsigned long offset; diff --git a/common/cmd_help.c b/common/cmd_help.c index 6ff494d..701ae7e 100644 --- a/common/cmd_help.c +++ b/common/cmd_help.c @@ -10,9 +10,13 @@ static int do_help(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { +#ifdef CONFIG_CMDLINE 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); +#else + return 0; +#endif } U_BOOT_CMD( diff --git a/common/command.c b/common/command.c index 35c9d71..180ce27 100644 --- a/common/command.c +++ b/common/command.c @@ -87,6 +87,7 @@ int _do_help (cmd_tbl_t *cmd_start, int cmd_items, cmd_tbl_t * cmdtp, int */ cmd_tbl_t *find_cmd_tbl (const char *cmd, cmd_tbl_t *table, int table_len) { +#ifdef CONFIG_CMDLINE cmd_tbl_t *cmdtp; cmd_tbl_t *cmdtp_temp = table; /*Init value */ const char *p; @@ -115,6 +116,7 @@ cmd_tbl_t *find_cmd_tbl (const char *cmd, cmd_tbl_t *table, int table_len) if (n_found == 1) { /* exactly one match */ return cmdtp_temp; } +#endif /* CONFIG_CMDLINE */ return NULL; /* not found or ambiguous command */ } diff --git a/common/main.c b/common/main.c index 8b6f274..cb021d3 100644 --- a/common/main.c +++ b/common/main.c @@ -270,7 +270,9 @@ static int abortboot(int bootdelay) #if defined(CONFIG_BOOTDELAY) && defined(CONFIG_OF_CONTROL) static void secure_boot_cmd(char *cmd) { +#ifdef CONFIG_CMDLINE cmd_tbl_t *cmdtp; +#endif int rc; if (!cmd) { @@ -282,6 +284,7 @@ static void secure_boot_cmd(char *cmd) disable_ctrlc(1); /* Find the command directly. */ +#ifdef CONFIG_CMDLINE cmdtp = find_cmd(cmd); if (!cmdtp) { printf("## Error: \"%s\" not defined\n", cmd); @@ -290,6 +293,9 @@ static void secure_boot_cmd(char *cmd) /* Run the command, forcing no flags and faking argc and argv. */ rc = (cmdtp->cmd)(cmdtp, 0, 1, &cmd); +#else + rc = board_run_command(cmd); +#endif /* Shouldn't ever return from boot command. */ printf("## Error: \"%s\" returned (code %d)\n", cmd, rc); diff --git a/include/command.h b/include/command.h index 1a3871f..9f507d9 100644 --- a/include/command.h +++ b/include/command.h @@ -184,6 +184,7 @@ int cmd_process(int flag, int argc, char * const argv[], * * We need to ensure that a command is placed between each entry */ +#ifdef CONFIG_CMDLINE #define U_BOOT_SUBCMD_START(name) static cmd_tbl_t name[] = { #define U_BOOT_SUBCMD_END }; #define U_BOOT_CMD_MKENT_LINE(_name, _maxargs, _rep, _cmd, _usage, \ @@ -203,6 +204,26 @@ int cmd_process(int flag, int argc, char * const argv[], ll_entry_declare(cmd_tbl_t, _name, cmd) = \ U_BOOT_CMD_MKENT_LINE(_name, _maxargs, _rep, _cmd, \ _usage, _help, _comp, _info); +#else +#define U_BOOT_SUBCMD_START(name) static cmd_tbl_t name[] = {}; +#define U_BOOT_SUBCMD_END + +#define _CMD_REMOVE(_name, _cmd) \ + int __remove_ ## _name(void) \ + { \ + if (0) \ + _cmd(NULL, 0, 0, NULL); \ + return 0; \ + } +#define U_BOOT_CMD_MKENT_COMPLETE(_name, _maxargs, _rep, _cmd, _usage, \ + _help, _comp, _info) \ + _CMD_REMOVE(_name ## _cmd, _cmd) + +#define U_BOOT_CMD_COMPLETE(_name, _maxargs, _rep, _cmd, _usage, _help, \ + _comp, _info) \ + _CMD_REMOVE(sub_ ## _name, _cmd) + +#endif /* CONFIG_CMDLINE */ #define U_BOOT_CMD_MKENT(_name, _maxargs, _rep, _cmd, _usage, _help) \ U_BOOT_CMD_MKENT_COMPLETE(_name, _maxargs, _rep, _cmd, \ @@ -223,6 +244,15 @@ static inline int cmd_dummy(cmd_tbl_t *cmdtp, int flag, int argc, return 0; } +/* + * When there is no U-Boot command line, the board must provide a way of + * executing commands. + * + * @cmd: Command string to execute + * @return Result of command, CMD_RET_... + */ +int board_run_command(const char *cmd); + #endif /* __ASSEMBLY__ */ #endif /* __COMMAND_H */ diff --git a/include/config_defaults.h b/include/config_defaults.h index ad08c1d..913acaf 100644 --- a/include/config_defaults.h +++ b/include/config_defaults.h @@ -20,4 +20,6 @@ #define CONFIG_ZLIB 1 #define CONFIG_PARTITIONS 1 +#define CONFIG_CMDLINE + #endif diff --git a/include/config_fallbacks.h b/include/config_fallbacks.h index d8339b2..8b11b54 100644 --- a/include/config_fallbacks.h +++ b/include/config_fallbacks.h @@ -63,4 +63,11 @@ #define CONFIG_SYS_HZ 1000 #endif +#ifndef CONFIG_CMDLINE +#undef CONFIG_CMDLINE_EDITING +#undef CONFIG_SYS_LONGHELP +#undef CONFIG_CMD_RUN +#undef CONFIG_SYS_HUSH_PARSER +#endif + #endif /* __CONFIG_FALLBACKS_H */