[edk2-devel] [PATCH 42/43] OvmfPkg/SmbiosPlatformDxe: split Xen entry point from QEMU entry point

Laszlo Ersek lersek at redhat.com
Wed May 26 20:14:45 UTC 2021


Remove the SmbiosTablePublishEntry() function from "SmbiosPlatformDxe.c".
"SmbiosPlatformDxe.c" becomes hypervisor-agnostic.

Add SmbiosTablePublishEntry() back, simplified for QEMU, to the existent
file "Qemu.c". The GetQemuSmbiosTables() function no longer needs to be
declared in "SmbiosPlatformDxe.h"; "SmbiosPlatformDxe.h" becomes
hypervisor-agnostic.

Add SmbiosTablePublishEntry() back, renamed and simplified for Xen, to the
new, arch-independent file "Xen.c". (The existent Xen-specific C files are
arch-dependent.)

Update both INF files; remove the dependencies that are now superfluous in
each.

Cc: Anthony Perard <anthony.perard at citrix.com>
Cc: Ard Biesheuvel <ardb+tianocore at kernel.org>
Cc: Jordan Justen <jordan.l.justen at intel.com>
Cc: Julien Grall <julien at xen.org>
Cc: Philippe Mathieu-Daudé <philmd at redhat.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2122
Signed-off-by: Laszlo Ersek <lersek at redhat.com>
---
 OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf    | 14 ------
 OvmfPkg/SmbiosPlatformDxe/XenSmbiosPlatformDxe.inf | 12 ++---
 OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.h      | 11 -----
 OvmfPkg/SmbiosPlatformDxe/Qemu.c                   | 33 +++++++++++++
 OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c      | 49 --------------------
 OvmfPkg/SmbiosPlatformDxe/Xen.c                    | 49 ++++++++++++++++++++
 6 files changed, 86 insertions(+), 82 deletions(-)

diff --git a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
index 140fa16ac135..eaee73110d27 100644
--- a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
+++ b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
@@ -24,19 +24,12 @@ [Defines]
 #
 
 [Sources]
   Qemu.c
   SmbiosPlatformDxe.c
   SmbiosPlatformDxe.h
-  XenSmbiosPlatformDxe.h
-
-[Sources.IA32, Sources.X64]
-  X86Xen.c
-
-[Sources.ARM, Sources.AARCH64]
-  ArmXen.c
 
 [Packages]
   MdePkg/MdePkg.dec
   OvmfPkg/OvmfPkg.dec
 
 [LibraryClasses]
@@ -44,22 +37,15 @@ [LibraryClasses]
   MemoryAllocationLib
   PcdLib
   QemuFwCfgLib
   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/XenSmbiosPlatformDxe.inf b/OvmfPkg/SmbiosPlatformDxe/XenSmbiosPlatformDxe.inf
index 5a093c69afd9..7f4588e33d1e 100644
--- a/OvmfPkg/SmbiosPlatformDxe/XenSmbiosPlatformDxe.inf
+++ b/OvmfPkg/SmbiosPlatformDxe/XenSmbiosPlatformDxe.inf
@@ -13,51 +13,47 @@ [Defines]
   INF_VERSION                    = 0x00010005
   BASE_NAME                      = XenSmbiosPlatformDxe
   FILE_GUID                      = c41f0579-5598-40f1-95db-3983c8ebbe2a
   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.
 #
 #  VALID_ARCHITECTURES           = IA32 X64 EBC ARM AARCH64
 #
 
 [Sources]
-  Qemu.c
   SmbiosPlatformDxe.c
   SmbiosPlatformDxe.h
+  Xen.c
   XenSmbiosPlatformDxe.h
 
 [Sources.IA32, Sources.X64]
   X86Xen.c
 
 [Sources.ARM, Sources.AARCH64]
   ArmXen.c
 
 [Packages]
   MdePkg/MdePkg.dec
+
+[Packages.IA32, Packages.X64]
   OvmfPkg/OvmfPkg.dec
 
 [LibraryClasses]
   DebugLib
-  MemoryAllocationLib
-  PcdLib
-  QemuFwCfgLib
   UefiBootServicesTableLib
   UefiDriverEntryPoint
 
 [LibraryClasses.IA32, LibraryClasses.X64]
   BaseLib
   HobLib
 
-[Pcd]
-  gUefiOvmfPkgTokenSpaceGuid.PcdQemuSmbiosValidated
-
 [Protocols]
   gEfiSmbiosProtocolGuid                      # PROTOCOL ALWAYS_CONSUMED
 
 [Guids.IA32, Guids.X64]
   gEfiXenInfoGuid
 
diff --git a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.h b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.h
index 0ae2556fe800..213a7f39e91d 100644
--- a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.h
+++ b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.h
@@ -19,18 +19,7 @@
 **/
 EFI_STATUS
 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/Qemu.c b/OvmfPkg/SmbiosPlatformDxe/Qemu.c
index fcfc3e33c28c..a668c6ac2123 100644
--- a/OvmfPkg/SmbiosPlatformDxe/Qemu.c
+++ b/OvmfPkg/SmbiosPlatformDxe/Qemu.c
@@ -45,6 +45,39 @@ GetQemuSmbiosTables (
 
   QemuFwCfgSelectItem (Tables);
   QemuFwCfgReadBytes (TablesSize, QemuTables);
 
   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 f280a1852ddd..7bcf83762e9b 100644
--- a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c
+++ b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c
@@ -7,18 +7,16 @@
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
 
 #include <IndustryStandard/SmBios.h>          // SMBIOS_TABLE_TYPE0
 #include <Library/DebugLib.h>                 // ASSERT_EFI_ERROR()
-#include <Library/MemoryAllocationLib.h>      // FreePool()
 #include <Library/UefiBootServicesTableLib.h> // gBS
 #include <Protocol/Smbios.h>                  // EFI_SMBIOS_PROTOCOL
 
 #include "SmbiosPlatformDxe.h"
-#include "XenSmbiosPlatformDxe.h"
 
 #define TYPE0_STRINGS \
   "EFI Development Kit II / OVMF\0"     /* Vendor */ \
   "0.0.0\0"                             /* BiosVersion */ \
   "02/06/2015\0"                        /* BiosReleaseDate */
 //
@@ -165,53 +163,6 @@ InstallAllStructures (
                        );
     ASSERT_EFI_ERROR (Status);
   }
 
   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/Xen.c b/OvmfPkg/SmbiosPlatformDxe/Xen.c
new file mode 100644
index 000000000000..75d9550913d1
--- /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 <gbtju85 at gmail.com>
+  Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.<BR>
+
+  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;
+}
-- 
2.19.1.3.g30247aa5d201




-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#75713): https://edk2.groups.io/g/devel/message/75713
Mute This Topic: https://groups.io/mt/83111228/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-






More information about the edk2-devel-archive mailing list