]> git.proxmox.com Git - mirror_edk2.git/blob - Nt32Pkg/MiscSubClassPlatformDxe/MiscChassisManufacturerFunction.c
EmulatorPkg/Unix GCC: Link to libdl
[mirror_edk2.git] / Nt32Pkg / MiscSubClassPlatformDxe / MiscChassisManufacturerFunction.c
1 /** @file
2 Chassis manufacturer information boot time changes.
3 SMBIOS type 3.
4
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
10
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.
13
14 **/
15
16 #include "MiscSubclassDriver.h"
17
18 /**
19 This function makes boot time changes to the contents of the
20 MiscChassisManufacturer (Type 3).
21
22 @param RecordData Pointer to copy of RecordData from the Data Table.
23
24 @retval EFI_SUCCESS All parameters were valid.
25 @retval EFI_UNSUPPORTED Unexpected RecordType value.
26 @retval EFI_INVALID_PARAMETER Invalid parameter was found.
27
28 **/
29 MISC_SMBIOS_TABLE_FUNCTION(MiscChassisManufacturer)
30 {
31 CHAR8 *OptionalStrStart;
32 UINTN ManuStrLen;
33 UINTN VerStrLen;
34 UINTN AssertTagStrLen;
35 UINTN SerialNumStrLen;
36 EFI_STATUS Status;
37 EFI_STRING Manufacturer;
38 EFI_STRING Version;
39 EFI_STRING SerialNumber;
40 EFI_STRING AssertTag;
41 STRING_REF TokenToGet;
42 EFI_SMBIOS_HANDLE SmbiosHandle;
43 SMBIOS_TABLE_TYPE3 *SmbiosRecord;
44 EFI_MISC_CHASSIS_MANUFACTURER *ForType3InputData;
45
46 ForType3InputData = (EFI_MISC_CHASSIS_MANUFACTURER *)RecordData;
47
48 //
49 // First check for invalid parameters.
50 //
51 if (RecordData == NULL) {
52 return EFI_INVALID_PARAMETER;
53 }
54
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;
60 }
61
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;
67 }
68
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;
74 }
75
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;
81 }
82
83 //
84 // Two zeros following the last string.
85 //
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);
88
89 SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_SYSTEM_ENCLOSURE;
90 SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE3);
91 //
92 // Make handle chosen by smbios protocol.add automatically.
93 //
94 SmbiosRecord->Hdr.Handle = 0;
95 //
96 // Manu will be the 1st optional string following the formatted structure.
97 //
98 SmbiosRecord->Manufacturer = 1;
99 SmbiosRecord->Type = (UINT8)ForType3InputData->ChassisType.ChassisType;
100 //
101 // Version will be the 2nd optional string following the formatted structure.
102 //
103 SmbiosRecord->Version = 2;
104 //
105 // SerialNumber will be the 3rd optional string following the formatted structure.
106 //
107 SmbiosRecord->SerialNumber = 3;
108 //
109 // AssertTag will be the 4th optional string following the formatted structure.
110 //
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);
117
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);
123
124 //
125 // Now we have got the full smbios record, call smbios protocol to add this record.
126 //
127 Status = AddSmbiosRecord (Smbios, &SmbiosHandle, (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord);
128
129 FreePool(SmbiosRecord);
130 return Status;
131 }