]> git.proxmox.com Git - mirror_edk2.git/blob - Nt32Pkg/MiscSubClassPlatformDxe/MiscPortInternalConnectorDesignatorFunction.c
Enable MiscSubclassDriver.inf in Nt32Pkg
[mirror_edk2.git] / Nt32Pkg / MiscSubClassPlatformDxe / MiscPortInternalConnectorDesignatorFunction.c
1 /*++
2
3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13
14 MiscPortInternalConnectorDesignatorFunction.c
15
16 Abstract:
17
18 This driver parses the mMiscSubclassDataTable structure and reports
19 any generated data to the DataHub.
20
21 --*/
22
23 //
24 // Include common header file for this module.
25 //
26 #include "CommonHeader.h"
27
28 #include "MiscSubclassDriver.h"
29
30 //
31 //
32 //
33 MISC_SUBCLASS_TABLE_FUNCTION (
34 MiscPortInternalConnectorDesignator
35 )
36 /*++
37 Description:
38
39 This function makes boot time changes to the contents of the
40 MiscPortConnectorInformation (Type 8).
41
42 Parameters:
43
44 RecordType
45 Type of record to be processed from the Data Table.
46 mMiscSubclassDataTable[].RecordType
47
48 RecordLen
49 Size of static RecordData from the Data Table.
50 mMiscSubclassDataTable[].RecordLen
51
52 RecordData
53 Pointer to copy of RecordData from the Data Table. Changes made
54 to this copy will be written to the Data Hub but will not alter
55 the contents of the static Data Table.
56
57 LogRecordData
58 Set *LogRecordData to TRUE to log RecordData to Data Hub.
59 Set *LogRecordData to FALSE when there is no more data to log.
60
61 Returns:
62
63 EFI_SUCCESS
64 All parameters were valid and *RecordData and *LogRecordData have
65 been set.
66
67 EFI_UNSUPPORTED
68 Unexpected RecordType value.
69
70 EFI_INVALID_PARAMETER
71 One of the following parameter conditions was true:
72 RecordLen was zero.
73 RecordData was NULL.
74 LogRecordData was NULL.
75 --*/
76 {
77 STATIC BOOLEAN Done = FALSE;
78 STATIC PS2_CONN_DEVICE_PATH mPs2KeyboardDevicePath = { DP_ACPI, DP_PCI (0x1F, 0x00), DP_LPC (0x0303, 0), DP_END };
79 STATIC PS2_CONN_DEVICE_PATH mPs2MouseDevicePath = { DP_ACPI, DP_PCI (0x1F, 0x00), DP_LPC (0x0303, 1), DP_END };
80 STATIC SERIAL_CONN_DEVICE_PATH mCom1DevicePath = { DP_ACPI, DP_PCI (0x1F, 0x00), DP_LPC (0x0501, 0), DP_END };
81 STATIC SERIAL_CONN_DEVICE_PATH mCom2DevicePath = { DP_ACPI, DP_PCI (0x1F, 0x00), DP_LPC (0x0501, 1), DP_END };
82 STATIC PARALLEL_CONN_DEVICE_PATH mLpt1DevicePath = { DP_ACPI, DP_PCI (0x1F, 0x00), DP_LPC (0x0401, 0), DP_END };
83 STATIC FLOOPY_CONN_DEVICE_PATH mFloopyADevicePath = { DP_ACPI, DP_PCI (0x1F, 0x00), DP_LPC (0x0604, 0), DP_END };
84 STATIC FLOOPY_CONN_DEVICE_PATH mFloopyBDevicePath = { DP_ACPI, DP_PCI (0x1F, 0x00), DP_LPC (0x0604, 1), DP_END };
85 STATIC USB_PORT_DEVICE_PATH mUsb0DevicePath = { DP_ACPI, DP_PCI (0x1d, 0x00), DP_END };
86 STATIC USB_PORT_DEVICE_PATH mUsb1DevicePath = { DP_ACPI, DP_PCI (0x1d, 0x01), DP_END };
87 STATIC USB_PORT_DEVICE_PATH mUsb2DevicePath = { DP_ACPI, DP_PCI (0x1d, 0x02), DP_END };
88 STATIC USB_PORT_DEVICE_PATH mUsb3DevicePath = { DP_ACPI, DP_PCI (0x1d, 0x07), DP_END };
89 STATIC IDE_DEVICE_PATH mIdeDevicePath = { DP_ACPI, DP_PCI (0x1F, 0x01), DP_END };
90 STATIC GB_NIC_DEVICE_PATH mGbNicDevicePath = { DP_ACPI, DP_PCI( 0x03,0x00 ),DP_PCI( 0x1F,0x00 ),DP_PCI( 0x07,0x00 ), DP_END };
91 EFI_DEVICE_PATH_PROTOCOL EndDevicePath = DP_END;
92
93 //
94 // First check for invalid parameters.
95 //
96 // Shanmu >> to fix the Device Path Issue...
97 // if (RecordLen == 0 || RecordData == NULL || LogRecordData == NULL) {
98 //
99 if (*RecordLen == 0 || RecordData == NULL || LogRecordData == NULL) {
100 //
101 // End Shanmu
102 //
103 return EFI_INVALID_PARAMETER;
104 }
105 //
106 // Then check for unsupported RecordType.
107 //
108 if (RecordType != EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_RECORD_NUMBER) {
109 return EFI_UNSUPPORTED;
110 }
111 //
112 // Is this the first time through this function?
113 //
114 if (!Done) {
115 //
116 // Yes, this is the first time. Inspect/Change the contents of the
117 // RecordData structure.
118 //
119 //
120 // Device path is only updated here as it was not taking that in static data
121 //
122 // Shanmu >> to fix the Device Path Issue...
123 //
124
125 /*
126 switch (((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortInternalConnectorDesignator)
127 {
128 case STR_MISC_PORT_INTERNAL_MOUSE:
129 {
130 (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mPs2MouseDevicePath);
131 }break;
132 case STR_MISC_PORT_INTERNAL_KEYBOARD:
133 {
134 (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mPs2KeyboardDevicePath);
135 }break;
136 case STR_MISC_PORT_INTERNAL_COM1:
137 {
138 (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mCom1DevicePath);
139 }break;
140 case STR_MISC_PORT_INTERNAL_COM2:
141 {
142 (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mCom2DevicePath);
143 }break;
144 case STR_MISC_PORT_INTERNAL_LPT1:
145 {
146 (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mLpt1DevicePath);
147 }break;
148 case STR_MISC_PORT_INTERNAL_USB1:
149 {
150 (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mUsb0DevicePath);
151 }break;
152 case STR_MISC_PORT_INTERNAL_USB2:
153 {
154 (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mUsb1DevicePath);
155 }break;
156 case STR_MISC_PORT_INTERNAL_USB3:
157 {
158 (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mUsb2DevicePath);
159 }break;
160 case STR_MISC_PORT_INTERNAL_NETWORK:
161 {
162 (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mGbNicDevicePath);
163 }break;
164 case STR_MISC_PORT_INTERNAL_FLOPPY:
165 {
166 (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mFloopyADevicePath);
167 }break;
168 case STR_MISC_PORT_INTERNAL_IDE1:
169 {
170 (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mIdeDevicePath);
171 }break;
172 case STR_MISC_PORT_INTERNAL_IDE2:
173 {
174 (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mIdeDevicePath);
175 }break;
176 default:
177 {
178 (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = EndDevicePath;
179 }break;
180 }
181 */
182 switch (((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *) RecordData)->PortInternalConnectorDesignator) {
183 case STR_MISC_PORT_INTERNAL_MOUSE:
184 {
185 CopyMem (
186 &((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *) RecordData)->PortPath,
187 &mPs2MouseDevicePath,
188 GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &mPs2MouseDevicePath)
189 );
190 *RecordLen = *RecordLen - sizeof (EFI_MISC_PORT_DEVICE_PATH) + GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &mPs2MouseDevicePath);
191 }
192 break;
193
194 case STR_MISC_PORT_INTERNAL_KEYBOARD:
195 {
196 CopyMem (
197 &((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *) RecordData)->PortPath,
198 &mPs2KeyboardDevicePath,
199 GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &mPs2KeyboardDevicePath)
200 );
201 *RecordLen = *RecordLen - sizeof (EFI_MISC_PORT_DEVICE_PATH) + GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &mPs2KeyboardDevicePath);
202 }
203 break;
204
205 case STR_MISC_PORT_INTERNAL_COM1:
206 {
207 CopyMem (
208 &((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *) RecordData)->PortPath,
209 &mCom1DevicePath,
210 GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &mCom1DevicePath)
211 );
212 *RecordLen = *RecordLen - sizeof (EFI_MISC_PORT_DEVICE_PATH) + GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &mCom1DevicePath);
213 }
214 break;
215
216 case STR_MISC_PORT_INTERNAL_COM2:
217 {
218 CopyMem (
219 &((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *) RecordData)->PortPath,
220 &mCom2DevicePath,
221 GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &mCom2DevicePath)
222 );
223 *RecordLen = *RecordLen - sizeof (EFI_MISC_PORT_DEVICE_PATH) + GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &mCom2DevicePath);
224 }
225 break;
226
227 case STR_MISC_PORT_INTERNAL_FLOPPY:
228 {
229 CopyMem (
230 &((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *) RecordData)->PortPath,
231 &mFloopyADevicePath,
232 GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &mFloopyADevicePath)
233 );
234 *RecordLen = *RecordLen - sizeof (EFI_MISC_PORT_DEVICE_PATH) + GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &mFloopyADevicePath);
235 }
236 break;
237
238 default:
239 {
240 CopyMem (
241 &((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *) RecordData)->PortPath,
242 &EndDevicePath,
243 GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &EndDevicePath)
244 );
245 *RecordLen = *RecordLen - sizeof (EFI_MISC_PORT_DEVICE_PATH) + GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &EndDevicePath);
246 }
247 break;
248 }
249 //
250 // End Shanmu
251 //
252 // Set Done flag to TRUE for next pass through this function.
253 // Set *LogRecordData to TRUE so data will get logged to Data Hub.
254 //
255 Done = TRUE;
256 *LogRecordData = TRUE;
257 } else {
258 //
259 // No, this is the second time. Reset the state of the Done flag
260 // to FALSE and tell the data logger that there is no more data
261 // to be logged for this record type. If any memory allocations
262 // were made by earlier passes, they must be released now.
263 //
264 Done = FALSE;
265 *LogRecordData = FALSE;
266 }
267
268 return EFI_SUCCESS;
269 }
270
271 /* eof - MiscSystemManufacturerFunction.c */