]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/SmbiosPlatformDxe/Qemu.c
OvmfPkg/SmbiosPlatformDxe: locate SMBIOS protocol in InstallAllStructures()
[mirror_edk2.git] / OvmfPkg / SmbiosPlatformDxe / Qemu.c
1 /** @file
2 Find and extract QEMU SMBIOS data from fw_cfg.
3
4 Copyright (C) 2014, Gabriel L. Somlo <somlo@cmu.edu>
5
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7 **/
8
9 #include <Library/DebugLib.h> // ASSERT_EFI_ERROR()
10 #include <Library/MemoryAllocationLib.h> // AllocatePool()
11 #include <Library/PcdLib.h> // PcdGetBool()
12 #include <Library/QemuFwCfgLib.h> // QemuFwCfgFindFile()
13
14 #include "SmbiosPlatformDxe.h"
15
16 /**
17 Locates and extracts the QEMU SMBIOS data if present in fw_cfg
18
19 @return Address of extracted QEMU SMBIOS data
20
21 **/
22 UINT8 *
23 GetQemuSmbiosTables (
24 VOID
25 )
26 {
27 EFI_STATUS Status;
28 FIRMWARE_CONFIG_ITEM Tables;
29 UINTN TablesSize;
30 UINT8 *QemuTables;
31
32 if (!PcdGetBool (PcdQemuSmbiosValidated)) {
33 return NULL;
34 }
35
36 Status = QemuFwCfgFindFile ("etc/smbios/smbios-tables", &Tables,
37 &TablesSize);
38 ASSERT_EFI_ERROR (Status);
39 ASSERT (TablesSize > 0);
40
41 QemuTables = AllocatePool (TablesSize);
42 if (QemuTables == NULL) {
43 return NULL;
44 }
45
46 QemuFwCfgSelectItem (Tables);
47 QemuFwCfgReadBytes (TablesSize, QemuTables);
48
49 return QemuTables;
50 }