diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2022-12-02 14:10:09 +0100 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2022-12-14 17:45:41 +0000 |
commit | cda98df16228970dcf9a4ce2af5368219711b4b0 (patch) | |
tree | bd172b19636374812c4921d03a42d35798039295 /OvmfPkg | |
parent | 81bbc1452c972218f071cd4a8f5899df974b1dae (diff) | |
download | edk2-cda98df16228970dcf9a4ce2af5368219711b4b0.tar.gz edk2-cda98df16228970dcf9a4ce2af5368219711b4b0.tar.bz2 edk2-cda98df16228970dcf9a4ce2af5368219711b4b0.zip |
OvmfPkg/QemuFwCfgLib: remove mQemuFwCfgSupported + mQemuFwCfgDmaSupported
Remove global variables, store the state in PlatformInfoHob instead.
Probing for fw_cfg happens on first use, at library initialization
time the Hob might not be present yet.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Tested-by: Tom Lendacky <thomas.lendacky@amd.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Diffstat (limited to 'OvmfPkg')
-rw-r--r-- | OvmfPkg/Include/Library/PlatformInitLib.h | 4 | ||||
-rw-r--r-- | OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPei.c | 44 | ||||
-rw-r--r-- | OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPeiLib.inf | 4 |
3 files changed, 45 insertions, 7 deletions
diff --git a/OvmfPkg/Include/Library/PlatformInitLib.h b/OvmfPkg/Include/Library/PlatformInitLib.h index da7ed76041..bf6f90a576 100644 --- a/OvmfPkg/Include/Library/PlatformInitLib.h +++ b/OvmfPkg/Include/Library/PlatformInitLib.h @@ -50,6 +50,10 @@ typedef struct { UINT32 S3AcpiReservedMemorySize;
UINT64 FeatureControlValue;
+
+ BOOLEAN QemuFwCfgChecked;
+ BOOLEAN QemuFwCfgSupported;
+ BOOLEAN QemuFwCfgDmaSupported;
} EFI_HOB_PLATFORM_INFO;
#pragma pack()
diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPei.c b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPei.c index a936fd1039..da86a3c84c 100644 --- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPei.c +++ b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPei.c @@ -9,17 +9,17 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
+#include <PiPei.h>
#include <Library/BaseLib.h>
-#include <Library/IoLib.h>
#include <Library/DebugLib.h>
+#include <Library/HobLib.h>
+#include <Library/IoLib.h>
+#include <Library/PlatformInitLib.h>
#include <Library/QemuFwCfgLib.h>
#include <WorkArea.h>
#include "QemuFwCfgLibInternal.h"
-STATIC BOOLEAN mQemuFwCfgSupported = FALSE;
-STATIC BOOLEAN mQemuFwCfgDmaSupported;
-
/**
Check if it is Tdx guest
@@ -93,13 +93,39 @@ QemuFwCfgProbe ( ));
}
+STATIC
+EFI_HOB_PLATFORM_INFO *
+QemuFwCfgGetPlatformInfo (
+ VOID
+ )
+{
+ EFI_HOB_PLATFORM_INFO *PlatformInfoHob;
+ EFI_HOB_GUID_TYPE *GuidHob;
+
+ GuidHob = GetFirstGuidHob (&gUefiOvmfPkgPlatformInfoGuid);
+ if (GuidHob == NULL) {
+ return NULL;
+ }
+
+ PlatformInfoHob = (EFI_HOB_PLATFORM_INFO *)GET_GUID_HOB_DATA (GuidHob);
+
+ if (!PlatformInfoHob->QemuFwCfgChecked) {
+ QemuFwCfgProbe (
+ &PlatformInfoHob->QemuFwCfgSupported,
+ &PlatformInfoHob->QemuFwCfgDmaSupported
+ );
+ PlatformInfoHob->QemuFwCfgChecked = TRUE;
+ }
+
+ return PlatformInfoHob;
+}
+
RETURN_STATUS
EFIAPI
QemuFwCfgInitialize (
VOID
)
{
- QemuFwCfgProbe (&mQemuFwCfgSupported, &mQemuFwCfgDmaSupported);
return RETURN_SUCCESS;
}
@@ -117,7 +143,9 @@ InternalQemuFwCfgIsAvailable ( VOID
)
{
- return mQemuFwCfgSupported;
+ EFI_HOB_PLATFORM_INFO *PlatformInfoHob = QemuFwCfgGetPlatformInfo ();
+
+ return PlatformInfoHob->QemuFwCfgSupported;
}
/**
@@ -132,7 +160,9 @@ InternalQemuFwCfgDmaIsAvailable ( VOID
)
{
- return mQemuFwCfgDmaSupported;
+ EFI_HOB_PLATFORM_INFO *PlatformInfoHob = QemuFwCfgGetPlatformInfo ();
+
+ return PlatformInfoHob->QemuFwCfgDmaSupported;
}
/**
diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPeiLib.inf b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPeiLib.inf index 1d7543a7d4..b1f548febc 100644 --- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPeiLib.inf +++ b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPeiLib.inf @@ -39,8 +39,12 @@ BaseLib
BaseMemoryLib
DebugLib
+ HobLib
IoLib
MemoryAllocationLib
+[Guids]
+ gUefiOvmfPkgPlatformInfoGuid
+
[Pcd]
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfWorkAreaBase
|