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