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 This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #include "MiscSubclassDriver.h"
19 This function makes boot time changes to the contents of the
20 MiscBaseBoardManufacturer (Type 2).
22 @param RecordData Pointer to copy of RecordData from the Data Table.
24 @retval EFI_SUCCESS All parameters were valid.
25 @retval EFI_UNSUPPORTED Unexpected RecordType value.
26 @retval EFI_INVALID_PARAMETER Invalid parameter was found.
29 MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer
)
31 CHAR8
*OptionalStrStart
;
36 UINTN SerialNumStrLen
;
39 EFI_STRING Manufacturer
;
42 EFI_STRING SerialNumber
;
45 STRING_REF TokenToGet
;
46 EFI_SMBIOS_HANDLE SmbiosHandle
;
47 SMBIOS_TABLE_TYPE2
*SmbiosRecord
;
48 EFI_MISC_BASE_BOARD_MANUFACTURER
*ForType2InputData
;
50 ForType2InputData
= (EFI_MISC_BASE_BOARD_MANUFACTURER
*)RecordData
;
53 // First check for invalid parameters.
55 if (RecordData
== NULL
) {
56 return EFI_INVALID_PARAMETER
;
59 TokenToGet
= STRING_TOKEN (STR_MISC_BASE_BOARD_MANUFACTURER
);
60 Manufacturer
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
61 ManuStrLen
= StrLen(Manufacturer
);
62 if (ManuStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
63 return EFI_UNSUPPORTED
;
66 TokenToGet
= STRING_TOKEN (STR_MISC_BASE_BOARD_PRODUCT_NAME
);
67 Product
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
68 ProductStrLen
= StrLen(Product
);
69 if (ProductStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
70 return EFI_UNSUPPORTED
;
73 TokenToGet
= STRING_TOKEN (STR_MISC_BASE_BOARD_VERSION
);
74 Version
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
75 VerStrLen
= StrLen(Version
);
76 if (VerStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
77 return EFI_UNSUPPORTED
;
80 TokenToGet
= STRING_TOKEN (STR_MISC_BASE_BOARD_SERIAL_NUMBER
);
81 SerialNumber
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
82 SerialNumStrLen
= StrLen(SerialNumber
);
83 if (SerialNumStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
84 return EFI_UNSUPPORTED
;
87 TokenToGet
= STRING_TOKEN (STR_MISC_BASE_BOARD_ASSET_TAG
);
88 AssetTag
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
89 AssetTagStrLen
= StrLen(AssetTag
);
90 if (AssetTagStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
91 return EFI_UNSUPPORTED
;
94 TokenToGet
= STRING_TOKEN (STR_MISC_BASE_BOARD_CHASSIS_LOCATION
);
95 Chassis
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
96 ChassisStrLen
= StrLen(Chassis
);
97 if (ChassisStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
98 return EFI_UNSUPPORTED
;
103 // Two zeros following the last string.
105 // Since we fill NumberOfContainedObjectHandles = 0, remove sizeof (UINT16) bytes for ContainedObjectHandles[1]
107 SmbiosRecord
= AllocatePool(sizeof (SMBIOS_TABLE_TYPE2
) - sizeof (UINT16
) + ManuStrLen
+ 1 + ProductStrLen
+ 1 + VerStrLen
+ 1 + SerialNumStrLen
+ 1 + AssetTagStrLen
+ 1 + ChassisStrLen
+ 1 + 1);
108 ZeroMem(SmbiosRecord
, sizeof (SMBIOS_TABLE_TYPE2
) - sizeof (UINT16
) + ManuStrLen
+ 1 + ProductStrLen
+ 1 + VerStrLen
+ 1 + SerialNumStrLen
+ 1 + AssetTagStrLen
+ 1 + ChassisStrLen
+ 1 + 1);
110 SmbiosRecord
->Hdr
.Type
= EFI_SMBIOS_TYPE_BASEBOARD_INFORMATION
;
112 // Since we fill NumberOfContainedObjectHandles = 0, remove sizeof (UINT16) bytes for ContainedObjectHandles[1]
114 SmbiosRecord
->Hdr
.Length
= sizeof (SMBIOS_TABLE_TYPE2
) - sizeof (UINT16
);
116 // Make handle chosen by smbios protocol.add automatically.
118 SmbiosRecord
->Hdr
.Handle
= 0;
120 // Manu will be the 1st optional string following the formatted structure.
122 SmbiosRecord
->Manufacturer
= 1;
124 // ProductName will be the 2st optional string following the formatted structure.
126 SmbiosRecord
->ProductName
= 2;
128 // Version will be the 3rd optional string following the formatted structure.
130 SmbiosRecord
->Version
= 3;
132 // SerialNumber will be the 4th optional string following the formatted structure.
134 SmbiosRecord
->SerialNumber
= 4;
136 // AssetTag will be the 5th optional string following the formatted structure.
138 SmbiosRecord
->AssetTag
= 5;
141 // LocationInChassis will be the 6th optional string following the formatted structure.
143 SmbiosRecord
->LocationInChassis
= 6;
144 SmbiosRecord
->FeatureFlag
= (*(BASE_BOARD_FEATURE_FLAGS
*)&(ForType2InputData
->BaseBoardFeatureFlags
));
145 SmbiosRecord
->ChassisHandle
= 0;
146 SmbiosRecord
->BoardType
= (UINT8
)ForType2InputData
->BaseBoardType
;
147 SmbiosRecord
->NumberOfContainedObjectHandles
= 0;
149 OptionalStrStart
= (CHAR8
*)(SmbiosRecord
+ 1);
151 // Since we fill NumberOfContainedObjectHandles = 0, just after this field to fill string
153 OptionalStrStart
-= sizeof (UINT16
);
154 UnicodeStrToAsciiStr(Manufacturer
, OptionalStrStart
);
155 UnicodeStrToAsciiStr(Product
, OptionalStrStart
+ ManuStrLen
+ 1);
156 UnicodeStrToAsciiStr(Version
, OptionalStrStart
+ ManuStrLen
+ 1 + ProductStrLen
+ 1);
157 UnicodeStrToAsciiStr(SerialNumber
, OptionalStrStart
+ ManuStrLen
+ 1 + ProductStrLen
+ 1 + VerStrLen
+ 1);
158 UnicodeStrToAsciiStr(AssetTag
, OptionalStrStart
+ ManuStrLen
+ 1 + ProductStrLen
+ 1 + VerStrLen
+ 1 + SerialNumStrLen
+ 1);
159 UnicodeStrToAsciiStr(Chassis
, OptionalStrStart
+ ManuStrLen
+ 1 + ProductStrLen
+ 1 + VerStrLen
+ 1 + SerialNumStrLen
+ 1 + AssetTagStrLen
+ 1);
161 // Now we have got the full smbios record, call smbios protocol to add this record.
163 Status
= AddSmbiosRecord (Smbios
, &SmbiosHandle
, (EFI_SMBIOS_TABLE_HEADER
*) SmbiosRecord
);
165 FreePool(SmbiosRecord
);