2 Chassis 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"
13 This function makes boot time changes to the contents of the
14 MiscChassisManufacturer (Type 3).
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(MiscChassisManufacturer
)
25 CHAR8
*OptionalStrStart
;
28 UINTN AssertTagStrLen
;
29 UINTN SerialNumStrLen
;
31 EFI_STRING Manufacturer
;
33 EFI_STRING SerialNumber
;
35 STRING_REF TokenToGet
;
36 EFI_SMBIOS_HANDLE SmbiosHandle
;
37 SMBIOS_TABLE_TYPE3
*SmbiosRecord
;
38 EFI_MISC_CHASSIS_MANUFACTURER
*ForType3InputData
;
40 ForType3InputData
= (EFI_MISC_CHASSIS_MANUFACTURER
*)RecordData
;
43 // First check for invalid parameters.
45 if (RecordData
== NULL
) {
46 return EFI_INVALID_PARAMETER
;
49 TokenToGet
= STRING_TOKEN (STR_MISC_CHASSIS_MANUFACTURER
);
50 Manufacturer
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
51 ManuStrLen
= StrLen(Manufacturer
);
52 if (ManuStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
53 return EFI_UNSUPPORTED
;
56 TokenToGet
= STRING_TOKEN (STR_MISC_CHASSIS_VERSION
);
57 Version
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
58 VerStrLen
= StrLen(Version
);
59 if (VerStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
60 return EFI_UNSUPPORTED
;
63 TokenToGet
= STRING_TOKEN (STR_MISC_CHASSIS_SERIAL_NUMBER
);
64 SerialNumber
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
65 SerialNumStrLen
= StrLen(SerialNumber
);
66 if (SerialNumStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
67 return EFI_UNSUPPORTED
;
70 TokenToGet
= STRING_TOKEN (STR_MISC_CHASSIS_ASSET_TAG
);
71 AssertTag
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
72 AssertTagStrLen
= StrLen(AssertTag
);
73 if (AssertTagStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
74 return EFI_UNSUPPORTED
;
78 // Two zeros following the last string.
80 SmbiosRecord
= AllocatePool(sizeof (SMBIOS_TABLE_TYPE3
) + ManuStrLen
+ 1 + VerStrLen
+ 1 + SerialNumStrLen
+ 1 + AssertTagStrLen
+ 1 + 1);
81 ZeroMem(SmbiosRecord
, sizeof (SMBIOS_TABLE_TYPE3
) + ManuStrLen
+ 1 + VerStrLen
+ 1 + SerialNumStrLen
+ 1 + AssertTagStrLen
+ 1 + 1);
83 SmbiosRecord
->Hdr
.Type
= EFI_SMBIOS_TYPE_SYSTEM_ENCLOSURE
;
84 SmbiosRecord
->Hdr
.Length
= sizeof (SMBIOS_TABLE_TYPE3
);
86 // Make handle chosen by smbios protocol.add automatically.
88 SmbiosRecord
->Hdr
.Handle
= 0;
90 // Manu will be the 1st optional string following the formatted structure.
92 SmbiosRecord
->Manufacturer
= 1;
93 SmbiosRecord
->Type
= (UINT8
)ForType3InputData
->ChassisType
.ChassisType
;
95 // Version will be the 2nd optional string following the formatted structure.
97 SmbiosRecord
->Version
= 2;
99 // SerialNumber will be the 3rd optional string following the formatted structure.
101 SmbiosRecord
->SerialNumber
= 3;
103 // AssertTag will be the 4th optional string following the formatted structure.
105 SmbiosRecord
->AssetTag
= 4;
106 SmbiosRecord
->BootupState
= (UINT8
)ForType3InputData
->ChassisBootupState
;
107 SmbiosRecord
->PowerSupplyState
= (UINT8
)ForType3InputData
->ChassisPowerSupplyState
;
108 SmbiosRecord
->ThermalState
= (UINT8
)ForType3InputData
->ChassisThermalState
;
109 SmbiosRecord
->SecurityStatus
= (UINT8
)ForType3InputData
->ChassisSecurityState
;
110 CopyMem (SmbiosRecord
->OemDefined
,(UINT8
*)&ForType3InputData
->ChassisOemDefined
, 4);
112 OptionalStrStart
= (CHAR8
*)(SmbiosRecord
+ 1);
113 UnicodeStrToAsciiStr(Manufacturer
, OptionalStrStart
);
114 UnicodeStrToAsciiStr(Version
, OptionalStrStart
+ ManuStrLen
+ 1);
115 UnicodeStrToAsciiStr(SerialNumber
, OptionalStrStart
+ ManuStrLen
+ 1 + VerStrLen
+ 1);
116 UnicodeStrToAsciiStr(AssertTag
, OptionalStrStart
+ ManuStrLen
+ 1 + VerStrLen
+ 1 + SerialNumStrLen
+ 1);
119 // Now we have got the full smbios record, call smbios protocol to add this record.
121 Status
= AddSmbiosRecord (Smbios
, &SmbiosHandle
, (EFI_SMBIOS_TABLE_HEADER
*) SmbiosRecord
);
123 FreePool(SmbiosRecord
);