This driver installs SMBIOS information for OVMF\r
\r
Copyright (c) 2011, Bei Guan <gbtju85@gmail.com>\r
- Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.<BR>\r
\r
- This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- 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
\r
#include "SmbiosPlatformDxe.h"\r
\r
-\r
-/**\r
- Validates the SMBIOS entry point structure\r
-\r
- @param EntryPointStructure SMBIOS entry point structure\r
-\r
- @retval TRUE The entry point structure is valid\r
- @retval FALSE The entry point structure is not valid\r
-\r
-**/\r
-BOOLEAN\r
-IsEntryPointStructureValid (\r
- IN SMBIOS_TABLE_ENTRY_POINT *EntryPointStructure\r
- )\r
-{\r
- UINTN Index;\r
- UINT8 Length;\r
- UINT8 Checksum;\r
- UINT8 *BytePtr;\r
-\r
- BytePtr = (UINT8*) EntryPointStructure;\r
- Length = EntryPointStructure->EntryPointLength;\r
- Checksum = 0;\r
-\r
- for (Index = 0; Index < Length; Index++) {\r
- Checksum += BytePtr[Index];\r
- }\r
-\r
- if (Checksum != 0) {\r
- return FALSE;\r
- } else {\r
- return TRUE;\r
- }\r
-}\r
+#define TYPE0_STRINGS \\r
+ "EFI Development Kit II / OVMF\0" /* Vendor */ \\r
+ "0.0.0\0" /* BiosVersion */ \\r
+ "02/06/2015\0" /* BiosReleaseDate */\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[sizeof(TYPE0_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
+ TYPE0_STRINGS\r
+};\r
\r
\r
/**\r
Install all structures from the given SMBIOS structures block\r
\r
@param Smbios SMBIOS protocol\r
- @param EntryPointStructure SMBIOS entry point structures block\r
+ @param TableAddress SMBIOS tables starting address\r
\r
**/\r
EFI_STATUS\r
InstallAllStructures (\r
IN EFI_SMBIOS_PROTOCOL *Smbios,\r
- IN SMBIOS_TABLE_ENTRY_POINT *EntryPointStructure\r
+ IN UINT8 *TableAddress\r
)\r
{\r
EFI_STATUS Status;\r
SMBIOS_STRUCTURE_POINTER SmbiosTable;\r
EFI_SMBIOS_HANDLE SmbiosHandle;\r
+ BOOLEAN NeedSmbiosType0;\r
\r
- SmbiosTable.Raw = (UINT8*)(UINTN) EntryPointStructure->TableAddress;\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
//\r
- SmbiosHandle = 0;\r
+ SmbiosHandle = SmbiosTable.Hdr->Handle;\r
Status = Smbios->Add (\r
Smbios,\r
NULL,\r
);\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
EFI_STATUS Status;\r
EFI_SMBIOS_PROTOCOL *Smbios;\r
SMBIOS_TABLE_ENTRY_POINT *EntryPointStructure;\r
+ UINT8 *SmbiosTables;\r
\r
//\r
// Find the SMBIOS protocol\r
}\r
\r
//\r
- // Add Xen SMBIOS data if found\r
+ // Add Xen or QEMU SMBIOS data if found\r
//\r
EntryPointStructure = GetXenSmbiosTables ();\r
if (EntryPointStructure != NULL) {\r
- Status = InstallAllStructures (Smbios, EntryPointStructure);\r
+ SmbiosTables = (UINT8*)(UINTN)EntryPointStructure->TableAddress;\r
+ } else {\r
+ SmbiosTables = GetQemuSmbiosTables ();\r
+ }\r
+\r
+ if (SmbiosTables != NULL) {\r
+ Status = InstallAllStructures (Smbios, SmbiosTables);\r
+\r
+ //\r
+ // Free SmbiosTables if allocated by Qemu (i.e., NOT by Xen):\r
+ //\r
+ if (EntryPointStructure == NULL) {\r
+ FreePool (SmbiosTables);\r
+ }\r
}\r
\r
return Status;\r