From patchwork Sun Feb 6 18:37:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Francis Laniel X-Patchwork-Id: 1589023 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.a=rsa-sha256 header.s=google header.b=fbRq8p/C; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JsJ3f691Nz9s1l for ; Mon, 7 Feb 2022 05:39:58 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E38F483BFB; Sun, 6 Feb 2022 19:38:17 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.b="fbRq8p/C"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 00A9183BE2; Sun, 6 Feb 2022 19:38:10 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 8DFD983BE7 for ; Sun, 6 Feb 2022 19:37:47 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=francis.laniel@amarulasolutions.com Received: by mail-wm1-x333.google.com with SMTP id j5-20020a05600c1c0500b0034d2e956aadso7178860wms.4 for ; Sun, 06 Feb 2022 10:37:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kOp0XNWtDKnbPbuI3fyPrCPhrRgRFS7FYw1IRhJrvEU=; b=fbRq8p/C5Uj0DQihxHm1Oj2OrbUv5IIeWH9CFsogYyNkvUKx9WP21+sKtzWT5UKU0z Pkb3CMk+iPzdt4vx3BytSvEG8TI2DsYlzrcUDfgicA96JFHjY57TdOBoLzlBiAqjzVHW KJ4P5SHZSkbVmmw9X/vbhtW7xV6hurH8jwEZg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kOp0XNWtDKnbPbuI3fyPrCPhrRgRFS7FYw1IRhJrvEU=; b=ER3uMyqVV5MEgXUsm6ufxFtyt5aPzi46f3hb+aU0D6zmDhnT5+HWdLNlg6sc86VvD4 zB+Yy5EBvalaRE+ex0uzdLQgclTTYYvTOBS7l1l0/fMWSTnufdU4sVvC94LcsXchzr8S ogWwbB483cPkVm4+IuQ14IiWX3Qgx7c/P985WMXS9Rn6683b39nJMTuzpr2bRHgkmAEN 7w3twfoUwWte5aVlwGIn5cSlb6lm9uB8jnP5i2fsngLv3IK9Bsypkemkc+QMEoSLmG0t rHN03rgcw9LI28S0Ut4Jy6Yzl5CC/PJ2R5qBE+7ZbzTGhE1QDXXbWLG+zZ8511XaWpo3 sZFw== X-Gm-Message-State: AOAM532Le+vUElRs7AVEWzQFfK6T1KSrJO1w7nRgVV5xF70ubnL4DcgW HDrJTFEnl0nFDLf3HniaNnAZ7hiI9nUy5g== X-Google-Smtp-Source: ABdhPJyLJszP2P2QaaTwRwrqwKcSHOj8sjAdeBzB9IYkIy+gNZmSfPiszKJw9C+oFhLgOoPQcFdStA== X-Received: by 2002:a05:600c:1911:: with SMTP id j17mr7736722wmq.143.1644172667231; Sun, 06 Feb 2022 10:37:47 -0800 (PST) Received: from pwmachine.home ([2a01:cb14:983:1f00:e5b3:218b:cb92:2549]) by smtp.gmail.com with ESMTPSA id ay29sm7095011wmb.38.2022.02.06.10.37.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Feb 2022 10:37:46 -0800 (PST) From: Francis Laniel To: u-boot@lists.denx.de Cc: Marek Behun , Michael Nazzareno Trimarchi , Simon Glass , Wolfgang Denk , Harald Seiler , Francis Laniel Subject: [RFC PATCH v2 11/21] cli: Enables using hush 2021 parser as command line parser Date: Sun, 6 Feb 2022 19:37:07 +0100 Message-Id: <20220206183717.57446-12-francis.laniel@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220206183717.57446-1-francis.laniel@amarulasolutions.com> References: <20220206183717.57446-1-francis.laniel@amarulasolutions.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean If one defines HUSH_2021_PARSER, cli_loop() will jump on hush 2021 parser code. Signed-off-by: Francis Laniel Reviewed-by: Simon Glass --- common/cli.c | 14 +++++++++++--- include/cli_hush.h | 8 ++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/common/cli.c b/common/cli.c index d86046a728..090677f7a0 100644 --- a/common/cli.c +++ b/common/cli.c @@ -40,12 +40,15 @@ int run_command(const char *cmd, int flag) return 1; return 0; -#else +#elif CONFIG_IS_ENABLED(HUSH_OLD_PARSER) int hush_flags = FLAG_PARSE_SEMICOLON | FLAG_EXIT_FROM_LOOP; if (flag & CMD_FLAG_ENV) hush_flags |= FLAG_CONT_ON_NEWLINE; return parse_string_outer(cmd, hush_flags); +#else /* HUSH_2021_PARSER */ + /* Not yet implemented. */ + return 0; #endif } @@ -104,7 +107,7 @@ int run_command_list(const char *cmd, int len, int flag) memcpy(buff, cmd, len); buff[len] = '\0'; } -#ifdef CONFIG_HUSH_PARSER +#if CONFIG_IS_ENABLED(HUSH_OLD_PARSER) rcode = parse_string_outer(buff, FLAG_PARSE_SEMICOLON); #else /* @@ -225,7 +228,12 @@ err: void cli_loop(void) { bootstage_mark(BOOTSTAGE_ID_ENTER_CLI_LOOP); -#ifdef CONFIG_HUSH_PARSER +#if CONFIG_IS_ENABLED(HUSH_2021_PARSER) + parse_and_run_file(); + printf("Problem\n"); + /* This point is never reached */ + for (;;); +#elif CONFIG_IS_ENABLED(CONFIG_HUSH_OLD_PARSER) parse_file_outer(); /* This point is never reached */ for (;;); diff --git a/include/cli_hush.h b/include/cli_hush.h index 2bd35670c7..f6c04929b9 100644 --- a/include/cli_hush.h +++ b/include/cli_hush.h @@ -14,9 +14,17 @@ extern int u_boot_hush_start(void); extern int parse_string_outer(const char *, int); +#if CONFIG_IS_ENABLED(HUSH_OLD_PARSER) extern int parse_file_outer(void); +#elif CONFIG_IS_ENABLED(HUSH_2021_PARSER) +extern void parse_and_run_file(void); +#endif +#if CONFIG_IS_ENABLED(HUSH_OLD_PARSER) int set_local_var(const char *s, int flg_export); +#elif CONFIG_IS_ENABLED(HUSH_2021_PARSER) +int set_local_var(char *s, int flg_export); +#endif void unset_local_var(const char *name); char *get_local_var(const char *s);