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