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@citrix.com> Cc: Ard Biesheuvel <ardb+tianocore@kernel.org> Cc: Jordan Justen <jordan.l.justen@intel.com> Cc: Julien Grall <julien@xen.org> Cc: Philippe Mathieu-Daudé <philmd@redhat.com> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2122 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Message-Id: <20210526201446.12554-43-lersek@redhat.com> Reviewed-by: Ard Biesheuvel <ardb@kernel.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
		
			
				
	
	
		
			84 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			84 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
/** @file
 | 
						|
  Find and extract QEMU SMBIOS data from fw_cfg.
 | 
						|
 | 
						|
  Copyright (C) 2014, Gabriel L. Somlo <somlo@cmu.edu>
 | 
						|
 | 
						|
  SPDX-License-Identifier: BSD-2-Clause-Patent
 | 
						|
**/
 | 
						|
 | 
						|
#include <Library/DebugLib.h>            // ASSERT_EFI_ERROR()
 | 
						|
#include <Library/MemoryAllocationLib.h> // AllocatePool()
 | 
						|
#include <Library/PcdLib.h>              // PcdGetBool()
 | 
						|
#include <Library/QemuFwCfgLib.h>        // QemuFwCfgFindFile()
 | 
						|
 | 
						|
#include "SmbiosPlatformDxe.h"
 | 
						|
 | 
						|
/**
 | 
						|
  Locates and extracts the QEMU SMBIOS data if present in fw_cfg
 | 
						|
 | 
						|
  @return                 Address of extracted QEMU SMBIOS data
 | 
						|
 | 
						|
**/
 | 
						|
UINT8 *
 | 
						|
GetQemuSmbiosTables (
 | 
						|
  VOID
 | 
						|
  )
 | 
						|
{
 | 
						|
  EFI_STATUS               Status;
 | 
						|
  FIRMWARE_CONFIG_ITEM     Tables;
 | 
						|
  UINTN                    TablesSize;
 | 
						|
  UINT8                    *QemuTables;
 | 
						|
 | 
						|
  if (!PcdGetBool (PcdQemuSmbiosValidated)) {
 | 
						|
    return NULL;
 | 
						|
  }
 | 
						|
 | 
						|
  Status = QemuFwCfgFindFile ("etc/smbios/smbios-tables", &Tables,
 | 
						|
             &TablesSize);
 | 
						|
  ASSERT_EFI_ERROR (Status);
 | 
						|
  ASSERT (TablesSize > 0);
 | 
						|
 | 
						|
  QemuTables = AllocatePool (TablesSize);
 | 
						|
  if (QemuTables == NULL) {
 | 
						|
    return NULL;
 | 
						|
  }
 | 
						|
 | 
						|
  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;
 | 
						|
}
 |