]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Pci/UhciDxe/UhciSched.h
In various archs, Processor memory address may not be same with Pci memory address...
[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
6d3ea23f 5Copyright (c) 2007, 2009, Intel Corporation\r
913cb9dc 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
3af875e2 134 @param Uhc The UHCI device.\r
ab6495ea 135 @param Qh The queue head to link into.\r
913cb9dc 136\r
913cb9dc 137**/\r
138VOID\r
139UhciLinkQhToFrameList (\r
3af875e2 140 USB_HC_DEV *Uhc,\r
913cb9dc 141 UHCI_QH_SW *Qh\r
ed66e1bc 142 );\r
913cb9dc 143\r
144\r
145/**\r
146 Unlink QH from the frame list is easier: find all\r
147 the precedence node, and pointer there next to QhSw's\r
148 next.\r
149\r
3af875e2 150 @param Uhc The UHCI device.\r
ab6495ea 151 @param Qh The queue head to unlink.\r
913cb9dc 152\r
913cb9dc 153**/\r
154VOID\r
155UhciUnlinkQhFromFrameList (\r
3af875e2 156 USB_HC_DEV *Uhc,\r
157 UHCI_QH_SW *Qh\r
ed66e1bc 158 );\r
913cb9dc 159\r
160\r
161/**\r
ab6495ea 162 Check the result of the transfer.\r
913cb9dc 163\r
ab6495ea 164 @param Uhc The UHCI device.\r
165 @param Qh The queue head of the transfer.\r
166 @param Td The first TDs of the transfer.\r
167 @param TimeOut TimeOut value in milliseconds.\r
168 @param IsLow Is Low Speed Device.\r
169 @param QhResult The variable to return result.\r
913cb9dc 170\r
ab6495ea 171 @retval EFI_SUCCESS The transfer finished with success.\r
172 @retval EFI_DEVICE_ERROR Transfer failed.\r
913cb9dc 173\r
174**/\r
175EFI_STATUS\r
176UhciExecuteTransfer (\r
177 IN USB_HC_DEV *Uhc,\r
178 IN UHCI_QH_SW *Qh,\r
179 IN UHCI_TD_SW *Td,\r
180 IN UINTN TimeOut,\r
181 IN BOOLEAN IsLow,\r
182 OUT UHCI_QH_RESULT *QhResult\r
ed66e1bc 183 );\r
913cb9dc 184\r
185\r
186/**\r
ab6495ea 187 Create Async Request node, and Link to List.\r
188\r
189 @param Uhc The UHCI device.\r
190 @param Qh The queue head of the transfer.\r
191 @param FirstTd First TD of the transfer.\r
192 @param DevAddr Device Address.\r
193 @param EndPoint EndPoint Address.\r
194 @param DataLen Data length.\r
195 @param Interval Polling Interval when inserted to frame list.\r
196 @param Mapping Mapping value.\r
197 @param Data Data buffer, unmapped.\r
198 @param Callback Callback after interrupt transfeer.\r
199 @param Context Callback Context passed as function parameter.\r
200 @param IsLow Is Low Speed.\r
201\r
202 @retval EFI_SUCCESS An asynchronous transfer is created.\r
203 @retval EFI_INVALID_PARAMETER Paremeter is error.\r
913cb9dc 204 @retval EFI_OUT_OF_RESOURCES Failed because of resource shortage.\r
205\r
206**/\r
207EFI_STATUS\r
208UhciCreateAsyncReq (\r
209 IN USB_HC_DEV *Uhc,\r
210 IN UHCI_QH_SW *Qh,\r
211 IN UHCI_TD_SW *FirstTd,\r
212 IN UINT8 DevAddr,\r
213 IN UINT8 EndPoint,\r
214 IN UINTN DataLen,\r
215 IN UINTN Interval,\r
216 IN VOID *Mapping,\r
217 IN UINT8 *Data,\r
218 IN EFI_ASYNC_USB_TRANSFER_CALLBACK Callback,\r
219 IN VOID *Context,\r
220 IN BOOLEAN IsLow\r
ed66e1bc 221 );\r
913cb9dc 222\r
223\r
224/**\r
ab6495ea 225 Delete Async Interrupt QH and TDs.\r
913cb9dc 226\r
ab6495ea 227 @param Uhc The UHCI device.\r
228 @param DevAddr Device Address.\r
229 @param EndPoint EndPoint Address.\r
230 @param Toggle The next data toggle to use.\r
913cb9dc 231\r
ab6495ea 232 @retval EFI_SUCCESS The request is deleted.\r
233 @retval EFI_INVALID_PARAMETER Paremeter is error.\r
234 @retval EFI_NOT_FOUND The asynchronous isn't found.\r
913cb9dc 235\r
236**/\r
237EFI_STATUS\r
238UhciRemoveAsyncReq (\r
239 IN USB_HC_DEV *Uhc,\r
240 IN UINT8 DevAddr,\r
241 IN UINT8 EndPoint,\r
242 OUT UINT8 *Toggle\r
ed66e1bc 243 );\r
913cb9dc 244\r
245\r
246/**\r
247 Release all the asynchronous transfers on the lsit.\r
248\r
ab6495ea 249 @param Uhc The UHCI device.\r
913cb9dc 250\r
ab6495ea 251 @return None.\r
913cb9dc 252\r
253**/\r
254VOID\r
255UhciFreeAllAsyncReq (\r
256 IN USB_HC_DEV *Uhc\r
ed66e1bc 257 );\r
913cb9dc 258\r
259\r
260/**\r
ab6495ea 261 Interrupt transfer periodic check handler.\r
913cb9dc 262\r
ab6495ea 263 @param Event The event of the time.\r
264 @param Context Context of the event, pointer to USB_HC_DEV.\r
913cb9dc 265\r
ab6495ea 266 @return None.\r
913cb9dc 267\r
268**/\r
269VOID\r
6d3ea23f 270EFIAPI\r
913cb9dc 271UhciMonitorAsyncReqList (\r
272 IN EFI_EVENT Event,\r
273 IN VOID *Context\r
ed66e1bc 274 );\r
913cb9dc 275\r
276#endif\r