]>
Commit | Line | Data |
---|---|---|
e237e7ae | 1 | /** @file\r |
2 | \r | |
3 | Copyright (c) 2007, Intel Corporation\r | |
4 | All rights reserved. This program and the accompanying materials\r | |
5 | are licensed and made available under the terms and conditions of the BSD License\r | |
6 | which accompanies this distribution. The full text of the license may be found at\r | |
7 | http://opensource.org/licenses/bsd-license.php\r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
11 | \r | |
12 | Module Name:\r | |
13 | \r | |
14 | UsbUtility.c\r | |
15 | \r | |
16 | Abstract:\r | |
17 | \r | |
18 | Wrapper function for usb host controller interface\r | |
19 | \r | |
20 | Revision History\r | |
21 | \r | |
22 | \r | |
23 | **/\r | |
24 | \r | |
25 | \r | |
26 | #include "UsbBus.h"\r | |
27 | \r | |
28 | \r | |
29 | /**\r | |
30 | Get the capability of the host controller\r | |
31 | \r | |
32 | @param UsbBus The usb driver\r | |
33 | @param MaxSpeed The maximum speed this host controller supports\r | |
34 | @param NumOfPort The number of the root hub port\r | |
35 | @param Is64BitCapable Whether this controller support 64 bit addressing\r | |
36 | \r | |
37 | @retval EFI_SUCCESS The host controller capability is returned\r | |
38 | @retval Others Failed to retrieve the host controller capability.\r | |
39 | \r | |
40 | **/\r | |
41 | EFI_STATUS\r | |
42 | UsbHcGetCapability (\r | |
43 | IN USB_BUS *UsbBus,\r | |
44 | OUT UINT8 *MaxSpeed,\r | |
45 | OUT UINT8 *NumOfPort,\r | |
46 | OUT UINT8 *Is64BitCapable\r | |
47 | )\r | |
48 | {\r | |
49 | EFI_STATUS Status;\r | |
50 | \r | |
51 | if (UsbBus->Usb2Hc != NULL) {\r | |
52 | Status = UsbBus->Usb2Hc->GetCapability (\r | |
53 | UsbBus->Usb2Hc,\r | |
54 | MaxSpeed,\r | |
55 | NumOfPort,\r | |
56 | Is64BitCapable\r | |
57 | );\r | |
58 | \r | |
59 | } else {\r | |
60 | Status = UsbBus->UsbHc->GetRootHubPortNumber (UsbBus->UsbHc, NumOfPort);\r | |
61 | \r | |
62 | *MaxSpeed = EFI_USB_SPEED_FULL;\r | |
63 | *Is64BitCapable = (UINT8) FALSE;\r | |
64 | }\r | |
65 | \r | |
66 | return Status;\r | |
67 | }\r | |
68 | \r | |
69 | \r | |
70 | /**\r | |
71 | Reset the host controller\r | |
72 | \r | |
73 | @param UsbBus The usb bus driver\r | |
74 | @param Attributes The reset type, only global reset is used by this driver\r | |
75 | \r | |
76 | @return GC_TODO: add return values\r | |
77 | \r | |
78 | **/\r | |
79 | EFI_STATUS\r | |
80 | UsbHcReset (\r | |
81 | IN USB_BUS *UsbBus,\r | |
82 | IN UINT16 Attributes\r | |
83 | )\r | |
84 | {\r | |
85 | EFI_STATUS Status;\r | |
86 | \r | |
87 | if (UsbBus->Usb2Hc != NULL) {\r | |
88 | Status = UsbBus->Usb2Hc->Reset (UsbBus->Usb2Hc, Attributes);\r | |
89 | } else {\r | |
90 | Status = UsbBus->UsbHc->Reset (UsbBus->UsbHc, Attributes);\r | |
91 | }\r | |
92 | \r | |
93 | return Status;\r | |
94 | }\r | |
95 | \r | |
96 | \r | |
97 | /**\r | |
98 | Get the current operation state of the host controller\r | |
99 | \r | |
100 | @param UsbBus The USB bus driver\r | |
101 | @param State The host controller operation state\r | |
102 | \r | |
103 | @retval EFI_SUCCESS The operation state is returned in State\r | |
104 | @retval Others Failed to get the host controller state\r | |
105 | \r | |
106 | **/\r | |
107 | EFI_STATUS\r | |
108 | UsbHcGetState (\r | |
109 | IN USB_BUS *UsbBus,\r | |
110 | OUT EFI_USB_HC_STATE *State\r | |
111 | )\r | |
112 | {\r | |
113 | EFI_STATUS Status;\r | |
114 | \r | |
115 | if (UsbBus->Usb2Hc != NULL) {\r | |
116 | Status = UsbBus->Usb2Hc->GetState (UsbBus->Usb2Hc, State);\r | |
117 | } else {\r | |
118 | Status = UsbBus->UsbHc->GetState (UsbBus->UsbHc, State);\r | |
119 | }\r | |
120 | \r | |
121 | return Status;\r | |
122 | }\r | |
123 | \r | |
124 | \r | |
125 | /**\r | |
126 | Set the host controller operation state\r | |
127 | \r | |
128 | @param UsbBus The USB bus driver\r | |
129 | @param State The state to set\r | |
130 | \r | |
131 | @retval EFI_SUCCESS The host controller is now working at State\r | |
132 | @retval Others Failed to set operation state\r | |
133 | \r | |
134 | **/\r | |
135 | EFI_STATUS\r | |
136 | UsbHcSetState (\r | |
137 | IN USB_BUS *UsbBus,\r | |
138 | IN EFI_USB_HC_STATE State\r | |
139 | )\r | |
140 | {\r | |
141 | EFI_STATUS Status;\r | |
142 | \r | |
143 | if (UsbBus->Usb2Hc != NULL) {\r | |
144 | Status = UsbBus->Usb2Hc->SetState (UsbBus->Usb2Hc, State);\r | |
145 | } else {\r | |
146 | Status = UsbBus->UsbHc->SetState (UsbBus->UsbHc, State);\r | |
147 | }\r | |
148 | \r | |
149 | return Status;\r | |
150 | }\r | |
151 | \r | |
152 | \r | |
153 | /**\r | |
154 | Get the root hub port state\r | |
155 | \r | |
156 | @param UsbBus The USB bus driver\r | |
157 | @param PortIndex The index of port\r | |
158 | @param PortStatus The variable to save port state\r | |
159 | \r | |
160 | @retval EFI_SUCCESS The root port state is returned in\r | |
161 | @retval Others Failed to get the root hub port state\r | |
162 | \r | |
163 | **/\r | |
164 | EFI_STATUS\r | |
165 | UsbHcGetRootHubPortStatus (\r | |
166 | IN USB_BUS *UsbBus,\r | |
167 | IN UINT8 PortIndex,\r | |
168 | OUT EFI_USB_PORT_STATUS *PortStatus\r | |
169 | )\r | |
170 | {\r | |
171 | EFI_STATUS Status;\r | |
172 | \r | |
173 | if (UsbBus->Usb2Hc != NULL) {\r | |
174 | Status = UsbBus->Usb2Hc->GetRootHubPortStatus (UsbBus->Usb2Hc, PortIndex, PortStatus);\r | |
175 | } else {\r | |
176 | Status = UsbBus->UsbHc->GetRootHubPortStatus (UsbBus->UsbHc, PortIndex, PortStatus);\r | |
177 | }\r | |
178 | \r | |
179 | return Status;\r | |
180 | }\r | |
181 | \r | |
182 | \r | |
183 | /**\r | |
184 | Set the root hub port feature\r | |
185 | \r | |
186 | @param UsbBus The USB bus driver\r | |
187 | @param PortIndex The port index\r | |
188 | @param Feature The port feature to set\r | |
189 | \r | |
190 | @retval EFI_SUCCESS The port feature is set\r | |
191 | @retval Others Failed to set port feature\r | |
192 | \r | |
193 | **/\r | |
194 | EFI_STATUS\r | |
195 | UsbHcSetRootHubPortFeature (\r | |
196 | IN USB_BUS *UsbBus,\r | |
197 | IN UINT8 PortIndex,\r | |
198 | IN EFI_USB_PORT_FEATURE Feature\r | |
199 | )\r | |
200 | {\r | |
201 | EFI_STATUS Status;\r | |
202 | \r | |
203 | \r | |
204 | if (UsbBus->Usb2Hc != NULL) {\r | |
205 | Status = UsbBus->Usb2Hc->SetRootHubPortFeature (UsbBus->Usb2Hc, PortIndex, Feature);\r | |
206 | } else {\r | |
207 | Status = UsbBus->UsbHc->SetRootHubPortFeature (UsbBus->UsbHc, PortIndex, Feature);\r | |
208 | }\r | |
209 | \r | |
210 | return Status;\r | |
211 | }\r | |
212 | \r | |
213 | \r | |
214 | /**\r | |
215 | Clear the root hub port feature\r | |
216 | \r | |
217 | @param UsbBus The USB bus driver\r | |
218 | @param PortIndex The port index\r | |
219 | @param Feature The port feature to clear\r | |
220 | \r | |
221 | @retval EFI_SUCCESS The port feature is clear\r | |
222 | @retval Others Failed to clear port feature\r | |
223 | \r | |
224 | **/\r | |
225 | EFI_STATUS\r | |
226 | UsbHcClearRootHubPortFeature (\r | |
227 | IN USB_BUS *UsbBus,\r | |
228 | IN UINT8 PortIndex,\r | |
229 | IN EFI_USB_PORT_FEATURE Feature\r | |
230 | )\r | |
231 | {\r | |
232 | EFI_STATUS Status;\r | |
233 | \r | |
234 | if (UsbBus->Usb2Hc != NULL) {\r | |
235 | Status = UsbBus->Usb2Hc->ClearRootHubPortFeature (UsbBus->Usb2Hc, PortIndex, Feature);\r | |
236 | } else {\r | |
237 | Status = UsbBus->UsbHc->ClearRootHubPortFeature (UsbBus->UsbHc, PortIndex, Feature);\r | |
238 | }\r | |
239 | \r | |
240 | return Status;\r | |
241 | }\r | |
242 | \r | |
243 | \r | |
244 | /**\r | |
245 | Execute a control transfer to the device\r | |
246 | \r | |
247 | @param UsbBus The USB bus driver\r | |
248 | @param DevAddr The device address\r | |
249 | @param DevSpeed The device speed\r | |
250 | @param MaxPacket Maximum packet size of endpoint 0\r | |
251 | @param Request The control transfer request\r | |
252 | @param Direction The direction of data stage\r | |
253 | @param Data The buffer holding data\r | |
254 | @param DataLength The length of the data\r | |
255 | @param TimeOut Timeout (in ms) to wait until timeout\r | |
256 | @param Translator The transaction translator for low/full speed device\r | |
257 | @param UsbResult The result of transfer\r | |
258 | \r | |
259 | @retval EFI_SUCCESS The control transfer finished without error\r | |
260 | @retval Others The control transfer failed, reason returned in UsbReslt\r | |
261 | \r | |
262 | **/\r | |
263 | EFI_STATUS\r | |
264 | UsbHcControlTransfer (\r | |
265 | IN USB_BUS *UsbBus,\r | |
266 | IN UINT8 DevAddr,\r | |
267 | IN UINT8 DevSpeed,\r | |
268 | IN UINTN MaxPacket,\r | |
269 | IN EFI_USB_DEVICE_REQUEST *Request,\r | |
270 | IN EFI_USB_DATA_DIRECTION Direction,\r | |
271 | IN OUT VOID *Data,\r | |
272 | IN OUT UINTN *DataLength,\r | |
273 | IN UINTN TimeOut,\r | |
274 | IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,\r | |
275 | OUT UINT32 *UsbResult\r | |
276 | )\r | |
277 | {\r | |
278 | EFI_STATUS Status;\r | |
279 | BOOLEAN IsSlowDevice;\r | |
280 | \r | |
281 | if (UsbBus->Usb2Hc != NULL) {\r | |
282 | Status = UsbBus->Usb2Hc->ControlTransfer (\r | |
283 | UsbBus->Usb2Hc,\r | |
284 | DevAddr,\r | |
285 | DevSpeed,\r | |
286 | MaxPacket,\r | |
287 | Request,\r | |
288 | Direction,\r | |
289 | Data,\r | |
290 | DataLength,\r | |
291 | TimeOut,\r | |
292 | Translator,\r | |
293 | UsbResult\r | |
294 | );\r | |
295 | \r | |
296 | } else {\r | |
297 | IsSlowDevice = (BOOLEAN)(EFI_USB_SPEED_LOW == DevSpeed);\r | |
298 | Status = UsbBus->UsbHc->ControlTransfer (\r | |
299 | UsbBus->UsbHc,\r | |
300 | DevAddr,\r | |
301 | IsSlowDevice,\r | |
302 | (UINT8) MaxPacket,\r | |
303 | Request,\r | |
304 | Direction,\r | |
305 | Data,\r | |
306 | DataLength,\r | |
307 | TimeOut,\r | |
308 | UsbResult\r | |
309 | );\r | |
310 | }\r | |
311 | \r | |
312 | return Status;\r | |
313 | }\r | |
314 | \r | |
315 | \r | |
316 | /**\r | |
317 | Execute a bulk transfer to the device's endpoint\r | |
318 | \r | |
319 | @param UsbBus The USB bus driver\r | |
320 | @param DevAddr The target device address\r | |
321 | @param EpAddr The target endpoint address, with direction encoded in\r | |
322 | bit 7\r | |
323 | @param DevSpeed The device's speed\r | |
324 | @param MaxPacket The endpoint's max packet size\r | |
325 | @param BufferNum The number of data buffer\r | |
326 | @param Data Array of pointers to data buffer\r | |
327 | @param DataLength The length of data buffer\r | |
328 | @param DataToggle On input, the initial data toggle to use, also return\r | |
329 | the next toggle on output.\r | |
330 | @param TimeOut The time to wait until timeout\r | |
331 | @param Translator The transaction translator for low/full speed device\r | |
332 | @param UsbResult The result of USB execution\r | |
333 | \r | |
334 | @retval EFI_SUCCESS The bulk transfer is finished without error\r | |
335 | @retval Others Failed to execute bulk transfer, result in UsbResult\r | |
336 | \r | |
337 | **/\r | |
338 | EFI_STATUS\r | |
339 | UsbHcBulkTransfer (\r | |
340 | IN USB_BUS *UsbBus,\r | |
341 | IN UINT8 DevAddr,\r | |
342 | IN UINT8 EpAddr,\r | |
343 | IN UINT8 DevSpeed,\r | |
344 | IN UINTN MaxPacket,\r | |
345 | IN UINT8 BufferNum,\r | |
346 | IN OUT VOID *Data[EFI_USB_MAX_BULK_BUFFER_NUM],\r | |
347 | IN OUT UINTN *DataLength,\r | |
348 | IN OUT UINT8 *DataToggle,\r | |
349 | IN UINTN TimeOut,\r | |
350 | IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,\r | |
351 | OUT UINT32 *UsbResult\r | |
352 | )\r | |
353 | {\r | |
354 | EFI_STATUS Status;\r | |
355 | \r | |
356 | if (UsbBus->Usb2Hc != NULL) {\r | |
357 | Status = UsbBus->Usb2Hc->BulkTransfer (\r | |
358 | UsbBus->Usb2Hc,\r | |
359 | DevAddr,\r | |
360 | EpAddr,\r | |
361 | DevSpeed,\r | |
362 | MaxPacket,\r | |
363 | BufferNum,\r | |
364 | Data,\r | |
365 | DataLength,\r | |
366 | DataToggle,\r | |
367 | TimeOut,\r | |
368 | Translator,\r | |
369 | UsbResult\r | |
370 | );\r | |
371 | } else {\r | |
372 | Status = UsbBus->UsbHc->BulkTransfer (\r | |
373 | UsbBus->UsbHc,\r | |
374 | DevAddr,\r | |
375 | EpAddr,\r | |
376 | (UINT8) MaxPacket,\r | |
377 | *Data,\r | |
378 | DataLength,\r | |
379 | DataToggle,\r | |
380 | TimeOut,\r | |
381 | UsbResult\r | |
382 | );\r | |
383 | }\r | |
384 | \r | |
385 | return Status;\r | |
386 | }\r | |
387 | \r | |
388 | \r | |
389 | /**\r | |
390 | Queue or cancel an asynchronous interrupt transfer\r | |
391 | \r | |
392 | @param UsbBus The USB bus driver\r | |
393 | @param DevAddr The target device address\r | |
394 | @param EpAddr The target endpoint address, with direction encoded in\r | |
395 | bit 7\r | |
396 | @param DevSpeed The device's speed\r | |
397 | @param MaxPacket The endpoint's max packet size\r | |
398 | @param IsNewTransfer Whether this is a new request. If not, cancel the old\r | |
399 | request\r | |
400 | @param DataToggle Data toggle to use on input, next toggle on output\r | |
401 | @param PollingInterval The interval to poll the interrupt transfer (in ms)\r | |
402 | @param DataLength The length of periodical data receive\r | |
403 | @param Translator The transaction translator for low/full speed device\r | |
404 | @param Callback Function to call when data is received\r | |
405 | @param Context The context to the callback\r | |
406 | \r | |
407 | @retval EFI_SUCCESS The asynchronous transfer is queued\r | |
408 | @retval Others Failed to queue the transfer\r | |
409 | \r | |
410 | **/\r | |
411 | EFI_STATUS\r | |
412 | UsbHcAsyncInterruptTransfer (\r | |
413 | IN USB_BUS *UsbBus,\r | |
414 | IN UINT8 DevAddr,\r | |
415 | IN UINT8 EpAddr,\r | |
416 | IN UINT8 DevSpeed,\r | |
417 | IN UINTN MaxPacket,\r | |
418 | IN BOOLEAN IsNewTransfer,\r | |
419 | IN OUT UINT8 *DataToggle,\r | |
420 | IN UINTN PollingInterval,\r | |
421 | IN UINTN DataLength,\r | |
422 | IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,\r | |
423 | IN EFI_ASYNC_USB_TRANSFER_CALLBACK Callback,\r | |
424 | IN VOID *Context OPTIONAL\r | |
425 | )\r | |
426 | {\r | |
427 | EFI_STATUS Status;\r | |
428 | BOOLEAN IsSlowDevice;\r | |
429 | \r | |
430 | if (UsbBus->Usb2Hc != NULL) {\r | |
431 | Status = UsbBus->Usb2Hc->AsyncInterruptTransfer (\r | |
432 | UsbBus->Usb2Hc,\r | |
433 | DevAddr,\r | |
434 | EpAddr,\r | |
435 | DevSpeed,\r | |
436 | MaxPacket,\r | |
437 | IsNewTransfer,\r | |
438 | DataToggle,\r | |
439 | PollingInterval,\r | |
440 | DataLength,\r | |
441 | Translator,\r | |
442 | Callback,\r | |
443 | Context\r | |
444 | );\r | |
445 | } else {\r | |
446 | IsSlowDevice = (BOOLEAN)(EFI_USB_SPEED_LOW == DevSpeed);\r | |
447 | \r | |
448 | Status = UsbBus->UsbHc->AsyncInterruptTransfer (\r | |
449 | UsbBus->UsbHc,\r | |
450 | DevAddr,\r | |
451 | EpAddr,\r | |
452 | IsSlowDevice,\r | |
453 | (UINT8) MaxPacket,\r | |
454 | IsNewTransfer,\r | |
455 | DataToggle,\r | |
456 | PollingInterval,\r | |
457 | DataLength,\r | |
458 | Callback,\r | |
459 | Context\r | |
460 | );\r | |
461 | }\r | |
462 | \r | |
463 | return Status;\r | |
464 | }\r | |
465 | \r | |
466 | \r | |
467 | /**\r | |
468 | Execute a synchronous interrupt transfer to the target endpoint\r | |
469 | \r | |
470 | @param UsbBus The USB bus driver\r | |
471 | @param DevAddr The target device address\r | |
472 | @param EpAddr The target endpoint address, with direction encoded in\r | |
473 | bit 7\r | |
474 | @param DevSpeed The device's speed\r | |
475 | @param MaxPacket The endpoint's max packet size\r | |
476 | @param Data Pointer to data buffer\r | |
477 | @param DataLength The length of data buffer\r | |
478 | @param DataToggle On input, the initial data toggle to use, also return\r | |
479 | the next toggle on output.\r | |
480 | @param TimeOut The time to wait until timeout\r | |
481 | @param Translator The transaction translator for low/full speed device\r | |
482 | @param UsbResult The result of USB execution\r | |
483 | \r | |
484 | @retval EFI_SUCCESS The synchronous interrupt transfer is OK\r | |
485 | @retval Others Failed to execute the synchronous interrupt transfer\r | |
486 | \r | |
487 | **/\r | |
488 | EFI_STATUS\r | |
489 | UsbHcSyncInterruptTransfer (\r | |
490 | IN USB_BUS *UsbBus,\r | |
491 | IN UINT8 DevAddr,\r | |
492 | IN UINT8 EpAddr,\r | |
493 | IN UINT8 DevSpeed,\r | |
494 | IN UINTN MaxPacket,\r | |
495 | IN OUT VOID *Data,\r | |
496 | IN OUT UINTN *DataLength,\r | |
497 | IN OUT UINT8 *DataToggle,\r | |
498 | IN UINTN TimeOut,\r | |
499 | IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,\r | |
500 | OUT UINT32 *UsbResult\r | |
501 | )\r | |
502 | {\r | |
503 | EFI_STATUS Status;\r | |
504 | BOOLEAN IsSlowDevice;\r | |
505 | \r | |
506 | if (UsbBus->Usb2Hc != NULL) {\r | |
507 | Status = UsbBus->Usb2Hc->SyncInterruptTransfer (\r | |
508 | UsbBus->Usb2Hc,\r | |
509 | DevAddr,\r | |
510 | EpAddr,\r | |
511 | DevSpeed,\r | |
512 | MaxPacket,\r | |
513 | Data,\r | |
514 | DataLength,\r | |
515 | DataToggle,\r | |
516 | TimeOut,\r | |
517 | Translator,\r | |
518 | UsbResult\r | |
519 | );\r | |
520 | } else {\r | |
c52fa98c | 521 | IsSlowDevice = (BOOLEAN) ((EFI_USB_SPEED_LOW == DevSpeed) ? TRUE : FALSE);\r |
e237e7ae | 522 | Status = UsbBus->UsbHc->SyncInterruptTransfer (\r |
523 | UsbBus->UsbHc,\r | |
524 | DevAddr,\r | |
525 | EpAddr,\r | |
526 | IsSlowDevice,\r | |
527 | (UINT8) MaxPacket,\r | |
528 | Data,\r | |
529 | DataLength,\r | |
530 | DataToggle,\r | |
531 | TimeOut,\r | |
532 | UsbResult\r | |
533 | );\r | |
534 | }\r | |
535 | \r | |
536 | return Status;\r | |
537 | }\r | |
538 | \r | |
539 | \r | |
540 | /**\r | |
541 | Execute a synchronous Isochronous USB transfer\r | |
542 | \r | |
543 | @param UsbBus The USB bus driver\r | |
544 | @param DevAddr The target device address\r | |
545 | @param EpAddr The target endpoint address, with direction encoded in\r | |
546 | bit 7\r | |
547 | @param DevSpeed The device's speed\r | |
548 | @param MaxPacket The endpoint's max packet size\r | |
549 | @param BufferNum The number of data buffer\r | |
550 | @param Data Array of pointers to data buffer\r | |
551 | @param DataLength The length of data buffer\r | |
552 | @param Translator The transaction translator for low/full speed device\r | |
553 | @param UsbResult The result of USB execution\r | |
554 | \r | |
555 | @retval EFI_UNSUPPORTED The isochronous transfer isn't supported now\r | |
556 | \r | |
557 | **/\r | |
558 | EFI_STATUS\r | |
559 | UsbHcIsochronousTransfer (\r | |
560 | IN USB_BUS *UsbBus,\r | |
561 | IN UINT8 DevAddr,\r | |
562 | IN UINT8 EpAddr,\r | |
563 | IN UINT8 DevSpeed,\r | |
564 | IN UINTN MaxPacket,\r | |
565 | IN UINT8 BufferNum,\r | |
566 | IN OUT VOID *Data[EFI_USB_MAX_ISO_BUFFER_NUM],\r | |
567 | IN UINTN DataLength,\r | |
568 | IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,\r | |
569 | OUT UINT32 *UsbResult\r | |
570 | )\r | |
571 | {\r | |
572 | return EFI_UNSUPPORTED;\r | |
573 | }\r | |
574 | \r | |
575 | \r | |
576 | /**\r | |
577 | Queue an asynchronous isochronous transfer\r | |
578 | \r | |
579 | @param UsbBus The USB bus driver\r | |
580 | @param DevAddr The target device address\r | |
581 | @param EpAddr The target endpoint address, with direction encoded in\r | |
582 | bit 7\r | |
583 | @param DevSpeed The device's speed\r | |
584 | @param MaxPacket The endpoint's max packet size\r | |
585 | @param BufferNum The number of data buffer\r | |
586 | @param Data Array of pointers to data buffer\r | |
587 | @param DataLength The length of data buffer\r | |
588 | @param Translator The transaction translator for low/full speed device\r | |
589 | @param Callback The function to call when data is transferred\r | |
590 | @param Context The context to the callback function\r | |
591 | \r | |
592 | @retval EFI_UNSUPPORTED The asynchronous isochronous transfer isn't supported\r | |
593 | \r | |
594 | **/\r | |
595 | EFI_STATUS\r | |
596 | UsbHcAsyncIsochronousTransfer (\r | |
597 | IN USB_BUS *UsbBus,\r | |
598 | IN UINT8 DevAddr,\r | |
599 | IN UINT8 EpAddr,\r | |
600 | IN UINT8 DevSpeed,\r | |
601 | IN UINTN MaxPacket,\r | |
602 | IN UINT8 BufferNum,\r | |
603 | IN OUT VOID *Data[EFI_USB_MAX_ISO_BUFFER_NUM],\r | |
604 | IN UINTN DataLength,\r | |
605 | IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,\r | |
606 | IN EFI_ASYNC_USB_TRANSFER_CALLBACK Callback,\r | |
607 | IN VOID *Context\r | |
608 | )\r | |
609 | {\r | |
610 | return EFI_UNSUPPORTED;\r | |
611 | }\r | |
612 | \r | |
613 | \r | |
614 | /**\r | |
615 | Open the USB host controller protocol BY_CHILD\r | |
616 | \r | |
617 | @param Bus The USB bus driver\r | |
618 | @param Child The child handle\r | |
619 | \r | |
620 | @return The open protocol return\r | |
621 | \r | |
622 | **/\r | |
623 | EFI_STATUS\r | |
624 | UsbOpenHostProtoByChild (\r | |
625 | IN USB_BUS *Bus,\r | |
626 | IN EFI_HANDLE Child\r | |
627 | )\r | |
628 | {\r | |
629 | EFI_USB_HC_PROTOCOL *UsbHc;\r | |
630 | EFI_USB2_HC_PROTOCOL *Usb2Hc;\r | |
631 | EFI_STATUS Status;\r | |
632 | \r | |
633 | if (Bus->Usb2Hc != NULL) {\r | |
634 | Status = gBS->OpenProtocol (\r | |
635 | Bus->HostHandle,\r | |
636 | &gEfiUsb2HcProtocolGuid,\r | |
c52fa98c | 637 | (VOID **) &Usb2Hc,\r |
e237e7ae | 638 | mUsbBusDriverBinding.DriverBindingHandle,\r |
639 | Child,\r | |
640 | EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r | |
641 | );\r | |
642 | \r | |
643 | } else {\r | |
644 | Status = gBS->OpenProtocol (\r | |
645 | Bus->HostHandle,\r | |
646 | &gEfiUsbHcProtocolGuid,\r | |
c52fa98c | 647 | (VOID **) &UsbHc,\r |
e237e7ae | 648 | mUsbBusDriverBinding.DriverBindingHandle,\r |
649 | Child,\r | |
650 | EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r | |
651 | );\r | |
652 | }\r | |
653 | \r | |
654 | return Status;\r | |
655 | }\r | |
656 | \r | |
657 | \r | |
658 | /**\r | |
659 | Close the USB host controller protocol BY_CHILD\r | |
660 | \r | |
661 | @param Bus The USB bus driver\r | |
662 | @param Child The child handle\r | |
663 | \r | |
664 | @return None\r | |
665 | \r | |
666 | **/\r | |
667 | VOID\r | |
668 | UsbCloseHostProtoByChild (\r | |
669 | IN USB_BUS *Bus,\r | |
670 | IN EFI_HANDLE Child\r | |
671 | )\r | |
672 | {\r | |
673 | if (Bus->Usb2Hc != NULL) {\r | |
674 | gBS->CloseProtocol (\r | |
675 | Bus->HostHandle,\r | |
676 | &gEfiUsb2HcProtocolGuid,\r | |
677 | mUsbBusDriverBinding.DriverBindingHandle,\r | |
678 | Child\r | |
679 | );\r | |
680 | \r | |
681 | } else {\r | |
682 | gBS->CloseProtocol (\r | |
683 | Bus->HostHandle,\r | |
684 | &gEfiUsbHcProtocolGuid,\r | |
685 | mUsbBusDriverBinding.DriverBindingHandle,\r | |
686 | Child\r | |
687 | );\r | |
688 | }\r | |
689 | }\r | |
690 | \r | |
691 | \r | |
692 | \r | |
693 | /**\r | |
694 | return the current TPL, copied from the EDKII glue lib.\r | |
695 | \r | |
696 | VOID\r | |
697 | \r | |
698 | @return Current TPL\r | |
699 | \r | |
700 | **/\r | |
701 | EFI_TPL\r | |
702 | UsbGetCurrentTpl (\r | |
703 | VOID\r | |
704 | )\r | |
705 | {\r | |
706 | EFI_TPL Tpl;\r | |
707 | \r | |
708 | Tpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r | |
709 | gBS->RestoreTPL (Tpl);\r | |
710 | \r | |
711 | return Tpl;\r | |
712 | }\r | |
713 | \r | |
714 | \r | |
715 | #ifdef EFI_DEBUG\r | |
716 | VOID\r | |
717 | UsbDebug (\r | |
718 | IN CHAR8 *Format,\r | |
719 | ...\r | |
720 | )\r | |
721 | /*++\r | |
722 | \r | |
723 | Routine Description:\r | |
724 | \r | |
725 | USB's debug output function.\r | |
726 | \r | |
727 | Arguments:\r | |
728 | \r | |
729 | Format - The format parameters to the print\r | |
730 | ... - The variable length parameters after format\r | |
731 | \r | |
732 | Returns:\r | |
733 | \r | |
734 | None\r | |
735 | \r | |
736 | --*/\r | |
737 | {\r | |
738 | VA_LIST Marker;\r | |
739 | \r | |
740 | VA_START (Marker, Format);\r | |
741 | DebugVPrint (DEBUG_INFO, Format, Marker);\r | |
742 | VA_END (Marker);\r | |
743 | }\r | |
744 | \r | |
745 | \r | |
746 | \r | |
747 | /**\r | |
748 | USB's error output function.\r | |
749 | \r | |
750 | @param Format The format parameters to the print\r | |
751 | @param ... The variable length parameters after format\r | |
752 | \r | |
753 | @return None\r | |
754 | \r | |
755 | **/\r | |
756 | VOID\r | |
757 | UsbError (\r | |
758 | IN CHAR8 *Format,\r | |
759 | ...\r | |
760 | )\r | |
761 | {\r | |
762 | VA_LIST Marker;\r | |
763 | \r | |
764 | VA_START (Marker, Format);\r | |
765 | DebugVPrint (DEBUG_ERROR, Format, Marker);\r | |
766 | VA_END (Marker);\r | |
767 | }\r | |
768 | \r | |
769 | #endif\r |