summaryrefslogtreecommitdiff
path: root/Nt32Pkg/MiscSubClassPlatformDxe/MiscPortInternalConnectorDesignatorFunction.c
blob: 49d2c50f6a648711fb620d9f82e1b4590b211a27 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
/**@file
 
Copyright (c) 2006, Intel Corporation                                                         
All rights reserved. This program and the accompanying materials                          
are licensed and made available under the terms and conditions of the BSD License         
which accompanies this distribution.  The full text of the license may be found at        
http://opensource.org/licenses/bsd-license.php                                            
                                                                                          
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             

Module Name:

  MiscPortInternalConnectorDesignatorFunction.c
  
Abstract: 

  This driver parses the mMiscSubclassDataTable structure and reports
  any generated data to the DataHub.

**/

#include "MiscSubclassDriver.h"

BOOLEAN                    mDone                   = FALSE;
PS2_CONN_DEVICE_PATH       mPs2KeyboardDevicePath  = { DP_ACPI, DP_PCI (0x1F, 0x00), DP_LPC (0x0303, 0), DP_END };
PS2_CONN_DEVICE_PATH       mPs2MouseDevicePath     = { DP_ACPI, DP_PCI (0x1F, 0x00), DP_LPC (0x0303, 1), DP_END };
SERIAL_CONN_DEVICE_PATH    mCom1DevicePath         = { DP_ACPI, DP_PCI (0x1F, 0x00), DP_LPC (0x0501, 0), DP_END };
SERIAL_CONN_DEVICE_PATH    mCom2DevicePath         = { DP_ACPI, DP_PCI (0x1F, 0x00), DP_LPC (0x0501, 1), DP_END };
PARALLEL_CONN_DEVICE_PATH  mLpt1DevicePath         = { DP_ACPI, DP_PCI (0x1F, 0x00), DP_LPC (0x0401, 0), DP_END };
FLOOPY_CONN_DEVICE_PATH    mFloopyADevicePath      = { DP_ACPI, DP_PCI (0x1F, 0x00), DP_LPC (0x0604, 0), DP_END };
FLOOPY_CONN_DEVICE_PATH    mFloopyBDevicePath      = { DP_ACPI, DP_PCI (0x1F, 0x00), DP_LPC (0x0604, 1), DP_END };
USB_PORT_DEVICE_PATH       mUsb0DevicePath         = { DP_ACPI, DP_PCI (0x1d, 0x00), DP_END };
USB_PORT_DEVICE_PATH       mUsb1DevicePath         = { DP_ACPI, DP_PCI (0x1d, 0x01), DP_END };
USB_PORT_DEVICE_PATH       mUsb2DevicePath         = { DP_ACPI, DP_PCI (0x1d, 0x02), DP_END };
USB_PORT_DEVICE_PATH       mUsb3DevicePath         = { DP_ACPI, DP_PCI (0x1d, 0x07), DP_END };
IDE_DEVICE_PATH            mIdeDevicePath          = { DP_ACPI, DP_PCI (0x1F, 0x01), DP_END };
GB_NIC_DEVICE_PATH         mGbNicDevicePath        = { DP_ACPI, DP_PCI( 0x03,0x00 ),DP_PCI( 0x1F,0x00 ),DP_PCI( 0x07,0x00 ), DP_END };

//
//
//
MISC_SUBCLASS_TABLE_FUNCTION (
  MiscPortInternalConnectorDesignator
  )
