mirror of https://github.com/acidanthera/audk.git
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>
This commit is contained in:
parent
81bbc1452c
commit
cda98df162
|
@ -50,6 +50,10 @@ typedef struct {
|
||||||
UINT32 S3AcpiReservedMemorySize;
|
UINT32 S3AcpiReservedMemorySize;
|
||||||
|
|
||||||
UINT64 FeatureControlValue;
|
UINT64 FeatureControlValue;
|
||||||
|
|
||||||
|
BOOLEAN QemuFwCfgChecked;
|
||||||
|
BOOLEAN QemuFwCfgSupported;
|
||||||
|
BOOLEAN QemuFwCfgDmaSupported;
|
||||||
} EFI_HOB_PLATFORM_INFO;
|
} EFI_HOB_PLATFORM_INFO;
|
||||||
#pragma pack()
|
#pragma pack()
|
||||||
|
|
||||||
|
|
|
@ -9,17 +9,17 @@
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
#include <PiPei.h>
|
||||||
#include <Library/BaseLib.h>
|
#include <Library/BaseLib.h>
|
||||||
#include <Library/IoLib.h>
|
|
||||||
#include <Library/DebugLib.h>
|
#include <Library/DebugLib.h>
|
||||||
|
#include <Library/HobLib.h>
|
||||||
|
#include <Library/IoLib.h>
|
||||||
|
#include <Library/PlatformInitLib.h>
|
||||||
#include <Library/QemuFwCfgLib.h>
|
#include <Library/QemuFwCfgLib.h>
|
||||||
#include <WorkArea.h>
|
#include <WorkArea.h>
|
||||||
|
|
||||||
#include "QemuFwCfgLibInternal.h"
|
#include "QemuFwCfgLibInternal.h"
|
||||||
|
|
||||||
STATIC BOOLEAN mQemuFwCfgSupported = FALSE;
|
|
||||||
STATIC BOOLEAN mQemuFwCfgDmaSupported;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Check if it is Tdx guest
|
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
|
RETURN_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
QemuFwCfgInitialize (
|
QemuFwCfgInitialize (
|
||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
QemuFwCfgProbe (&mQemuFwCfgSupported, &mQemuFwCfgDmaSupported);
|
|
||||||
return RETURN_SUCCESS;
|
return RETURN_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,7 +143,9 @@ InternalQemuFwCfgIsAvailable (
|
||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return mQemuFwCfgSupported;
|
EFI_HOB_PLATFORM_INFO *PlatformInfoHob = QemuFwCfgGetPlatformInfo ();
|
||||||
|
|
||||||
|
return PlatformInfoHob->QemuFwCfgSupported;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -132,7 +160,9 @@ InternalQemuFwCfgDmaIsAvailable (
|
||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return mQemuFwCfgDmaSupported;
|
EFI_HOB_PLATFORM_INFO *PlatformInfoHob = QemuFwCfgGetPlatformInfo ();
|
||||||
|
|
||||||
|
return PlatformInfoHob->QemuFwCfgDmaSupported;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -39,8 +39,12 @@
|
||||||
BaseLib
|
BaseLib
|
||||||
BaseMemoryLib
|
BaseMemoryLib
|
||||||
DebugLib
|
DebugLib
|
||||||
|
HobLib
|
||||||
IoLib
|
IoLib
|
||||||
MemoryAllocationLib
|
MemoryAllocationLib
|
||||||
|
|
||||||
|
[Guids]
|
||||||
|
gUefiOvmfPkgPlatformInfoGuid
|
||||||
|
|
||||||
[Pcd]
|
[Pcd]
|
||||||
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfWorkAreaBase
|
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfWorkAreaBase
|
||||||
|
|
Loading…
Reference in New Issue