From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=217.140.101.70; helo=foss.arm.com; envelope-from=jagadeesh.ujja@arm.com; receiver=edk2-devel@lists.01.org Received: from foss.arm.com (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by ml01.01.org (Postfix) with ESMTP id 7B88F21A07096 for ; Mon, 4 Mar 2019 02:12:08 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5A34AEBD; Mon, 4 Mar 2019 02:12:08 -0800 (PST) Received: from usa.arm.com (a075556-lin.blr.arm.com [10.162.2.22]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 04CF63F703; Mon, 4 Mar 2019 02:12:06 -0800 (PST) From: Jagadeesh Ujja To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, ard.biesheuvel@linaro.org Date: Mon, 4 Mar 2019 15:41:52 +0530 Message-Id: <1551694313-23594-3-git-send-email-jagadeesh.ujja@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1551694313-23594-1-git-send-email-jagadeesh.ujja@arm.com> References: <1551694313-23594-1-git-send-email-jagadeesh.ujja@arm.com> MIME-Version: 1.0 Subject: [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 10:12:08 -0000 X-List-Received-Date: Mon, 04 Mar 2019 10:12:08 -0000 X-List-Received-Date: Mon, 04 Mar 2019 10:12:08 -0000 X-List-Received-Date: Mon, 04 Mar 2019 10:12:08 -0000 X-List-Received-Date: Mon, 04 Mar 2019 10:12:08 -0000 X-List-Received-Date: Mon, 04 Mar 2019 10:12:08 -0000 X-List-Received-Date: Mon, 04 Mar 2019 10:12:08 -0000 X-List-Received-Date: Mon, 04 Mar 2019 10:12:08 -0000 X-List-Received-Date: Mon, 04 Mar 2019 10:12:08 -0000 X-List-Received-Date: Mon, 04 Mar 2019 10:12:08 -0000 X-List-Received-Date: Mon, 04 Mar 2019 10:12:08 -0000 X-List-Received-Date: Mon, 04 Mar 2019 10:12:08 -0000 X-List-Received-Date: Mon, 04 Mar 2019 10:12:08 -0000 X-List-Received-Date: Mon, 04 Mar 2019 10:12:08 -0000 X-List-Received-Date: Mon, 04 Mar 2019 10:12:08 -0000 X-List-Received-Date: Mon, 04 Mar 2019 10:12:08 -0000 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit “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 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/StandaloneMmNorFlashLib.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 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 +#include +#include +#include +#include + +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 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 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 -- 2.7.4