]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/SmbiosPlatformDxe/Qemu.c
OvmfPkg: Apply uncrustify changes
[mirror_edk2.git] / OvmfPkg / SmbiosPlatformDxe / Qemu.c
index f7ace4f1deb203f846830283fa3cc97d89ebfd6e..4dae4b0b98f1d37cc3c51da79fa337b325f0b7cb 100644 (file)
@@ -3,18 +3,15 @@
 \r
   Copyright (C) 2014, Gabriel L. Somlo <somlo@cmu.edu>\r
 \r
-  This program and the accompanying materials are licensed and made\r
-  available under the terms and conditions of the BSD License which\r
-  accompanies this distribution.   The full text of the license may\r
-  be found at http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 **/\r
 \r
+#include <Library/DebugLib.h>            // ASSERT_EFI_ERROR()\r
+#include <Library/MemoryAllocationLib.h> // AllocatePool()\r
+#include <Library/PcdLib.h>              // PcdGetBool()\r
+#include <Library/QemuFwCfgLib.h>        // QemuFwCfgFindFile()\r
+\r
 #include "SmbiosPlatformDxe.h"\r
-#include <Library/QemuFwCfgLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
 \r
 /**\r
   Locates and extracts the QEMU SMBIOS data if present in fw_cfg\r
@@ -27,33 +24,23 @@ GetQemuSmbiosTables (
   VOID\r
   )\r
 {\r
-  SMBIOS_TABLE_ENTRY_POINT QemuAnchor;\r
-  FIRMWARE_CONFIG_ITEM     Anchor, Tables;\r
-  UINTN                    AnchorSize, TablesSize;\r
-  UINT8                    *QemuTables;\r
-\r
-  if (EFI_ERROR (QemuFwCfgFindFile (\r
-                   "etc/smbios/smbios-anchor", &Anchor, &AnchorSize)) ||\r
-      EFI_ERROR (QemuFwCfgFindFile (\r
-                   "etc/smbios/smbios-tables", &Tables, &TablesSize)) ||\r
-      AnchorSize != sizeof (QemuAnchor) ||\r
-      TablesSize == 0) {\r
-    return NULL;\r
-  }\r
+  EFI_STATUS            Status;\r
+  FIRMWARE_CONFIG_ITEM  Tables;\r
+  UINTN                 TablesSize;\r
+  UINT8                 *QemuTables;\r
 \r
-  //\r
-  // We copy the entry point structure to perform some additional checks,\r
-  // but discard it upon return.\r
-  //\r
-  QemuFwCfgSelectItem (Anchor);\r
-  QemuFwCfgReadBytes (AnchorSize, &QemuAnchor);\r
-\r
-  if (AsciiStrnCmp ((CHAR8 *)QemuAnchor.AnchorString, "_SM_", 4) ||\r
-      AsciiStrnCmp ((CHAR8 *)QemuAnchor.IntermediateAnchorString, "_DMI_", 5) ||\r
-      TablesSize != QemuAnchor.TableLength) {\r
+  if (!PcdGetBool (PcdQemuSmbiosValidated)) {\r
     return NULL;\r
   }\r
 \r
+  Status = QemuFwCfgFindFile (\r
+             "etc/smbios/smbios-tables",\r
+             &Tables,\r
+             &TablesSize\r
+             );\r
+  ASSERT_EFI_ERROR (Status);\r
+  ASSERT (TablesSize > 0);\r
+\r
   QemuTables = AllocatePool (TablesSize);\r
   if (QemuTables == NULL) {\r
     return NULL;\r
@@ -64,3 +51,36 @@ GetQemuSmbiosTables (
 \r
   return QemuTables;\r
 }\r
+\r
+/**\r
+  Installs SMBIOS information for OVMF\r
+\r
+  @param ImageHandle     Module's image handle\r
+  @param SystemTable     Pointer of EFI_SYSTEM_TABLE\r
+\r
+  @retval EFI_SUCCESS    Smbios data successfully installed\r
+  @retval Other          Smbios data was not installed\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SmbiosTablePublishEntry (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+  UINT8       *SmbiosTables;\r
+\r
+  Status = EFI_NOT_FOUND;\r
+  //\r
+  // Add QEMU SMBIOS data if found\r
+  //\r
+  SmbiosTables = GetQemuSmbiosTables ();\r
+  if (SmbiosTables != NULL) {\r
+    Status = InstallAllStructures (SmbiosTables);\r
+    FreePool (SmbiosTables);\r
+  }\r
+\r
+  return Status;\r
+}\r