2 This driver installs SMBIOS information for OVMF
4 Copyright (c) 2011, Bei Guan <gbtju85@gmail.com>
5 Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.<BR>
7 This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #include "SmbiosPlatformDxe.h"
19 #define TYPE0_STRINGS \
20 "EFI Development Kit II / OVMF\0" /* Vendor */ \
21 "0.0.0\0" /* BiosVersion */ \
22 "02/06/2015\0" /* BiosReleaseDate */
24 // Type definition and contents of the default Type 0 SMBIOS table.
28 SMBIOS_TABLE_TYPE0 Base
;
29 UINT8 Strings
[sizeof(TYPE0_STRINGS
)];
33 STATIC CONST OVMF_TYPE0 mOvmfDefaultType0
= {
35 // SMBIOS_STRUCTURE Hdr
37 EFI_SMBIOS_TYPE_BIOS_INFORMATION
, // UINT8 Type
38 sizeof (SMBIOS_TABLE_TYPE0
), // UINT8 Length
40 1, // SMBIOS_TABLE_STRING Vendor
41 2, // SMBIOS_TABLE_STRING BiosVersion
42 0xE800,// UINT16 BiosSegment
43 3, // SMBIOS_TABLE_STRING BiosReleaseDate
45 { // MISC_BIOS_CHARACTERISTICS BiosCharacteristics
48 1, // BiosCharacteristicsNotSupported :1
49 // Remaining BiosCharacteristics bits left unset :60
51 { // BIOSCharacteristicsExtensionBytes[2]
53 0x1C // SystemReserved = VirtualMachineSupported |
54 // UefiSpecificationSupported |
55 // TargetContentDistributionEnabled
57 0, // UINT8 SystemBiosMajorRelease
58 0, // UINT8 SystemBiosMinorRelease
59 0xFF, // UINT8 EmbeddedControllerFirmwareMajorRelease
60 0xFF // UINT8 EmbeddedControllerFirmwareMinorRelease
62 // Text strings (unformatted area)
68 Get SMBIOS record length.
70 @param SmbiosTable SMBIOS pointer.
75 IN SMBIOS_STRUCTURE_POINTER SmbiosTable
81 AChar
= (CHAR8
*)(SmbiosTable
.Raw
+ SmbiosTable
.Hdr
->Length
);
84 // Each structure shall be terminated by a double-null (SMBIOS spec.7.1)
86 while ((*AChar
!= 0) || (*(AChar
+ 1) != 0)) {
89 Length
= ((UINTN
)AChar
- (UINTN
)SmbiosTable
.Raw
+ 2);
96 Install all structures from the given SMBIOS structures block
98 @param Smbios SMBIOS protocol
99 @param TableAddress SMBIOS tables starting address
103 InstallAllStructures (
104 IN EFI_SMBIOS_PROTOCOL
*Smbios
,
105 IN UINT8
*TableAddress
109 SMBIOS_STRUCTURE_POINTER SmbiosTable
;
110 EFI_SMBIOS_HANDLE SmbiosHandle
;
111 BOOLEAN NeedSmbiosType0
;
113 SmbiosTable
.Raw
= TableAddress
;
114 if (SmbiosTable
.Raw
== NULL
) {
115 return EFI_INVALID_PARAMETER
;
118 NeedSmbiosType0
= TRUE
;
120 while (SmbiosTable
.Hdr
->Type
!= 127) {
122 // Log the SMBIOS data for this structure
124 SmbiosHandle
= SmbiosTable
.Hdr
->Handle
;
125 Status
= Smbios
->Add (
129 (EFI_SMBIOS_TABLE_HEADER
*) SmbiosTable
.Raw
131 ASSERT_EFI_ERROR (Status
);
133 if (SmbiosTable
.Hdr
->Type
== 0) {
134 NeedSmbiosType0
= FALSE
;
138 // Get the next structure address
140 SmbiosTable
.Raw
= (UINT8
*)(SmbiosTable
.Raw
+ SmbiosTableLength (SmbiosTable
));
143 if (NeedSmbiosType0
) {
145 // Add OVMF default Type 0 (BIOS Information) table
147 SmbiosHandle
= SMBIOS_HANDLE_PI_RESERVED
;
148 Status
= Smbios
->Add (
152 (EFI_SMBIOS_TABLE_HEADER
*) &mOvmfDefaultType0
154 ASSERT_EFI_ERROR (Status
);
162 Installs SMBIOS information for OVMF
164 @param ImageHandle Module's image handle
165 @param SystemTable Pointer of EFI_SYSTEM_TABLE
167 @retval EFI_SUCCESS Smbios data successfully installed
168 @retval Other Smbios data was not installed
173 SmbiosTablePublishEntry (
174 IN EFI_HANDLE ImageHandle
,
175 IN EFI_SYSTEM_TABLE
*SystemTable
179 EFI_SMBIOS_PROTOCOL
*Smbios
;
180 SMBIOS_TABLE_ENTRY_POINT
*EntryPointStructure
;
184 // Find the SMBIOS protocol
186 Status
= gBS
->LocateProtocol (
187 &gEfiSmbiosProtocolGuid
,
191 if (EFI_ERROR (Status
)) {
196 // Add Xen or QEMU SMBIOS data if found
198 EntryPointStructure
= GetXenSmbiosTables ();
199 if (EntryPointStructure
!= NULL
) {
200 SmbiosTables
= (UINT8
*)(UINTN
)EntryPointStructure
->TableAddress
;
202 SmbiosTables
= GetQemuSmbiosTables ();
205 if (SmbiosTables
!= NULL
) {
206 Status
= InstallAllStructures (Smbios
, SmbiosTables
);
209 // Free SmbiosTables if allocated by Qemu (i.e., NOT by Xen):
211 if (EntryPointStructure
== NULL
) {
212 FreePool (SmbiosTables
);