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 SPDX-License-Identifier: BSD-2-Clause-Patent
11 #include "SmbiosPlatformDxe.h"
13 #define TYPE0_STRINGS \
14 "EFI Development Kit II / OVMF\0" /* Vendor */ \
15 "0.0.0\0" /* BiosVersion */ \
16 "02/06/2015\0" /* BiosReleaseDate */
18 // Type definition and contents of the default Type 0 SMBIOS table.
22 SMBIOS_TABLE_TYPE0 Base
;
23 UINT8 Strings
[sizeof(TYPE0_STRINGS
)];
27 STATIC CONST OVMF_TYPE0 mOvmfDefaultType0
= {
29 // SMBIOS_STRUCTURE Hdr
31 EFI_SMBIOS_TYPE_BIOS_INFORMATION
, // UINT8 Type
32 sizeof (SMBIOS_TABLE_TYPE0
), // UINT8 Length
34 1, // SMBIOS_TABLE_STRING Vendor
35 2, // SMBIOS_TABLE_STRING BiosVersion
36 0xE800,// UINT16 BiosSegment
37 3, // SMBIOS_TABLE_STRING BiosReleaseDate
39 { // MISC_BIOS_CHARACTERISTICS BiosCharacteristics
42 1, // BiosCharacteristicsNotSupported :1
43 // Remaining BiosCharacteristics bits left unset :60
45 { // BIOSCharacteristicsExtensionBytes[2]
47 0x1C // SystemReserved = VirtualMachineSupported |
48 // UefiSpecificationSupported |
49 // TargetContentDistributionEnabled
51 0, // UINT8 SystemBiosMajorRelease
52 0, // UINT8 SystemBiosMinorRelease
53 0xFF, // UINT8 EmbeddedControllerFirmwareMajorRelease
54 0xFF // UINT8 EmbeddedControllerFirmwareMinorRelease
56 // Text strings (unformatted area)
62 Get SMBIOS record length.
64 @param SmbiosTable SMBIOS pointer.
69 IN SMBIOS_STRUCTURE_POINTER SmbiosTable
75 AChar
= (CHAR8
*)(SmbiosTable
.Raw
+ SmbiosTable
.Hdr
->Length
);
78 // Each structure shall be terminated by a double-null (SMBIOS spec.7.1)
80 while ((*AChar
!= 0) || (*(AChar
+ 1) != 0)) {
83 Length
= ((UINTN
)AChar
- (UINTN
)SmbiosTable
.Raw
+ 2);
90 Install all structures from the given SMBIOS structures block
92 @param Smbios SMBIOS protocol
93 @param TableAddress SMBIOS tables starting address
97 InstallAllStructures (
98 IN EFI_SMBIOS_PROTOCOL
*Smbios
,
99 IN UINT8
*TableAddress
103 SMBIOS_STRUCTURE_POINTER SmbiosTable
;
104 EFI_SMBIOS_HANDLE SmbiosHandle
;
105 BOOLEAN NeedSmbiosType0
;
107 SmbiosTable
.Raw
= TableAddress
;
108 if (SmbiosTable
.Raw
== NULL
) {
109 return EFI_INVALID_PARAMETER
;
112 NeedSmbiosType0
= TRUE
;
114 while (SmbiosTable
.Hdr
->Type
!= 127) {
116 // Log the SMBIOS data for this structure
118 SmbiosHandle
= SmbiosTable
.Hdr
->Handle
;
119 Status
= Smbios
->Add (
123 (EFI_SMBIOS_TABLE_HEADER
*) SmbiosTable
.Raw
125 ASSERT_EFI_ERROR (Status
);
127 if (SmbiosTable
.Hdr
->Type
== 0) {
128 NeedSmbiosType0
= FALSE
;
132 // Get the next structure address
134 SmbiosTable
.Raw
= (UINT8
*)(SmbiosTable
.Raw
+ SmbiosTableLength (SmbiosTable
));
137 if (NeedSmbiosType0
) {
139 // Add OVMF default Type 0 (BIOS Information) table
141 SmbiosHandle
= SMBIOS_HANDLE_PI_RESERVED
;
142 Status
= Smbios
->Add (
146 (EFI_SMBIOS_TABLE_HEADER
*) &mOvmfDefaultType0
148 ASSERT_EFI_ERROR (Status
);
156 Installs SMBIOS information for OVMF
158 @param ImageHandle Module's image handle
159 @param SystemTable Pointer of EFI_SYSTEM_TABLE
161 @retval EFI_SUCCESS Smbios data successfully installed
162 @retval Other Smbios data was not installed
167 SmbiosTablePublishEntry (
168 IN EFI_HANDLE ImageHandle
,
169 IN EFI_SYSTEM_TABLE
*SystemTable
173 EFI_SMBIOS_PROTOCOL
*Smbios
;
174 SMBIOS_TABLE_ENTRY_POINT
*EntryPointStructure
;
178 // Find the SMBIOS protocol
180 Status
= gBS
->LocateProtocol (
181 &gEfiSmbiosProtocolGuid
,
185 if (EFI_ERROR (Status
)) {
190 // Add Xen or QEMU SMBIOS data if found
192 EntryPointStructure
= GetXenSmbiosTables ();
193 if (EntryPointStructure
!= NULL
) {
194 SmbiosTables
= (UINT8
*)(UINTN
)EntryPointStructure
->TableAddress
;
196 SmbiosTables
= GetQemuSmbiosTables ();
199 if (SmbiosTables
!= NULL
) {
200 Status
= InstallAllStructures (Smbios
, SmbiosTables
);
203 // Free SmbiosTables if allocated by Qemu (i.e., NOT by Xen):
205 if (EntryPointStructure
== NULL
) {
206 FreePool (SmbiosTables
);