public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Sami Mujawar" <sami.mujawar@arm.com>
To: Sayanta Pattanayak <sayanta.pattanayak@arm.com>, devel@edk2.groups.io
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>, nd@arm.com
Subject: Re: [edk2-platforms][PATCH V1 2/3] Platform/Sgi: add StandaloneMM usable NorFlashPlatformLib
Date: Tue, 25 May 2021 14:57:08 +0100	[thread overview]
Message-ID: <6698738e-5183-24ea-9978-fb16fc2d47dc@arm.com> (raw)
In-Reply-To: <20210524172300.28754-3-sayanta.pattanayak@arm.com>

Hi Sayanta,

I have a minor suggestion maked inline as [SAMI].

Otherwise this patch looks good to me.

With that addressed.

Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>

Regards,

Sami Mujawar

On 24/05/2021 06:22 PM, Sayanta Pattanayak wrote:
> Add the NorFlashPlatformLib library instance that can be linked with
> MM_STANDALONE modules that implement a secure variable storage. The
> third instance of the NOR flash is used as the non-volatile storage.
>
> Signed-off-by: Sayanta Pattanayak <sayanta.pattanayak@arm.com>
> ---
>   Platform/ARM/SgiPkg/SgiPlatform.dec                                 |  1 +
>   Platform/ARM/SgiPkg/Library/NorFlashLib/StandaloneMmNorFlashLib.inf | 33 ++++++++
>   Platform/ARM/SgiPkg/Library/NorFlashLib/StandaloneMmNorFlashLib.c   | 82 ++++++++++++++++++++
>   3 files changed, 116 insertions(+)
>
> diff --git a/Platform/ARM/SgiPkg/SgiPlatform.dec b/Platform/ARM/SgiPkg/SgiPlatform.dec
> index 3effd49592ea..af08ed153eae 100644
> --- a/Platform/ARM/SgiPkg/SgiPlatform.dec
> +++ b/Platform/ARM/SgiPkg/SgiPlatform.dec
> @@ -54,6 +54,7 @@
>   
>     gArmSgiTokenSpaceGuid.PcdSmcCs0Base|0|UINT64|0x0000000C
>     gArmSgiTokenSpaceGuid.PcdSmcCs1Base|0|UINT64|0x0000000D
> +  gArmSgiTokenSpaceGuid.PcdSmcCs2Base|0|UINT64|0x00001000
>     gArmSgiTokenSpaceGuid.PcdSysPeriphBase|0x00000000|UINT64|0x0000000E
>     gArmSgiTokenSpaceGuid.PcdSysPeriphSysRegBase|0x0|UINT64|0x0000000F
>   
> diff --git a/Platform/ARM/SgiPkg/Library/NorFlashLib/StandaloneMmNorFlashLib.inf b/Platform/ARM/SgiPkg/Library/NorFlashLib/StandaloneMmNorFlashLib.inf
> new file mode 100644
> index 000000000000..96bbf1e42313
> --- /dev/null
> +++ b/Platform/ARM/SgiPkg/Library/NorFlashLib/StandaloneMmNorFlashLib.inf
> @@ -0,0 +1,33 @@
> +## @file
> +#  StandaloneMM instance of NOR Flash library.
> +#
> +#  Copyright (c) 2021, ARM Limited. All rights reserved.
> +#  SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +[Defines]
> +  INF_VERSION                    = 0x0001001A
> +  BASE_NAME                      = NorFlashMmLib
> +  FILE_GUID                      = 2ce22190-b933-4d1e-99ba-8bf1f0768255
> +  MODULE_TYPE                    = MM_STANDALONE
> +  VERSION_STRING                 = 1.0
> +  PI_SPECIFICATION_VERSION       = 0x00010032
> +  LIBRARY_CLASS                  = NorFlashPlatformLib
> +
> +[Sources.common]
> +  StandaloneMmNorFlashLib.c
> +
> +[Packages]
> +  ArmPlatformPkg/ArmPlatformPkg.dec
> +  MdePkg/MdePkg.dec
> +  Platform/ARM/SgiPkg/SgiPlatform.dec
> +
> +[LibraryClasses]
> +  BaseLib
> +  DebugLib
> +  IoLib
> +
> +[FixedPcd]
> +  gArmSgiTokenSpaceGuid.PcdSysPeriphSysRegBase
> +  gArmSgiTokenSpaceGuid.PcdSmcCs2Base
> diff --git a/Platform/ARM/SgiPkg/Library/NorFlashLib/StandaloneMmNorFlashLib.c b/Platform/ARM/SgiPkg/Library/NorFlashLib/StandaloneMmNorFlashLib.c
> new file mode 100644
> index 000000000000..3e5a5612c17e
> --- /dev/null
> +++ b/Platform/ARM/SgiPkg/Library/NorFlashLib/StandaloneMmNorFlashLib.c
> @@ -0,0 +1,82 @@
> +/** @file
> +* NOR flash platform library to be used in StandaloneMM context
> +*
> +* This file provides platform callbacks for the NOR flash module that executes
> +* in the StandaloneMM context. The third NOR flash instance of 64MB size on the
> +* reference design platform is assigned to be used in the StandaloneMM context.
> +*
> +* Copyright (c) 2021, ARM Ltd. All rights reserved.
> +*
> +* SPDX-License-Identifier: BSD-2-Clause-Patent
> +*
> +**/
> +
> +#include <Library/DebugLib.h>
> +#include <Library/IoLib.h>
> +#include <Library/NorFlashPlatformLib.h>
> +#include <PiMm.h>
> +#include <SgiPlatform.h>
> +
> +//
> +// 64MB NOR flash connected to CS2 is assigned to be used in StandaloneMM
> +// context.
> +//
> +STATIC NOR_FLASH_DESCRIPTION mNorFlashDevices[] = {
[SAMI] Minor - Can we add the CONST qualifier?
> +  {
> +    // NOR-Flash2 assigned for secure storage.
> +    FixedPcdGet64 (PcdSmcCs2Base),
> +    FixedPcdGet64 (PcdSmcCs2Base),
> +    SIZE_256KB * 256,
> +    SIZE_256KB,
> +  },
> +};
> +
> +/** Allow access to NOR flash
> +
> +  On the reference design platforms, the access to NOR flash has to be
> +  explicitly permitted by writing to the FLASH_RWEN bit of the SYSPH_SYS_REG
> +  register.
> +
> +  @retval  EFI_SUCCESS  Initialize required to access NOR flash is complete.
> +
> +**/
> +EFI_STATUS
> +NorFlashPlatformInitialization (
> +  VOID
> +  )
> +{
> +  UINT64 SysRegFlash;
> +
> +  SysRegFlash = FixedPcdGet64 (PcdSysPeriphSysRegBase) + SGI_SYSPH_SYS_REG_FLASH;
> +  MmioOr32 (SysRegFlash, SGI_SYSPH_SYS_REG_FLASH_RWEN);
> +  return EFI_SUCCESS;
> +}
> +
> +/** Returns the list of available NOR flash devices
> +
> +  For the StandaloneMM execution context, return the list of available NOR
> +  flash devices that are available for use.
> +
> +  @param[in]   NorFlashDevices  Pointer to array of NOR flash devices.
> +  @param[in]   Count            Number of elements in the NOR flash devices
> +                                array.
> +
> +  @retval  EFI_SUCCESS            Valid set of NOR flash devices is returned.
> +  @retval  EFI_INVALID_PARAMETER  Pointers to NOR flash devices and/or count is
> +                                  invalid.
> +
> +**/
> +EFI_STATUS
> +NorFlashPlatformGetDevices (
> +  OUT NOR_FLASH_DESCRIPTION   **NorFlashDevices,
> +  OUT UINT32                  *Count
> +  )
> +{
> +  if ((NorFlashDevices == NULL) || (Count == NULL)) {
> +    return EFI_INVALID_PARAMETER;
> +  }
> +
> +  *NorFlashDevices = mNorFlashDevices;
> +  *Count = ARRAY_SIZE (mNorFlashDevices);
> +  return EFI_SUCCESS;
> +}


  reply	other threads:[~2021-05-25 13:57 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-24 17:22 [edk2-platforms][PATCH V1 0/3] Platform/Sgi: enable support for UEFI secure boot sayanta.pattanayak
2021-05-24 17:22 ` [edk2-platforms][PATCH V1 1/3] Platform/Sgi: refactor StandaloneMM platform description file Sayanta Pattanayak
2021-05-25 13:57   ` Sami Mujawar
2021-05-24 17:22 ` [edk2-platforms][PATCH V1 2/3] Platform/Sgi: add StandaloneMM usable NorFlashPlatformLib Sayanta Pattanayak
2021-05-25 13:57   ` Sami Mujawar [this message]
2021-05-24 17:23 ` [edk2-platforms][PATCH V1 3/3] Platform/Sgi: enable support for UEFI secure boot Sayanta Pattanayak
2021-05-25 14:00   ` Sami Mujawar
2021-05-26 18:15     ` Sayanta Pattanayak
2021-05-26 18:20       ` Sami Mujawar
2021-06-01 18:09 ` [edk2-devel] [edk2-platforms][PATCH V1 0/3] " Thomas Abraham
2021-06-02 18:18 ` Sami Mujawar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6698738e-5183-24ea-9978-fb16fc2d47dc@arm.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox