3 This file contains the definition for XHCI host controller schedule routines.
5 Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #ifndef _EFI_XHCI_SCHED_H_
17 #define _EFI_XHCI_SCHED_H_
19 #define XHC_URB_SIG SIGNATURE_32 ('U', 'S', 'B', 'R')
22 // Transfer types, used in URB to identify the transfer type
24 #define XHC_CTRL_TRANSFER 0x01
25 #define XHC_BULK_TRANSFER 0x02
26 #define XHC_INT_TRANSFER_SYNC 0x04
27 #define XHC_INT_TRANSFER_ASYNC 0x08
28 #define XHC_INT_ONLY_TRANSFER_ASYNC 0x10
33 #define TRB_TYPE_NORMAL 1
34 #define TRB_TYPE_SETUP_STAGE 2
35 #define TRB_TYPE_DATA_STAGE 3
36 #define TRB_TYPE_STATUS_STAGE 4
37 #define TRB_TYPE_ISOCH 5
38 #define TRB_TYPE_LINK 6
39 #define TRB_TYPE_EVENT_DATA 7
40 #define TRB_TYPE_NO_OP 8
41 #define TRB_TYPE_EN_SLOT 9
42 #define TRB_TYPE_DIS_SLOT 10
43 #define TRB_TYPE_ADDRESS_DEV 11
44 #define TRB_TYPE_CON_ENDPOINT 12
45 #define TRB_TYPE_EVALU_CONTXT 13
46 #define TRB_TYPE_RESET_ENDPOINT 14
47 #define TRB_TYPE_STOP_ENDPOINT 15
48 #define TRB_TYPE_SET_TR_DEQUE 16
49 #define TRB_TYPE_RESET_DEV 17
50 #define TRB_TYPE_GET_PORT_BANW 21
51 #define TRB_TYPE_FORCE_HEADER 22
52 #define TRB_TYPE_NO_OP_COMMAND 23
53 #define TRB_TYPE_TRANS_EVENT 32
54 #define TRB_TYPE_COMMAND_COMPLT_EVENT 33
55 #define TRB_TYPE_PORT_STATUS_CHANGE_EVENT 34
56 #define TRB_TYPE_HOST_CONTROLLER_EVENT 37
57 #define TRB_TYPE_DEVICE_NOTIFI_EVENT 38
58 #define TRB_TYPE_MFINDEX_WRAP_EVENT 39
61 // Endpoint Type (EP Type).
63 #define ED_NOT_VALID 0
64 #define ED_ISOCH_OUT 1
66 #define ED_INTERRUPT_OUT 3
67 #define ED_CONTROL_BIDIR 4
70 #define ED_INTERRUPT_IN 7
73 // 6.4.5 TRB Completion Codes
75 #define TRB_COMPLETION_INVALID 0
76 #define TRB_COMPLETION_SUCCESS 1
77 #define TRB_COMPLETION_DATA_BUFFER_ERROR 2
78 #define TRB_COMPLETION_BABBLE_ERROR 3
79 #define TRB_COMPLETION_USB_TRANSACTION_ERROR 4
80 #define TRB_COMPLETION_TRB_ERROR 5
81 #define TRB_COMPLETION_STALL_ERROR 6
82 #define TRB_COMPLETION_SHORT_PACKET 13
83 #define TRB_COMPLETION_STOPPED 26
84 #define TRB_COMPLETION_STOPPED_LENGTH_INVALID 27
87 // The topology string used to present usb device location
89 typedef struct _USB_DEV_TOPOLOGY
{
91 // The tier concatenation of down stream port.
93 UINT32 RouteString
:20;
95 // The root port number of the chain.
99 // The Tier the device reside.
105 // USB Device's RouteChart
107 typedef union _USB_DEV_ROUTE
{
109 USB_DEV_TOPOLOGY Route
;
113 // Endpoint address and its capabilities
115 typedef struct _USB_ENDPOINT
{
117 // Store logical device address assigned by UsbBus
118 // It's because some XHCI host controllers may assign the same physcial device
119 // address for those devices inserted at different root port.
124 EFI_USB_DATA_DIRECTION Direction
;
133 typedef struct _TRB_TEMPLATE
{
146 typedef struct _TRANSFER_RING
{
149 TRB_TEMPLATE
*RingEnqueue
;
150 TRB_TEMPLATE
*RingDequeue
;
154 typedef struct _EVENT_RING
{
158 TRB_TEMPLATE
*EventRingEnqueue
;
159 TRB_TEMPLATE
*EventRingDequeue
;
164 // URB (Usb Request Block) contains information for all kinds of
167 typedef struct _URB
{
171 // Usb Device URB related information
174 EFI_USB_DEVICE_REQUEST
*Request
;
179 EFI_ASYNC_USB_TRANSFER_CALLBACK Callback
;
186 // completed data length
190 // Command/Tranfer Ring info
193 TRB_TEMPLATE
*TrbStart
;
194 TRB_TEMPLATE
*TrbEnd
;
200 TRB_TEMPLATE
*EvtTrb
;
204 // 6.5 Event Ring Segment Table
205 // The Event Ring Segment Table is used to define multi-segment Event Rings and to enable runtime
206 // expansion and shrinking of the Event Ring. The location of the Event Ring Segment Table is defined by the
207 // Event Ring Segment Table Base Address Register (5.5.2.3.2). The size of the Event Ring Segment Table
208 // is defined by the Event Ring Segment Table Base Size Register (5.5.2.3.1).
210 typedef struct _EVENT_RING_SEG_TABLE_ENTRY
{
213 UINT32 RingTrbSize
:16;
216 } EVENT_RING_SEG_TABLE_ENTRY
;
219 // 6.4.1.1 Normal TRB
220 // A Normal TRB is used in several ways; exclusively on Bulk and Interrupt Transfer Rings for normal and
221 // Scatter/Gather operations, to define additional data buffers for Scatter/Gather operations on Isoch Transfer
222 // Rings, and to define the Data stage information for Control Transfer Rings.
224 typedef struct _TRANSFER_TRB_NORMAL
{
244 } TRANSFER_TRB_NORMAL
;
247 // 6.4.1.2.1 Setup Stage TRB
248 // A Setup Stage TRB is created by system software to initiate a USB Setup packet on a control endpoint.
250 typedef struct _TRANSFER_TRB_CONTROL_SETUP
{
251 UINT32 bmRequestType
:8;
270 } TRANSFER_TRB_CONTROL_SETUP
;
273 // 6.4.1.2.2 Data Stage TRB
274 // A Data Stage TRB is used generate the Data stage transaction of a USB Control transfer.
276 typedef struct _TRANSFER_TRB_CONTROL_DATA
{
296 } TRANSFER_TRB_CONTROL_DATA
;
299 // 6.4.1.2.2 Data Stage TRB
300 // A Data Stage TRB is used generate the Data stage transaction of a USB Control transfer.
302 typedef struct _TRANSFER_TRB_CONTROL_STATUS
{
318 } TRANSFER_TRB_CONTROL_STATUS
;
321 // 6.4.2.1 Transfer Event TRB
322 // A Transfer Event provides the completion status associated with a Transfer TRB. Refer to section 4.11.3.1
323 // for more information on the use and operation of Transfer Events.
325 typedef struct _EVT_TRB_TRANSFER
{
331 UINT32 Completecode
:8;
344 // 6.4.2.2 Command Completion Event TRB
345 // A Command Completion Event TRB shall be generated by the xHC when a command completes on the
346 // Command Ring. Refer to section 4.11.4 for more information on the use of Command Completion Events.
348 typedef struct _EVT_TRB_COMMAND_COMPLETION
{
354 UINT32 Completecode
:8;
361 } EVT_TRB_COMMAND_COMPLETION
;
364 TRB_TEMPLATE TrbTemplate
;
365 TRANSFER_TRB_NORMAL TrbNormal
;
366 TRANSFER_TRB_CONTROL_SETUP TrbCtrSetup
;
367 TRANSFER_TRB_CONTROL_DATA TrbCtrData
;
368 TRANSFER_TRB_CONTROL_STATUS TrbCtrStatus
;
372 // 6.4.3.1 No Op Command TRB
373 // The No Op Command TRB provides a simple means for verifying the operation of the Command Ring
374 // mechanisms offered by the xHCI.
376 typedef struct _CMD_TRB_NO_OP
{
388 // 6.4.3.2 Enable Slot Command TRB
389 // The Enable Slot Command TRB causes the xHC to select an available Device Slot and return the ID of the
390 // selected slot to the host in a Command Completion Event.
392 typedef struct _CMD_TRB_ENABLE_SLOT
{
401 } CMD_TRB_ENABLE_SLOT
;
404 // 6.4.3.3 Disable Slot Command TRB
405 // The Disable Slot Command TRB releases any bandwidth assigned to the disabled slot and frees any
406 // internal xHC resources assigned to the slot.
408 typedef struct _CMD_TRB_DISABLE_SLOT
{
418 } CMD_TRB_DISABLE_SLOT
;
421 // 6.4.3.4 Address Device Command TRB
422 // The Address Device Command TRB transitions the selected Device Context from the Default to the
423 // Addressed state and causes the xHC to select an address for the USB device in the Default State and
424 // issue a SET_ADDRESS request to the USB device.
426 typedef struct _CMD_TRB_ADDRESS_DEVICE
{
439 } CMD_TRB_ADDRESS_DEVICE
;
442 // 6.4.3.5 Configure Endpoint Command TRB
443 // The Configure Endpoint Command TRB evaluates the bandwidth and resource requirements of the
444 // endpoints selected by the command.
446 typedef struct _CMD_TRB_CONFIG_ENDPOINT
{
459 } CMD_TRB_CONFIG_ENDPOINT
;
462 // 6.4.3.6 Evaluate Context Command TRB
463 // The Evaluate Context Command TRB is used by system software to inform the xHC that the selected
464 // Context data structures in the Device Context have been modified by system software and that the xHC
465 // shall evaluate any changes
467 typedef struct _CMD_TRB_EVALUATE_CONTEXT
{
479 } CMD_TRB_EVALUATE_CONTEXT
;
482 // 6.4.3.7 Reset Endpoint Command TRB
483 // The Reset Endpoint Command TRB is used by system software to reset a specified Transfer Ring
485 typedef struct _CMD_TRB_RESET_ENDPOINT
{
497 } CMD_TRB_RESET_ENDPOINT
;
500 // 6.4.3.8 Stop Endpoint Command TRB
501 // The Stop Endpoint Command TRB command allows software to stop the xHC execution of the TDs on a
502 // Transfer Ring and temporarily take ownership of TDs that had previously been passed to the xHC.
504 typedef struct _CMD_TRB_STOP_ENDPOINT
{
516 } CMD_TRB_STOP_ENDPOINT
;
519 // 6.4.3.9 Set TR Dequeue Pointer Command TRB
520 // The Set TR Dequeue Pointer Command TRB is used by system software to modify the TR Dequeue
521 // Pointer and DCS fields of an Endpoint or Stream Context.
523 typedef struct _CMD_SET_TR_DEQ_POINTER
{
537 } CMD_SET_TR_DEQ_POINTER
;
541 // A Link TRB provides support for non-contiguous TRB Rings.
543 typedef struct _LINK_TRB
{
549 UINT32 InterTarget
:10;
562 // 6.2.2 Slot Context
564 typedef struct _SLOT_CONTEXT
{
565 UINT32 RouteString
:20;
570 UINT32 ContextEntries
:5;
572 UINT32 MaxExitLatency
:16;
573 UINT32 RootHubPortNum
:8;
576 UINT32 TTHubSlotId
:8;
580 UINT32 InterTarget
:10;
582 UINT32 DeviceAddress
:8;
592 typedef struct _SLOT_CONTEXT_64
{
593 UINT32 RouteString
:20;
598 UINT32 ContextEntries
:5;
600 UINT32 MaxExitLatency
:16;
601 UINT32 RootHubPortNum
:8;
604 UINT32 TTHubSlotId
:8;
608 UINT32 InterTarget
:10;
610 UINT32 DeviceAddress
:8;
633 // 6.2.3 Endpoint Context
635 typedef struct _ENDPOINT_CONTEXT
{
639 UINT32 MaxPStreams
:5;
649 UINT32 MaxBurstSize
:8;
650 UINT32 MaxPacketSize
:16;
656 UINT32 AverageTRBLength
:16;
657 UINT32 MaxESITPayload
:16;
664 typedef struct _ENDPOINT_CONTEXT_64
{
668 UINT32 MaxPStreams
:5;
678 UINT32 MaxBurstSize
:8;
679 UINT32 MaxPacketSize
:16;
685 UINT32 AverageTRBLength
:16;
686 UINT32 MaxESITPayload
:16;
702 } ENDPOINT_CONTEXT_64
;
706 // 6.2.5.1 Input Control Context
708 typedef struct _INPUT_CONTRL_CONTEXT
{
717 } INPUT_CONTRL_CONTEXT
;
719 typedef struct _INPUT_CONTRL_CONTEXT_64
{
736 } INPUT_CONTRL_CONTEXT_64
;
739 // 6.2.1 Device Context
741 typedef struct _DEVICE_CONTEXT
{
743 ENDPOINT_CONTEXT EP
[31];
746 typedef struct _DEVICE_CONTEXT_64
{
747 SLOT_CONTEXT_64 Slot
;
748 ENDPOINT_CONTEXT_64 EP
[31];
752 // 6.2.5 Input Context
754 typedef struct _INPUT_CONTEXT
{
755 INPUT_CONTRL_CONTEXT InputControlContext
;
757 ENDPOINT_CONTEXT EP
[31];
760 typedef struct _INPUT_CONTEXT_64
{
761 INPUT_CONTRL_CONTEXT_64 InputControlContext
;
762 SLOT_CONTEXT_64 Slot
;
763 ENDPOINT_CONTEXT_64 EP
[31];
768 Initialize the XHCI host controller for schedule.
770 @param Xhc The XHCI Instance to be initialized.
775 IN USB_XHCI_INSTANCE
*Xhc
779 Free the resouce allocated at initializing schedule.
781 @param Xhc The XHCI Instance.
786 IN USB_XHCI_INSTANCE
*Xhc
790 Ring the door bell to notify XHCI there is a transaction to be executed through URB.
792 @param Xhc The XHCI Instance.
793 @param Urb The URB to be rung.
795 @retval EFI_SUCCESS Successfully ring the door bell.
799 RingIntTransferDoorBell (
800 IN USB_XHCI_INSTANCE
*Xhc
,
805 Execute the transfer by polling the URB. This is a synchronous operation.
807 @param Xhc The XHCI Instance.
808 @param CmdTransfer The executed URB is for cmd transfer or not.
809 @param Urb The URB to execute.
810 @param Timeout The time to wait before abort, in millisecond.
812 @return EFI_DEVICE_ERROR The transfer failed due to transfer error.
813 @return EFI_TIMEOUT The transfer failed due to time out.
814 @return EFI_SUCCESS The transfer finished OK.
819 IN USB_XHCI_INSTANCE
*Xhc
,
820 IN BOOLEAN CmdTransfer
,
826 Delete a single asynchronous interrupt transfer for
827 the device and endpoint.
829 @param Xhc The XHCI Instance.
830 @param BusAddr The logical device address assigned by UsbBus driver.
831 @param EpNum The endpoint of the target.
833 @retval EFI_SUCCESS An asynchronous transfer is removed.
834 @retval EFI_NOT_FOUND No transfer for the device is found.
838 XhciDelAsyncIntTransfer (
839 IN USB_XHCI_INSTANCE
*Xhc
,
845 Remove all the asynchronous interrupt transfers.
847 @param Xhc The XHCI Instance.
851 XhciDelAllAsyncIntTransfers (
852 IN USB_XHCI_INSTANCE
*Xhc
858 @param Xhc The XHCI Instance.
862 XhcSetBiosOwnership (
863 IN USB_XHCI_INSTANCE
*Xhc
869 @param Xhc The XHCI Instance.
873 XhcClearBiosOwnership (
874 IN USB_XHCI_INSTANCE
*Xhc
878 Find out the slot id according to the device's route string.
880 @param Xhc The XHCI Instance.
881 @param RouteString The route string described the device location.
883 @return The slot id used by the device.
888 XhcRouteStringToSlotId (
889 IN USB_XHCI_INSTANCE
*Xhc
,
890 IN USB_DEV_ROUTE RouteString
894 Calculate the device context index by endpoint address and direction.
896 @param EpAddr The target endpoint number.
897 @param Direction The direction of the target endpoint.
899 @return The device context index of endpoint.
909 Ring the door bell to notify XHCI there is a transaction to be executed.
911 @param Xhc The XHCI Instance.
912 @param SlotId The slot id of the target device.
913 @param Dci The device context index of the target slot or endpoint.
915 @retval EFI_SUCCESS Successfully ring the door bell.
921 IN USB_XHCI_INSTANCE
*Xhc
,
927 Interrupt transfer periodic check handler.
929 @param Event Interrupt event.
930 @param Context Pointer to USB_XHCI_INSTANCE.
935 XhcMonitorAsyncRequests (
941 Monitor the port status change. Enable/Disable device slot if there is a device attached/detached.
943 @param Xhc The XHCI Instance.
944 @param ParentRouteChart The route string pointed to the parent device if it exists.
945 @param Port The port to be polled.
946 @param PortState The port state.
948 @retval EFI_SUCCESS Successfully enable/disable device slot according to port state.
949 @retval Others Should not appear.
954 XhcPollPortStatusChange (
955 IN USB_XHCI_INSTANCE
*Xhc
,
956 IN USB_DEV_ROUTE ParentRouteChart
,
958 IN EFI_USB_PORT_STATUS
*PortState
962 Evaluate the slot context for hub device through XHCI's Configure_Endpoint cmd.
964 @param Xhc The XHCI Instance.
965 @param SlotId The slot id to be configured.
966 @param PortNum The total number of downstream port supported by the hub.
967 @param TTT The TT think time of the hub device.
968 @param MTT The multi-TT of the hub device.
970 @retval EFI_SUCCESS Successfully configure the hub device's slot context.
974 XhcConfigHubContext (
975 IN USB_XHCI_INSTANCE
*Xhc
,
984 Evaluate the slot context for hub device through XHCI's Configure_Endpoint cmd.
986 @param Xhc The XHCI Instance.
987 @param SlotId The slot id to be configured.
988 @param PortNum The total number of downstream port supported by the hub.
989 @param TTT The TT think time of the hub device.
990 @param MTT The multi-TT of the hub device.
992 @retval EFI_SUCCESS Successfully configure the hub device's slot context.
996 XhcConfigHubContext64 (
997 IN USB_XHCI_INSTANCE
*Xhc
,
1006 Configure all the device endpoints through XHCI's Configure_Endpoint cmd.
1008 @param Xhc The XHCI Instance.
1009 @param SlotId The slot id to be configured.
1010 @param DeviceSpeed The device's speed.
1011 @param ConfigDesc The pointer to the usb device configuration descriptor.
1013 @retval EFI_SUCCESS Successfully configure all the device endpoints.
1019 IN USB_XHCI_INSTANCE
*Xhc
,
1021 IN UINT8 DeviceSpeed
,
1022 IN USB_CONFIG_DESCRIPTOR
*ConfigDesc
1027 Configure all the device endpoints through XHCI's Configure_Endpoint cmd.
1029 @param Xhc The XHCI Instance.
1030 @param SlotId The slot id to be configured.
1031 @param DeviceSpeed The device's speed.
1032 @param ConfigDesc The pointer to the usb device configuration descriptor.
1034 @retval EFI_SUCCESS Successfully configure all the device endpoints.
1040 IN USB_XHCI_INSTANCE
*Xhc
,
1042 IN UINT8 DeviceSpeed
,
1043 IN USB_CONFIG_DESCRIPTOR
*ConfigDesc
1047 Set interface through XHCI's Configure_Endpoint cmd.
1049 @param Xhc The XHCI Instance.
1050 @param SlotId The slot id to be configured.
1051 @param DeviceSpeed The device's speed.
1052 @param ConfigDesc The pointer to the usb device configuration descriptor.
1053 @param Request USB device request to send.
1055 @retval EFI_SUCCESS Successfully set interface.
1061 IN USB_XHCI_INSTANCE
*Xhc
,
1063 IN UINT8 DeviceSpeed
,
1064 IN USB_CONFIG_DESCRIPTOR
*ConfigDesc
,
1065 IN EFI_USB_DEVICE_REQUEST
*Request
1069 Set interface through XHCI's Configure_Endpoint cmd.
1071 @param Xhc The XHCI Instance.
1072 @param SlotId The slot id to be configured.
1073 @param DeviceSpeed The device's speed.
1074 @param ConfigDesc The pointer to the usb device configuration descriptor.
1075 @param Request USB device request to send.
1077 @retval EFI_SUCCESS Successfully set interface.
1083 IN USB_XHCI_INSTANCE
*Xhc
,
1085 IN UINT8 DeviceSpeed
,
1086 IN USB_CONFIG_DESCRIPTOR
*ConfigDesc
,
1087 IN EFI_USB_DEVICE_REQUEST
*Request
1091 Find out the actual device address according to the requested device address from UsbBus.
1093 @param Xhc The XHCI Instance.
1094 @param BusDevAddr The requested device address by UsbBus upper driver.
1096 @return The actual device address assigned to the device.
1101 XhcBusDevAddrToSlotId (
1102 IN USB_XHCI_INSTANCE
*Xhc
,
1107 Assign and initialize the device slot for a new device.
1109 @param Xhc The XHCI Instance.
1110 @param ParentRouteChart The route string pointed to the parent device.
1111 @param ParentPort The port at which the device is located.
1112 @param RouteChart The route string pointed to the device.
1113 @param DeviceSpeed The device speed.
1115 @retval EFI_SUCCESS Successfully assign a slot to the device and assign an address to it.
1120 XhcInitializeDeviceSlot (
1121 IN USB_XHCI_INSTANCE
*Xhc
,
1122 IN USB_DEV_ROUTE ParentRouteChart
,
1123 IN UINT16 ParentPort
,
1124 IN USB_DEV_ROUTE RouteChart
,
1125 IN UINT8 DeviceSpeed
1129 Assign and initialize the device slot for a new device.
1131 @param Xhc The XHCI Instance.
1132 @param ParentRouteChart The route string pointed to the parent device.
1133 @param ParentPort The port at which the device is located.
1134 @param RouteChart The route string pointed to the device.
1135 @param DeviceSpeed The device speed.
1137 @retval EFI_SUCCESS Successfully assign a slot to the device and assign an address to it.
1142 XhcInitializeDeviceSlot64 (
1143 IN USB_XHCI_INSTANCE
*Xhc
,
1144 IN USB_DEV_ROUTE ParentRouteChart
,
1145 IN UINT16 ParentPort
,
1146 IN USB_DEV_ROUTE RouteChart
,
1147 IN UINT8 DeviceSpeed
1151 Evaluate the endpoint 0 context through XHCI's Evaluate_Context cmd.
1153 @param Xhc The XHCI Instance.
1154 @param SlotId The slot id to be evaluated.
1155 @param MaxPacketSize The max packet size supported by the device control transfer.
1157 @retval EFI_SUCCESS Successfully evaluate the device endpoint 0.
1162 XhcEvaluateContext (
1163 IN USB_XHCI_INSTANCE
*Xhc
,
1165 IN UINT32 MaxPacketSize
1170 Evaluate the endpoint 0 context through XHCI's Evaluate_Context cmd.
1172 @param Xhc The XHCI Instance.
1173 @param SlotId The slot id to be evaluated.
1174 @param MaxPacketSize The max packet size supported by the device control transfer.
1176 @retval EFI_SUCCESS Successfully evaluate the device endpoint 0.
1181 XhcEvaluateContext64 (
1182 IN USB_XHCI_INSTANCE
*Xhc
,
1184 IN UINT32 MaxPacketSize
1189 Disable the specified device slot.
1191 @param Xhc The XHCI Instance.
1192 @param SlotId The slot id to be disabled.
1194 @retval EFI_SUCCESS Successfully disable the device slot.
1200 IN USB_XHCI_INSTANCE
*Xhc
,
1206 Disable the specified device slot.
1208 @param Xhc The XHCI Instance.
1209 @param SlotId The slot id to be disabled.
1211 @retval EFI_SUCCESS Successfully disable the device slot.
1216 XhcDisableSlotCmd64 (
1217 IN USB_XHCI_INSTANCE
*Xhc
,
1223 Synchronize the specified transfer ring to update the enqueue and dequeue pointer.
1225 @param Xhc The XHCI Instance.
1226 @param TrsRing The transfer ring to sync.
1228 @retval EFI_SUCCESS The transfer ring is synchronized successfully.
1234 IN USB_XHCI_INSTANCE
*Xhc
,
1235 TRANSFER_RING
*TrsRing
1239 Synchronize the specified event ring to update the enqueue and dequeue pointer.
1241 @param Xhc The XHCI Instance.
1242 @param EvtRing The event ring to sync.
1244 @retval EFI_SUCCESS The event ring is synchronized successfully.
1250 IN USB_XHCI_INSTANCE
*Xhc
,
1255 Check if there is a new generated event.
1257 @param Xhc The XHCI Instance.
1258 @param EvtRing The event ring to check.
1259 @param NewEvtTrb The new event TRB found.
1261 @retval EFI_SUCCESS Found a new event TRB at the event ring.
1262 @retval EFI_NOT_READY The event ring has no new event.
1268 IN USB_XHCI_INSTANCE
*Xhc
,
1269 IN EVENT_RING
*EvtRing
,
1270 OUT TRB_TEMPLATE
**NewEvtTrb
1274 Create XHCI transfer ring.
1276 @param Xhc The XHCI Instance.
1277 @param TrbNum The number of TRB in the ring.
1278 @param TransferRing The created transfer ring.
1282 CreateTransferRing (
1283 IN USB_XHCI_INSTANCE
*Xhc
,
1285 OUT TRANSFER_RING
*TransferRing
1289 Create XHCI event ring.
1291 @param Xhc The XHCI Instance.
1292 @param EventRing The created event ring.
1297 IN USB_XHCI_INSTANCE
*Xhc
,
1298 OUT EVENT_RING
*EventRing
1302 System software shall use a Reset Endpoint Command (section 4.11.4.7) to remove the Halted
1303 condition in the xHC. After the successful completion of the Reset Endpoint Command, the Endpoint
1304 Context is transitioned from the Halted to the Stopped state and the Transfer Ring of the endpoint is
1305 reenabled. The next write to the Doorbell of the Endpoint will transition the Endpoint Context from the
1306 Stopped to the Running state.
1308 @param Xhc The XHCI Instance.
1309 @param Urb The urb which makes the endpoint halted.
1311 @retval EFI_SUCCESS The recovery is successful.
1312 @retval Others Failed to recovery halted endpoint.
1317 XhcRecoverHaltedEndpoint (
1318 IN USB_XHCI_INSTANCE
*Xhc
,
1323 System software shall use a Stop Endpoint Command (section 4.6.9) and the Set TR Dequeue Pointer
1324 Command (section 4.6.10) to remove the timed-out TDs from the xHC transfer ring. The next write to
1325 the Doorbell of the Endpoint will transition the Endpoint Context from the Stopped to the Running
1328 @param Xhc The XHCI Instance.
1329 @param Urb The urb which doesn't get completed in a specified timeout range.
1331 @retval EFI_SUCCESS The dequeuing of the TDs is successful.
1332 @retval Others Failed to stop the endpoint and dequeue the TDs.
1337 XhcDequeueTrbFromEndpoint (
1338 IN USB_XHCI_INSTANCE
*Xhc
,
1343 Stop endpoint through XHCI's Stop_Endpoint cmd.
1345 @param Xhc The XHCI Instance.
1346 @param SlotId The slot id to be configured.
1347 @param Dci The device context index of endpoint.
1348 @param PendingUrb The pending URB to check completion status when stopping the end point.
1350 @retval EFI_SUCCESS Stop endpoint successfully.
1351 @retval Others Failed to stop endpoint.
1357 IN USB_XHCI_INSTANCE
*Xhc
,
1360 IN URB
*PendingUrb OPTIONAL
1364 Reset endpoint through XHCI's Reset_Endpoint cmd.
1366 @param Xhc The XHCI Instance.
1367 @param SlotId The slot id to be configured.
1368 @param Dci The device context index of endpoint.
1370 @retval EFI_SUCCESS Reset endpoint successfully.
1371 @retval Others Failed to reset endpoint.
1377 IN USB_XHCI_INSTANCE
*Xhc
,
1383 Set transfer ring dequeue pointer through XHCI's Set_Tr_Dequeue_Pointer cmd.
1385 @param Xhc The XHCI Instance.
1386 @param SlotId The slot id to be configured.
1387 @param Dci The device context index of endpoint.
1388 @param Urb The dequeue pointer of the transfer ring specified
1389 by the urb to be updated.
1391 @retval EFI_SUCCESS Set transfer ring dequeue pointer succeeds.
1392 @retval Others Failed to set transfer ring dequeue pointer.
1397 XhcSetTrDequeuePointer (
1398 IN USB_XHCI_INSTANCE
*Xhc
,
1405 Create a new URB for a new transaction.
1407 @param Xhc The XHCI Instance
1408 @param DevAddr The device address
1409 @param EpAddr Endpoint addrress
1410 @param DevSpeed The device speed
1411 @param MaxPacket The max packet length of the endpoint
1412 @param Type The transaction type
1413 @param Request The standard USB request for control transfer
1414 @param Data The user data to transfer
1415 @param DataLen The length of data buffer
1416 @param Callback The function to call when data is transferred
1417 @param Context The context to the callback
1419 @return Created URB or NULL
1424 IN USB_XHCI_INSTANCE
*Xhc
,
1430 IN EFI_USB_DEVICE_REQUEST
*Request
,
1433 IN EFI_ASYNC_USB_TRANSFER_CALLBACK Callback
,
1438 Free an allocated URB.
1440 @param Xhc The XHCI device.
1441 @param Urb The URB to free.
1446 IN USB_XHCI_INSTANCE
*Xhc
,
1451 Create a transfer TRB.
1453 @param Xhc The XHCI Instance
1454 @param Urb The urb used to construct the transfer TRB.
1456 @return Created TRB or NULL
1460 XhcCreateTransferTrb (
1461 IN USB_XHCI_INSTANCE
*Xhc
,