/*++
Description:

  This function makes boot time changes to the contents of the
  MiscPortConnectorInformation (Type 8).

Parameters:

  RecordType
    Type of record to be processed from the Data Table.
    mMiscSubclassDataTable[].RecordType

  RecordLen
    Size of static RecordData from the Data Table.
    mMiscSubclassDataTable[].RecordLen

  RecordData
    Pointer to copy of RecordData from the Data Table.  Changes made
    to this copy will be written to the Data Hub but will not alter
    the contents of the static Data Table.

  LogRecordData
    Set *LogRecordData to TRUE to log RecordData to Data Hub.
    Set *LogRecordData to FALSE when there is no more data to log.

Returns:

  EFI_SUCCESS
    All parameters were valid and *RecordData and *LogRecordData have
    been set.

  EFI_UNSUPPORTED
    Unexpected RecordType value.

  EFI_INVALID_PARAMETER
    One of the following parameter conditions was true:
      RecordLen was zero.
      RecordData was NULL.
      LogRecordData was NULL.
--*/
{
  EFI_DEVICE_PATH_PROTOCOL          EndDevicePath           = DP_END;

  //
  // First check for invalid parameters.
  //
  // Shanmu >> to fix the Device Path Issue...
  // if (RecordLen == 0 || RecordData == NULL || LogRecordData == NULL) {
  //
  if (*RecordLen == 0 || RecordData == NULL || LogRecordData == NULL) {
    //
    // End Shanmu
    //
    return EFI_INVALID_PARAMETER;
  }
  //
  // Then check for unsupported RecordType.
  //
  if (RecordType != EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_RECORD_NUMBER) {
    return EFI_UNSUPPORTED;
  }
  //
  // Is this the first time through this function?
  //
  if (!mDone) {
    //
    // Yes, this is the first time.  Inspect/Change the contents of the
    // RecordData structure.
    //
    //
    // Device path is only updated here as it was not taking that in static data
    //
    // Shanmu >> to fix the Device Path Issue...
    //

    /*
    switch (((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortInternalConnectorDesignator) 
    {
      case STR_MISC_PORT_INTERNAL_MOUSE:
        {
          (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mPs2MouseDevicePath);          
        }break;
      case STR_MISC_PORT_INTERNAL_KEYBOARD:
        {
          (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mPs2KeyboardDevicePath);          
        }break;
      case STR_MISC_PORT_INTERNAL_COM1:
        {
          (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mCom1DevicePath);          
        }break;
      case STR_MISC_PORT_INTERNAL_COM2:
        {
          (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mCom2DevicePath);          
        }break;
      case STR_MISC_PORT_INTERNAL_LPT1:
        {
          (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mLpt1DevicePath);          
        }break;
      case STR_MISC_PORT_INTERNAL_USB1:
        {
          (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mUsb0DevicePath);          
        }break;
      case STR_MISC_PORT_INTERNAL_USB2:
        {
          (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mUsb1DevicePath);          
        }break;
      case STR_MISC_PORT_INTERNAL_USB3:
        {
          (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mUsb2DevicePath);          
        }break;
      case STR_MISC_PORT_INTERNAL_NETWORK:
        {
          (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mGbNicDevicePath);          
        }break;
      case STR_MISC_PORT_INTERNAL_FLOPPY:
        {
          (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mFloopyADevicePath);          
        }break;
      case STR_MISC_PORT_INTERNAL_IDE1:
        {
          (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mIdeDevicePath);          
        }break;
      case STR_MISC_PORT_INTERNAL_IDE2:
        {
          (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mIdeDevicePath);          
        }break;
      default:
        {
          (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = EndDevicePath;
        }break;    
    }
    */
    switch (((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *) RecordData)->PortInternalConnectorDesignator) {
    case STR_MISC_PORT_INTERNAL_MOUSE:
      {
        CopyMem (
          &((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *) RecordData)->PortPath,
          &mPs2MouseDevicePath,
          GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &mPs2MouseDevicePath)
          );
        *RecordLen = *RecordLen - sizeof (EFI_MISC_PORT_DEVICE_PATH) + GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &mPs2MouseDevicePath);
      }
      break;

    case STR_MISC_PORT_INTERNAL_KEYBOARD:
      {
        CopyMem (
          &((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *) RecordData)->PortPath,
          &mPs2KeyboardDevicePath,
          GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &mPs2KeyboardDevicePath)
          );
        *RecordLen = *RecordLen - sizeof (EFI_MISC_PORT_DEVICE_PATH) + GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &mPs2KeyboardDevicePath);
      }
      break;

    case STR_MISC_PORT_INTERNAL_COM1:
      {
        CopyMem (
          &((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *) RecordData)->PortPath,
          &mCom1DevicePath,
          GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &mCom1DevicePath)
          );
        *RecordLen = *RecordLen - sizeof (EFI_MISC_PORT_DEVICE_PATH) + GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &mCom1DevicePath);
      }
      break;

    case STR_MISC_PORT_INTERNAL_COM2:
      {
        CopyMem (
          &((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *) RecordData)->PortPath,
          &mCom2DevicePath,
          GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &mCom2DevicePath)
          );
        *RecordLen = *RecordLen - sizeof (EFI_MISC_PORT_DEVICE_PATH) + GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &mCom2DevicePath);
      }
      break;

    case STR_MISC_PORT_INTERNAL_FLOPPY:
      {
        CopyMem (
          &((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *) RecordData)->PortPath,
          &mFloopyADevicePath,
          GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &mFloopyADevicePath)
          );
        *RecordLen = *RecordLen - sizeof (EFI_MISC_PORT_DEVICE_PATH) + GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &mFloopyADevicePath);
      }
      break;

    default:
      {
        CopyMem (
          &((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *) RecordData)->PortPath,
          &EndDevicePath,
          GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &EndDevicePath)
          );
        *RecordLen = *RecordLen - sizeof (EFI_MISC_PORT_DEVICE_PATH) + GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &EndDevicePath);
      }
      break;
    }
    //
    // End Shanmu
    //
    // Set mDone flag to TRUE for next pass through this function.
    // Set *LogRecordData to TRUE so data will get logged to Data Hub.
    //
    mDone            = TRUE;
    *LogRecordData  = TRUE;
  } else {
    //
    // No, this is the second time.  Reset the state of the mDone flag
    // to FALSE and tell the data logger that there is no more data
    // to be logged for this record type.  If any memory allocations
    // were made by earlier passes, they must be released now.
    //
    mDone            = FALSE;
    *LogRecordData  = FALSE;
  }

  return EFI_SUCCESS;
}

/* eof - MiscSystemManufacturerFunction.c */