[edk2-devel] [PATCH 38/43] OvmfPkg/SmbiosPlatformDxe: locate SMBIOS protocol in InstallAllStructures()

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


Locate the SMBIOS protocol internally to the InstallAllStructures()
function. This has no performance impact (InstallAllStructures() is only
called once), but moving the code from the entry point function makes the
latter smaller. And that will be useful when we split the entry point
function to two versions.

Cc: Ard Biesheuvel <ardb+tianocore at kernel.org>
Cc: Jordan Justen <jordan.l.justen at intel.com>
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.c | 30 +++++++++-----------
 1 file changed, 14 insertions(+), 16 deletions(-)

diff --git a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c
index 6d73173aa512..757bec879e4a 100644
--- a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c
+++ b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c
@@ -92,27 +92,38 @@ SmbiosTableLength (
 }
 
 
 /**
   Install all structures from the given SMBIOS structures block
 
-  @param  Smbios               SMBIOS protocol
   @param  TableAddress         SMBIOS tables starting address
 
 **/
 EFI_STATUS
 InstallAllStructures (
-  IN EFI_SMBIOS_PROTOCOL       *Smbios,
   IN UINT8                     *TableAddress
   )
 {
+  EFI_SMBIOS_PROTOCOL       *Smbios;
   EFI_STATUS                Status;
   SMBIOS_STRUCTURE_POINTER  SmbiosTable;
   EFI_SMBIOS_HANDLE         SmbiosHandle;
   BOOLEAN                   NeedSmbiosType0;
 
+  //
+  // Find the SMBIOS protocol
+  //
+  Status = gBS->LocateProtocol (
+                  &gEfiSmbiosProtocolGuid,
+                  NULL,
+                  (VOID**)&Smbios
+                  );
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+
   SmbiosTable.Raw = TableAddress;
   if (SmbiosTable.Raw == NULL) {
     return EFI_INVALID_PARAMETER;
   }
 
   NeedSmbiosType0 = TRUE;
@@ -173,41 +184,28 @@ EFIAPI
 SmbiosTablePublishEntry (
   IN EFI_HANDLE           ImageHandle,
   IN EFI_SYSTEM_TABLE     *SystemTable
   )
 {
   EFI_STATUS                Status;
-  EFI_SMBIOS_PROTOCOL       *Smbios;
   SMBIOS_TABLE_ENTRY_POINT  *EntryPointStructure;
   UINT8                     *SmbiosTables;
 
-  //
-  // Find the SMBIOS protocol
-  //
-  Status = gBS->LocateProtocol (
-                  &gEfiSmbiosProtocolGuid,
-                  NULL,
-                  (VOID**)&Smbios
-                  );
-  if (EFI_ERROR (Status)) {
-    return Status;
-  }
-
   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 (Smbios, SmbiosTables);
+    Status = InstallAllStructures (SmbiosTables);
 
     //
     // Free SmbiosTables if allocated by Qemu (i.e., NOT by Xen):
     //
     if (EntryPointStructure == NULL) {
       FreePool (SmbiosTables);
-- 
2.19.1.3.g30247aa5d201




-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#75709): https://edk2.groups.io/g/devel/message/75709
Mute This Topic: https://groups.io/mt/83111142/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