public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "levi.yun" <yeoreum.yun@arm.com>
To: <thomas.abraham@arm.com>, <sami.mujawar@arm.com>, <devel@edk2.groups.io>
Cc: <nd@arm.com>, levi.yun <yeoreum.yun@arm.com>
Subject: [edk2-devel] [PATCH RESEND edk2-platforms v1 1/3] Platform/Arm: FVP: Add a NorFlashLib instance for StandaloneMm
Date: Fri, 19 Jan 2024 09:33:03 +0000	[thread overview]
Message-ID: <20240119093305.2258464-2-yeoreum.yun@arm.com> (raw)
In-Reply-To: <20240119093305.2258464-1-yeoreum.yun@arm.com>

The NOR Flash1 is used for UEFI Variable storage. When
Standalone MM is enabled the variable storage is managed
in the secure world by Standalone MM.

Therefore, add a new instance of NorFlashLib for that has
the NOR Flash1 definitions for Standalone MM.

Also, disable the NOR Flash1 definitions from the Normal
world NorFlashLib instance when Standalone MM is enabled
using the ENABLE_STMM build flag.

Signed-off-by: levi.yun <yeoreum.yun@arm.com>
---
 Platform/ARM/VExpressPkg/Library/NorFlashArmVExpressLib/NorFlashArmVExpress.c      | 34 ++--------------
 Platform/ARM/VExpressPkg/Library/NorFlashArmVExpressLib/NorFlashArmVExpressLib.inf |  3 +-
 Platform/ARM/VExpressPkg/Library/NorFlashArmVExpressLib/NorFlashInfo.c             | 42 ++++++++++++++++++++
 Platform/ARM/VExpressPkg/Library/NorFlashArmVExpressLib/NorFlashStMmInfo.c         | 28 +++++++++++++
 Platform/ARM/VExpressPkg/Library/NorFlashArmVExpressLib/NorFlashStMmLib.inf        | 30 ++++++++++++++
 5 files changed, 106 insertions(+), 31 deletions(-)

diff --git a/Platform/ARM/VExpressPkg/Library/NorFlashArmVExpressLib/NorFlashArmVExpress.c b/Platform/ARM/VExpressPkg/Library/NorFlashArmVExpressLib/NorFlashArmVExpress.c
index ec5ac8cc625fa3037edf63551baa43dab327ec5b..9b71df991a7a288f63f7dc2f50ffba251beaf8f2 100644
--- a/Platform/ARM/VExpressPkg/Library/NorFlashArmVExpressLib/NorFlashArmVExpress.c
+++ b/Platform/ARM/VExpressPkg/Library/NorFlashArmVExpressLib/NorFlashArmVExpress.c
@@ -1,6 +1,6 @@
 /** @file

- Copyright (c) 2011-2014, ARM Ltd. All rights reserved.<BR>
+ Copyright (c) 2011-2024, ARM Ltd. All rights reserved.<BR>

  SPDX-License-Identifier: BSD-2-Clause-Patent

@@ -12,34 +12,8 @@
 #include <Library/NorFlashPlatformLib.h>
 #include <ArmPlatform.h>

-#define NOR_FLASH_DEVICE_COUNT                     4
-
-NOR_FLASH_DESCRIPTION mNorFlashDevices[NOR_FLASH_DEVICE_COUNT] = {
-  { // BootMon
-    ARM_VE_SMB_NOR0_BASE,
-    ARM_VE_SMB_NOR0_BASE,
-    SIZE_256KB * 255,
-    SIZE_256KB,
-  },
-  { // BootMon non-volatile storage
-    ARM_VE_SMB_NOR0_BASE,
-    ARM_VE_SMB_NOR0_BASE + SIZE_256KB * 255,
-    SIZE_64KB * 4,
-    SIZE_64KB,
-  },
-  { // UEFI
-    ARM_VE_SMB_NOR1_BASE,
-    ARM_VE_SMB_NOR1_BASE,
-    SIZE_256KB * 255,
-    SIZE_256KB,
-  },
-  { // UEFI Variable Services non-volatile storage
-    ARM_VE_SMB_NOR1_BASE,
-    ARM_VE_SMB_NOR1_BASE + SIZE_256KB * 255,
-    SIZE_64KB * 3, //FIXME: Set 3 blocks because I did not succeed to copy 4 blocks into the ARM Versatile Express NOR Flash in the last NOR Flash. It should be 4 blocks
-    SIZE_64KB,
-  }
-};
+extern NOR_FLASH_DESCRIPTION mNorFlashDevices[];
+extern UINT32                mNorFlashCount;

 EFI_STATUS
 NorFlashPlatformInitialization (
@@ -68,7 +42,7 @@ NorFlashPlatformGetDevices (
   }

   *NorFlashDevices = mNorFlashDevices;
-  *Count = NOR_FLASH_DEVICE_COUNT;
+  *Count = mNorFlashCount;

   return EFI_SUCCESS;
 }
diff --git a/Platform/ARM/VExpressPkg/Library/NorFlashArmVExpressLib/NorFlashArmVExpressLib.inf b/Platform/ARM/VExpressPkg/Library/NorFlashArmVExpressLib/NorFlashArmVExpressLib.inf
index c9fbd80d47eb865b81e85bb513a44f7c18b58927..1a656836675876b492cdb33f3bf6bfc0b76d15b7 100644
--- a/Platform/ARM/VExpressPkg/Library/NorFlashArmVExpressLib/NorFlashArmVExpressLib.inf
+++ b/Platform/ARM/VExpressPkg/Library/NorFlashArmVExpressLib/NorFlashArmVExpressLib.inf
@@ -1,6 +1,6 @@
 #/** @file
 #
-#  Copyright (c) 2011, ARM Ltd. All rights reserved.<BR>
+#  Copyright (c) 2011-2024, ARM Ltd. All rights reserved.<BR>
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
 #**/
