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