2 This driver installs SMBIOS information for OVMF
4 Copyright (c) 2011, Bei Guan <gbtju85@gmail.com>
5 Copyright (c) 2011, 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"
20 // Type definition and contents of the default Type 0 SMBIOS table.
24 SMBIOS_TABLE_TYPE0 Base
;
29 STATIC CONST OVMF_TYPE0 mOvmfDefaultType0
= {
31 // SMBIOS_STRUCTURE Hdr
33 EFI_SMBIOS_TYPE_BIOS_INFORMATION
, // UINT8 Type
34 sizeof (SMBIOS_TABLE_TYPE0
), // UINT8 Length
36 1, // SMBIOS_TABLE_STRING Vendor
37 2, // SMBIOS_TABLE_STRING BiosVersion
38 0xE800,// UINT16 BiosSegment
39 3, // SMBIOS_TABLE_STRING BiosReleaseDate
41 { // MISC_BIOS_CHARACTERISTICS BiosCharacteristics
44 1, // BiosCharacteristicsNotSupported :1
45 // Remaining BiosCharacteristics bits left unset :60
47 { // BIOSCharacteristicsExtensionBytes[2]
49 0x1C // SystemReserved = VirtualMachineSupported |
50 // UefiSpecificationSupported |
51 // TargetContentDistributionEnabled
53 0, // UINT8 SystemBiosMajorRelease
54 0, // UINT8 SystemBiosMinorRelease
55 0xFF, // UINT8 EmbeddedControllerFirmwareMajorRelease
56 0xFF // UINT8 EmbeddedControllerFirmwareMinorRelease
58 // Text strings (unformatted area)
59 "EFI Development Kit II / OVMF\0" // Vendor
60 "0.0.0\0" // BiosVersion
61 "02/06/2015\0" // BiosReleaseDate
66 Validates the SMBIOS entry point structure
68 @param EntryPointStructure SMBIOS entry point structure
70 @retval TRUE The entry point structure is valid
71 @retval FALSE The entry point structure is not valid
75 IsEntryPointStructureValid (
76 IN SMBIOS_TABLE_ENTRY_POINT
*EntryPointStructure
84 BytePtr
= (UINT8
*) EntryPointStructure
;
85 Length
= EntryPointStructure
->EntryPointLength
;
88 for (Index
= 0; Index
< Length
; Index
++) {
89 Checksum
= Checksum
+ (UINT8
) BytePtr
[Index
];
101 Get SMBIOS record length.
103 @param SmbiosTable SMBIOS pointer.
108 IN SMBIOS_STRUCTURE_POINTER SmbiosTable
114 AChar
= (CHAR8
*)(SmbiosTable
.Raw
+ SmbiosTable
.Hdr
->Length
);
117 // Each structure shall be terminated by a double-null (SMBIOS spec.7.1)
119 while ((*AChar
!= 0) || (*(AChar
+ 1) != 0)) {
122 Length
= ((UINTN
)AChar
- (UINTN
)SmbiosTable
.Raw
+ 2);
129 Install all structures from the given SMBIOS structures block
131 @param Smbios SMBIOS protocol
132 @param TableAddress SMBIOS tables starting address
136 InstallAllStructures (
137 IN EFI_SMBIOS_PROTOCOL
*Smbios
,
138 IN UINT8
*TableAddress
142 SMBIOS_STRUCTURE_POINTER SmbiosTable
;
143 EFI_SMBIOS_HANDLE SmbiosHandle
;
144 BOOLEAN NeedSmbiosType0
;
146 SmbiosTable
.Raw
= TableAddress
;
147 if (SmbiosTable
.Raw
== NULL
) {
148 return EFI_INVALID_PARAMETER
;
151 NeedSmbiosType0
= TRUE
;
153 while (SmbiosTable
.Hdr
->Type
!= 127) {
155 // Log the SMBIOS data for this structure
157 SmbiosHandle
= SmbiosTable
.Hdr
->Handle
;
158 Status
= Smbios
->Add (
162 (EFI_SMBIOS_TABLE_HEADER
*) SmbiosTable
.Raw
164 ASSERT_EFI_ERROR (Status
);
166 if (SmbiosTable
.Hdr
->Type
== 0) {
167 NeedSmbiosType0
= FALSE
;
171 // Get the next structure address
173 SmbiosTable
.Raw
= (UINT8
*)(SmbiosTable
.Raw
+ SmbiosTableLength (SmbiosTable
));
176 if (NeedSmbiosType0
) {
178 // Add OVMF default Type 0 (BIOS Information) table
180 SmbiosHandle
= SMBIOS_HANDLE_PI_RESERVED
;
181 Status
= Smbios
->Add (
185 (EFI_SMBIOS_TABLE_HEADER
*) &mOvmfDefaultType0
187 ASSERT_EFI_ERROR (Status
);
195 Installs SMBIOS information for OVMF
197 @param ImageHandle Module's image handle
198 @param SystemTable Pointer of EFI_SYSTEM_TABLE
200 @retval EFI_SUCCESS Smbios data successfully installed
201 @retval Other Smbios data was not installed
206 SmbiosTablePublishEntry (
207 IN EFI_HANDLE ImageHandle
,
208 IN EFI_SYSTEM_TABLE
*SystemTable
212 EFI_SMBIOS_PROTOCOL
*Smbios
;
213 SMBIOS_TABLE_ENTRY_POINT
*EntryPointStructure
;
217 // Find the SMBIOS protocol
219 Status
= gBS
->LocateProtocol (
220 &gEfiSmbiosProtocolGuid
,
224 if (EFI_ERROR (Status
)) {
229 // Add Xen or QEMU SMBIOS data if found
231 EntryPointStructure
= GetXenSmbiosTables ();
232 if (EntryPointStructure
!= NULL
) {
233 SmbiosTables
= (UINT8
*)(UINTN
)EntryPointStructure
->TableAddress
;
235 SmbiosTables
= GetQemuSmbiosTables ();
238 if (SmbiosTables
!= NULL
) {
239 Status
= InstallAllStructures (Smbios
, SmbiosTables
);
242 // Free SmbiosTables if allocated by Qemu (i.e., NOT by Xen):
244 if (EntryPointStructure
== NULL
) {
245 FreePool (SmbiosTables
);