]>
Commit | Line | Data |
---|---|---|
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 | |
6 | This program and the accompanying materials are licensed and made\r | |
7 | available under the terms and conditions of the BSD License which\r | |
8 | accompanies this distribution. The full text of the license may\r | |
9 | be found at http://opensource.org/licenses/bsd-license.php\r | |
10 | \r | |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
13 | **/\r | |
14 | \r | |
15 | #include "SmbiosPlatformDxe.h"\r | |
16 | #include <Library/QemuFwCfgLib.h>\r | |
17 | #include <Library/MemoryAllocationLib.h>\r | |
18 | \r | |
19 | /**\r | |
20 | Locates and extracts the QEMU SMBIOS data if present in fw_cfg\r | |
21 | \r | |
22 | @return Address of extracted QEMU SMBIOS data\r | |
23 | \r | |
24 | **/\r | |
25 | UINT8 *\r | |
26 | GetQemuSmbiosTables (\r | |
27 | VOID\r | |
28 | )\r | |
29 | {\r | |
30 | SMBIOS_TABLE_ENTRY_POINT QemuAnchor;\r | |
31 | FIRMWARE_CONFIG_ITEM Anchor, Tables;\r | |
32 | UINTN AnchorSize, TablesSize;\r | |
33 | UINT8 *QemuTables;\r | |
34 | \r | |
35 | if (EFI_ERROR (QemuFwCfgFindFile (\r | |
36 | "etc/smbios/smbios-anchor", &Anchor, &AnchorSize)) ||\r | |
37 | EFI_ERROR (QemuFwCfgFindFile (\r | |
38 | "etc/smbios/smbios-tables", &Tables, &TablesSize)) ||\r | |
39 | AnchorSize != sizeof (QemuAnchor) ||\r | |
40 | TablesSize == 0) {\r | |
41 | return NULL;\r | |
42 | }\r | |
43 | \r | |
44 | //\r | |
45 | // We copy the entry point structure to perform some additional checks,\r | |
46 | // but discard it upon return.\r | |
47 | //\r | |
48 | QemuFwCfgSelectItem (Anchor);\r | |
49 | QemuFwCfgReadBytes (AnchorSize, &QemuAnchor);\r | |
50 | \r | |
51 | if (AsciiStrnCmp ((CHAR8 *)QemuAnchor.AnchorString, "_SM_", 4) ||\r | |
52 | AsciiStrnCmp ((CHAR8 *)QemuAnchor.IntermediateAnchorString, "_DMI_", 5) ||\r | |
53 | TablesSize != QemuAnchor.TableLength) {\r | |
54 | return NULL;\r | |
55 | }\r | |
56 | \r | |
57 | QemuTables = AllocatePool (TablesSize);\r | |
58 | if (QemuTables == NULL) {\r | |
59 | return NULL;\r | |
60 | }\r | |
61 | \r | |
62 | QemuFwCfgSelectItem (Tables);\r | |
63 | QemuFwCfgReadBytes (TablesSize, QemuTables);\r | |
64 | \r | |
65 | return QemuTables;\r | |
66 | }\r |