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+tianoc...@kernel.org> Cc: Jordan Justen <jordan.l.jus...@intel.com> Cc: Philippe Mathieu-Daudé <phi...@redhat.com> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2122 Signed-off-by: Laszlo Ersek <ler...@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/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-