]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/SmbiosPlatformDxe/Qemu.c
DynamicTablesPkg: Change complex DEBUG_CODE() to DEBUG_CODE_BEGIN/END()
[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 14#include "SmbiosPlatformDxe.h"\r
a145e28d
GS
15\r
16/**\r
17 Locates and extracts the QEMU SMBIOS data if present in fw_cfg\r
18\r
19 @return Address of extracted QEMU SMBIOS data\r
20\r
21**/\r
22UINT8 *\r
23GetQemuSmbiosTables (\r
24 VOID\r
25 )\r
26{\r
92dc0bb2
LE
27 EFI_STATUS Status;\r
28 FIRMWARE_CONFIG_ITEM Tables;\r
29 UINTN TablesSize;\r
a145e28d
GS
30 UINT8 *QemuTables;\r
31\r
92dc0bb2 32 if (!PcdGetBool (PcdQemuSmbiosValidated)) {\r
a145e28d
GS
33 return NULL;\r
34 }\r
35\r
92dc0bb2
LE
36 Status = QemuFwCfgFindFile ("etc/smbios/smbios-tables", &Tables,\r
37 &TablesSize);\r
38 ASSERT_EFI_ERROR (Status);\r
39 ASSERT (TablesSize > 0);\r
a145e28d
GS
40\r
41 QemuTables = AllocatePool (TablesSize);\r
42 if (QemuTables == NULL) {\r
43 return NULL;\r
44 }\r
45\r
46 QemuFwCfgSelectItem (Tables);\r
47 QemuFwCfgReadBytes (TablesSize, QemuTables);\r
48\r
49 return QemuTables;\r
50}\r
ce270905
LE
51\r
52/**\r
53 Installs SMBIOS information for OVMF\r
54\r
55 @param ImageHandle Module's image handle\r
56 @param SystemTable Pointer of EFI_SYSTEM_TABLE\r
57\r
58 @retval EFI_SUCCESS Smbios data successfully installed\r
59 @retval Other Smbios data was not installed\r
60\r
61**/\r
62EFI_STATUS\r
63EFIAPI\r
64SmbiosTablePublishEntry (\r
65 IN EFI_HANDLE ImageHandle,\r
66 IN EFI_SYSTEM_TABLE *SystemTable\r
67 )\r
68{\r
69 EFI_STATUS Status;\r
70 UINT8 *SmbiosTables;\r
71\r
72 Status = EFI_NOT_FOUND;\r
73 //\r
74 // Add QEMU SMBIOS data if found\r
75 //\r
76 SmbiosTables = GetQemuSmbiosTables ();\r
77 if (SmbiosTables != NULL) {\r
78 Status = InstallAllStructures (SmbiosTables);\r
79 FreePool (SmbiosTables);\r
80 }\r
81\r
82 return Status;\r
83}\r