From patchwork Fri Dec 22 21:13:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Schulz X-Patchwork-Id: 122666 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp2746358qgn; Fri, 22 Dec 2017 13:18:35 -0800 (PST) X-Google-Smtp-Source: ACJfBotUQ1hSm6h35yTL+ZhKrhXxKx/Zuw1fFdyQ+YQy5Wi/W+WRwMP+nIGItbT9/DaQNgahRoHw X-Received: by 10.80.187.99 with SMTP id y90mr16519814ede.154.1513977515454; Fri, 22 Dec 2017 13:18:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513977515; cv=none; d=google.com; s=arc-20160816; b=qt4YaDb4rzf8ZC5dF7X8gV1jtSOSm57cW+c0EDs1PfwOBun+yDGYJRH2zZO3h1FjTX 3AAT9sRWlJ64pEKQ7a9AYCIfI/xMnaymliOgXSDC/KRDnsShxy9NLcvpgoQ7o8XGYU5v KTT9C7m1NeKevyJnePwddR6+HaN3vfL4YBR4ljKkz0RCCcPmZBShemn3U6SrfRjAiGCH 27fAjcLmtwP2wvBU8klOXGVjBlKf7nbd3siLlPngFB0NuVLXMY+recvstcPtHNm1IbU5 1YKlxxKZiYUGLkoO5WzGWPmlOgyai4gBNKAkvaZtqtXtKROzpBnYrsbrCnMjIR/ztFSj tyZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:references :in-reply-to:message-id:date:to:from:arc-authentication-results; bh=6g69nbvZPZ3amH+JbXV6uYuO0alSK1EU6ohAsDREuns=; b=tezaSaB/kBqJ+V/sU5YNts/BMyHMgMocYpM/kTtd1yQiLgkeWGjAOuQfRwDM+TgUAU gixoqO2H0p8FmTQ8wxGCWdFGdAQAZhgFqgPP4jmhYUuaC8lfZIplysBJ9VJ80OShVvVj FQxP+5X0kWspeA1dEkJSXmOCbYlFPtAyF9G/yz864j2tM3DJWh+pdbwXjqSqUdpzMNNM fq6e13X0cnakcBgQsdlqbum4VcOMVqAefsIw32rkK3XGjo3xq4ugeoCbWgaOgDS6TcP7 o4y+l2tZEAwQxzf82hb/nmPsWicLM2yH15LFqrpVFbr1wj+dsWrzYIEt2dd2NCchvLP1 MK+w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id x3si2476402edc.447.2017.12.22.13.18.35; Fri, 22 Dec 2017 13:18:35 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 091B0C22206; Fri, 22 Dec 2017 21:15:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 8C2D7C21FBE; Fri, 22 Dec 2017 21:14:22 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id CD916C21FF4; Fri, 22 Dec 2017 21:14:16 +0000 (UTC) Received: from mail.free-electrons.com (mail.free-electrons.com [62.4.15.54]) by lists.denx.de (Postfix) with ESMTP id 543BCC21F3F for ; Fri, 22 Dec 2017 21:14:15 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 7211B207F3; Fri, 22 Dec 2017 22:14:14 +0100 (CET) Received: from localhost.localdomain (unknown [80.12.41.248]) by mail.free-electrons.com (Postfix) with ESMTPSA id CD08C203A1; Fri, 22 Dec 2017 22:14:13 +0100 (CET) From: Quentin Schulz To: jagan@openedev.com, maxime.ripard@free-electrons.com, hdegoede@redhat.com, sjg@chromium.org, wd@denx.de, andre.przywara@arm.com, lukma@denx.de Date: Fri, 22 Dec 2017 22:13:38 +0100 Message-Id: <8828c4cb3ae7c387e8381ad1cbe0d29ad1c0e323.1513975247.git-series.quentin.schulz@free-electrons.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: References: In-Reply-To: References: Cc: thomas.petazzoni@free-electrons.com, u-boot@lists.denx.de Subject: [U-Boot] [PATCH 04/11] env: make nowhere an env medium like the others X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" Since we now allow the loading of different environment media by priority, we can mimic the current fallback system with nowhere medium by adding a load function to the nowhere driver (and make it the medium with the lowest priority). Nowhere then becomes a valid environment medium. This also makes it possible to either enforce the value of some variables by using nowhere medium when using it as secondary environment or to completely enforce all the environment variables except a few from a secondary environment when using it as base environment. Signed-off-by: Quentin Schulz --- env/Kconfig | 12 ++---------- env/common.c | 2 +- env/nowhere.c | 8 +++++++- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/env/Kconfig b/env/Kconfig index d57594d..f99a701 100644 --- a/env/Kconfig +++ b/env/Kconfig @@ -2,16 +2,6 @@ menu "Environment" config ENV_IS_NOWHERE bool "Environment is not stored" - depends on !ENV_IS_IN_EEPROM - depends on !ENV_IS_IN_FAT - depends on !ENV_IS_IN_FLASH - depends on !ENV_IS_IN_MMC - depends on !ENV_IS_IN_NAND - depends on !ENV_IS_IN_NVRAM - depends on !ENV_IS_IN_ONENAND - depends on !ENV_IS_IN_REMOTE - depends on !ENV_IS_IN_SPI_FLASH - depends on !ENV_IS_IN_UBI default y help Define this if you don't want to or can't have an environment stored @@ -19,6 +9,8 @@ config ENV_IS_NOWHERE while U-Boot is running, but once U-Boot exits it will not be stored. U-Boot will therefore always start up with a default environment. + When whitelisting is enabled, define this to be able to use the + default environment as either base or secondary environment. config ENV_IS_IN_EEPROM bool "Environment in EEPROM" diff --git a/env/common.c b/env/common.c index 00c454d..c8d8993 100644 --- a/env/common.c +++ b/env/common.c @@ -279,7 +279,7 @@ void env_relocate(void) env_htab.change_ok += gd->reloc_off; #endif if (gd->env_valid == ENV_INVALID) { -#if defined(CONFIG_ENV_IS_NOWHERE) || defined(CONFIG_SPL_BUILD) +#if defined(CONFIG_SPL_BUILD) /* Environment not changable */ set_default_env(NULL); #else diff --git a/env/nowhere.c b/env/nowhere.c index f654883..7a37909 100644 --- a/env/nowhere.c +++ b/env/nowhere.c @@ -15,6 +15,11 @@ DECLARE_GLOBAL_DATA_PTR; +static int env_nowhere_load(void) +{ + return !env_import((char *)default_environment, 0); +} + /* * Because we only ever have the default environment available we must mark * it as invalid. @@ -22,7 +27,7 @@ DECLARE_GLOBAL_DATA_PTR; static int env_nowhere_init(void) { gd->env_addr = (ulong)&default_environment[0]; - gd->env_valid = ENV_INVALID; + gd->env_valid = ENV_VALID; return 0; } @@ -31,4 +36,5 @@ U_BOOT_ENV_LOCATION(nowhere) = { .location = ENVL_NOWHERE, .init = env_nowhere_init, ENV_NAME("nowhere") + .load = env_nowhere_load, };