2 Chassis manufacturer information boot time changes.
5 Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include "MiscSubClassDriver.h"
19 This function makes boot time changes to the contents of the
20 MiscChassisManufacturer (Type 3).
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(MiscChassisManufacturer
)
31 CHAR8
*OptionalStrStart
;
34 UINTN AssertTagStrLen
;
35 UINTN SerialNumStrLen
;
37 EFI_STRING Manufacturer
;
39 EFI_STRING SerialNumber
;
41 STRING_REF TokenToGet
;
42 EFI_SMBIOS_HANDLE SmbiosHandle
;
43 SMBIOS_TABLE_TYPE3
*SmbiosRecord
;
44 EFI_MISC_CHASSIS_MANUFACTURER
*ForType3InputData
;
46 ForType3InputData
= (EFI_MISC_CHASSIS_MANUFACTURER
*)RecordData
;
49 // First check for invalid parameters.
51 if (RecordData
== NULL
) {
52 return EFI_INVALID_PARAMETER
;
55 TokenToGet
= STRING_TOKEN (STR_MISC_CHASSIS_MANUFACTURER
);
56 Manufacturer
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
57 ManuStrLen
= StrLen(Manufacturer
);
58 if (ManuStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
59 return EFI_UNSUPPORTED
;
62 TokenToGet
= STRING_TOKEN (STR_MISC_CHASSIS_VERSION
);
63 Version
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
64 VerStrLen
= StrLen(Version
);
65 if (VerStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
66 return EFI_UNSUPPORTED
;
69 TokenToGet
= STRING_TOKEN (STR_MISC_CHASSIS_SERIAL_NUMBER
);
70 SerialNumber
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
71 SerialNumStrLen
= StrLen(SerialNumber
);
72 if (SerialNumStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
73 return EFI_UNSUPPORTED
;
76 TokenToGet
= STRING_TOKEN (STR_MISC_CHASSIS_ASSET_TAG
);
77 AssertTag
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
78 AssertTagStrLen
= StrLen(AssertTag
);
79 if (AssertTagStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
80 return EFI_UNSUPPORTED
;
84 // Two zeros following the last string.
86 SmbiosRecord
= AllocatePool(sizeof (SMBIOS_TABLE_TYPE3
) + ManuStrLen
+ 1 + VerStrLen
+ 1 + SerialNumStrLen
+ 1 + AssertTagStrLen
+ 1 + 1);
87 ZeroMem(SmbiosRecord
, sizeof (SMBIOS_TABLE_TYPE3
) + ManuStrLen
+ 1 + VerStrLen
+ 1 + SerialNumStrLen
+ 1 + AssertTagStrLen
+ 1 + 1);
89 SmbiosRecord
->Hdr
.Type
= EFI_SMBIOS_TYPE_SYSTEM_ENCLOSURE
;
90 SmbiosRecord
->Hdr
.Length
= sizeof (SMBIOS_TABLE_TYPE3
);
92 // Make handle chosen by smbios protocol.add automatically.
94 SmbiosRecord
->Hdr
.Handle
= 0;
96 // Manu will be the 1st optional string following the formatted structure.
98 SmbiosRecord
->Manufacturer
= 1;
99 SmbiosRecord
->Type
= (UINT8
)ForType3InputData
->ChassisType
.ChassisType
;
101 // Version will be the 2nd optional string following the formatted structure.
103 SmbiosRecord
->Version
= 2;
105 // SerialNumber will be the 3rd optional string following the formatted structure.
107 SmbiosRecord
->SerialNumber
= 3;
109 // AssertTag will be the 4th optional string following the formatted structure.
111 SmbiosRecord
->AssetTag
= 4;
112 SmbiosRecord
->BootupState
= (UINT8
)ForType3InputData
->ChassisBootupState
;
113 SmbiosRecord
->PowerSupplyState
= (UINT8
)ForType3InputData
->ChassisPowerSupplyState
;
114 SmbiosRecord
->ThermalState
= (UINT8
)ForType3InputData
->ChassisThermalState
;
115 SmbiosRecord
->SecurityStatus
= (UINT8
)ForType3InputData
->ChassisSecurityState
;
116 CopyMem (SmbiosRecord
->OemDefined
,(UINT8
*)&ForType3InputData
->ChassisOemDefined
, 4);
118 OptionalStrStart
= (CHAR8
*)(SmbiosRecord
+ 1);
119 UnicodeStrToAsciiStr(Manufacturer
, OptionalStrStart
);
120 UnicodeStrToAsciiStr(Version
, OptionalStrStart
+ ManuStrLen
+ 1);
121 UnicodeStrToAsciiStr(SerialNumber
, OptionalStrStart
+ ManuStrLen
+ 1 + VerStrLen
+ 1);
122 UnicodeStrToAsciiStr(AssertTag
, OptionalStrStart
+ ManuStrLen
+ 1 + VerStrLen
+ 1 + SerialNumStrLen
+ 1);
125 // Now we have got the full smbios record, call smbios protocol to add this record.
127 Status
= AddSmbiosRecord (Smbios
, &SmbiosHandle
, (EFI_SMBIOS_TABLE_HEADER
*) SmbiosRecord
);
129 FreePool(SmbiosRecord
);