]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Pci/UhciDxe/UhciSched.h
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / UhciDxe / UhciSched.h
CommitLineData
913cb9dc 1/** @file\r
2\r
ab6495ea 3 The definition for EHCI register operation routines.\r
4\r
cd5ebaa0 5Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
9d510e61 6SPDX-License-Identifier: BSD-2-Clause-Patent\r
913cb9dc 7\r
913cb9dc 8**/\r
9\r
10#ifndef _EFI_UHCI_SCHED_H_\r
11#define _EFI_UHCI_SCHED_H_\r
12\r
13\r
1ccdbf2a 14#define UHCI_ASYNC_INT_SIGNATURE SIGNATURE_32 ('u', 'h', 'c', 'a')\r
15//\r
16// The failure mask for USB transfer return status. If any of\r
17// these bit is set, the transfer failed. EFI_USB_ERR_NOEXECUTE\r
18// and EFI_USB_ERR_NAK are not considered as error condition:\r
19// the transfer is still going on.\r
20//\r
21#define USB_ERR_FAIL_MASK (EFI_USB_ERR_STALL | EFI_USB_ERR_BUFFER | \\r
22 EFI_USB_ERR_BABBLE | EFI_USB_ERR_CRC | \\r
23 EFI_USB_ERR_TIMEOUT | EFI_USB_ERR_BITSTUFF | \\r
24 EFI_USB_ERR_SYSTEM)\r
913cb9dc 25\r
913cb9dc 26\r
27//\r
28// Structure to return the result of UHCI QH execution.\r
29// Result is the final result of the QH's QTD. NextToggle\r
30// is the next data toggle to use. Complete is the actual\r
31// length of data transferred.\r
32//\r
33typedef struct {\r
34 UINT32 Result;\r
35 UINT8 NextToggle;\r
36 UINTN Complete;\r
37} UHCI_QH_RESULT;\r
38\r
39typedef struct _UHCI_ASYNC_REQUEST UHCI_ASYNC_REQUEST;\r
40\r
41//\r
42// Structure used to manager the asynchronous interrupt transfers.\r
43//\r
c52fa98c 44struct _UHCI_ASYNC_REQUEST{\r
913cb9dc 45 UINTN Signature;\r
46 LIST_ENTRY Link;\r
47 UHCI_ASYNC_REQUEST *Recycle;\r
48\r
49 //\r
50 // Endpoint attributes\r
51 //\r
52 UINT8 DevAddr;\r
53 UINT8 EndPoint;\r
54 BOOLEAN IsLow;\r
55 UINTN Interval;\r
56\r
57 //\r
58 // Data and UHC structures\r
59 //\r
60 UHCI_QH_SW *QhSw;\r
61 UHCI_TD_SW *FirstTd;\r
62 UINT8 *Data; // Allocated host memory, not mapped memory\r
63 UINTN DataLen;\r
64 VOID *Mapping;\r
65\r
66 //\r
67 // User callback and its context\r
68 //\r
69 EFI_ASYNC_USB_TRANSFER_CALLBACK Callback;\r
70 VOID *Context;\r
c52fa98c 71};\r
913cb9dc 72\r
73#define UHCI_ASYNC_INT_FROM_LINK(a) \\r
74 CR (a, UHCI_ASYNC_REQUEST, Link, UHCI_ASYNC_INT_SIGNATURE)\r
75\r
913cb9dc 76\r
ab6495ea 77/**\r
78 Create Frame List Structure.\r
913cb9dc 79\r
ab6495ea 80 @param Uhc The UHCI device.\r
913cb9dc 81\r
ab6495ea 82 @return EFI_OUT_OF_RESOURCES Can't allocate memory resources.\r
83 @return EFI_UNSUPPORTED Map memory fail.\r
84 @return EFI_SUCCESS Success.\r
913cb9dc 85\r
ab6495ea 86**/\r
87EFI_STATUS\r
88UhciInitFrameList (\r
89 IN USB_HC_DEV *Uhc\r
ed66e1bc 90 );\r
913cb9dc 91\r
913cb9dc 92/**\r
ab6495ea 93 Destory FrameList buffer.\r
913cb9dc 94\r
ab6495ea 95 @param Uhc The UHCI device.\r
913cb9dc 96\r
ab6495ea 97 @return None.\r
913cb9dc 98\r
99**/\r
100VOID\r
101UhciDestoryFrameList (\r
102 IN USB_HC_DEV *Uhc\r
ed66e1bc 103 );\r
913cb9dc 104\r
105\r
106/**\r
107 Convert the poll rate to the maxium 2^n that is smaller\r
ab6495ea 108 than Interval.\r
913cb9dc 109\r
ab6495ea 110 @param Interval The poll rate to convert.\r
913cb9dc 111\r
ab6495ea 112 @return The converted poll rate.\r
913cb9dc 113\r
114**/\r
115UINTN\r
116UhciConvertPollRate (\r
117 IN UINTN Interval\r
ed66e1bc 118 );\r
913cb9dc 119\r
120\r
121/**\r
122 Link a queue head (for asynchronous interrupt transfer) to\r
123 the frame list.\r
124\r
3af875e2 125 @param Uhc The UHCI device.\r
ab6495ea 126 @param Qh The queue head to link into.\r
913cb9dc 127\r
913cb9dc 128**/\r
129VOID\r
130UhciLinkQhToFrameList (\r
3af875e2 131 USB_HC_DEV *Uhc,\r
913cb9dc 132 UHCI_QH_SW *Qh\r
ed66e1bc 133 );\r
913cb9dc 134\r
135\r
136/**\r
137 Unlink QH from the frame list is easier: find all\r
138 the precedence node, and pointer there next to QhSw's\r
139 next.\r
140\r
3af875e2 141 @param Uhc The UHCI device.\r
ab6495ea 142 @param Qh The queue head to unlink.\r
913cb9dc 143\r
913cb9dc 144**/\r
145VOID\r
146UhciUnlinkQhFromFrameList (\r
3af875e2 147 USB_HC_DEV *Uhc,\r
148 UHCI_QH_SW *Qh\r
ed66e1bc 149 );\r
913cb9dc 150\r
151\r
152/**\r
ab6495ea 153 Check the result of the transfer.\r
913cb9dc 154\r
ab6495ea 155 @param Uhc The UHCI device.\r
156 @param Qh The queue head of the transfer.\r
157 @param Td The first TDs of the transfer.\r
158 @param TimeOut TimeOut value in milliseconds.\r
159 @param IsLow Is Low Speed Device.\r
160 @param QhResult The variable to return result.\r
913cb9dc 161\r
ab6495ea 162 @retval EFI_SUCCESS The transfer finished with success.\r
163 @retval EFI_DEVICE_ERROR Transfer failed.\r
913cb9dc 164\r
165**/\r
166EFI_STATUS\r
167UhciExecuteTransfer (\r
168 IN USB_HC_DEV *Uhc,\r
169 IN UHCI_QH_SW *Qh,\r
170 IN UHCI_TD_SW *Td,\r
171 IN UINTN TimeOut,\r
172 IN BOOLEAN IsLow,\r
173 OUT UHCI_QH_RESULT *QhResult\r
ed66e1bc 174 );\r
913cb9dc 175\r
176\r
177/**\r
ab6495ea 178 Create Async Request node, and Link to List.\r
179\r
180 @param Uhc The UHCI device.\r
181 @param Qh The queue head of the transfer.\r
182 @param FirstTd First TD of the transfer.\r
183 @param DevAddr Device Address.\r
184 @param EndPoint EndPoint Address.\r
185 @param DataLen Data length.\r
186 @param Interval Polling Interval when inserted to frame list.\r
ab6495ea 187 @param Data Data buffer, unmapped.\r
188 @param Callback Callback after interrupt transfeer.\r
189 @param Context Callback Context passed as function parameter.\r
190 @param IsLow Is Low Speed.\r
191\r
192 @retval EFI_SUCCESS An asynchronous transfer is created.\r
193 @retval EFI_INVALID_PARAMETER Paremeter is error.\r
913cb9dc 194 @retval EFI_OUT_OF_RESOURCES Failed because of resource shortage.\r
195\r
196**/\r
197EFI_STATUS\r
198UhciCreateAsyncReq (\r
199 IN USB_HC_DEV *Uhc,\r
200 IN UHCI_QH_SW *Qh,\r
201 IN UHCI_TD_SW *FirstTd,\r
202 IN UINT8 DevAddr,\r
203 IN UINT8 EndPoint,\r
204 IN UINTN DataLen,\r
205 IN UINTN Interval,\r
913cb9dc 206 IN UINT8 *Data,\r
207 IN EFI_ASYNC_USB_TRANSFER_CALLBACK Callback,\r
208 IN VOID *Context,\r
209 IN BOOLEAN IsLow\r
ed66e1bc 210 );\r
913cb9dc 211\r
212\r
213/**\r
ab6495ea 214 Delete Async Interrupt QH and TDs.\r
913cb9dc 215\r
ab6495ea 216 @param Uhc The UHCI device.\r
217 @param DevAddr Device Address.\r
218 @param EndPoint EndPoint Address.\r
219 @param Toggle The next data toggle to use.\r
913cb9dc 220\r
ab6495ea 221 @retval EFI_SUCCESS The request is deleted.\r
222 @retval EFI_INVALID_PARAMETER Paremeter is error.\r
223 @retval EFI_NOT_FOUND The asynchronous isn't found.\r
913cb9dc 224\r
225**/\r
226EFI_STATUS\r
227UhciRemoveAsyncReq (\r
228 IN USB_HC_DEV *Uhc,\r
229 IN UINT8 DevAddr,\r
230 IN UINT8 EndPoint,\r
231 OUT UINT8 *Toggle\r
ed66e1bc 232 );\r
913cb9dc 233\r
234\r
235/**\r
236 Release all the asynchronous transfers on the lsit.\r
237\r
ab6495ea 238 @param Uhc The UHCI device.\r
913cb9dc 239\r
ab6495ea 240 @return None.\r
913cb9dc 241\r
242**/\r
243VOID\r
244UhciFreeAllAsyncReq (\r
245 IN USB_HC_DEV *Uhc\r
ed66e1bc 246 );\r
913cb9dc 247\r
248\r
249/**\r
ab6495ea 250 Interrupt transfer periodic check handler.\r
913cb9dc 251\r
ab6495ea 252 @param Event The event of the time.\r
253 @param Context Context of the event, pointer to USB_HC_DEV.\r
913cb9dc 254\r
ab6495ea 255 @return None.\r
913cb9dc 256\r
257**/\r
258VOID\r
6d3ea23f 259EFIAPI\r
913cb9dc 260UhciMonitorAsyncReqList (\r
261 IN EFI_EVENT Event,\r
262 IN VOID *Context\r
ed66e1bc 263 );\r
913cb9dc 264\r
265#endif\r