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 (foss.arm.com [217.140.101.70]) by ml01.01.org (Postfix) with ESMTP id 3DC3D211D6171 for ; Tue, 12 Mar 2019 09:06:53 -0700 (PDT) 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 CA81D165C; Tue, 12 Mar 2019 09:06:52 -0700 (PDT) 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 75C043F71D; Tue, 12 Mar 2019 09:06:51 -0700 (PDT) From: Jagadeesh Ujja To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, ard.biesheuvel@linaro.org Date: Tue, 12 Mar 2019 21:36:34 +0530 Message-Id: <1552406795-16588-3-git-send-email-jagadeesh.ujja@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1552406795-16588-1-git-send-email-jagadeesh.ujja@arm.com> References: <1552406795-16588-1-git-send-email-jagadeesh.ujja@arm.com> MIME-Version: 1.0 Subject: [PATCH edk2-platforms v2 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: Tue, 12 Mar 2019 16:06:53 -0000 X-List-Received-Date: Tue, 12 Mar 2019 16:06:53 -0000 X-List-Received-Date: Tue, 12 Mar 2019 16:06:53 -0000 X-List-Received-Date: Tue, 12 Mar 2019 16:06:53 -0000 X-List-Received-Date: Tue, 12 Mar 2019 16:06:53 -0000 X-List-Received-Date: Tue, 12 Mar 2019 16:06:53 -0000 X-List-Received-Date: Tue, 12 Mar 2019 16:06:53 -0000 X-List-Received-Date: Tue, 12 Mar 2019 16:06:53 -0000 X-List-Received-Date: Tue, 12 Mar 2019 16:06:53 -0000 X-List-Received-Date: Tue, 12 Mar 2019 16:06:53 -0000 X-List-Received-Date: Tue, 12 Mar 2019 16:06:53 -0000 X-List-Received-Date: Tue, 12 Mar 2019 16:06:53 -0000 X-List-Received-Date: Tue, 12 Mar 2019 16:06:53 -0000 X-List-Received-Date: Tue, 12 Mar 2019 16:06:53 -0000 X-List-Received-Date: Tue, 12 Mar 2019 16:06:53 -0000 X-List-Received-Date: Tue, 12 Mar 2019 16:06:53 -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 | 33 ++++++++++ 2 files changed, 96 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..d24eb21 --- /dev/null +++ b/Platform/ARM/SgiPkg/Library/NorFlashLib/StandaloneMmNorFlashLib.inf @@ -0,0 +1,33 @@ +#/** @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 = BASE + 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