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