]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg/SMBIOS: Provide default Type 0 (BIOS Information) structure
authorGabriel Somlo <somlo@cmu.edu>
Fri, 13 Feb 2015 19:50:05 +0000 (19:50 +0000)
committerjljusten <jljusten@Edk2>
Fri, 13 Feb 2015 19:50:05 +0000 (19:50 +0000)
Insert a default, OVMF-specific Type 0 (BIOS Information) structure
into the SMBIOS table, unless the underlying guest VM supplies its
own, overriding instance.

As an example, QEMU, while allowing the user to specifically force
generation of a Type 0 structure, will not generate one by default,
considering that task to be the responsibility of the BIOS itself.

Based on an earlier out-of-tree patch by Laszlo Ersek <lersek@redhat.com>

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Gabriel Somlo <somlo@cmu.edu>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16868 6f19259b-4bc3-4df7-8a09-765794883524

OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c

index 626f7dbbfb95ba65852e2ca480b2769e861d5239..bf7f717a59e8e2a030c7d25a5c5e457ea62eb35e 100644 (file)
 \r
 #include "SmbiosPlatformDxe.h"\r
 \r
+//\r
+// Type definition and contents of the default Type 0 SMBIOS table.\r
+//\r
+#pragma pack(1)\r
+typedef struct {\r
+  SMBIOS_TABLE_TYPE0 Base;\r
+  UINT8              Strings[];\r
+} OVMF_TYPE0;\r
+#pragma pack()\r
+\r
+STATIC CONST OVMF_TYPE0 mOvmfDefaultType0 = {\r
+  {\r
+    // SMBIOS_STRUCTURE Hdr\r
+    {\r
+      EFI_SMBIOS_TYPE_BIOS_INFORMATION, // UINT8 Type\r
+      sizeof (SMBIOS_TABLE_TYPE0),      // UINT8 Length\r
+    },\r
+    1,     // SMBIOS_TABLE_STRING       Vendor\r
+    2,     // SMBIOS_TABLE_STRING       BiosVersion\r
+    0xE800,// UINT16                    BiosSegment\r
+    3,     // SMBIOS_TABLE_STRING       BiosReleaseDate\r
+    0,     // UINT8                     BiosSize\r
+    {      // MISC_BIOS_CHARACTERISTICS BiosCharacteristics\r
+      0,     // Reserved                                      :2\r
+      0,     // Unknown                                       :1\r
+      1,     // BiosCharacteristicsNotSupported               :1\r
+             // Remaining BiosCharacteristics bits left unset :60\r
+    },\r
+    {      // BIOSCharacteristicsExtensionBytes[2]\r
+      0,     // BiosReserved\r
+      0x1C   // SystemReserved = VirtualMachineSupported |\r
+             //                  UefiSpecificationSupported |\r
+             //                  TargetContentDistributionEnabled\r
+    },\r
+    0,     // UINT8                     SystemBiosMajorRelease\r
+    0,     // UINT8                     SystemBiosMinorRelease\r
+    0xFF,  // UINT8                     EmbeddedControllerFirmwareMajorRelease\r
+    0xFF   // UINT8                     EmbeddedControllerFirmwareMinorRelease\r
+  },\r
+  // Text strings (unformatted area)\r
+  "EFI Development Kit II / OVMF\0"     // Vendor\r
+  "0.0.0\0"                             // BiosVersion\r
+  "02/06/2015\0"                        // BiosReleaseDate\r
+};\r
+\r
 \r
 /**\r
   Validates the SMBIOS entry point structure\r
@@ -96,12 +141,15 @@ InstallAllStructures (
   EFI_STATUS                Status;\r
   SMBIOS_STRUCTURE_POINTER  SmbiosTable;\r
   EFI_SMBIOS_HANDLE         SmbiosHandle;\r
+  BOOLEAN                   NeedSmbiosType0;\r
 \r
   SmbiosTable.Raw = TableAddress;\r
   if (SmbiosTable.Raw == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
+  NeedSmbiosType0 = TRUE;\r
+\r
   while (SmbiosTable.Hdr->Type != 127) {\r
     //\r
     // Log the SMBIOS data for this structure\r
@@ -115,12 +163,30 @@ InstallAllStructures (
                        );\r
     ASSERT_EFI_ERROR (Status);\r
 \r
+    if (SmbiosTable.Hdr->Type == 0) {\r
+      NeedSmbiosType0 = FALSE;\r
+    }\r
+\r
     //\r
     // Get the next structure address\r
     //\r
     SmbiosTable.Raw = (UINT8 *)(SmbiosTable.Raw + SmbiosTableLength (SmbiosTable));\r
   }\r
 \r
+  if (NeedSmbiosType0) {\r
+    //\r
+    // Add OVMF default Type 0 (BIOS Information) table\r
+    //\r
+    SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;\r
+    Status = Smbios->Add (\r
+                       Smbios,\r
+                       NULL,\r
+                       &SmbiosHandle,\r
+                       (EFI_SMBIOS_TABLE_HEADER*) &mOvmfDefaultType0\r
+                       );\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+\r
   return EFI_SUCCESS;\r
 }\r
 \r