2 Find and extract QEMU SMBIOS data from fw_cfg.
4 Copyright (C) 2014, Gabriel L. Somlo <somlo@cmu.edu>
6 This program and the accompanying materials are licensed and made
7 available under the terms and conditions of the BSD License which
8 accompanies this distribution. The full text of the license may
9 be found at http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "SmbiosPlatformDxe.h"
16 #include <Library/QemuFwCfgLib.h>
17 #include <Library/MemoryAllocationLib.h>
20 Locates and extracts the QEMU SMBIOS data if present in fw_cfg
22 @return Address of extracted QEMU SMBIOS data
30 SMBIOS_TABLE_ENTRY_POINT QemuAnchor
;
31 FIRMWARE_CONFIG_ITEM Anchor
, Tables
;
32 UINTN AnchorSize
, TablesSize
;
35 if (EFI_ERROR (QemuFwCfgFindFile (
36 "etc/smbios/smbios-anchor", &Anchor
, &AnchorSize
)) ||
37 EFI_ERROR (QemuFwCfgFindFile (
38 "etc/smbios/smbios-tables", &Tables
, &TablesSize
)) ||
39 AnchorSize
!= sizeof (QemuAnchor
) ||
45 // We copy the entry point structure to perform some additional checks,
46 // but discard it upon return.
48 QemuFwCfgSelectItem (Anchor
);
49 QemuFwCfgReadBytes (AnchorSize
, &QemuAnchor
);
51 if (AsciiStrnCmp ((CHAR8
*)QemuAnchor
.AnchorString
, "_SM_", 4) ||
52 AsciiStrnCmp ((CHAR8
*)QemuAnchor
.IntermediateAnchorString
, "_DMI_", 5) ||
53 TablesSize
!= QemuAnchor
.TableLength
) {
57 QemuTables
= AllocatePool (TablesSize
);
58 if (QemuTables
== NULL
) {
62 QemuFwCfgSelectItem (Tables
);
63 QemuFwCfgReadBytes (TablesSize
, QemuTables
);