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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
|
/*++
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:
usbbus.h
Abstract:
Header file for USB bus driver Interface
Revision History
--*/
#ifndef _EFI_USB_BUS_H
#define _EFI_USB_BUS_H
#include <IndustryStandard/Usb.h>
#include "hub.h"
#include "usbutil.h"
GLOBAL_REMOVE_IF_UNREFERENCED extern UINTN gUSBDebugLevel;
GLOBAL_REMOVE_IF_UNREFERENCED extern UINTN gUSBErrorLevel;
#define MICROSECOND 10000
#define ONESECOND (1000 * MICROSECOND)
#define BUSPOLLING_PERIOD ONESECOND
//
// We define some maximun value here
//
#define USB_MAXCONFIG 8
#define USB_MAXALTSETTING 4
#define USB_MAXINTERFACES 32
#define USB_MAXENDPOINTS 16
#define USB_MAXSTRINGS 16
#define USB_MAXLANID 16
#define USB_MAXCHILDREN 8
#define USB_MAXCONTROLLERS 4
#define USB_IO_CONTROLLER_SIGNATURE EFI_SIGNATURE_32 ('u', 's', 'b', 'd')
typedef struct {
LIST_ENTRY Link;
UINT16 StringIndex;
CHAR16 *String;
} STR_LIST_ENTRY;
typedef struct {
LIST_ENTRY Link;
UINT16 Toggle;
EFI_USB_ENDPOINT_DESCRIPTOR EndpointDescriptor;
} ENDPOINT_DESC_LIST_ENTRY;
typedef struct {
LIST_ENTRY Link;
EFI_USB_INTERFACE_DESCRIPTOR InterfaceDescriptor;
LIST_ENTRY EndpointDescListHead;
} INTERFACE_DESC_LIST_ENTRY;
typedef struct {
LIST_ENTRY Link;
EFI_USB_CONFIG_DESCRIPTOR CongfigDescriptor;
LIST_ENTRY InterfaceDescListHead;
UINTN ActiveInterface;
} CONFIG_DESC_LIST_ENTRY;
//
// Forward declaring
//
struct usb_io_device;
//
// This is used to form the USB Controller Handle
//
typedef struct usb_io_controller_device {
UINTN Signature;
EFI_HANDLE Handle;
EFI_USB_IO_PROTOCOL UsbIo;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
EFI_HANDLE HostController;
UINT8 CurrentConfigValue;
UINT8 InterfaceNumber;
struct usb_io_device *UsbDevice;
BOOLEAN IsUsbHub;
BOOLEAN IsManagedByDriver;
//
// Fields specified for USB Hub
//
EFI_EVENT HubNotify;
UINT8 HubEndpointAddress;
UINT8 StatusChangePort;
UINT8 DownstreamPorts;
UINT8 ParentPort;
struct usb_io_controller_device *Parent;
struct usb_io_device *Children[USB_MAXCHILDREN];
} USB_IO_CONTROLLER_DEVICE;
#define USB_IO_CONTROLLER_DEVICE_FROM_USB_IO_THIS(a) \
CR(a, USB_IO_CONTROLLER_DEVICE, UsbIo, USB_IO_CONTROLLER_SIGNATURE)
//
// This is used to keep the topology of USB bus
//
struct _usb_bus_controller_device;
typedef struct usb_io_device {
UINT8 DeviceAddress;
BOOLEAN IsConfigured;
BOOLEAN IsSlowDevice;
UINT8 DeviceSpeed;
EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator;
EFI_USB_DEVICE_DESCRIPTOR DeviceDescriptor;
LIST_ENTRY ConfigDescListHead;
CONFIG_DESC_LIST_ENTRY *ActiveConfig;
UINT16 LangID[USB_MAXLANID];
struct _usb_bus_controller_device *BusController;
//
// Track the controller handle
//
UINT8 NumOfControllers;
USB_IO_CONTROLLER_DEVICE *UsbController[USB_MAXCONTROLLERS];
} USB_IO_DEVICE;
//
// Usb Bus Controller device strcuture
//
#define EFI_USB_BUS_PROTOCOL_GUID \
{ 0x2B2F68CC, 0x0CD2, 0x44cf, { 0x8E, 0x8B, 0xBB, 0xA2, 0x0B, 0x1B, 0x5B, 0x75 } }
typedef struct _EFI_USB_BUS_PROTOCOL {
UINT64 Reserved;
} EFI_USB_BUS_PROTOCOL;
#define USB_BUS_DEVICE_SIGNATURE EFI_SIGNATURE_32 ('u', 'b', 'u', 's')
typedef struct _usb_bus_controller_device {
UINTN Signature;
EFI_USB_BUS_PROTOCOL BusIdentify;
EFI_USB2_HC_PROTOCOL *Usb2HCInterface;
EFI_USB_HC_PROTOCOL *UsbHCInterface;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
UINT8 AddressPool[16];
USB_IO_DEVICE *Root;
BOOLEAN Hc2ProtocolSupported;
} USB_BUS_CONTROLLER_DEVICE;
#define USB_BUS_CONTROLLER_DEVICE_FROM_THIS(a) \
CR(a, USB_BUS_CONTROLLER_DEVICE, BusIdentify, USB_BUS_DEVICE_SIGNATURE)
//
// Global Variables
//
extern EFI_DRIVER_BINDING_PROTOCOL gUsbBusDriverBinding;
extern EFI_COMPONENT_NAME_PROTOCOL gUsbBusComponentName;
extern EFI_GUID gUSBBusDriverGuid;
//
// Usb Device Configuration functions
//
BOOLEAN
IsHub (
IN USB_IO_CONTROLLER_DEVICE *Dev
)
/*++
Routine Description:
Tell if a usb controller is a hub controller.
Arguments:
Dev - UsbIoController device structure.
Returns:
TRUE/FALSE
--*/
;
EFI_STATUS
UsbGetStringtable (
IN USB_IO_DEVICE *UsbIoDevice
)
/*++
Routine Description:
Get the string table stored in a usb device.
Arguments:
Dev - UsbIoController device structure.
Returns:
EFI_SUCCESS
EFI_UNSUPPORTED
EFI_OUT_OF_RESOURCES
--*/
;
EFI_STATUS
UsbGetAllConfigurations (
IN USB_IO_DEVICE *UsbIoDevice
)
/*++
Routine Description:
This function is to parse all the configuration descriptor.
Arguments:
UsbIoDevice - USB_IO_DEVICE device structure.
Returns:
EFI_SUCCESS
EFI_DEVICE_ERROR
EFI_OUT_OF_RESOURCES
--*/
;
EFI_STATUS
UsbSetConfiguration (
IN USB_IO_DEVICE *Dev,
IN UINTN ConfigurationValue
)
/*++
Routine Description:
Set the device to a configuration value.
Arguments:
UsbIoDev - USB_IO_DEVICE to be set configuration
ConfigrationValue - The configuration value to be set to that device
Returns:
EFI_SUCCESS
EFI_DEVICE_ERROR
--*/
;
EFI_STATUS
UsbSetDefaultConfiguration (
IN USB_IO_DEVICE *Dev
)
/*++
Routine Description:
Set the device to a default configuration value.
Arguments:
UsbIoDev - USB_IO_DEVICE to be set configuration
Returns
EFI_SUCCESS
EFI_DEVICE_ERROR
--*/
;
//
// Device Deconfiguration functions
//
VOID
UsbDestroyAllConfiguration (
IN USB_IO_DEVICE *UsbIoDevice
)
/*++
Routine Description:
Delete all configuration data when device is not used.
Arguments:
UsbIoDevice - USB_IO_DEVICE to be set configuration
Returns:
VOID
--*/
;
EFI_STATUS
DoHubConfig (
IN USB_IO_CONTROLLER_DEVICE *HubIoDevice
)
/*++
Routine Description:
Configure the hub
Arguments:
HubController - Indicating the hub controller device that
will be configured
Returns:
EFI_SUCCESS
EFI_DEVICE_ERROR
--*/
;
VOID
GetDeviceEndPointMaxPacketLength (
IN EFI_USB_IO_PROTOCOL *UsbIo,
IN UINT8 EndpointAddr,
OUT UINTN *MaxPacketLength
)
/*++
Routine Description:
Get the Max Packet Length of the speified Endpoint.
Arguments:
UsbIo - Given Usb Controller device.
EndpointAddr - Given Endpoint address.
MaxPacketLength - The max packet length of that endpoint
Returns:
N/A
--*/
;
VOID
GetDataToggleBit (
IN EFI_USB_IO_PROTOCOL *UsbIo,
IN UINT8 EndpointAddr,
OUT UINT8 *DataToggle
)
/*++
Routine Description:
Get the datatoggle of a specified endpoint.
Arguments:
UsbIo - Given Usb Controller device.
EndpointAddr - Given Endpoint address.
DataToggle - The current data toggle of that endpoint
Returns:
VOID
--*/
;
VOID
SetDataToggleBit (
IN EFI_USB_IO_PROTOCOL *UsbIo,
IN UINT8 EndpointAddr,
IN UINT8 DataToggle
)
/*++
Routine Description:
Set the datatoggle of a specified endpoint
Arguments:
UsbIo - Given Usb Controller device.
EndpointAddr - Given Endpoint address.
DataToggle - The current data toggle of that endpoint to be set
Returns:
VOID
--*/
;
INTERFACE_DESC_LIST_ENTRY *
FindInterfaceListEntry (
IN EFI_USB_IO_PROTOCOL *This
)
/*++
Routine Description:
Find Interface ListEntry.
Arguments:
This - EFI_USB_IO_PROTOCOL
Returns:
INTERFACE_DESC_LIST_ENTRY pointer
--*/
;
ENDPOINT_DESC_LIST_ENTRY *
FindEndPointListEntry (
IN EFI_USB_IO_PROTOCOL *This,
IN UINT8 EndPointAddress
)
/*++
Routine Description:
Find EndPoint ListEntry.
Arguments:
This - EFI_USB_IO_PROTOCOL
EndpointAddr - Endpoint address.
Returns:
ENDPOINT_DESC_LIST_ENTRY pointer
--*/
;
EFI_STATUS
IsDeviceDisconnected (
IN USB_IO_CONTROLLER_DEVICE *UsbIoController,
IN OUT BOOLEAN *Disconnected
)
/*++
Routine Description:
Reset if the device is disconencted or not
Arguments:
UsbIoController - Indicating the Usb Controller Device.
Disconnected - Indicate whether the device is disconencted or not
Returns:
EFI_SUCCESS
EFI_DEVICE_ERROR
--*/
;
EFI_STATUS
UsbDeviceDeConfiguration (
IN USB_IO_DEVICE *UsbIoDevice
)
/*++
Routine Description:
Remove Device, Device Handles, Uninstall Protocols.
Arguments:
UsbIoDevice - The device to be deconfigured.
Returns:
EFI_SUCCESS
EFI_DEVICE_ERROR
--*/
;
EFI_STATUS
EFIAPI
UsbVirtualHcGetCapability (
IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
OUT UINT8 *MaxSpeed,
OUT UINT8 *PortNumber,
OUT UINT8 *Is64BitCapable
)
/*++
Routine Description:
Virtual interface to Retrieves the capablility of root hub ports
for both Hc2 and Hc protocol.
Arguments:
UsbBusDev - A pointer to bus controller of the device.
MaxSpeed - A pointer to the number of the host controller.
PortNumber - A pointer to the number of the root hub ports.
Is64BitCapable - A pointer to the flag for whether controller supports
64-bit memory addressing.
Returns:
EFI_SUCCESS
The host controller capability were retrieved successfully.
EFI_INVALID_PARAMETER
MaxSpeed or PortNumber or Is64BitCapable is NULL.
EFI_DEVICE_ERROR
An error was encountered while attempting to retrieve the capabilities.
--*/
;
EFI_STATUS
EFIAPI
UsbVirtualHcReset (
IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
IN UINT16 Attributes
)
/*++
Routine Description:
Virtual interface to provides software reset for the USB host controller
for both Hc2 and Hc protocol.
Arguments:
UsbBusDev - A pointer to bus controller of the device.
Attributes - A bit mask of the reset operation to perform.
See below for a list of the supported bit mask values.
#define EFI_USB_HC_RESET_GLOBAL 0x0001 // Hc2 and Hc
#define EFI_USB_HC_RESET_HOST_CONTROLLER 0x0002 // Hc2 and Hc
#define EFI_USB_HC_RESET_GLOBAL_WITH_DEBUG 0x0004 // Hc2
#define EFI_USB_HC_RESET_HOST_WITH_DEBUG 0x0008 // Hc2
EFI_USB_HC_RESET_GLOBAL
If this bit is set, a global reset signal will be sent to the USB bus.
This resets all of the USB bus logic, including the USB host
controller hardware and all the devices attached on the USB bus.
EFI_USB_HC_RESET_HOST_CONTROLLER
If this bit is set, the USB host controller hardware will be reset.
No reset signal will be sent to the USB bus.
EFI_USB_HC_RESET_GLOBAL_WITH_DEBUG
If this bit is set, a global reset signal will be sent to the USB bus.
This resets all of the USB bus logic, including the USB host
controller hardware and all the devices attached on the USB bus.
If this is an EHCI controller and the debug port has configured, then
this is will still reset the host controller.
EFI_USB_HC_RESET_HOST_WITH_DEBUG
If this bit is set, the USB host controller hardware will be reset.
If this is an EHCI controller and the debug port has been configured,
then this will still reset the host controller.
Returns:
EFI_SUCCESS
The reset operation succeeded.
EFI_INVALID_PARAMETER
Attributes is not valid.
EFI_UNSUPPOURTED
The type of reset specified by Attributes is not currently supported by
the host controller hardware.
EFI_ACCESS_DENIED
Reset operation is rejected due to the debug port being configured and
active; only EFI_USB_HC_RESET_GLOBAL_WITH_DEBUG or
EFI_USB_HC_RESET_HOST_WITH_DEBUG reset Atrributes can be used to
perform reset operation for this host controller.
EFI_DEVICE_ERROR
An error was encountered while attempting to perform
the reset operation.
--*/
;
EFI_STATUS
EFIAPI
UsbVirtualHcGetState (
IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
OUT EFI_USB_HC_STATE *State
)
/*++
Routine Description:
Virtual interface to retrieves current state of the USB host controller
for both Hc2 and Hc protocol.
Arguments:
UsbBusDev - A pointer to bus controller of the device.
State - A pointer to the EFI_USB_HC_STATE data structure that
indicates current state of the USB host controller.
Type EFI_USB_HC_STATE is defined below.
typedef enum {
EfiUsbHcStateHalt,
EfiUsbHcStateOperational,
EfiUsbHcStateSuspend,
EfiUsbHcStateMaximum
} EFI_USB_HC_STATE;
Returns:
EFI_SUCCESS
The state information of the host controller was returned in State.
EFI_INVALID_PARAMETER
State is NULL.
EFI_DEVICE_ERROR
An error was encountered while attempting to retrieve the
host controller's current state.
--*/
;
EFI_STATUS
EFIAPI
UsbVirtualHcSetState (
IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
IN EFI_USB_HC_STATE State
)
/*++
Routine Description:
Virtual interface to sets the USB host controller to a specific state
for both Hc2 and Hc protocol.
Arguments:
UsbBusDev - A pointer to bus controller of the device.
State - Indicates the state of the host controller that will be set.
Returns:
EFI_SUCCESS
The USB host controller was successfully placed in the state
specified by State.
EFI_INVALID_PARAMETER
State is invalid.
EFI_DEVICE_ERROR
Failed to set the state specified by State due to device error.
--*/
;
EFI_STATUS
EFIAPI
UsbVirtualHcGetRootHubPortStatus (
IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
IN UINT8 PortNumber,
OUT EFI_USB_PORT_STATUS *PortStatus
)
/*++
Routine Description:
Virtual interface to retrieves the current status of a USB root hub port
both for Hc2 and Hc protocol.
Arguments:
UsbBusDev - A pointer to bus controller of the device.
PortNumber - Specifies the root hub port from which the status
is to be retrieved. This value is zero-based. For example,
if a root hub has two ports, then the first port is numbered 0,
and the second port is numbered 1.
PortStatus - A pointer to the current port status bits and
port status change bits.
Returns:
EFI_SUCCESS The status of the USB root hub port specified by PortNumber
was returned in PortStatus.
EFI_INVALID_PARAMETER PortNumber is invalid.
EFI_DEVICE_ERROR Can't read register
--*/
;
EFI_STATUS
EFIAPI
UsbVirtualHcSetRootHubPortFeature (
IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
IN UINT8 PortNumber,
IN EFI_USB_PORT_FEATURE PortFeature
)
/*++
Routine Description:
Virual interface to sets a feature for the specified root hub port
for both Hc2 and Hc protocol.
Arguments:
UsbBusDev - A pointer to bus controller of the device.
PortNumber - Specifies the root hub port whose feature
is requested to be set.
PortFeature - Indicates the feature selector associated
with the feature set request.
Returns:
EFI_SUCCESS
The feature specified by PortFeature was set for the
USB root hub port specified by PortNumber.
EFI_INVALID_PARAMETER
PortNumber is invalid or PortFeature is invalid.
EFI_DEVICE_ERROR
Can't read register
--*/
;
EFI_STATUS
EFIAPI
UsbVirtualHcClearRootHubPortFeature (
IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
IN UINT8 PortNumber,
IN EFI_USB_PORT_FEATURE PortFeature
)
/*++
Routine Description:
Virtual interface to clears a feature for the specified root hub port
for both Hc2 and Hc protocol.
Arguments:
UsbBusDev - A pointer to bus controller of the device.
PortNumber - Specifies the root hub port whose feature
is requested to be cleared.
PortFeature - Indicates the feature selector associated with the
feature clear request.
Returns:
EFI_SUCCESS
The feature specified by PortFeature was cleared for the
USB root hub port specified by PortNumber.
EFI_INVALID_PARAMETER
PortNumber is invalid or PortFeature is invalid.
EFI_DEVICE_ERROR
Can't read register
--*/
;
EFI_STATUS
EFIAPI
UsbVirtualHcControlTransfer (
IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
IN UINT8 DeviceAddress,
IN UINT8 DeviceSpeed,
IN UINTN MaximumPacketLength,
IN EFI_USB_DEVICE_REQUEST *Request,
IN EFI_USB_DATA_DIRECTION TransferDirection,
IN OUT VOID *Data,
IN OUT UINTN *DataLength,
IN UINTN TimeOut,
IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
OUT UINT32 *TransferResult
)
/*++
Routine Description:
Virtual interface to submits control transfer to a target USB device
for both Hc2 and Hc protocol.
Arguments:
UsbBusDev - A pointer to bus controller of the device.
DeviceAddress - Represents the address of the target device on the USB,
which is assigned during USB enumeration.
DeviceSpeed - Indicates target device speed.
MaximumPacketLength - Indicates the maximum packet size that the
default control transfer endpoint is capable of
sending or receiving.
Request - A pointer to the USB device request that will be sent
to the USB device.
TransferDirection - Specifies the data direction for the transfer.
There are three values available, DataIn, DataOut
and NoData.
Data - A pointer to the buffer of data that will be transmitted
to USB device or received from USB device.
DataLength - Indicates the size, in bytes, of the data buffer
specified by Data.
TimeOut - Indicates the maximum time, in microseconds,
which the transfer is allowed to complete.
Translator - A pointr to the transaction translator data.
TransferResult - A pointer to the detailed result information generated
by this control transfer.
Returns:
EFI_SUCCESS
The control transfer was completed successfully.
EFI_OUT_OF_RESOURCES
The control transfer could not be completed due to a lack of resources.
EFI_INVALID_PARAMETER
Some parameters are invalid.
EFI_TIMEOUT
The control transfer failed due to timeout.
EFI_DEVICE_ERROR
The control transfer failed due to host controller or device error.
Caller should check TranferResult for detailed error information.
--*/
;
EFI_STATUS
EFIAPI
UsbVirtualHcBulkTransfer (
IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
IN UINT8 DeviceAddress,
IN UINT8 EndPointAddress,
IN UINT8 DeviceSpeed,
IN UINTN MaximumPacketLength,
IN UINT8 DataBuffersNumber,
IN OUT VOID *Data[EFI_USB_MAX_BULK_BUFFER_NUM],
IN OUT UINTN *DataLength,
IN OUT UINT8 *DataToggle,
IN UINTN TimeOut,
IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
OUT UINT32 *TransferResult
)
/*++
Routine Description:
Virtual interface to submits bulk transfer to a bulk endpoint of a USB device
both for Hc2 and Hc protocol.
Arguments:
UsbBusDev - A pointer to bus controller of the device.
DeviceAddress - Represents the address of the target device on the USB,
which is assigned during USB enumeration.
EndPointAddress - The combination of an endpoint number and an
endpoint direction of the target USB device.
Each endpoint address supports data transfer in
one direction except the control endpoint
(whose default endpoint address is 0).
It is the caller's responsibility to make sure that
the EndPointAddress represents a bulk endpoint.
DeviceSpeed - Indicates device speed. The supported values are EFI_USB_SPEED_FULL
and EFI_USB_SPEED_HIGH.
MaximumPacketLength - Indicates the maximum packet size the target endpoint
is capable of sending or receiving.
DataBuffersNumber - Number of data buffers prepared for the transfer.
Data - Array of pointers to the buffers of data that will be transmitted
to USB device or received from USB device.
DataLength - When input, indicates the size, in bytes, of the data buffer
specified by Data. When output, indicates the actually
transferred data size.
DataToggle - A pointer to the data toggle value. On input, it indicates
the initial data toggle value the bulk transfer should adopt;
on output, it is updated to indicate the data toggle value
of the subsequent bulk transfer.
Translator - A pointr to the transaction translator data.
TimeOut - Indicates the maximum time, in microseconds, which the
transfer is allowed to complete.
TransferResult - A pointer to the detailed result information of the
bulk transfer.
Returns:
EFI_SUCCESS
The bulk transfer was completed successfully.
EFI_OUT_OF_RESOURCES
The bulk transfer could not be submitted due to lack of resource.
EFI_INVALID_PARAMETER
Some parameters are invalid.
EFI_TIMEOUT
The bulk transfer failed due to timeout.
EFI_DEVICE_ERROR
The bulk transfer failed due to host controller or device error.
Caller should check TranferResult for detailed error information.
--*/
;
EFI_STATUS
EFIAPI
UsbVirtualHcAsyncInterruptTransfer (
IN USB_BUS_CONTROLLER_DEVICE * UsbBusDev,
IN UINT8 DeviceAddress,
IN UINT8 EndPointAddress,
IN UINT8 DeviceSpeed,
IN UINTN MaximumPacketLength,
IN BOOLEAN IsNewTransfer,
IN OUT UINT8 *DataToggle,
IN UINTN PollingInterval,
IN UINTN DataLength,
IN EFI_USB2_HC_TRANSACTION_TRANSLATOR * Translator,
IN EFI_ASYNC_USB_TRANSFER_CALLBACK CallBackFunction,
IN VOID *Context OPTIONAL
)
/*++
Routine Description:
Virtual interface to submits an asynchronous interrupt transfer to an
interrupt endpoint of a USB device for both Hc2 and Hc protocol.
Arguments:
UsbBusDev - A pointer to bus controller of the device.
DeviceAddress - Represents the address of the target device on the USB,
which is assigned during USB enumeration.
EndPointAddress - The combination of an endpoint number and an endpoint
direction of the target USB device. Each endpoint address
supports data transfer in one direction except the
control endpoint (whose default endpoint address is 0).
It is the caller's responsibility to make sure that
the EndPointAddress represents an interrupt endpoint.
DeviceSpeed - Indicates device speed.
MaximumPacketLength - Indicates the maximum packet size the target endpoint
is capable of sending or receiving.
IsNewTransfer - If TRUE, an asynchronous interrupt pipe is built between
the host and the target interrupt endpoint.
If FALSE, the specified asynchronous interrupt pipe
is canceled.
DataToggle - A pointer to the data toggle value. On input, it is valid
when IsNewTransfer is TRUE, and it indicates the initial
data toggle value the asynchronous interrupt transfer
should adopt.
On output, it is valid when IsNewTransfer is FALSE,
and it is updated to indicate the data toggle value of
the subsequent asynchronous interrupt transfer.
PollingInterval - Indicates the interval, in milliseconds, that the
asynchronous interrupt transfer is polled.
This parameter is required when IsNewTransfer is TRUE.
DataLength - Indicates the length of data to be received at the
rate specified by PollingInterval from the target
asynchronous interrupt endpoint. This parameter
is only required when IsNewTransfer is TRUE.
Translator - A pointr to the transaction translator data.
CallBackFunction - The Callback function.This function is called at the
rate specified by PollingInterval.This parameter is
only required when IsNewTransfer is TRUE.
Context - The context that is passed to the CallBackFunction.
- This is an optional parameter and may be NULL.
Returns:
EFI_SUCCESS
The asynchronous interrupt transfer request has been successfully
submitted or canceled.
EFI_INVALID_PARAMETER
Some parameters are invalid.
EFI_OUT_OF_RESOURCES
The request could not be completed due to a lack of resources.
EFI_DEVICE_ERROR
Can't read register
--*/
;
EFI_STATUS
EFIAPI
UsbVirtualHcSyncInterruptTransfer (
IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
IN UINT8 DeviceAddress,
IN UINT8 EndPointAddress,
IN UINT8 DeviceSpeed,
IN UINTN MaximumPacketLength,
IN OUT VOID *Data,
IN OUT UINTN *DataLength,
IN OUT UINT8 *DataToggle,
IN UINTN TimeOut,
IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
OUT UINT32 *TransferResult
)
/*++
Routine Description:
Vitual interface to submits synchronous interrupt transfer to an interrupt endpoint
of a USB device for both Hc2 and Hc protocol.
Arguments:
UsbBusDev - A pointer to bus controller of the device.
DeviceAddress - Represents the address of the target device on the USB,
which is assigned during USB enumeration.
EndPointAddress - The combination of an endpoint number and an endpoint
direction of the target USB device. Each endpoint
address supports data transfer in one direction
except the control endpoint (whose default
endpoint address is 0). It is the caller's responsibility
to make sure that the EndPointAddress represents
an interrupt endpoint.
DeviceSpeed - Indicates device speed.
MaximumPacketLength - Indicates the maximum packet size the target endpoint
is capable of sending or receiving.
Data - A pointer to the buffer of data that will be transmitted
to USB device or received from USB device.
DataLength - On input, the size, in bytes, of the data buffer specified
by Data. On output, the number of bytes transferred.
DataToggle - A pointer to the data toggle value. On input, it indicates
the initial data toggle value the synchronous interrupt
transfer should adopt;
on output, it is updated to indicate the data toggle value
of the subsequent synchronous interrupt transfer.
TimeOut - Indicates the maximum time, in microseconds, which the
transfer is allowed to complete.
Translator - A pointr to the transaction translator data.
TransferResult - A pointer to the detailed result information from
the synchronous interrupt transfer.
Returns:
EFI_SUCCESS
The synchronous interrupt transfer was completed successfully.
EFI_OUT_OF_RESOURCES
The synchronous interrupt transfer could not be submitted due
to lack of resource.
EFI_INVALID_PARAMETER
Some parameters are invalid.
EFI_TIMEOUT
The synchronous interrupt transfer failed due to timeout.
EFI_DEVICE_ERROR
The synchronous interrupt transfer failed due to host controller
or device error. Caller should check TranferResult for detailed
error information.
--*/
;
EFI_STATUS
EFIAPI
UsbVirtualHcIsochronousTransfer (
IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
IN UINT8 DeviceAddress,
IN UINT8 EndPointAddress,
IN UINT8 DeviceSpeed,
IN UINTN MaximumPacketLength,
IN UINT8 DataBuffersNumber,
IN OUT VOID *Data[EFI_USB_MAX_ISO_BUFFER_NUM],
IN UINTN DataLength,
IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
OUT UINT32 *TransferResult
)
/*++
Routine Description:
Virtual interface to submits isochronous transfer to a target USB device
for both Hc2 and Hc protocol.
Arguments:
UsbBusDev - A pointer to bus controller of the device.
DeviceAddress - Represents the address of the target device on the USB,
which is assigned during USB enumeration.
EndPointAddress - End point address
DeviceSpeed - Indicates device speed.
MaximumPacketLength - Indicates the maximum packet size that the
default control transfer endpoint is capable of
sending or receiving.
DataBuffersNumber - Number of data buffers prepared for the transfer.
Data - Array of pointers to the buffers of data that will be
transmitted to USB device or received from USB device.
DataLength - Indicates the size, in bytes, of the data buffer
specified by Data.
Translator - A pointr to the transaction translator data.
TransferResult - A pointer to the detailed result information generated
by this control transfer.
Returns:
EFI_UNSUPPORTED
--*/
;
EFI_STATUS
EFIAPI
UsbVirtualHcAsyncIsochronousTransfer (
IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
IN UINT8 DeviceAddress,
IN UINT8 EndPointAddress,
IN UINT8 DeviceSpeed,
IN UINTN MaximumPacketLength,
IN UINT8 DataBuffersNumber,
IN OUT VOID *Data[EFI_USB_MAX_ISO_BUFFER_NUM],
IN UINTN DataLength,
IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
IN EFI_ASYNC_USB_TRANSFER_CALLBACK IsochronousCallBack,
IN VOID *Context
)
/*++
Routine Description:
Vitual interface to submits Async isochronous transfer to a target USB device
for both Hc2 and Hc protocol.
Arguments:
UsbBusDev - A pointer to bus controller of the device.
DeviceAddress - Represents the address of the target device on the USB,
which is assigned during USB enumeration.
EndPointAddress - End point address
DeviceSpeed - Indicates device speed.
MaximumPacketLength - Indicates the maximum packet size that the
default control transfer endpoint is capable of
sending or receiving.
DataBuffersNumber - Number of data buffers prepared for the transfer.
Data - Array of pointers to the buffers of data that will be transmitted
to USB device or received from USB device.
DataLength - Indicates the size, in bytes, of the data buffer
specified by Data.
Translator - A pointr to the transaction translator data.
IsochronousCallBack - When the transfer complete, the call back function will be called
Context - Pass to the call back function as parameter
Returns:
EFI_UNSUPPORTED
--*/
;
#endif
|