From patchwork Fri Apr 11 02:01:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 338328 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 A305B140076 for ; Fri, 11 Apr 2014 12:04:58 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E85E74B69C; Fri, 11 Apr 2014 04:04:23 +0200 (CEST) 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 XSO3GZl3dgmY; Fri, 11 Apr 2014 04:04:23 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E68F54B69E; Fri, 11 Apr 2014 04:03:11 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B18864B66E for ; Fri, 11 Apr 2014 04:02:49 +0200 (CEST) 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 NjWOVQoOLBUI for ; Fri, 11 Apr 2014 04:02:44 +0200 (CEST) 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-pd0-f202.google.com (mail-pd0-f202.google.com [209.85.192.202]) by theia.denx.de (Postfix) with ESMTPS id 6FBDE4B674 for ; Fri, 11 Apr 2014 04:02:29 +0200 (CEST) Received: by mail-pd0-f202.google.com with SMTP id fp1so626099pdb.3 for ; Thu, 10 Apr 2014 19:02:28 -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=iNWW1M2YcVU3lfsy6Bm8CFD58Fk5RkUKp/Ad13sRL3o=; b=gHXofqfB4iTEmLzisaP/Lb0fhUlhK6sycSoxHMR12xRCiQilJYxU3g/HHGwWCzT0XN XUHbcg0QhREhXgHc/2T2S2gBmTGFJv4TXW6sotpg7mSrd6Fjk8t9U4gE8VyPzoAoLU7R wcI3vda7lyqV4xBrbs9N1z35YYuY1m6d0kzm6SB3IolrnUdwLWTqU9I4z4YUOiDi2J5F KumO3xRP50xL1NzKAPI85awa8J0moaoHJ1cUXv0pGC8neu/1Xle3tf4byBYrSD8IaqgD Mojbv7NehzOA+MZJMp6lN6DOlGyzG9qRQi9g/68jk9QiRVqqvbMbZDrudm9Rmg8TqNTJ /GJg== X-Gm-Message-State: ALoCoQlQmXBu54ydJ2pM4MY80UL+Lms80hig45pNALEiIdbBSX8tny7v4DWan0EGcHHixyVrqEMYQZjbG1ma7GXWj03D4xL/6ZSU7Qa8OE9zT8iHW7Pnxos0wXpSpfTtryhEJp101AHFhjRvtJuJS8+zzm6tbBruq6ELE+VTkMetc/dgqf4cfHhUOuIPUhw8uhyegQEt3Iho X-Received: by 10.66.141.231 with SMTP id rr7mr9476870pab.47.1397181748294; Thu, 10 Apr 2014 19:02:28 -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 f65si943539yhg.7.2014.04.10.19.02.28 for (version=TLSv1.1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 10 Apr 2014 19:02:28 -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 255EA5A4217; Thu, 10 Apr 2014 19:02:28 -0700 (PDT) Received: by kaki.bld.corp.google.com (Postfix, from userid 121222) id C8D6F220D67; Thu, 10 Apr 2014 20:02:27 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Thu, 10 Apr 2014 20:01:34 -0600 Message-Id: <1397181696-7271-13-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.9.1.423.g4596e3a In-Reply-To: <1397181696-7271-1-git-send-email-sjg@chromium.org> References: <1397181696-7271-1-git-send-email-sjg@chromium.org> Cc: Tom Rini Subject: [U-Boot] [PATCH 12/14] main: Hide the hush/simple details inside cli.c 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 Move these details from main (which doesn't care which parser is used) to cli.c where they belong. Signed-off-by: Simon Glass --- common/cli.c | 22 ++++++++++++++++++++++ common/cli_simple.c | 2 +- common/main.c | 16 ++-------------- include/cli.h | 13 ++++++++++++- 4 files changed, 37 insertions(+), 16 deletions(-) diff --git a/common/cli.c b/common/cli.c index 9cf7ba1..4ac9b3f 100644 --- a/common/cli.c +++ b/common/cli.c @@ -104,3 +104,25 @@ int do_run(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return 0; } #endif + +void cli_loop(void) +{ +#ifdef CONFIG_SYS_HUSH_PARSER + parse_file_outer(); + /* This point is never reached */ + for (;;); +#else + cli_simple_loop(); +#endif /*CONFIG_SYS_HUSH_PARSER*/ +} + +void cli_init(void) +{ +#ifdef CONFIG_SYS_HUSH_PARSER + u_boot_hush_start(); +#endif + +#if defined(CONFIG_HUSH_INIT_VAR) + hush_init_var(); +#endif +} diff --git a/common/cli_simple.c b/common/cli_simple.c index bba586e..413c2eb 100644 --- a/common/cli_simple.c +++ b/common/cli_simple.c @@ -256,7 +256,7 @@ int cli_simple_run_command(const char *cmd, int flag) return rc ? rc : repeatable; } -void cli_loop(void) +void cli_simple_loop(void) { static char lastcommand[CONFIG_SYS_CBSIZE] = { 0, }; diff --git a/common/main.c b/common/main.c index d95e5fc..12f6ac4 100644 --- a/common/main.c +++ b/common/main.c @@ -10,7 +10,6 @@ #include #include #include -#include #include #include @@ -65,13 +64,7 @@ void main_loop(void) setenv("ver", version_string); /* set version variable */ #endif /* CONFIG_VERSION_VARIABLE */ -#ifdef CONFIG_SYS_HUSH_PARSER - u_boot_hush_start(); -#endif - -#if defined(CONFIG_HUSH_INIT_VAR) - hush_init_var(); -#endif + cli_init(); run_preboot_environment_command(); @@ -83,11 +76,6 @@ void main_loop(void) /* * Main Loop for Monitor Command Processing */ -#ifdef CONFIG_SYS_HUSH_PARSER - parse_file_outer(); - /* This point is never reached */ - for (;;); -#else + cli_loop(); -#endif /*CONFIG_SYS_HUSH_PARSER*/ } diff --git a/include/cli.h b/include/cli.h index 10dbc66..5158976 100644 --- a/include/cli.h +++ b/include/cli.h @@ -14,7 +14,7 @@ * This will return if we get a timeout waiting for a command. See * CONFIG_BOOT_RETRY_TIME. */ -void cli_loop(void); +void cli_simple_loop(void); /** * cli_simple_run_command() - Execute a command with the simple CLI @@ -100,6 +100,17 @@ int cli_readline_into_buffer(const char *const prompt, char *buffer, */ int cli_simple_parse_line(char *line, char *argv[]); +/** + * Go into the command loop + * + * This will return if we get a timeout waiting for a command, but only for + * the simple parser (not hush). See CONFIG_BOOT_RETRY_TIME. + */ +void cli_loop(void); + +/** Set up the command line interpreter ready for action */ +void cli_init(void); + #define endtick(seconds) (get_ticks() + (uint64_t)(seconds) * get_tbclk()) #endif