From patchwork Tue May 17 15:22:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laszlo Ersek X-Patchwork-Id: 67995 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp2136673qge; Tue, 17 May 2016 08:23:05 -0700 (PDT) X-Received: by 10.66.234.131 with SMTP id ue3mr2934030pac.120.1463498583764; Tue, 17 May 2016 08:23:03 -0700 (PDT) Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id se4si5175642pac.61.2016.05.17.08.23.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 May 2016 08:23:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 0B08D1A1FF0; Tue, 17 May 2016 08:23:08 -0700 (PDT) X-Original-To: edk2-devel@ml01.01.org Delivered-To: edk2-devel@ml01.01.org Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id A60A71A1E47 for ; Tue, 17 May 2016 08:23:06 -0700 (PDT) Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7997215567; Tue, 17 May 2016 15:23:01 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-87.phx2.redhat.com [10.3.116.87]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u4HFMsOC007828; Tue, 17 May 2016 11:23:00 -0400 From: Laszlo Ersek To: edk2-devel-01 Date: Tue, 17 May 2016 17:22:45 +0200 Message-Id: <1463498570-4469-3-git-send-email-lersek@redhat.com> In-Reply-To: <1463498570-4469-1-git-send-email-lersek@redhat.com> References: <1463498570-4469-1-git-send-email-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 17 May 2016 15:23:01 +0000 (UTC) Subject: [edk2] [PATCH v2 2/7] OvmfPkg: replace PcdAcpiPmBaseAddress with PIIX4_PMBA_VALUE X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Jordan Justen , Gabriel Somlo MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" In the next patches, we'll differentiate the PMBA IO port address that we program on PIIX4 vs. Q35. Normally we'd just turn PcdAcpiPmBaseAddress into a dynamic PCD. However, because we need this value in BaseRomAcpiTimerLib too (which cannot access RAM and dynamic PCDs), it must remain a build time constant. We will introduce its Q35 counterpart later. As first step, replace the PCD with a new macro in "OvmfPlatforms.h"; Jordan prefers the latter to fixed PCDs in this instance. Cc: Gabriel Somlo Cc: Jordan Justen Ref: https://bugzilla.redhat.com/show_bug.cgi?id=1333238 Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek --- Notes: v2: - use macro instead of fixed PcdPiix4AcpiPmBaseAddress [Jordan] - update the comments in "BaseAcpiTimerLib.c" and "BaseRomAcpiTimerLib.c" in this patch (since the PCD is going away in this patch) rather than in patch #4 OvmfPkg/OvmfPkg.dec | 4 ---- OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.inf | 3 --- OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.inf | 3 --- OvmfPkg/Library/ResetSystemLib/ResetSystemLib.inf | 3 --- OvmfPkg/PlatformPei/PlatformPei.inf | 1 - OvmfPkg/Include/OvmfPlatforms.h | 5 +++++ OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.c | 5 ++--- OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.c | 5 ++--- OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c | 7 ++++--- OvmfPkg/PlatformPei/Platform.c | 2 +- 10 files changed, 14 insertions(+), 24 deletions(-) -- 1.8.3.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec index 97ffb8749be3..ce76f11e1b7e 100644 --- a/OvmfPkg/OvmfPkg.dec +++ b/OvmfPkg/OvmfPkg.dec @@ -70,20 +70,16 @@ [PcdsFixedAtBuild] gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvBase|0x0|UINT32|0 gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvSize|0x0|UINT32|1 gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvBase|0x0|UINT32|0x15 gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvSize|0x0|UINT32|0x16 ## This flag is used to control the destination port for PlatformDebugLibIoPort gUefiOvmfPkgTokenSpaceGuid.PcdDebugIoPort|0x402|UINT16|4 - ## This flag determines the Power Management Base Address of choice, written - # to PIIX4 function 3 offset 0x40-0x43 bits [15:6]. - gUefiOvmfPkgTokenSpaceGuid.PcdAcpiPmBaseAddress|0xB000|UINT16|5 - ## When VirtioScsiDxe is instantiated for a HBA, the numbers of targets and # LUNs are retrieved from the host during virtio-scsi setup. # MdeModulePkg/Bus/Scsi/ScsiBusDxe then scans all MaxTarget * MaxLun # possible devices. This can take extremely long, for example with # MaxTarget=255 and MaxLun=16383. The *inclusive* constants below limit # MaxTarget and MaxLun, independently, should the host report higher values, # so that scanning the number of devices given by their product is still # acceptably fast. diff --git a/OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.inf b/OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.inf index 4c0e6159554d..04df609220e1 100644 --- a/OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.inf +++ b/OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.inf @@ -26,15 +26,12 @@ [Defines] [Sources] AcpiTimerLib.c BaseAcpiTimerLib.c [Packages] MdePkg/MdePkg.dec OvmfPkg/OvmfPkg.dec -[Pcd] - gUefiOvmfPkgTokenSpaceGuid.PcdAcpiPmBaseAddress - [LibraryClasses] BaseLib PciLib IoLib diff --git a/OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.inf b/OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.inf index d5e50aef618d..946292c181e4 100644 --- a/OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.inf +++ b/OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.inf @@ -25,15 +25,12 @@ [Defines] [Sources] AcpiTimerLib.c BaseRomAcpiTimerLib.c [Packages] MdePkg/MdePkg.dec OvmfPkg/OvmfPkg.dec -[Pcd] - gUefiOvmfPkgTokenSpaceGuid.PcdAcpiPmBaseAddress - [LibraryClasses] BaseLib PciLib IoLib diff --git a/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.inf b/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.inf index b6a3ffe77254..ecd462ba7d84 100644 --- a/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.inf +++ b/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.inf @@ -32,11 +32,8 @@ [Sources] [Packages] MdePkg/MdePkg.dec OvmfPkg/OvmfPkg.dec [LibraryClasses] DebugLib IoLib TimerLib - -[Pcd] - gUefiOvmfPkgTokenSpaceGuid.PcdAcpiPmBaseAddress \ No newline at end of file diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf b/OvmfPkg/PlatformPei/PlatformPei.inf index ed31b1f724b5..3556404017fc 100644 --- a/OvmfPkg/PlatformPei/PlatformPei.inf +++ b/OvmfPkg/PlatformPei/PlatformPei.inf @@ -60,17 +60,16 @@ [LibraryClasses] MtrrLib PcdLib [Pcd] gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvBase gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvSize gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvBase gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvSize - gUefiOvmfPkgTokenSpaceGuid.PcdAcpiPmBaseAddress gUefiOvmfPkgTokenSpaceGuid.PcdS3AcpiReservedMemoryBase gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamBase gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamSize gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesBase gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesSize gUefiOvmfPkgTokenSpaceGuid.PcdOvmfLockBoxStorageBase gUefiOvmfPkgTokenSpaceGuid.PcdOvmfLockBoxStorageSize gUefiOvmfPkgTokenSpaceGuid.PcdGuidedExtractHandlerTableSize diff --git a/OvmfPkg/Include/OvmfPlatforms.h b/OvmfPkg/Include/OvmfPlatforms.h index 43ab01d57c6f..ee9f6554d08d 100644 --- a/OvmfPkg/Include/OvmfPlatforms.h +++ b/OvmfPkg/Include/OvmfPlatforms.h @@ -23,16 +23,21 @@ // // OVMF Host Bridge DID Address // #define OVMF_HOSTBRIDGE_DID \ PCI_LIB_ADDRESS (0, 0, 0, PCI_DEVICE_ID_OFFSET) // +// Values we program into the PM base address registers +// +#define PIIX4_PMBA_VALUE 0xB000 + +// // Common bits in same-purpose registers // #define PMBA_RTE BIT0 // // Common IO ports relative to the Power Management Base Address // #define ACPI_TIMER_OFFSET 0x8 diff --git a/OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.c b/OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.c index 7144d75c7325..109b267cf4aa 100644 --- a/OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.c +++ b/OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.c @@ -10,17 +10,16 @@ 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 // // Cached ACPI Timer IO Address // STATIC UINT32 mAcpiTimerIoAddr; /** @@ -64,19 +63,19 @@ AcpiTimerLibConstructor ( } // // Check to see if the Power Management Base Address is already enabled // if ((PciRead8 (AcpiCtlReg) & AcpiEnBit) == 0) { // // If the Power Management Base Address is not programmed, - // then program the Power Management Base Address from a PCD. + // then program it now. // - PciAndThenOr32 (Pmba, (UINT32) ~0xFFC0, PcdGet16 (PcdAcpiPmBaseAddress)); + PciAndThenOr32 (Pmba, (UINT32) ~0xFFC0, PIIX4_PMBA_VALUE); // // Enable PMBA I/O port decodes // PciOr8 (AcpiCtlReg, AcpiEnBit); } mAcpiTimerIoAddr = (PciRead32 (Pmba) & ~PMBA_RTE) + ACPI_TIMER_OFFSET; diff --git a/OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.c b/OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.c index 5164769f6020..c46055a09b52 100644 --- a/OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.c +++ b/OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.c @@ -11,17 +11,16 @@ 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 /** The constructor function enables ACPI IO space. If ACPI I/O space not enabled, this function will enable it. It will always return RETURN_SUCCESS. @@ -62,19 +61,19 @@ AcpiTimerLibConstructor ( } // // Check to see if the Power Management Base Address is already enabled // if ((PciRead8 (AcpiCtlReg) & AcpiEnBit) == 0) { // // If the Power Management Base Address is not programmed, - // then program the Power Management Base Address from a PCD. + // then program it now. // - PciAndThenOr32 (Pmba, (UINT32) ~0xFFC0, PcdGet16 (PcdAcpiPmBaseAddress)); + PciAndThenOr32 (Pmba, (UINT32) ~0xFFC0, PIIX4_PMBA_VALUE); // // Enable PMBA I/O port decodes // PciOr8 (AcpiCtlReg, AcpiEnBit); } return RETURN_SUCCESS; diff --git a/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c b/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c index 6d149e84c21e..308a6002149d 100644 --- a/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c +++ b/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c @@ -12,28 +12,29 @@ **/ #include #include #include #include -#include #include +#include + VOID AcpiPmControl ( UINTN SuspendType ) { ASSERT (SuspendType < 6); - IoBitFieldWrite16 (PcdGet16 (PcdAcpiPmBaseAddress) + 4, 10, 13, (UINT16) SuspendType); - IoOr16 (PcdGet16 (PcdAcpiPmBaseAddress) + 4, BIT13); + IoBitFieldWrite16 (PIIX4_PMBA_VALUE + 4, 10, 13, (UINT16) SuspendType); + IoOr16 (PIIX4_PMBA_VALUE + 4, BIT13); CpuDeadLoop (); } /** Calling this function causes a system-wide reset. This sets all circuitry within the system to its initial state. This type of reset is asynchronous to system operation and operates without regard to cycle boundaries. diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c index 4be9922aeb1f..2348b56f0b22 100644 --- a/OvmfPkg/PlatformPei/Platform.c +++ b/OvmfPkg/PlatformPei/Platform.c @@ -407,17 +407,17 @@ MiscInitialization ( // has been configured (e.g., by Xen) and skip the setup here. // This matches the logic in AcpiTimerLibConstructor (). // if ((PciRead8 (AcpiCtlReg) & AcpiEnBit) == 0) { // // The PEI phase should be exited with fully accessibe ACPI PM IO space: // 1. set PMBA // - PciAndThenOr32 (Pmba, (UINT32) ~0xFFC0, PcdGet16 (PcdAcpiPmBaseAddress)); + PciAndThenOr32 (Pmba, (UINT32) ~0xFFC0, PIIX4_PMBA_VALUE); // // 2. set PCICMD/IOSE // PciOr8 (PmCmd, EFI_PCI_COMMAND_IO_SPACE); // // 3. set ACPI PM IO enable bit (PMREGMISC:PMIOSE or ACPI_CNTL:ACPI_EN)