1 | /** @file
|
---|
2 | Find and extract QEMU SMBIOS data from fw_cfg.
|
---|
3 |
|
---|
4 | Copyright (C) 2014, Gabriel L. Somlo <[email protected]>
|
---|
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 | /**
|
---|
15 | Locates and extracts the QEMU SMBIOS data if present in fw_cfg
|
---|
16 |
|
---|
17 | @return Address of extracted QEMU SMBIOS data
|
---|
18 |
|
---|
19 | **/
|
---|
20 | UINT8 *
|
---|
21 | GetQemuSmbiosTables (
|
---|
22 | VOID
|
---|
23 | )
|
---|
24 | {
|
---|
25 | EFI_STATUS Status;
|
---|
26 | FIRMWARE_CONFIG_ITEM Tables;
|
---|
27 | UINTN TablesSize;
|
---|
28 | UINT8 *QemuTables;
|
---|
29 |
|
---|
30 | if (!PcdGetBool (PcdQemuSmbiosValidated)) {
|
---|
31 | return NULL;
|
---|
32 | }
|
---|
33 |
|
---|
34 | Status = QemuFwCfgFindFile (
|
---|
35 | "etc/smbios/smbios-tables",
|
---|
36 | &Tables,
|
---|
37 | &TablesSize
|
---|
38 | );
|
---|
39 | ASSERT_EFI_ERROR (Status);
|
---|
40 | ASSERT (TablesSize > 0);
|
---|
41 |
|
---|
42 | QemuTables = AllocatePool (TablesSize);
|
---|
43 | if (QemuTables == NULL) {
|
---|
44 | return NULL;
|
---|
45 | }
|
---|
46 |
|
---|
47 | QemuFwCfgSelectItem (Tables);
|
---|
48 | QemuFwCfgReadBytes (TablesSize, QemuTables);
|
---|
49 |
|
---|
50 | return QemuTables;
|
---|
51 | }
|
---|