]> git.proxmox.com Git - mirror_edk2.git/blob - ArmVirtPkg/QemuFwCfgToPcdDxe/QemuFwCfgToPcd.c
ArmVirtPkg: QemuFwCfgToPcdDxe: set SMBIOS entry point version dynamically
[mirror_edk2.git] / ArmVirtPkg / QemuFwCfgToPcdDxe / QemuFwCfgToPcd.c
1 /** @file
2 * An "early" DXE driver that parses well-known fw-cfg files into dynamic PCDs
3 * that control other (universal) DXE drivers.
4 *
5 * Copyright (C) 2015, Red Hat, Inc.
6 * Copyright (c) 2014, Linaro Ltd. All rights reserved.<BR>
7 *
8 * This program and the accompanying materials are licensed and made available
9 * under the terms and conditions of the BSD License which accompanies this
10 * distribution. The full text of the license may be found at
11 * http://opensource.org/licenses/bsd-license.php
12 *
13 * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR
15 * IMPLIED.
16 *
17 **/
18
19 #include <Uefi/UefiBaseType.h>
20 #include <Uefi/UefiSpec.h>
21
22 #include <IndustryStandard/SmBios.h>
23
24 #include <Library/BaseMemoryLib.h>
25 #include <Library/DebugLib.h>
26 #include <Library/PcdLib.h>
27 #include <Library/QemuFwCfgLib.h>
28
29
30 /**
31 Set the SMBIOS entry point version for the generic SmbiosDxe driver.
32 **/
33 STATIC
34 VOID
35 SmbiosVersionInitialization (
36 VOID
37 )
38 {
39 FIRMWARE_CONFIG_ITEM Anchor;
40 UINTN AnchorSize;
41 SMBIOS_TABLE_ENTRY_POINT QemuAnchor;
42 UINT16 SmbiosVersion;
43
44 if (RETURN_ERROR (QemuFwCfgFindFile ("etc/smbios/smbios-anchor", &Anchor,
45 &AnchorSize)) ||
46 AnchorSize != sizeof QemuAnchor) {
47 return;
48 }
49
50 QemuFwCfgSelectItem (Anchor);
51 QemuFwCfgReadBytes (AnchorSize, &QemuAnchor);
52 if (CompareMem (QemuAnchor.AnchorString, "_SM_", 4) != 0 ||
53 CompareMem (QemuAnchor.IntermediateAnchorString, "_DMI_", 5) != 0) {
54 return;
55 }
56
57 SmbiosVersion = (UINT16)(QemuAnchor.MajorVersion << 8 |
58 QemuAnchor.MinorVersion);
59 DEBUG ((EFI_D_INFO, "%a: SMBIOS version from QEMU: 0x%04x\n", __FUNCTION__,
60 SmbiosVersion));
61 PcdSet16 (PcdSmbiosVersion, SmbiosVersion);
62 }
63
64 EFI_STATUS
65 EFIAPI
66 ParseQemuFwCfgToPcd (
67 IN EFI_HANDLE ImageHandle,
68 IN EFI_SYSTEM_TABLE *SystemTable
69 )
70 {
71 SmbiosVersionInitialization ();
72 return EFI_SUCCESS;
73 }