]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/SmbiosPlatformDxe/Qemu.c
OvmfPkg: Apply uncrustify changes
[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
ac0a286f
MK
27 EFI_STATUS Status;\r
28 FIRMWARE_CONFIG_ITEM Tables;\r
29 UINTN TablesSize;\r
30 UINT8 *QemuTables;\r
a145e28d 31\r
92dc0bb2 32 if (!PcdGetBool (PcdQemuSmbiosValidated)) {\r
a145e28d
GS
33 return NULL;\r
34 }\r
35\r
ac0a286f
MK
36 Status = QemuFwCfgFindFile (\r
37 "etc/smbios/smbios-tables",\r
38 &Tables,\r
39 &TablesSize\r
40 );\r
92dc0bb2
LE
41 ASSERT_EFI_ERROR (Status);\r
42 ASSERT (TablesSize > 0);\r
a145e28d
GS
43\r
44 QemuTables = AllocatePool (TablesSize);\r
45 if (QemuTables == NULL) {\r
46 return NULL;\r
47 }\r
48\r
49 QemuFwCfgSelectItem (Tables);\r
50 QemuFwCfgReadBytes (TablesSize, QemuTables);\r
51\r
52 return QemuTables;\r
53}\r
ce270905
LE
54\r
55/**\r
56 Installs SMBIOS information for OVMF\r
57\r
58 @param ImageHandle Module's image handle\r
59 @param SystemTable Pointer of EFI_SYSTEM_TABLE\r
60\r
61 @retval EFI_SUCCESS Smbios data successfully installed\r
62 @retval Other Smbios data was not installed\r
63\r
64**/\r
65EFI_STATUS\r
66EFIAPI\r
67SmbiosTablePublishEntry (\r
ac0a286f
MK
68 IN EFI_HANDLE ImageHandle,\r
69 IN EFI_SYSTEM_TABLE *SystemTable\r
ce270905
LE
70 )\r
71{\r
ac0a286f
MK
72 EFI_STATUS Status;\r
73 UINT8 *SmbiosTables;\r
ce270905
LE
74\r
75 Status = EFI_NOT_FOUND;\r
76 //\r
77 // Add QEMU SMBIOS data if found\r
78 //\r
79 SmbiosTables = GetQemuSmbiosTables ();\r
80 if (SmbiosTables != NULL) {\r
81 Status = InstallAllStructures (SmbiosTables);\r
82 FreePool (SmbiosTables);\r
83 }\r
84\r
85 return Status;\r
86}\r