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