20 if ( !ep->m_hcEd->m_tdTail || ED_HALTED(*(ep->m_hcEd)) || ED_SKIPPED(*(ep->m_hcEd)) || !ep->m_ioReqListStart )
23 if ( ep->m_inTdQueue == NOTIN_QUEUE )
26 ep->m_busyNext->m_busyPrev = ep->m_busyPrev;
28 memPool->m_tdQueueEnd = ep->m_busyPrev;
31 ep->m_busyPrev->m_busyNext = ep->m_busyNext;
35 memPool->m_tdQueueStart = ep->m_busyNext;
37 ep->m_inTdQueue = NOTIN_QUEUE;
40 curIoReq = ep->m_ioReqListStart;
42 if ( curIoReq->m_destPtr && (
int)curIoReq->m_length > 0 )
47 if ( ep->m_inTdQueue != NOTIN_QUEUE )
49 ep->m_busyPrev = memPool->m_tdQueueEnd;
50 if ( memPool->m_tdQueueEnd )
52 memPool->m_tdQueueEnd->m_busyNext = ep;
56 memPool->m_tdQueueStart = ep;
58 ep->m_busyNext = NULL;
59 memPool->m_tdQueueEnd = ep;
60 ep->m_inTdQueue = GENTD_QUEUE;
66 if ( !statusTd || !tailTd )
71 if ( ep->m_inTdQueue != NOTIN_QUEUE )
73 ep->m_busyPrev = memPool->m_tdQueueEnd;
74 if ( memPool->m_tdQueueEnd )
76 memPool->m_tdQueueEnd->m_busyNext = ep;
80 memPool->m_tdQueueStart = ep;
82 ep->m_busyNext = NULL;
83 memPool->m_tdQueueEnd = ep;
84 ep->m_inTdQueue = GENTD_QUEUE;
87 if ( curIoReq->m_next )
88 curIoReq->m_next->m_prev = curIoReq->m_prev;
90 ep->m_ioReqListEnd = curIoReq->m_prev;
91 if ( curIoReq->m_prev )
92 curIoReq->m_prev->m_next = curIoReq->m_next;
94 ep->m_ioReqListStart = curIoReq->m_next;
96 ep->m_hcEd->m_tdTail->m_hcArea = TD_HCAREA(
USB_RC_NOTACCESSED, 2, 7, TD_SETUP, 0) << 16;
97 ep->m_hcEd->m_tdTail->m_curBufPtr = &curIoReq->m_devReq;
98 ep->m_hcEd->m_tdTail->m_next = dataTd ? dataTd : statusTd;
99 ep->m_hcEd->m_tdTail->m_bufferEnd = ((u8 *)&curIoReq->m_devReq) +
sizeof(
UsbDeviceRequest) - 1;
100 memPool->m_hcTdToIoReqLUT[ep->m_hcEd->m_tdTail - memPool->m_hcTdBuf] = curIoReq;
104 dataTd->m_hcArea = (curIoReq->m_devReq.requesttype & USB_ENDPOINT_DIR_MASK) != USB_DIR_IN ?
107 dataTd->m_next = statusTd;
108 dataTd->m_curBufPtr = curIoReq->m_destPtr;
109 dataTd->m_bufferEnd = (u8 *)curIoReq->m_destPtr + curIoReq->m_length - 1;
110 memPool->m_hcTdToIoReqLUT[dataTd - memPool->m_hcTdBuf] = curIoReq;
113 statusTd->m_hcArea = (curIoReq->m_devReq.requesttype & USB_ENDPOINT_DIR_MASK) != USB_DIR_IN ?
116 statusTd->m_curBufPtr = NULL;
117 statusTd->m_next = tailTd;
118 statusTd->m_bufferEnd = NULL;
119 memPool->m_hcTdToIoReqLUT[statusTd - memPool->m_hcTdBuf] = curIoReq;
120 ep->m_hcEd->m_tdTail = tailTd;
121 memPool->m_ohciRegs->HcCommandStatus |= OHCI_COM_CLF;
122 if ( ep->m_ioReqListStart )
126 if ( ep->m_inTdQueue == NOTIN_QUEUE )
131 if ( ep->m_busyNext )
132 ep->m_busyNext->m_busyPrev = ep->m_busyPrev;
134 memPool->m_tdQueueEnd = ep->m_busyPrev;
135 if ( ep->m_busyPrev )
136 ep->m_busyPrev->m_busyNext = ep->m_busyNext;
138 memPool->m_tdQueueStart = ep->m_busyNext;
139 ep->m_inTdQueue = NOTIN_QUEUE;
152 if ( !ed->m_tdTail || ED_HALTED(*ed) || ED_SKIPPED(*ed) || !ep->m_ioReqListStart )
155 if ( ep->m_inTdQueue == NOTIN_QUEUE )
157 if ( ep->m_busyNext )
158 ep->m_busyNext->m_busyPrev = ep->m_busyPrev;
160 memPool->m_tdQueueEnd = ep->m_busyPrev;
161 if ( ep->m_busyPrev )
163 ep->m_busyPrev->m_busyNext = ep->m_busyNext;
167 memPool->m_tdQueueStart = ep->m_busyNext;
169 ep->m_inTdQueue = NOTIN_QUEUE;
172 curIoReq = ep->m_ioReqListStart;
174 newTd = allocIsoTd();
177 if ( ep->m_inTdQueue != NOTIN_QUEUE )
179 ep->m_busyPrev = memPool->m_tdQueueEnd;
180 if ( memPool->m_tdQueueEnd )
181 memPool->m_tdQueueEnd->m_busyNext = ep;
183 memPool->m_tdQueueStart = ep;
184 ep->m_busyNext = NULL;
185 memPool->m_tdQueueEnd = ep;
186 ep->m_inTdQueue = ISOTD_QUEUE;
189 if ( curIoReq->m_next )
190 curIoReq->m_next->m_prev = curIoReq->m_prev;
192 ep->m_ioReqListEnd = curIoReq->m_prev;
193 if ( curIoReq->m_prev )
194 curIoReq->m_prev->m_next = curIoReq->m_next;
196 ep->m_ioReqListStart = curIoReq->m_next;
197 if ( (
UsbdHcTD_t *)((uiptr)ed->m_tdHead & ~0xF) == ed->m_tdTail )
198 frameNo = (memPool->m_hcHCCA->FrameNumber + 2) & 0xFFFF;
200 frameNo = (ep->m_isochronLastFrameNum) & 0xFFFF;
201 frameNo = (u16)(frameNo + (curIoReq->m_waitFrames & 0xFFFF));
202 ep->m_isochronLastFrameNum = (curIoReq->m_req.bNumPackets ? (curIoReq->m_req.bNumPackets & 0xFFFF) : 1) + frameNo;
203 if ( curIoReq->m_req.bNumPackets )
208 curTd->m_hcArea = ((curIoReq->m_req.bNumPackets - 1) << 24) | frameNo | (
USB_RC_NOTACCESSED << 28);
209 curTd->m_next = newTd;
210 curTd->m_bufferPage0 = (
void *)((uiptr)curIoReq->m_destPtr & ~0xFFF);
211 curTd->m_bufferEnd = NULL;
212 if ( curIoReq->m_destPtr && (
int)(curIoReq->m_length) > 0 )
214 curTd->m_bufferEnd = (u8 *)curIoReq->m_destPtr + ((
int)curIoReq->m_length - 1);
217 for ( i = 0; i < (int)curIoReq->m_req.bNumPackets; i += 1 )
219 curTd->m_psw[i] = psw0_tmp;
220 psw0_tmp += curIoReq->m_req.Packets[i].bLength;
226 curTd->m_next = newTd;
227 curTd->m_bufferPage0 = (
void *)((uiptr)curIoReq->m_destPtr & ~0xFFF);
228 curTd->m_bufferEnd = NULL;
229 if ( curIoReq->m_destPtr && (
int)(curIoReq->m_length) > 0 )
231 curTd->m_bufferEnd = (u8 *)curIoReq->m_destPtr + ((
int)curIoReq->m_length - 1);
235 memPool->m_hcIsoTdToIoReqLUT[curTd - memPool->m_hcIsoTdBuf] = curIoReq;
237 if ( ep->m_ioReqListStart )
241 if ( ep->m_inTdQueue == NOTIN_QUEUE )
246 if ( ep->m_busyNext )
247 ep->m_busyNext->m_busyPrev = ep->m_busyPrev;
249 memPool->m_tdQueueEnd = ep->m_busyPrev;
250 if ( ep->m_busyPrev )
251 ep->m_busyPrev->m_busyNext = ep->m_busyNext;
253 memPool->m_tdQueueStart = ep->m_busyNext;
254 ep->m_inTdQueue = NOTIN_QUEUE;
266 if ( !ed->m_tdTail || ED_HALTED(*ed) || ED_SKIPPED(*ed) || !ep->m_ioReqListStart )
269 dbg_printf(
"ERROR UsbdEndpoint_t error\n");
270 if ( ep->m_inTdQueue == NOTIN_QUEUE )
272 if ( ep->m_busyNext )
273 ep->m_busyNext->m_busyPrev = ep->m_busyPrev;
275 memPool->m_tdQueueEnd = ep->m_busyPrev;
276 if ( ep->m_busyPrev )
278 ep->m_busyPrev->m_busyNext = ep->m_busyNext;
282 memPool->m_tdQueueStart = ep->m_busyNext;
284 ep->m_inTdQueue = NOTIN_QUEUE;
287 curIoReq = ep->m_ioReqListStart;
288 curTd = ed->m_tdTail;
292 if ( ep->m_inTdQueue != NOTIN_QUEUE )
294 ep->m_busyPrev = memPool->m_tdQueueEnd;
295 if ( memPool->m_tdQueueEnd )
296 memPool->m_tdQueueEnd->m_busyNext = ep;
298 memPool->m_tdQueueStart = ep;
299 ep->m_busyNext = NULL;
300 memPool->m_tdQueueEnd = ep;
301 ep->m_inTdQueue = GENTD_QUEUE;
304 if ( curIoReq->m_next )
305 curIoReq->m_next->m_prev = curIoReq->m_prev;
307 ep->m_ioReqListEnd = curIoReq->m_prev;
308 if ( curIoReq->m_prev )
309 curIoReq->m_prev->m_next = curIoReq->m_next;
311 ep->m_ioReqListStart = curIoReq->m_next;
313 curTd->m_next = newTd;
314 curTd->m_curBufPtr = curIoReq->m_destPtr;
315 curTd->m_bufferEnd = NULL;
316 if ( curIoReq->m_destPtr && (
int)curIoReq->m_length > 0 )
318 curTd->m_bufferEnd = (u8 *)curIoReq->m_destPtr + ((
int)curIoReq->m_length - 1);
320 memPool->m_hcTdToIoReqLUT[curTd - memPool->m_hcTdBuf] = curIoReq;
321 ed->m_tdTail = newTd;
322 if ( ep->m_endpointType == TYPE_BULK )
323 memPool->m_ohciRegs->HcCommandStatus |= OHCI_COM_BLF;
324 if ( ep->m_ioReqListStart )
328 if ( ep->m_inTdQueue == NOTIN_QUEUE )
333 if ( ep->m_busyNext )
334 ep->m_busyNext->m_busyPrev = ep->m_busyPrev;
336 memPool->m_tdQueueEnd = ep->m_busyPrev;
337 if ( ep->m_busyPrev )
338 ep->m_busyPrev->m_busyNext = ep->m_busyNext;
340 memPool->m_tdQueueStart = ep->m_busyNext;
341 ep->m_inTdQueue = NOTIN_QUEUE;
347 switch ( ep->m_endpointType )
351 setupControlTransfer(ep);
356 setupIsocronTransfer(ep);
362 setupBulkTransfer(ep);
#define USB_RC_NOTACCESSED