3 Copyright (c) 2009, Intel Corporation. All rights reserved. <BR>
4 This software and associated documentation (if any) is furnished
5 under a license and may only be used or copied in accordance
6 with the terms of the license. Except as permitted by such
7 license, no part of this software or documentation may be
8 reproduced, stored in a retrieval system, or transmitted in any
9 form or by any means without the express written consent of
15 MiscChassisManufacturerFunction.c
19 Chassis manufacturer information boot time changes.
24 #include "MiscSubclassDriver.h"
27 This function makes boot time changes to the contents of the
28 MiscChassisManufacturer (Type 3).
30 @param RecordData Pointer to copy of RecordData from the Data Table.
32 @retval EFI_SUCCESS All parameters were valid.
33 @retval EFI_UNSUPPORTED Unexpected RecordType value.
34 @retval EFI_INVALID_PARAMETER Invalid parameter was found.
37 MISC_SMBIOS_TABLE_FUNCTION(MiscChassisManufacturer
)
39 CHAR8
*OptionalStrStart
;
42 UINTN AssertTagStrLen
;
43 UINTN SerialNumStrLen
;
45 EFI_STRING Manufacturer
;
47 EFI_STRING SerialNumber
;
49 STRING_REF TokenToGet
;
50 EFI_SMBIOS_HANDLE SmbiosHandle
;
51 SMBIOS_TABLE_TYPE3
*SmbiosRecord
;
52 EFI_MISC_CHASSIS_MANUFACTURER
*ForType3InputData
;
54 ForType3InputData
= (EFI_MISC_CHASSIS_MANUFACTURER
*)RecordData
;
57 // First check for invalid parameters.
59 if (RecordData
== NULL
) {
60 return EFI_INVALID_PARAMETER
;
63 TokenToGet
= STRING_TOKEN (STR_MISC_CHASSIS_MANUFACTURER
);
64 Manufacturer
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
65 ManuStrLen
= StrLen(Manufacturer
);
66 if (ManuStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
67 return EFI_UNSUPPORTED
;
70 TokenToGet
= STRING_TOKEN (STR_MISC_CHASSIS_VERSION
);
71 Version
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
72 VerStrLen
= StrLen(Version
);
73 if (VerStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
74 return EFI_UNSUPPORTED
;
77 TokenToGet
= STRING_TOKEN (STR_MISC_CHASSIS_SERIAL_NUMBER
);
78 SerialNumber
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
79 SerialNumStrLen
= StrLen(SerialNumber
);
80 if (SerialNumStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
81 return EFI_UNSUPPORTED
;
84 TokenToGet
= STRING_TOKEN (STR_MISC_CHASSIS_ASSET_TAG
);
85 AssertTag
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
86 AssertTagStrLen
= StrLen(AssertTag
);
87 if (AssertTagStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
88 return EFI_UNSUPPORTED
;
92 // Two zeros following the last string.
94 SmbiosRecord
= AllocatePool(sizeof (SMBIOS_TABLE_TYPE3
) + ManuStrLen
+ 1 + VerStrLen
+ 1 + SerialNumStrLen
+ 1 + AssertTagStrLen
+ 1 + 1);
95 ZeroMem(SmbiosRecord
, sizeof (SMBIOS_TABLE_TYPE3
) + ManuStrLen
+ 1 + VerStrLen
+ 1 + SerialNumStrLen
+ 1 + AssertTagStrLen
+ 1 + 1);
97 SmbiosRecord
->Hdr
.Type
= EFI_SMBIOS_TYPE_SYSTEM_ENCLOSURE
;
98 SmbiosRecord
->Hdr
.Length
= sizeof (SMBIOS_TABLE_TYPE3
);
100 // Make handle chosen by smbios protocol.add automatically.
102 SmbiosRecord
->Hdr
.Handle
= 0;
104 // Manu will be the 1st optional string following the formatted structure.
106 SmbiosRecord
->Manufacturer
= 1;
107 SmbiosRecord
->Type
= (UINT8
)ForType3InputData
->ChassisType
.ChassisType
;
109 // Version will be the 2nd optional string following the formatted structure.
111 SmbiosRecord
->Version
= 2;
113 // SerialNumber will be the 3rd optional string following the formatted structure.
115 SmbiosRecord
->SerialNumber
= 3;
117 // AssertTag will be the 4th optional string following the formatted structure.
119 SmbiosRecord
->AssetTag
= 4;
120 SmbiosRecord
->BootupState
= (UINT8
)ForType3InputData
->ChassisBootupState
;
121 SmbiosRecord
->PowerSupplyState
= (UINT8
)ForType3InputData
->ChassisPowerSupplyState
;
122 SmbiosRecord
->ThermalState
= (UINT8
)ForType3InputData
->ChassisThermalState
;
123 SmbiosRecord
->SecurityStatus
= (UINT8
)ForType3InputData
->ChassisSecurityState
;
124 CopyMem (SmbiosRecord
->OemDefined
,(UINT8
*)&ForType3InputData
->ChassisOemDefined
, 4);
126 OptionalStrStart
= (CHAR8
*)(SmbiosRecord
+ 1);
127 UnicodeStrToAsciiStr(Manufacturer
, OptionalStrStart
);
128 UnicodeStrToAsciiStr(Version
, OptionalStrStart
+ ManuStrLen
+ 1);
129 UnicodeStrToAsciiStr(SerialNumber
, OptionalStrStart
+ ManuStrLen
+ 1 + VerStrLen
+ 1);
130 UnicodeStrToAsciiStr(AssertTag
, OptionalStrStart
+ ManuStrLen
+ 1 + VerStrLen
+ 1 + SerialNumStrLen
+ 1);
133 // Now we have got the full smbios record, call smbios protocol to add this record.
136 Status
= Smbios
-> Add(
140 (EFI_SMBIOS_TABLE_HEADER
*) SmbiosRecord
143 FreePool(SmbiosRecord
);