[edk2-devel] [PATCH RESEND edk2-platforms v1 1/3] Platform/Arm: FVP: Add a NorFlashLib instance for StandaloneMm

levi.yun posted 3 patches 1 year, 3 months ago
[edk2-devel] [PATCH RESEND edk2-platforms v1 1/3] Platform/Arm: FVP: Add a NorFlashLib instance for StandaloneMm
Posted by levi.yun 1 year, 3 months ago
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/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-