diff options
author | Min Xu <min.m.xu@intel.com> | 2021-12-14 10:54:14 +0800 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2022-04-02 10:09:47 +0000 |
commit | f674fa9cde3d2d6919bb3e35b94d95c098b6696a (patch) | |
tree | 5f97f1ccf5992f549791452423fd9cc6659f6f77 /OvmfPkg | |
parent | 55fda68a80088e709e6393b0a03c68ab59e27390 (diff) | |
download | edk2-f674fa9cde3d2d6919bb3e35b94d95c098b6696a.tar.gz edk2-f674fa9cde3d2d6919bb3e35b94d95c098b6696a.tar.bz2 edk2-f674fa9cde3d2d6919bb3e35b94d95c098b6696a.zip |
OvmfPkg: Update DxeAcpiTimerLib to read HostBridgeDevId in PlatformInfoHob
RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3429
The entrypoint of DxeAcpiTimerLib checks HostBridgeDevId by reading
PcdOvmfHostBridgePciDevId. If the DevId is not set, ASSERT is
triggered. Normally this DevId is set in PlatformPei which is executed
in PEI phase.
This patch-set is introducing PEI-less boot which means PEI phase is
skipped. So there is no chance to set this DevId. Instead HostBridgeDevId
is set in PlatformInfoHob. So we can check if PlatformInfoHob exists and
if HostBridgeDevId is set in this Hob.
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Diffstat (limited to 'OvmfPkg')
-rw-r--r-- | OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c | 25 | ||||
-rw-r--r-- | OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf | 7 |
2 files changed, 26 insertions, 6 deletions
diff --git a/OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c b/OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c index 1158461874..01a41a6a45 100644 --- a/OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c +++ b/OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c @@ -6,10 +6,16 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
+#include <Uefi/UefiBaseType.h>
+#include <Uefi/UefiMultiPhase.h>
+#include <Pi/PiBootMode.h>
+#include <Pi/PiHob.h>
+#include <Library/HobLib.h>
#include <Library/DebugLib.h>
#include <Library/IoLib.h>
#include <Library/PcdLib.h>
#include <Library/PciLib.h>
+#include <Library/PlatformInitLib.h>
#include <OvmfPlatforms.h>
//
@@ -36,13 +42,26 @@ AcpiTimerLibConstructor ( VOID
)
{
- UINT16 HostBridgeDevId;
- UINTN Pmba;
+ UINT16 HostBridgeDevId;
+ UINTN Pmba;
+ EFI_HOB_GUID_TYPE *GuidHob;
+ EFI_HOB_PLATFORM_INFO *PlatformInfoHob = NULL;
//
// Query Host Bridge DID to determine platform type
+ // Tdx guest stores the HostBridgePciDevId in a GuidHob.
+ // So we first check if this HOB exists
//
- HostBridgeDevId = PcdGet16 (PcdOvmfHostBridgePciDevId);
+ GuidHob = GetFirstGuidHob (&gUefiOvmfPkgPlatformInfoGuid);
+ if (GuidHob != NULL) {
+ PlatformInfoHob = (EFI_HOB_PLATFORM_INFO *)GET_GUID_HOB_DATA (GuidHob);
+ HostBridgeDevId = PlatformInfoHob->HostBridgeDevId;
+ } else {
+ DEBUG ((DEBUG_ERROR, "PlatformInfoHob is not found.\n"));
+ ASSERT (FALSE);
+ return RETURN_UNSUPPORTED;
+ }
+
switch (HostBridgeDevId) {
case INTEL_82441_DEVICE_ID:
Pmba = POWER_MGMT_REGISTER_PIIX4 (PIIX4_PMBA);
diff --git a/OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf b/OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf index e29872add3..9c364be886 100644 --- a/OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf +++ b/OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf @@ -26,10 +26,11 @@ MdePkg/MdePkg.dec
OvmfPkg/OvmfPkg.dec
-[Pcd]
- gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId
-
[LibraryClasses]
BaseLib
PciLib
IoLib
+ HobLib
+
+[Guids]
+ gUefiOvmfPkgPlatformInfoGuid ## CONSUMES
|