1 /*++ 2 3 Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR> 4 5 6 This program and the accompanying materials are licensed and made available under 7 8 the terms and conditions of the BSD License that accompanies this distribution. 9 10 The full text of the license may be found at 11 12 http://opensource.org/licenses/bsd-license.php. 13 14 15 16 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 17 18 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 19 20 21 22 23 24 Module Name: 25 26 MiscChassisManufacturerFunction.c 27 28 Abstract: 29 30 Chassis manufacturer information boot time changes. 31 SMBIOS type 3. 32 33 --*/ 34 35 36 #include "CommonHeader.h" 37 #include "MiscSubclassDriver.h" 38 #include <Guid/PlatformInfo.h> 39 40 41 extern EFI_PLATFORM_INFO_HOB *mPlatformInfo; 42 43 /** 44 This function makes boot time changes to the contents of the MISC_SMBIOS_TABLE_FUNCTION(MiscChassisManufacturer)45 MiscChassisManufacturer (Type 3). 46 47 @param RecordData Pointer to copy of RecordData from the Data Table. 48 49 @retval EFI_SUCCESS All parameters were valid. 50 @retval EFI_UNSUPPORTED Unexpected RecordType value. 51 @retval EFI_INVALID_PARAMETER Invalid parameter was found. 52 53 **/ 54 MISC_SMBIOS_TABLE_FUNCTION(MiscChassisManufacturer) 55 { 56 CHAR8 *OptionalStrStart; 57 UINTN ManuStrLen; 58 UINTN VerStrLen; 59 UINTN AssertTagStrLen; 60 UINTN SerialNumStrLen; 61 EFI_STATUS Status; 62 EFI_STRING Manufacturer; 63 EFI_STRING Version; 64 EFI_STRING SerialNumber; 65 EFI_STRING AssertTag; 66 STRING_REF TokenToGet; 67 EFI_SMBIOS_HANDLE SmbiosHandle; 68 SMBIOS_TABLE_TYPE3 *SmbiosRecord; 69 EFI_MISC_CHASSIS_MANUFACTURER *ForType3InputData; 70 CHAR16 Buffer[40]; 71 72 ForType3InputData = (EFI_MISC_CHASSIS_MANUFACTURER *)RecordData; 73 74 // 75 // First check for invalid parameters. 76 // 77 if (RecordData == NULL || mPlatformInfo == NULL) { 78 return EFI_INVALID_PARAMETER; 79 } 80 81 if (BOARD_ID_MINNOW2_TURBOT == mPlatformInfo->BoardId) { 82 UnicodeSPrint (Buffer, sizeof (Buffer),L"ADI"); 83 HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_CHASSIS_MANUFACTURER), Buffer, NULL); 84 } 85 TokenToGet = STRING_TOKEN (STR_MISC_CHASSIS_MANUFACTURER); 86 Manufacturer = SmbiosMiscGetString (TokenToGet); 87 ManuStrLen = StrLen(Manufacturer); 88 if (ManuStrLen > SMBIOS_STRING_MAX_LENGTH) { 89 return EFI_UNSUPPORTED; 90 } 91 92 TokenToGet = STRING_TOKEN (STR_MISC_CHASSIS_VERSION); 93 Version = SmbiosMiscGetString (TokenToGet); 94 VerStrLen = StrLen(Version); 95 if (VerStrLen > SMBIOS_STRING_MAX_LENGTH) { 96 return EFI_UNSUPPORTED; 97 } 98 99 TokenToGet = STRING_TOKEN (STR_MISC_CHASSIS_SERIAL_NUMBER); 100 SerialNumber = SmbiosMiscGetString (TokenToGet); 101 SerialNumStrLen = StrLen(SerialNumber); 102 if (SerialNumStrLen > SMBIOS_STRING_MAX_LENGTH) { 103 return EFI_UNSUPPORTED; 104 } 105 106 TokenToGet = STRING_TOKEN (STR_MISC_CHASSIS_ASSET_TAG); 107 AssertTag = SmbiosMiscGetString (TokenToGet); 108 AssertTagStrLen = StrLen(AssertTag); 109 if (AssertTagStrLen > SMBIOS_STRING_MAX_LENGTH) { 110 return EFI_UNSUPPORTED; 111 } 112 113 // 114 // Two zeros following the last string. 115 // 116 SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE3) + ManuStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1 + 1); 117 ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE3) + ManuStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1 + 1); 118 119 SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_SYSTEM_ENCLOSURE; 120 SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE3); 121 122 // 123 // Make handle chosen by smbios protocol.add automatically. 124 // 125 SmbiosRecord->Hdr.Handle = 0; 126 127 // 128 // Manu will be the 1st optional string following the formatted structure. 129 // 130 SmbiosRecord->Manufacturer = 1; 131 SmbiosRecord->Type = (UINT8)ForType3InputData->ChassisType.ChassisType; 132 133 // 134 // Version will be the 2nd optional string following the formatted structure. 135 // 136 SmbiosRecord->Version = 2; 137 138 // 139 // SerialNumber will be the 3rd optional string following the formatted structure. 140 // 141 SmbiosRecord->SerialNumber = 3; 142 143 // 144 // AssertTag will be the 4th optional string following the formatted structure. 145 // 146 SmbiosRecord->AssetTag = 4; 147 SmbiosRecord->BootupState = (UINT8)ForType3InputData->ChassisBootupState; 148 SmbiosRecord->PowerSupplyState = (UINT8)ForType3InputData->ChassisPowerSupplyState; 149 SmbiosRecord->ThermalState = (UINT8)ForType3InputData->ChassisThermalState; 150 SmbiosRecord->SecurityStatus = (UINT8)ForType3InputData->ChassisSecurityState; 151 CopyMem (SmbiosRecord->OemDefined,(UINT8*)&ForType3InputData->ChassisOemDefined, 4); 152 153 OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1); 154 UnicodeStrToAsciiStr(Manufacturer, OptionalStrStart); 155 UnicodeStrToAsciiStr(Version, OptionalStrStart + ManuStrLen + 1); 156 UnicodeStrToAsciiStr(SerialNumber, OptionalStrStart + ManuStrLen + 1 + VerStrLen + 1); 157 UnicodeStrToAsciiStr(AssertTag, OptionalStrStart + ManuStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1); 158 159 // 160 // Now we have got the full smbios record, call smbios protocol to add this record. 161 // 162 SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED; 163 Status = Smbios-> Add( 164 Smbios, 165 NULL, 166 &SmbiosHandle, 167 (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord 168 ); 169 170 FreePool(SmbiosRecord); 171 return Status; 172 } 173