From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4864:20::d41; helo=mail-io1-xd41.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-io1-xd41.google.com (mail-io1-xd41.google.com [IPv6:2607:f8b0:4864:20::d41]) (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 5DCD3211D35F0 for ; Mon, 4 Mar 2019 07:23:09 -0800 (PST) Received: by mail-io1-xd41.google.com with SMTP id k21so4212952ior.13 for ; Mon, 04 Mar 2019 07:23:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=XWzf1C91447z8MQytoYdUrBlQ/OjkXRcKxL7MpMeT0o=; b=Bdo7W210GkdVtAhJepRlJ6KeZba4bO2V+0ADwAoOB9L1pwrA/AddEuOUa5DdUhiCgB NH4+bkIo+BAyizMcf05/MrW/LpospJIau/ZTkc9Pn/fRDDcB5qzbdcpPw1Zx9V3p0utf Ah9HbVaXB4Qq57VbjaAUd2Ggcy1kPGe8/y0kcWzRB32s6BeYPGq81YUwvf/HKzBlXMWr rmaUHYFzxJ2Wk7NqorjJ4jKSkWXsEHato0F5R86oqEjOx76kfA9drMYuXwyKxWZsO/Mx Tfna77vzdmLLOaHmuiDxTLMNUYif7qoLH5xfyLzdFGS/oxww9OI21Eib/orJiRy+Zq+c WTUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=XWzf1C91447z8MQytoYdUrBlQ/OjkXRcKxL7MpMeT0o=; b=ZZM2HRx0kLGgr8G0Skqr59Y+dTvjwmqZrrbSCPD47bStqaCfN0D26MU8uTx6HidFJR bcgxm2JdSbPKi1cNkXiA55Nc4ils5xjTcA9lP1mKyvnhVqpcykd6PC0SBl7o4FO6Hjlm pDf4rfI/vIWVL4eRycDv56JCQp20mbEI3G8RCyZjYtWrKeLWf9xsu1ygDqUoJ07rX+8Y L4i/iI85ccdy2dVLdEns6ZwEPaw60EdWkMDWJP6FZ05hVWv9QilgE9YYy7GeXnbzfPro 4hHh/eGGHvcswn8mTjX1smKxP8cTGj0zd3o8z6Blj3vYshD1eWqqb2UEOnBphPi1ABFO xF9g== X-Gm-Message-State: APjAAAVbyagV9/fLafd52a05yhsOIeCwxVN1bPoIe7QruYgUqEX4kZBU TPoYyJNjY1Z8QDYSqS83OGaTAq7nw7CfUK2Dhdkp+A== X-Google-Smtp-Source: APXvYqyEixHvOqGDHn8+US+uVWrSjwa979CksVDlp90K/L5jZy+AUhh5eZEemO+8rWo9OOz84j250toiASAkhIDEEJg= X-Received: by 2002:a5e:d609:: with SMTP id w9mr9612126iom.170.1551712988046; Mon, 04 Mar 2019 07:23:08 -0800 (PST) MIME-Version: 1.0 References: <1551694313-23594-1-git-send-email-jagadeesh.ujja@arm.com> <1551694313-23594-3-git-send-email-jagadeesh.ujja@arm.com> In-Reply-To: <1551694313-23594-3-git-send-email-jagadeesh.ujja@arm.com> From: Ard Biesheuvel Date: Mon, 4 Mar 2019 16:22:56 +0100 Message-ID: To: Jagadeesh Ujja Cc: "edk2-devel@lists.01.org" , Leif Lindholm Subject: Re: [PATCH edk2-platforms 2/3] Platform/ARM/Sgi: allow MM_STANDALONE modules to use NorFlashPlatformLib X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Mar 2019 15:23:09 -0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, 4 Mar 2019 at 11:12, Jagadeesh Ujja wrote: > > =E2=80=9CNorFlashPlatformLib=E2=80=9D library can be used by MM_STANDALON= E drivers as > well. When used in MM mode, the third instance of the NOR flash is used a= s > the non-volatile storage. This NOR flash instance is partitioned into > two regions - first 4MB space is used for secure boot and next 3MB for > secure variable storage > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Jagadeesh Ujja > --- > Platform/ARM/SgiPkg/Library/NorFlashLib/StandaloneMmNorFlashLib.c | 63= ++++++++++++++++++++ > Platform/ARM/SgiPkg/Library/NorFlashLib/StandaloneMmNorFlashLib.inf | 35= +++++++++++ > 2 files changed, 98 insertions(+) > > diff --git a/Platform/ARM/SgiPkg/Library/NorFlashLib/StandaloneMmNorFlash= Lib.c b/Platform/ARM/SgiPkg/Library/NorFlashLib/StandaloneMmNorFlashLib.c > new file mode 100644 > index 0000000..06e3f97 > --- /dev/null > +++ b/Platform/ARM/SgiPkg/Library/NorFlashLib/StandaloneMmNorFlashLib.c > @@ -0,0 +1,63 @@ > +/** @file > + > + Copyright (c) 2019, ARM Ltd. All rights reserved. > + > + This program and the accompanying materials are licensed and made avai= lable > + under the terms and conditions of the BSD License which accompanies th= is > + distribution. The full text of the license may be found at > + http://opensource.org/licenses/bsd-license.php > + > + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, > + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR I= MPLIED. > + > + **/ > + > +#include > +#include > +#include > +#include > +#include > + > +STATIC NOR_FLASH_DESCRIPTION mNorFlashDevices[] =3D { > + { > + // Secure Boot storage space of 4MB > + SGI_EXP_SMC_CS2_BASE, > + SGI_EXP_SMC_CS2_BASE, > + SIZE_256KB * 16, > + SIZE_256KB, > + }, > + { > + //Secure variable storage space of 1MB*3 > + SGI_EXP_SMC_CS2_BASE, > + SGI_EXP_SMC_CS2_BASE + SIZE_256KB * 16, > + SIZE_256KB * 12, > + SIZE_256KB, > + }, > +}; > + > +EFI_STATUS > +NorFlashPlatformInitialization ( > + VOID > + ) > +{ > + UINT64 SysRegFlash; > + > + SysRegFlash =3D SGI_EXP_SYSPH_SYSTEM_REGISTERS + SGI_SYSPH_SYS_REG_FLA= SH; > + MmioOr32 (SysRegFlash, SGI_SYSPH_SYS_REG_FLASH_RWEN); > + return EFI_SUCCESS; > +} > + > +EFI_STATUS > +NorFlashPlatformGetDevices ( > + OUT NOR_FLASH_DESCRIPTION **NorFlashDevices, > + OUT UINT32 *Count > + ) > +{ > + if ((NorFlashDevices =3D=3D NULL) || (Count =3D=3D NULL)) { > + return EFI_INVALID_PARAMETER; > + } > + > + *NorFlashDevices =3D mNorFlashDevices; > + *Count =3D ARRAY_SIZE (mNorFlashDevices); > + return EFI_SUCCESS; > +} > diff --git a/Platform/ARM/SgiPkg/Library/NorFlashLib/StandaloneMmNorFlash= Lib.inf b/Platform/ARM/SgiPkg/Library/NorFlashLib/StandaloneMmNorFlashLib.i= nf > new file mode 100644 > index 0000000..eedfacc > --- /dev/null > +++ b/Platform/ARM/SgiPkg/Library/NorFlashLib/StandaloneMmNorFlashLib.inf > @@ -0,0 +1,35 @@ > +#/** @file > +# > +# Copyright (c) 2019, ARM Ltd. All rights reserved. > + > +# This program and the accompanying materials are licensed and made ava= ilable > +# under the terms and conditions of the BSD License which accompanies t= his > +# distribution. The full text of the license may be found at > +# http://opensource.org/licenses/bsd-license.php > +# > +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, > +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR = IMPLIED. > +# > +#**/ > + > +[Defines] > + INF_VERSION =3D 0x0001001A > + BASE_NAME =3D NorFlashSgiLib > + FILE_GUID =3D 2ce22190-b933-4d1e-99ba-8bf1f076825= 5 > + MODULE_TYPE =3D MM_STANDALONE Could this be BASE ? > + VERSION_STRING =3D 1.0 > + PI_SPECIFICATION_VERSION =3D 0x00010032 Can we drop this? > + LIBRARY_CLASS =3D NorFlashPlatformLib > + > +[Sources.common] > + StandaloneMmNorFlashLib.c > + > +[Packages] > + ArmPlatformPkg/ArmPlatformPkg.dec > + MdePkg/MdePkg.dec > + Platform/ARM/SgiPkg/SgiPlatform.dec > + > +[LibraryClasses] > + BaseLib > + DebugLib > + IoLib > -- > 2.7.4 >