From patchwork Sat Mar 19 08:18:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 599758 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 3qRw3X2jqSz9s6n for ; Sat, 19 Mar 2016 19:19:04 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b=F17aLHnZ; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 89252A76D4; Sat, 19 Mar 2016 09:19:01 +0100 (CET) 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 CgTcc4omrTxW; Sat, 19 Mar 2016 09:19:01 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id EB100A76CE; Sat, 19 Mar 2016 09:19:00 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A0347A76CE for ; Sat, 19 Mar 2016 09:18:58 +0100 (CET) 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 TRv4RkPIH969 for ; Sat, 19 Mar 2016 09:18:58 +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-ig0-f182.google.com (mail-ig0-f182.google.com [209.85.213.182]) by theia.denx.de (Postfix) with ESMTPS id 2698CA74C5 for ; Sat, 19 Mar 2016 09:18:54 +0100 (CET) Received: by mail-ig0-f182.google.com with SMTP id ig19so54641598igb.0 for ; Sat, 19 Mar 2016 01:18:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id; bh=345ct6sY2T5dEdkFcDyewA7RUI7SurpRqm25lek4qX4=; b=F17aLHnZqLRIGomS3S2YrUJ/W6bN26gwtrkzKs8DTYUvcehA9Tc7ucijGqT04CzfQv 5eUMZgZBvCkKwAQRhtWgDq6r8+hSPwJxcDTb2EapSpW2Yl4WrJ/fWTgpvjd7in4kH0x5 +Pu5fj3Ny+aG0WcTDOF8YAyficwhxZh8Jv8OXCZFfBoIhQ8uO3TXKrmnbDb9vq2szsAo d2VRGZW//voMIJNSUr8xzrNrRY72+0/MgNrJpQN9ZRlAGcoceDgGuQFDaNfmJiph2MMQ tqiHHQFXCIgRiNduIszyv1YZEdU6/N8CKlXpyKXwB1eC11MtaEY2ZHITRMxtcTiY4QuS 85xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=345ct6sY2T5dEdkFcDyewA7RUI7SurpRqm25lek4qX4=; b=QU8RU/g1Ze1v3NkovkMZ+yNrH10AK8SoX6KlGqYlcN2xgt6PO7DN/KApkm+SW8u/+G 7K/EqQmj3/FDS61vLD4YwEA6mtoVpFRWkmjBLauRjHqScR3Y+i1Uj7AZBe1F/FCFfMIK 4mvRnPGHackJPLUH8K7QKAqVwX7cqZ1p8oiwo/b7cQRO62P72xxq+iMhnWzQbgJ/2tJP lh315QqskgroDUpVTpbbedCNNOwqh6+XXREohp1meOBhpjeShqh9+9p2W/b+c4YIaOkr fnCac7zohHBEkICiWhnBUAIbqtv5zcd0J02Otgi2RVejDrmDEUG8w1m93H/xrp9Nfc8e Ddpw== X-Gm-Message-State: AD7BkJJL7+e2tixIxlNgfE/Mb4/I14t4yWdpIEur9mq1XMMNS+jBPVQdfxnos36L5RgGA/hm X-Received: by 10.50.112.101 with SMTP id ip5mr2987615igb.52.1458375533203; Sat, 19 Mar 2016 01:18:53 -0700 (PDT) Received: from kaki.bld.corp.google.com ([172.29.216.32]) by smtp.gmail.com with ESMTPSA id j29sm7367429ioi.31.2016.03.19.01.18.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 19 Mar 2016 01:18:52 -0700 (PDT) Received: by kaki.bld.corp.google.com (Postfix, from userid 121222) id 6161A2209A8; Sat, 19 Mar 2016 02:18:51 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Sat, 19 Mar 2016 02:18:38 -0600 Message-Id: <1458375522-23219-6-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 Cc: Tom Rini , Stephen Warren Subject: [U-Boot] [PATCH v3 5/9] Drop command-processing code when CONFIG_CMDLINE is disabled X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Command parsing and processing code is not needed when the command line is disabled. Remove this code in that case. Signed-off-by: Simon Glass Reviewed-by: Tom Rini --- Changes in v3: - Drop the indentation on the #if...#else...#endif Changes in v2: - Move the board_run_command() prototype into this patch cmd/help.c | 4 ++++ common/cli.c | 17 ++++++++++++++++- common/command.c | 6 ++++++ include/command.h | 18 ++++++++++++++++++ 4 files changed, 44 insertions(+), 1 deletion(-) diff --git a/cmd/help.c b/cmd/help.c index 6ff494d..701ae7e 100644 --- a/cmd/help.c +++ b/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/cli.c b/common/cli.c index 119d282..5e17da8 100644 --- a/common/cli.c +++ b/common/cli.c @@ -18,6 +18,7 @@ DECLARE_GLOBAL_DATA_PTR; +#ifdef CONFIG_CMDLINE /* * Run a command using the selected parser. * @@ -68,6 +69,7 @@ int run_command_repeatable(const char *cmd, int flag) return 0; #endif } +#endif /* CONFIG_CMDLINE */ int run_command_list(const char *cmd, int len, int flag) { @@ -102,7 +104,11 @@ int run_command_list(const char *cmd, int len, int flag) * doing a malloc() which is actually required only in a case that * is pretty rare. */ +#ifdef CONFIG_CMDLINE rcode = cli_simple_run_command_list(buff, flag); +#else + rcode = board_run_command(buff); +#endif #endif if (need_buff) free(buff); @@ -166,7 +172,9 @@ bool cli_process_fdt(const char **cmdp) */ void cli_secure_boot_cmd(const char *cmd) { +#ifdef CONFIG_CMDLINE cmd_tbl_t *cmdtp; +#endif int rc; if (!cmd) { @@ -178,6 +186,7 @@ void cli_secure_boot_cmd(const 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); @@ -187,6 +196,10 @@ void cli_secure_boot_cmd(const char *cmd) /* Run the command, forcing no flags and faking argc and argv. */ rc = (cmdtp->cmd)(cmdtp, 0, 1, (char **)&cmd); +#else + rc = board_run_command(cmd); +#endif + /* Shouldn't ever return from boot command. */ printf("## Error: \"%s\" returned (code %d)\n", cmd, rc); @@ -205,8 +218,10 @@ void cli_loop(void) parse_file_outer(); /* This point is never reached */ for (;;); -#else +#elif defined(CONFIG_CMDINE) cli_simple_loop(); +#else + printf("## U-Boot command line is disabled. Please enable CONFIG_CMDLINE\n"); #endif /*CONFIG_SYS_HUSH_PARSER*/ } diff --git a/common/command.c b/common/command.c index 858e288..e5d9b9c 100644 --- a/common/command.c +++ b/common/command.c @@ -85,6 +85,7 @@ int _do_help(cmd_tbl_t *cmd_start, int cmd_items, cmd_tbl_t *cmdtp, int flag, /* find command table entry for a command */ 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; @@ -111,6 +112,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 */ } @@ -162,6 +164,7 @@ 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[]) { +#ifdef CONFIG_CMDLINE 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; @@ -231,6 +234,9 @@ static int complete_cmdv(int argc, char * const argv[], char last_char, int maxv cmdv[n_found] = NULL; return n_found; +#else + return 0; +#endif } static int make_argv(char *s, int argvsz, char *argv[]) diff --git a/include/command.h b/include/command.h index 0524c0b..0d2b653 100644 --- a/include/command.h +++ b/include/command.h @@ -144,6 +144,24 @@ int cmd_process(int flag, int argc, char * const argv[], int *repeatable, unsigned long *ticks); void fixup_cmdtable(cmd_tbl_t *cmdtp, int size); + +/** + * board_run_command() - Fallback function to execute a command + * + * When no command line features are enabled in U-Boot, this function is + * called to execute a command. Typically the function can look at the + * command and perform a few very specific tasks, such as booting the + * system in a particular way. + * + * This function is only used when CONFIG_CMDLINE is not enabled. + * + * In normal situations this function should not return, since U-Boot will + * simply hang. + * + * @cmdline: Command line string to execute + * @return 0 if OK, 1 for error + */ +int board_run_command(const char *cmdline); #endif /* __ASSEMBLY__ */ /*