100 // IN endpoints don't need a packet array |
105 // IN endpoints don't need a packet array |
101 |
106 |
102 // At most 2 packets (clump of max packet size packets) + possible zlp |
107 // At most 2 packets (clump of max packet size packets) + possible zlp |
103 TUsbcPacketArray* bufPtr = iPacketInfoStorage; |
108 TUsbcPacketArray* bufPtr = iPacketInfoStorage; |
104 // this divides up the packet indexing & packet size array over the number of buffers |
109 // this divides up the packet indexing & packet size array over the number of buffers |
105 __KTRACE_OPT(KUSB, Kern::Printf("TDmaBuf::Construct() array base=0x%08x", bufPtr)); |
110 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TDMABUF_CONSTRUCT, |
|
111 "TDmaBuf::Construct() array base=0x%08x", bufPtr ); |
106 for (TInt i = 0; i < iNumberofBuffers; i++) |
112 for (TInt i = 0; i < iNumberofBuffers; i++) |
107 { |
113 { |
108 iPacketIndex[i] = bufPtr; |
114 iPacketIndex[i] = bufPtr; |
109 bufPtr += KUsbcDmaBufMaxPkts; |
115 bufPtr += KUsbcDmaBufMaxPkts; |
110 iPacketSize[i] = bufPtr; |
116 iPacketSize[i] = bufPtr; |
111 bufPtr += KUsbcDmaBufMaxPkts; |
117 bufPtr += KUsbcDmaBufMaxPkts; |
112 __KTRACE_OPT(KUSB, Kern::Printf("TDmaBuf::Construct() packetIndex[%d]=0x%08x packetSize[%d]=0x%08x", |
118 OstTraceDefExt4( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TDMABUF_CONSTRUCT_DUP1, |
113 i, iPacketIndex[i], i, iPacketSize[i])); |
119 "TDmaBuf::Construct() packetIndex[%d]=0x%08x packetSize[%d]=0x%08x", |
|
120 i, reinterpret_cast<TUint>(iPacketIndex[i]), i, |
|
121 reinterpret_cast<TUint>(iPacketSize[i]) ); |
|
122 |
114 } |
123 } |
115 } |
124 } |
116 else |
125 else |
117 { |
126 { |
118 __KTRACE_OPT(KUSB, Kern::Printf("TDmaBuf::Construct() IN endpoint")); |
127 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TDMABUF_CONSTRUCT_DUP2, |
|
128 "TDmaBuf::Construct() IN endpoint" ); |
119 } |
129 } |
120 Flush(); |
130 Flush(); |
121 return KErrNone; |
131 return KErrNone; |
122 } |
132 } |
123 |
133 |
124 |
134 |
125 TDmaBuf::~TDmaBuf() |
135 TDmaBuf::~TDmaBuf() |
126 { |
136 { |
127 __KTRACE_OPT(KUSB, Kern::Printf("TDmaBuf::~TDmaBuf()")); |
137 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TDMABUF_TDMABUF_DES, "TDmaBuf::~TDmaBuf()" ); |
128 } |
138 } |
129 |
139 |
130 TInt TDmaBuf::BufferTotalSize() const |
140 TInt TDmaBuf::BufferTotalSize() const |
131 { |
141 { |
132 return iBufSz * iNumberofBuffers; |
142 return iBufSz * iNumberofBuffers; |
142 __ASSERT_DEBUG((aBufInd < iNumberofBuffers), |
152 __ASSERT_DEBUG((aBufInd < iNumberofBuffers), |
143 Kern::Fault(KUsbPanicLdd, __LINE__)); |
153 Kern::Fault(KUsbPanicLdd, __LINE__)); |
144 iDrainable[aBufInd] = iCanBeFreed[aBufInd] = EFalse; |
154 iDrainable[aBufInd] = iCanBeFreed[aBufInd] = EFalse; |
145 iBuffers[aBufInd] = aBufAddr; |
155 iBuffers[aBufInd] = aBufAddr; |
146 iBufferPhys[aBufInd] = Epoc::LinearToPhysical((TLinAddr)aBufAddr); |
156 iBufferPhys[aBufInd] = Epoc::LinearToPhysical((TLinAddr)aBufAddr); |
147 __KTRACE_OPT(KUSB, Kern::Printf("TDmaBuf::SetBufferAddr() iBuffers[%d]=0x%08x", aBufInd, iBuffers[aBufInd])); |
157 OstTraceDefExt2( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TDMABUF_SETBUFFERADDR, |
|
158 "TDmaBuf::SetBufferAddr() iBuffers[%d]=0x%08x", aBufInd, |
|
159 reinterpret_cast<TUint>(iBuffers[aBufInd]) ); |
148 return KErrNone; |
160 return KErrNone; |
149 } |
161 } |
150 |
162 |
151 TInt TDmaBuf::BufferNumber() const |
163 TInt TDmaBuf::BufferNumber() const |
152 { |
164 { |
194 } |
207 } |
195 |
208 |
196 |
209 |
197 void TDmaBuf::RxSetActive() |
210 void TDmaBuf::RxSetActive() |
198 { |
211 { |
199 __KTRACE_OPT(KUSB, Kern::Printf("TDmaBuf::RxSetActive %x", this)); |
212 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TDMABUF_RXSETACTIVE, |
|
213 "TDmaBuf::RxSetActive %x", this ); |
200 iRxActive = ETrue; |
214 iRxActive = ETrue; |
201 } |
215 } |
202 |
216 |
203 |
217 |
204 void TDmaBuf::RxSetInActive() |
218 void TDmaBuf::RxSetInActive() |
205 { |
219 { |
206 __KTRACE_OPT(KUSB, Kern::Printf("TDmaBuf::RxSetInActive %x", this)); |
220 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TDMABUF_RXSETINACTIVE, |
|
221 "TDmaBuf::RxSetInActive %x", this ); |
207 iRxActive = EFalse; |
222 iRxActive = EFalse; |
208 } |
223 } |
209 |
224 |
210 |
225 |
211 TBool TDmaBuf::RxIsActive() |
226 TBool TDmaBuf::RxIsActive() |
312 |
327 |
313 |
328 |
314 // used to decide whether a client read can complete straight away |
329 // used to decide whether a client read can complete straight away |
315 TBool TDmaBuf::IsReaderEmpty() |
330 TBool TDmaBuf::IsReaderEmpty() |
316 { |
331 { |
317 __KTRACE_OPT(KUSB, Kern::Printf("TDmaBuf::IsReaderEmpty iTotalRxPacketsAvail=%d", |
332 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TDMABUF_ISREADEREMPTY, |
318 iTotalRxPacketsAvail)); |
333 "TDmaBuf::IsReaderEmpty iTotalRxPacketsAvail=%d", iTotalRxPacketsAvail); |
319 return (iTotalRxPacketsAvail == 0); |
334 return (iTotalRxPacketsAvail == 0); |
320 } |
335 } |
321 |
336 |
322 |
337 |
323 void TDmaBuf::ReadXferComplete(TInt aNoBytesRecv, TInt aNoPacketsRecv, TInt aErrorCode) |
338 void TDmaBuf::ReadXferComplete(TInt aNoBytesRecv, TInt aNoPacketsRecv, TInt aErrorCode) |
338 #if defined(USBC_LDD_BUFFER_TRACE) |
353 #if defined(USBC_LDD_BUFFER_TRACE) |
339 iNumberofBytesRxRemain[iCurrentFillingBufferIndex] = aNoBytesRecv; |
354 iNumberofBytesRxRemain[iCurrentFillingBufferIndex] = aNoBytesRecv; |
340 iNumberofPacketsRxRemain[iCurrentFillingBufferIndex] = aNoPacketsRecv; |
355 iNumberofPacketsRxRemain[iCurrentFillingBufferIndex] = aNoPacketsRecv; |
341 #endif |
356 #endif |
342 |
357 |
343 __KTRACE_OPT(KUSB, Kern::Printf("TDmaBuf::ReadXferComplete 2 # of bytes=%d # of packets=%d", |
358 OstTraceDefExt2( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TDMABUF_READXFERCOMPLETE, |
344 iTotalRxBytesAvail, iTotalRxPacketsAvail)); |
359 "TDmaBuf::ReadXferComplete 2 # of bytes=%d # of packets=%d", iTotalRxBytesAvail, iTotalRxPacketsAvail ); |
345 iDrainable[iCurrentFillingBufferIndex] = ETrue; |
360 iDrainable[iCurrentFillingBufferIndex] = ETrue; |
346 iError[iCurrentFillingBufferIndex] = aErrorCode; |
361 iError[iCurrentFillingBufferIndex] = aErrorCode; |
347 AddToDrainQueue(iCurrentFillingBufferIndex); |
362 AddToDrainQueue(iCurrentFillingBufferIndex); |
348 if (iCurrentDrainingBufferIndex == KUsbcInvalidBufferIndex) |
363 if (iCurrentDrainingBufferIndex == KUsbcInvalidBufferIndex) |
349 { |
364 { |
353 |
368 |
354 |
369 |
355 TInt TDmaBuf::RxGetNextXfer(TUint8*& aBufferAddr, TUsbcPacketArray*& aIndexArray, |
370 TInt TDmaBuf::RxGetNextXfer(TUint8*& aBufferAddr, TUsbcPacketArray*& aIndexArray, |
356 TUsbcPacketArray*& aSizeArray, TInt& aLength, TPhysAddr& aBufferPhys) |
371 TUsbcPacketArray*& aSizeArray, TInt& aLength, TPhysAddr& aBufferPhys) |
357 { |
372 { |
358 __KTRACE_OPT(KUSB, Kern::Printf("TDmaBuf::RxGetNextXfer 1")); |
373 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TDMABUF_RXGETNEXTXFER, |
|
374 "TDmaBuf::RxGetNextXfer 1" ); |
359 if (RxIsActive()) |
375 if (RxIsActive()) |
360 { |
376 { |
361 __KTRACE_OPT(KUSB, Kern::Printf(" ---> RxIsActive, returning")); |
377 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TDMABUF_RXGETNEXTXFER_DUP1, |
|
378 " ---> RxIsActive, returning" ); |
362 return KErrInUse; |
379 return KErrInUse; |
363 } |
380 } |
364 |
381 |
365 __KTRACE_OPT(KUSB, Kern::Printf("TDmaBuf::RxGetNextXfer Current buffer=%d", |
382 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TDMABUF_RXGETNEXTXFER_DUP2, |
366 iCurrentFillingBufferIndex)); |
383 "TDmaBuf::RxGetNextXfer Current buffer=%d", iCurrentFillingBufferIndex ); |
367 if (iDrainable[iCurrentFillingBufferIndex]) |
384 if (iDrainable[iCurrentFillingBufferIndex]) |
368 { |
385 { |
369 // If the controller refused the last read request, then the current buffer will still be marked |
386 // If the controller refused the last read request, then the current buffer will still be marked |
370 // as !Drainable, because the controller never completed the read to the ldd. and therefore the buffer |
387 // as !Drainable, because the controller never completed the read to the ldd. and therefore the buffer |
371 // can be reused. |
388 // can be reused. |
373 { |
390 { |
374 return KErrNoMemory; |
391 return KErrNoMemory; |
375 } |
392 } |
376 } |
393 } |
377 |
394 |
378 __KTRACE_OPT(KUSB, Kern::Printf("TDmaBuf::RxGetNextXfer New buffer=%d", |
395 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TDMABUF_RXGETNEXTXFER_DUP3, |
379 iCurrentFillingBufferIndex)); |
396 "TDmaBuf::RxGetNextXfer New buffer=%d", iCurrentFillingBufferIndex ); |
380 aBufferAddr = iBuffers[iCurrentFillingBufferIndex]; |
397 aBufferAddr = iBuffers[iCurrentFillingBufferIndex]; |
381 aBufferPhys = iBufferPhys[iCurrentFillingBufferIndex]; |
398 aBufferPhys = iBufferPhys[iCurrentFillingBufferIndex]; |
382 aIndexArray = iPacketIndex[iCurrentFillingBufferIndex]; |
399 aIndexArray = iPacketIndex[iCurrentFillingBufferIndex]; |
383 aSizeArray = iPacketSize[iCurrentFillingBufferIndex]; |
400 aSizeArray = iPacketSize[iCurrentFillingBufferIndex]; |
384 aLength = iBufSz; |
401 aLength = iBufSz; |
391 } |
408 } |
392 |
409 |
393 |
410 |
394 TInt TDmaBuf::RxCopyPacketToClient(DThread* aThread, TClientBuffer *aTcb, TInt aLength) |
411 TInt TDmaBuf::RxCopyPacketToClient(DThread* aThread, TClientBuffer *aTcb, TInt aLength) |
395 { |
412 { |
396 __KTRACE_OPT(KUSB, Kern::Printf("TDmaBuf::RxCopyPacketToClient 1")); |
413 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TDMABUF_RXCOPYPACKETTOCLIENT, |
|
414 "TDmaBuf::RxCopyPacketToClient 1" ); |
397 |
415 |
398 #if defined(USBC_LDD_BUFFER_TRACE) |
416 #if defined(USBC_LDD_BUFFER_TRACE) |
399 const TInt numPkts = NoRxPackets(); |
417 const TInt numPkts = NoRxPackets(); |
400 const TInt numPktsAlt = NoRxPacketsAlt(); |
418 const TInt numPktsAlt = NoRxPacketsAlt(); |
401 const TInt numBytes = RxBytesAvailable(); |
419 const TInt numBytes = RxBytesAvailable(); |
402 const TInt numBytesAlt = NoRxBytesAlt(); |
420 const TInt numBytesAlt = NoRxBytesAlt(); |
403 |
421 |
404 if (numPkts != numPktsAlt) |
422 if (numPkts != numPktsAlt) |
405 { |
423 { |
406 Kern::Printf( |
424 OstTraceExt2( TRACE_NORMAL, TDMABUF_RXCOPYPACKETTOCLIENT_DUP1, |
407 "TDmaBuf::RxCopyPacketToClient: Error: #pkts mismatch global=%d actual=%d", |
425 "TDmaBuf::RxCopyPacketToClient: Error: #pkts mismatch global=%d actual=%d", |
408 numPkts, numPktsAlt); |
426 numPkts, numPktsAlt); |
409 } |
427 } |
410 if (numBytes != numBytesAlt) |
428 if (numBytes != numBytesAlt) |
411 { |
429 { |
412 Kern::Printf( |
430 OstTraceExt2( TRACE_NORMAL, TDMABUF_RXCOPYPACKETTOCLIENT_DUP2, |
413 "TDmaBuf::RxCopyPacketToClient: Error: #bytes mismatch global=%d actual=%d", |
431 "TDmaBuf::RxCopyPacketToClient: Error: #bytes mismatch global=%d actual=%d", |
414 numBytes, numBytesAlt); |
432 numBytes, numBytesAlt); |
|
433 |
415 } |
434 } |
416 if ((numPkts == 0) && (numBytes !=0)) |
435 if ((numPkts == 0) && (numBytes !=0)) |
417 { |
436 { |
418 Kern::Printf( |
437 OstTraceExt2( TRACE_NORMAL, TDMABUF_RXCOPYPACKETTOCLIENT_DUP3, |
419 "TDmaBuf::RxCopyPacketToClient: Error: global bytes & pkts mismatch pkts=%d bytes=%d", |
438 "TDmaBuf::RxCopyPacketToClient: Error: global bytes & pkts mismatch pkts=%d bytes=%d", |
420 numPkts, numBytes); |
439 numPkts, numBytes); |
421 } |
440 } |
422 if ((numPktsAlt == 0) && (numBytesAlt !=0)) |
441 if ((numPktsAlt == 0) && (numBytesAlt !=0)) |
423 { |
442 { |
424 Kern::Printf( |
443 OstTraceExt2( TRACE_NORMAL, TDMABUF_RXCOPYPACKETTOCLIENT_DUP4, |
425 "TDmaBuf::RxCopyPacketToClient: Error: actual bytes & pkts mismatch pkts=%d bytes=%d", |
444 "TDmaBuf::RxCopyPacketToClient: Error: actual bytes & pkts mismatch pkts=%d bytes=%d", |
426 numPktsAlt, numBytesAlt); |
445 numPktsAlt, numBytesAlt); |
427 } |
446 } |
428 #endif |
447 #endif |
429 |
448 |
430 if (!NoRxPackets()) |
449 if (!NoRxPackets()) |
431 return KErrNotFound; |
450 return KErrNotFound; |
432 |
451 |
433 __KTRACE_OPT(KUSB, Kern::Printf("TDmaBuf::RxCopyPacketToClient 2")); |
452 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TDMABUF_RXCOPYPACKETTOCLIENT_DUP5, |
|
453 "TDmaBuf::RxCopyPacketToClient 2" ); |
434 // the next condition should be true because we have some packets available |
454 // the next condition should be true because we have some packets available |
435 // coverity[var_tested_neg] |
455 // coverity[var_tested_neg] |
436 if (iCurrentDrainingBufferIndex == KUsbcInvalidBufferIndex) |
456 if (iCurrentDrainingBufferIndex == KUsbcInvalidBufferIndex) |
437 { |
457 { |
438 // Marked as Coverity "Intentional" as the member variable |
458 // Marked as Coverity "Intentional" as the member variable |
502 TInt r=Kern::ThreadBufWrite(aThread, aTcb, des, 0, 0, aThread); |
522 TInt r=Kern::ThreadBufWrite(aThread, aTcb, des, 0, 0, aThread); |
503 if (r == KErrNone) |
523 if (r == KErrNone) |
504 { |
524 { |
505 r = errorCode; |
525 r = errorCode; |
506 } |
526 } |
507 __KTRACE_OPT(KUSB, Kern::Printf("TDmaBuf::RxCopyPacketToClient 3")); |
527 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TDMABUF_RXCOPYPACKETTOCLIENT_DUP6, |
|
528 "TDmaBuf::RxCopyPacketToClient 3" ); |
|
529 |
508 |
530 |
509 FreeDrainedBuffers(); |
531 FreeDrainedBuffers(); |
510 |
532 |
511 // Use this error code to complete client read request: |
533 // Use this error code to complete client read request: |
512 return r; |
534 return r; |
514 |
536 |
515 |
537 |
516 TInt TDmaBuf::RxCopyDataToClient(DThread* aThread, TClientBuffer *aTcb, TInt aLength, TUint32& aDestOffset, |
538 TInt TDmaBuf::RxCopyDataToClient(DThread* aThread, TClientBuffer *aTcb, TInt aLength, TUint32& aDestOffset, |
517 TBool aRUS, TBool& aCompleteNow) |
539 TBool aRUS, TBool& aCompleteNow) |
518 { |
540 { |
519 __KTRACE_OPT(KUSB, Kern::Printf("TDmaBuf::RxCopyDataToClient 1")); |
541 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TDMABUF_RXCOPYDATATOCLIENT, |
|
542 "TDmaBuf::RxCopyDataToClient 1" ); |
520 aCompleteNow = ETrue; |
543 aCompleteNow = ETrue; |
521 |
544 |
522 #if defined(USBC_LDD_BUFFER_TRACE) |
545 #if defined(USBC_LDD_BUFFER_TRACE) |
523 const TInt numPkts = NoRxPackets(); |
546 const TInt numPkts = NoRxPackets(); |
524 const TInt numPktsAlt = NoRxPacketsAlt(); |
547 const TInt numPktsAlt = NoRxPacketsAlt(); |
525 const TInt numBytes = RxBytesAvailable(); |
548 const TInt numBytes = RxBytesAvailable(); |
526 const TInt numBytesAlt = NoRxBytesAlt(); |
549 const TInt numBytesAlt = NoRxBytesAlt(); |
527 |
550 |
528 if (numPkts != numPktsAlt) |
551 if (numPkts != numPktsAlt) |
529 { |
552 { |
530 Kern::Printf( |
553 OstTraceExt2( TRACE_NORMAL, TDMABUF_RXCOPYDATATOCLIENT_DUP1, |
531 "TDmaBuf::RxCopyDataToClient: Error: #pkts mismatch global=%d actual=%d", |
554 "TDmaBuf::RxCopyDataToClient: Error: #pkts mismatch global=%d actual=%d", |
532 numPkts, numPktsAlt); |
555 numPkts, numPktsAlt); |
533 } |
556 } |
534 if (numBytes != numBytesAlt) |
557 if (numBytes != numBytesAlt) |
535 { |
558 { |
536 Kern::Printf( |
559 OstTraceExt2( TRACE_NORMAL, TDMABUF_RXCOPYDATATOCLIENT_DUP2, |
537 "TDmaBuf::RxCopyDataToClient: Error: #bytes mismatch global=%d actual=%d", |
560 "TDmaBuf::RxCopyDataToClient: Error: #bytes mismatch global=%d actual=%d", |
538 numBytes, numBytesAlt); |
561 numBytes, numBytesAlt); |
539 } |
562 } |
540 if ((numPkts == 0) && (numBytes != 0)) |
563 if ((numPkts == 0) && (numBytes != 0)) |
541 { |
564 { |
542 Kern::Printf( |
565 OstTraceExt2( TRACE_NORMAL, TDMABUF_RXCOPYDATATOCLIENT_DUP3, |
543 "TDmaBuf::RxCopyDataToClient: Error: global bytes & pkts mismatch pkts=%d bytes=%d", |
566 "TDmaBuf::RxCopyDataToClient: Error: global bytes & pkts mismatch pkts=%d bytes=%d", |
544 numPkts, numBytes); |
567 numPkts, numBytes); |
545 } |
568 } |
546 if ((numPktsAlt == 0) && (numBytesAlt != 0)) |
569 if ((numPktsAlt == 0) && (numBytesAlt != 0)) |
547 { |
570 { |
548 Kern::Printf( |
571 OstTraceExt2( TRACE_NORMAL, TDMABUF_RXCOPYDATATOCLIENT_DUP4, |
549 "TDmaBuf::RxCopyDataToClient: Error: actual bytes & pkts mismatch pkts=%d bytes=%d", |
572 "TDmaBuf::RxCopyDataToClient: Error: actual bytes & pkts mismatch pkts=%d bytes=%d", |
550 numPktsAlt, numBytesAlt); |
573 numPktsAlt, numBytesAlt); |
551 } |
574 } |
552 #endif |
575 #endif |
553 |
576 |
564 // initialization to KUsbcInvalidBufferIndex (which equals -1). |
587 // initialization to KUsbcInvalidBufferIndex (which equals -1). |
565 |
588 |
566 if (!NextDrainableBuffer()) |
589 if (!NextDrainableBuffer()) |
567 { |
590 { |
568 #if defined(USBC_LDD_BUFFER_TRACE) |
591 #if defined(USBC_LDD_BUFFER_TRACE) |
569 Kern::Printf("TDmaBuf::RxCopyDataToClient: Error: No buffer draining=%d, packets=%d", |
592 OstTraceExt2( TRACE_NORMAL, TDMABUF_RXCOPYDATATOCLIENT_DUP5, |
570 iCurrentDrainingBufferIndex, iTotalRxPacketsAvail); |
593 "TDmaBuf::RxCopyDataToClient: Error: No buffer draining=%d, packets=%d", |
|
594 iCurrentDrainingBufferIndex, iTotalRxPacketsAvail); |
571 #endif |
595 #endif |
572 return KErrNotFound; |
596 return KErrNotFound; |
573 } |
597 } |
574 } |
598 } |
575 #if defined(USBC_LDD_BUFFER_TRACE) |
599 #if defined(USBC_LDD_BUFFER_TRACE) |
577 __ASSERT_DEBUG((iCurrentDrainingBufferIndex >= 0 ), |
601 __ASSERT_DEBUG((iCurrentDrainingBufferIndex >= 0 ), |
578 Kern::Fault(KUsbPanicLdd, __LINE__)); |
602 Kern::Fault(KUsbPanicLdd, __LINE__)); |
579 |
603 |
580 if (iDrainingOrder != iFillingOrderArray[iCurrentDrainingBufferIndex]) |
604 if (iDrainingOrder != iFillingOrderArray[iCurrentDrainingBufferIndex]) |
581 { |
605 { |
582 Kern::Printf("!!! Out of Order Draining TDmaBuf::RxCopyDataToClient 10 draining=%d", |
606 OstTrace1( TRACE_NORMAL, TDMABUF_RXCOPYDATATOCLIENT_DUP6, |
583 iCurrentDrainingBufferIndex); |
607 "!!! Out of Order Draining TDmaBuf::RxCopyDataToClient 10 draining=%d", |
584 } |
608 iCurrentDrainingBufferIndex); |
585 #endif |
609 } |
586 __KTRACE_OPT(KUSB, Kern::Printf("TDmaBuf::RxCopyDataToClient 2")); |
610 #endif |
|
611 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TDMABUF_RXCOPYDATATOCLIENT_DUP7, |
|
612 "TDmaBuf::RxCopyDataToClient 2" ); |
587 |
613 |
588 TUint8* blockStartAddr = iCurrentDrainingBuffer + iCurrentPacketIndexArray[iCurrentPacket] + iExtractOffset; |
614 TUint8* blockStartAddr = iCurrentDrainingBuffer + iCurrentPacketIndexArray[iCurrentPacket] + iExtractOffset; |
589 TUint8* lastEndAddr = blockStartAddr; // going to track the contiguity of the memory |
615 TUint8* lastEndAddr = blockStartAddr; // going to track the contiguity of the memory |
590 TUint8* thisStartAddr = blockStartAddr; |
616 TUint8* thisStartAddr = blockStartAddr; |
591 TInt toDo = Min(aLength - (TInt)aDestOffset, iTotalRxBytesAvail); |
617 TInt toDo = Min(aLength - (TInt)aDestOffset, iTotalRxBytesAvail); |
601 if (bufnum != iCurrentDrainingBufferIndex) |
627 if (bufnum != iCurrentDrainingBufferIndex) |
602 { |
628 { |
603 bufnum = iCurrentDrainingBufferIndex; |
629 bufnum = iCurrentDrainingBufferIndex; |
604 if (iDrainingOrder != iFillingOrderArray[iCurrentDrainingBufferIndex]) |
630 if (iDrainingOrder != iFillingOrderArray[iCurrentDrainingBufferIndex]) |
605 { |
631 { |
606 Kern::Printf("!!! Out of Order Draining TDmaBuf::RxCopyDataToClient 20 draining=%d", |
632 OstTrace1( TRACE_NORMAL, TDMABUF_RXCOPYDATATOCLIENT_DUP8, |
607 iCurrentDrainingBufferIndex); |
633 "!!! Out of Order Draining TDmaBuf::RxCopyDataToClient 20 draining=%d", |
|
634 iCurrentDrainingBufferIndex); |
608 } |
635 } |
609 } |
636 } |
610 #endif |
637 #endif |
611 if (errorCode == KErrNone) |
638 if (errorCode == KErrNone) |
612 { |
639 { |
733 #if defined(USBC_LDD_BUFFER_TRACE) |
760 #if defined(USBC_LDD_BUFFER_TRACE) |
734 TUint& bytesRemain = iNumberofBytesRxRemain[iCurrentDrainingBufferIndex]; |
761 TUint& bytesRemain = iNumberofBytesRxRemain[iCurrentDrainingBufferIndex]; |
735 TUint& pktsRemain = iNumberofPacketsRxRemain[iCurrentDrainingBufferIndex]; |
762 TUint& pktsRemain = iNumberofPacketsRxRemain[iCurrentDrainingBufferIndex]; |
736 if ((bytesRemain != 0) || (pktsRemain != 0)) |
763 if ((bytesRemain != 0) || (pktsRemain != 0)) |
737 { |
764 { |
738 Kern::Printf( |
765 OstTraceExt3( TRACE_NORMAL, TDMABUF_NEXTDRAINABLEBUFFER, |
739 "TDmaBuf::NextDrainableBuffer: Error: data discarded buffer=%d pkts=%d bytes=%d", |
766 "TDmaBuf::NextDrainableBuffer: Error: data discarded buffer=%d pkts=%d bytes=%d", |
740 iCurrentDrainingBufferIndex, pktsRemain, bytesRemain); |
767 iCurrentDrainingBufferIndex, pktsRemain, bytesRemain); |
741 bytesRemain = 0; |
768 bytesRemain = 0; |
742 pktsRemain = 0; |
769 pktsRemain = 0; |
743 } |
770 } |
744 #endif |
771 #endif |
745 |
772 |
817 |
844 |
818 |
845 |
819 TBool TDmaBuf::ShortPacketExists() |
846 TBool TDmaBuf::ShortPacketExists() |
820 { |
847 { |
821 // Actually, a short packet or residue data |
848 // Actually, a short packet or residue data |
822 __KTRACE_OPT(KUSB, Kern::Printf("TDmaBuf::ShortPacketExists 1")); |
849 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TDMABUF_SHORTPACKETEXISTS, |
|
850 "TDmaBuf::ShortPacketExists 1" ); |
823 TInt index = iCurrentDrainingBufferIndex; |
851 TInt index = iCurrentDrainingBufferIndex; |
824 TUsbcPacketArray* pktSizeArray = iCurrentPacketSizeArray; |
852 TUsbcPacketArray* pktSizeArray = iCurrentPacketSizeArray; |
825 |
853 |
826 if (iMaxPacketSize > 0) |
854 if (iMaxPacketSize > 0) |
827 { |
855 { |
936 |
964 |
937 |
965 |
938 // We only store 1 transaction, no other buffering is done |
966 // We only store 1 transaction, no other buffering is done |
939 TInt TDmaBuf::TxStoreData(DThread* aThread, TClientBuffer *aTcb, TInt aTxLength, TUint32 aBufferOffset) |
967 TInt TDmaBuf::TxStoreData(DThread* aThread, TClientBuffer *aTcb, TInt aTxLength, TUint32 aBufferOffset) |
940 { |
968 { |
941 __KTRACE_OPT(KUSB, Kern::Printf("TDmaBuf::TxStoreData 1")); |
969 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TDMABUF_TXSTOREDATA, |
|
970 "TDmaBuf::TxStoreData 1" ); |
942 if (!IsReaderEmpty()) |
971 if (!IsReaderEmpty()) |
943 return KErrInUse; |
972 return KErrInUse; |
944 |
973 |
945 __KTRACE_OPT(KUSB, Kern::Printf("TDmaBuf::TxStoreData 2")); |
974 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TDMABUF_TXSTOREDATA_DUP1, |
946 |
975 "TDmaBuf::TxStoreData 2" ); |
947 TInt remainTxLength = aTxLength; |
976 TInt remainTxLength = aTxLength; |
948 TUint32 bufferOffset = aBufferOffset; |
977 TUint32 bufferOffset = aBufferOffset; |
949 // Store each buffer separately |
978 // Store each buffer separately |
950 for( TInt i=0;(i<iNumberofBuffers)&&(remainTxLength>0);i++) |
979 for( TInt i=0;(i<iNumberofBuffers)&&(remainTxLength>0);i++) |
951 { |
980 { |