@@ -15,6 +15,7 @@ [Defines]

 [Sources.common]
   NorFlashArmVExpress.c
+  NorFlashInfo.c

 [Packages]
   MdePkg/MdePkg.dec
diff --git a/Platform/ARM/VExpressPkg/Library/NorFlashArmVExpressLib/NorFlashInfo.c b/Platform/ARM/VExpressPkg/Library/NorFlashArmVExpressLib/NorFlashInfo.c
new file mode 100644
index 0000000000000000000000000000000000000000..fd515305fbbf1bbbfe5213329a88e40ed5b3f7a6
--- /dev/null
+++ b/Platform/ARM/VExpressPkg/Library/NorFlashArmVExpressLib/NorFlashInfo.c
@@ -0,0 +1,42 @@
+/** @file
+
+ Copyright (c) 2011-2024, Arm Ltd. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+ **/
+
+#include <Base.h>
+#include <Library/NorFlashPlatformLib.h>
+#include <ArmPlatform.h>
+
+NOR_FLASH_DESCRIPTION mNorFlashDevices[] = {
+  { // BootMon
+    ARM_VE_SMB_NOR0_BASE,
+    ARM_VE_SMB_NOR0_BASE,
+    SIZE_256KB * 255,
+    SIZE_256KB,
+  },
+  { // BootMon non-volatile storage
+    ARM_VE_SMB_NOR0_BASE,
+    ARM_VE_SMB_NOR0_BASE + SIZE_256KB * 255,
+    SIZE_64KB * 4,
+    SIZE_64KB,
+  },
+#ifndef ENABLE_UEFI_SECURE_VARIABLE
+  { // UEFI
+    ARM_VE_SMB_NOR1_BASE,
+    ARM_VE_SMB_NOR1_BASE,
+    SIZE_256KB * 255,
+    SIZE_256KB,
+  },
+  { // UEFI Variable Services non-volatile storage
+    ARM_VE_SMB_NOR1_BASE,
+    ARM_VE_SMB_NOR1_BASE + SIZE_256KB * 255,
+    SIZE_64KB * 3, //FIXME: Set 3 blocks because I did not succeed to copy 4 blocks into the ARM Versatile Express NOR Flash in the last NOR Flash. It should be 4 blocks
+    SIZE_64KB,
+  },
+#endif
+};
+
+UINT32 mNorFlashCount = ARRAY_SIZE(mNorFlashDevices);
diff --git a/Platform/ARM/VExpressPkg/Library/NorFlashArmVExpressLib/NorFlashStMmInfo.c b/Platform/ARM/VExpressPkg/Library/NorFlashArmVExpressLib/NorFlashStMmInfo.c
new file mode 100644
index 0000000000000000000000000000000000000000..165e265e2c47a4ab66326fcc924c3aeaeaf68c62
--- /dev/null
+++ b/Platform/ARM/VExpressPkg/Library/NorFlashArmVExpressLib/NorFlashStMmInfo.c
@@ -0,0 +1,28 @@
+/** @file
+
+ Copyright (c) 2024, Arm Limited. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+ **/
+
+#include <Base.h>
+#include <Library/NorFlashPlatformLib.h>
+#include <ArmPlatform.h>
+
+NOR_FLASH_DESCRIPTION mNorFlashDevices[] = {
+  {
+    ARM_VE_SMB_NOR1_BASE,
+    ARM_VE_SMB_NOR1_BASE,
+    SIZE_256KB * 255,
+    SIZE_256KB,
+  },
+  { // UEFI Variable Services non-volatile storage
+    ARM_VE_SMB_NOR1_BASE,
+    ARM_VE_SMB_NOR1_BASE + SIZE_256KB * 255,
+    SIZE_64KB * 4,
+    SIZE_64KB,
+  },
+};
+
+UINT32 mNorFlashCount = ARRAY_SIZE (mNorFlashDevices);
diff --git a/Platform/ARM/VExpressPkg/Library/NorFlashArmVExpressLib/NorFlashStMmLib.inf b/Platform/ARM/VExpressPkg/Library/NorFlashArmVExpressLib/NorFlashStMmLib.inf
new file mode 100644
index 0000000000000000000000000000000000000000..79f3723d62a36577c1242f87265b7fc1c07cbee1
--- /dev/null
+++ b/Platform/ARM/VExpressPkg/Library/NorFlashArmVExpressLib/NorFlashStMmLib.inf
@@ -0,0 +1,30 @@
+## @file
+#  StandaloneMM instance of NOR Flash library.
+#
+#  Copyright (c) 2024, ARM Limited. All rights reserved.
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION                    = 0x0001001A
+  BASE_NAME                      = NorFlashStMmLib
+  FILE_GUID                      = 011baec0-ae08-11ee-93fa-bb327a85ca4a
+  MODULE_TYPE                    = MM_STANDALONE
+  VERSION_STRING                 = 1.0
+  PI_SPECIFICATION_VERSION       = 0x00010032
+  LIBRARY_CLASS                  = NorFlashPlatformLib
+
+[Sources.common]
+  NorFlashArmVExpress.c
+  NorFlashStMmInfo.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  Platform/ARM/ARM.dec
+  Platform/ARM/VExpressPkg/ArmVExpressPkg.dec
+
+[LibraryClasses]
+  BaseLib
+  DebugLib
+  IoLib
--
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")

IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#114036): https://edk2.groups.io/g/devel/message/114036
Mute This Topic: https://groups.io/mt/103827103/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



  reply	other threads:[~2024-01-19  9:33 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-19  9:33 [edk2-devel] [PATCH RESEND edk2-platforms v1 0/3] Platform/Arm: StandloneMm support for FVP levi.yun
2024-01-19  9:33 ` levi.yun [this message]
2024-01-19  9:33 ` [edk2-devel] [PATCH RESEND edk2-platforms v1 2/3] Platform/Arm: Enable UEFI Secure Variable " levi.yun
2024-03-15 10:22   ` Sami Mujawar
2024-03-15 10:29     ` levi.yun
2024-01-19  9:33 ` [edk2-devel] [PATCH RESEND edk2-platforms v1 3/3] Platform/Arm: Add Standalone MM " levi.yun
2024-03-15 10:10 ` [edk2-devel] [PATCH RESEND edk2-platforms v1 0/3] Platform/Arm: StandloneMm " Sami Mujawar
2024-03-15 10:28   ` levi.yun
2024-03-15 10:31 ` Sami Mujawar
2024-03-25 11:58 ` 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=20240119093305.2258464-2-yeoreum.yun@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