2 BaseBoard manufacturer information boot time changes.
5 Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
6 (C) Copyright 2017 Hewlett Packard Enterprise Development LP<BR>
7 SPDX-License-Identifier: BSD-2-Clause-Patent
11 #include "MiscSubclassDriver.h"
13 This function makes boot time changes to the contents of the
14 MiscBaseBoardManufacturer (Type 2).
16 @param RecordData Pointer to copy of RecordData from the Data Table.
18 @retval EFI_SUCCESS All parameters were valid.
19 @retval EFI_UNSUPPORTED Unexpected RecordType value.
20 @retval EFI_INVALID_PARAMETER Invalid parameter was found.
23 MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer
)
25 CHAR8
*OptionalStrStart
;
30 UINTN SerialNumStrLen
;
33 EFI_STRING Manufacturer
;
36 EFI_STRING SerialNumber
;
39 STRING_REF TokenToGet
;
40 EFI_SMBIOS_HANDLE SmbiosHandle
;
41 SMBIOS_TABLE_TYPE2
*SmbiosRecord
;
42 EFI_MISC_BASE_BOARD_MANUFACTURER
*ForType2InputData
;
44 ForType2InputData
= (EFI_MISC_BASE_BOARD_MANUFACTURER
*)RecordData
;
47 // First check for invalid parameters.
49 if (RecordData
== NULL
) {
50 return EFI_INVALID_PARAMETER
;
53 TokenToGet
= STRING_TOKEN (STR_MISC_BASE_BOARD_MANUFACTURER
);
54 Manufacturer
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
55 ManuStrLen
= StrLen(Manufacturer
);
56 if (ManuStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
57 return EFI_UNSUPPORTED
;
60 TokenToGet
= STRING_TOKEN (STR_MISC_BASE_BOARD_PRODUCT_NAME
);
61 Product
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
62 ProductStrLen
= StrLen(Product
);
63 if (ProductStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
64 return EFI_UNSUPPORTED
;
67 TokenToGet
= STRING_TOKEN (STR_MISC_BASE_BOARD_VERSION
);
68 Version
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
69 VerStrLen
= StrLen(Version
);
70 if (VerStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
71 return EFI_UNSUPPORTED
;
74 TokenToGet
= STRING_TOKEN (STR_MISC_BASE_BOARD_SERIAL_NUMBER
);
75 SerialNumber
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
76 SerialNumStrLen
= StrLen(SerialNumber
);
77 if (SerialNumStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
78 return EFI_UNSUPPORTED
;
81 TokenToGet
= STRING_TOKEN (STR_MISC_BASE_BOARD_ASSET_TAG
);
82 AssetTag
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
83 AssetTagStrLen
= StrLen(AssetTag
);
84 if (AssetTagStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
85 return EFI_UNSUPPORTED
;
88 TokenToGet
= STRING_TOKEN (STR_MISC_BASE_BOARD_CHASSIS_LOCATION
);
89 Chassis
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
90 ChassisStrLen
= StrLen(Chassis
);
91 if (ChassisStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
92 return EFI_UNSUPPORTED
;
97 // Two zeros following the last string.
99 // Since we fill NumberOfContainedObjectHandles = 0, remove sizeof (UINT16) bytes for ContainedObjectHandles[1]
101 SmbiosRecord
= AllocatePool(sizeof (SMBIOS_TABLE_TYPE2
) - sizeof (UINT16
) + ManuStrLen
+ 1 + ProductStrLen
+ 1 + VerStrLen
+ 1 + SerialNumStrLen
+ 1 + AssetTagStrLen
+ 1 + ChassisStrLen
+ 1 + 1);
102 ZeroMem(SmbiosRecord
, sizeof (SMBIOS_TABLE_TYPE2
) - sizeof (UINT16
) + ManuStrLen
+ 1 + ProductStrLen
+ 1 + VerStrLen
+ 1 + SerialNumStrLen
+ 1 + AssetTagStrLen
+ 1 + ChassisStrLen
+ 1 + 1);
104 SmbiosRecord
->Hdr
.Type
= EFI_SMBIOS_TYPE_BASEBOARD_INFORMATION
;
106 // Since we fill NumberOfContainedObjectHandles = 0, remove sizeof (UINT16) bytes for ContainedObjectHandles[1]
108 SmbiosRecord
->Hdr
.Length
= sizeof (SMBIOS_TABLE_TYPE2
) - sizeof (UINT16
);
110 // Make handle chosen by smbios protocol.add automatically.
112 SmbiosRecord
->Hdr
.Handle
= 0;
114 // Manu will be the 1st optional string following the formatted structure.
116 SmbiosRecord
->Manufacturer
= 1;
118 // ProductName will be the 2st optional string following the formatted structure.
120 SmbiosRecord
->ProductName
= 2;
122 // Version will be the 3rd optional string following the formatted structure.
124 SmbiosRecord
->Version
= 3;
126 // SerialNumber will be the 4th optional string following the formatted structure.
128 SmbiosRecord
->SerialNumber
= 4;
130 // AssetTag will be the 5th optional string following the formatted structure.
132 SmbiosRecord
->AssetTag
= 5;
135 // LocationInChassis will be the 6th optional string following the formatted structure.
137 SmbiosRecord
->LocationInChassis
= 6;
138 SmbiosRecord
->FeatureFlag
= (*(BASE_BOARD_FEATURE_FLAGS
*)&(ForType2InputData
->BaseBoardFeatureFlags
));
139 SmbiosRecord
->ChassisHandle
= 0;
140 SmbiosRecord
->BoardType
= (UINT8
)ForType2InputData
->BaseBoardType
;
141 SmbiosRecord
->NumberOfContainedObjectHandles
= 0;
143 OptionalStrStart
= (CHAR8
*)(SmbiosRecord
+ 1);
145 // Since we fill NumberOfContainedObjectHandles = 0, just after this field to fill string
147 OptionalStrStart
-= sizeof (UINT16
);
148 UnicodeStrToAsciiStr(Manufacturer
, OptionalStrStart
);
149 UnicodeStrToAsciiStr(Product
, OptionalStrStart
+ ManuStrLen
+ 1);
150 UnicodeStrToAsciiStr(Version
, OptionalStrStart
+ ManuStrLen
+ 1 + ProductStrLen
+ 1);
151 UnicodeStrToAsciiStr(SerialNumber
, OptionalStrStart
+ ManuStrLen
+ 1 + ProductStrLen
+ 1 + VerStrLen
+ 1);
152 UnicodeStrToAsciiStr(AssetTag
, OptionalStrStart
+ ManuStrLen
+ 1 + ProductStrLen
+ 1 + VerStrLen
+ 1 + SerialNumStrLen
+ 1);
153 UnicodeStrToAsciiStr(Chassis
, OptionalStrStart
+ ManuStrLen
+ 1 + ProductStrLen
+ 1 + VerStrLen
+ 1 + SerialNumStrLen
+ 1 + AssetTagStrLen
+ 1);
155 // Now we have got the full smbios record, call smbios protocol to add this record.
157 Status
= AddSmbiosRecord (Smbios
, &SmbiosHandle
, (EFI_SMBIOS_TABLE_HEADER
*) SmbiosRecord
);
159 FreePool(SmbiosRecord
);