From patchwork Tue Oct 25 11:43:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 686426 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3t3BBP3DSPz9t37 for ; Tue, 25 Oct 2016 22:43:57 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3t3BBP2NlbzDvkF for ; Tue, 25 Oct 2016 22:43:57 +1100 (AEDT) X-Original-To: slof@lists.ozlabs.org Delivered-To: slof@lists.ozlabs.org Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3t3BBJ0fYNzDvjh for ; Tue, 25 Oct 2016 22:43:52 +1100 (AEDT) Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6FB898F237; Tue, 25 Oct 2016 11:43:50 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-116-28.ams2.redhat.com [10.36.116.28]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u9PBhkiJ013786; Tue, 25 Oct 2016 07:43:49 -0400 From: Thomas Huth To: slof@lists.ozlabs.org Date: Tue, 25 Oct 2016 13:43:44 +0200 Message-Id: <1477395825-6930-2-git-send-email-thuth@redhat.com> In-Reply-To: <1477395825-6930-1-git-send-email-thuth@redhat.com> References: <1477395825-6930-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 25 Oct 2016 11:43:50 +0000 (UTC) Subject: [SLOF] [PATCH 1/2] envvar: Set properties in /options during "(set-defaults)" X-BeenThere: slof@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Patches for https://github.com/aik/SLOF" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "SLOF" The properties in /options are currently only populated from the NVRAM common partition or if the user explicitely sets and environment variable with "setenv". This causes two problems: 1) The properties in /options are not reset when the user runs the "set-defaults" Forth word, e.g. like this: setenv auto-boot? false dev /options printenv auto-boot? s" auto-boot?" get-node get-property drop type set-defaults printenv auto-boot? s" auto-boot?" get-node get-property drop type After the "set-defaults", the property in /options has the wrong value and is not in sync with the environment variable anymore. 2) If the common NVRAM partition is not containing all the required variables, SLOF currently also does not create default values in /options for the missing entries. This causes problems for example when we want to initialize the NVRAM from QEMU instead (to support the "-prom-env" parameter of QEMU). Boot loaders like grub2 depend on the availability of certain properties in the /options node and thus refuse to work if the NVRAM did not contain all the variables. To fix both issues, let's always populate the /options properties during "(set-default)" already. Signed-off-by: Thomas Huth Reviewed-by: Nikunj A Dadhania --- slof/fs/envvar.fs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/slof/fs/envvar.fs b/slof/fs/envvar.fs index 3364313..4a4d237 100644 --- a/slof/fs/envvar.fs +++ b/slof/fs/envvar.fs @@ -186,12 +186,16 @@ DEFER old-emit \ set envvar(s) to default value : (set-default) ( def-xt -- ) - dup >name name>string $CREATE dup >body c@ >r execute r> CASE - 1 OF env-int ENDOF - 2 OF env-bytes ENDOF - 3 OF env-string ENDOF - 4 OF env-flag ENDOF - 5 OF env-secmode ENDOF ENDCASE + dup >name name>string 2dup $CREATE + rot dup >body c@ >r + execute + r> CASE + 1 OF dup env-int (.d) 2swap set-option ENDOF + 2 OF 2dup env-bytes 2swap set-option ENDOF + 3 OF 2dup env-string 2swap set-option ENDOF + 4 OF dup env-flag IF s" true" ELSE s" false" THEN 2swap set-option ENDOF + 5 OF dup env-secmode (.d) 2swap set-option ENDOF + ENDCASE ; \ Environment variables might be board specific