From 2ccefa32a65164da2ec74e8a1e81f90257967c7f Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Fri, 10 Dec 2021 22:41:55 +0800 Subject: OvmfPkg: Create global entry point for SMBIOS parsing Move the generic entry point part out of Qemu.c to anticipate the addition of new ways of retrieving the SMBIOS table. Reviewed-by: Gerd Hoffmann Reviewed-by: Jiewen Yao Signed-off-by: Sebastien Boeuf --- OvmfPkg/SmbiosPlatformDxe/EntryPoint.c | 42 +++++++++++++++++++++++++ OvmfPkg/SmbiosPlatformDxe/Qemu.c | 35 --------------------- OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.h | 11 +++++++ OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf | 1 + 4 files changed, 54 insertions(+), 35 deletions(-) create mode 100644 OvmfPkg/SmbiosPlatformDxe/EntryPoint.c (limited to 'OvmfPkg/SmbiosPlatformDxe') diff --git a/OvmfPkg/SmbiosPlatformDxe/EntryPoint.c b/OvmfPkg/SmbiosPlatformDxe/EntryPoint.c new file mode 100644 index 0000000000..f53af2b2e6 --- /dev/null +++ b/OvmfPkg/SmbiosPlatformDxe/EntryPoint.c @@ -0,0 +1,42 @@ +/** @file + Find and extract SMBIOS data. + + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include // FreePool() + +#include "SmbiosPlatformDxe.h" + +/** + Installs SMBIOS information for OVMF + + @param ImageHandle Module's image handle + @param SystemTable Pointer of EFI_SYSTEM_TABLE + + @retval EFI_SUCCESS Smbios data successfully installed + @retval Other Smbios data was not installed + +**/ +EFI_STATUS +EFIAPI +SmbiosTablePublishEntry ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + UINT8 *SmbiosTables; + + Status = EFI_NOT_FOUND; + // + // Add QEMU SMBIOS data if found + // + SmbiosTables = GetQemuSmbiosTables (); + if (SmbiosTables != NULL) { + Status = InstallAllStructures (SmbiosTables); + FreePool (SmbiosTables); + } + + return Status; +} diff --git a/OvmfPkg/SmbiosPlatformDxe/Qemu.c b/OvmfPkg/SmbiosPlatformDxe/Qemu.c index 4dae4b0b98..9613c090c5 100644 --- a/OvmfPkg/SmbiosPlatformDxe/Qemu.c +++ b/OvmfPkg/SmbiosPlatformDxe/Qemu.c @@ -11,8 +11,6 @@ #include // PcdGetBool() #include // QemuFwCfgFindFile() -#include "SmbiosPlatformDxe.h" - /** Locates and extracts the QEMU SMBIOS data if present in fw_cfg @@ -51,36 +49,3 @@ GetQemuSmbiosTables ( return QemuTables; } - -/** - Installs SMBIOS information for OVMF - - @param ImageHandle Module's image handle - @param SystemTable Pointer of EFI_SYSTEM_TABLE - - @retval EFI_SUCCESS Smbios data successfully installed - @retval Other Smbios data was not installed - -**/ -EFI_STATUS -EFIAPI -SmbiosTablePublishEntry ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - EFI_STATUS Status; - UINT8 *SmbiosTables; - - Status = EFI_NOT_FOUND; - // - // Add QEMU SMBIOS data if found - // - SmbiosTables = GetQemuSmbiosTables (); - if (SmbiosTables != NULL) { - Status = InstallAllStructures (SmbiosTables); - FreePool (SmbiosTables); - } - - return Status; -} diff --git a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.h b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.h index 74e314a895..b7bf004be9 100644 --- a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.h +++ b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.h @@ -22,4 +22,15 @@ InstallAllStructures ( IN UINT8 *TableAddress ); +/** + Locates and extracts the QEMU SMBIOS data if present in fw_cfg + + @return Address of extracted QEMU SMBIOS data + +**/ +UINT8 * +GetQemuSmbiosTables ( + VOID + ); + #endif diff --git a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf index eaee73110d..e239a631f2 100644 --- a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf +++ b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf @@ -24,6 +24,7 @@ # [Sources] + EntryPoint.c Qemu.c SmbiosPlatformDxe.c SmbiosPlatformDxe.h -- cgit v1.2.3