3 Copyright (c) 2009, Intel Corporation. All rights reserved. <BR>
4 This software and associated documentation (if any) is furnished
5 under a license and may only be used or copied in accordance
6 with the terms of the license. Except as permitted by such
7 license, no part of this software or documentation may be
8 reproduced, stored in a retrieval system, or transmitted in any
9 form or by any means without the express written consent of
15 MiscBiosVendorFunction.c
19 BIOS vendor information boot time changes.
20 Misc. subclass type 2.
25 #include "MiscSubclassDriver.h"
28 This function returns the value & exponent to Base2 for a given
29 Hex value. This is used to calculate the BiosPhysicalDeviceSize.
31 @param Value The hex value which is to be converted into value-exponent form
32 @param Exponent The exponent out of the conversion
34 @retval EFI_SUCCESS All parameters were valid and *Value & *Exponent have been set.
35 @retval EFI_INVALID_PARAMETER Invalid parameter was found.
39 GetValueExponentBase2(
44 if ((Value
== NULL
) || (Exponent
== NULL
)) {
45 return EFI_INVALID_PARAMETER
;
48 while ((*Value
% 2) == 0) {
57 Field Filling Function. Transform an EFI_EXP_BASE2_DATA to a byte, with '64k'
60 @param Base2Data Pointer to Base2_Data
62 @retval EFI_SUCCESS Transform successfully.
63 @retval EFI_INVALID_PARAMETER Invalid parameter was found.
67 Base2ToByteWith64KUnit (
68 IN EFI_EXP_BASE2_DATA
*Base2Data
74 Value
= Base2Data
->Value
;
75 Exponent
= Base2Data
->Exponent
;
84 This function makes boot time changes to the contents of the
85 MiscBiosVendor (Type 0).
87 @param RecordData Pointer to copy of RecordData from the Data Table.
89 @retval EFI_SUCCESS All parameters were valid.
90 @retval EFI_UNSUPPORTED Unexpected RecordType value.
91 @retval EFI_INVALID_PARAMETER Invalid parameter was found.
94 MISC_SMBIOS_TABLE_FUNCTION(MiscBiosVendor
)
96 CHAR8
*OptionalStrStart
;
103 EFI_STRING Char16String
;
104 STRING_REF TokenToGet
;
105 STRING_REF TokenToUpdate
;
106 SMBIOS_TABLE_TYPE0
*SmbiosRecord
;
107 EFI_SMBIOS_HANDLE SmbiosHandle
;
108 EFI_MISC_BIOS_VENDOR
*ForType0InputData
;
110 ForType0InputData
= (EFI_MISC_BIOS_VENDOR
*)RecordData
;
113 // First check for invalid parameters.
115 if (RecordData
== NULL
) {
116 return EFI_INVALID_PARAMETER
;
119 Version
= (CHAR16
*) PcdGetPtr (PcdFirmwareVersionString
);
120 if (StrLen (Version
) > 0) {
121 TokenToUpdate
= STRING_TOKEN (STR_MISC_BIOS_VERSION
);
122 HiiSetString (mHiiHandle
, TokenToUpdate
, Version
, NULL
);
125 ReleaseDate
= (CHAR16
*) PcdGetPtr (PcdFirmwareReleaseDateString
);
126 if (StrLen(ReleaseDate
) > 0) {
127 TokenToUpdate
= STRING_TOKEN (STR_MISC_BIOS_RELEASE_DATE
);
128 HiiSetString (mHiiHandle
, TokenToUpdate
, ReleaseDate
, NULL
);
131 TokenToGet
= STRING_TOKEN (STR_MISC_BIOS_VENDOR
);
132 Char16String
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
133 VendorStrLen
= StrLen(Char16String
);
134 if (VendorStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
135 return EFI_UNSUPPORTED
;
138 TokenToGet
= STRING_TOKEN (STR_MISC_BIOS_VERSION
);
139 Version
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
140 VerStrLen
= StrLen(Version
);
141 if (VerStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
142 return EFI_UNSUPPORTED
;
145 TokenToGet
= STRING_TOKEN (STR_MISC_BIOS_RELEASE_DATE
);
146 ReleaseDate
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
147 DateStrLen
= StrLen(ReleaseDate
);
148 if (DateStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
149 return EFI_UNSUPPORTED
;
153 // Two zeros following the last string.
155 SmbiosRecord
= AllocatePool(sizeof (SMBIOS_TABLE_TYPE0
) + VendorStrLen
+ 1 + VerStrLen
+ 1 + DateStrLen
+ 1 + 1);
156 ZeroMem(SmbiosRecord
, sizeof (SMBIOS_TABLE_TYPE0
) + VendorStrLen
+ 1 + VerStrLen
+ 1 + DateStrLen
+ 1 + 1);
158 SmbiosRecord
->Hdr
.Type
= EFI_SMBIOS_TYPE_BIOS_INFORMATION
;
159 SmbiosRecord
->Hdr
.Length
= sizeof (SMBIOS_TABLE_TYPE0
);
161 // Make handle chosen by smbios protocol.add automatically.
163 SmbiosRecord
->Hdr
.Handle
= 0;
165 // Vendor will be the 1st optional string following the formatted structure.
167 SmbiosRecord
->Vendor
= 1;
169 // Version will be the 2nd optional string following the formatted structure.
171 SmbiosRecord
->BiosVersion
= 2;
172 SmbiosRecord
->BiosSegment
= (UINT16
)ForType0InputData
->BiosStartingAddress
;
174 // ReleaseDate will be the 3rd optional string following the formatted structure.
176 SmbiosRecord
->BiosReleaseDate
= 3;
178 // Nt32 has no PCD value to indicate BIOS Size, just fill 0 for simply.
180 SmbiosRecord
->BiosSize
= 0;
181 SmbiosRecord
->BiosCharacteristics
= *(MISC_BIOS_CHARACTERISTICS
*)(&ForType0InputData
->BiosCharacteristics1
);
183 // CharacterExtensionBytes also store in ForType0InputData->BiosCharacteristics1 later two bytes to save size.
185 SmbiosRecord
->BIOSCharacteristicsExtensionBytes
[0] = *((UINT8
*) &ForType0InputData
->BiosCharacteristics1
+ 4);
186 SmbiosRecord
->BIOSCharacteristicsExtensionBytes
[1] = *((UINT8
*) &ForType0InputData
->BiosCharacteristics1
+ 5);
188 SmbiosRecord
->SystemBiosMajorRelease
= ForType0InputData
->BiosMajorRelease
;
189 SmbiosRecord
->SystemBiosMinorRelease
= ForType0InputData
->BiosMinorRelease
;
190 SmbiosRecord
->EmbeddedControllerFirmwareMajorRelease
= ForType0InputData
->BiosEmbeddedFirmwareMajorRelease
;
191 SmbiosRecord
->EmbeddedControllerFirmwareMinorRelease
= ForType0InputData
->BiosEmbeddedFirmwareMinorRelease
;
193 OptionalStrStart
= (CHAR8
*)(SmbiosRecord
+ 1);
194 UnicodeStrToAsciiStr(Char16String
, OptionalStrStart
);
195 UnicodeStrToAsciiStr(Version
, OptionalStrStart
+ VendorStrLen
+ 1);
196 UnicodeStrToAsciiStr(ReleaseDate
, OptionalStrStart
+ VendorStrLen
+ 1 + VerStrLen
+ 1);
198 // Now we have got the full smbios record, call smbios protocol to add this record.
201 Status
= Smbios
-> Add(
205 (EFI_SMBIOS_TABLE_HEADER
*) SmbiosRecord
208 FreePool(SmbiosRecord
);