2 BaseBoard manufacturer information boot time changes.
5 Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #include "MiscSubClassDriver.h"
12 This function makes boot time changes to the contents of the
13 MiscBaseBoardManufacturer (Type 2).
15 @param RecordData Pointer to copy of RecordData from the Data Table.
17 @retval EFI_SUCCESS All parameters were valid.
18 @retval EFI_UNSUPPORTED Unexpected RecordType value.
19 @retval EFI_INVALID_PARAMETER Invalid parameter was found.
22 MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer
)
24 CHAR8
*OptionalStrStart
;
28 UINTN AssertTagStrLen
;
29 UINTN SerialNumStrLen
;
32 EFI_STRING Manufacturer
;
35 EFI_STRING SerialNumber
;
38 STRING_REF TokenToGet
;
39 EFI_SMBIOS_HANDLE SmbiosHandle
;
40 SMBIOS_TABLE_TYPE2
*SmbiosRecord
;
41 EFI_MISC_BASE_BOARD_MANUFACTURER
*ForType2InputData
;
43 ForType2InputData
= (EFI_MISC_BASE_BOARD_MANUFACTURER
*)RecordData
;
46 // First check for invalid parameters.
48 if (RecordData
== NULL
) {
49 return EFI_INVALID_PARAMETER
;
52 TokenToGet
= STRING_TOKEN (STR_MISC_BASE_BOARD_MANUFACTURER
);
53 Manufacturer
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
54 ManuStrLen
= StrLen(Manufacturer
);
55 if (ManuStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
56 return EFI_UNSUPPORTED
;
59 TokenToGet
= STRING_TOKEN (STR_MISC_BASE_BOARD_PRODUCT_NAME
);
60 Product
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
61 ProductStrLen
= StrLen(Product
);
62 if (ProductStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
63 return EFI_UNSUPPORTED
;
66 TokenToGet
= STRING_TOKEN (STR_MISC_BASE_BOARD_VERSION
);
67 Version
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
68 VerStrLen
= StrLen(Version
);
69 if (VerStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
70 return EFI_UNSUPPORTED
;
73 TokenToGet
= STRING_TOKEN (STR_MISC_BASE_BOARD_SERIAL_NUMBER
);
74 SerialNumber
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
75 SerialNumStrLen
= StrLen(SerialNumber
);
76 if (SerialNumStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
77 return EFI_UNSUPPORTED
;
80 TokenToGet
= STRING_TOKEN (STR_MISC_BASE_BOARD_ASSET_TAG
);
81 AssertTag
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
82 AssertTagStrLen
= StrLen(AssertTag
);
83 if (AssertTagStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
84 return EFI_UNSUPPORTED
;
87 TokenToGet
= STRING_TOKEN (STR_MISC_BASE_BOARD_CHASSIS_LOCATION
);
88 Chassis
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
89 ChassisStrLen
= StrLen(Chassis
);
90 if (ChassisStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
91 return EFI_UNSUPPORTED
;
96 // Two zeros following the last string.
98 SmbiosRecord
= AllocatePool(sizeof (SMBIOS_TABLE_TYPE3
) + ManuStrLen
+ 1 + ProductStrLen
+ 1 + VerStrLen
+ 1 + SerialNumStrLen
+ 1 + AssertTagStrLen
+ 1 + ChassisStrLen
+1 + 1);
99 ZeroMem(SmbiosRecord
, sizeof (SMBIOS_TABLE_TYPE3
) + ManuStrLen
+ 1 + ProductStrLen
+ 1 + VerStrLen
+ 1 + SerialNumStrLen
+ 1 + AssertTagStrLen
+ 1 + ChassisStrLen
+1 + 1);
101 SmbiosRecord
->Hdr
.Type
= EFI_SMBIOS_TYPE_BASEBOARD_INFORMATION
;
102 SmbiosRecord
->Hdr
.Length
= sizeof (SMBIOS_TABLE_TYPE2
);
104 // Make handle chosen by smbios protocol.add automatically.
106 SmbiosRecord
->Hdr
.Handle
= 0;
108 // Manu will be the 1st optional string following the formatted structure.
110 SmbiosRecord
->Manufacturer
= 1;
112 // ProductName will be the 2st optional string following the formatted structure.
114 SmbiosRecord
->ProductName
= 2;
116 // Version will be the 3rd optional string following the formatted structure.
118 SmbiosRecord
->Version
= 3;
120 // SerialNumber will be the 4th optional string following the formatted structure.
122 SmbiosRecord
->SerialNumber
= 4;
124 // AssertTag will be the 5th optional string following the formatted structure.
126 SmbiosRecord
->AssetTag
= 5;
129 // LocationInChassis will be the 6th optional string following the formatted structure.
131 SmbiosRecord
->LocationInChassis
= 6;
132 SmbiosRecord
->FeatureFlag
= (*(BASE_BOARD_FEATURE_FLAGS
*)&(ForType2InputData
->BaseBoardFeatureFlags
));
133 SmbiosRecord
->ChassisHandle
= 0;
134 SmbiosRecord
->BoardType
= (UINT8
)ForType2InputData
->BaseBoardType
;
135 SmbiosRecord
->NumberOfContainedObjectHandles
= 0;
137 OptionalStrStart
= (CHAR8
*)(SmbiosRecord
+ 1);
139 // Since we fill NumberOfContainedObjectHandles = 0 for simple, just after this filed to fill string
141 OptionalStrStart
-= 2;
142 UnicodeStrToAsciiStr(Manufacturer
, OptionalStrStart
);
143 UnicodeStrToAsciiStr(Product
, OptionalStrStart
+ ManuStrLen
+ 1);
144 UnicodeStrToAsciiStr(Version
, OptionalStrStart
+ ManuStrLen
+ 1 + ProductStrLen
+ 1);
145 UnicodeStrToAsciiStr(SerialNumber
, OptionalStrStart
+ ManuStrLen
+ 1 + ProductStrLen
+ 1 + VerStrLen
+ 1);
146 UnicodeStrToAsciiStr(AssertTag
, OptionalStrStart
+ ManuStrLen
+ 1 + ProductStrLen
+ 1 + VerStrLen
+ 1 + SerialNumStrLen
+ 1);
147 UnicodeStrToAsciiStr(Chassis
, OptionalStrStart
+ ManuStrLen
+ 1 + ProductStrLen
+ 1 + VerStrLen
+ 1 + SerialNumStrLen
+ 1 + AssertTagStrLen
+ 1);
149 // Now we have got the full smbios record, call smbios protocol to add this record.
151 Status
= AddSmbiosRecord (Smbios
, &SmbiosHandle
, (EFI_SMBIOS_TABLE_HEADER
*) SmbiosRecord
);
153 FreePool(SmbiosRecord
);