1 /** @file 2 3 This file contains the definination for host controller schedule routines. 4 5 Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR> 6 SPDX-License-Identifier: BSD-2-Clause-Patent 7 8 **/ 9 10 #ifndef _EFI_EHCI_SCHED_H_ 11 #define _EFI_EHCI_SCHED_H_ 12 13 14 /** 15 Initialize the schedule data structure such as frame list. 16 17 @param Ehc The EHCI device to init schedule data for. 18 19 @retval EFI_OUT_OF_RESOURCES Failed to allocate resource to init schedule data. 20 @retval EFI_SUCCESS The schedule data is initialized. 21 22 **/ 23 EFI_STATUS 24 EhcInitSched ( 25 IN USB2_HC_DEV *Ehc 26 ); 27 28 29 /** 30 Free the schedule data. It may be partially initialized. 31 32 @param Ehc The EHCI device. 33 34 **/ 35 VOID 36 EhcFreeSched ( 37 IN USB2_HC_DEV *Ehc 38 ); 39 40 41 /** 42 Link the queue head to the asynchronous schedule list. 43 UEFI only supports one CTRL/BULK transfer at a time 44 due to its interfaces. This simplifies the AsynList 45 management: A reclamation header is always linked to 46 the AsyncListAddr, the only active QH is appended to it. 47 48 @param Ehc The EHCI device. 49 @param Qh The queue head to link. 50 51 **/ 52 VOID 53 EhcLinkQhToAsync ( 54 IN USB2_HC_DEV *Ehc, 55 IN EHC_QH *Qh 56 ); 57 58 59 /** 60 Unlink a queue head from the asynchronous schedule list. 61 Need to synchronize with hardware. 62 63 @param Ehc The EHCI device. 64 @param Qh The queue head to unlink. 65 66 **/ 67 VOID 68 EhcUnlinkQhFromAsync ( 69 IN USB2_HC_DEV *Ehc, 70 IN EHC_QH *Qh 71 ); 72 73 74 /** 75 Link a queue head for interrupt transfer to the periodic 76 schedule frame list. This code is very much the same as 77 that in UHCI. 78 79 @param Ehc The EHCI device. 80 @param Qh The queue head to link. 81 82 **/ 83 VOID 84 EhcLinkQhToPeriod ( 85 IN USB2_HC_DEV *Ehc, 86 IN EHC_QH *Qh 87 ); 88 89 90 /** 91 Unlink an interrupt queue head from the periodic 92 schedule frame list. 93 94 @param Ehc The EHCI device. 95 @param Qh The queue head to unlink. 96 97 **/ 98 VOID 99 EhcUnlinkQhFromPeriod ( 100 IN USB2_HC_DEV *Ehc, 101 IN EHC_QH *Qh 102 ); 103 104 105 106 /** 107 Execute the transfer by polling the URB. This is a synchronous operation. 108 109 @param Ehc The EHCI device. 110 @param Urb The URB to execute. 111 @param TimeOut The time to wait before abort, in millisecond. 112 113 @retval EFI_DEVICE_ERROR The transfer failed due to transfer error. 114 @retval EFI_TIMEOUT The transfer failed due to time out. 115 @retval EFI_SUCCESS The transfer finished OK. 116 117 **/ 118 EFI_STATUS 119 EhcExecTransfer ( 120 IN USB2_HC_DEV *Ehc, 121 IN URB *Urb, 122 IN UINTN TimeOut 123 ); 124 125 126 /** 127 Delete a single asynchronous interrupt transfer for 128 the device and endpoint. 129 130 @param Ehc The EHCI device. 131 @param DevAddr The address of the target device. 132 @param EpNum The endpoint of the target. 133 @param DataToggle Return the next data toggle to use. 134 135 @retval EFI_SUCCESS An asynchronous transfer is removed. 136 @retval EFI_NOT_FOUND No transfer for the device is found. 137 138 **/ 139 EFI_STATUS 140 EhciDelAsyncIntTransfer ( 141 IN USB2_HC_DEV *Ehc, 142 IN UINT8 DevAddr, 143 IN UINT8 EpNum, 144 OUT UINT8 *DataToggle 145 ); 146 147 148 /** 149 Remove all the asynchronous interrutp transfers. 150 151 @param Ehc The EHCI device. 152 153 **/ 154 VOID 155 EhciDelAllAsyncIntTransfers ( 156 IN USB2_HC_DEV *Ehc 157 ); 158 159 /** 160 Insert a single asynchronous interrupt transfer for 161 the device and endpoint. 162 163 @param Ehc The EHCI device. 164 @param DevAddr The device address. 165 @param EpAddr Endpoint addrress & its direction. 166 @param DevSpeed The device speed. 167 @param Toggle Initial data toggle to use. 168 @param MaxPacket The max packet length of the endpoint. 169 @param Hub The transaction translator to use. 170 @param DataLen The length of data buffer. 171 @param Callback The function to call when data is transferred. 172 @param Context The context to the callback. 173 @param Interval The interval for interrupt transfer. 174 175 @return Created URB or NULL. 176 177 **/ 178 URB * 179 EhciInsertAsyncIntTransfer ( 180 IN USB2_HC_DEV *Ehc, 181 IN UINT8 DevAddr, 182 IN UINT8 EpAddr, 183 IN UINT8 DevSpeed, 184 IN UINT8 Toggle, 185 IN UINTN MaxPacket, 186 IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Hub, 187 IN UINTN DataLen, 188 IN EFI_ASYNC_USB_TRANSFER_CALLBACK Callback, 189 IN VOID *Context, 190 IN UINTN Interval 191 ); 192 193 /** 194 Interrupt transfer periodic check handler. 195 196 @param Event Interrupt event. 197 @param Context Pointer to USB2_HC_DEV. 198 199 **/ 200 VOID 201 EFIAPI 202 EhcMonitorAsyncRequests ( 203 IN EFI_EVENT Event, 204 IN VOID *Context 205 ); 206 207 #endif 208