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