Revision: 16868
          http://sourceforge.net/p/edk2/code/16868
Author:   jljusten
Date:     2015-02-13 19:50:05 +0000 (Fri, 13 Feb 2015)
Log Message:
-----------
OvmfPkg/SMBIOS: Provide default Type 0 (BIOS Information) structure

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 <[email protected]>

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Gabriel Somlo <[email protected]>
Reviewed-by: Jordan Justen <[email protected]>

Modified Paths:
--------------
    trunk/edk2/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c

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


------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to