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