]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Bus/Pci/UhciDxe/UhciSched.h
Fix bug: The lower 2 bits of Width and stripped, Count will always be multiplied...
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / UhciDxe / UhciSched.h
... / ...
CommitLineData
1/** @file\r
2\r
3 The definition for EHCI register operation routines.\r
4\r
5Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
6This 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
14**/\r
15\r
16#ifndef _EFI_UHCI_SCHED_H_\r
17#define _EFI_UHCI_SCHED_H_\r
18\r
19\r
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
31\r
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
50struct _UHCI_ASYNC_REQUEST{\r
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
77};\r
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
82\r
83/**\r
84 Create Frame List Structure.\r
85\r
86 @param Uhc The UHCI device.\r
87\r
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
91\r
92**/\r
93EFI_STATUS\r
94UhciInitFrameList (\r
95 IN USB_HC_DEV *Uhc\r
96 );\r
97\r
98/**\r
99 Destory FrameList buffer.\r
100\r
101 @param Uhc The UHCI device.\r
102\r
103 @return None.\r
104\r
105**/\r
106VOID\r
107UhciDestoryFrameList (\r
108 IN USB_HC_DEV *Uhc\r
109 );\r
110\r
111\r
112/**\r
113 Convert the poll rate to the maxium 2^n that is smaller\r
114 than Interval.\r
115\r
116 @param Interval The poll rate to convert.\r
117\r
118 @return The converted poll rate.\r
119\r
120**/\r
121UINTN\r
122UhciConvertPollRate (\r
123 IN UINTN Interval\r
124 );\r
125\r
126\r
127/**\r
128 Link a queue head (for asynchronous interrupt transfer) to\r
129 the frame list.\r
130\r
131 @param Uhc The UHCI device.\r
132 @param Qh The queue head to link into.\r
133\r
134**/\r
135VOID\r
136UhciLinkQhToFrameList (\r
137 USB_HC_DEV *Uhc,\r
138 UHCI_QH_SW *Qh\r
139 );\r
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
147 @param Uhc The UHCI device.\r
148 @param Qh The queue head to unlink.\r
149\r
150**/\r
151VOID\r
152UhciUnlinkQhFromFrameList (\r
153 USB_HC_DEV *Uhc,\r
154 UHCI_QH_SW *Qh\r
155 );\r
156\r
157\r
158/**\r
159 Check the result of the transfer.\r
160\r
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
167\r
168 @retval EFI_SUCCESS The transfer finished with success.\r
169 @retval EFI_DEVICE_ERROR Transfer failed.\r
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
180 );\r
181\r
182\r
183/**\r
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
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
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
212 IN UINT8 *Data,\r
213 IN EFI_ASYNC_USB_TRANSFER_CALLBACK Callback,\r
214 IN VOID *Context,\r
215 IN BOOLEAN IsLow\r
216 );\r
217\r
218\r
219/**\r
220 Delete Async Interrupt QH and TDs.\r
221\r
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
226\r
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
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
238 );\r
239\r
240\r
241/**\r
242 Release all the asynchronous transfers on the lsit.\r
243\r
244 @param Uhc The UHCI device.\r
245\r
246 @return None.\r
247\r
248**/\r
249VOID\r
250UhciFreeAllAsyncReq (\r
251 IN USB_HC_DEV *Uhc\r
252 );\r
253\r
254\r
255/**\r
256 Interrupt transfer periodic check handler.\r
257\r
258 @param Event The event of the time.\r
259 @param Context Context of the event, pointer to USB_HC_DEV.\r
260\r
261 @return None.\r
262\r
263**/\r
264VOID\r
265EFIAPI\r
266UhciMonitorAsyncReqList (\r
267 IN EFI_EVENT Event,\r
268 IN VOID *Context\r
269 );\r
270\r
271#endif\r