From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c0c::22a; helo=mail-wr0-x22a.google.com; envelope-from=leif.lindholm@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x22a.google.com (mail-wr0-x22a.google.com [IPv6:2a00:1450:400c:c0c::22a]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id BD93C2035BB1B for ; Fri, 17 Nov 2017 08:06:40 -0800 (PST) Received: by mail-wr0-x22a.google.com with SMTP id y42so2550389wrd.3 for ; Fri, 17 Nov 2017 08:10:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=H6rkTdeUEOT7TQvwT9ublzWGpd8t0Pz0ypfTdeu7/Wk=; b=HD1P9Ag+RKlI6JpxMiWVa1SGvDQ/wmZppuvR+jHLnLdpzTc5H7SGFix4JdyMm4j0kv sPVTIiTt8YZAKDbhWEnga7v5iTxfP0DncdMuNa9P4fmXUXqyGd0rxzN/5e+QF73OPhrV fUFi++Uww5Os2d1UPG6HGmy/8ASIXZIEOsRtg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=H6rkTdeUEOT7TQvwT9ublzWGpd8t0Pz0ypfTdeu7/Wk=; b=lttWnwpjaGh4SN0zy32SOyvnj+LL3/lEUfdtPJ1eLdiz/zvBgWRqHAAG8DU+ZEO6nR zMOHFm0ZiAZQUX39AuzXk2SwwPp92dWso+aWSvZy+1IxCxR4eBJhsGnWr5/1LuSncFua zJZuhW4Mu+KcAJmMVDB1VWIJC7sT1MgV469ZRSqxGYnca6jECbvaythysGnWFj49ybjf eAjg0AFvgggvW+ennHnEg20QjbCJY9MYTx3DoNXwLabPLNoCFgMzeQacHYKO5AoTlz7k wvTWkjMDVWFjb45CQOv0J5vXiaDr5rFVhmqCpX3nS70skeMeFmUopbsMxgVnu/TZdb5H 7gjA== X-Gm-Message-State: AJaThX6I5/va0oAhmLhuHgj9abzd+XT/Qi9yXj3q5OPhMR/rbPUCaizf M4edqsyEiyqlw8eEdtH/40HBkQ== X-Google-Smtp-Source: AGs4zMbxFHDzwXSAhkky14mCOt73OhyKctuAZyzZZWlT9Rvk9AhGpybWqTINvdAV3p/8Mxvai/zJ4A== X-Received: by 10.223.145.166 with SMTP id 35mr4619433wri.51.1510935050181; Fri, 17 Nov 2017 08:10:50 -0800 (PST) Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id n64sm5163888wmd.36.2017.11.17.08.10.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 17 Nov 2017 08:10:48 -0800 (PST) Date: Fri, 17 Nov 2017 16:10:47 +0000 From: Leif Lindholm To: Ard Biesheuvel Cc: edk2-devel@lists.01.org, daniel.thompson@linaro.org, masami.hiramatsu@linaro.org, methavanitpong.pipat@socionext.com, masahisa.kojima@linaro.org Message-ID: <20171117161046.uaxf4qhjzkdupzd5@bivouac.eciton.net> References: <20171110142127.12018-1-ard.biesheuvel@linaro.org> <20171110142127.12018-30-ard.biesheuvel@linaro.org> MIME-Version: 1.0 In-Reply-To: <20171110142127.12018-30-ard.biesheuvel@linaro.org> User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [PATCH edk2-platforms v4 29/34] Silicon/SynQuacer: implement 'clear NVRAM' feature using a DIP switch X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Nov 2017 16:06:41 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, Nov 10, 2017 at 02:21:22PM +0000, Ard Biesheuvel wrote: > Ordinary computers typically have a physical switch or jumper on the > board that allows non-volatile settings to be cleared. Let's implement > the same using DIP switch #1 on block #3, and clear the EFI variable > store if it is set to ON at boot time. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ard Biesheuvel > --- > Platform/Socionext/DeveloperBox/DeveloperBox.dsc | 4 ++++ > Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc | 4 ++++ > Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf | 1 + > Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformPeiLib/SynQuacerPlatformPeiLib.c | 25 +++++++++++++++++++- > Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformPeiLib/SynQuacerPlatformPeiLib.inf | 6 +++++ > Silicon/Socionext/SynQuacer/SynQuacer.dec | 2 ++ > 6 files changed, 41 insertions(+), 1 deletion(-) > > diff --git a/Platform/Socionext/DeveloperBox/DeveloperBox.dsc b/Platform/Socionext/DeveloperBox/DeveloperBox.dsc > index 10d070773cdc..af978db2c034 100644 > --- a/Platform/Socionext/DeveloperBox/DeveloperBox.dsc > +++ b/Platform/Socionext/DeveloperBox/DeveloperBox.dsc > @@ -381,6 +381,9 @@ [PcdsFixedAtBuild.common] > gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorId|0x4f524e4c # LNRO > gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorRevision|1 > > + # set DIP switch DSW3-PIN1 to clear the varstore > + gSynQuacerTokenSpaceGuid.PcdClearSettingsGpioPin|0 > + Right, so could you change this value to 1 ... > [PcdsPatchableInModule] > gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution|0 > gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution|0 > @@ -418,6 +421,7 @@ [Components.common] > MdeModulePkg/Universal/FaultTolerantWritePei/FaultTolerantWritePei.inf > MdeModulePkg/Universal/Variable/Pei/VariablePei.inf > MdeModulePkg/Universal/CapsulePei/CapsulePei.inf > + Silicon/Socionext/SynQuacer/Drivers/SynQuacerGpioPei/SynQuacerGpioPei.inf > MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf { > > NULL|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf > diff --git a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc > index 4630d78bce93..4034bcfe82c5 100644 > --- a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc > +++ b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc > @@ -369,6 +369,9 @@ [PcdsFixedAtBuild.common] > gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0x08420000 > gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize|0x00010000 > > + # set DIP switch DSW3-PIN1 to clear the varstore > + gSynQuacerTokenSpaceGuid.PcdClearSettingsGpioPin|0 > + > [PcdsPatchableInModule] > gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution|0 > gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution|0 > @@ -406,6 +409,7 @@ [Components.common] > MdeModulePkg/Universal/FaultTolerantWritePei/FaultTolerantWritePei.inf > MdeModulePkg/Universal/Variable/Pei/VariablePei.inf > MdeModulePkg/Universal/CapsulePei/CapsulePei.inf > + Silicon/Socionext/SynQuacer/Drivers/SynQuacerGpioPei/SynQuacerGpioPei.inf > MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf { > > NULL|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf > diff --git a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf > index 365085c8f243..4577bd316a1f 100644 > --- a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf > +++ b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf > @@ -248,6 +248,7 @@ [FV.FVMAIN_COMPACT] > INF MdeModulePkg/Universal/FaultTolerantWritePei/FaultTolerantWritePei.inf > INF MdeModulePkg/Universal/Variable/Pei/VariablePei.inf > INF MdeModulePkg/Universal/CapsulePei/CapsulePei.inf > + INF Silicon/Socionext/SynQuacer/Drivers/SynQuacerGpioPei/SynQuacerGpioPei.inf > INF RuleOverride = FMP_IMAGE_DESC Platform/Socionext/SynQuacerEvalBoard/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf > INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf > > diff --git a/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformPeiLib/SynQuacerPlatformPeiLib.c b/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformPeiLib/SynQuacerPlatformPeiLib.c > index 358dd5a91f08..bd8ee7a368f5 100644 > --- a/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformPeiLib/SynQuacerPlatformPeiLib.c > +++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformPeiLib/SynQuacerPlatformPeiLib.c > @@ -21,6 +21,7 @@ > #include > #include > #include > +#include > #include > > STATIC > @@ -103,10 +104,32 @@ PlatformPeim ( > VOID > ) > { > - EFI_STATUS Status; > + EMBEDDED_GPIO_PPI *Gpio; > + EFI_STATUS Status; > + UINTN Value; And use a local variable Pin, initialized to FixedPcdGet32 (PcdClearSettingsGpioPin) - 1? (You could then also have an assert verifying PcdClearSettingsGpioPin != 0, to make fallback to default value flash warnings.) > > ASSERT (mDramInfo->NumRegions > 0); > > + Status = PeiServicesLocatePpi (&gEdkiiEmbeddedGpioPpiGuid, 0, NULL, > + (VOID **)&Gpio); > + ASSERT_EFI_ERROR (Status); > + > + Status = Gpio->Set (Gpio, FixedPcdGet32 (PcdClearSettingsGpioPin), > + GPIO_MODE_INPUT); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_WARN, "%a: failed to set GPIO as input - %r\n", __FUNCTION__, > + Status)); > + } else { > + Status = Gpio->Get (Gpio, FixedPcdGet32 (PcdClearSettingsGpioPin), &Value); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_WARN, "%a: failed to get GPIO state - %r\n", __FUNCTION__, > + Status)); > + } else if (Value > 0) { > + DEBUG ((DEBUG_INFO, "%a: clearing NVRAM\n", __FUNCTION__)); > + PeiServicesSetBootMode (BOOT_WITH_DEFAULT_SETTINGS); > + } > + } > + > // > // Record the first region into PcdSystemMemoryBase and PcdSystemMemorySize. > // This is the region we will use for UEFI itself. > diff --git a/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformPeiLib/SynQuacerPlatformPeiLib.inf b/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformPeiLib/SynQuacerPlatformPeiLib.inf > index 70eb715d44e3..a6501fb205e1 100644 > --- a/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformPeiLib/SynQuacerPlatformPeiLib.inf > +++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformPeiLib/SynQuacerPlatformPeiLib.inf > @@ -25,6 +25,7 @@ [Sources] > > [Packages] > ArmPkg/ArmPkg.dec > + EmbeddedPkg/EmbeddedPkg.dec > MdePkg/MdePkg.dec > MdeModulePkg/MdeModulePkg.dec > Silicon/Socionext/SynQuacer/SynQuacer.dec > @@ -40,11 +41,16 @@ [LibraryClasses] > [FixedPcd] > gArmTokenSpaceGuid.PcdFvBaseAddress > gArmTokenSpaceGuid.PcdFvSize > + gSynQuacerTokenSpaceGuid.PcdClearSettingsGpioPin > gSynQuacerTokenSpaceGuid.PcdDramInfoBase > > [Ppis] > + gEdkiiEmbeddedGpioPpiGuid ## CONSUMES > gSynQuacerDramInfoPpiGuid ## PRODUCES > > [Pcd] > gArmTokenSpaceGuid.PcdSystemMemoryBase > gArmTokenSpaceGuid.PcdSystemMemorySize > + > +[Depex] > + gEdkiiEmbeddedGpioPpiGuid > diff --git a/Silicon/Socionext/SynQuacer/SynQuacer.dec b/Silicon/Socionext/SynQuacer/SynQuacer.dec > index 1a683b81521b..c11550469cd0 100644 > --- a/Silicon/Socionext/SynQuacer/SynQuacer.dec > +++ b/Silicon/Socionext/SynQuacer/SynQuacer.dec > @@ -30,3 +30,5 @@ [PcdsFixedAtBuild] > > gSynQuacerTokenSpaceGuid.PcdNetsecEepromBase|0|UINT32|0x00000002 > gSynQuacerTokenSpaceGuid.PcdNetsecPhyAddress|0|UINT8|0x00000003 > + > + gSynQuacerTokenSpaceGuid.PcdClearSettingsGpioPin|0|UINT32|0x00000004 And add a small comment for this line that this refers to block 3 and 0 means "don't use"? / Leif