diff --git a/OvmfPkg/SmbiosPlatformDxe/Qemu.c b/OvmfPkg/SmbiosPlatformDxe/Qemu.c index fcfc3e33c2..a668c6ac21 100644 --- a/OvmfPkg/SmbiosPlatformDxe/Qemu.c +++ b/OvmfPkg/SmbiosPlatformDxe/Qemu.c @@ -48,3 +48,36 @@ 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.c b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c index f280a1852d..7bcf83762e 100644 --- a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c +++ b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c @@ -10,12 +10,10 @@ #include // SMBIOS_TABLE_TYPE0 #include // ASSERT_EFI_ERROR() -#include // FreePool() #include // gBS #include // EFI_SMBIOS_PROTOCOL #include "SmbiosPlatformDxe.h" -#include "XenSmbiosPlatformDxe.h" #define TYPE0_STRINGS \ "EFI Development Kit II / OVMF\0" /* Vendor */ \ @@ -168,50 +166,3 @@ InstallAllStructures ( return EFI_SUCCESS; } - - -/** - 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; - SMBIOS_TABLE_ENTRY_POINT *EntryPointStructure; - UINT8 *SmbiosTables; - - Status = EFI_NOT_FOUND; - // - // Add Xen or QEMU SMBIOS data if found - // - EntryPointStructure = GetXenSmbiosTables (); - if (EntryPointStructure != NULL) { - SmbiosTables = (UINT8*)(UINTN)EntryPointStructure->TableAddress; - } else { - SmbiosTables = GetQemuSmbiosTables (); - } - - if (SmbiosTables != NULL) { - Status = InstallAllStructures (SmbiosTables); - - // - // Free SmbiosTables if allocated by Qemu (i.e., NOT by Xen): - // - if (EntryPointStructure == NULL) { - FreePool (SmbiosTables); - } - } - - return Status; -} diff --git a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.h b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.h index 0ae2556fe8..213a7f39e9 100644 --- a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.h +++ b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.h @@ -22,15 +22,4 @@ InstallAllStructures ( IN UINT8 *TableAddress ); -/** - Locates and extracts the QEMU SMBIOS table 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 140fa16ac1..eaee73110d 100644 --- a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf +++ b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf @@ -27,13 +27,6 @@ Qemu.c SmbiosPlatformDxe.c SmbiosPlatformDxe.h - XenSmbiosPlatformDxe.h - -[Sources.IA32, Sources.X64] - X86Xen.c - -[Sources.ARM, Sources.AARCH64] - ArmXen.c [Packages] MdePkg/MdePkg.dec @@ -47,19 +40,12 @@ UefiBootServicesTableLib UefiDriverEntryPoint -[LibraryClasses.IA32, LibraryClasses.X64] - BaseLib - HobLib - [Pcd] gUefiOvmfPkgTokenSpaceGuid.PcdQemuSmbiosValidated [Protocols] gEfiSmbiosProtocolGuid # PROTOCOL ALWAYS_CONSUMED -[Guids.IA32, Guids.X64] - gEfiXenInfoGuid - [Depex] gEfiSmbiosProtocolGuid diff --git a/OvmfPkg/SmbiosPlatformDxe/Xen.c b/OvmfPkg/SmbiosPlatformDxe/Xen.c new file mode 100644 index 0000000000..75d9550913 --- /dev/null +++ b/OvmfPkg/SmbiosPlatformDxe/Xen.c @@ -0,0 +1,49 @@ +/** @file + This driver installs SMBIOS information for OVMF on Xen + + Copyright (C) 2021, Red Hat, Inc. + Copyright (c) 2011, Bei Guan + Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include "SmbiosPlatformDxe.h" +#include "XenSmbiosPlatformDxe.h" + +/** + Installs SMBIOS information for OVMF on Xen + + @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 +XenSmbiosTablePublishEntry ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + SMBIOS_TABLE_ENTRY_POINT *EntryPointStructure; + UINT8 *SmbiosTables; + + Status = EFI_NOT_FOUND; + // + // Add Xen SMBIOS data if found + // + EntryPointStructure = GetXenSmbiosTables (); + if (EntryPointStructure != NULL) { + SmbiosTables = (UINT8*)(UINTN)EntryPointStructure->TableAddress; + if (SmbiosTables != NULL) { + Status = InstallAllStructures (SmbiosTables); + } + } + + return Status; +} diff --git a/OvmfPkg/SmbiosPlatformDxe/XenSmbiosPlatformDxe.inf b/OvmfPkg/SmbiosPlatformDxe/XenSmbiosPlatformDxe.inf index 5a093c69af..7f4588e33d 100644 --- a/OvmfPkg/SmbiosPlatformDxe/XenSmbiosPlatformDxe.inf +++ b/OvmfPkg/SmbiosPlatformDxe/XenSmbiosPlatformDxe.inf @@ -16,7 +16,7 @@ MODULE_TYPE = DXE_DRIVER VERSION_STRING = 1.0 - ENTRY_POINT = SmbiosTablePublishEntry + ENTRY_POINT = XenSmbiosTablePublishEntry # # The following information is for reference only and not required by the build tools. @@ -25,9 +25,9 @@ # [Sources] - Qemu.c SmbiosPlatformDxe.c SmbiosPlatformDxe.h + Xen.c XenSmbiosPlatformDxe.h [Sources.IA32, Sources.X64] @@ -38,13 +38,12 @@ [Packages] MdePkg/MdePkg.dec + +[Packages.IA32, Packages.X64] OvmfPkg/OvmfPkg.dec [LibraryClasses] DebugLib - MemoryAllocationLib - PcdLib - QemuFwCfgLib UefiBootServicesTableLib UefiDriverEntryPoint @@ -52,9 +51,6 @@ BaseLib HobLib -[Pcd] - gUefiOvmfPkgTokenSpaceGuid.PcdQemuSmbiosValidated - [Protocols] gEfiSmbiosProtocolGuid # PROTOCOL ALWAYS_CONSUMED