]> git.proxmox.com Git - mirror_edk2.git/blame - EmulatorPkg/MiscSubClassPlatformDxe/MiscPortInternalConnectorDesignatorFunction.c
StdLib/LibC/StdLib/Malloc.c: Make the free() function conform to the ISO/IEC 9899...
[mirror_edk2.git] / EmulatorPkg / MiscSubClassPlatformDxe / MiscPortInternalConnectorDesignatorFunction.c
CommitLineData
949f388f 1/*++\r
d18d8a1d 2\r
2bfd90f9 3Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
d18d8a1d 4This program and the accompanying materials\r
5are licensed and made available under the terms and conditions of the BSD License\r
6which accompanies this distribution. The full text of the license may be found at\r
7http://opensource.org/licenses/bsd-license.php\r
8\r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
949f388f 11\r
12Module Name:\r
13\r
14 MiscPortInternalConnectorDesignatorFunction.c\r
d18d8a1d 15\r
16Abstract:\r
949f388f 17\r
18 This driver parses the mMiscSubclassDataTable structure and reports\r
19 any generated data to the DataHub.\r
20\r
21**/\r
22\r
23#include "MiscSubClassDriver.h"\r
24\r
25\r
26MISC_SMBIOS_TABLE_FUNCTION (\r
27 MiscPortInternalConnectorDesignator\r
28 )\r
29/*++\r
30Description:\r
31\r
32 This function makes boot time changes to the contents of the\r
33 MiscPortConnectorInformation (Type 8).\r
34\r
35Parameters:\r
36\r
37 RecordType\r
38 Type of record to be processed from the Data Table.\r
39 mMiscSubclassDataTable[].RecordType\r
40\r
41 RecordLen\r
42 Size of static RecordData from the Data Table.\r
43 mMiscSubclassDataTable[].RecordLen\r
44\r
45 RecordData\r
46 Pointer to copy of RecordData from the Data Table. Changes made\r
47 to this copy will be written to the Data Hub but will not alter\r
48 the contents of the static Data Table.\r
49\r
50 LogRecordData\r
51 Set *LogRecordData to TRUE to log RecordData to Data Hub.\r
52 Set *LogRecordData to FALSE when there is no more data to log.\r
53\r
54Returns:\r
55\r
56 EFI_SUCCESS\r
57 All parameters were valid and *RecordData and *LogRecordData have\r
58 been set.\r
59\r
60 EFI_UNSUPPORTED\r
61 Unexpected RecordType value.\r
62\r
63 EFI_INVALID_PARAMETER\r
64 One of the following parameter conditions was true:\r
65 RecordLen was zero.\r
66 RecordData was NULL.\r
67 LogRecordData was NULL.\r
68**/\r
69{\r
70 CHAR8 *OptionalStrStart;\r
71 UINTN InternalRefStrLen;\r
d18d8a1d 72 UINTN ExternalRefStrLen;\r
949f388f 73 EFI_STRING InternalRef;\r
74 EFI_STRING ExternalRef;\r
75 STRING_REF TokenForInternal;\r
76 STRING_REF TokenForExternal;\r
77 EFI_STATUS Status;\r
78 SMBIOS_TABLE_TYPE8 *SmbiosRecord;\r
79 EFI_SMBIOS_HANDLE SmbiosHandle;\r
80 EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR *ForType8InputData;\r
d18d8a1d 81\r
949f388f 82 ForType8InputData = (EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR *)RecordData;\r
83 //\r
84 // First check for invalid parameters.\r
85 //\r
86 if (RecordData == NULL) {\r
87 return EFI_INVALID_PARAMETER;\r
88 }\r
89\r
90 TokenForInternal = 0;\r
91 TokenForExternal = 0;\r
d18d8a1d 92\r
93 switch (ForType8InputData->PortInternalConnectorDesignator) {\r
949f388f 94\r
95 case STR_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR:\r
96 TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR);\r
97 TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_CONNECTOR_DESIGNATOR);\r
98 break;\r
99 case STR_MISC_PORT_INTERNAL_KEYBOARD:\r
100 TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_KEYBOARD);\r
101 TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_KEYBOARD);\r
102 break;\r
103 case STR_MISC_PORT_INTERNAL_MOUSE:\r
104 TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_MOUSE);\r
105 TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_MOUSE);\r
106 break;\r
107 case STR_MISC_PORT_INTERNAL_COM1:\r
108 TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_COM1);\r
109 TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_COM1);\r
110 break;\r
111 case STR_MISC_PORT_INTERNAL_COM2:\r
112 TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_COM2);\r
113 TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_COM2);\r
114 break;\r
115 case STR_MISC_PORT_INTERNAL_EXTENSION_POWER:\r
116 TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_EXTENSION_POWER);\r
117 TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_EXTENSION_POWER);\r
118 break;\r
119 case STR_MISC_PORT_INTERNAL_FLOPPY:\r
120 TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_FLOPPY);\r
121 TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_FLOPPY);\r
122 break;\r
123 default:\r
124 break;\r
125 }\r
126\r
127 InternalRef = HiiGetPackageString(&gEfiCallerIdGuid, TokenForInternal, NULL);\r
128 InternalRefStrLen = StrLen(InternalRef);\r
129 if (InternalRefStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
130 return EFI_UNSUPPORTED;\r
131 }\r
132\r
133 ExternalRef = HiiGetPackageString(&gEfiCallerIdGuid, TokenForExternal, NULL);\r
134 ExternalRefStrLen = StrLen(ExternalRef);\r
135 if (ExternalRefStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
136 return EFI_UNSUPPORTED;\r
137 }\r
138\r
139 //\r
140 // Two zeros following the last string.\r
141 //\r
142 SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE8) + InternalRefStrLen + 1 + ExternalRefStrLen + 1 + 1);\r
143 ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE8) + InternalRefStrLen + 1 + ExternalRefStrLen + 1 + 1);\r
144\r
145 SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_PORT_CONNECTOR_INFORMATION;\r
146 SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE8);\r
147 //\r
148 // Make handle chosen by smbios protocol.add automatically.\r
149 //\r
d18d8a1d 150 SmbiosRecord->Hdr.Handle = 0;\r
949f388f 151 SmbiosRecord->InternalReferenceDesignator = 1;\r
152 SmbiosRecord->InternalConnectorType = (UINT8)ForType8InputData->PortInternalConnectorType;\r
153 SmbiosRecord->ExternalReferenceDesignator = 2;\r
154 SmbiosRecord->ExternalConnectorType = (UINT8)ForType8InputData->PortExternalConnectorType;\r
155 SmbiosRecord->PortType = (UINT8)ForType8InputData->PortType;\r
d18d8a1d 156\r
949f388f 157 OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);\r
158 UnicodeStrToAsciiStr(InternalRef, OptionalStrStart);\r
159 UnicodeStrToAsciiStr(ExternalRef, OptionalStrStart + InternalRefStrLen + 1);\r
160\r
161 //\r
162 // Now we have got the full smbios record, call smbios protocol to add this record.\r
163 //\r
2bfd90f9
SZ
164 Status = AddSmbiosRecord (Smbios, &SmbiosHandle, (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord);\r
165\r
949f388f 166 FreePool(SmbiosRecord);\r
167 return Status;\r
168}\r
169\r
170\r
171\r
172/* eof - MiscSystemManufacturerFunction.c */\r