2 BIOS vendor information boot time changes.
6 Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
7 SPDX-License-Identifier: BSD-2-Clause-Patent
11 #include "MiscSubclassDriver.h"
14 This function returns the value & exponent to Base2 for a given
15 Hex value. This is used to calculate the BiosPhysicalDeviceSize.
17 @param Value The hex value which is to be converted into value-exponent form
18 @param Exponent The exponent out of the conversion
20 @retval EFI_SUCCESS All parameters were valid and *Value & *Exponent have been set.
21 @retval EFI_INVALID_PARAMETER Invalid parameter was found.
25 GetValueExponentBase2(
30 if ((Value
== NULL
) || (Exponent
== NULL
)) {
31 return EFI_INVALID_PARAMETER
;
34 while ((*Value
% 2) == 0) {
43 Field Filling Function. Transform an EFI_EXP_BASE2_DATA to a byte, with '64k'
46 @param Base2Data Pointer to Base2_Data
48 @retval EFI_SUCCESS Transform successfully.
49 @retval EFI_INVALID_PARAMETER Invalid parameter was found.
53 Base2ToByteWith64KUnit (
54 IN EFI_EXP_BASE2_DATA
*Base2Data
60 Value
= Base2Data
->Value
;
61 Exponent
= Base2Data
->Exponent
;
70 This function makes boot time changes to the contents of the
71 MiscBiosVendor (Type 0).
73 @param RecordData Pointer to copy of RecordData from the Data Table.
75 @retval EFI_SUCCESS All parameters were valid.
76 @retval EFI_UNSUPPORTED Unexpected RecordType value.
77 @retval EFI_INVALID_PARAMETER Invalid parameter was found.
80 MISC_SMBIOS_TABLE_FUNCTION(MiscBiosVendor
)
82 CHAR8
*OptionalStrStart
;
89 EFI_STRING Char16String
;
90 STRING_REF TokenToGet
;
91 STRING_REF TokenToUpdate
;
92 SMBIOS_TABLE_TYPE0
*SmbiosRecord
;
93 EFI_SMBIOS_HANDLE SmbiosHandle
;
94 EFI_MISC_BIOS_VENDOR
*ForType0InputData
;
96 ForType0InputData
= (EFI_MISC_BIOS_VENDOR
*)RecordData
;
99 // First check for invalid parameters.
101 if (RecordData
== NULL
) {
102 return EFI_INVALID_PARAMETER
;
105 Version
= (CHAR16
*) PcdGetPtr (PcdFirmwareVersionString
);
106 if (StrLen (Version
) > 0) {
107 TokenToUpdate
= STRING_TOKEN (STR_MISC_BIOS_VERSION
);
108 HiiSetString (mHiiHandle
, TokenToUpdate
, Version
, NULL
);
111 ReleaseDate
= (CHAR16
*) PcdGetPtr (PcdFirmwareReleaseDateString
);
112 if (StrLen(ReleaseDate
) > 0) {
113 TokenToUpdate
= STRING_TOKEN (STR_MISC_BIOS_RELEASE_DATE
);
114 HiiSetString (mHiiHandle
, TokenToUpdate
, ReleaseDate
, NULL
);
117 TokenToGet
= STRING_TOKEN (STR_MISC_BIOS_VENDOR
);
118 Char16String
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
119 VendorStrLen
= StrLen(Char16String
);
120 if (VendorStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
121 return EFI_UNSUPPORTED
;
124 TokenToGet
= STRING_TOKEN (STR_MISC_BIOS_VERSION
);
125 Version
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
126 VerStrLen
= StrLen(Version
);
127 if (VerStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
128 return EFI_UNSUPPORTED
;
131 TokenToGet
= STRING_TOKEN (STR_MISC_BIOS_RELEASE_DATE
);
132 ReleaseDate
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
133 DateStrLen
= StrLen(ReleaseDate
);
134 if (DateStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
135 return EFI_UNSUPPORTED
;
139 // Two zeros following the last string.
141 SmbiosRecord
= AllocatePool(sizeof (SMBIOS_TABLE_TYPE0
) + VendorStrLen
+ 1 + VerStrLen
+ 1 + DateStrLen
+ 1 + 1);
142 ZeroMem(SmbiosRecord
, sizeof (SMBIOS_TABLE_TYPE0
) + VendorStrLen
+ 1 + VerStrLen
+ 1 + DateStrLen
+ 1 + 1);
144 SmbiosRecord
->Hdr
.Type
= EFI_SMBIOS_TYPE_BIOS_INFORMATION
;
145 SmbiosRecord
->Hdr
.Length
= sizeof (SMBIOS_TABLE_TYPE0
);
147 // Make handle chosen by smbios protocol.add automatically.
149 SmbiosRecord
->Hdr
.Handle
= 0;
151 // Vendor will be the 1st optional string following the formatted structure.
153 SmbiosRecord
->Vendor
= 1;
155 // Version will be the 2nd optional string following the formatted structure.
157 SmbiosRecord
->BiosVersion
= 2;
158 SmbiosRecord
->BiosSegment
= (UINT16
)ForType0InputData
->BiosStartingAddress
;
160 // ReleaseDate will be the 3rd optional string following the formatted structure.
162 SmbiosRecord
->BiosReleaseDate
= 3;
164 // Nt32 has no PCD value to indicate BIOS Size, just fill 0 for simply.
166 SmbiosRecord
->BiosSize
= 0;
167 SmbiosRecord
->BiosCharacteristics
= *(MISC_BIOS_CHARACTERISTICS
*)(&ForType0InputData
->BiosCharacteristics1
);
169 // CharacterExtensionBytes also store in ForType0InputData->BiosCharacteristics1 later two bytes to save size.
171 SmbiosRecord
->BIOSCharacteristicsExtensionBytes
[0] = *((UINT8
*) &ForType0InputData
->BiosCharacteristics1
+ 4);
172 SmbiosRecord
->BIOSCharacteristicsExtensionBytes
[1] = *((UINT8
*) &ForType0InputData
->BiosCharacteristics1
+ 5);
174 SmbiosRecord
->SystemBiosMajorRelease
= ForType0InputData
->BiosMajorRelease
;
175 SmbiosRecord
->SystemBiosMinorRelease
= ForType0InputData
->BiosMinorRelease
;
176 SmbiosRecord
->EmbeddedControllerFirmwareMajorRelease
= ForType0InputData
->BiosEmbeddedFirmwareMajorRelease
;
177 SmbiosRecord
->EmbeddedControllerFirmwareMinorRelease
= ForType0InputData
->BiosEmbeddedFirmwareMinorRelease
;
179 OptionalStrStart
= (CHAR8
*)(SmbiosRecord
+ 1);
180 UnicodeStrToAsciiStr(Char16String
, OptionalStrStart
);
181 UnicodeStrToAsciiStr(Version
, OptionalStrStart
+ VendorStrLen
+ 1);
182 UnicodeStrToAsciiStr(ReleaseDate
, OptionalStrStart
+ VendorStrLen
+ 1 + VerStrLen
+ 1);
184 // Now we have got the full smbios record, call smbios protocol to add this record.
186 Status
= AddSmbiosRecord (Smbios
, &SmbiosHandle
, (EFI_SMBIOS_TABLE_HEADER
*) SmbiosRecord
);
188 FreePool(SmbiosRecord
);