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 <IndustryStandard/SmBios.h> // SMBIOS_TABLE_TYPE0
12 #include <Library/DebugLib.h> // ASSERT_EFI_ERROR()
13 #include <Library/UefiBootServicesTableLib.h> // gBS
14 #include <Protocol/Smbios.h> // EFI_SMBIOS_PROTOCOL
16 #include "SmbiosPlatformDxe.h"
18 #define TYPE0_STRINGS \
19 "EFI Development Kit II / OVMF\0" /* Vendor */ \
20 "0.0.0\0" /* BiosVersion */ \
21 "02/06/2015\0" /* BiosReleaseDate */
23 // Type definition and contents of the default Type 0 SMBIOS table.
27 SMBIOS_TABLE_TYPE0 Base
;
28 UINT8 Strings
[sizeof (TYPE0_STRINGS
)];
32 STATIC CONST OVMF_TYPE0 mOvmfDefaultType0
= {
34 // SMBIOS_STRUCTURE Hdr
36 EFI_SMBIOS_TYPE_BIOS_INFORMATION
, // UINT8 Type
37 sizeof (SMBIOS_TABLE_TYPE0
), // UINT8 Length
39 1, // SMBIOS_TABLE_STRING Vendor
40 2, // SMBIOS_TABLE_STRING BiosVersion
41 0xE800, // UINT16 BiosSegment
42 3, // SMBIOS_TABLE_STRING BiosReleaseDate
44 { // MISC_BIOS_CHARACTERISTICS BiosCharacteristics
47 1, // BiosCharacteristicsNotSupported :1
48 // Remaining BiosCharacteristics bits left unset :60
50 { // BIOSCharacteristicsExtensionBytes[2]
52 0x1C // SystemReserved = VirtualMachineSupported |
53 // UefiSpecificationSupported |
54 // TargetContentDistributionEnabled
56 0, // UINT8 SystemBiosMajorRelease
57 0, // UINT8 SystemBiosMinorRelease
58 0xFF, // UINT8 EmbeddedControllerFirmwareMajorRelease
59 0xFF // UINT8 EmbeddedControllerFirmwareMinorRelease
61 // Text strings (unformatted area)
66 Get SMBIOS record length.
68 @param SmbiosTable SMBIOS pointer.
73 IN SMBIOS_STRUCTURE_POINTER SmbiosTable
79 AChar
= (CHAR8
*)(SmbiosTable
.Raw
+ SmbiosTable
.Hdr
->Length
);
82 // Each structure shall be terminated by a double-null (SMBIOS spec.7.1)
84 while ((*AChar
!= 0) || (*(AChar
+ 1) != 0)) {
88 Length
= ((UINTN
)AChar
- (UINTN
)SmbiosTable
.Raw
+ 2);
94 Install all structures from the given SMBIOS structures block
96 @param TableAddress SMBIOS tables starting address
100 InstallAllStructures (
101 IN UINT8
*TableAddress
104 EFI_SMBIOS_PROTOCOL
*Smbios
;
106 SMBIOS_STRUCTURE_POINTER SmbiosTable
;
107 EFI_SMBIOS_HANDLE SmbiosHandle
;
108 BOOLEAN NeedSmbiosType0
;
111 // Find the SMBIOS protocol
113 Status
= gBS
->LocateProtocol (
114 &gEfiSmbiosProtocolGuid
,
118 if (EFI_ERROR (Status
)) {
122 SmbiosTable
.Raw
= TableAddress
;
123 if (SmbiosTable
.Raw
== NULL
) {
124 return EFI_INVALID_PARAMETER
;
127 NeedSmbiosType0
= TRUE
;
129 while (SmbiosTable
.Hdr
->Type
!= 127) {
131 // Log the SMBIOS data for this structure
133 SmbiosHandle
= SmbiosTable
.Hdr
->Handle
;
134 Status
= Smbios
->Add (
138 (EFI_SMBIOS_TABLE_HEADER
*)SmbiosTable
.Raw
140 ASSERT_EFI_ERROR (Status
);
142 if (SmbiosTable
.Hdr
->Type
== 0) {
143 NeedSmbiosType0
= FALSE
;
147 // Get the next structure address
149 SmbiosTable
.Raw
= (UINT8
*)(SmbiosTable
.Raw
+ SmbiosTableLength (SmbiosTable
));
152 if (NeedSmbiosType0
) {
154 // Add OVMF default Type 0 (BIOS Information) table
156 SmbiosHandle
= SMBIOS_HANDLE_PI_RESERVED
;
157 Status
= Smbios
->Add (
161 (EFI_SMBIOS_TABLE_HEADER
*)&mOvmfDefaultType0
163 ASSERT_EFI_ERROR (Status
);