3 A hook-in library for MdeModulePkg/Universal/SmbiosDxe, in order to set
4 gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosVersion (and possibly other PCDs)
5 just before SmbiosDxe consumes them.
7 Copyright (C) 2013, 2015, Red Hat, Inc.
8 Copyright (c) 2008 - 2012, Intel Corporation. All rights reserved.<BR>
10 This program and the accompanying materials are licensed and made available
11 under the terms and conditions of the BSD License which accompanies this
12 distribution. The full text of the license may be found at
13 http://opensource.org/licenses/bsd-license.php
15 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
16 WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
20 #include <IndustryStandard/SmBios.h>
23 #include <Library/BaseMemoryLib.h>
24 #include <Library/DebugLib.h>
25 #include <Library/PcdLib.h>
26 #include <Library/QemuFwCfgLib.h>
29 SMBIOS_TABLE_ENTRY_POINT V2
;
38 FIRMWARE_CONFIG_ITEM Anchor
, Tables
;
39 UINTN AnchorSize
, TablesSize
;
40 QEMU_SMBIOS_ANCHOR QemuAnchor
;
43 if (RETURN_ERROR (QemuFwCfgFindFile (
44 "etc/smbios/smbios-anchor", &Anchor
, &AnchorSize
)) ||
45 RETURN_ERROR (QemuFwCfgFindFile (
46 "etc/smbios/smbios-tables", &Tables
, &TablesSize
)) ||
48 return RETURN_SUCCESS
;
51 QemuFwCfgSelectItem (Anchor
);
54 case sizeof QemuAnchor
.V2
:
55 QemuFwCfgReadBytes (AnchorSize
, &QemuAnchor
);
57 if (QemuAnchor
.V2
.MajorVersion
!= 2 ||
58 QemuAnchor
.V2
.TableLength
!= TablesSize
||
59 CompareMem (QemuAnchor
.V2
.AnchorString
, "_SM_", 4) != 0 ||
60 CompareMem (QemuAnchor
.V2
.IntermediateAnchorString
, "_DMI_", 5) != 0) {
61 return RETURN_SUCCESS
;
63 SmbiosVersion
= (UINT16
)(QemuAnchor
.V2
.MajorVersion
<< 8 |
64 QemuAnchor
.V2
.MinorVersion
);
68 return RETURN_SUCCESS
;
71 DEBUG ((EFI_D_INFO
, "%a: SMBIOS version from QEMU: 0x%04x\n", __FUNCTION__
,
73 PcdSet16 (PcdSmbiosVersion
, SmbiosVersion
);
75 return RETURN_SUCCESS
;