]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmVirtPkg: QemuFwCfgToPcdDxe: set SMBIOS entry point version dynamically
authorLaszlo Ersek <lersek@redhat.com>
Sun, 26 Jul 2015 08:02:55 +0000 (08:02 +0000)
committerjljusten <jljusten@Edk2>
Sun, 26 Jul 2015 08:02:55 +0000 (08:02 +0000)
(This patch parallels OvmfPkg commit 37baf06b (SVN r17676).)

PcdSmbiosVersion controls the version number of the SMBIOS entry point
table (and other, related things) that the universal
"MdeModulePkg/Universal/SmbiosDxe" driver, providing EFI_SMBIOS_PROTOCOL,
installs.

The "virt" machine type of QEMU generates SMBIOS payload for the firmware
to install. The payload includes the entry point table ("anchor" table).
OvmfPkg/SmbiosPlatformDxe cannot install the anchor table (because that is
the jurisdiction of the generic "MdeModulePkg/Universal/SmbiosDxe"
driver); however, we can parse the entry point version from QEMU's anchor
table, and instruct "MdeModulePkg/Universal/SmbiosDxe" to adhere to that
version.

As default for PcdSmbiosVersion we should keep the current 0x0300 value
(ie. SMBIOS 3.0) from "MdeModulePkg/MdeModulePkg.dec"; that spec version
was specifically created for ARM / AARCH64 needs.

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18043 6f19259b-4bc3-4df7-8a09-765794883524

ArmVirtPkg/ArmVirtQemu.dsc
ArmVirtPkg/QemuFwCfgToPcdDxe/QemuFwCfgToPcd.c
ArmVirtPkg/QemuFwCfgToPcdDxe/QemuFwCfgToPcd.inf

index 07d5a87e661d61097163060d93f49e925ba20cd3..a7bde48beb720b5c8ccf3d2c4369fa01e41e301d 100644 (file)
   gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoHorizontalResolution|640\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoVerticalResolution|480\r
 \r
+  #\r
+  # SMBIOS entry point version\r
+  #\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosVersion|0x0300\r
+\r
 ################################################################################\r
 #\r
 # Components Section - list of all EDK II Modules needed by this Platform\r
index 8f60e217891fcbe3540ac7bb9248ac89796ed765..814bb5c55eccea34cb01c70fef5190e49ee2ef35 100644 (file)
 #include <Uefi/UefiBaseType.h>\r
 #include <Uefi/UefiSpec.h>\r
 \r
+#include <IndustryStandard/SmBios.h>\r
+\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/DebugLib.h>\r
 #include <Library/PcdLib.h>\r
 #include <Library/QemuFwCfgLib.h>\r
 \r
+\r
+/**\r
+  Set the SMBIOS entry point version for the generic SmbiosDxe driver.\r
+**/\r
+STATIC\r
+VOID\r
+SmbiosVersionInitialization (\r
+  VOID\r
+  )\r
+{\r
+  FIRMWARE_CONFIG_ITEM     Anchor;\r
+  UINTN                    AnchorSize;\r
+  SMBIOS_TABLE_ENTRY_POINT QemuAnchor;\r
+  UINT16                   SmbiosVersion;\r
+\r
+  if (RETURN_ERROR (QemuFwCfgFindFile ("etc/smbios/smbios-anchor", &Anchor,\r
+                      &AnchorSize)) ||\r
+      AnchorSize != sizeof QemuAnchor) {\r
+    return;\r
+  }\r
+\r
+  QemuFwCfgSelectItem (Anchor);\r
+  QemuFwCfgReadBytes (AnchorSize, &QemuAnchor);\r
+  if (CompareMem (QemuAnchor.AnchorString, "_SM_", 4) != 0 ||\r
+      CompareMem (QemuAnchor.IntermediateAnchorString, "_DMI_", 5) != 0) {\r
+    return;\r
+  }\r
+\r
+  SmbiosVersion = (UINT16)(QemuAnchor.MajorVersion << 8 |\r
+                           QemuAnchor.MinorVersion);\r
+  DEBUG ((EFI_D_INFO, "%a: SMBIOS version from QEMU: 0x%04x\n", __FUNCTION__,\r
+    SmbiosVersion));\r
+  PcdSet16 (PcdSmbiosVersion, SmbiosVersion);\r
+}\r
+\r
 EFI_STATUS\r
 EFIAPI\r
 ParseQemuFwCfgToPcd (\r
@@ -29,5 +68,6 @@ ParseQemuFwCfgToPcd (
   IN EFI_SYSTEM_TABLE *SystemTable\r
   )\r
 {\r
+  SmbiosVersionInitialization ();\r
   return EFI_SUCCESS;\r
 }\r
index a9983becef1fe9c9da63e0e37a1841e00575c89f..649cfdc1417dcdde3167050003bf7eb62da3870b 100644 (file)
 \r
 [Packages]\r
   MdePkg/MdePkg.dec\r
+  MdeModulePkg/MdeModulePkg.dec\r
   OvmfPkg/OvmfPkg.dec\r
 \r
 [LibraryClasses]\r
+  BaseMemoryLib\r
+  DebugLib\r
   PcdLib\r
   QemuFwCfgLib\r
   UefiDriverEntryPoint\r
 \r
 [Pcd]\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosVersion\r
 \r
 [Depex]\r
   TRUE\r