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