]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Usb/UsbBusDxe/UsbUtility.h
Update the copyright notice format
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbBusDxe / UsbUtility.h
CommitLineData
e237e7ae 1/** @file\r
2\r
8616fc4c 3 Manage Usb Port/Hc/Etc.\r
4\r
e237e7ae 5Copyright (c) 2007, Intel Corporation\r
6All rights reserved. This program and the accompanying materials\r
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
10\r
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
8616fc4c 14**/\r
e237e7ae 15\r
8616fc4c 16#ifndef _EFI_USB_UTILITY_H_\r
17#define _EFI_USB_UTILITY_H_\r
e237e7ae 18\r
8616fc4c 19/**\r
20 Get the capability of the host controller.\r
e237e7ae 21\r
8616fc4c 22 @param UsbBus The usb driver.\r
23 @param MaxSpeed The maximum speed this host controller supports.\r
24 @param NumOfPort The number of the root hub port.\r
25 @param Is64BitCapable Whether this controller support 64 bit addressing.\r
e237e7ae 26\r
8616fc4c 27 @retval EFI_SUCCESS The host controller capability is returned.\r
28 @retval Others Failed to retrieve the host controller capability.\r
e237e7ae 29\r
30**/\r
e237e7ae 31EFI_STATUS\r
32UsbHcGetCapability (\r
33 IN USB_BUS *UsbBus,\r
34 OUT UINT8 *MaxSpeed,\r
35 OUT UINT8 *NumOfPort,\r
36 OUT UINT8 *Is64BitCapable\r
37 );\r
38\r
8616fc4c 39/**\r
40 Reset the host controller.\r
41\r
42 @param UsbBus The usb bus driver.\r
43 @param Attributes The reset type, only global reset is used by this driver.\r
44\r
45 @retval EFI_SUCCESS The reset operation succeeded.\r
46 @retval EFI_INVALID_PARAMETER Attributes is not valid.\r
47 @retval EFI_UNSUPPOURTED The type of reset specified by Attributes is\r
48 not currently supported by the host controller.\r
49 @retval EFI_DEVICE_ERROR Host controller isn't halted to reset.\r
50**/\r
e237e7ae 51EFI_STATUS\r
52UsbHcReset (\r
53 IN USB_BUS *UsbBus,\r
54 IN UINT16 Attributes\r
55 );\r
56\r
8616fc4c 57/**\r
58 Get the current operation state of the host controller.\r
59\r
60 @param UsbBus The USB bus driver.\r
61 @param State The host controller operation state.\r
62\r
63 @retval EFI_SUCCESS The operation state is returned in State.\r
64 @retval Others Failed to get the host controller state.\r
e237e7ae 65\r
8616fc4c 66**/\r
e237e7ae 67EFI_STATUS\r
68UsbHcGetState (\r
69 IN USB_BUS *UsbBus,\r
70 OUT EFI_USB_HC_STATE *State\r
71 );\r
72\r
8616fc4c 73/**\r
74 Set the host controller operation state.\r
75\r
76 @param UsbBus The USB bus driver.\r
77 @param State The state to set.\r
78\r
79 @retval EFI_SUCCESS The host controller is now working at State.\r
80 @retval Others Failed to set operation state.\r
e237e7ae 81\r
8616fc4c 82**/\r
e237e7ae 83EFI_STATUS\r
84UsbHcSetState (\r
85 IN USB_BUS *UsbBus,\r
86 IN EFI_USB_HC_STATE State\r
87 );\r
88\r
8616fc4c 89/**\r
90 Get the root hub port state.\r
91\r
92 @param UsbBus The USB bus driver.\r
93 @param PortIndex The index of port.\r
94 @param PortStatus The variable to save port state.\r
e237e7ae 95\r
8616fc4c 96 @retval EFI_SUCCESS The root port state is returned in.\r
97 @retval Others Failed to get the root hub port state.\r
98\r
99**/\r
e237e7ae 100EFI_STATUS\r
101UsbHcGetRootHubPortStatus (\r
102 IN USB_BUS *UsbBus,\r
103 IN UINT8 PortIndex,\r
104 OUT EFI_USB_PORT_STATUS *PortStatus\r
105 );\r
106\r
8616fc4c 107/**\r
108 Set the root hub port feature.\r
e237e7ae 109\r
8616fc4c 110 @param UsbBus The USB bus driver.\r
111 @param PortIndex The port index.\r
112 @param Feature The port feature to set.\r
113\r
114 @retval EFI_SUCCESS The port feature is set.\r
115 @retval Others Failed to set port feature.\r
116\r
117**/\r
e237e7ae 118EFI_STATUS\r
119UsbHcSetRootHubPortFeature (\r
120 IN USB_BUS *UsbBus,\r
121 IN UINT8 PortIndex,\r
122 IN EFI_USB_PORT_FEATURE Feature\r
123 );\r
124\r
8616fc4c 125/**\r
126 Clear the root hub port feature.\r
e237e7ae 127\r
8616fc4c 128 @param UsbBus The USB bus driver.\r
129 @param PortIndex The port index.\r
130 @param Feature The port feature to clear.\r
131\r
132 @retval EFI_SUCCESS The port feature is clear.\r
133 @retval Others Failed to clear port feature.\r
134\r
135**/\r
e237e7ae 136EFI_STATUS\r
137UsbHcClearRootHubPortFeature (\r
138 IN USB_BUS *UsbBus,\r
139 IN UINT8 PortIndex,\r
140 IN EFI_USB_PORT_FEATURE Feature\r
141 );\r
142\r
8616fc4c 143/**\r
144 Execute a control transfer to the device.\r
e237e7ae 145\r
8616fc4c 146 @param UsbBus The USB bus driver.\r
147 @param DevAddr The device address.\r
148 @param DevSpeed The device speed.\r
149 @param MaxPacket Maximum packet size of endpoint 0.\r
150 @param Request The control transfer request.\r
151 @param Direction The direction of data stage.\r
152 @param Data The buffer holding data.\r
153 @param DataLength The length of the data.\r
154 @param TimeOut Timeout (in ms) to wait until timeout.\r
155 @param Translator The transaction translator for low/full speed device.\r
156 @param UsbResult The result of transfer.\r
157\r
158 @retval EFI_SUCCESS The control transfer finished without error.\r
159 @retval Others The control transfer failed, reason returned in UsbReslt.\r
160\r
161**/\r
e237e7ae 162EFI_STATUS\r
163UsbHcControlTransfer (\r
164 IN USB_BUS *UsbBus,\r
165 IN UINT8 DevAddr,\r
166 IN UINT8 DevSpeed,\r
167 IN UINTN MaxPacket,\r
168 IN EFI_USB_DEVICE_REQUEST *Request,\r
169 IN EFI_USB_DATA_DIRECTION Direction,\r
170 IN OUT VOID *Data,\r
171 IN OUT UINTN *DataLength,\r
172 IN UINTN TimeOut,\r
173 IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,\r
174 OUT UINT32 *UsbResult\r
175 );\r
176\r
8616fc4c 177/**\r
178 Execute a bulk transfer to the device's endpoint.\r
179\r
180 @param UsbBus The USB bus driver.\r
181 @param DevAddr The target device address.\r
182 @param EpAddr The target endpoint address, with direction encoded in\r
183 bit 7.\r
184 @param DevSpeed The device's speed.\r
185 @param MaxPacket The endpoint's max packet size.\r
186 @param BufferNum The number of data buffer.\r
187 @param Data Array of pointers to data buffer.\r
188 @param DataLength The length of data buffer.\r
189 @param DataToggle On input, the initial data toggle to use, also return\r
190 the next toggle on output.\r
191 @param TimeOut The time to wait until timeout.\r
192 @param Translator The transaction translator for low/full speed device.\r
193 @param UsbResult The result of USB execution.\r
194\r
195 @retval EFI_SUCCESS The bulk transfer is finished without error.\r
196 @retval Others Failed to execute bulk transfer, result in UsbResult.\r
e237e7ae 197\r
8616fc4c 198**/\r
e237e7ae 199EFI_STATUS\r
200UsbHcBulkTransfer (\r
201 IN USB_BUS *UsbBus,\r
202 IN UINT8 DevAddr,\r
203 IN UINT8 EpAddr,\r
204 IN UINT8 DevSpeed,\r
205 IN UINTN MaxPacket,\r
206 IN UINT8 BufferNum,\r
207 IN OUT VOID *Data[EFI_USB_MAX_BULK_BUFFER_NUM],\r
208 IN OUT UINTN *DataLength,\r
209 IN OUT UINT8 *DataToggle,\r
210 IN UINTN TimeOut,\r
211 IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,\r
212 OUT UINT32 *UsbResult\r
213 );\r
214\r
8616fc4c 215/**\r
216 Queue or cancel an asynchronous interrupt transfer.\r
217\r
218 @param UsbBus The USB bus driver.\r
219 @param DevAddr The target device address.\r
220 @param EpAddr The target endpoint address, with direction encoded in\r
221 bit 7.\r
222 @param DevSpeed The device's speed.\r
223 @param MaxPacket The endpoint's max packet size.\r
224 @param IsNewTransfer Whether this is a new request. If not, cancel the old\r
225 request.\r
226 @param DataToggle Data toggle to use on input, next toggle on output.\r
227 @param PollingInterval The interval to poll the interrupt transfer (in ms).\r
228 @param DataLength The length of periodical data receive.\r
229 @param Translator The transaction translator for low/full speed device.\r
230 @param Callback Function to call when data is received.\r
231 @param Context The context to the callback.\r
232\r
233 @retval EFI_SUCCESS The asynchronous transfer is queued.\r
234 @retval Others Failed to queue the transfer.\r
e237e7ae 235\r
8616fc4c 236**/\r
e237e7ae 237EFI_STATUS\r
238UsbHcAsyncInterruptTransfer (\r
239 IN USB_BUS *UsbBus,\r
240 IN UINT8 DevAddr,\r
241 IN UINT8 EpAddr,\r
242 IN UINT8 DevSpeed,\r
243 IN UINTN MaxPacket,\r
244 IN BOOLEAN IsNewTransfer,\r
245 IN OUT UINT8 *DataToggle,\r
246 IN UINTN PollingInterval,\r
247 IN UINTN DataLength,\r
248 IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,\r
249 IN EFI_ASYNC_USB_TRANSFER_CALLBACK Callback,\r
250 IN VOID *Context OPTIONAL\r
251 );\r
252\r
8616fc4c 253/**\r
254 Execute a synchronous interrupt transfer to the target endpoint.\r
255\r
256 @param UsbBus The USB bus driver.\r
257 @param DevAddr The target device address.\r
258 @param EpAddr The target endpoint address, with direction encoded in\r
259 bit 7.\r
260 @param DevSpeed The device's speed.\r
261 @param MaxPacket The endpoint's max packet size.\r
262 @param Data Pointer to data buffer.\r
263 @param DataLength The length of data buffer.\r
264 @param DataToggle On input, the initial data toggle to use, also return\r
265 the next toggle on output.\r
266 @param TimeOut The time to wait until timeout.\r
267 @param Translator The transaction translator for low/full speed device.\r
268 @param UsbResult The result of USB execution.\r
269\r
270 @retval EFI_SUCCESS The synchronous interrupt transfer is OK.\r
271 @retval Others Failed to execute the synchronous interrupt transfer.\r
e237e7ae 272\r
8616fc4c 273**/\r
e237e7ae 274EFI_STATUS\r
275UsbHcSyncInterruptTransfer (\r
276 IN USB_BUS *UsbBus,\r
277 IN UINT8 DevAddr,\r
278 IN UINT8 EpAddr,\r
279 IN UINT8 DevSpeed,\r
280 IN UINTN MaxPacket,\r
281 IN OUT VOID *Data,\r
282 IN OUT UINTN *DataLength,\r
283 IN OUT UINT8 *DataToggle,\r
284 IN UINTN TimeOut,\r
285 IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,\r
286 OUT UINT32 *UsbResult\r
287 );\r
288\r
8616fc4c 289/**\r
290 Execute a synchronous Isochronous USB transfer.\r
291\r
292 @param UsbBus The USB bus driver.\r
293 @param DevAddr The target device address.\r
294 @param EpAddr The target endpoint address, with direction encoded in\r
295 bit 7.\r
296 @param DevSpeed The device's speed.\r
297 @param MaxPacket The endpoint's max packet size.\r
298 @param BufferNum The number of data buffer.\r
299 @param Data Array of pointers to data buffer.\r
300 @param DataLength The length of data buffer.\r
301 @param Translator The transaction translator for low/full speed device.\r
302 @param UsbResult The result of USB execution.\r
e237e7ae 303\r
8616fc4c 304 @retval EFI_UNSUPPORTED The isochronous transfer isn't supported now.\r
305\r
306**/\r
e237e7ae 307EFI_STATUS\r
308UsbHcIsochronousTransfer (\r
309 IN USB_BUS *UsbBus,\r
310 IN UINT8 DevAddr,\r
311 IN UINT8 EpAddr,\r
312 IN UINT8 DevSpeed,\r
313 IN UINTN MaxPacket,\r
314 IN UINT8 BufferNum,\r
315 IN OUT VOID *Data[EFI_USB_MAX_ISO_BUFFER_NUM],\r
316 IN UINTN DataLength,\r
317 IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,\r
318 OUT UINT32 *UsbResult\r
319 );\r
320\r
8616fc4c 321/**\r
322 Queue an asynchronous isochronous transfer.\r
323\r
324 @param UsbBus The USB bus driver.\r
325 @param DevAddr The target device address.\r
326 @param EpAddr The target endpoint address, with direction encoded in\r
327 bit 7.\r
328 @param DevSpeed The device's speed.\r
329 @param MaxPacket The endpoint's max packet size.\r
330 @param BufferNum The number of data buffer.\r
331 @param Data Array of pointers to data buffer.\r
332 @param DataLength The length of data buffer.\r
333 @param Translator The transaction translator for low/full speed device.\r
334 @param Callback The function to call when data is transferred.\r
335 @param Context The context to the callback function.\r
e237e7ae 336\r
8616fc4c 337 @retval EFI_UNSUPPORTED The asynchronous isochronous transfer isn't supported.\r
338\r
339**/\r
e237e7ae 340EFI_STATUS\r
341UsbHcAsyncIsochronousTransfer (\r
342 IN USB_BUS *UsbBus,\r
343 IN UINT8 DevAddr,\r
344 IN UINT8 EpAddr,\r
345 IN UINT8 DevSpeed,\r
346 IN UINTN MaxPacket,\r
347 IN UINT8 BufferNum,\r
348 IN OUT VOID *Data[EFI_USB_MAX_ISO_BUFFER_NUM],\r
349 IN UINTN DataLength,\r
350 IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,\r
351 IN EFI_ASYNC_USB_TRANSFER_CALLBACK Callback,\r
352 IN VOID *Context\r
353 );\r
354\r
8616fc4c 355/**\r
356 Open the USB host controller protocol BY_CHILD.\r
357\r
358 @param Bus The USB bus driver.\r
359 @param Child The child handle.\r
e237e7ae 360\r
8616fc4c 361 @return The open protocol return.\r
362\r
363**/\r
e237e7ae 364EFI_STATUS\r
365UsbOpenHostProtoByChild (\r
366 IN USB_BUS *Bus,\r
367 IN EFI_HANDLE Child\r
368 );\r
369\r
8616fc4c 370/**\r
371 Close the USB host controller protocol BY_CHILD.\r
372\r
373 @param Bus The USB bus driver.\r
374 @param Child The child handle.\r
e237e7ae 375\r
8616fc4c 376 @return None.\r
377\r
378**/\r
e237e7ae 379VOID\r
380UsbCloseHostProtoByChild (\r
381 IN USB_BUS *Bus,\r
382 IN EFI_HANDLE Child\r
383 );\r
384\r
8616fc4c 385/**\r
386 return the current TPL, copied from the EDKII glue lib.\r
387\r
388 @param VOID.\r
e237e7ae 389\r
8616fc4c 390 @return Current TPL.\r
391\r
392**/\r
e237e7ae 393EFI_TPL\r
394UsbGetCurrentTpl (\r
395 VOID\r
396 );\r
397\r
e237e7ae 398#endif\r