From patchwork Mon Aug 25 19:19:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 35936 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f198.google.com (mail-vc0-f198.google.com [209.85.220.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C340C20565 for ; Mon, 25 Aug 2014 19:20:50 +0000 (UTC) Received: by mail-vc0-f198.google.com with SMTP id le20sf42468145vcb.5 for ; Mon, 25 Aug 2014 12:20:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:subject:precedence:reply-to:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version :errors-to:x-original-sender:x-original-authentication-results :mailing-list:content-type:content-transfer-encoding; bh=QOzyUm1JB5TVR2UChWGt3G63wU9+8M3RtKLmFvv4UuA=; b=REh9XjjUds+A/mY2IzO7gHPz97qNb6UIZHTAufcTgW70Q4qwZfULf1YLcZLOSf9L71 2o+IPmdkXef4MJ2nqSw8Ty8xzEMDGKQSU3oF3D0FIhkPmwNHY0e3l1h0ektRaGD8ns7N DGcTjCpJ4XxumXSjjGAJFilvVMLJXvty58pCe60xQRhj9NbKKcSaLu20tnqDE9Mx2PKu MIM5JptqLM7/oYzMAP67TfDxBHrNKfYCsvcXvXJXn1GoQmcmGaIQMcmBTd4NEt2EL4Hh kNeQcTP0Fvtm0jlOfir0kWJSsY+u1zKcoNq1C48SDCUHGj0jaWoLdorhvd3FuqRy1wJP e0Bg== X-Gm-Message-State: ALoCoQla5HEfE9REqtVmKDJ4MbsQnsVpV3lf5WdjOOpfHvtttA3LvrTl6aavRM7/zYSE74H15oIp X-Received: by 10.236.34.233 with SMTP id s69mr1524070yha.57.1408994450568; Mon, 25 Aug 2014 12:20:50 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.98.212 with SMTP id o78ls2175205qge.55.gmail; Mon, 25 Aug 2014 12:20:50 -0700 (PDT) X-Received: by 10.52.62.195 with SMTP id a3mr2803926vds.76.1408994450412; Mon, 25 Aug 2014 12:20:50 -0700 (PDT) Received: from mail-vc0-f171.google.com (mail-vc0-f171.google.com [209.85.220.171]) by mx.google.com with ESMTPS id c11si450294vdj.97.2014.08.25.12.20.50 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 25 Aug 2014 12:20:50 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.171 as permitted sender) client-ip=209.85.220.171; Received: by mail-vc0-f171.google.com with SMTP id hq11so15732373vcb.16 for ; Mon, 25 Aug 2014 12:20:50 -0700 (PDT) X-Received: by 10.220.77.65 with SMTP id f1mr7067864vck.48.1408994450334; Mon, 25 Aug 2014 12:20:50 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.45.67 with SMTP id uj3csp141544vcb; Mon, 25 Aug 2014 12:20:49 -0700 (PDT) X-Received: by 10.50.117.106 with SMTP id kd10mr17359690igb.5.1408994449692; Mon, 25 Aug 2014 12:20:49 -0700 (PDT) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id ci5si885694igb.25.2014.08.25.12.20.49 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 25 Aug 2014 12:20:49 -0700 (PDT) Received-SPF: pass (google.com: domain of edk2-devel-bounces@lists.sourceforge.net designates 216.34.181.88 as permitted sender) client-ip=216.34.181.88; Received: from localhost ([127.0.0.1] helo=sfs-ml-2.v29.ch3.sourceforge.com) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1XLzon-0004Fb-FR; Mon, 25 Aug 2014 19:20:41 +0000 Received: from sog-mx-4.v43.ch3.sourceforge.com ([172.29.43.194] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1XLzom-0004FV-Hs for edk2-devel@lists.sourceforge.net; Mon, 25 Aug 2014 19:20:40 +0000 Received-SPF: pass (sog-mx-4.v43.ch3.sourceforge.com: domain of linaro.org designates 74.125.82.51 as permitted sender) client-ip=74.125.82.51; envelope-from=ard.biesheuvel@linaro.org; helo=mail-wg0-f51.google.com; Received: from mail-wg0-f51.google.com ([74.125.82.51]) by sog-mx-4.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1XLzol-0003Xc-6S for edk2-devel@lists.sourceforge.net; Mon, 25 Aug 2014 19:20:40 +0000 Received: by mail-wg0-f51.google.com with SMTP id b13so13394178wgh.34 for ; Mon, 25 Aug 2014 12:20:33 -0700 (PDT) X-Received: by 10.180.188.205 with SMTP id gc13mr17372109wic.66.1408994432913; Mon, 25 Aug 2014 12:20:32 -0700 (PDT) Received: from ards-macbook-pro.local ([193.77.13.198]) by mx.google.com with ESMTPSA id b3sm3476891wiw.22.2014.08.25.12.20.29 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 25 Aug 2014 12:20:32 -0700 (PDT) From: Ard Biesheuvel To: lersek@redhat.com, olivier.martin@arm.com, edk2-devel@lists.sourceforge.net, peter.maydell@linaro.org, christoffer.dall@linaro.org, drjones@redhat.com, ilias.biris@linaro.org, leif.lindholm@linaro.org Date: Mon, 25 Aug 2014 21:19:27 +0200 Message-Id: <1408994367-11143-11-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1408994367-11143-1-git-send-email-ard.biesheuvel@linaro.org> References: <1408994367-11143-1-git-send-email-ard.biesheuvel@linaro.org> X-Spam-Score: -1.5 (-) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain -0.0 SPF_PASS SPF: sender matches SPF record X-Headers-End: 1XLzol-0003Xc-6S Subject: [edk2] [PATCH 10/10] AArch64-KVM: add support for non-volatile variable store X-BeenThere: edk2-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list Reply-To: edk2-devel@lists.sourceforge.net List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.sourceforge.net X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ard.biesheuvel@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.171 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 This adds support for retaining UEFI environment variables in the second emulated NOR flash which resided at phys address 0x04000000 (64 MB). Note that this requires booting QEMU with two -pflash arguments, each of which points to a NOR image file of exactly 64 MB in size. The second one will be used as the variable store. Signed-off-by: Ard Biesheuvel --- .../AArch64Virtualization-KVM.dsc | 16 +++++- .../AArch64Virtualization-KVM.fdf | 4 +- .../Include/Platform/KVM/ArmPlatform.h | 6 +++ .../Library/NorFlashKVM/NorFlashKVM.c | 63 ++++++++++++++++++++++ .../Library/NorFlashKVM/NorFlashKVM.inf | 35 ++++++++++++ 5 files changed, 122 insertions(+), 2 deletions(-) create mode 100644 ArmPlatformPkg/AArch64VirtualizationPkg/Library/NorFlashKVM/NorFlashKVM.c create mode 100644 ArmPlatformPkg/AArch64VirtualizationPkg/Library/NorFlashKVM/NorFlashKVM.inf diff --git a/ArmPlatformPkg/AArch64VirtualizationPkg/AArch64Virtualization-KVM.dsc b/ArmPlatformPkg/AArch64VirtualizationPkg/AArch64Virtualization-KVM.dsc index d8a5dcc87941..b7c03b079577 100644 --- a/ArmPlatformPkg/AArch64VirtualizationPkg/AArch64Virtualization-KVM.dsc +++ b/ArmPlatformPkg/AArch64VirtualizationPkg/AArch64Virtualization-KVM.dsc @@ -116,6 +116,16 @@ gArmTokenSpaceGuid.PcdArmArchTimerUseVirtual|1 gArmTokenSpaceGuid.PcdArmArchTimerFreqInHz|100000000 + # + # NV Storage PCDs. Use base of 0x04000000 for NOR1 + # + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase|0x04000000 + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize|0x00040000 + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0x04040000 + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize|0x00040000 + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0x04080000 + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize|0x00040000 + [PcdsDynamicDefault.common] # System Memory -- 1 MB initially, actual size will be fetched from DT gArmTokenSpaceGuid.PcdSystemMemoryBase|0x40000000 @@ -178,7 +188,7 @@ MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf - MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf + MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf EmbeddedPkg/ResetRuntimeDxe/ResetRuntimeDxe.inf @@ -196,6 +206,10 @@ ArmPkg/Drivers/ArmGic/ArmGicDxe.inf ArmPkg/Drivers/TimerDxe/TimerDxe.inf + ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf { + + NorFlashPlatformLib|ArmPlatformPkg/AArch64VirtualizationPkg/Library/NorFlashKVM/NorFlashKVM.inf + } MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf # diff --git a/ArmPlatformPkg/AArch64VirtualizationPkg/AArch64Virtualization-KVM.fdf b/ArmPlatformPkg/AArch64VirtualizationPkg/AArch64Virtualization-KVM.fdf index b40f915c88fe..9e3b1a625984 100644 --- a/ArmPlatformPkg/AArch64VirtualizationPkg/AArch64Virtualization-KVM.fdf +++ b/ArmPlatformPkg/AArch64VirtualizationPkg/AArch64Virtualization-KVM.fdf @@ -99,8 +99,8 @@ READ_LOCK_STATUS = TRUE INF MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf - INF MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf INF MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf + INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf INF MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf INF EmbeddedPkg/ResetRuntimeDxe/ResetRuntimeDxe.inf INF EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf @@ -118,6 +118,7 @@ READ_LOCK_STATUS = TRUE INF ArmPkg/Drivers/ArmGic/ArmGicDxe.inf INF ArmPkg/Drivers/TimerDxe/TimerDxe.inf + INF ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf INF MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf # @@ -177,6 +178,7 @@ READ_LOCK_STATUS = TRUE INF ArmPlatformPkg/MemoryInitPei/MemoryInitPeim.inf INF ArmPkg/Drivers/CpuPei/CpuPei.inf INF MdeModulePkg/Universal/PCD/Pei/Pcd.inf + INF MdeModulePkg/Universal/Variable/Pei/VariablePei.inf INF IntelFrameworkModulePkg/Universal/StatusCode/Pei/StatusCodePei.inf INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf diff --git a/ArmPlatformPkg/AArch64VirtualizationPkg/Include/Platform/KVM/ArmPlatform.h b/ArmPlatformPkg/AArch64VirtualizationPkg/Include/Platform/KVM/ArmPlatform.h index f6f694f54390..8dddb1dccd63 100644 --- a/ArmPlatformPkg/AArch64VirtualizationPkg/Include/Platform/KVM/ArmPlatform.h +++ b/ArmPlatformPkg/AArch64VirtualizationPkg/Include/Platform/KVM/ArmPlatform.h @@ -29,4 +29,10 @@ #define PSCI_0_2_FN_SYSTEM_OFF PSCI_0_2_FN(8) #define PSCI_0_2_FN_SYSTEM_RESET PSCI_0_2_FN(9) +#define QEMU_NOR_BSIZE SIZE_256KB +#define QEMU_NOR0_BASE 0x0 +#define QEMU_NOR0_SIZE SIZE_64MB +#define QEMU_NOR1_BASE 0x04000000 +#define QEMU_NOR1_SIZE SIZE_64MB + #endif diff --git a/ArmPlatformPkg/AArch64VirtualizationPkg/Library/NorFlashKVM/NorFlashKVM.c b/ArmPlatformPkg/AArch64VirtualizationPkg/Library/NorFlashKVM/NorFlashKVM.c new file mode 100644 index 000000000000..df38eae34cb1 --- /dev/null +++ b/ArmPlatformPkg/AArch64VirtualizationPkg/Library/NorFlashKVM/NorFlashKVM.c @@ -0,0 +1,63 @@ +/** @file + + Copyright (c) 2014, Linaro 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. + + **/ + +#ifndef _NORFLASHPLATFORMLIB_H_ +#define _NORFLASHPLATFORMLIB_H_ + +#include + +typedef struct { + UINTN DeviceBaseAddress; // Start address of the Device Base Address (DBA) + UINTN RegionBaseAddress; // Start address of one single region + UINTN Size; + UINTN BlockSize; + EFI_GUID Guid; +} NOR_FLASH_DESCRIPTION; + +EFI_STATUS +NorFlashPlatformInitialization ( + VOID + ) +{ + return EFI_SUCCESS; +} + +NOR_FLASH_DESCRIPTION mNorFlashDevices[] = { + { + QEMU_NOR0_BASE, + QEMU_NOR0_BASE, + QEMU_NOR0_SIZE, + QEMU_NOR_BSIZE, + {0xF9B94AE2, 0x8BA6, 0x409B, 0x9D, 0x56, 0xB9, 0xB4, 0x17, 0xF5, 0x3C, 0xB3} + }, { + QEMU_NOR1_BASE, + QEMU_NOR1_BASE, + QEMU_NOR1_SIZE, + QEMU_NOR_BSIZE, + {0x8047DB4B, 0x7E9C, 0x4C0C, 0x8E, 0xBC, 0xDF, 0xBB, 0xAA, 0xCA, 0xCE, 0x8F} + } +}; + +EFI_STATUS +NorFlashPlatformGetDevices ( + OUT NOR_FLASH_DESCRIPTION **NorFlashDescriptions, + OUT UINT32 *Count + ) +{ + *NorFlashDescriptions = mNorFlashDevices; + *Count = sizeof(mNorFlashDevices)/sizeof(mNorFlashDevices[0]); + return EFI_SUCCESS; +} + +#endif /* _NORFLASHPLATFORMLIB_H_ */ diff --git a/ArmPlatformPkg/AArch64VirtualizationPkg/Library/NorFlashKVM/NorFlashKVM.inf b/ArmPlatformPkg/AArch64VirtualizationPkg/Library/NorFlashKVM/NorFlashKVM.inf new file mode 100644 index 000000000000..fe812adaa5bb --- /dev/null +++ b/ArmPlatformPkg/AArch64VirtualizationPkg/Library/NorFlashKVM/NorFlashKVM.inf @@ -0,0 +1,35 @@ +#/** @file +# +# Component description file for NorFlashKVM module +# +# Copyright (c) 2014, Linaro 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 = 0x00010005 + BASE_NAME = NorFlashArmRealViewEbLib + FILE_GUID = 339B7829-4C5F-4EFC-B2DD-5050E530DECE + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + LIBRARY_CLASS = NorFlashPlatformLib + +[Sources.common] + NorFlashKVM.c + +[Packages] + MdePkg/MdePkg.dec + ArmPlatformPkg/ArmPlatformPkg.dec + +[LibraryClasses] + BaseLib + DebugLib + IoLib