144 // --- TUsbcDeviceDescriptor |
151 // --- TUsbcDeviceDescriptor |
145 |
152 |
146 TUsbcDeviceDescriptor::TUsbcDeviceDescriptor() |
153 TUsbcDeviceDescriptor::TUsbcDeviceDescriptor() |
147 : iBuf() |
154 : iBuf() |
148 { |
155 { |
149 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcDeviceDescriptor::TUsbcDeviceDescriptor()")); |
156 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCDEVICEDESCRIPTOR_TUSBCDEVICEDESCRIPTOR_CONS, |
|
157 "TUsbcDeviceDescriptor::TUsbcDeviceDescriptor()" ); |
150 } |
158 } |
151 |
159 |
152 |
160 |
153 TUsbcDeviceDescriptor* TUsbcDeviceDescriptor::New(TUint8 aDeviceClass, TUint8 aDeviceSubClass, |
161 TUsbcDeviceDescriptor* TUsbcDeviceDescriptor::New(TUint8 aDeviceClass, TUint8 aDeviceSubClass, |
154 TUint8 aDeviceProtocol, TUint8 aMaxPacketSize0, |
162 TUint8 aDeviceProtocol, TUint8 aMaxPacketSize0, |
155 TUint16 aVendorId, TUint16 aProductId, |
163 TUint16 aVendorId, TUint16 aProductId, |
156 TUint16 aDeviceRelease, TUint8 aNumConfigurations) |
164 TUint16 aDeviceRelease, TUint8 aNumConfigurations) |
157 { |
165 { |
158 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcDeviceDescriptor::New()")); |
166 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCDEVICEDESCRIPTOR_NEW, |
|
167 "TUsbcDeviceDescriptor::New()" ); |
159 TUsbcDeviceDescriptor* self = new TUsbcDeviceDescriptor(); |
168 TUsbcDeviceDescriptor* self = new TUsbcDeviceDescriptor(); |
160 if (self) |
169 if (self) |
161 { |
170 { |
162 if (self->Construct(aDeviceClass, aDeviceSubClass, aDeviceProtocol, aMaxPacketSize0, aVendorId, |
171 if (self->Construct(aDeviceClass, aDeviceSubClass, aDeviceProtocol, aMaxPacketSize0, aVendorId, |
163 aProductId, aDeviceRelease, aNumConfigurations) != KErrNone) |
172 aProductId, aDeviceRelease, aNumConfigurations) != KErrNone) |
196 } |
206 } |
197 |
207 |
198 |
208 |
199 void TUsbcDeviceDescriptor::UpdateFs() |
209 void TUsbcDeviceDescriptor::UpdateFs() |
200 { |
210 { |
201 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcDeviceDescriptor::UpdateFs()")); |
211 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCDEVICEDESCRIPTOR_UPDATEFS, |
|
212 "TUsbcDeviceDescriptor::UpdateFs()" ); |
202 SetByte(7, iEp0Size_Fs); // bMaxPacketSize0 |
213 SetByte(7, iEp0Size_Fs); // bMaxPacketSize0 |
203 } |
214 } |
204 |
215 |
205 |
216 |
206 void TUsbcDeviceDescriptor::UpdateHs() |
217 void TUsbcDeviceDescriptor::UpdateHs() |
207 { |
218 { |
208 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcDeviceDescriptor::UpdateHs()")); |
219 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCDEVICEDESCRIPTOR_UPDATEHS, |
|
220 "TUsbcDeviceDescriptor::UpdateHs()" ); |
209 SetByte(7, 64); // bMaxPacketSize0 |
221 SetByte(7, 64); // bMaxPacketSize0 |
210 } |
222 } |
211 |
223 |
212 |
224 |
213 // --- TUsbcDeviceQualifierDescriptor |
225 // --- TUsbcDeviceQualifierDescriptor |
214 |
226 |
215 TUsbcDeviceQualifierDescriptor::TUsbcDeviceQualifierDescriptor() |
227 TUsbcDeviceQualifierDescriptor::TUsbcDeviceQualifierDescriptor() |
216 : iBuf() |
228 : iBuf() |
217 { |
229 { |
218 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcDeviceDescriptor::TUsbcDeviceQualifierDescriptor()")); |
230 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCDEVICEQUALIFIERDESCRIPTOR_TUSBCDEVICEQUALIFIERDESCRIPTOR_CONS, |
|
231 "TUsbcDeviceQualifierDescriptor::TUsbcDeviceQualifierDescriptor()" ); |
219 } |
232 } |
220 |
233 |
221 |
234 |
222 TUsbcDeviceQualifierDescriptor* TUsbcDeviceQualifierDescriptor::New(TUint8 aDeviceClass, |
235 TUsbcDeviceQualifierDescriptor* TUsbcDeviceQualifierDescriptor::New(TUint8 aDeviceClass, |
223 TUint8 aDeviceSubClass, |
236 TUint8 aDeviceSubClass, |
224 TUint8 aDeviceProtocol, |
237 TUint8 aDeviceProtocol, |
225 TUint8 aMaxPacketSize0, |
238 TUint8 aMaxPacketSize0, |
226 TUint8 aNumConfigurations, |
239 TUint8 aNumConfigurations, |
227 TUint8 aReserved) |
240 TUint8 aReserved) |
228 { |
241 { |
229 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcDeviceQualifierDescriptor::New()")); |
242 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCDEVICEQUALIFIERDESCRIPTOR_NEW, |
|
243 "TUsbcDeviceQualifierDescriptor::New()" ); |
230 TUsbcDeviceQualifierDescriptor* self = new TUsbcDeviceQualifierDescriptor(); |
244 TUsbcDeviceQualifierDescriptor* self = new TUsbcDeviceQualifierDescriptor(); |
231 if (self) |
245 if (self) |
232 { |
246 { |
233 if (self->Construct(aDeviceClass, aDeviceSubClass, aDeviceProtocol, aMaxPacketSize0, |
247 if (self->Construct(aDeviceClass, aDeviceSubClass, aDeviceProtocol, aMaxPacketSize0, |
234 aNumConfigurations, aReserved) != KErrNone) |
248 aNumConfigurations, aReserved) != KErrNone) |
321 iBuf[6] = 0; // iConfiguration |
341 iBuf[6] = 0; // iConfiguration |
322 iBuf[7] = 0x80 | |
342 iBuf[7] = 0x80 | |
323 (aSelfPowered ? KUsbDevAttr_SelfPowered : 0) | |
343 (aSelfPowered ? KUsbDevAttr_SelfPowered : 0) | |
324 (aRemoteWakeup ? KUsbDevAttr_RemoteWakeup : 0); // bmAttributes (bit 7 always 1) |
344 (aRemoteWakeup ? KUsbDevAttr_RemoteWakeup : 0); // bmAttributes (bit 7 always 1) |
325 if (aMaxPower > 510) |
345 if (aMaxPower > 510) |
326 __KTRACE_OPT(KPANIC, Kern::Printf(" Error: Invalid value for bMaxPower: %d", aMaxPower)); |
346 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUP1_TUSBCCONFIGDESCRIPTOR_CONSTRUCT_DUP1, |
|
347 " Error: Invalid value for bMaxPower: %d", aMaxPower ); |
327 iBuf[8] = aMaxPower / 2; // bMaxPower (2mA units!) |
348 iBuf[8] = aMaxPower / 2; // bMaxPower (2mA units!) |
328 return KErrNone; |
349 return KErrNone; |
329 } |
350 } |
330 |
351 |
331 |
352 |
332 // --- TUsbcInterfaceDescriptor |
353 // --- TUsbcInterfaceDescriptor |
333 |
354 |
334 TUsbcInterfaceDescriptor::TUsbcInterfaceDescriptor() |
355 TUsbcInterfaceDescriptor::TUsbcInterfaceDescriptor() |
335 : iBuf() |
356 : iBuf() |
336 { |
357 { |
337 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcInterfaceDescriptor::TUsbcInterfaceDescriptor()")); |
358 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCINTERFACEDESCRIPTOR_TUSBCINTERFACEDESCRIPTOR_CONS, |
|
359 "TUsbcInterfaceDescriptor::TUsbcInterfaceDescriptor()" ); |
338 } |
360 } |
339 |
361 |
340 |
362 |
341 TUsbcInterfaceDescriptor* TUsbcInterfaceDescriptor::New(TUint8 aInterfaceNumber, TUint8 aAlternateSetting, |
363 TUsbcInterfaceDescriptor* TUsbcInterfaceDescriptor::New(TUint8 aInterfaceNumber, TUint8 aAlternateSetting, |
342 TInt aNumEndpoints, const TUsbcClassInfo& aClassInfo) |
364 TInt aNumEndpoints, const TUsbcClassInfo& aClassInfo) |
343 { |
365 { |
344 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcInterfaceDescriptor::New()")); |
366 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCINTERFACEDESCRIPTOR_NEW, |
|
367 "TUsbcInterfaceDescriptor::New()" ); |
345 TUsbcInterfaceDescriptor* self = new TUsbcInterfaceDescriptor(); |
368 TUsbcInterfaceDescriptor* self = new TUsbcInterfaceDescriptor(); |
346 if (self) |
369 if (self) |
347 { |
370 { |
348 if (self->Construct(aInterfaceNumber, aAlternateSetting, aNumEndpoints, aClassInfo) != KErrNone) |
371 if (self->Construct(aInterfaceNumber, aAlternateSetting, aNumEndpoints, aClassInfo) != KErrNone) |
349 { |
372 { |
376 |
400 |
377 // --- TUsbcEndpointDescriptorBase |
401 // --- TUsbcEndpointDescriptorBase |
378 |
402 |
379 TUsbcEndpointDescriptorBase::TUsbcEndpointDescriptorBase() |
403 TUsbcEndpointDescriptorBase::TUsbcEndpointDescriptorBase() |
380 { |
404 { |
381 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcEndpointDescriptorBase::TUsbcEndpointDescriptorBase()")); |
405 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCENDPOINTDESCRIPTORBASE_TUSBCENDPOINTDESCRIPTORBASE_CONS, |
|
406 "TUsbcEndpointDescriptorBase::TUsbcEndpointDescriptorBase()" ); |
382 } |
407 } |
383 |
408 |
384 |
409 |
385 TInt TUsbcEndpointDescriptorBase::Construct(const TUsbcEndpointInfo& aEpInfo) |
410 TInt TUsbcEndpointDescriptorBase::Construct(const TUsbcEndpointInfo& aEpInfo) |
386 { |
411 { |
387 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcEndpointDescriptorBase::Construct()")); |
412 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCENDPOINTDESCRIPTORBASE_CONSTRUCT, |
|
413 "TUsbcEndpointDescriptorBase::Construct()" ); |
388 // Adjust FS/HS endpoint sizes |
414 // Adjust FS/HS endpoint sizes |
389 if (aEpInfo.AdjustEpSizes(iEpSize_Fs, iEpSize_Hs) != KErrNone) |
415 if (aEpInfo.AdjustEpSizes(iEpSize_Fs, iEpSize_Hs) != KErrNone) |
390 { |
416 { |
391 __KTRACE_OPT(KPANIC, Kern::Printf(" Error: Unknown endpoint type: %d", aEpInfo.iType)); |
417 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCENDPOINTDESCRIPTORBASE_CONSTRUCT_DUP1, |
392 } |
418 " Error: Unknown endpoint type: %d", aEpInfo.iType ); |
393 __KTRACE_OPT(KUSB, Kern::Printf(" Now set: iEpSize_Fs=%d iEpSize_Hs=%d (aEpInfo.iSize=%d)", |
419 } |
394 iEpSize_Fs, iEpSize_Hs, aEpInfo.iSize)); |
420 OstTraceDefExt3( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCENDPOINTDESCRIPTORBASE_CONSTRUCT_DUP2, |
|
421 " Now set: iEpSize_Fs=%d iEpSize_Hs=%d (aEpInfo.iSize=%d)", |
|
422 iEpSize_Fs, iEpSize_Hs, aEpInfo.iSize ); |
395 |
423 |
396 // Adjust HS endpoint size for additional transactions |
424 // Adjust HS endpoint size for additional transactions |
397 if ((aEpInfo.iType == KUsbEpTypeIsochronous) || (aEpInfo.iType == KUsbEpTypeInterrupt)) |
425 if ((aEpInfo.iType == KUsbEpTypeIsochronous) || (aEpInfo.iType == KUsbEpTypeInterrupt)) |
398 { |
426 { |
399 if ((aEpInfo.iTransactions > 0) && (aEpInfo.iTransactions < 3)) |
427 if ((aEpInfo.iTransactions > 0) && (aEpInfo.iTransactions < 3)) |
400 { |
428 { |
401 // Bits 12..11 specify the number of additional transactions per microframe |
429 // Bits 12..11 specify the number of additional transactions per microframe |
402 iEpSize_Hs |= (aEpInfo.iTransactions << 12); |
430 iEpSize_Hs |= (aEpInfo.iTransactions << 12); |
403 __KTRACE_OPT(KUSB, Kern::Printf(" Adjusted for add. transact.: iEpSize_Hs=0x%02x " |
431 OstTraceDefExt2( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCENDPOINTDESCRIPTORBASE_CONSTRUCT_DUP3, |
404 "(aEpInfo.iTransactions=%d)", |
432 " Adjusted for add. transact.: iEpSize_Hs=0x%02x (aEpInfo.iTransactions=%d)", |
405 iEpSize_Hs, aEpInfo.iTransactions)); |
433 iEpSize_Hs, aEpInfo.iTransactions ); |
|
434 |
406 } |
435 } |
407 else if (aEpInfo.iTransactions != 0) |
436 else if (aEpInfo.iTransactions != 0) |
408 { |
437 { |
409 __KTRACE_OPT(KPANIC, Kern::Printf(" Warning: Invalid iTransactions value: %d (ignored)", |
438 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCENDPOINTDESCRIPTORBASE_CONSTRUCT_DUP4, |
410 aEpInfo.iTransactions)); |
439 " Warning: Invalid iTransactions value: %d (ignored)", aEpInfo.iTransactions ); |
|
440 |
411 } |
441 } |
412 } |
442 } |
413 |
443 |
414 // Adjust HS polling interval |
444 // Adjust HS polling interval |
415 TUsbcEndpointInfo info(aEpInfo); // create local writeable copy |
445 TUsbcEndpointInfo info(aEpInfo); // create local writeable copy |
416 if (info.AdjustPollInterval() != KErrNone) |
446 if (info.AdjustPollInterval() != KErrNone) |
417 { |
447 { |
418 __KTRACE_OPT(KPANIC, Kern::Printf(" Error: Unknown ep type (%d) or invalid interval value (%d)", |
448 OstTraceDefExt2( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCENDPOINTDESCRIPTORBASE_CONSTRUCT_DUP5, |
419 info.iType, info.iInterval)); |
449 " Error: Unknown ep type (%d) or invalid interval value (%d)", info.iType, info.iInterval ); |
420 } |
450 } |
421 iInterval_Fs = info.iInterval; |
451 iInterval_Fs = info.iInterval; |
422 iInterval_Hs = info.iInterval_Hs; |
452 iInterval_Hs = info.iInterval_Hs; |
423 __KTRACE_OPT(KUSB, Kern::Printf(" Now set: iInterval_Fs=%d iInterval_Hs=%d", |
453 OstTraceDefExt2( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCENDPOINTDESCRIPTORBASE_CONSTRUCT_DUP6, |
424 iInterval_Fs, iInterval_Hs)); |
454 " Now set: iInterval_Fs=%d iInterval_Hs=%d", iInterval_Fs, iInterval_Hs ); |
|
455 |
425 return KErrNone; |
456 return KErrNone; |
426 } |
457 } |
427 |
458 |
428 |
459 |
429 void TUsbcEndpointDescriptorBase::UpdateFs() |
460 void TUsbcEndpointDescriptorBase::UpdateFs() |
430 { |
461 { |
431 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcEndpointDescriptorBase::UpdateFs()")); |
462 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCENDPOINTDESCRIPTORBASE_UPDATEFS, |
|
463 "TUsbcEndpointDescriptorBase::UpdateFs" ); |
432 // (TUsbcEndpointDescriptorBase's FS/HS endpoint sizes and interval values got |
464 // (TUsbcEndpointDescriptorBase's FS/HS endpoint sizes and interval values got |
433 // adjusted in its Construct() method.) |
465 // adjusted in its Construct() method.) |
434 SetWord(4, iEpSize_Fs); // wMaxPacketSize |
466 SetWord(4, iEpSize_Fs); // wMaxPacketSize |
435 SetByte(6, iInterval_Fs); // bInterval |
467 SetByte(6, iInterval_Fs); // bInterval |
436 } |
468 } |
437 |
469 |
438 |
470 |
439 void TUsbcEndpointDescriptorBase::UpdateHs() |
471 void TUsbcEndpointDescriptorBase::UpdateHs() |
440 { |
472 { |
441 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcEndpointDescriptorBase::UpdateHs()")); |
473 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCENDPOINTDESCRIPTORBASE_UPDATEHS, |
|
474 "TUsbcEndpointDescriptorBase::UpdateHs()" ); |
442 // (TUsbcEndpointDescriptorBase's FS/HS endpoint sizes and interval values get |
475 // (TUsbcEndpointDescriptorBase's FS/HS endpoint sizes and interval values get |
443 // adjusted in its Construct() method.) |
476 // adjusted in its Construct() method.) |
444 SetWord(4, iEpSize_Hs); // wMaxPacketSize |
477 SetWord(4, iEpSize_Hs); // wMaxPacketSize |
445 SetByte(6, iInterval_Hs); // bInterval |
478 SetByte(6, iInterval_Hs); // bInterval |
446 } |
479 } |
618 // --- TUsbcStringDescriptorBase |
665 // --- TUsbcStringDescriptorBase |
619 |
666 |
620 TUsbcStringDescriptorBase::TUsbcStringDescriptorBase() |
667 TUsbcStringDescriptorBase::TUsbcStringDescriptorBase() |
621 : /*iIndex(0),*/ iSBuf(0), iBufPtr(NULL, 0) |
668 : /*iIndex(0),*/ iSBuf(0), iBufPtr(NULL, 0) |
622 { |
669 { |
623 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcStringDescriptorBase::TUsbcStringDescriptorBase()")); |
670 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCSTRINGDESCRIPTORBASE_TUSBCSTRINGDESCRIPTORBASE_CONS, |
|
671 "TUsbcStringDescriptorBase::TUsbcStringDescriptorBase()" ); |
624 } |
672 } |
625 |
673 |
626 |
674 |
627 TUsbcStringDescriptorBase::~TUsbcStringDescriptorBase() |
675 TUsbcStringDescriptorBase::~TUsbcStringDescriptorBase() |
628 { |
676 { |
629 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcStringDescriptorBase::~TUsbcStringDescriptorBase()")); |
677 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCSTRINGDESCRIPTORBASE_TUSBCSTRINGDESCRIPTORBASE_DES, |
|
678 "TUsbcStringDescriptorBase::~TUsbcStringDescriptorBase()" ); |
630 } |
679 } |
631 |
680 |
632 |
681 |
633 TUint16 TUsbcStringDescriptorBase::Word(TInt aPosition) const |
682 TUint16 TUsbcStringDescriptorBase::Word(TInt aPosition) const |
634 { |
683 { |
635 if (aPosition <= 1) |
684 if (aPosition <= 1) |
636 { |
685 { |
637 __KTRACE_OPT(KPANIC, Kern::Printf(" Error: Word(%d) in string descriptor " |
686 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCSTRINGDESCRIPTORBASE_WORD, |
638 "(TUsbcStringDescriptorBase::Word)", aPosition)); |
687 " Error: Word(%d) in string descriptor (TUsbcStringDescriptorBase::Word)", aPosition ); |
639 return 0; |
688 return 0; |
640 } |
689 } |
641 else |
690 else |
642 { |
691 { |
643 // since iBufPtr[0] is actually string descriptor byte index 2, |
692 // since iBufPtr[0] is actually string descriptor byte index 2, |
810 // |
868 // |
811 // The constructor for this class. |
869 // The constructor for this class. |
812 // |
870 // |
813 : iDescriptors(), iStrings(), iIfcIdx(0), iEp0_TxBuf(aEp0_TxBuf), iHighSpeed(EFalse) |
871 : iDescriptors(), iStrings(), iIfcIdx(0), iEp0_TxBuf(aEp0_TxBuf), iHighSpeed(EFalse) |
814 { |
872 { |
815 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcDescriptorPool::TUsbcDescriptorPool()")); |
873 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCDESCRIPTORPOOL_TUSBCDESCRIPTORPOOL_CONS, |
|
874 "TUsbcDescriptorPool::TUsbcDescriptorPool()" ); |
816 } |
875 } |
817 |
876 |
818 |
877 |
819 TUsbcDescriptorPool::~TUsbcDescriptorPool() |
878 TUsbcDescriptorPool::~TUsbcDescriptorPool() |
820 { |
879 { |
821 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcDescriptorPool::~TUsbcDescriptorPool()")); |
880 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCDESCRIPTORPOOL_TUSBCDESCRIPTORPOOL_DES, |
|
881 "TUsbcDescriptorPool::~TUsbcDescriptorPool()" ); |
822 // The destructor of each <class T> object is called before the objects themselves are destroyed. |
882 // The destructor of each <class T> object is called before the objects themselves are destroyed. |
823 __KTRACE_OPT(KUSB, Kern::Printf(" iDescriptors.Count(): %d", iDescriptors.Count())); |
883 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCDESCRIPTORPOOL_TUSBCDESCRIPTORPOOL_DES_DUP1, |
|
884 " iDescriptors.Count(): %d", iDescriptors.Count() ); |
824 iDescriptors.ResetAndDestroy(); |
885 iDescriptors.ResetAndDestroy(); |
825 __KTRACE_OPT(KUSB, Kern::Printf(" iStrings.Count(): %d", iStrings.Count())); |
886 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCDESCRIPTORPOOL_TUSBCDESCRIPTORPOOL_DES_DUP2, |
|
887 " iStrings.Count(): %d", iStrings.Count() ); |
|
888 |
826 iStrings.ResetAndDestroy(); |
889 iStrings.ResetAndDestroy(); |
827 } |
890 } |
828 |
891 |
829 |
892 |
830 TInt TUsbcDescriptorPool::Init(TUsbcDeviceDescriptor* aDeviceDesc, TUsbcConfigDescriptor* aConfigDesc, |
893 TInt TUsbcDescriptorPool::Init(TUsbcDeviceDescriptor* aDeviceDesc, TUsbcConfigDescriptor* aConfigDesc, |
831 TUsbcLangIdDescriptor* aLangId, TUsbcStringDescriptor* aManufacturer, |
894 TUsbcLangIdDescriptor* aLangId, TUsbcStringDescriptor* aManufacturer, |
832 TUsbcStringDescriptor* aProduct, TUsbcStringDescriptor* aSerialNum, |
895 TUsbcStringDescriptor* aProduct, TUsbcStringDescriptor* aSerialNum, |
833 TUsbcStringDescriptor* aConfig, TUsbcOtgDescriptor* aOtgDesc) |
896 TUsbcStringDescriptor* aConfig, TUsbcOtgDescriptor* aOtgDesc) |
834 { |
897 { |
835 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcDescriptorPool::Init()")); |
898 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCDESCRIPTORPOOL_INIT, |
|
899 "TUsbcDescriptorPool::Init()" ); |
836 if (!aDeviceDesc || !aConfigDesc) |
900 if (!aDeviceDesc || !aConfigDesc) |
837 { |
901 { |
838 __KTRACE_OPT(KPANIC, Kern::Printf(" Error: No Device or Config descriptor specified")); |
902 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCDESCRIPTORPOOL_INIT_DUP1, |
|
903 " Error: No Device or Config descriptor specified" ); |
839 return KErrArgument; |
904 return KErrArgument; |
840 } |
905 } |
841 for (TInt n = 0; n < KDescPosition_FirstAvailable; n++) |
906 for (TInt n = 0; n < KDescPosition_FirstAvailable; n++) |
842 { |
907 { |
843 iDescriptors.Append(NULL); |
908 iDescriptors.Append(NULL); |
844 } |
909 } |
845 __ASSERT_DEBUG((iDescriptors.Count() == KDescPosition_FirstAvailable), |
910 #ifdef _DEBUG |
846 Kern::Printf(" Error: iDescriptors.Count() (%d) != KDescPosition_FirstAvailable (%d)", |
911 if (iDescriptors.Count() != KDescPosition_FirstAvailable) |
847 iDescriptors.Count(), KDescPosition_FirstAvailable)); |
912 { |
|
913 OstTraceDefExt2( OST_TRACE_CATEGORY_DEBUG, TRACE_NORMAL, TUSBCDESCRIPTORPOOL_INIT_DUP2, |
|
914 " Error: iDescriptors.Count() (%d) != KDescPosition_FirstAvailable (%d)", |
|
915 iDescriptors.Count(), KDescPosition_FirstAvailable ); |
|
916 |
|
917 } |
|
918 #endif |
848 iDescriptors[KDescPosition_Device] = aDeviceDesc; |
919 iDescriptors[KDescPosition_Device] = aDeviceDesc; |
849 iDescriptors[KDescPosition_Config] = aConfigDesc; |
920 iDescriptors[KDescPosition_Config] = aConfigDesc; |
850 if (aOtgDesc) |
921 if (aOtgDesc) |
851 { |
922 { |
852 iDescriptors[KDescPosition_Otg] = aOtgDesc; |
923 iDescriptors[KDescPosition_Otg] = aOtgDesc; |
857 { |
928 { |
858 // USB spec 9.6.7 says: "String index zero for all languages returns a string descriptor |
929 // USB spec 9.6.7 says: "String index zero for all languages returns a string descriptor |
859 // that contains an array of two-byte LANGID codes supported by the device. ... |
930 // that contains an array of two-byte LANGID codes supported by the device. ... |
860 // USB devices that omit all string descriptors must not return an array of LANGID codes." |
931 // USB devices that omit all string descriptors must not return an array of LANGID codes." |
861 // So if we have at least one string descriptor, we must also have a LANGID descriptor. |
932 // So if we have at least one string descriptor, we must also have a LANGID descriptor. |
862 __KTRACE_OPT(KPANIC, Kern::Printf(" Error: No LANGID string descriptor specified")); |
933 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCDESCRIPTORPOOL_INIT_DUP3, |
|
934 " Error: No LANGID string descriptor specified" ); |
|
935 |
863 return KErrArgument; |
936 return KErrArgument; |
864 } |
937 } |
865 iStrings.Insert(aLangId, KStringPosition_Langid); |
938 iStrings.Insert(aLangId, KStringPosition_Langid); |
866 iStrings.Insert(aManufacturer, KStringPosition_Manufact); |
939 iStrings.Insert(aManufacturer, KStringPosition_Manufact); |
867 iStrings.Insert(aProduct, KStringPosition_Product); |
940 iStrings.Insert(aProduct, KStringPosition_Product); |
868 iStrings.Insert(aSerialNum, KStringPosition_Serial); |
941 iStrings.Insert(aSerialNum, KStringPosition_Serial); |
869 iStrings.Insert(aConfig, KStringPosition_Config); |
942 iStrings.Insert(aConfig, KStringPosition_Config); |
870 __ASSERT_DEBUG((iStrings.Count() == 5), |
943 #ifdef _DEBUG |
871 Kern::Printf(" Error: iStrings.Count() != 5 (%d)", iStrings.Count())); |
944 if (iStrings.Count() != 5) |
|
945 { |
|
946 OstTraceDef1( OST_TRACE_CATEGORY_DEBUG, TRACE_NORMAL, TUSBCDESCRIPTORPOOL_INIT_DUP4, |
|
947 " Error: iStrings.Count() != 5 (%d)", iStrings.Count() ); |
|
948 } |
|
949 #endif |
872 #ifdef _DEBUG |
950 #ifdef _DEBUG |
873 for (TInt i = KStringPosition_Langid; i <= KStringPosition_Config; i++) |
951 for (TInt i = KStringPosition_Langid; i <= KStringPosition_Config; i++) |
874 { |
952 { |
875 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcDescriptorPool.iStrings[%d] = 0x%x", i, iStrings[i])); |
953 OstTraceDefExt2( OST_TRACE_CATEGORY_DEBUG, TRACE_NORMAL, TUSBCDESCRIPTORPOOL_INIT_DUP5, |
|
954 "TUsbcDescriptorPool.iStrings[%d] = 0x%x", i, reinterpret_cast<TUint>(iStrings[i]) ); |
876 } |
955 } |
877 #endif |
956 #endif |
878 // Set string indices |
957 // Set string indices |
879 if (aManufacturer) |
958 if (aManufacturer) |
880 iDescriptors[KDescPosition_Device]->SetByte(KUsbDescStringIndex_Manufact, |
959 iDescriptors[KDescPosition_Device]->SetByte(KUsbDescStringIndex_Manufact, |
892 } |
971 } |
893 |
972 |
894 |
973 |
895 TInt TUsbcDescriptorPool::InitHs() |
974 TInt TUsbcDescriptorPool::InitHs() |
896 { |
975 { |
897 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcDescriptorPool::InitHs()")); |
976 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCDESCRIPTORPOOL_INITHS, |
898 __ASSERT_DEBUG((iDescriptors.Count() >= KDescPosition_FirstAvailable), |
977 "TUsbcDescriptorPool::InitHs()" ); |
899 Kern::Printf(" Error: Call Init() first)")); |
978 #ifdef _DEBUG |
|
979 if (iDescriptors.Count() < KDescPosition_FirstAvailable) |
|
980 { |
|
981 OstTraceDef0( OST_TRACE_CATEGORY_DEBUG, TRACE_NORMAL, TUSBCDESCRIPTORPOOL_INITHS_DUP1, |
|
982 " Error: Call Init() first)" ); |
|
983 |
|
984 } |
|
985 #endif |
900 |
986 |
901 TUsbcDeviceQualifierDescriptor* const dq_desc = TUsbcDeviceQualifierDescriptor::New( |
987 TUsbcDeviceQualifierDescriptor* const dq_desc = TUsbcDeviceQualifierDescriptor::New( |
902 iDescriptors[KDescPosition_Device]->Byte(4), // aDeviceClass |
988 iDescriptors[KDescPosition_Device]->Byte(4), // aDeviceClass |
903 iDescriptors[KDescPosition_Device]->Byte(5), // aDeviceSubClass |
989 iDescriptors[KDescPosition_Device]->Byte(5), // aDeviceSubClass |
904 iDescriptors[KDescPosition_Device]->Byte(6), // aDeviceProtocol |
990 iDescriptors[KDescPosition_Device]->Byte(6), // aDeviceProtocol |
905 iDescriptors[KDescPosition_Device]->Byte(7), // aMaxPacketSize0 |
991 iDescriptors[KDescPosition_Device]->Byte(7), // aMaxPacketSize0 |
906 iDescriptors[KDescPosition_Device]->Byte(17)); // aNumConfigurations |
992 iDescriptors[KDescPosition_Device]->Byte(17)); // aNumConfigurations |
907 if (!dq_desc) |
993 if (!dq_desc) |
908 { |
994 { |
909 __KTRACE_OPT(KPANIC, Kern::Printf(" Error: Memory allocation for dev qualif desc failed.")); |
995 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCDESCRIPTORPOOL_INITHS_DUP2, |
|
996 " Error: Memory allocation for dev qualif desc failed." ); |
910 return KErrGeneral; |
997 return KErrGeneral; |
911 } |
998 } |
912 iDescriptors[KDescPosition_DeviceQualifier] = dq_desc; |
999 iDescriptors[KDescPosition_DeviceQualifier] = dq_desc; |
913 |
1000 |
914 TUsbcOtherSpeedConfigDescriptor* const osc_desc = TUsbcOtherSpeedConfigDescriptor::New( |
1001 TUsbcOtherSpeedConfigDescriptor* const osc_desc = TUsbcOtherSpeedConfigDescriptor::New( |
968 // |
1058 // |
969 // An error can be indicated by either a return value != KErrNone or by a descriptor size == 0. |
1059 // An error can be indicated by either a return value != KErrNone or by a descriptor size == 0. |
970 // |
1060 // |
971 TInt TUsbcDescriptorPool::FindDescriptor(TUint8 aType, TUint8 aIndex, TUint16 aLangid, TInt& aSize) const |
1061 TInt TUsbcDescriptorPool::FindDescriptor(TUint8 aType, TUint8 aIndex, TUint16 aLangid, TInt& aSize) const |
972 { |
1062 { |
973 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcDescriptorPool::FindDescriptor()")); |
1063 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCDESCRIPTORPOOL_FINDDESCRIPTOR, |
|
1064 "TUsbcDescriptorPool::FindDescriptor()" ); |
974 TInt result = KErrGeneral; |
1065 TInt result = KErrGeneral; |
975 switch (aType) |
1066 switch (aType) |
976 { |
1067 { |
977 case KUsbDescType_Device: |
1068 case KUsbDescType_Device: |
978 if (aLangid != 0) |
1069 if (aLangid != 0) |
979 { |
1070 { |
980 __KTRACE_OPT(KPANIC, Kern::Printf(" Error: bad langid: 0x%04x", aLangid)); |
1071 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCDESCRIPTORPOOL_FINDDESCRIPTOR_DUP1, |
|
1072 " Error: bad langid: 0x%04x", aLangid ); |
981 } |
1073 } |
982 else if (aIndex > 0) |
1074 else if (aIndex > 0) |
983 { |
1075 { |
984 __KTRACE_OPT(KPANIC, Kern::Printf(" Error: bad device index: %d", aIndex)); |
1076 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCDESCRIPTORPOOL_FINDDESCRIPTOR_DUP2, |
|
1077 " Error: bad device index: %d", aIndex ); |
985 } |
1078 } |
986 else |
1079 else |
987 { |
1080 { |
988 aSize = GetDeviceDescriptor(KDescPosition_Device); |
1081 aSize = GetDeviceDescriptor(KDescPosition_Device); |
989 result = KErrNone; |
1082 result = KErrNone; |
990 } |
1083 } |
991 break; |
1084 break; |
992 case KUsbDescType_Config: |
1085 case KUsbDescType_Config: |
993 if (aLangid != 0) |
1086 if (aLangid != 0) |
994 { |
1087 { |
995 __KTRACE_OPT(KPANIC, Kern::Printf(" Error: bad langid: 0x%04x", aLangid)); |
1088 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCDESCRIPTORPOOL_FINDDESCRIPTOR_DUP3, |
|
1089 " Error: bad langid: 0x%04x", aLangid ); |
996 } |
1090 } |
997 else if (aIndex > 0) |
1091 else if (aIndex > 0) |
998 { |
1092 { |
999 __KTRACE_OPT(KPANIC, Kern::Printf(" Error: bad config index: %d", aIndex)); |
1093 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCDESCRIPTORPOOL_FINDDESCRIPTOR_DUP4, |
|
1094 " Error: bad config index: %d", aIndex ); |
1000 } |
1095 } |
1001 else |
1096 else |
1002 { |
1097 { |
1003 aSize = GetConfigurationDescriptor(KDescPosition_Config); |
1098 aSize = GetConfigurationDescriptor(KDescPosition_Config); |
1004 result = KErrNone; |
1099 result = KErrNone; |
1005 } |
1100 } |
1006 break; |
1101 break; |
1007 case KUsbDescType_DeviceQualifier: |
1102 case KUsbDescType_DeviceQualifier: |
1008 if (aLangid != 0) |
1103 if (aLangid != 0) |
1009 { |
1104 { |
1010 __KTRACE_OPT(KPANIC, Kern::Printf(" Error: bad langid: 0x%04x", aLangid)); |
1105 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCDESCRIPTORPOOL_FINDDESCRIPTOR_DUP5, |
|
1106 " Error: bad langid: 0x%04x", aLangid ); |
1011 } |
1107 } |
1012 else if (aIndex > 0) |
1108 else if (aIndex > 0) |
1013 { |
1109 { |
1014 __KTRACE_OPT(KPANIC, Kern::Printf(" Error: bad device index: %d", aIndex)); |
1110 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCDESCRIPTORPOOL_FINDDESCRIPTOR_DUP6, |
|
1111 " Error: bad device index: %d", aIndex ); |
1015 } |
1112 } |
1016 else |
1113 else |
1017 { |
1114 { |
1018 aSize = GetDeviceDescriptor(KDescPosition_DeviceQualifier); |
1115 aSize = GetDeviceDescriptor(KDescPosition_DeviceQualifier); |
1019 result = KErrNone; |
1116 result = KErrNone; |
1020 } |
1117 } |
1021 break; |
1118 break; |
1022 case KUsbDescType_OtherSpeedConfig: |
1119 case KUsbDescType_OtherSpeedConfig: |
1023 if (aLangid != 0) |
1120 if (aLangid != 0) |
1024 { |
1121 { |
1025 __KTRACE_OPT(KPANIC, Kern::Printf(" Error: bad langid: 0x%04x", aLangid)); |
1122 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCDESCRIPTORPOOL_FINDDESCRIPTOR_DUP7, |
|
1123 " Error: bad langid: 0x%04x", aLangid ); |
1026 } |
1124 } |
1027 else if (aIndex > 0) |
1125 else if (aIndex > 0) |
1028 { |
1126 { |
1029 __KTRACE_OPT(KPANIC, Kern::Printf(" Error: bad config index: %d", aIndex)); |
1127 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCDESCRIPTORPOOL_FINDDESCRIPTOR_DUP8, |
|
1128 " Error: bad config index: %d", aIndex ); |
1030 } |
1129 } |
1031 else |
1130 else |
1032 { |
1131 { |
1033 aSize = GetConfigurationDescriptor(KDescPosition_OtherSpeedConfig); |
1132 aSize = GetConfigurationDescriptor(KDescPosition_OtherSpeedConfig); |
1034 result = KErrNone; |
1133 result = KErrNone; |
1046 aSize = GetStringDescriptor(aIndex); |
1145 aSize = GetStringDescriptor(aIndex); |
1047 result = KErrNone; |
1146 result = KErrNone; |
1048 } |
1147 } |
1049 else |
1148 else |
1050 { |
1149 { |
1051 __KTRACE_OPT(KUSB, Kern::Printf(" No string descriptors: not returning LANGID array")); |
1150 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCDESCRIPTORPOOL_FINDDESCRIPTOR_DUP9, |
|
1151 " No string descriptors: not returning LANGID array" ); |
1052 } |
1152 } |
1053 } |
1153 } |
1054 else |
1154 else |
1055 { |
1155 { |
1056 if (!aLangid) |
1156 if (!aLangid) |
1057 { |
1157 { |
1058 __KTRACE_OPT(KUSB, |
1158 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCDESCRIPTORPOOL_FINDDESCRIPTOR_DUP10, |
1059 Kern::Printf(" Strange: LANGID=0 for a $ descriptor (ignoring LANGID)")); |
1159 " Strange: LANGID=0 for a $ descriptor (ignoring LANGID)" ); |
1060 // The USB spec doesn't really say what to do in this case, but as there are host apps |
1160 // The USB spec doesn't really say what to do in this case, but as there are host apps |
1061 // that fail if we return an error here, we choose to ignore the issue. |
1161 // that fail if we return an error here, we choose to ignore the issue. |
1062 } |
1162 } |
1063 else if (aLangid != iStrings[KStringPosition_Langid]->Word(2)) |
1163 else if (aLangid != iStrings[KStringPosition_Langid]->Word(2)) |
1064 { |
1164 { |
1065 // We have only one (this) language |
1165 // We have only one (this) language |
1066 __KTRACE_OPT(KUSB, |
1166 OstTraceDefExt2( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCDESCRIPTORPOOL_FINDDESCRIPTOR_DUP11, |
1067 Kern::Printf(" Bad LANGID: 0x%04X requested, 0x%04X supported (ignoring LANGID)", |
1167 " Bad LANGID: 0x%04X requested, 0x%04X supported (ignoring LANGID)", |
1068 aLangid, iStrings[KStringPosition_Langid]->Word(2))); |
1168 aLangid, iStrings[KStringPosition_Langid]->Word(2) ); |
1069 // We could return an error here, but rather choose to ignore the discrepancy |
1169 // We could return an error here, but rather choose to ignore the discrepancy |
1070 // (the USB spec is not very clear what to do in such a case anyway). |
1170 // (the USB spec is not very clear what to do in such a case anyway). |
1071 } |
1171 } |
1072 aSize = GetStringDescriptor(aIndex); |
1172 aSize = GetStringDescriptor(aIndex); |
1073 result = KErrNone; |
1173 result = KErrNone; |
1074 } |
1174 } |
1075 break; |
1175 break; |
1076 case KUsbDescType_CS_Interface: |
1176 case KUsbDescType_CS_Interface: |
1077 /* fall through */ |
1177 /* fall through */ |
1078 case KUsbDescType_CS_Endpoint: |
1178 case KUsbDescType_CS_Endpoint: |
1079 __KTRACE_OPT(KPANIC, Kern::Printf(" Warning: finding of class specific descriptors not supported")); |
1179 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCDESCRIPTORPOOL_FINDDESCRIPTOR_DUP12, |
|
1180 " Warning: finding of class specific descriptors not supported" ); |
1080 break; |
1181 break; |
1081 default: |
1182 default: |
1082 __KTRACE_OPT(KPANIC, Kern::Printf(" Error: unknown descriptor type requested: %d", aType)); |
1183 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCDESCRIPTORPOOL_FINDDESCRIPTOR_DUP13, |
|
1184 " Error: unknown descriptor type requested: %d", aType ); |
1083 break; |
1185 break; |
1084 } |
1186 } |
1085 return result; |
1187 return result; |
1086 } |
1188 } |
1087 |
1189 |
1088 |
1190 |
1089 void TUsbcDescriptorPool::InsertDescriptor(TUsbcDescriptorBase* aDesc) |
1191 void TUsbcDescriptorPool::InsertDescriptor(TUsbcDescriptorBase* aDesc) |
1090 { |
1192 { |
1091 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcDescriptorPool::InsertDescriptor()")); |
1193 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCDESCRIPTORPOOL_INSERTDESCRIPTOR, |
|
1194 "TUsbcDescriptorPool::InsertDescriptor()" ); |
1092 switch (aDesc->Type()) |
1195 switch (aDesc->Type()) |
1093 { |
1196 { |
1094 case KUsbDescType_Interface: |
1197 case KUsbDescType_Interface: |
1095 InsertIfcDesc(aDesc); |
1198 InsertIfcDesc(aDesc); |
1096 break; |
1199 break; |
1097 case KUsbDescType_Endpoint: |
1200 case KUsbDescType_Endpoint: |
1098 InsertEpDesc(aDesc); |
1201 InsertEpDesc(aDesc); |
1099 break; |
1202 break; |
1100 default: |
1203 default: |
1101 __KTRACE_OPT(KUSB, Kern::Printf(" Error: unsupported descriptor type")); |
1204 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCDESCRIPTORPOOL_INSERTDESCRIPTOR_DUP1, |
|
1205 " Error: unsupported descriptor type" ); |
1102 } |
1206 } |
1103 } |
1207 } |
1104 |
1208 |
1105 |
1209 |
1106 void TUsbcDescriptorPool::SetIfcStringDescriptor(TUsbcStringDescriptor* aDesc, TInt aNumber, TInt aSetting) |
1210 void TUsbcDescriptorPool::SetIfcStringDescriptor(TUsbcStringDescriptor* aDesc, TInt aNumber, TInt aSetting) |
1107 { |
1211 { |
1108 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcDescriptorPool::SetIfcDescriptor(%d, %d)", aNumber, aSetting)); |
1212 OstTraceDefExt2( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCDESCRIPTORPOOL_SETIFCSTRINGDESCRIPTOR, |
|
1213 "TUsbcDescriptorPool::SetIfcDescriptor(%d, %d)", aNumber, aSetting ); |
1109 const TInt i = FindIfcDescriptor(aNumber, aSetting); |
1214 const TInt i = FindIfcDescriptor(aNumber, aSetting); |
1110 if (i < 0) |
1215 if (i < 0) |
1111 { |
1216 { |
1112 __KTRACE_OPT(KPANIC, Kern::Printf(" Error: Ifc descriptor not found (%d, %d)", |
1217 OstTraceDefExt2( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCDESCRIPTORPOOL_SETIFCSTRINGDESCRIPTOR_DUP1, |
1113 aNumber, aSetting)); |
1218 " Error: Ifc descriptor not found (%d, %d)", aNumber, aSetting ); |
1114 return; |
1219 return; |
1115 } |
1220 } |
1116 // Try to find available NULL postition |
1221 // Try to find available NULL postition |
1117 TInt str_idx = FindAvailableStringPos(); |
1222 TInt str_idx = FindAvailableStringPos(); |
1118 if (str_idx >= 0) |
1223 if (str_idx >= 0) |
1137 // Append string descriptor for specified interface |
1243 // Append string descriptor for specified interface |
1138 iStrings.Append(aDesc); |
1244 iStrings.Append(aDesc); |
1139 } |
1245 } |
1140 // Update this ifc descriptor's string index field |
1246 // Update this ifc descriptor's string index field |
1141 iDescriptors[i]->SetByte(8, str_idx); |
1247 iDescriptors[i]->SetByte(8, str_idx); |
1142 __KTRACE_OPT(KUSB, Kern::Printf(" String for ifc %d/%d (@ pos %d): \"%S\"", aNumber, aSetting, str_idx, |
1248 OstTraceDefExt4( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCDESCRIPTORPOOL_SETIFCSTRINGDESCRIPTOR_DUP3, |
1143 &iStrings[str_idx]->StringData())); |
1249 " String for ifc %d/%d (@ pos %d): \"%s\"", aNumber, aSetting, str_idx, |
|
1250 iStrings[str_idx]->StringData() ); |
1144 } |
1251 } |
1145 |
1252 |
1146 |
1253 |
1147 void TUsbcDescriptorPool::DeleteIfcDescriptor(TInt aNumber, TInt aSetting) |
1254 void TUsbcDescriptorPool::DeleteIfcDescriptor(TInt aNumber, TInt aSetting) |
1148 { |
1255 { |
1149 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcDescriptorPool::DeleteIfcDescriptor(%d, %d)", aNumber, aSetting)); |
1256 OstTraceDefExt2( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCDESCRIPTORPOOL_DELETEIFCDESCRIPTOR, |
|
1257 "TUsbcDescriptorPool::DeleteIfcDescriptor(%d, %d)", aNumber, aSetting ); |
1150 const TInt i = FindIfcDescriptor(aNumber, aSetting); |
1258 const TInt i = FindIfcDescriptor(aNumber, aSetting); |
1151 if (i < 0) |
1259 if (i < 0) |
1152 { |
1260 { |
1153 __KTRACE_OPT(KPANIC, Kern::Printf(" Error: DeleteIfcDescriptor - descriptor not found (%d, %d)", |
1261 OstTraceDefExt2( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCDESCRIPTORPOOL_DELETEIFCDESCRIPTOR_DUP1, |
1154 aNumber, aSetting)); |
1262 " Error: DeleteIfcDescriptor - descriptor not found (%d, %d)", aNumber, aSetting ); |
1155 return; |
1263 return; |
1156 } |
1264 } |
1157 // Delete (if necessary) specified interface's string descriptor |
1265 // Delete (if necessary) specified interface's string descriptor |
1158 const TInt si = iDescriptors[i]->Byte(8); |
1266 const TInt si = iDescriptors[i]->Byte(8); |
1159 if (si != 0) |
1267 if (si != 0) |
1177 // The TC in many of the following functions stands for 'ThreadCopy', |
1285 // The TC in many of the following functions stands for 'ThreadCopy', |
1178 // because that's what's happening there. |
1286 // because that's what's happening there. |
1179 |
1287 |
1180 TInt TUsbcDescriptorPool::GetDeviceDescriptorTC(DThread* aThread, TDes8& aBuffer) const |
1288 TInt TUsbcDescriptorPool::GetDeviceDescriptorTC(DThread* aThread, TDes8& aBuffer) const |
1181 { |
1289 { |
1182 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcDescriptorPool::GetDeviceDescriptorTC()")); |
1290 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCDESCRIPTORPOOL_GETDEVICEDESCRIPTORTC, |
|
1291 "TUsbcDescriptorPool::GetDeviceDescriptorTC()" ); |
1183 return Kern::ThreadDesWrite(aThread, &aBuffer, iDescriptors[KDescPosition_Device]->DescriptorData(), 0); |
1292 return Kern::ThreadDesWrite(aThread, &aBuffer, iDescriptors[KDescPosition_Device]->DescriptorData(), 0); |
1184 } |
1293 } |
1185 |
1294 |
1186 |
1295 |
1187 TInt TUsbcDescriptorPool::SetDeviceDescriptorTC(DThread* aThread, const TDes8& aBuffer) |
1296 TInt TUsbcDescriptorPool::SetDeviceDescriptorTC(DThread* aThread, const TDes8& aBuffer) |
1188 { |
1297 { |
1189 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcDescriptorPool::SetDeviceDescriptorTC()")); |
1298 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCDESCRIPTORPOOL_SETDEVICEDESCRIPTORTC, |
|
1299 "TUsbcDescriptorPool::SetDeviceDescriptorTC()" ); |
1190 TBuf8<KUsbDescSize_Device> device; |
1300 TBuf8<KUsbDescSize_Device> device; |
1191 const TInt r = Kern::ThreadDesRead(aThread, &aBuffer, device, 0); |
1301 const TInt r = Kern::ThreadDesRead(aThread, &aBuffer, device, 0); |
1192 if (r != KErrNone) |
1302 if (r != KErrNone) |
1193 { |
1303 { |
1194 return r; |
1304 return r; |
1244 |
1356 |
1245 |
1357 |
1246 TInt TUsbcDescriptorPool::GetInterfaceDescriptorTC(DThread* aThread, TDes8& aBuffer, |
1358 TInt TUsbcDescriptorPool::GetInterfaceDescriptorTC(DThread* aThread, TDes8& aBuffer, |
1247 TInt aInterface, TInt aSetting) const |
1359 TInt aInterface, TInt aSetting) const |
1248 { |
1360 { |
1249 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcDescriptorPool::GetInterfaceDescriptorTC()")); |
1361 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCDESCRIPTORPOOL_GETINTERFACEDESCRIPTORTC, |
|
1362 "TUsbcDescriptorPool::GetInterfaceDescriptorTC()" ); |
1250 const TInt i = FindIfcDescriptor(aInterface, aSetting); |
1363 const TInt i = FindIfcDescriptor(aInterface, aSetting); |
1251 if (i < 0) |
1364 if (i < 0) |
1252 { |
1365 { |
1253 __KTRACE_OPT(KPANIC, Kern::Printf(" Error: no such interface")); |
1366 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCDESCRIPTORPOOL_GETINTERFACEDESCRIPTORTC_DUP1, |
|
1367 " Error: no such interface" ); |
1254 return KErrNotFound; |
1368 return KErrNotFound; |
1255 } |
1369 } |
1256 return Kern::ThreadDesWrite(aThread, &aBuffer, iDescriptors[i]->DescriptorData(), 0); |
1370 return Kern::ThreadDesWrite(aThread, &aBuffer, iDescriptors[i]->DescriptorData(), 0); |
1257 } |
1371 } |
1258 |
1372 |
1259 |
1373 |
1260 TInt TUsbcDescriptorPool::SetInterfaceDescriptor(const TDes8& aBuffer, TInt aInterface, TInt aSetting) |
1374 TInt TUsbcDescriptorPool::SetInterfaceDescriptor(const TDes8& aBuffer, TInt aInterface, TInt aSetting) |
1261 { |
1375 { |
1262 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcDescriptorPool::SetInterfaceDescriptor()")); |
1376 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCDESCRIPTORPOOL_SETINTERFACEDESCRIPTOR, |
|
1377 "TUsbcDescriptorPool::SetInterfaceDescriptor()" ); |
1263 const TInt i = FindIfcDescriptor(aInterface, aSetting); |
1378 const TInt i = FindIfcDescriptor(aInterface, aSetting); |
1264 if (i < 0) |
1379 if (i < 0) |
1265 { |
1380 { |
1266 __KTRACE_OPT(KPANIC, Kern::Printf(" Error: no such interface")); |
1381 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCDESCRIPTORPOOL_SETINTERFACEDESCRIPTOR_DUP1, |
|
1382 " Error: no such interface" ); |
1267 return KErrNotFound; |
1383 return KErrNotFound; |
1268 } |
1384 } |
1269 iDescriptors[i]->SetByte(2, aBuffer[2]); // bInterfaceNumber |
1385 iDescriptors[i]->SetByte(2, aBuffer[2]); // bInterfaceNumber |
1270 iDescriptors[i]->SetByte(5, aBuffer[5]); // bInterfaceClass |
1386 iDescriptors[i]->SetByte(5, aBuffer[5]); // bInterfaceClass |
1271 iDescriptors[i]->SetByte(6, aBuffer[6]); // bInterfaceSubClass |
1387 iDescriptors[i]->SetByte(6, aBuffer[6]); // bInterfaceSubClass |
1275 |
1391 |
1276 |
1392 |
1277 TInt TUsbcDescriptorPool::GetEndpointDescriptorTC(DThread* aThread, TDes8& aBuffer, |
1393 TInt TUsbcDescriptorPool::GetEndpointDescriptorTC(DThread* aThread, TDes8& aBuffer, |
1278 TInt aInterface, TInt aSetting, TUint8 aEndpointAddress) const |
1394 TInt aInterface, TInt aSetting, TUint8 aEndpointAddress) const |
1279 { |
1395 { |
1280 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcDescriptorPool::GetEndpointDescriptorTC()")); |
1396 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCDESCRIPTORPOOL_GETENDPOINTDESCRIPTORTC, |
|
1397 "TUsbcDescriptorPool::GetEndpointDescriptorTC()" ); |
1281 const TInt i = FindEpDescriptor(aInterface, aSetting, aEndpointAddress); |
1398 const TInt i = FindEpDescriptor(aInterface, aSetting, aEndpointAddress); |
1282 if (i < 0) |
1399 if (i < 0) |
1283 { |
1400 { |
1284 __KTRACE_OPT(KPANIC, Kern::Printf(" Error: no such endpoint")); |
1401 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCDESCRIPTORPOOL_GETENDPOINTDESCRIPTORTC_DUP1, |
|
1402 " Error: no such endpoint" ); |
1285 return KErrNotFound; |
1403 return KErrNotFound; |
1286 } |
1404 } |
1287 return Kern::ThreadDesWrite(aThread, &aBuffer, iDescriptors[i]->DescriptorData(), 0); |
1405 return Kern::ThreadDesWrite(aThread, &aBuffer, iDescriptors[i]->DescriptorData(), 0); |
1288 } |
1406 } |
1289 |
1407 |
1290 |
1408 |
1291 TInt TUsbcDescriptorPool::SetEndpointDescriptorTC(DThread* aThread, const TDes8& aBuffer, |
1409 TInt TUsbcDescriptorPool::SetEndpointDescriptorTC(DThread* aThread, const TDes8& aBuffer, |
1292 TInt aInterface, TInt aSetting, TUint8 aEndpointAddress) |
1410 TInt aInterface, TInt aSetting, TUint8 aEndpointAddress) |
1293 { |
1411 { |
1294 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcDescriptorPool::SetEndpointDescriptorTC()")); |
1412 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCDESCRIPTORPOOL_SETENDPOINTDESCRIPTORTC, |
|
1413 "TUsbcDescriptorPool::SetEndpointDescriptorTC()" ); |
1295 const TInt i = FindEpDescriptor(aInterface, aSetting, aEndpointAddress); |
1414 const TInt i = FindEpDescriptor(aInterface, aSetting, aEndpointAddress); |
1296 if (i < 0) |
1415 if (i < 0) |
1297 { |
1416 { |
1298 __KTRACE_OPT(KPANIC, Kern::Printf(" Error: no such endpoint")); |
1417 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCDESCRIPTORPOOL_SETENDPOINTDESCRIPTORTC_DUP1, |
|
1418 " Error: no such endpoint" ); |
1299 return KErrNotFound; |
1419 return KErrNotFound; |
1300 } |
1420 } |
1301 TBuf8<KUsbDescSize_AudioEndpoint> ep; // it could be an audio endpoint |
1421 TBuf8<KUsbDescSize_AudioEndpoint> ep; // it could be an audio endpoint |
1302 const TInt r = Kern::ThreadDesRead(aThread, &aBuffer, ep, 0); |
1422 const TInt r = Kern::ThreadDesRead(aThread, &aBuffer, ep, 0); |
1303 if (r != KErrNone) |
1423 if (r != KErrNone) |
1316 |
1436 |
1317 |
1437 |
1318 TInt TUsbcDescriptorPool::GetEndpointDescriptorSize(TInt aInterface, TInt aSetting, TUint8 aEndpointAddress, |
1438 TInt TUsbcDescriptorPool::GetEndpointDescriptorSize(TInt aInterface, TInt aSetting, TUint8 aEndpointAddress, |
1319 TInt& aSize) const |
1439 TInt& aSize) const |
1320 { |
1440 { |
1321 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcDescriptorPool::GetEndpointDescriptorSize()")); |
1441 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCDESCRIPTORPOOL_GETENDPOINTDESCRIPTORSIZE, |
|
1442 "TUsbcDescriptorPool::GetEndpointDescriptorSize()" ); |
1322 const TInt i = FindEpDescriptor(aInterface, aSetting, aEndpointAddress); |
1443 const TInt i = FindEpDescriptor(aInterface, aSetting, aEndpointAddress); |
1323 if (i < 0) |
1444 if (i < 0) |
1324 { |
1445 { |
1325 __KTRACE_OPT(KPANIC, Kern::Printf(" Error: no such endpoint")); |
1446 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCDESCRIPTORPOOL_GETENDPOINTDESCRIPTORSIZE_DUP1, |
|
1447 " Error: no such endpoint" ); |
1326 return KErrNotFound; |
1448 return KErrNotFound; |
1327 } |
1449 } |
1328 aSize = iDescriptors[i]->Size(); |
1450 aSize = iDescriptors[i]->Size(); |
1329 return KErrNone; |
1451 return KErrNone; |
1330 } |
1452 } |
1331 |
1453 |
1332 |
1454 |
1333 TInt TUsbcDescriptorPool::GetDeviceQualifierDescriptorTC(DThread* aThread, TDes8& aBuffer) const |
1455 TInt TUsbcDescriptorPool::GetDeviceQualifierDescriptorTC(DThread* aThread, TDes8& aBuffer) const |
1334 { |
1456 { |
1335 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcDescriptorPool::GetDeviceQualifierDescriptorTC()")); |
1457 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCDESCRIPTORPOOL_GETDEVICEQUALIFIERDESCRIPTORTC, |
|
1458 "TUsbcDescriptorPool::GetDeviceQualifierDescriptorTC()" ); |
1336 if (iDescriptors[KDescPosition_DeviceQualifier] == NULL) |
1459 if (iDescriptors[KDescPosition_DeviceQualifier] == NULL) |
1337 { |
1460 { |
1338 __KTRACE_OPT(KPANIC, Kern::Printf(" Warning: Device_Qualifier descriptor not supported")); |
1461 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCDESCRIPTORPOOL_GETDEVICEQUALIFIERDESCRIPTORTC_DUP1, |
|
1462 " Warning: Device_Qualifier descriptor not supported" ); |
1339 return KErrNotSupported; |
1463 return KErrNotSupported; |
1340 } |
1464 } |
1341 return Kern::ThreadDesWrite(aThread, &aBuffer, |
1465 return Kern::ThreadDesWrite(aThread, &aBuffer, |
1342 iDescriptors[KDescPosition_DeviceQualifier]->DescriptorData(), 0); |
1466 iDescriptors[KDescPosition_DeviceQualifier]->DescriptorData(), 0); |
1343 } |
1467 } |
1344 |
1468 |
1345 |
1469 |
1346 TInt TUsbcDescriptorPool::SetDeviceQualifierDescriptorTC(DThread* aThread, const TDes8& aBuffer) |
1470 TInt TUsbcDescriptorPool::SetDeviceQualifierDescriptorTC(DThread* aThread, const TDes8& aBuffer) |
1347 { |
1471 { |
1348 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcDescriptorPool::SetDeviceQualifierDescriptorTC()")); |
1472 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCDESCRIPTORPOOL_SETDEVICEQUALIFIERDESCRIPTORTC, |
|
1473 "TUsbcDescriptorPool::SetDeviceQualifierDescriptorTC()" ); |
1349 if (iDescriptors[KDescPosition_DeviceQualifier] == NULL) |
1474 if (iDescriptors[KDescPosition_DeviceQualifier] == NULL) |
1350 { |
1475 { |
1351 __KTRACE_OPT(KPANIC, Kern::Printf(" Warning: Device_Qualifier descriptor not supported")); |
1476 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCDESCRIPTORPOOL_SETDEVICEQUALIFIERDESCRIPTORTC_DUP1, |
|
1477 " Warning: Device_Qualifier descriptor not supported" ); |
1352 return KErrNotSupported; |
1478 return KErrNotSupported; |
1353 } |
1479 } |
1354 TBuf8<KUsbDescSize_DeviceQualifier> device; |
1480 TBuf8<KUsbDescSize_DeviceQualifier> device; |
1355 const TInt r = Kern::ThreadDesRead(aThread, &aBuffer, device, 0); |
1481 const TInt r = Kern::ThreadDesRead(aThread, &aBuffer, device, 0); |
1356 if (r != KErrNone) |
1482 if (r != KErrNone) |
1366 } |
1492 } |
1367 |
1493 |
1368 |
1494 |
1369 TInt TUsbcDescriptorPool::GetOtherSpeedConfigurationDescriptorTC(DThread* aThread, TDes8& aBuffer) const |
1495 TInt TUsbcDescriptorPool::GetOtherSpeedConfigurationDescriptorTC(DThread* aThread, TDes8& aBuffer) const |
1370 { |
1496 { |
1371 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcDescriptorPool::GetOtherSpeedConfigurationDescriptorTC()")); |
1497 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCDESCRIPTORPOOL_GETOTHERSPEEDCONFIGURATIONDESCRIPTORTC, |
|
1498 "TUsbcDescriptorPool::GetOtherSpeedConfigurationDescriptorTC()" ); |
1372 if (iDescriptors[KDescPosition_OtherSpeedConfig] == NULL) |
1499 if (iDescriptors[KDescPosition_OtherSpeedConfig] == NULL) |
1373 { |
1500 { |
1374 __KTRACE_OPT(KPANIC, Kern::Printf(" Warning: Other_Speed_Configuration descriptor not supported")); |
1501 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCDESCRIPTORPOOL_GETOTHERSPEEDCONFIGURATIONDESCRIPTORTC_DUP1, |
|
1502 " Warning: Other_Speed_Configuration descriptor not supported" ); |
1375 return KErrNotSupported; |
1503 return KErrNotSupported; |
1376 } |
1504 } |
1377 return Kern::ThreadDesWrite(aThread, &aBuffer, |
1505 return Kern::ThreadDesWrite(aThread, &aBuffer, |
1378 iDescriptors[KDescPosition_OtherSpeedConfig]->DescriptorData(), 0); |
1506 iDescriptors[KDescPosition_OtherSpeedConfig]->DescriptorData(), 0); |
1379 } |
1507 } |
1380 |
1508 |
1381 |
1509 |
1382 TInt TUsbcDescriptorPool::SetOtherSpeedConfigurationDescriptorTC(DThread* aThread, const TDes8& aBuffer) |
1510 TInt TUsbcDescriptorPool::SetOtherSpeedConfigurationDescriptorTC(DThread* aThread, const TDes8& aBuffer) |
1383 { |
1511 { |
1384 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcDescriptorPool::SetOtherSpeedConfigurationDescriptorTC()")); |
1512 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCDESCRIPTORPOOL_SETOTHERSPEEDCONFIGURATIONDESCRIPTORTC, |
|
1513 "TUsbcDescriptorPool::SetOtherSpeedConfigurationDescriptorTC()" ); |
1385 if (iDescriptors[KDescPosition_OtherSpeedConfig] == NULL) |
1514 if (iDescriptors[KDescPosition_OtherSpeedConfig] == NULL) |
1386 { |
1515 { |
1387 __KTRACE_OPT(KPANIC, Kern::Printf(" Warning: Other_Speed_Configuration descriptor not supported")); |
1516 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCDESCRIPTORPOOL_SETOTHERSPEEDCONFIGURATIONDESCRIPTORTC_DUP1, |
|
1517 " Warning: Other_Speed_Configuration descriptor not supported" ); |
1388 return KErrNotSupported; |
1518 return KErrNotSupported; |
1389 } |
1519 } |
1390 TBuf8<KUsbDescSize_OtherSpeedConfig> config; |
1520 TBuf8<KUsbDescSize_OtherSpeedConfig> config; |
1391 const TInt r = Kern::ThreadDesRead(aThread, &aBuffer, config, 0); |
1521 const TInt r = Kern::ThreadDesRead(aThread, &aBuffer, config, 0); |
1392 if (r != KErrNone) |
1522 if (r != KErrNone) |
1653 { |
1792 { |
1654 // we don't know the length of the string, so we have to allocate memory dynamically |
1793 // we don't know the length of the string, so we have to allocate memory dynamically |
1655 TUint strlen = Kern::ThreadGetDesLength(aThread, &aString); |
1794 TUint strlen = Kern::ThreadGetDesLength(aThread, &aString); |
1656 if (strlen > KUsbStringDescStringMaxSize) |
1795 if (strlen > KUsbStringDescStringMaxSize) |
1657 { |
1796 { |
1658 __KTRACE_OPT(KPANIC, Kern::Printf(" Warning: config $ descriptor too long - will be truncated")); |
1797 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCDESCRIPTORPOOL_SETCONFIGURATIONSTRINGDESCRIPTORTC, |
|
1798 " Warning: config $ descriptor too long - will be truncated" ); |
1659 strlen = KUsbStringDescStringMaxSize; |
1799 strlen = KUsbStringDescStringMaxSize; |
1660 } |
1800 } |
1661 HBuf8* const strbuf = HBuf8::New(strlen); |
1801 HBuf8* const strbuf = HBuf8::New(strlen); |
1662 if (!strbuf) |
1802 if (!strbuf) |
1663 { |
1803 { |
1664 __KTRACE_OPT(KPANIC, Kern::Printf(" Error: Memory allocation for config $ desc string failed (1)")); |
1804 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCDESCRIPTORPOOL_SETCONFIGURATIONSTRINGDESCRIPTORTC_DUP1, |
|
1805 " Error: Memory allocation for config $ desc string failed (1)" ); |
1665 return KErrNoMemory; |
1806 return KErrNoMemory; |
1666 } |
1807 } |
1667 strbuf->SetMax(); |
1808 strbuf->SetMax(); |
1668 // the aString points to data that lives in user memory, so we have to copy it: |
1809 // the aString points to data that lives in user memory, so we have to copy it: |
1669 const TInt r = Kern::ThreadDesRead(aThread, &aString, *strbuf, 0); |
1810 const TInt r = Kern::ThreadDesRead(aThread, &aString, *strbuf, 0); |
1670 if (r != KErrNone) |
1811 if (r != KErrNone) |
1671 { |
1812 { |
1672 __KTRACE_OPT(KPANIC, Kern::Printf(" Error: Thread read error")); |
1813 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCDESCRIPTORPOOL_SETCONFIGURATIONSTRINGDESCRIPTORTC_DUP2, |
|
1814 " Error: Thread read error" ); |
1673 delete strbuf; |
1815 delete strbuf; |
1674 return r; |
1816 return r; |
1675 } |
1817 } |
1676 TUsbcStringDescriptor* sd = TUsbcStringDescriptor::New(*strbuf); |
1818 TUsbcStringDescriptor* sd = TUsbcStringDescriptor::New(*strbuf); |
1677 if (!sd) |
1819 if (!sd) |
1678 { |
1820 { |
1679 __KTRACE_OPT(KPANIC, Kern::Printf(" Error: Memory allocation for config $ desc failed (2)")); |
1821 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCDESCRIPTORPOOL_SETCONFIGURATIONSTRINGDESCRIPTORTC_DUP3, |
|
1822 " Error: Memory allocation for config $ desc failed (2)" ); |
1680 delete strbuf; |
1823 delete strbuf; |
1681 return KErrNoMemory; |
1824 return KErrNoMemory; |
1682 } |
1825 } |
1683 // Delete old string, put in new one |
1826 // Delete old string, put in new one |
1684 ExchangeStringDescriptor(KStringPosition_Config, sd); |
1827 ExchangeStringDescriptor(KStringPosition_Config, sd); |
1712 } |
1855 } |
1713 |
1856 |
1714 |
1857 |
1715 TInt TUsbcDescriptorPool::GetStringDescriptorTC(DThread* aThread, TInt aIndex, TDes8& aString) const |
1858 TInt TUsbcDescriptorPool::GetStringDescriptorTC(DThread* aThread, TInt aIndex, TDes8& aString) const |
1716 { |
1859 { |
1717 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcDescriptorPool::GetStringDescriptorTC()")); |
1860 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCDESCRIPTORPOOL_GETSTRINGDESCRIPTORTC, |
|
1861 "TUsbcDescriptorPool::GetStringDescriptorTC()" ); |
1718 if (!StringDescriptorExists(aIndex)) |
1862 if (!StringDescriptorExists(aIndex)) |
1719 { |
1863 { |
1720 return KErrNotFound; |
1864 return KErrNotFound; |
1721 } |
1865 } |
1722 __KTRACE_OPT(KUSB, Kern::Printf(" String @ pos %d: \"%S\"", |
1866 OstTraceDefExt2( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCDESCRIPTORPOOL_GETSTRINGDESCRIPTORTC_DUP1, |
1723 aIndex, &iStrings[aIndex]->StringData())); |
1867 " String @ pos %d: \"%s\"", aIndex, iStrings[aIndex]->StringData() ); |
1724 return Kern::ThreadDesWrite(aThread, &aString, iStrings[aIndex]->StringData(), 0); |
1868 return Kern::ThreadDesWrite(aThread, &aString, iStrings[aIndex]->StringData(), 0); |
1725 } |
1869 } |
1726 |
1870 |
1727 |
1871 |
1728 TInt TUsbcDescriptorPool::SetStringDescriptorTC(DThread* aThread, TInt aIndex, const TDes8& aString) |
1872 TInt TUsbcDescriptorPool::SetStringDescriptorTC(DThread* aThread, TInt aIndex, const TDes8& aString) |
1729 { |
1873 { |
1730 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcDescriptorPool::SetStringDescriptorTC()")); |
1874 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCDESCRIPTORPOOL_SETSTRINGDESCRIPTORTC, |
|
1875 "TUsbcDescriptorPool::SetStringDescriptorTC()" ); |
1731 // we don't know the length of the string, so we have to allocate memory dynamically |
1876 // we don't know the length of the string, so we have to allocate memory dynamically |
1732 TUint strlen = Kern::ThreadGetDesLength(aThread, &aString); |
1877 TUint strlen = Kern::ThreadGetDesLength(aThread, &aString); |
1733 if (strlen > KUsbStringDescStringMaxSize) |
1878 if (strlen > KUsbStringDescStringMaxSize) |
1734 { |
1879 { |
1735 __KTRACE_OPT(KPANIC, Kern::Printf(" Warning: $ descriptor too long - will be truncated")); |
1880 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCDESCRIPTORPOOL_SETSTRINGDESCRIPTORTC_DUP1, |
|
1881 " Warning: $ descriptor too long - will be truncated" ); |
1736 strlen = KUsbStringDescStringMaxSize; |
1882 strlen = KUsbStringDescStringMaxSize; |
1737 } |
1883 } |
1738 HBuf8* strbuf = HBuf8::New(strlen); |
1884 HBuf8* strbuf = HBuf8::New(strlen); |
1739 if (!strbuf) |
1885 if (!strbuf) |
1740 { |
1886 { |
1741 __KTRACE_OPT(KPANIC, Kern::Printf(" Error: Mem alloc for $ desc string failed (1)")); |
1887 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCDESCRIPTORPOOL_SETSTRINGDESCRIPTORTC_DUP2, |
|
1888 " Error: Mem alloc for $ desc string failed (1)" ); |
1742 return KErrNoMemory; |
1889 return KErrNoMemory; |
1743 } |
1890 } |
1744 strbuf->SetMax(); |
1891 strbuf->SetMax(); |
1745 // the aString points to data that lives in user memory, so we have to copy it over: |
1892 // the aString points to data that lives in user memory, so we have to copy it over: |
1746 const TInt r = Kern::ThreadDesRead(aThread, &aString, *strbuf, 0); |
1893 const TInt r = Kern::ThreadDesRead(aThread, &aString, *strbuf, 0); |
1747 if (r != KErrNone) |
1894 if (r != KErrNone) |
1748 { |
1895 { |
1749 __KTRACE_OPT(KPANIC, Kern::Printf(" Error: Thread read error")); |
1896 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCDESCRIPTORPOOL_SETSTRINGDESCRIPTORTC_DUP3, |
|
1897 " Error: Thread read error" ); |
1750 delete strbuf; |
1898 delete strbuf; |
1751 return r; |
1899 return r; |
1752 } |
1900 } |
1753 TUsbcStringDescriptor* const sd = TUsbcStringDescriptor::New(*strbuf); |
1901 TUsbcStringDescriptor* const sd = TUsbcStringDescriptor::New(*strbuf); |
1754 if (!sd) |
1902 if (!sd) |
1755 { |
1903 { |
1756 __KTRACE_OPT(KPANIC, Kern::Printf(" Error: Mem alloc for $ desc failed (2)")); |
1904 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCDESCRIPTORPOOL_SETSTRINGDESCRIPTORTC_DUP4, |
|
1905 " Error: Mem alloc for $ desc failed (2)" ); |
1757 delete strbuf; |
1906 delete strbuf; |
1758 return KErrNoMemory; |
1907 return KErrNoMemory; |
1759 } |
1908 } |
1760 if (aIndex < iStrings.Count()) |
1909 if (aIndex < iStrings.Count()) |
1761 { |
1910 { |
1774 } |
1923 } |
1775 |
1924 |
1776 |
1925 |
1777 TInt TUsbcDescriptorPool::RemoveStringDescriptor(TInt aIndex) |
1926 TInt TUsbcDescriptorPool::RemoveStringDescriptor(TInt aIndex) |
1778 { |
1927 { |
1779 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcDescriptorPool::RemoveStringDescriptor()")); |
1928 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCDESCRIPTORPOOL_REMOVESTRINGDESCRIPTOR, |
|
1929 "TUsbcDescriptorPool::RemoveStringDescriptor()" ); |
1780 if (!StringDescriptorExists(aIndex)) |
1930 if (!StringDescriptorExists(aIndex)) |
1781 { |
1931 { |
1782 return KErrNotFound; |
1932 return KErrNotFound; |
1783 } |
1933 } |
1784 __KTRACE_OPT(KUSB, Kern::Printf(" Removing string @ pos %d: \"%S\"", |
1934 OstTraceDefExt2( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCDESCRIPTORPOOL_REMOVESTRINGDESCRIPTOR_DUP1, |
1785 aIndex, &iStrings[aIndex]->StringData())); |
1935 " Removing string @ pos %d: \"%s\"", aIndex, iStrings[aIndex]->StringData() ); |
1786 ExchangeStringDescriptor(aIndex, NULL); |
1936 ExchangeStringDescriptor(aIndex, NULL); |
1787 |
1937 |
1788 // Make sure there's no $ after aIndex. |
1938 // Make sure there's no $ after aIndex. |
1789 const TInt n = iStrings.Count(); |
1939 const TInt n = iStrings.Count(); |
1790 for (TInt i = aIndex; i < n; i++) |
1940 for (TInt i = aIndex; i < n; i++) |
1791 { |
1941 { |
1792 if (iStrings[i] != NULL) |
1942 if (iStrings[i] != NULL) |
1793 { |
1943 { |
1794 __KTRACE_OPT(KUSB, Kern::Printf(" Found $ @ idx %d - not compressing", i)); |
1944 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCDESCRIPTORPOOL_REMOVESTRINGDESCRIPTOR_DUP2, |
|
1945 " Found $ @ idx %d - not compressing", i ); |
1795 return KErrNone; |
1946 return KErrNone; |
1796 } |
1947 } |
1797 } |
1948 } |
1798 |
1949 |
1799 __KTRACE_OPT(KUSB, Kern::Printf(" No $ found after idx %d - compressing array", aIndex)); |
1950 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCDESCRIPTORPOOL_REMOVESTRINGDESCRIPTOR_DUP3, |
|
1951 " No $ found after idx %d - compressing array", aIndex ); |
1800 // Move aIndex back just before the first !NULL element. |
1952 // Move aIndex back just before the first !NULL element. |
1801 while (iStrings[--aIndex] == NULL) |
1953 while (iStrings[--aIndex] == NULL) |
1802 ; |
1954 ; |
1803 // Let aIndex point to first NULL. |
1955 // Let aIndex point to first NULL. |
1804 aIndex++; |
1956 aIndex++; |
1805 __KTRACE_OPT(KUSB, Kern::Printf(" Starting at index %d", aIndex)); |
1957 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCDESCRIPTORPOOL_REMOVESTRINGDESCRIPTOR_DUP4, |
|
1958 " Starting at index %d", aIndex ); |
1806 // Now remove NULL pointers until (Count() == aIndex). |
1959 // Now remove NULL pointers until (Count() == aIndex). |
1807 __KTRACE_OPT(KUSB, Kern::Printf(" iStrings.Count() before: %d", iStrings.Count())); |
1960 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCDESCRIPTORPOOL_REMOVESTRINGDESCRIPTOR_DUP5, |
|
1961 " iStrings.Count() before: %d", iStrings.Count() ); |
1808 do |
1962 do |
1809 { |
1963 { |
1810 iStrings.Remove(aIndex); |
1964 iStrings.Remove(aIndex); |
1811 __KTRACE_OPT(KUSB, Kern::Printf(" Removing $")); |
1965 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCDESCRIPTORPOOL_REMOVESTRINGDESCRIPTOR_DUP6, |
|
1966 " Removing $" ); |
1812 } |
1967 } |
1813 while (iStrings.Count() > aIndex); |
1968 while (iStrings.Count() > aIndex); |
1814 __KTRACE_OPT(KUSB, Kern::Printf(" iStrings.Count() after: %d", iStrings.Count())); |
1969 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCDESCRIPTORPOOL_REMOVESTRINGDESCRIPTOR_DUP7, |
1815 |
1970 " iStrings.Count() after: %d", iStrings.Count() ); |
1816 // Regain some memory. |
1971 // Regain some memory. |
1817 iStrings.Compress(); |
1972 iStrings.Compress(); |
1818 |
1973 |
1819 return KErrNone; |
1974 return KErrNone; |
1820 } |
1975 } |
1911 // |
2070 // |
1912 // Find the index of the Interface descriptor for a given interface setting. |
2071 // Find the index of the Interface descriptor for a given interface setting. |
1913 // |
2072 // |
1914 TInt TUsbcDescriptorPool::FindIfcDescriptor(TInt aIfcNumber, TInt aIfcSetting) const |
2073 TInt TUsbcDescriptorPool::FindIfcDescriptor(TInt aIfcNumber, TInt aIfcSetting) const |
1915 { |
2074 { |
1916 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcDescriptorPool::FindIfcDescriptor(%d, %d)", |
2075 OstTraceDefExt2( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCDESCRIPTORPOOL_FINDIFCDESCRIPTOR, |
1917 aIfcNumber, aIfcSetting)); |
2076 "TUsbcDescriptorPool::FindIfcDescriptor(%d, %d)", aIfcNumber, aIfcSetting ); |
1918 const TInt count = iDescriptors.Count(); |
2077 const TInt count = iDescriptors.Count(); |
1919 for (TInt i = KDescPosition_FirstAvailable; i < count; i++) |
2078 for (TInt i = KDescPosition_FirstAvailable; i < count; i++) |
1920 { |
2079 { |
1921 if ((iDescriptors[i]->Type() == KUsbDescType_Interface) && |
2080 if ((iDescriptors[i]->Type() == KUsbDescType_Interface) && |
1922 (iDescriptors[i]->Byte(2) == aIfcNumber) && |
2081 (iDescriptors[i]->Byte(2) == aIfcNumber) && |
1923 (iDescriptors[i]->Byte(3) == aIfcSetting)) |
2082 (iDescriptors[i]->Byte(3) == aIfcSetting)) |
1924 { |
2083 { |
1925 return i; |
2084 return i; |
1926 } |
2085 } |
1927 } |
2086 } |
1928 __KTRACE_OPT(KPANIC, Kern::Printf(" Error: no such interface")); |
2087 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCDESCRIPTORPOOL_FINDIFCDESCRIPTOR_DUP1, |
|
2088 " Error: no such interface" ); |
1929 return -1; |
2089 return -1; |
1930 } |
2090 } |
1931 |
2091 |
1932 |
2092 |
1933 // |
2093 // |
1934 // Find the index of the Endpoint descriptor for a given endpoint on a given interface setting. |
2094 // Find the index of the Endpoint descriptor for a given endpoint on a given interface setting. |
1935 // |
2095 // |
1936 TInt TUsbcDescriptorPool::FindEpDescriptor(TInt aIfcNumber, TInt aIfcSetting, TUint8 aEpAddress) const |
2096 TInt TUsbcDescriptorPool::FindEpDescriptor(TInt aIfcNumber, TInt aIfcSetting, TUint8 aEpAddress) const |
1937 { |
2097 { |
1938 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcDescriptorPool::FindEpDescriptor(%d, %d, 0x%02x)", |
2098 OstTraceDefExt3( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCDESCRIPTORPOOL_FINDEPDESCRIPTOR, |
1939 aIfcNumber, aIfcSetting, aEpAddress)); |
2099 "TUsbcDescriptorPool::FindEpDescriptor(%d, %d, 0x%02x)", aIfcNumber, aIfcSetting, aEpAddress ); |
1940 // first find the interface |
2100 // first find the interface |
1941 const TInt ifc = FindIfcDescriptor(aIfcNumber, aIfcSetting); |
2101 const TInt ifc = FindIfcDescriptor(aIfcNumber, aIfcSetting); |
1942 if (ifc < 0) |
2102 if (ifc < 0) |
1943 { |
2103 { |
1944 __KTRACE_OPT(KPANIC, Kern::Printf(" Error: no such interface")); |
2104 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCDESCRIPTORPOOL_FINDEPDESCRIPTOR_DUP1, |
|
2105 " Error: no such interface" ); |
1945 return ifc; |
2106 return ifc; |
1946 } |
2107 } |
1947 const TInt count = iDescriptors.Count(); |
2108 const TInt count = iDescriptors.Count(); |
1948 // then, before the next interface, try to locate the endpoint |
2109 // then, before the next interface, try to locate the endpoint |
1949 for (TInt i = ifc + 1; i < count; i++) |
2110 for (TInt i = ifc + 1; i < count; i++) |
1950 { |
2111 { |
1951 if (iDescriptors[i]->Type() == KUsbDescType_Interface) |
2112 if (iDescriptors[i]->Type() == KUsbDescType_Interface) |
1952 { |
2113 { |
1953 __KTRACE_OPT(KPANIC, Kern::Printf(" Error: no such endpoint before next interface")); |
2114 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCDESCRIPTORPOOL_FINDEPDESCRIPTOR_DUP2, |
|
2115 " Error: no such endpoint before next interface" ); |
1954 return -1; |
2116 return -1; |
1955 } |
2117 } |
1956 else if ((iDescriptors[i]->Type() == KUsbDescType_Endpoint) && |
2118 else if ((iDescriptors[i]->Type() == KUsbDescType_Endpoint) && |
1957 (iDescriptors[i]->Byte(2) == aEpAddress)) |
2119 (iDescriptors[i]->Byte(2) == aEpAddress)) |
1958 { |
2120 { |
1959 // found |
2121 // found |
1960 return i; |
2122 return i; |
1961 } |
2123 } |
1962 } |
2124 } |
1963 __KTRACE_OPT(KPANIC, Kern::Printf(" Error: no such endpoint")); |
2125 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCDESCRIPTORPOOL_FINDEPDESCRIPTOR_DUP3, |
|
2126 " Error: no such endpoint" ); |
1964 return -1; |
2127 return -1; |
1965 } |
2128 } |
1966 |
2129 |
1967 |
2130 |
1968 // |
2131 // |
1969 // Delete n descriptors starting from aIndex and remove their pointers from the array. |
2132 // Delete n descriptors starting from aIndex and remove their pointers from the array. |
1970 // |
2133 // |
1971 void TUsbcDescriptorPool::DeleteDescriptors(TInt aIndex, TInt aCount) |
2134 void TUsbcDescriptorPool::DeleteDescriptors(TInt aIndex, TInt aCount) |
1972 { |
2135 { |
1973 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcDescriptorPool::DeleteDescriptors()")); |
2136 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCDESCRIPTORPOOL_DELETEDESCRIPTORS, |
|
2137 "TUsbcDescriptorPool::DeleteDescriptors()" ); |
1974 if (aIndex < KDescPosition_FirstAvailable) |
2138 if (aIndex < KDescPosition_FirstAvailable) |
1975 { |
2139 { |
1976 __KTRACE_OPT(KPANIC, Kern::Printf(" Error: aIndex < KDescPosition_FirstAvailable")); |
2140 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCDESCRIPTORPOOL_DELETEDESCRIPTORS_DUP1, |
|
2141 " Error: aIndex < KDescPosition_FirstAvailable" ); |
1977 return; |
2142 return; |
1978 } |
2143 } |
1979 if (aCount <= 0) |
2144 if (aCount <= 0) |
1980 { |
2145 { |
1981 __KTRACE_OPT(KPANIC, Kern::Printf(" Error: aCount <= 0")); |
2146 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCDESCRIPTORPOOL_DELETEDESCRIPTORS_DUP2, |
|
2147 " Error: aCount <= 0" ); |
1982 return; |
2148 return; |
1983 } |
2149 } |
1984 __KTRACE_OPT(KUSB, Kern::Printf(" Removing descriptors at index %d:", aIndex)); |
2150 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCDESCRIPTORPOOL_DELETEDESCRIPTORS_DUP3, |
|
2151 " Removing descriptors at index %d:", aIndex ); |
1985 // Try to update wTotalLength field in Config descriptor |
2152 // Try to update wTotalLength field in Config descriptor |
1986 while (aCount--) |
2153 while (aCount--) |
1987 { |
2154 { |
1988 // In this loop we don't decrement aIndex, because after deleting an element |
2155 // In this loop we don't decrement aIndex, because after deleting an element |
1989 // aIndex is already indexing the next one. |
2156 // aIndex is already indexing the next one. |
1990 TUsbcDescriptorBase* const ptr = iDescriptors[aIndex]; |
2157 TUsbcDescriptorBase* const ptr = iDescriptors[aIndex]; |
1991 switch (ptr->Type()) |
2158 switch (ptr->Type()) |
1992 { |
2159 { |
1993 case KUsbDescType_Interface: |
2160 case KUsbDescType_Interface: |
1994 __KTRACE_OPT(KUSB, Kern::Printf(" - an interface descriptor")); |
2161 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCDESCRIPTORPOOL_DELETEDESCRIPTORS_DUP4, |
|
2162 " - an interface descriptor" ); |
1995 UpdateConfigDescriptorLength(-KUsbDescSize_Interface); |
2163 UpdateConfigDescriptorLength(-KUsbDescSize_Interface); |
1996 break; |
2164 break; |
1997 case KUsbDescType_Endpoint: |
2165 case KUsbDescType_Endpoint: |
1998 __KTRACE_OPT(KUSB, Kern::Printf(" - an endpoint descriptor")); |
2166 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCDESCRIPTORPOOL_DELETEDESCRIPTORS_DUP5, |
|
2167 " - an endpoint descriptor" ); |
1999 UpdateConfigDescriptorLength(-ptr->Size()); |
2168 UpdateConfigDescriptorLength(-ptr->Size()); |
2000 break; |
2169 break; |
2001 case KUsbDescType_CS_Interface: |
2170 case KUsbDescType_CS_Interface: |
2002 /* fall through */ |
2171 /* fall through */ |
2003 case KUsbDescType_CS_Endpoint: |
2172 case KUsbDescType_CS_Endpoint: |
2004 __KTRACE_OPT(KUSB, Kern::Printf(" - a class specific descriptor")); |
2173 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCDESCRIPTORPOOL_DELETEDESCRIPTORS_DUP6, |
|
2174 " - a class specific descriptor" ); |
2005 UpdateConfigDescriptorLength(-ptr->Size()); |
2175 UpdateConfigDescriptorLength(-ptr->Size()); |
2006 break; |
2176 break; |
2007 default: |
2177 default: |
2008 __KTRACE_OPT(KUSB, Kern::Printf(" - an unknown descriptor")); |
2178 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCDESCRIPTORPOOL_DELETEDESCRIPTORS_DUP7, |
2009 __KTRACE_OPT(KPANIC, Kern::Printf(" Error: unknown descriptor type")); |
2179 " - an unknown descriptor" ); |
|
2180 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCDESCRIPTORPOOL_DELETEDESCRIPTORS_DUP8, |
|
2181 " Error: unknown descriptor type" ); |
2010 } |
2182 } |
2011 iDescriptors.Remove(aIndex); |
2183 iDescriptors.Remove(aIndex); |
2012 delete ptr; |
2184 delete ptr; |
2013 } |
2185 } |
2014 } |
2186 } |
2017 // |
2189 // |
2018 // Update the wTotalLength field in the Configuration descriptor (aLength can be negative). |
2190 // Update the wTotalLength field in the Configuration descriptor (aLength can be negative). |
2019 // |
2191 // |
2020 void TUsbcDescriptorPool::UpdateConfigDescriptorLength(TInt aLength) |
2192 void TUsbcDescriptorPool::UpdateConfigDescriptorLength(TInt aLength) |
2021 { |
2193 { |
2022 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcDescriptorPool::UpdateConfigDescriptorLength(%d)", aLength)); |
2194 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCDESCRIPTORPOOL_UPDATECONFIGDESCRIPTORLENGTH, |
|
2195 "TUsbcDescriptorPool::UpdateConfigDescriptorLength(%d)", aLength ); |
2023 TUsbcDescriptorBase* const cnf = iDescriptors[KDescPosition_Config]; |
2196 TUsbcDescriptorBase* const cnf = iDescriptors[KDescPosition_Config]; |
2024 __KTRACE_OPT(KUSB, Kern::Printf(" wTotalLength old: %d", cnf->Word(2))); |
2197 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCDESCRIPTORPOOL_UPDATECONFIGDESCRIPTORLENGTH_DUP1, |
|
2198 " wTotalLength old: %d", cnf->Word(2) ); |
2025 // Update Config descriptor |
2199 // Update Config descriptor |
2026 cnf->SetWord(2, cnf->Word(2) + aLength); |
2200 cnf->SetWord(2, cnf->Word(2) + aLength); |
2027 __KTRACE_OPT(KUSB, Kern::Printf(" wTotalLength new: %d", cnf->Word(2))); |
2201 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCDESCRIPTORPOOL_UPDATECONFIGDESCRIPTORLENGTH_DUP2, |
|
2202 " wTotalLength new: %d", cnf->Word(2) ); |
2028 // Update Other_Speed_Config descriptor as well, if applicable |
2203 // Update Other_Speed_Config descriptor as well, if applicable |
2029 if (iDescriptors[KDescPosition_OtherSpeedConfig]) |
2204 if (iDescriptors[KDescPosition_OtherSpeedConfig]) |
2030 iDescriptors[KDescPosition_OtherSpeedConfig]->SetWord(2, cnf->Word(2)); |
2205 iDescriptors[KDescPosition_OtherSpeedConfig]->SetWord(2, cnf->Word(2)); |
2031 } |
2206 } |
2032 |
2207 |
2034 // |
2209 // |
2035 // Update the bNumInterfaces field in the Configuration descriptor (aNumber can be negative). |
2210 // Update the bNumInterfaces field in the Configuration descriptor (aNumber can be negative). |
2036 // |
2211 // |
2037 void TUsbcDescriptorPool::UpdateConfigDescriptorNumIfcs(TInt aNumber) |
2212 void TUsbcDescriptorPool::UpdateConfigDescriptorNumIfcs(TInt aNumber) |
2038 { |
2213 { |
2039 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcDescriptorPool::UpdateConfigDescriptorNumIfcs(%d)", aNumber)); |
2214 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCDESCRIPTORPOOL_UPDATECONFIGDESCRIPTORNUMIFCS, |
|
2215 "TUsbcDescriptorPool::UpdateConfigDescriptorNumIfcs(%d)", aNumber ); |
2040 TUsbcDescriptorBase* const cnf = iDescriptors[KDescPosition_Config]; |
2216 TUsbcDescriptorBase* const cnf = iDescriptors[KDescPosition_Config]; |
2041 __KTRACE_OPT(KUSB, Kern::Printf(" bNumInterfaces old: %d", cnf->Byte(4))); |
2217 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCDESCRIPTORPOOL_UPDATECONFIGDESCRIPTORNUMIFCS_DUP1, |
|
2218 " bNumInterfaces old: %d", cnf->Byte(4) ); |
2042 const TInt n = cnf->Byte(4) + aNumber; |
2219 const TInt n = cnf->Byte(4) + aNumber; |
2043 if (n < 0) |
2220 if (n < 0) |
2044 { |
2221 { |
2045 __KTRACE_OPT(KPANIC, Kern::Printf(" Error: bNumInterfaces + aNumber < 0")); |
2222 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCDESCRIPTORPOOL_UPDATECONFIGDESCRIPTORNUMIFCS_DUP2, |
|
2223 " Error: bNumInterfaces + aNumber < 0" ); |
2046 return; |
2224 return; |
2047 } |
2225 } |
2048 // Update Config descriptor |
2226 // Update Config descriptor |
2049 cnf->SetByte(4, n); |
2227 cnf->SetByte(4, n); |
2050 __KTRACE_OPT(KUSB, Kern::Printf(" bNumInterfaces new: %d", cnf->Byte(4))); |
2228 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCDESCRIPTORPOOL_UPDATECONFIGDESCRIPTORNUMIFCS_DUP3, |
|
2229 " bNumInterfaces new: %d", cnf->Byte(4) ); |
2051 // Update Other_Speed_Config descriptor as well, if applicable |
2230 // Update Other_Speed_Config descriptor as well, if applicable |
2052 if (iDescriptors[KDescPosition_OtherSpeedConfig]) |
2231 if (iDescriptors[KDescPosition_OtherSpeedConfig]) |
2053 iDescriptors[KDescPosition_OtherSpeedConfig]->SetByte(4, n); |
2232 iDescriptors[KDescPosition_OtherSpeedConfig]->SetByte(4, n); |
2054 } |
2233 } |
2055 |
2234 |
2079 // Put the current Device or Device_Qualifier descriptor in the Ep0 Tx buffer. |
2259 // Put the current Device or Device_Qualifier descriptor in the Ep0 Tx buffer. |
2080 // Only used for Ep0 standard requests, so target buffer can be hard-wired. |
2260 // Only used for Ep0 standard requests, so target buffer can be hard-wired. |
2081 // |
2261 // |
2082 TInt TUsbcDescriptorPool::GetDeviceDescriptor(TInt aIndex) const |
2262 TInt TUsbcDescriptorPool::GetDeviceDescriptor(TInt aIndex) const |
2083 { |
2263 { |
2084 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcDescriptorPool::GetDeviceDescriptor()")); |
2264 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCDESCRIPTORPOOL_GETDEVICEDESCRIPTOR, |
2085 __ASSERT_DEBUG((aIndex == KDescPosition_Device) || (aIndex == KDescPosition_DeviceQualifier), |
2265 "TUsbcDescriptorPool::GetDeviceDescriptor()" ); |
2086 Kern::Printf(" Error: invalid descriptor index: %d", aIndex)); |
2266 #ifdef _DEBUG |
|
2267 if (!((aIndex == KDescPosition_Device) || (aIndex == KDescPosition_DeviceQualifier))) |
|
2268 { |
|
2269 OstTraceDef1( OST_TRACE_CATEGORY_DEBUG, TRACE_NORMAL, TUSBCDESCRIPTORPOOL_GETDEVICEDESCRIPTOR_DUP1, |
|
2270 " Error: invalid descriptor index: %d", aIndex ); |
|
2271 } |
|
2272 #endif |
2087 if (iDescriptors[aIndex] == NULL) |
2273 if (iDescriptors[aIndex] == NULL) |
2088 { |
2274 { |
2089 // This doesn't have to be an error - we might get asked here for the Device_Qualifier descriptor |
2275 // This doesn't have to be an error - we might get asked here for the Device_Qualifier descriptor |
2090 // on a FS-only device. |
2276 // on a FS-only device. |
2091 __KTRACE_OPT(KUSB, Kern::Printf(" Descriptor #%d requested but not available", aIndex)); |
2277 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCDESCRIPTORPOOL_GETDEVICEDESCRIPTOR_DUP2, |
|
2278 " Descriptor #%d requested but not available", aIndex ); |
2092 return 0; |
2279 return 0; |
2093 } |
2280 } |
2094 return iDescriptors[aIndex]->GetDescriptorData(iEp0_TxBuf, KUsbcBufSz_Ep0Tx); |
2281 return iDescriptors[aIndex]->GetDescriptorData(iEp0_TxBuf, KUsbcBufSz_Ep0Tx); |
2095 } |
2282 } |
2096 |
2283 |
2100 // descriptors in the Ep0 Tx buffer. |
2287 // descriptors in the Ep0 Tx buffer. |
2101 // Only used for Ep0 standard requests, so target buffer can be hard-wired. |
2288 // Only used for Ep0 standard requests, so target buffer can be hard-wired. |
2102 // |
2289 // |
2103 TInt TUsbcDescriptorPool::GetConfigurationDescriptor(TInt aIndex) const |
2290 TInt TUsbcDescriptorPool::GetConfigurationDescriptor(TInt aIndex) const |
2104 { |
2291 { |
2105 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcDescriptorPool::GetConfigDescriptor(%d)", aIndex)); |
2292 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCDESCRIPTORPOOL_GETCONFIGURATIONDESCRIPTOR, |
2106 __ASSERT_DEBUG((aIndex == KDescPosition_Config) || (aIndex == KDescPosition_OtherSpeedConfig), |
2293 "TUsbcDescriptorPool::GetConfigDescriptor(%d)", aIndex ); |
2107 Kern::Printf(" Error: invalid descriptor index: %d", aIndex)); |
2294 #ifdef _DEBUG |
|
2295 if (!((aIndex == KDescPosition_Config) || (aIndex == KDescPosition_OtherSpeedConfig))) |
|
2296 { |
|
2297 OstTraceDef1( OST_TRACE_CATEGORY_DEBUG, TRACE_NORMAL, TUSBCDESCRIPTORPOOL_GETCONFIGURATIONDESCRIPTOR_DUP1, |
|
2298 " Error: invalid descriptor index: %d", aIndex ); |
|
2299 } |
|
2300 #endif |
2108 if (iDescriptors[aIndex] == NULL) |
2301 if (iDescriptors[aIndex] == NULL) |
2109 { |
2302 { |
2110 // This is always an error: We should always have a Configuration descriptor and we should never |
2303 // This is always an error: We should always have a Configuration descriptor and we should never |
2111 // get asked for the Other_Speed_Configuration descriptor if we don't have one (9.6.2). |
2304 // get asked for the Other_Speed_Configuration descriptor if we don't have one (9.6.2). |
2112 __KTRACE_OPT(KPANIC, Kern::Printf(" Warning: Descriptor %d requested but not available", aIndex)); |
2305 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCDESCRIPTORPOOL_GETCONFIGURATIONDESCRIPTOR_DUP2, |
|
2306 " Warning: Descriptor %d requested but not available", aIndex ); |
2113 return 0; |
2307 return 0; |
2114 } |
2308 } |
2115 |
2309 |
2116 const TInt count = iDescriptors.Count(); |
2310 const TInt count = iDescriptors.Count(); |
2117 TInt copied = 0; |
2311 TInt copied = 0; |
2166 { |
2361 { |
2167 ptr->UpdateFs(); |
2362 ptr->UpdateFs(); |
2168 } |
2363 } |
2169 } |
2364 } |
2170 |
2365 |
2171 __KTRACE_OPT(KUSB, Kern::Printf(" desc[%02d]: type = 0x%02x size = %d ", |
2366 OstTraceDefExt3( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCDESCRIPTORPOOL_GETCONFIGURATIONDESCRIPTOR_DUP4, |
2172 pos, ptr->Type(), ptr->Size())); |
2367 " desc[%02d]: type = 0x%02x size = %d ", pos, ptr->Type(), ptr->Size() ); |
2173 const TInt size = ptr->GetDescriptorData(buf, KUsbcBufSz_Ep0Tx - copied); |
2368 const TInt size = ptr->GetDescriptorData(buf, KUsbcBufSz_Ep0Tx - copied); |
2174 if (size == 0) |
2369 if (size == 0) |
2175 { |
2370 { |
2176 |
2371 |
2177 __KTRACE_OPT(KPANIC, |
2372 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCDESCRIPTORPOOL_GETCONFIGURATIONDESCRIPTOR_DUP5, |
2178 Kern::Printf(" Error: No Tx buffer space to copy this descriptor -> exiting")); |
2373 " Error: No Tx buffer space to copy this descriptor -> exiting" ); |
2179 break; |
2374 break; |
2180 } |
2375 } |
2181 copied += size; |
2376 copied += size; |
2182 if (copied >= KUsbcBufSz_Ep0Tx) |
2377 if (copied >= KUsbcBufSz_Ep0Tx) |
2183 { |
2378 { |
2184 __KTRACE_OPT(KPANIC, |
2379 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCDESCRIPTORPOOL_GETCONFIGURATIONDESCRIPTOR_DUP6, |
2185 Kern::Printf(" Error: No Tx buffer space left -> stopping here")); |
2380 " Error: No Tx buffer space left -> stopping here" ); |
2186 break; |
2381 break; |
2187 } |
2382 } |
2188 buf += size; |
2383 buf += size; |
2189 } |
2384 } |
2190 |
2385 |
2191 |
2386 |
2192 __KTRACE_OPT(KUSB, Kern::Printf(" copied %d bytes", copied)); |
2387 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCDESCRIPTORPOOL_GETCONFIGURATIONDESCRIPTOR_DUP7, |
|
2388 " copied %d bytes", copied ); |
2193 return copied; |
2389 return copied; |
2194 } |
2390 } |
2195 |
2391 |
2196 |
2392 |
2197 // |
2393 // |
2198 // Put the current OTG descriptor in the Ep0 Tx buffer. |
2394 // Put the current OTG descriptor in the Ep0 Tx buffer. |
2199 // Only used for Ep0 standard requests, so target buffer can be hard-wired. |
2395 // Only used for Ep0 standard requests, so target buffer can be hard-wired. |
2200 // |
2396 // |
2201 TInt TUsbcDescriptorPool::GetOtgDescriptor() const |
2397 TInt TUsbcDescriptorPool::GetOtgDescriptor() const |
2202 { |
2398 { |
2203 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcDescriptorPool::GetOtgDescriptor()")); |
2399 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCDESCRIPTORPOOL_GETOTGDESCRIPTOR, |
|
2400 "TUsbcDescriptorPool::GetOtgDescriptor()" ); |
2204 if (iDescriptors[KDescPosition_Otg] == NULL) |
2401 if (iDescriptors[KDescPosition_Otg] == NULL) |
2205 { |
2402 { |
2206 __KTRACE_OPT(KUSB, Kern::Printf(" OTG Descriptor not set")); |
2403 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCDESCRIPTORPOOL_GETOTGDESCRIPTOR_DUP1, |
|
2404 " OTG Descriptor not set" ); |
2207 return 0; |
2405 return 0; |
2208 } |
2406 } |
2209 return iDescriptors[KDescPosition_Otg]->GetDescriptorData(iEp0_TxBuf, KUsbcBufSz_Ep0Tx); |
2407 return iDescriptors[KDescPosition_Otg]->GetDescriptorData(iEp0_TxBuf, KUsbcBufSz_Ep0Tx); |
2210 } |
2408 } |
2211 |
2409 |
2234 // (one of Manufacturer, Product, SerialNumber). |
2433 // (one of Manufacturer, Product, SerialNumber). |
2235 // |
2434 // |
2236 TInt TUsbcDescriptorPool::GetDeviceStringDescriptorTC(DThread* aThread, TDes8& aString, |
2435 TInt TUsbcDescriptorPool::GetDeviceStringDescriptorTC(DThread* aThread, TDes8& aString, |
2237 TInt aIndex, TInt aPosition) const |
2436 TInt aIndex, TInt aPosition) const |
2238 { |
2437 { |
2239 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcDescriptorPool::GetDeviceStringDescriptorTC()")); |
2438 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCDESCRIPTORPOOL_GETDEVICESTRINGDESCRIPTORTC, |
|
2439 "TUsbcDescriptorPool::GetDeviceStringDescriptorTC()" ); |
2240 const TInt str_idx = iDescriptors[KDescPosition_Device]->Byte(aIndex); |
2440 const TInt str_idx = iDescriptors[KDescPosition_Device]->Byte(aIndex); |
2241 if (str_idx) |
2441 if (str_idx) |
2242 { |
2442 { |
2243 __ASSERT_ALWAYS((str_idx == aPosition), Kern::Fault(KUsbPanicCat, __LINE__)); |
2443 __ASSERT_ALWAYS((str_idx == aPosition), Kern::Fault(KUsbPanicCat, __LINE__)); |
2244 __KTRACE_OPT(KUSB, Kern::Printf(" String @ pos %d (device $): \"%S\"", |
2444 OstTraceDefExt2( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCDESCRIPTORPOOL_GETDEVICESTRINGDESCRIPTORTC_DUP1, |
2245 str_idx, &iStrings[str_idx]->StringData())); |
2445 " String @ pos %d (device $): \"%s\"", str_idx, iStrings[str_idx]->StringData() ); |
2246 return Kern::ThreadDesWrite(aThread, &aString, |
2446 return Kern::ThreadDesWrite(aThread, &aString, |
2247 iStrings[str_idx]->StringData(), 0); |
2447 iStrings[str_idx]->StringData(), 0); |
2248 } |
2448 } |
2249 else |
2449 else |
2250 { |
2450 { |
2251 __KTRACE_OPT(KUSB, Kern::Printf(" No string descriptor @ pos %d", aIndex)); |
2451 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCDESCRIPTORPOOL_GETDEVICESTRINGDESCRIPTORTC_DUP2, |
|
2452 " No string descriptor @ pos %d", aIndex ); |
2252 return KErrNotFound; |
2453 return KErrNotFound; |
2253 } |
2454 } |
2254 } |
2455 } |
2255 |
2456 |
2256 |
2457 |
2259 // (one of Manufacturer, Product, SerialNumber). |
2460 // (one of Manufacturer, Product, SerialNumber). |
2260 // |
2461 // |
2261 TInt TUsbcDescriptorPool::SetDeviceStringDescriptorTC(DThread* aThread, const TDes8& aString, |
2462 TInt TUsbcDescriptorPool::SetDeviceStringDescriptorTC(DThread* aThread, const TDes8& aString, |
2262 TInt aIndex, TInt aPosition) |
2463 TInt aIndex, TInt aPosition) |
2263 { |
2464 { |
2264 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcDescriptorPool::SetDeviceStringDescriptorTC()")); |
2465 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCDESCRIPTORPOOL_SETDEVICESTRINGDESCRIPTORTC, |
|
2466 "TUsbcDescriptorPool::SetDeviceStringDescriptorTC()" ); |
2265 // we don't know the length of the string, so we have to allocate memory dynamically |
2467 // we don't know the length of the string, so we have to allocate memory dynamically |
2266 TUint strlen = Kern::ThreadGetDesLength(aThread, &aString); |
2468 TUint strlen = Kern::ThreadGetDesLength(aThread, &aString); |
2267 if (strlen > KUsbStringDescStringMaxSize) |
2469 if (strlen > KUsbStringDescStringMaxSize) |
2268 { |
2470 { |
2269 __KTRACE_OPT(KPANIC, Kern::Printf(" Warning: $ descriptor too long - will be truncated")); |
2471 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCDESCRIPTORPOOL_SETDEVICESTRINGDESCRIPTORTC_DUP1, |
|
2472 " Warning: $ descriptor too long - will be truncated" ); |
2270 strlen = KUsbStringDescStringMaxSize; |
2473 strlen = KUsbStringDescStringMaxSize; |
2271 } |
2474 } |
2272 HBuf8* const strbuf = HBuf8::New(strlen); |
2475 HBuf8* const strbuf = HBuf8::New(strlen); |
2273 if (!strbuf) |
2476 if (!strbuf) |
2274 { |
2477 { |
2275 __KTRACE_OPT(KPANIC, Kern::Printf(" Error: Memory allocation for dev $ desc string failed (1)")); |
2478 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCDESCRIPTORPOOL_SETDEVICESTRINGDESCRIPTORTC_DUP2, |
|
2479 " Error: Memory allocation for dev $ desc string failed (1)" ); |
2276 return KErrNoMemory; |
2480 return KErrNoMemory; |
2277 } |
2481 } |
2278 strbuf->SetMax(); |
2482 strbuf->SetMax(); |
2279 // the aString points to data that lives in user memory, so we have to copy it: |
2483 // the aString points to data that lives in user memory, so we have to copy it: |
2280 const TInt r = Kern::ThreadDesRead(aThread, &aString, *strbuf, 0); |
2484 const TInt r = Kern::ThreadDesRead(aThread, &aString, *strbuf, 0); |
2281 if (r != KErrNone) |
2485 if (r != KErrNone) |
2282 { |
2486 { |
2283 __KTRACE_OPT(KPANIC, Kern::Printf(" Error: Thread read error")); |
2487 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCDESCRIPTORPOOL_SETDEVICESTRINGDESCRIPTORTC_DUP3, |
|
2488 " Error: Thread read error" ); |
2284 delete strbuf; |
2489 delete strbuf; |
2285 return r; |
2490 return r; |
2286 } |
2491 } |
2287 TUsbcStringDescriptor* const sd = TUsbcStringDescriptor::New(*strbuf); |
2492 TUsbcStringDescriptor* const sd = TUsbcStringDescriptor::New(*strbuf); |
2288 if (!sd) |
2493 if (!sd) |
2289 { |
2494 { |
2290 __KTRACE_OPT(KPANIC, Kern::Printf(" Error: Memory allocation for dev $ desc failed (2)")); |
2495 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCDESCRIPTORPOOL_SETDEVICESTRINGDESCRIPTORTC_DUP4, |
|
2496 " Error: Memory allocation for dev $ desc failed (2)" ); |
2291 delete strbuf; |
2497 delete strbuf; |
2292 return KErrNoMemory; |
2498 return KErrNoMemory; |
2293 } |
2499 } |
2294 ExchangeStringDescriptor(aPosition, sd); |
2500 ExchangeStringDescriptor(aPosition, sd); |
2295 iDescriptors[KDescPosition_Device]->SetByte(aIndex, aPosition); |
2501 iDescriptors[KDescPosition_Device]->SetByte(aIndex, aPosition); |
2319 // |
2527 // |
2320 // Puts aDesc at postion aIndex in the string descriptor array, after deleting what was (possibly) there. |
2528 // Puts aDesc at postion aIndex in the string descriptor array, after deleting what was (possibly) there. |
2321 // |
2529 // |
2322 void TUsbcDescriptorPool::ExchangeStringDescriptor(TInt aIndex, const TUsbcStringDescriptor* aDesc) |
2530 void TUsbcDescriptorPool::ExchangeStringDescriptor(TInt aIndex, const TUsbcStringDescriptor* aDesc) |
2323 { |
2531 { |
2324 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcDescriptorPool::ExchangeStringDescriptor()")); |
2532 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCDESCRIPTORPOOL_EXCHANGESTRINGDESCRIPTOR, |
|
2533 "TUsbcDescriptorPool::ExchangeStringDescriptor()" ); |
2325 TUsbcStringDescriptorBase* const ptr = iStrings[aIndex]; |
2534 TUsbcStringDescriptorBase* const ptr = iStrings[aIndex]; |
2326 __KTRACE_OPT(KUSB, Kern::Printf(" Deleting string descriptor at index %d: 0x%x", aIndex, ptr)); |
2535 OstTraceDefExt2( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCDESCRIPTORPOOL_EXCHANGESTRINGDESCRIPTOR_DUP1, |
|
2536 " Deleting string descriptor at index %d: 0x%x", aIndex, reinterpret_cast<TUint>(ptr) ); |
2327 iStrings.Remove(aIndex); |
2537 iStrings.Remove(aIndex); |
2328 delete ptr; |
2538 delete ptr; |
2329 __KTRACE_OPT(KUSB, Kern::Printf(" Inserting string descriptor at index %d: 0x%x", aIndex, aDesc)); |
2539 OstTraceDefExt2( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCDESCRIPTORPOOL_EXCHANGESTRINGDESCRIPTOR_DUP2, |
|
2540 " Inserting string descriptor at index %d: 0x%x", aIndex, reinterpret_cast<TUint>(aDesc) ); |
2330 iStrings.Insert(aDesc, aIndex); |
2541 iStrings.Insert(aDesc, aIndex); |
2331 } |
2542 } |
2332 |
2543 |
2333 |
2544 |
2334 // |
2545 // |