]> git.proxmox.com Git - mirror_edk2.git/blob - EdkModulePkg/Bus/Usb/UsbBus/Dxe/usbbus.h
ce0e69801373a08cfa0217720e8595edee5b4e99
[mirror_edk2.git] / EdkModulePkg / Bus / Usb / UsbBus / Dxe / usbbus.h
1 /*++
2 Copyright (c) 2006, Intel Corporation
3 All rights reserved. This program and the accompanying materials
4 are licensed and made available under the terms and conditions of the BSD License
5 which accompanies this distribution. The full text of the license may be found at
6 http://opensource.org/licenses/bsd-license.php
7
8 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
9 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
10
11 Module Name:
12
13 usbbus.h
14
15 Abstract:
16
17 Header file for USB bus driver Interface
18
19 Revision History
20
21
22
23 --*/
24
25 #ifndef _EFI_USB_BUS_H
26 #define _EFI_USB_BUS_H
27
28
29 #include <IndustryStandard/Usb.h>
30 #include "hub.h"
31 #include "usbutil.h"
32
33
34 extern UINTN gUSBDebugLevel;
35 extern UINTN gUSBErrorLevel;
36
37
38 #define MICROSECOND 10000
39 #define ONESECOND (1000 * MICROSECOND)
40 #define BUSPOLLING_PERIOD ONESECOND
41 //
42 // We define some maximun value here
43 //
44 #define USB_MAXCONFIG 8
45 #define USB_MAXALTSETTING 4
46 #define USB_MAXINTERFACES 32
47 #define USB_MAXENDPOINTS 16
48 #define USB_MAXSTRINGS 16
49 #define USB_MAXLANID 16
50 #define USB_MAXCHILDREN 8
51 #define USB_MAXCONTROLLERS 4
52
53 #define USB_IO_CONTROLLER_SIGNATURE EFI_SIGNATURE_32 ('u', 's', 'b', 'd')
54
55 typedef struct {
56 LIST_ENTRY Link;
57 UINT16 StringIndex;
58 CHAR16 *String;
59 } STR_LIST_ENTRY;
60
61 typedef struct {
62 LIST_ENTRY Link;
63 UINT16 Toggle;
64 EFI_USB_ENDPOINT_DESCRIPTOR EndpointDescriptor;
65 } ENDPOINT_DESC_LIST_ENTRY;
66
67 typedef struct {
68 LIST_ENTRY Link;
69 EFI_USB_INTERFACE_DESCRIPTOR InterfaceDescriptor;
70 LIST_ENTRY EndpointDescListHead;
71 } INTERFACE_DESC_LIST_ENTRY;
72
73 typedef struct {
74 LIST_ENTRY Link;
75 EFI_USB_CONFIG_DESCRIPTOR CongfigDescriptor;
76 LIST_ENTRY InterfaceDescListHead;
77 UINTN ActiveInterface;
78 } CONFIG_DESC_LIST_ENTRY;
79
80 //
81 // Forward declaring
82 //
83 struct usb_io_device;
84
85 //
86 // This is used to form the USB Controller Handle
87 //
88 typedef struct usb_io_controller_device {
89 UINTN Signature;
90 EFI_HANDLE Handle;
91 EFI_USB_IO_PROTOCOL UsbIo;
92 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
93 EFI_HANDLE HostController;
94 UINT8 CurrentConfigValue;
95 UINT8 InterfaceNumber;
96 struct usb_io_device *UsbDevice;
97
98 BOOLEAN IsUsbHub;
99 BOOLEAN IsManagedByDriver;
100
101 //
102 // Fields specified for USB Hub
103 //
104 EFI_EVENT HubNotify;
105 UINT8 HubEndpointAddress;
106 UINT8 StatusChangePort;
107 UINT8 DownstreamPorts;
108
109 UINT8 ParentPort;
110 struct usb_io_controller_device *Parent;
111 struct usb_io_device *Children[USB_MAXCHILDREN];
112 } USB_IO_CONTROLLER_DEVICE;
113
114 #define USB_IO_CONTROLLER_DEVICE_FROM_USB_IO_THIS(a) \
115 CR(a, USB_IO_CONTROLLER_DEVICE, UsbIo, USB_IO_CONTROLLER_SIGNATURE)
116
117 //
118 // This is used to keep the topology of USB bus
119 //
120 struct _usb_bus_controller_device;
121
122 typedef struct usb_io_device {
123 UINT8 DeviceAddress;
124 BOOLEAN IsConfigured;
125 BOOLEAN IsSlowDevice;
126 UINT8 DeviceSpeed;
127 EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator;
128 EFI_USB_DEVICE_DESCRIPTOR DeviceDescriptor;
129 LIST_ENTRY ConfigDescListHead;
130 CONFIG_DESC_LIST_ENTRY *ActiveConfig;
131 UINT16 LangID[USB_MAXLANID];
132
133 struct _usb_bus_controller_device *BusController;
134
135 //
136 // Track the controller handle
137 //
138 UINT8 NumOfControllers;
139 USB_IO_CONTROLLER_DEVICE *UsbController[USB_MAXCONTROLLERS];
140
141 } USB_IO_DEVICE;
142
143 //
144 // Usb Bus Controller device strcuture
145 //
146 #define EFI_USB_BUS_PROTOCOL_GUID \
147 { 0x2B2F68CC, 0x0CD2, 0x44cf, { 0x8E, 0x8B, 0xBB, 0xA2, 0x0B, 0x1B, 0x5B, 0x75 } }
148
149 typedef struct _EFI_USB_BUS_PROTOCOL {
150 UINT64 Reserved;
151 } EFI_USB_BUS_PROTOCOL;
152
153 #define USB_BUS_DEVICE_SIGNATURE EFI_SIGNATURE_32 ('u', 'b', 'u', 's')
154
155 typedef struct _usb_bus_controller_device {
156 UINTN Signature;
157
158 EFI_USB_BUS_PROTOCOL BusIdentify;
159 EFI_USB2_HC_PROTOCOL *Usb2HCInterface;
160 EFI_USB_HC_PROTOCOL *UsbHCInterface;
161 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
162 UINT8 AddressPool[16];
163 USB_IO_DEVICE *Root;
164 BOOLEAN Hc2ProtocolSupported;
165 } USB_BUS_CONTROLLER_DEVICE;
166
167 #define USB_BUS_CONTROLLER_DEVICE_FROM_THIS(a) \
168 CR(a, USB_BUS_CONTROLLER_DEVICE, BusIdentify, USB_BUS_DEVICE_SIGNATURE)
169
170
171 //
172 // Global Variables
173 //
174 extern EFI_DRIVER_BINDING_PROTOCOL gUsbBusDriverBinding;
175 extern EFI_COMPONENT_NAME_PROTOCOL gUsbBusComponentName;
176 extern EFI_GUID gUSBBusDriverGuid;
177
178 //
179 // EFI_DRIVER_BINDING_PROTOCOL Protocol Interface
180 //
181 EFI_STATUS
182 EFIAPI
183 UsbBusControllerDriverSupported (
184 IN EFI_DRIVER_BINDING_PROTOCOL *This,
185 IN EFI_HANDLE Controller,
186 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
187 );
188
189 EFI_STATUS
190 EFIAPI
191 UsbBusControllerDriverStart (
192 IN EFI_DRIVER_BINDING_PROTOCOL *This,
193 IN EFI_HANDLE Controller,
194 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
195 );
196
197 EFI_STATUS
198 EFIAPI
199 UsbBusControllerDriverStop (
200 IN EFI_DRIVER_BINDING_PROTOCOL *This,
201 IN EFI_HANDLE Controller,
202 IN UINTN NumberOfChildren,
203 IN EFI_HANDLE *ChildHandleBuffer
204 );
205
206 //
207 // EFI Component Name Functions
208 //
209 EFI_STATUS
210 EFIAPI
211 UsbBusComponentNameGetDriverName (
212 IN EFI_COMPONENT_NAME_PROTOCOL *This,
213 IN CHAR8 *Language,
214 OUT CHAR16 **DriverName
215 );
216
217 EFI_STATUS
218 EFIAPI
219 UsbBusComponentNameGetControllerName (
220 IN EFI_COMPONENT_NAME_PROTOCOL *This,
221 IN EFI_HANDLE ControllerHandle,
222 IN EFI_HANDLE ChildHandle, OPTIONAL
223 IN CHAR8 *Language,
224 OUT CHAR16 **ControllerName
225 );
226
227 //
228 // Usb Device Configuration functions
229 //
230 BOOLEAN
231 IsHub (
232 IN USB_IO_CONTROLLER_DEVICE *Dev
233 )
234 /*++
235
236 Routine Description:
237 Tell if a usb controller is a hub controller.
238
239 Arguments:
240 Dev - UsbIoController device structure.
241
242 Returns:
243 TRUE/FALSE
244 --*/
245 ;
246
247 EFI_STATUS
248 UsbGetStringtable (
249 IN USB_IO_DEVICE *UsbIoDevice
250 )
251 /*++
252
253 Routine Description:
254 Get the string table stored in a usb device.
255
256 Arguments:
257 Dev - UsbIoController device structure.
258
259 Returns:
260 EFI_SUCCESS
261 EFI_UNSUPPORTED
262 EFI_OUT_OF_RESOURCES
263
264 --*/
265 ;
266
267 EFI_STATUS
268 UsbGetAllConfigurations (
269 IN USB_IO_DEVICE *UsbIoDevice
270 )
271 /*++
272
273 Routine Description:
274 This function is to parse all the configuration descriptor.
275
276 Arguments:
277 UsbIoDevice - USB_IO_DEVICE device structure.
278
279 Returns:
280 EFI_SUCCESS
281 EFI_DEVICE_ERROR
282 EFI_OUT_OF_RESOURCES
283
284 --*/
285 ;
286
287 EFI_STATUS
288 UsbSetConfiguration (
289 IN USB_IO_DEVICE *Dev,
290 IN UINTN ConfigurationValue
291 )
292 /*++
293
294 Routine Description:
295 Set the device to a configuration value.
296
297 Arguments:
298 UsbIoDev - USB_IO_DEVICE to be set configuration
299 ConfigrationValue - The configuration value to be set to that device
300
301 Returns:
302 EFI_SUCCESS
303 EFI_DEVICE_ERROR
304
305 --*/
306 ;
307
308 EFI_STATUS
309 UsbSetDefaultConfiguration (
310 IN USB_IO_DEVICE *Dev
311 )
312 /*++
313
314 Routine Description:
315 Set the device to a default configuration value.
316
317 Arguments:
318 UsbIoDev - USB_IO_DEVICE to be set configuration
319
320 Returns
321 EFI_SUCCESS
322 EFI_DEVICE_ERROR
323
324 --*/
325 ;
326
327 //
328 // Device Deconfiguration functions
329 //
330 VOID
331 UsbDestroyAllConfiguration (
332 IN USB_IO_DEVICE *UsbIoDevice
333 )
334 /*++
335
336 Routine Description:
337 Delete all configuration data when device is not used.
338
339 Arguments:
340 UsbIoDevice - USB_IO_DEVICE to be set configuration
341
342 Returns:
343 VOID
344
345 --*/
346 ;
347
348 EFI_STATUS
349 DoHubConfig (
350 IN USB_IO_CONTROLLER_DEVICE *HubIoDevice
351 )
352 /*++
353
354 Routine Description:
355 Configure the hub
356
357 Arguments:
358 HubController - Indicating the hub controller device that
359 will be configured
360
361 Returns:
362 EFI_SUCCESS
363 EFI_DEVICE_ERROR
364
365 --*/
366
367 ;
368
369 VOID
370 GetDeviceEndPointMaxPacketLength (
371 IN EFI_USB_IO_PROTOCOL *UsbIo,
372 IN UINT8 EndpointAddr,
373 OUT UINTN *MaxPacketLength
374 )
375 /*++
376
377 Routine Description:
378 Get the Max Packet Length of the speified Endpoint.
379
380 Arguments:
381 UsbIo - Given Usb Controller device.
382 EndpointAddr - Given Endpoint address.
383 MaxPacketLength - The max packet length of that endpoint
384
385 Returns:
386 N/A
387
388 --*/
389 ;
390
391 VOID
392 GetDataToggleBit (
393 IN EFI_USB_IO_PROTOCOL *UsbIo,
394 IN UINT8 EndpointAddr,
395 OUT UINT8 *DataToggle
396 )
397 /*++
398
399 Routine Description:
400 Get the datatoggle of a specified endpoint.
401
402 Arguments:
403 UsbIo - Given Usb Controller device.
404 EndpointAddr - Given Endpoint address.
405 DataToggle - The current data toggle of that endpoint
406
407 Returns:
408 VOID
409
410 --*/
411 ;
412
413 VOID
414 SetDataToggleBit (
415 IN EFI_USB_IO_PROTOCOL *UsbIo,
416 IN UINT8 EndpointAddr,
417 IN UINT8 DataToggle
418 )
419 /*++
420
421 Routine Description:
422 Set the datatoggle of a specified endpoint
423
424 Arguments:
425 UsbIo - Given Usb Controller device.
426 EndpointAddr - Given Endpoint address.
427 DataToggle - The current data toggle of that endpoint to be set
428
429 Returns:
430 VOID
431
432 --*/
433 ;
434
435 INTERFACE_DESC_LIST_ENTRY *
436 FindInterfaceListEntry (
437 IN EFI_USB_IO_PROTOCOL *This
438 )
439 /*++
440
441 Routine Description:
442 Find Interface ListEntry.
443
444 Arguments:
445 This - EFI_USB_IO_PROTOCOL
446
447 Returns:
448 INTERFACE_DESC_LIST_ENTRY pointer
449
450 --*/
451 ;
452
453 ENDPOINT_DESC_LIST_ENTRY *
454 FindEndPointListEntry (
455 IN EFI_USB_IO_PROTOCOL *This,
456 IN UINT8 EndPointAddress
457 )
458 /*++
459
460 Routine Description:
461 Find EndPoint ListEntry.
462
463 Arguments:
464 This - EFI_USB_IO_PROTOCOL
465 EndpointAddr - Endpoint address.
466
467 Returns:
468 ENDPOINT_DESC_LIST_ENTRY pointer
469
470 --*/
471 ;
472
473 EFI_STATUS
474 IsDeviceDisconnected (
475 IN USB_IO_CONTROLLER_DEVICE *UsbIoController,
476 IN OUT BOOLEAN *Disconnected
477 )
478 /*++
479
480 Routine Description:
481 Reset if the device is disconencted or not
482
483 Arguments:
484 UsbIoController - Indicating the Usb Controller Device.
485 Disconnected - Indicate whether the device is disconencted or not
486
487 Returns:
488 EFI_SUCCESS
489 EFI_DEVICE_ERROR
490
491 --*/
492 ;
493
494 EFI_STATUS
495 UsbDeviceDeConfiguration (
496 IN USB_IO_DEVICE *UsbIoDevice
497 )
498 /*++
499
500 Routine Description:
501 Remove Device, Device Handles, Uninstall Protocols.
502
503 Arguments:
504 UsbIoDevice - The device to be deconfigured.
505
506 Returns:
507 EFI_SUCCESS
508 EFI_DEVICE_ERROR
509
510 --*/
511 ;
512
513 EFI_STATUS
514 EFIAPI
515 UsbVirtualHcGetCapability (
516 IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
517 OUT UINT8 *MaxSpeed,
518 OUT UINT8 *PortNumber,
519 OUT UINT8 *Is64BitCapable
520 )
521 /*++
522
523 Routine Description:
524
525 Virtual interface to Retrieves the capablility of root hub ports
526 for both Hc2 and Hc protocol.
527
528 Arguments:
529
530 UsbBusDev - A pointer to bus controller of the device.
531 MaxSpeed - A pointer to the number of the host controller.
532 PortNumber - A pointer to the number of the root hub ports.
533 Is64BitCapable - A pointer to the flag for whether controller supports
534 64-bit memory addressing.
535
536 Returns:
537
538 EFI_SUCCESS
539 The host controller capability were retrieved successfully.
540 EFI_INVALID_PARAMETER
541 MaxSpeed or PortNumber or Is64BitCapable is NULL.
542 EFI_DEVICE_ERROR
543 An error was encountered while attempting to retrieve the capabilities.
544
545 --*/
546 ;
547
548 EFI_STATUS
549 EFIAPI
550 UsbVirtualHcReset (
551 IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
552 IN UINT16 Attributes
553 )
554 /*++
555
556 Routine Description:
557
558 Virtual interface to provides software reset for the USB host controller
559 for both Hc2 and Hc protocol.
560
561 Arguments:
562
563 UsbBusDev - A pointer to bus controller of the device.
564 Attributes - A bit mask of the reset operation to perform.
565 See below for a list of the supported bit mask values.
566
567 #define EFI_USB_HC_RESET_GLOBAL 0x0001 // Hc2 and Hc
568 #define EFI_USB_HC_RESET_HOST_CONTROLLER 0x0002 // Hc2 and Hc
569 #define EFI_USB_HC_RESET_GLOBAL_WITH_DEBUG 0x0004 // Hc2
570 #define EFI_USB_HC_RESET_HOST_WITH_DEBUG 0x0008 // Hc2
571
572 EFI_USB_HC_RESET_GLOBAL
573 If this bit is set, a global reset signal will be sent to the USB bus.
574 This resets all of the USB bus logic, including the USB host
575 controller hardware and all the devices attached on the USB bus.
576 EFI_USB_HC_RESET_HOST_CONTROLLER
577 If this bit is set, the USB host controller hardware will be reset.
578 No reset signal will be sent to the USB bus.
579 EFI_USB_HC_RESET_GLOBAL_WITH_DEBUG
580 If this bit is set, a global reset signal will be sent to the USB bus.
581 This resets all of the USB bus logic, including the USB host
582 controller hardware and all the devices attached on the USB bus.
583 If this is an EHCI controller and the debug port has configured, then
584 this is will still reset the host controller.
585 EFI_USB_HC_RESET_HOST_WITH_DEBUG
586 If this bit is set, the USB host controller hardware will be reset.
587 If this is an EHCI controller and the debug port has been configured,
588 then this will still reset the host controller.
589
590 Returns:
591
592 EFI_SUCCESS
593 The reset operation succeeded.
594 EFI_INVALID_PARAMETER
595 Attributes is not valid.
596 EFI_UNSUPPOURTED
597 The type of reset specified by Attributes is not currently supported by
598 the host controller hardware.
599 EFI_ACCESS_DENIED
600 Reset operation is rejected due to the debug port being configured and
601 active; only EFI_USB_HC_RESET_GLOBAL_WITH_DEBUG or
602 EFI_USB_HC_RESET_HOST_WITH_DEBUG reset Atrributes can be used to
603 perform reset operation for this host controller.
604 EFI_DEVICE_ERROR
605 An error was encountered while attempting to perform
606 the reset operation.
607
608 --*/
609 ;
610
611 EFI_STATUS
612 EFIAPI
613 UsbVirtualHcGetState (
614 IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
615 OUT EFI_USB_HC_STATE *State
616 )
617 /*++
618
619 Routine Description:
620
621 Virtual interface to retrieves current state of the USB host controller
622 for both Hc2 and Hc protocol.
623
624 Arguments:
625
626 UsbBusDev - A pointer to bus controller of the device.
627 State - A pointer to the EFI_USB_HC_STATE data structure that
628 indicates current state of the USB host controller.
629 Type EFI_USB_HC_STATE is defined below.
630
631 typedef enum {
632 EfiUsbHcStateHalt,
633 EfiUsbHcStateOperational,
634 EfiUsbHcStateSuspend,
635 EfiUsbHcStateMaximum
636 } EFI_USB_HC_STATE;
637
638 Returns:
639
640 EFI_SUCCESS
641 The state information of the host controller was returned in State.
642 EFI_INVALID_PARAMETER
643 State is NULL.
644 EFI_DEVICE_ERROR
645 An error was encountered while attempting to retrieve the
646 host controller's current state.
647
648 --*/
649 ;
650
651 EFI_STATUS
652 EFIAPI
653 UsbVirtualHcSetState (
654 IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
655 IN EFI_USB_HC_STATE State
656 )
657 /*++
658
659 Routine Description:
660
661 Virtual interface to sets the USB host controller to a specific state
662 for both Hc2 and Hc protocol.
663
664 Arguments:
665
666 UsbBusDev - A pointer to bus controller of the device.
667 State - Indicates the state of the host controller that will be set.
668
669 Returns:
670
671 EFI_SUCCESS
672 The USB host controller was successfully placed in the state
673 specified by State.
674 EFI_INVALID_PARAMETER
675 State is invalid.
676 EFI_DEVICE_ERROR
677 Failed to set the state specified by State due to device error.
678
679 --*/
680 ;
681
682 EFI_STATUS
683 EFIAPI
684 UsbVirtualHcGetRootHubPortStatus (
685 IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
686 IN UINT8 PortNumber,
687 OUT EFI_USB_PORT_STATUS *PortStatus
688 )
689 /*++
690
691 Routine Description:
692
693 Virtual interface to retrieves the current status of a USB root hub port
694 both for Hc2 and Hc protocol.
695
696 Arguments:
697
698 UsbBusDev - A pointer to bus controller of the device.
699 PortNumber - Specifies the root hub port from which the status
700 is to be retrieved. This value is zero-based. For example,
701 if a root hub has two ports, then the first port is numbered 0,
702 and the second port is numbered 1.
703 PortStatus - A pointer to the current port status bits and
704 port status change bits.
705
706 Returns:
707
708 EFI_SUCCESS The status of the USB root hub port specified by PortNumber
709 was returned in PortStatus.
710 EFI_INVALID_PARAMETER PortNumber is invalid.
711 EFI_DEVICE_ERROR Can't read register
712
713 --*/
714 ;
715
716 EFI_STATUS
717 EFIAPI
718 UsbVirtualHcSetRootHubPortFeature (
719 IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
720 IN UINT8 PortNumber,
721 IN EFI_USB_PORT_FEATURE PortFeature
722 )
723 /*++
724
725 Routine Description:
726 Virual interface to sets a feature for the specified root hub port
727 for both Hc2 and Hc protocol.
728
729 Arguments:
730
731 UsbBusDev - A pointer to bus controller of the device.
732 PortNumber - Specifies the root hub port whose feature
733 is requested to be set.
734 PortFeature - Indicates the feature selector associated
735 with the feature set request.
736
737 Returns:
738
739 EFI_SUCCESS
740 The feature specified by PortFeature was set for the
741 USB root hub port specified by PortNumber.
742 EFI_INVALID_PARAMETER
743 PortNumber is invalid or PortFeature is invalid.
744 EFI_DEVICE_ERROR
745 Can't read register
746
747 --*/
748 ;
749
750 EFI_STATUS
751 EFIAPI
752 UsbVirtualHcClearRootHubPortFeature (
753 IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
754 IN UINT8 PortNumber,
755 IN EFI_USB_PORT_FEATURE PortFeature
756 )
757 /*++
758
759 Routine Description:
760
761 Virtual interface to clears a feature for the specified root hub port
762 for both Hc2 and Hc protocol.
763
764 Arguments:
765
766 UsbBusDev - A pointer to bus controller of the device.
767 PortNumber - Specifies the root hub port whose feature
768 is requested to be cleared.
769 PortFeature - Indicates the feature selector associated with the
770 feature clear request.
771
772 Returns:
773
774 EFI_SUCCESS
775 The feature specified by PortFeature was cleared for the
776 USB root hub port specified by PortNumber.
777 EFI_INVALID_PARAMETER
778 PortNumber is invalid or PortFeature is invalid.
779 EFI_DEVICE_ERROR
780 Can't read register
781
782 --*/
783 ;
784
785 EFI_STATUS
786 EFIAPI
787 UsbVirtualHcControlTransfer (
788 IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
789 IN UINT8 DeviceAddress,
790 IN UINT8 DeviceSpeed,
791 IN UINTN MaximumPacketLength,
792 IN EFI_USB_DEVICE_REQUEST *Request,
793 IN EFI_USB_DATA_DIRECTION TransferDirection,
794 IN OUT VOID *Data,
795 IN OUT UINTN *DataLength,
796 IN UINTN TimeOut,
797 IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
798 OUT UINT32 *TransferResult
799 )
800 /*++
801
802 Routine Description:
803
804 Virtual interface to submits control transfer to a target USB device
805 for both Hc2 and Hc protocol.
806
807 Arguments:
808
809 UsbBusDev - A pointer to bus controller of the device.
810 DeviceAddress - Represents the address of the target device on the USB,
811 which is assigned during USB enumeration.
812 DeviceSpeed - Indicates target device speed.
813 MaximumPacketLength - Indicates the maximum packet size that the
814 default control transfer endpoint is capable of
815 sending or receiving.
816 Request - A pointer to the USB device request that will be sent
817 to the USB device.
818 TransferDirection - Specifies the data direction for the transfer.
819 There are three values available, DataIn, DataOut
820 and NoData.
821 Data - A pointer to the buffer of data that will be transmitted
822 to USB device or received from USB device.
823 DataLength - Indicates the size, in bytes, of the data buffer
824 specified by Data.
825 TimeOut - Indicates the maximum time, in microseconds,
826 which the transfer is allowed to complete.
827 Translator - A pointr to the transaction translator data.
828 TransferResult - A pointer to the detailed result information generated
829 by this control transfer.
830
831 Returns:
832
833 EFI_SUCCESS
834 The control transfer was completed successfully.
835 EFI_OUT_OF_RESOURCES
836 The control transfer could not be completed due to a lack of resources.
837 EFI_INVALID_PARAMETER
838 Some parameters are invalid.
839 EFI_TIMEOUT
840 The control transfer failed due to timeout.
841 EFI_DEVICE_ERROR
842 The control transfer failed due to host controller or device error.
843 Caller should check TranferResult for detailed error information.
844
845 --*/
846 ;
847
848 EFI_STATUS
849 EFIAPI
850 UsbVirtualHcBulkTransfer (
851 IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
852 IN UINT8 DeviceAddress,
853 IN UINT8 EndPointAddress,
854 IN UINT8 DeviceSpeed,
855 IN UINTN MaximumPacketLength,
856 IN UINT8 DataBuffersNumber,
857 IN OUT VOID *Data[EFI_USB_MAX_BULK_BUFFER_NUM],
858 IN OUT UINTN *DataLength,
859 IN OUT UINT8 *DataToggle,
860 IN UINTN TimeOut,
861 IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
862 OUT UINT32 *TransferResult
863 )
864 /*++
865
866 Routine Description:
867
868 Virtual interface to submits bulk transfer to a bulk endpoint of a USB device
869 both for Hc2 and Hc protocol.
870
871 Arguments:
872
873 UsbBusDev - A pointer to bus controller of the device.
874 DeviceAddress - Represents the address of the target device on the USB,
875 which is assigned during USB enumeration.
876 EndPointAddress - The combination of an endpoint number and an
877 endpoint direction of the target USB device.
878 Each endpoint address supports data transfer in
879 one direction except the control endpoint
880 (whose default endpoint address is 0).
881 It is the caller's responsibility to make sure that
882 the EndPointAddress represents a bulk endpoint.
883 DeviceSpeed - Indicates device speed. The supported values are EFI_USB_SPEED_FULL
884 and EFI_USB_SPEED_HIGH.
885 MaximumPacketLength - Indicates the maximum packet size the target endpoint
886 is capable of sending or receiving.
887 DataBuffersNumber - Number of data buffers prepared for the transfer.
888 Data - Array of pointers to the buffers of data that will be transmitted
889 to USB device or received from USB device.
890 DataLength - When input, indicates the size, in bytes, of the data buffer
891 specified by Data. When output, indicates the actually
892 transferred data size.
893 DataToggle - A pointer to the data toggle value. On input, it indicates
894 the initial data toggle value the bulk transfer should adopt;
895 on output, it is updated to indicate the data toggle value
896 of the subsequent bulk transfer.
897 Translator - A pointr to the transaction translator data.
898 TimeOut - Indicates the maximum time, in microseconds, which the
899 transfer is allowed to complete.
900 TransferResult - A pointer to the detailed result information of the
901 bulk transfer.
902
903 Returns:
904
905 EFI_SUCCESS
906 The bulk transfer was completed successfully.
907 EFI_OUT_OF_RESOURCES
908 The bulk transfer could not be submitted due to lack of resource.
909 EFI_INVALID_PARAMETER
910 Some parameters are invalid.
911 EFI_TIMEOUT
912 The bulk transfer failed due to timeout.
913 EFI_DEVICE_ERROR
914 The bulk transfer failed due to host controller or device error.
915 Caller should check TranferResult for detailed error information.
916
917 --*/
918 ;
919
920 EFI_STATUS
921 EFIAPI
922 UsbVirtualHcAsyncInterruptTransfer (
923 IN USB_BUS_CONTROLLER_DEVICE * UsbBusDev,
924 IN UINT8 DeviceAddress,
925 IN UINT8 EndPointAddress,
926 IN UINT8 DeviceSpeed,
927 IN UINTN MaximumPacketLength,
928 IN BOOLEAN IsNewTransfer,
929 IN OUT UINT8 *DataToggle,
930 IN UINTN PollingInterval,
931 IN UINTN DataLength,
932 IN EFI_USB2_HC_TRANSACTION_TRANSLATOR * Translator,
933 IN EFI_ASYNC_USB_TRANSFER_CALLBACK CallBackFunction,
934 IN VOID *Context OPTIONAL
935 )
936 /*++
937
938 Routine Description:
939
940 Virtual interface to submits an asynchronous interrupt transfer to an
941 interrupt endpoint of a USB device for both Hc2 and Hc protocol.
942
943 Arguments:
944
945 UsbBusDev - A pointer to bus controller of the device.
946 DeviceAddress - Represents the address of the target device on the USB,
947 which is assigned during USB enumeration.
948 EndPointAddress - The combination of an endpoint number and an endpoint
949 direction of the target USB device. Each endpoint address
950 supports data transfer in one direction except the
951 control endpoint (whose default endpoint address is 0).
952 It is the caller's responsibility to make sure that
953 the EndPointAddress represents an interrupt endpoint.
954 DeviceSpeed - Indicates device speed.
955 MaximumPacketLength - Indicates the maximum packet size the target endpoint
956 is capable of sending or receiving.
957 IsNewTransfer - If TRUE, an asynchronous interrupt pipe is built between
958 the host and the target interrupt endpoint.
959 If FALSE, the specified asynchronous interrupt pipe
960 is canceled.
961 DataToggle - A pointer to the data toggle value. On input, it is valid
962 when IsNewTransfer is TRUE, and it indicates the initial
963 data toggle value the asynchronous interrupt transfer
964 should adopt.
965 On output, it is valid when IsNewTransfer is FALSE,
966 and it is updated to indicate the data toggle value of
967 the subsequent asynchronous interrupt transfer.
968 PollingInterval - Indicates the interval, in milliseconds, that the
969 asynchronous interrupt transfer is polled.
970 This parameter is required when IsNewTransfer is TRUE.
971 DataLength - Indicates the length of data to be received at the
972 rate specified by PollingInterval from the target
973 asynchronous interrupt endpoint. This parameter
974 is only required when IsNewTransfer is TRUE.
975 Translator - A pointr to the transaction translator data.
976 CallBackFunction - The Callback function.This function is called at the
977 rate specified by PollingInterval.This parameter is
978 only required when IsNewTransfer is TRUE.
979 Context - The context that is passed to the CallBackFunction.
980 - This is an optional parameter and may be NULL.
981
982 Returns:
983
984 EFI_SUCCESS
985 The asynchronous interrupt transfer request has been successfully
986 submitted or canceled.
987 EFI_INVALID_PARAMETER
988 Some parameters are invalid.
989 EFI_OUT_OF_RESOURCES
990 The request could not be completed due to a lack of resources.
991 EFI_DEVICE_ERROR
992 Can't read register
993
994 --*/
995 ;
996
997 EFI_STATUS
998 EFIAPI
999 UsbVirtualHcSyncInterruptTransfer (
1000 IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
1001 IN UINT8 DeviceAddress,
1002 IN UINT8 EndPointAddress,
1003 IN UINT8 DeviceSpeed,
1004 IN UINTN MaximumPacketLength,
1005 IN OUT VOID *Data,
1006 IN OUT UINTN *DataLength,
1007 IN OUT UINT8 *DataToggle,
1008 IN UINTN TimeOut,
1009 IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
1010 OUT UINT32 *TransferResult
1011 )
1012 /*++
1013
1014 Routine Description:
1015
1016 Vitual interface to submits synchronous interrupt transfer to an interrupt endpoint
1017 of a USB device for both Hc2 and Hc protocol.
1018
1019 Arguments:
1020
1021 UsbBusDev - A pointer to bus controller of the device.
1022 DeviceAddress - Represents the address of the target device on the USB,
1023 which is assigned during USB enumeration.
1024 EndPointAddress - The combination of an endpoint number and an endpoint
1025 direction of the target USB device. Each endpoint
1026 address supports data transfer in one direction
1027 except the control endpoint (whose default
1028 endpoint address is 0). It is the caller's responsibility
1029 to make sure that the EndPointAddress represents
1030 an interrupt endpoint.
1031 DeviceSpeed - Indicates device speed.
1032 MaximumPacketLength - Indicates the maximum packet size the target endpoint
1033 is capable of sending or receiving.
1034 Data - A pointer to the buffer of data that will be transmitted
1035 to USB device or received from USB device.
1036 DataLength - On input, the size, in bytes, of the data buffer specified
1037 by Data. On output, the number of bytes transferred.
1038 DataToggle - A pointer to the data toggle value. On input, it indicates
1039 the initial data toggle value the synchronous interrupt
1040 transfer should adopt;
1041 on output, it is updated to indicate the data toggle value
1042 of the subsequent synchronous interrupt transfer.
1043 TimeOut - Indicates the maximum time, in microseconds, which the
1044 transfer is allowed to complete.
1045 Translator - A pointr to the transaction translator data.
1046 TransferResult - A pointer to the detailed result information from
1047 the synchronous interrupt transfer.
1048
1049 Returns:
1050
1051 EFI_SUCCESS
1052 The synchronous interrupt transfer was completed successfully.
1053 EFI_OUT_OF_RESOURCES
1054 The synchronous interrupt transfer could not be submitted due
1055 to lack of resource.
1056 EFI_INVALID_PARAMETER
1057 Some parameters are invalid.
1058 EFI_TIMEOUT
1059 The synchronous interrupt transfer failed due to timeout.
1060 EFI_DEVICE_ERROR
1061 The synchronous interrupt transfer failed due to host controller
1062 or device error. Caller should check TranferResult for detailed
1063 error information.
1064
1065 --*/
1066 ;
1067
1068 EFI_STATUS
1069 EFIAPI
1070 UsbVirtualHcIsochronousTransfer (
1071 IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
1072 IN UINT8 DeviceAddress,
1073 IN UINT8 EndPointAddress,
1074 IN UINT8 DeviceSpeed,
1075 IN UINTN MaximumPacketLength,
1076 IN UINT8 DataBuffersNumber,
1077 IN OUT VOID *Data[EFI_USB_MAX_ISO_BUFFER_NUM],
1078 IN UINTN DataLength,
1079 IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
1080 OUT UINT32 *TransferResult
1081 )
1082 /*++
1083
1084 Routine Description:
1085
1086 Virtual interface to submits isochronous transfer to a target USB device
1087 for both Hc2 and Hc protocol.
1088
1089 Arguments:
1090
1091 UsbBusDev - A pointer to bus controller of the device.
1092 DeviceAddress - Represents the address of the target device on the USB,
1093 which is assigned during USB enumeration.
1094 EndPointAddress - End point address
1095 DeviceSpeed - Indicates device speed.
1096 MaximumPacketLength - Indicates the maximum packet size that the
1097 default control transfer endpoint is capable of
1098 sending or receiving.
1099 DataBuffersNumber - Number of data buffers prepared for the transfer.
1100 Data - Array of pointers to the buffers of data that will be
1101 transmitted to USB device or received from USB device.
1102 DataLength - Indicates the size, in bytes, of the data buffer
1103 specified by Data.
1104 Translator - A pointr to the transaction translator data.
1105 TransferResult - A pointer to the detailed result information generated
1106 by this control transfer.
1107
1108 Returns:
1109
1110 EFI_UNSUPPORTED
1111
1112 --*/
1113 ;
1114
1115 EFI_STATUS
1116 EFIAPI
1117 UsbVirtualHcAsyncIsochronousTransfer (
1118 IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
1119 IN UINT8 DeviceAddress,
1120 IN UINT8 EndPointAddress,
1121 IN UINT8 DeviceSpeed,
1122 IN UINTN MaximumPacketLength,
1123 IN UINT8 DataBuffersNumber,
1124 IN OUT VOID *Data[EFI_USB_MAX_ISO_BUFFER_NUM],
1125 IN UINTN DataLength,
1126 IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
1127 IN EFI_ASYNC_USB_TRANSFER_CALLBACK IsochronousCallBack,
1128 IN VOID *Context
1129 )
1130 /*++
1131
1132 Routine Description:
1133
1134 Vitual interface to submits Async isochronous transfer to a target USB device
1135 for both Hc2 and Hc protocol.
1136
1137 Arguments:
1138
1139 UsbBusDev - A pointer to bus controller of the device.
1140 DeviceAddress - Represents the address of the target device on the USB,
1141 which is assigned during USB enumeration.
1142 EndPointAddress - End point address
1143 DeviceSpeed - Indicates device speed.
1144 MaximumPacketLength - Indicates the maximum packet size that the
1145 default control transfer endpoint is capable of
1146 sending or receiving.
1147 DataBuffersNumber - Number of data buffers prepared for the transfer.
1148 Data - Array of pointers to the buffers of data that will be transmitted
1149 to USB device or received from USB device.
1150 DataLength - Indicates the size, in bytes, of the data buffer
1151 specified by Data.
1152 Translator - A pointr to the transaction translator data.
1153 IsochronousCallBack - When the transfer complete, the call back function will be called
1154 Context - Pass to the call back function as parameter
1155
1156 Returns:
1157
1158 EFI_UNSUPPORTED
1159
1160 --*/
1161 ;
1162
1163 EFI_STATUS
1164 EFIAPI
1165 UsbPortReset (
1166 IN EFI_USB_IO_PROTOCOL *This
1167 )
1168 /*++
1169
1170 Routine Description:
1171 Resets and reconfigures the USB controller. This function will
1172 work for all USB devices except USB Hub Controllers.
1173
1174 Arguments:
1175 This - Indicates the calling context.
1176
1177 Returns:
1178 EFI_SUCCESS
1179 EFI_INVALID_PARAMETER
1180 EFI_DEVICE_ERROR
1181
1182 --*/
1183 ;
1184
1185 VOID
1186 InitializeUsbIoInstance (
1187 IN USB_IO_CONTROLLER_DEVICE *UsbIoController
1188 )
1189 /*++
1190
1191 Routine Description:
1192
1193 Initialize the instance of UsbIo controller
1194
1195 Arguments:
1196
1197 UsbIoController - A pointer to controller structure of UsbIo
1198
1199 Returns:
1200
1201 --*/
1202 ;
1203
1204 #endif