summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJagadeesh Ujja <jagadeesh.ujja@arm.com>2019-01-25 15:16:22 +0530
committerThomas Abraham <thomas.abraham@arm.com>2020-04-15 21:22:49 +0530
commit6d3d1e614937633d4b22ca9885c3842c39598a86 (patch)
tree12fca89b233d050f3aea29a324a4ac87c87f9390
parent5fb1c4b186a8ee80b7b50938e7aac161ac6b1b45 (diff)
Platform/ARM/Sgi: allow MM_STANDALONE modules to use NorFlashPlatformLib
“NorFlashPlatformLib” library can be used by MM_STANDALONE drivers as well. When used in MM mode, the third instance of the NOR flash is used as 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 Change-Id: I6caaff7122a551fead33ffa3d64ed4dad8368918 Signed-off-by: Jagadeesh Ujja jagadeesh.ujja@arm.com
-rw-r--r--Platform/ARM/SgiPkg/Library/NorFlashLib/StandaloneMmNorFlashLib.c63
-rw-r--r--Platform/ARM/SgiPkg/Library/NorFlashLib/StandaloneMmNorFlashLib.inf35
2 files changed, 98 insertions, 0 deletions
diff --git a/Platform/ARM/SgiPkg/Library/NorFlashLib/StandaloneMmNorFlashLib.c b/Platform/ARM/SgiPkg/Library/NorFlashLib/StandaloneMmNorFlashLib.c
new file mode 100644
index 00000000..06e3f97a
--- /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 available
+ under the terms and conditions of the BSD License which accompanies this
+ 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.
+
+ **/
+
+#include <PiMm.h>
+#include <Library/DebugLib.h>
+#include <Library/IoLib.h>
+#include <Library/NorFlashPlatformLib.h>
+#include <SgiPlatform.h>
+
+STATIC NOR_FLASH_DESCRIPTION mNorFlashDevices[] = {
+ {
+ // 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 = SGI_EXP_SYSPH_SYSTEM_REGISTERS + SGI_SYSPH_SYS_REG_FLASH;
+ MmioOr32 (SysRegFlash, SGI_SYSPH_SYS_REG_FLASH_RWEN);
+ return EFI_SUCCESS;
+}
+
+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;
+}
diff --git a/Platform/ARM/SgiPkg/Library/NorFlashLib/StandaloneMmNorFlashLib.inf b/Platform/ARM/SgiPkg/Library/NorFlashLib/StandaloneMmNorFlashLib.inf
new file mode 100644
index 00000000..eedfacc9
--- /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 available
+# under the terms and conditions of the BSD License which accompanies this
+# 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 = 0x0001001A
+ BASE_NAME = NorFlashSgiLib
+ 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