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