23 #include "fdf.h" |
23 #include "fdf.h" |
24 #include <usb/usblogger.h> |
24 #include <usb/usblogger.h> |
25 #include "utils.h" |
25 #include "utils.h" |
26 #include <usbhost/internal/fdcplugin.hrh> |
26 #include <usbhost/internal/fdcplugin.hrh> |
27 #include "eventqueue.h" |
27 #include "eventqueue.h" |
28 #include "OstTraceDefinitions.h" |
28 |
29 #ifdef OST_TRACE_COMPILER_IN_USE |
29 #ifdef __FLOG_ACTIVE |
30 #include "fdfTraces.h" |
30 _LIT8(KLogComponent, "fdf "); |
31 #endif |
31 #endif |
32 |
|
33 |
32 |
34 _LIT(KDriverUsbhubLddFileName,"usbhubdriver"); |
33 _LIT(KDriverUsbhubLddFileName,"usbhubdriver"); |
35 _LIT(KDriverUsbdiLddFileName,"usbdi"); |
34 _LIT(KDriverUsbdiLddFileName,"usbdi"); |
36 |
35 |
37 _LIT(KPanicCategory, "fdf"); |
36 PANICCATEGORY("fdf"); |
38 |
37 |
39 const TUint KVendorSpecificDeviceClassValue = 0xFF; |
38 const TUint KVendorSpecificDeviceClassValue = 0xFF; |
40 const TUint KVendorSpecificInterfaceClassValue = 0xFF; |
39 const TUint KVendorSpecificInterfaceClassValue = 0xFF; |
41 const TUint KMaxSearchKeyLength = 64; |
40 const TUint KMaxSearchKeyLength = 64; |
42 |
41 |
43 // Factory function for TInterfaceInfo objects. |
42 // Factory function for TInterfaceInfo objects. |
44 CFdf::TInterfaceInfo* CFdf::TInterfaceInfo::NewL(RPointerArray<CFdf::TInterfaceInfo>& aInterfaces) |
43 CFdf::TInterfaceInfo* CFdf::TInterfaceInfo::NewL(RPointerArray<CFdf::TInterfaceInfo>& aInterfaces) |
45 { |
44 { |
46 OstTraceFunctionEntry0( CFDF_TINTERFACEINFO_NEWL_ENTRY ); |
45 LOG_STATIC_FUNC_ENTRY |
47 |
46 |
48 TInterfaceInfo* self = new(ELeave) TInterfaceInfo; |
47 TInterfaceInfo* self = new(ELeave) TInterfaceInfo; |
49 CleanupStack::PushL(self); |
48 CleanupStack::PushL(self); |
50 aInterfaces.AppendL(self); |
49 aInterfaces.AppendL(self); |
51 CLEANUPSTACK_POP1(self); |
50 CLEANUPSTACK_POP1(self); |
52 OstTraceFunctionExit0( CFDF_TINTERFACEINFO_NEWL_EXIT ); |
|
53 return self; |
51 return self; |
54 } |
52 } |
55 |
53 |
56 |
54 |
57 CFdf* CFdf::NewL() |
55 CFdf* CFdf::NewL() |
58 { |
56 { |
59 OstTraceFunctionEntry0( CFDF_NEWL_ENTRY ); |
57 LOG_STATIC_FUNC_ENTRY |
60 |
58 |
61 CFdf* self = new(ELeave) CFdf; |
59 CFdf* self = new(ELeave) CFdf; |
62 CleanupStack::PushL(self); |
60 CleanupStack::PushL(self); |
63 self->ConstructL(); |
61 self->ConstructL(); |
64 CLEANUPSTACK_POP1(self); |
62 CLEANUPSTACK_POP1(self); |
65 OstTraceFunctionExit0( CFDF_NEWL_EXIT ); |
|
66 return self; |
63 return self; |
67 } |
64 } |
68 |
65 |
69 CFdf::CFdf() |
66 CFdf::CFdf() |
70 : iDevices(_FOFF(CDeviceProxy, iLink)), |
67 : iDevices(_FOFF(CDeviceProxy, iLink)), |
71 iFunctionDrivers(_FOFF(CFdcProxy, iLink)) |
68 iFunctionDrivers(_FOFF(CFdcProxy, iLink)) |
72 { |
69 { |
73 OstTraceFunctionEntry0( CFDF_CFDF_CONS_ENTRY ); |
70 LOG_FUNC |
74 } |
71 } |
75 |
72 |
76 void CFdf::ConstructL() |
73 void CFdf::ConstructL() |
77 { |
74 { |
78 OstTraceFunctionEntry0( CFDF_CONSTRUCTL_ENTRY ); |
75 LOG_FUNC |
79 |
76 |
80 #ifndef __OVER_DUMMYUSBDI__ |
77 #ifndef __OVER_DUMMYUSBDI__ |
81 // If we're using the DummyUSBDI we don't need the real USBDI. |
78 // If we're using the DummyUSBDI we don't need the real USBDI. |
82 TInt err = User::LoadLogicalDevice(KDriverUsbhubLddFileName); |
79 TInt err = User::LoadLogicalDevice(KDriverUsbhubLddFileName); |
83 if ( err != KErrAlreadyExists ) |
80 if ( err != KErrAlreadyExists ) |
84 { |
81 { |
85 LEAVEIFERRORL(err,OstTrace1( TRACE_NORMAL, CFDF_CONSTRUCTL, "Error when loading KDriverUsbhubLddFileName OVER DUMMYUSBDI; err=%d", err );); |
82 LEAVEIFERRORL(err); |
86 } |
83 } |
87 #endif // __OVER_DUMMYUSBDI__ |
84 #endif // __OVER_DUMMYUSBDI__ |
88 |
85 |
89 TInt errDr=iHubDriver.Open(); |
86 LEAVEIFERRORL(iHubDriver.Open()); |
90 LEAVEIFERRORL(errDr,OstTrace1( TRACE_NORMAL, CFDF_CONSTRUCTL_DUP1, "Error when open iHubDriver; errDr=%d", errDr );); |
|
91 |
87 |
92 #ifdef __OVER_DUMMYUSBDI__ |
88 #ifdef __OVER_DUMMYUSBDI__ |
93 //LEAVEIFERRORL(iHubDriver.StartHost()); |
89 LEAVEIFERRORL(iHubDriver.StartHost()); |
94 TInt errHo=iHubDriver.StartHost(); |
|
95 LEAVEIFERRORL(errHo,OstTrace1( TRACE_NORMAL, CFDF_CONSTRUCTL_DUP2, "Fail in iHubDriver.StartHost in dummy; errHo=%d", errHo );); |
|
96 |
|
97 #endif |
90 #endif |
98 |
91 |
99 iActiveWaitForBusEvent = CActiveWaitForBusEvent::NewL(iHubDriver, iBusEvent, *this); |
92 iActiveWaitForBusEvent = CActiveWaitForBusEvent::NewL(iHubDriver, iBusEvent, *this); |
100 iActiveWaitForBusEvent->Wait(); |
93 iActiveWaitForBusEvent->Wait(); |
101 |
94 |
183 iHubDriver.Close(); |
172 iHubDriver.Close(); |
184 |
173 |
185 #ifndef __OVER_DUMMYUSBDI__ |
174 #ifndef __OVER_DUMMYUSBDI__ |
186 //If we're using the DummyUSBDI the real USBDI isn't loaded. |
175 //If we're using the DummyUSBDI the real USBDI isn't loaded. |
187 TInt err = User::FreeLogicalDevice(KDriverUsbhubLddFileName); |
176 TInt err = User::FreeLogicalDevice(KDriverUsbhubLddFileName); |
188 OstTrace1( TRACE_NORMAL, CFDF_CFDF_DUP1, "FreeLogicalDevice( usbhubdriver ) returned %d", err ); |
177 LOGTEXT2(_L8("\tFreeLogicalDevice( usbhubdriver ) returned %d"), err); |
|
178 |
189 err = User::FreeLogicalDevice(KDriverUsbdiLddFileName); |
179 err = User::FreeLogicalDevice(KDriverUsbdiLddFileName); |
190 OstTrace1( TRACE_NORMAL, CFDF_CFDF_DUP2, "FreeLogicalDevice( usbdi ) returned %d", err ); |
180 LOGTEXT2(_L8("\tFreeLogicalDevice( usbdi ) returned %d"), err); |
191 #endif // __OVER_DUMMYUSBDI__ |
181 #endif // __OVER_DUMMYUSBDI__ |
192 |
182 |
193 delete iEventQueue; |
183 delete iEventQueue; |
194 |
184 |
195 // This is a worthwhile check to do at this point. If we ever don't clean |
185 // This is a worthwhile check to do at this point. If we ever don't clean |
196 // up iInterfaces at the *right* time, then this will be easier to debug |
186 // up iInterfaces at the *right* time, then this will be easier to debug |
197 // than a memory leak. |
187 // than a memory leak. |
198 if(!(iInterfaces.Count() == 0)) |
188 ASSERT_DEBUG(iInterfaces.Count() == 0); |
199 { |
|
200 OstTrace1( TRACE_FATAL, CFDF_CFDF_DUP3, "Memory leak from interface;Interface remains %d", iInterfaces.Count() ); |
|
201 __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); |
|
202 } |
|
203 |
189 |
204 iImplInfoArray.ResetAndDestroy(); |
190 iImplInfoArray.ResetAndDestroy(); |
205 REComSession::FinalClose(); |
191 REComSession::FinalClose(); |
206 OstTraceFunctionExit0( CFDF_CFDF_DES_EXIT ); |
|
207 } |
192 } |
208 |
193 |
209 void CFdf::EnableDriverLoading() |
194 void CFdf::EnableDriverLoading() |
210 { |
195 { |
211 OstTraceFunctionEntry0( CFDF_ENABLEDRIVERLOADING_ENTRY ); |
196 LOG_FUNC |
|
197 |
212 iDriverLoadingEnabled = ETrue; |
198 iDriverLoadingEnabled = ETrue; |
213 } |
199 } |
214 |
200 |
215 void CFdf::DisableDriverLoading() |
201 void CFdf::DisableDriverLoading() |
216 { |
202 { |
217 OstTraceFunctionEntry0( CFDF_DISABLEDRIVERLOADING_ENTRY ); |
203 LOG_FUNC |
|
204 |
218 iDriverLoadingEnabled = EFalse; |
205 iDriverLoadingEnabled = EFalse; |
219 } |
206 } |
220 |
207 |
221 void CFdf::SetSession(CFdfSession* aSession) |
208 void CFdf::SetSession(CFdfSession* aSession) |
222 { |
209 { |
223 OstTraceFunctionEntry0( CFDF_SETSESSION_ENTRY ); |
210 LOG_FUNC |
224 OstTrace1( TRACE_NORMAL, CFDF_SETSESSION, "aSession = 0x%08x", aSession ); |
211 LOGTEXT2(_L8("\taSession = 0x%08x"), aSession); |
|
212 |
225 iSession = aSession; |
213 iSession = aSession; |
226 } |
214 } |
227 |
215 |
228 CFdfSession* CFdf::Session() |
216 CFdfSession* CFdf::Session() |
229 { |
217 { |
230 return iSession; |
218 return iSession; |
231 } |
219 } |
232 |
220 |
233 TBool CFdf::GetDeviceEvent(TDeviceEvent& aEvent) |
221 TBool CFdf::GetDeviceEvent(TDeviceEvent& aEvent) |
234 { |
222 { |
235 OstTraceFunctionEntry0( CFDF_GETDEVICEEVENT_ENTRY ); |
223 LOG_FUNC |
236 if(!iEventQueue) |
224 |
237 { |
225 ASSERT_DEBUG(iEventQueue); |
238 OstTrace0( TRACE_FATAL, CFDF_GETDEVICEEVENT, "iEventQueue is empty" ); |
|
239 __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); |
|
240 } |
|
241 |
|
242 return iEventQueue->GetDeviceEvent(aEvent); |
226 return iEventQueue->GetDeviceEvent(aEvent); |
243 } |
227 } |
244 |
228 |
245 TBool CFdf::GetDevmonEvent(TInt& aEvent) |
229 TBool CFdf::GetDevmonEvent(TInt& aEvent) |
246 { |
230 { |
247 OstTraceFunctionEntry0( CFDF_GETDEVMONEVENT_ENTRY ); |
231 LOG_FUNC |
248 |
232 |
249 if(!iEventQueue) |
233 ASSERT_DEBUG(iEventQueue); |
250 { |
|
251 OstTrace0( TRACE_FATAL, CFDF_GETDEVMONEVENT, "iEventQueue is empty" ); |
|
252 __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); |
|
253 } |
|
254 |
|
255 |
|
256 return iEventQueue->GetDevmonEvent(aEvent); |
234 return iEventQueue->GetDevmonEvent(aEvent); |
257 } |
235 } |
258 |
236 |
259 |
237 |
260 // An ECom plugin has been installed or removed |
238 // An ECom plugin has been installed or removed |
266 |
244 |
267 } |
245 } |
268 |
246 |
269 void CFdf::HandleEComEventReceivedL() |
247 void CFdf::HandleEComEventReceivedL() |
270 { |
248 { |
271 OstTraceFunctionEntry0( CFDF_HANDLEECOMEVENTRECEIVEDL_ENTRY ); |
249 LOG_FUNC |
272 |
250 |
273 // There is no way to filter ecom notification to only receive ones we are interested in, also there is no way |
251 // There is no way to filter ecom notification to only receive ones we are interested in, also there is no way |
274 // to query ecom as to what has changed. Hence there is no option but to call ListImplementations(). |
252 // to query ecom as to what has changed. Hence there is no option but to call ListImplementations(). |
275 iImplInfoArray.ResetAndDestroy(); |
253 iImplInfoArray.ResetAndDestroy(); |
276 |
254 |
277 REComSession::ListImplementationsL(TUid::Uid(KFdcEcomInterfaceUid), iImplInfoArray); |
255 REComSession::ListImplementationsL(TUid::Uid(KFdcEcomInterfaceUid), iImplInfoArray); |
278 TUint implementationsCount = iImplInfoArray.Count(); |
256 TUint implementationsCount = iImplInfoArray.Count(); |
279 OstTrace1( TRACE_NORMAL, CFDF_HANDLEECOMEVENTRECEIVEDL, "iImplInfoArray.Count() after ECom notification= %d", implementationsCount ); |
257 LOGTEXT2(_L8("\tiImplInfoArray.Count() after ECom notification= %d"), implementationsCount); |
280 |
258 |
|
259 #ifdef __FLOG_ACTIVE |
281 if ( implementationsCount == 0 ) |
260 if ( implementationsCount == 0 ) |
282 { |
261 { |
283 OstTrace0( TRACE_NORMAL, CFDF_HANDLEECOMEVENTRECEIVEDL_DUP1, "THERE ARE NO FUNCTION DRIVERS PRESENT IN THE SYSTEM" ); |
262 LOGTEXT(_L8("\tTHERE ARE NO FUNCTION DRIVERS PRESENT IN THE SYSTEM")); |
284 } |
263 } |
285 |
264 |
286 TSglQueIter<CFdcProxy> proxiesIterDebug(iFunctionDrivers); |
265 TSglQueIter<CFdcProxy> proxiesIterDebug(iFunctionDrivers); |
287 CFdcProxy* fdcDebug = NULL; |
266 CFdcProxy* fdcDebug = NULL; |
288 while ( ( fdcDebug = proxiesIterDebug++ ) != NULL ) |
267 while ( ( fdcDebug = proxiesIterDebug++ ) != NULL ) |
289 { |
268 { |
290 TUid fdcUid = fdcDebug->ImplUid(); |
269 TUid fdcUid = fdcDebug->ImplUid(); |
291 OstTrace1( TRACE_NORMAL, CFDF_HANDLEECOMEVENTRECEIVEDL_DUP2, "Old FDC Proxy implementation UID: 0x%08x", fdcUid.iUid ); |
270 LOGTEXT2(_L8("\t\tOld FDC Proxy implementation UID: 0x%08x"), fdcUid.iUid); |
292 TInt fdcVersion = fdcDebug->Version(); |
271 TInt fdcVersion = fdcDebug->Version(); |
293 OstTrace1( TRACE_NORMAL, CFDF_HANDLEECOMEVENTRECEIVEDL_DUP3, "FDC Proxy version UID: %d", fdcVersion ); |
272 LOGTEXT2(_L8("\t\tFDC Proxy version UID: %d"), fdcVersion); |
294 } |
273 } |
295 OstTrace0( TRACE_NORMAL, CFDF_HANDLEECOMEVENTRECEIVEDL_DUP4, "------------------------------------------------------------------" ); |
274 LOGTEXT(_L8("\t\t------------------------------------------------------------------")); |
296 |
|
297 for (TInt kk = 0; kk < implementationsCount; ++kk) |
275 for (TInt kk = 0; kk < implementationsCount; ++kk) |
298 { |
276 { |
299 TUid fdcUid2 = iImplInfoArray[kk]->ImplementationUid(); |
277 TUid fdcUid2 = iImplInfoArray[kk]->ImplementationUid(); |
300 OstTrace1( TRACE_NORMAL, CFDF_HANDLEECOMEVENTRECEIVEDL_DUP5, "New FDC Proxy implementation UID: 0x%08x", fdcUid2.iUid ); |
278 LOGTEXT2(_L8("\t\tNew FDC Proxy implementation UID: 0x%08x"), fdcUid2.iUid); |
301 TInt fdcVersion2 = iImplInfoArray[kk]->Version(); |
279 TInt fdcVersion2 = iImplInfoArray[kk]->Version(); |
302 OstTrace1( TRACE_NORMAL, CFDF_HANDLEECOMEVENTRECEIVEDL_DUP6, "FDC Proxy version UID: %d", fdcVersion2 ); |
280 LOGTEXT2(_L8("\t\tFDC Proxy version UID: %d"), fdcVersion2); |
303 } |
281 } |
|
282 #endif |
304 |
283 |
305 // See if any relevant FDCs (or upgrades) have been installed or uninstalled: |
284 // See if any relevant FDCs (or upgrades) have been installed or uninstalled: |
306 |
285 |
307 // For each FD in the proxy list compare the uid and version with each FD returned by ECom looking |
286 // For each FD in the proxy list compare the uid and version with each FD returned by ECom looking |
308 // for the removal, upgrade or downgrade of an existing FD |
287 // for the removal, upgrade or downgrade of an existing FD |
456 |
425 |
457 // Only re-post the notification when we've finished examining the |
426 // Only re-post the notification when we've finished examining the |
458 // TBusEvent from the previous completion. (Otherwise it might get |
427 // TBusEvent from the previous completion. (Otherwise it might get |
459 // overwritten.) |
428 // overwritten.) |
460 iActiveWaitForBusEvent->Wait(); |
429 iActiveWaitForBusEvent->Wait(); |
461 OstTraceFunctionExit0( CFDF_MBEOBUSEVENT_EXIT ); |
|
462 } |
430 } |
463 |
431 |
464 // This is the central handler for device attachment. |
432 // This is the central handler for device attachment. |
465 // We deal with device attachments in two phases. |
433 // We deal with device attachments in two phases. |
466 // The first phase is confusingly called device attachment. |
434 // The first phase is confusingly called device attachment. |
467 // The second phase is driver loading. |
435 // The second phase is driver loading. |
468 void CFdf::HandleDeviceAttachment(TUint aDeviceId) |
436 void CFdf::HandleDeviceAttachment(TUint aDeviceId) |
469 { |
437 { |
470 OstTraceFunctionEntry0( CFDF_HANDLEDEVICEATTACHMENT_ENTRY ); |
438 LOG_FUNC |
471 // This is filled in by HandleDeviceAttachmentL on success. |
439 // This is filled in by HandleDeviceAttachmentL on success. |
472 CDeviceProxy* device; |
440 CDeviceProxy* device; |
473 TRAPD(err, HandleDeviceAttachmentL(aDeviceId, device)); |
441 TRAPD(err, HandleDeviceAttachmentL(aDeviceId, device)); |
474 if ( err ) |
442 if ( err ) |
475 { |
443 { |
476 OstTrace1( TRACE_NORMAL, CFDF_HANDLEDEVICEATTACHMENT, "err = %d", err ); |
444 LOGTEXT2(_L8("\terr = %d"), err); |
477 // There was an attachment failure, so we just increment the count of |
445 // There was an attachment failure, so we just increment the count of |
478 // attachment failures. |
446 // attachment failures. |
479 if(!iEventQueue) |
447 ASSERT_DEBUG(iEventQueue); |
480 { |
|
481 OstTrace0( TRACE_FATAL, CFDF_HANDLEDEVICEATTACHMENT_DUP1, "Empty iEventQueue" ); |
|
482 __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); |
|
483 } |
|
484 |
|
485 iEventQueue->AttachmentFailure(err); |
448 iEventQueue->AttachmentFailure(err); |
486 // If we failed the attachment phase, we can't try to load drivers for |
449 // If we failed the attachment phase, we can't try to load drivers for |
487 // the device. |
450 // the device. |
488 |
451 |
489 } |
452 } |
491 { |
454 { |
492 // This function always moves the 'driver loading' event from the |
455 // This function always moves the 'driver loading' event from the |
493 // device proxy created by HandleDeviceAttachmentL to the event queue. |
456 // device proxy created by HandleDeviceAttachmentL to the event queue. |
494 // This event object is always populated with the correct status and |
457 // This event object is always populated with the correct status and |
495 // error. |
458 // error. |
496 if(!device) |
459 ASSERT_DEBUG(device); |
497 { |
|
498 OstTrace0( TRACE_FATAL, CFDF_HANDLEDEVICEATTACHMENT_DUP2, "Empty device" ); |
|
499 __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); |
|
500 } |
|
501 |
|
502 DoDriverLoading(*device); |
460 DoDriverLoading(*device); |
503 } |
461 } |
504 |
462 |
505 // Finally, clean up the collection of information on the device's |
463 // Finally, clean up the collection of information on the device's |
506 // interfaces which was populated (maybe only partly) in |
464 // interfaces which was populated (maybe only partly) in |
507 // HandleDeviceAttachmentL. |
465 // HandleDeviceAttachmentL. |
508 iCurrentDevice = NULL; |
466 iCurrentDevice = NULL; |
509 iInterfaces.ResetAndDestroy(); |
467 iInterfaces.ResetAndDestroy(); |
510 OstTraceFunctionExit0( CFDF_HANDLEDEVICEATTACHMENT_EXIT ); |
|
511 } |
468 } |
512 |
469 |
513 // This does the 'device attachment' phase of the new device attachment only. |
470 // This does the 'device attachment' phase of the new device attachment only. |
514 void CFdf::HandleDeviceAttachmentL(TUint aDeviceId, CDeviceProxy*& aDevice) |
471 void CFdf::HandleDeviceAttachmentL(TUint aDeviceId, CDeviceProxy*& aDevice) |
515 { |
472 { |
516 OstTraceFunctionEntry0( CFDF_HANDLEDEVICEATTACHMENTL_ENTRY ); |
473 LOG_FUNC |
|
474 |
517 // Create the device proxy |
475 // Create the device proxy |
518 aDevice = CDeviceProxy::NewL(iHubDriver, aDeviceId); |
476 aDevice = CDeviceProxy::NewL(iHubDriver, aDeviceId); |
519 CleanupStack::PushL(aDevice); |
477 CleanupStack::PushL(aDevice); |
520 iCurrentDevice = aDevice; |
478 iCurrentDevice = aDevice; |
521 // Get necessary descriptors (for this phase) |
479 // Get necessary descriptors (for this phase) |
522 TInt err=aDevice->GetDeviceDescriptor(iDD); |
480 LEAVEIFERRORL(aDevice->GetDeviceDescriptor(iDD)); |
523 if (err<0) |
481 LOGTEXT2(_L8("\tiDD.USBBcd = 0x%04x"), iDD.USBBcd()); |
524 { |
482 LOGTEXT2(_L8("\tiDD.DeviceClass = 0x%02x"), iDD.DeviceClass()); |
525 OstTrace1( TRACE_NORMAL, CFDF_HANDLEDEVICEATTACHMENTL, "GetDeviceDescriptor error=%d", err ); |
483 LOGTEXT2(_L8("\tiDD.DeviceSubClass = 0x%02x"), iDD.DeviceSubClass()); |
526 User::Leave(err); |
484 LOGTEXT2(_L8("\tiDD.DeviceProtocol = 0x%02x"), iDD.DeviceProtocol()); |
527 } |
485 LOGTEXT2(_L8("\tiDD.MaxPacketSize0 = %d"), iDD.MaxPacketSize0()); |
528 |
486 LOGTEXT2(_L8("\tiDD.VendorId = 0x%04x"), iDD.VendorId()); |
529 OstTrace1( TRACE_DUMP, CFDF_HANDLEDEVICEATTACHMENTL_DUP1, "iDD.USBBcd = 0x%04x", iDD.USBBcd() ); |
487 LOGTEXT2(_L8("\tiDD.ProductId = 0x%04x"), iDD.ProductId()); |
530 OstTrace1( TRACE_DUMP, CFDF_HANDLEDEVICEATTACHMENTL_DUP2, "iDD.DeviceClass = 0x%02x", iDD.DeviceClass() ); |
488 LOGTEXT2(_L8("\tiDD.DeviceBcd = 0x%04x"), iDD.DeviceBcd()); |
531 OstTrace1( TRACE_DUMP, CFDF_HANDLEDEVICEATTACHMENTL_DUP3, "iDD.DeviceSubClass = 0x%02x", iDD.DeviceSubClass() ); |
489 LOGTEXT2(_L8("\tiDD.ManufacturerIndex = %d"), iDD.ManufacturerIndex()); |
532 OstTrace1( TRACE_DUMP, CFDF_HANDLEDEVICEATTACHMENTL_DUP4, "iDD.DeviceProtocol = 0x%02x", iDD.DeviceProtocol() ); |
490 LOGTEXT2(_L8("\tiDD.ProductIndex = %d"), iDD.ProductIndex()); |
533 OstTrace1( TRACE_DUMP, CFDF_HANDLEDEVICEATTACHMENTL_DUP5, "iDD.MaxPacketSize0 = %d", iDD.MaxPacketSize0() ); |
491 LOGTEXT2(_L8("\tiDD.SerialNumberIndex = %d"), iDD.SerialNumberIndex()); |
534 OstTrace1( TRACE_DUMP, CFDF_HANDLEDEVICEATTACHMENTL_DUP6, "iDD.VendorId = 0x%04x", iDD.VendorId() ); |
492 LOGTEXT2(_L8("\tiDD.NumConfigurations = %d"), iDD.NumConfigurations()); |
535 OstTrace1( TRACE_DUMP, CFDF_HANDLEDEVICEATTACHMENTL_DUP7, "iDD.ProductId = 0x%04x", iDD.ProductId() ); |
493 LEAVEIFERRORL(aDevice->GetConfigurationDescriptor(iCD)); |
536 OstTrace1( TRACE_DUMP, CFDF_HANDLEDEVICEATTACHMENTL_DUP8, "iDD.DeviceBcd = 0x%04x", iDD.DeviceBcd() ); |
494 LOGTEXT2(_L8("\tiCD.TotalLength = %d"), iCD.TotalLength()); |
537 OstTrace1( TRACE_DUMP, CFDF_HANDLEDEVICEATTACHMENTL_DUP9, "iDD.ManufacturerIndex = %d", iDD.ManufacturerIndex() ); |
495 LOGTEXT2(_L8("\tiCD.NumInterfaces = %d"), iCD.NumInterfaces()); |
538 OstTrace1( TRACE_DUMP, CFDF_HANDLEDEVICEATTACHMENTL_DUP10, "iDD.ProductIndex = %d", iDD.ProductIndex() ); |
496 LOGTEXT2(_L8("\tiCD.ConfigurationValue = %d"), iCD.ConfigurationValue()); |
539 OstTrace1( TRACE_DUMP, CFDF_HANDLEDEVICEATTACHMENTL_DUP11, "iDD.SerialNumberIndex = %d", iDD.SerialNumberIndex() ); |
497 LOGTEXT2(_L8("\tiCD.ConfigurationIndex = %d"), iCD.ConfigurationIndex()); |
540 OstTrace1( TRACE_DUMP, CFDF_HANDLEDEVICEATTACHMENTL_DUP12, "iDD.NumConfigurations = %d", iDD.NumConfigurations() ); |
498 LOGTEXT2(_L8("\tiCD.Attributes = %d"), iCD.Attributes()); |
541 err=aDevice->GetConfigurationDescriptor(iCD); |
499 LOGTEXT2(_L8("\tiCD.MaxPower = %d"), iCD.MaxPower()); |
542 if(err<0) |
500 |
543 { |
|
544 OstTrace1( TRACE_NORMAL, CFDF_HANDLEDEVICEATTACHMENTL_DUP13, "GetConfigurationDescriptor error=%d", err); |
|
545 User::Leave(err); |
|
546 } |
|
547 |
|
548 OstTrace1( TRACE_DUMP, CFDF_HANDLEDEVICEATTACHMENTL_DUP14, "iCD.TotalLength = %d", iCD.TotalLength() ); |
|
549 OstTrace1( TRACE_DUMP, CFDF_HANDLEDEVICEATTACHMENTL_DUP15, "iCD.NumInterfaces = %d", iCD.NumInterfaces() ); |
|
550 OstTrace1( TRACE_DUMP, CFDF_HANDLEDEVICEATTACHMENTL_DUP16, "iCD.ConfigurationValue = %d", iCD.ConfigurationValue() ); |
|
551 OstTrace1( TRACE_DUMP, CFDF_HANDLEDEVICEATTACHMENTL_DUP17, "iCD.ConfigurationIndex = %d", iCD.ConfigurationIndex() ); |
|
552 OstTrace1( TRACE_DUMP, CFDF_HANDLEDEVICEATTACHMENTL_DUP18, "iCD.Attributes = %d", iCD.Attributes() ); |
|
553 OstTrace1( TRACE_DUMP, CFDF_HANDLEDEVICEATTACHMENTL_DUP19, "iCD.MaxPower = %d", iCD.MaxPower() ); |
|
554 |
|
555 const TUint8 numberOfInterfaces = iCD.NumInterfaces(); |
501 const TUint8 numberOfInterfaces = iCD.NumInterfaces(); |
556 OstTrace1( TRACE_DUMP, CFDF_HANDLEDEVICEATTACHMENTL_DUP20, "numberOfInterfaces (field in config descriptor) = %d)", numberOfInterfaces ); |
502 LOGTEXT2(_L8("\tnumberOfInterfaces (field in config descriptor) = %d)"), numberOfInterfaces); |
557 if ( numberOfInterfaces == 0 ) |
503 if ( numberOfInterfaces == 0 ) |
558 { |
504 { |
559 OstTrace0( TRACE_NORMAL, CFDF_HANDLEDEVICEATTACHMENTL_DUP21, "Error: Usb Configuration Has No Interfaces"); |
505 LEAVEL(KErrUsbConfigurationHasNoInterfaces); |
560 User::Leave(KErrUsbConfigurationHasNoInterfaces); |
|
561 } |
506 } |
562 |
507 |
563 // Walk the configuration bundle. Collect information on each interface |
508 // Walk the configuration bundle. Collect information on each interface |
564 // (its number, class, subclass and protocol). This populates iInterfaces. |
509 // (its number, class, subclass and protocol). This populates iInterfaces. |
565 if(!(iInterfaces.Count() == 0)) |
510 ASSERT_DEBUG(iInterfaces.Count() == 0); |
566 { |
511 ASSERT_ALWAYS(iCurrentDevice); |
567 OstTrace0( TRACE_FATAL, CFDF_HANDLEDEVICEATTACHMENTL_DUP22, "Error: Usb Configuration Has No Interfaces"); |
|
568 __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); |
|
569 } |
|
570 |
|
571 if(!iCurrentDevice) |
|
572 { |
|
573 OstTrace0( TRACE_FATAL, CFDF_HANDLEDEVICEATTACHMENTL_DUP23, "Empty iCurrentDevice"); |
|
574 User::Panic(KPanicCategory,__LINE__); |
|
575 } |
|
576 |
|
577 ParseL(iCD); |
512 ParseL(iCD); |
578 |
513 |
579 // Log iInterfaces. |
514 // Log iInterfaces. |
580 const TUint interfaceCount = iInterfaces.Count(); |
515 const TUint interfaceCount = iInterfaces.Count(); |
581 OstTrace1( TRACE_DUMP, CFDF_HANDLEDEVICEATTACHMENTL_DUP24, "interfaceCount (parsed from bundle) = %d", interfaceCount ); |
516 LOGTEXT2(_L8("\tinterfaceCount (parsed from bundle) = %d"), interfaceCount); |
582 #ifdef _DEBUG |
517 #ifdef __FLOG_ACTIVE |
583 OstTrace0( TRACE_DUMP, CFDF_HANDLEDEVICEATTACHMENTL_DUP25, "Logging iInterfaces:"); |
518 LOGTEXT(_L8("\tLogging iInterfaces:")); |
584 for ( TUint ii = 0 ; ii < interfaceCount ; ++ii ) |
519 for ( TUint ii = 0 ; ii < interfaceCount ; ++ii ) |
585 { |
520 { |
586 const TInterfaceInfo* ifInfo = iInterfaces[ii]; |
521 const TInterfaceInfo* ifInfo = iInterfaces[ii]; |
587 if(!ifInfo) |
522 ASSERT_DEBUG(ifInfo); |
588 { |
523 LOGTEXT6(_L8("\t\tiInterfaces[%d]: number %d, interface class 0x%02x subclass 0x%02x protocol 0x%02x"), |
589 OstTrace0( TRACE_FATAL, CFDF_HANDLEDEVICEATTACHMENTL_DUP26, "Empty ifInfo"); |
|
590 __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); |
|
591 } |
|
592 |
|
593 OstTraceExt5(TRACE_DUMP, CFDF_HANDLEDEVICEATTACHMENTL_DUP27, "\t\tiInterfaces[%d]: number %d, interface class 0x%02x subclass 0x%02x protocol 0x%02x", |
|
594 ii, |
524 ii, |
595 ifInfo->iNumber, |
525 ifInfo->iNumber, |
596 ifInfo->iClass, |
526 ifInfo->iClass, |
597 ifInfo->iSubclass, |
527 ifInfo->iSubclass, |
598 ifInfo->iProtocol |
528 ifInfo->iProtocol |
599 ); |
529 ); |
600 } |
530 } |
601 #endif |
531 #endif |
602 |
532 |
603 // Check that the config's NumInterfaces is the same as the actual number |
533 // Check that the config's NumInterfaces is the same as the actual number |
604 // of interface descriptors we found. We rely on this later on. |
534 // of interface descriptors we found. We rely on this later on. |
605 if ( numberOfInterfaces != interfaceCount ) |
535 if ( numberOfInterfaces != interfaceCount ) |
606 { |
536 { |
607 OstTrace0( TRACE_NORMAL, CFDF_HANDLEDEVICEATTACHMENTL_DUP28, "KErrUsbInterfaceCountMismatch"); |
537 LEAVEL(KErrUsbInterfaceCountMismatch); |
608 User::Leave(KErrUsbInterfaceCountMismatch); |
|
609 } |
538 } |
610 |
539 |
611 // Check that each interface number in iInterfaces is unique. |
540 // Check that each interface number in iInterfaces is unique. |
612 if ( interfaceCount > 1 ) |
541 if ( interfaceCount > 1 ) |
613 { |
542 { |
614 for ( TUint ii = 0 ; ii < interfaceCount ; ++ii ) |
543 for ( TUint ii = 0 ; ii < interfaceCount ; ++ii ) |
615 { |
544 { |
616 const TInterfaceInfo* lhs = iInterfaces[ii]; |
545 const TInterfaceInfo* lhs = iInterfaces[ii]; |
617 if(!lhs) |
546 ASSERT_DEBUG(lhs); |
618 { |
|
619 OstTrace0( TRACE_FATAL, CFDF_HANDLEDEVICEATTACHMENTL_DUP29, "Empty lhs"); |
|
620 __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); |
|
621 } |
|
622 |
|
623 for ( TUint jj = ii+1 ; jj < interfaceCount ; ++jj ) |
547 for ( TUint jj = ii+1 ; jj < interfaceCount ; ++jj ) |
624 { |
548 { |
625 const TInterfaceInfo* rhs = iInterfaces[jj]; |
549 const TInterfaceInfo* rhs = iInterfaces[jj]; |
626 if(!rhs) |
550 ASSERT_DEBUG(rhs); |
627 { |
|
628 OstTrace0( TRACE_FATAL, CFDF_HANDLEDEVICEATTACHMENTL_DUP30, "Empty rhs"); |
|
629 __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); |
|
630 } |
|
631 |
|
632 if ( lhs->iNumber == rhs->iNumber ) |
551 if ( lhs->iNumber == rhs->iNumber ) |
633 { |
552 { |
634 OstTrace1( TRACE_NORMAL, CFDF_HANDLEDEVICEATTACHMENTL_DUP31, "KErrUsbDuplicateInterfaceNumbers; iNumber=%d", lhs->iNumber); |
553 LEAVEL(KErrUsbDuplicateInterfaceNumbers); |
635 User::Leave(KErrUsbDuplicateInterfaceNumbers); |
|
636 } |
554 } |
637 } |
555 } |
638 } |
556 } |
639 } |
557 } |
640 |
558 |
644 if (iDevices.IsEmpty()) |
562 if (iDevices.IsEmpty()) |
645 { |
563 { |
646 TInt err = User::LoadLogicalDevice(KDriverUsbdiLddFileName); |
564 TInt err = User::LoadLogicalDevice(KDriverUsbdiLddFileName); |
647 if ( err != KErrAlreadyExists ) |
565 if ( err != KErrAlreadyExists ) |
648 { |
566 { |
649 LEAVEIFERRORL(err,OstTrace1( TRACE_NORMAL, CFDF_HANDLEDEVICEATTACHMENTL_DUP32, "Load Logical Device error; error=%d", err);); |
567 LEAVEIFERRORL(err); |
650 } |
568 } |
651 } |
569 } |
652 #endif // __OVER_DUMMYUSBDI__ |
570 #endif // __OVER_DUMMYUSBDI__ |
653 |
571 |
654 // Now we know we've succeeded with a device attachment, remove the device |
572 // Now we know we've succeeded with a device attachment, remove the device |
655 // proxy from the cleanup stack and put it on the TSglQue. |
573 // proxy from the cleanup stack and put it on the TSglQue. |
656 CLEANUPSTACK_POP1(aDevice); |
574 CLEANUPSTACK_POP1(aDevice); |
657 iDevices.AddLast(*aDevice); |
575 iDevices.AddLast(*aDevice); |
658 // Also put an event on the event queue. |
576 // Also put an event on the event queue. |
659 TDeviceEvent* const attachmentEvent = aDevice->GetAttachmentEventObject(); |
577 TDeviceEvent* const attachmentEvent = aDevice->GetAttachmentEventObject(); |
660 |
578 ASSERT_DEBUG(attachmentEvent); |
661 if(!attachmentEvent) |
|
662 { |
|
663 OstTrace0( TRACE_FATAL, CFDF_HANDLEDEVICEATTACHMENTL_DUP33, "Empty attachmentEvent"); |
|
664 __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); |
|
665 } |
|
666 |
|
667 attachmentEvent->iInfo.iVid = iDD.VendorId(); |
579 attachmentEvent->iInfo.iVid = iDD.VendorId(); |
668 attachmentEvent->iInfo.iPid = iDD.ProductId(); |
580 attachmentEvent->iInfo.iPid = iDD.ProductId(); |
669 attachmentEvent->iInfo.iError = KErrNone; |
581 attachmentEvent->iInfo.iError = KErrNone; |
670 if(!iEventQueue) |
582 ASSERT_DEBUG(iEventQueue); |
671 { |
|
672 OstTrace0( TRACE_FATAL, CFDF_HANDLEDEVICEATTACHMENTL_DUP34, "Empty iEventQueue"); |
|
673 __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); |
|
674 } |
|
675 |
|
676 iEventQueue->AddDeviceEvent(*attachmentEvent); |
583 iEventQueue->AddDeviceEvent(*attachmentEvent); |
677 OstTrace1( TRACE_DUMP, CFDF_HANDLEDEVICEATTACHMENTL_DUP35, "***USB HOST STACK: SUCCESSFUL ATTACHMENT OF DEVICE (id %d)", aDeviceId ); |
584 LOGTEXT2(_L8("***USB HOST STACK: SUCCESSFUL ATTACHMENT OF DEVICE (id %d)"), aDeviceId); |
678 |
|
679 OstTraceFunctionExit0( CFDF_HANDLEDEVICEATTACHMENTL_EXIT ); |
|
680 } |
585 } |
681 |
586 |
682 void CFdf::DoDriverLoading(CDeviceProxy& aDevice) |
587 void CFdf::DoDriverLoading(CDeviceProxy& aDevice) |
683 { |
588 { |
684 OstTraceFunctionEntry0( CFDF_DODRIVERLOADING_ENTRY ); |
589 LOG_FUNC |
|
590 |
685 // Leaving or returning from DoDriverLoadingL is the trigger to put the |
591 // Leaving or returning from DoDriverLoadingL is the trigger to put the |
686 // 'driver loading' event object on the event queue. It must already have |
592 // 'driver loading' event object on the event queue. It must already have |
687 // been populated correctly (the actual error code it left with doesn't |
593 // been populated correctly (the actual error code it left with doesn't |
688 // feed into the driver loading event). |
594 // feed into the driver loading event). |
689 TRAP_IGNORE(DoDriverLoadingL(aDevice)); |
595 TRAP_IGNORE(DoDriverLoadingL(aDevice)); |
690 |
596 |
691 TDeviceEvent* const driverLoadingEvent = aDevice.GetDriverLoadingEventObject(); |
597 TDeviceEvent* const driverLoadingEvent = aDevice.GetDriverLoadingEventObject(); |
692 if(!driverLoadingEvent) |
598 ASSERT_DEBUG(driverLoadingEvent); |
693 { |
|
694 OstTrace0( TRACE_FATAL, CFDF_DODRIVERLOADING, "Empty driverLoadingEvent" ); |
|
695 __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); |
|
696 } |
|
697 |
|
698 // The driver loading event object says whether driver loading succeeded |
599 // The driver loading event object says whether driver loading succeeded |
699 // (all interfaces were claimed without error), partly succeeded (not all |
600 // (all interfaces were claimed without error), partly succeeded (not all |
700 // interfaces were claimed without error), or failed (no interfaces were |
601 // interfaces were claimed without error), or failed (no interfaces were |
701 // claimed without error). This information is intended for USBMAN so it |
602 // claimed without error). This information is intended for USBMAN so it |
702 // can tell the user, but we also use it now to suspend the device if |
603 // can tell the user, but we also use it now to suspend the device if |
772 // (a) are there any unclaimed interfaces remaining? |
665 // (a) are there any unclaimed interfaces remaining? |
773 // (b) what's in collectedErr? |
666 // (b) what's in collectedErr? |
774 // Whether all interfaces were taken, some, or none, collectedErr may have |
667 // Whether all interfaces were taken, some, or none, collectedErr may have |
775 // an error in it or KErrNone. We use specific error codes in some cases. |
668 // an error in it or KErrNone. We use specific error codes in some cases. |
776 TUint unclaimedInterfaces = UnclaimedInterfaceCount(); |
669 TUint unclaimedInterfaces = UnclaimedInterfaceCount(); |
777 OstTrace1( TRACE_DUMP, CFDF_DODRIVERLOADINGL_DUP2, "unclaimedInterfaces = %d", unclaimedInterfaces ); |
670 LOGTEXT2(_L8("\tunclaimedInterfaces = %d"), unclaimedInterfaces); |
778 OstTrace1( TRACE_DUMP, CFDF_DODRIVERLOADINGL_DUP3, "anySuccess = %d", anySuccess ); |
671 LOGTEXT2(_L8("\tanySuccess = %d"), anySuccess); |
779 OstTrace1( TRACE_DUMP, CFDF_DODRIVERLOADINGL_DUP4, "collectedErr = %d", collectedErr ); |
672 LOGTEXT2(_L8("\tcollectedErr = %d"), collectedErr); |
780 if(!(unclaimedInterfaces <= interfaceCount)) |
673 ASSERT_DEBUG(unclaimedInterfaces <= interfaceCount); |
781 { |
|
782 OstTrace0( TRACE_FATAL, CFDF_DODRIVERLOADINGL_DUP5, "interface Count error" ); |
|
783 __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); |
|
784 } |
|
785 |
|
786 |
674 |
787 if(iDeviceDetachedTooEarly) |
675 if(iDeviceDetachedTooEarly) |
788 { |
676 { |
789 OstTrace0( TRACE_NORMAL, CFDF_DODRIVERLOADINGL_DUP6, "Device has been detached too early!" ); |
677 LOGTEXT(_L8("\tDevice has been detached too early!")); |
790 iDeviceDetachedTooEarly = EFalse; |
678 iDeviceDetachedTooEarly = EFalse; |
791 // the choice of having the status to be EDriverLoadPartialSuccess |
679 // the choice of having the status to be EDriverLoadPartialSuccess |
792 // was not to clash with trying to suspend the device because |
680 // was not to clash with trying to suspend the device because |
793 // of a total failure to load the FD.(because device is detached) |
681 // of a total failure to load the FD.(because device is detached) |
794 // even though that a FDC has been created |
682 // even though that a FDC has been created |
800 else |
688 else |
801 { |
689 { |
802 SetFailureStatus(unclaimedInterfaces, interfaceCount, anySuccess, collectedErr, aDevice); |
690 SetFailureStatus(unclaimedInterfaces, interfaceCount, anySuccess, collectedErr, aDevice); |
803 }// iDeviceDetachedTooEarly |
691 }// iDeviceDetachedTooEarly |
804 |
692 |
805 OstTraceFunctionExit0( CFDF_DODRIVERLOADINGL_EXIT ); |
|
806 } |
693 } |
807 |
694 |
808 // Recursive function, originally called with the configuration descriptor. |
695 // Recursive function, originally called with the configuration descriptor. |
809 // Builds up information on the interface descriptors in the configuration |
696 // Builds up information on the interface descriptors in the configuration |
810 // bundle. |
697 // bundle. |
811 void CFdf::ParseL(TUsbGenericDescriptor& aDesc) |
698 void CFdf::ParseL(TUsbGenericDescriptor& aDesc) |
812 { |
699 { |
813 OstTraceFunctionEntry0( CFDF_PARSEL_ENTRY ); |
700 LOG_FUNC |
814 OstTrace1( TRACE_DUMP, CFDF_PARSEL, "&aDesc = 0x%08x", &aDesc ); |
701 LOGTEXT2(_L8("\t&aDesc = 0x%08x"), &aDesc); |
815 OstTrace1( TRACE_DUMP, CFDF_PARSEL_DUP1, "aDesc.ibDescriptorType = %d", aDesc.ibDescriptorType ); |
702 LOGTEXT2(_L8("\taDesc.ibDescriptorType = %d"), aDesc.ibDescriptorType); |
816 OstTrace1( TRACE_DUMP, CFDF_PARSEL_DUP2, "aDesc.iFirstChild = 0x%08x", aDesc.iFirstChild ); |
703 LOGTEXT2(_L8("\taDesc.iFirstChild = 0x%08x"), aDesc.iFirstChild); |
817 OstTrace1( TRACE_DUMP, CFDF_PARSEL_DUP3, "aDesc.iNextPeer = 0x%08x", aDesc.iNextPeer ); |
704 LOGTEXT2(_L8("\taDesc.iNextPeer = 0x%08x"), aDesc.iNextPeer); |
818 |
705 |
819 if ( aDesc.ibDescriptorType == EInterface ) |
706 if ( aDesc.ibDescriptorType == EInterface ) |
820 { |
707 { |
821 // Add interface information to collection, but only if it's alternate |
708 // Add interface information to collection, but only if it's alternate |
822 // setting 0. |
709 // setting 0. |
823 const TUsbInterfaceDescriptor& ifDesc = static_cast<TUsbInterfaceDescriptor&>(aDesc); |
710 const TUsbInterfaceDescriptor& ifDesc = static_cast<TUsbInterfaceDescriptor&>(aDesc); |
824 if ( ifDesc.AlternateSetting() == 0 ) // hard-coded '0' means the default (initial configuration) setting |
711 if ( ifDesc.AlternateSetting() == 0 ) // hard-coded '0' means the default (initial configuration) setting |
825 { |
712 { |
826 OstTrace1( TRACE_DUMP, CFDF_PARSEL_DUP4, "ifDesc.InterfaceNumber = %d", ifDesc.InterfaceNumber() ); |
713 LOGTEXT2(_L8("\tifDesc.InterfaceNumber = %d"), ifDesc.InterfaceNumber()); |
827 OstTrace1( TRACE_DUMP, CFDF_PARSEL_DUP5, "ifDesc.NumEndpoints = %d", ifDesc.NumEndpoints() ); |
714 LOGTEXT2(_L8("\tifDesc.NumEndpoints = %d"), ifDesc.NumEndpoints()); |
828 OstTrace1( TRACE_DUMP, CFDF_PARSEL_DUP6, "ifDesc.InterfaceClass = 0x%02x", ifDesc.InterfaceClass() ); |
715 LOGTEXT2(_L8("\tifDesc.InterfaceClass = 0x%02x"), ifDesc.InterfaceClass()); |
829 OstTrace1( TRACE_DUMP, CFDF_PARSEL_DUP7, "ifDesc.InterfaceSubClass = 0x%02x", ifDesc.InterfaceSubClass() ); |
716 LOGTEXT2(_L8("\tifDesc.InterfaceSubClass = 0x%02x"), ifDesc.InterfaceSubClass()); |
830 OstTrace1( TRACE_DUMP, CFDF_PARSEL_DUP8, "ifDesc.InterfaceProtocol = 0x%02x", ifDesc.InterfaceProtocol() ); |
717 LOGTEXT2(_L8("\tifDesc.InterfaceProtocol = 0x%02x"), ifDesc.InterfaceProtocol()); |
831 OstTrace1( TRACE_DUMP, CFDF_PARSEL_DUP9, "ifDesc.Interface = %d", ifDesc.Interface() ); |
718 LOGTEXT2(_L8("\tifDesc.Interface = %d"), ifDesc.Interface()); |
832 |
719 |
833 TInterfaceInfo* ifInfo = TInterfaceInfo::NewL(iInterfaces); |
720 TInterfaceInfo* ifInfo = TInterfaceInfo::NewL(iInterfaces); |
834 ifInfo->iNumber = ifDesc.InterfaceNumber(); |
721 ifInfo->iNumber = ifDesc.InterfaceNumber(); |
835 ifInfo->iClass = ifDesc.InterfaceClass(); |
722 ifInfo->iClass = ifDesc.InterfaceClass(); |
836 ifInfo->iSubclass = ifDesc.InterfaceSubClass(); |
723 ifInfo->iSubclass = ifDesc.InterfaceSubClass(); |
837 ifInfo->iProtocol = ifDesc.InterfaceProtocol(); |
724 ifInfo->iProtocol = ifDesc.InterfaceProtocol(); |
961 // suitable FDC we found so fa. |
844 // suitable FDC we found so fa. |
962 if (!aDevice.MultipleDriversFlag() && FindMultipleFDs(aSearchKey, iter)) |
845 if (!aDevice.MultipleDriversFlag() && FindMultipleFDs(aSearchKey, iter)) |
963 { |
846 { |
964 aDevice.SetMultipleDriversFlag(); |
847 aDevice.SetMultipleDriversFlag(); |
965 } |
848 } |
966 OstTrace1( TRACE_NORMAL, CFDF_FINDDRIVERFORINTERFACEUSINGSPECIFICKEY_DUP2, "found matching FDC (0x%08x)", fdc ); |
849 |
967 |
850 LOGTEXT2(_L8("\tfound matching FDC (0x%08x)"), fdc); |
|
851 #ifdef __FLOG_ACTIVE |
968 const TUint count = aInterfacesGivenToFdc.Count(); |
852 const TUint count = aInterfacesGivenToFdc.Count(); |
969 OstTrace1( TRACE_NORMAL, CFDF_FINDDRIVERFORINTERFACEUSINGSPECIFICKEY_DUP3, "logging aInterfacesGivenToFdc (interfaces being offered to the FDC): count = %d", count ); |
853 LOGTEXT2(_L8("\tlogging aInterfacesGivenToFdc (interfaces being offered to the FDC): count = %d"), count); |
970 for ( TUint ii = 0 ; ii < count ; ++ii ) |
854 for ( TUint ii = 0 ; ii < count ; ++ii ) |
971 { |
855 { |
972 OstTraceExt2( TRACE_NORMAL, CFDF_FINDDRIVERFORINTERFACEUSINGSPECIFICKEY_DUP4, |
856 LOGTEXT3(_L8("\t\tindex %d: interface number %d"), ii, aInterfacesGivenToFdc[ii]); |
973 "index %u: interface number %u", |
857 } |
974 ii, aInterfacesGivenToFdc[ii] ); |
858 #endif |
975 } |
|
976 TInt err = fdc->NewFunction(aDevice.DeviceId(), aInterfacesGivenToFdc, iDD, iCD); |
859 TInt err = fdc->NewFunction(aDevice.DeviceId(), aInterfacesGivenToFdc, iDD, iCD); |
977 OstTrace1( TRACE_NORMAL, CFDF_FINDDRIVERFORINTERFACEUSINGSPECIFICKEY_DUP5, "NewFunction returned %d", err ); |
860 LOGTEXT2(_L8("\tNewFunction returned %d"), err); |
978 |
|
979 // To correctly determine whether the driver load for the whole |
861 // To correctly determine whether the driver load for the whole |
980 // configuration was a complete failure, a partial success or a |
862 // configuration was a complete failure, a partial success or a |
981 // complete success, we need to collect any non-KErrNone error |
863 // complete success, we need to collect any non-KErrNone error |
982 // from this, and whether any handovers worked at all. |
864 // from this, and whether any handovers worked at all. |
983 if ( err == KErrNone ) |
865 if ( err == KErrNone ) |
984 { |
866 { |
985 OstTraceExt2(TRACE_NORMAL, CFDF_FINDDRIVERFORINTERFACEUSINGSPECIFICKEY_DUP6, |
867 #ifdef __FLOG_ACTIVE |
986 "***USB HOST STACK: THE FOLLOWING INTERFACES OF DEVICE %u WERE SUCCESSFULLY PASSED TO FUNCTION DRIVER WITH IMPL UID 0x%08x", |
868 LOGTEXT3(_L8("***USB HOST STACK: THE FOLLOWING INTERFACES OF DEVICE %d WERE SUCCESSFULLY PASSED TO FUNCTION DRIVER WITH IMPL UID 0x%08x"), |
987 (TInt32) aDevice.DeviceId(), fdc->ImplUid().iUid); |
869 aDevice.DeviceId(), fdc->ImplUid()); |
988 // We want to log each interface that's in |
870 // We want to log each interface that's in |
989 // aInterfacesGivenToFdc AND is marked claimed in iInterfaces. |
871 // aInterfacesGivenToFdc AND is marked claimed in iInterfaces. |
990 for ( TUint ii = 0 ; ii < aInterfacesGivenToFdc.Count() ; ++ii ) |
872 for ( TUint ii = 0 ; ii < aInterfacesGivenToFdc.Count() ; ++ii ) |
991 { |
873 { |
992 const TUint ifNum = aInterfacesGivenToFdc[ii]; |
874 const TUint ifNum = aInterfacesGivenToFdc[ii]; |
993 for ( TUint jj = 0 ; jj < iInterfaces.Count() ; ++jj ) |
875 for ( TUint jj = 0 ; jj < iInterfaces.Count() ; ++jj ) |
994 { |
876 { |
995 const TInterfaceInfo* ifInfo = iInterfaces[jj]; |
877 const TInterfaceInfo* ifInfo = iInterfaces[jj]; |
996 |
878 ASSERT_DEBUG(ifInfo); |
997 if(!ifInfo) |
|
998 { |
|
999 OstTrace0( TRACE_FATAL, CFDF_FINDDRIVERFORINTERFACEUSINGSPECIFICKEY_DUP7, "Empty ifInfo" ); |
|
1000 __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); |
|
1001 } |
|
1002 if ( ifNum == ifInfo->iNumber |
879 if ( ifNum == ifInfo->iNumber |
1003 && ifInfo->iClaimed |
880 && ifInfo->iClaimed |
1004 ) |
881 ) |
1005 { |
882 { |
1006 OstTrace1( TRACE_NORMAL, CFDF_FINDDRIVERFORINTERFACEUSINGSPECIFICKEY_DUP8, "***USB HOST STACK: bInterfaceNumber %d", ifNum ); |
883 LOGTEXT2(_L8("***USB HOST STACK: bInterfaceNumber %d"), ifNum); |
1007 } |
884 } |
1008 } |
885 } |
1009 } |
886 } |
|
887 #endif |
1010 aAnySuccess = ETrue; |
888 aAnySuccess = ETrue; |
1011 } |
889 } |
1012 else |
890 else |
1013 { |
891 { |
1014 aCollectedErr = err; |
892 aCollectedErr = err; |
1015 } |
893 } |
1016 // We found a matching FDC for this interface- no need to look for more. |
894 // We found a matching FDC for this interface- no need to look for more. |
1017 break; |
895 break; |
1018 } |
896 } |
1019 } |
897 } |
1020 OstTraceFunctionExit0( CFDF_FINDDRIVERFORINTERFACEUSINGSPECIFICKEY_EXIT ); |
|
1021 } |
898 } |
1022 |
899 |
1023 void CFdf::HandleDeviceDetachment(TUint aDeviceId) |
900 void CFdf::HandleDeviceDetachment(TUint aDeviceId) |
1024 { |
901 { |
1025 OstTraceFunctionEntry0( CFDF_HANDLEDEVICEDETACHMENT_ENTRY ); |
902 LOG_FUNC |
1026 OstTrace1( TRACE_NORMAL, CFDF_HANDLEDEVICEDETACHMENT, "aDeviceId = %d", aDeviceId ); |
903 LOGTEXT2(_L8("\taDeviceId = %d"), aDeviceId); |
|
904 |
1027 |
905 |
1028 #ifdef _DEBUG |
906 #ifdef _DEBUG |
1029 TBool found = EFalse; |
907 TBool found = EFalse; |
1030 #endif |
908 #endif |
1031 // Find the relevant device proxy. If there isn't one, just drop the |
909 // Find the relevant device proxy. If there isn't one, just drop the |
1039 if ( device->DeviceId() == aDeviceId ) |
917 if ( device->DeviceId() == aDeviceId ) |
1040 { |
918 { |
1041 #ifdef _DEBUG |
919 #ifdef _DEBUG |
1042 found = ETrue; |
920 found = ETrue; |
1043 #endif |
921 #endif |
1044 OstTrace0( TRACE_NORMAL, CFDF_HANDLEDEVICEDETACHMENT_DUP1, "found matching device proxy" ); |
922 LOGTEXT(_L8("\tfound matching device proxy")); |
1045 |
923 |
1046 iDevices.Remove(*device); |
924 iDevices.Remove(*device); |
1047 // Before destroying the device proxy, take the detachment event |
925 // Before destroying the device proxy, take the detachment event |
1048 // stored in it for the event queue. |
926 // stored in it for the event queue. |
1049 TDeviceEvent* const detachmentEvent = device->GetDetachmentEventObject(); |
927 TDeviceEvent* const detachmentEvent = device->GetDetachmentEventObject(); |
1050 if(!detachmentEvent) |
928 ASSERT_DEBUG(detachmentEvent); |
1051 { |
929 ASSERT_DEBUG(iEventQueue); |
1052 OstTrace0( TRACE_FATAL, CFDF_HANDLEDEVICEDETACHMENT_DUP2, "Empty detachmentEvent" ); |
|
1053 __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); |
|
1054 } |
|
1055 if(!iEventQueue) |
|
1056 { |
|
1057 OstTrace0( TRACE_FATAL, CFDF_HANDLEDEVICEDETACHMENT_DUP3, "Empty iEventQueue" ); |
|
1058 __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); |
|
1059 } |
|
1060 iEventQueue->AddDeviceEvent(*detachmentEvent); |
930 iEventQueue->AddDeviceEvent(*detachmentEvent); |
1061 OstTrace1( TRACE_NORMAL, CFDF_HANDLEDEVICEDETACHMENT_DUP4, "***USB HOST STACK: DETACHMENT OF DEVICE (id %d)", aDeviceId ); |
931 LOGTEXT2(_L8("***USB HOST STACK: DETACHMENT OF DEVICE (id %d)"), aDeviceId); |
1062 delete device; |
932 delete device; |
1063 |
933 |
1064 TellFdcsOfDeviceDetachment(aDeviceId); |
934 TellFdcsOfDeviceDetachment(aDeviceId); |
1065 |
935 |
1066 #ifndef __OVER_DUMMYUSBDI__ |
936 #ifndef __OVER_DUMMYUSBDI__ |
1067 // If we're using the DummyUSBDI the real USBDI isn't loaded. |
937 // If we're using the DummyUSBDI the real USBDI isn't loaded. |
1068 // Unload USBDI when attached devices goes from 1 to 0 |
938 // Unload USBDI when attached devices goes from 1 to 0 |
1069 if (iDevices.IsEmpty()) |
939 if (iDevices.IsEmpty()) |
1070 { |
940 { |
1071 TInt err = User::FreeLogicalDevice(KDriverUsbdiLddFileName); |
941 TInt err = User::FreeLogicalDevice(KDriverUsbdiLddFileName); |
1072 OstTrace1( TRACE_NORMAL, CFDF_HANDLEDEVICEDETACHMENT_DUP5, "FreeLogicalDevice( usbdi ) returned %d", err ); |
942 LOGTEXT2(_L8("\tFreeLogicalDevice( usbdi ) returned %d"), err); |
1073 } |
943 } |
1074 #endif // __OVER_DUMMYUSBDI__ |
944 #endif // __OVER_DUMMYUSBDI__ |
1075 |
945 |
1076 break; |
946 break; |
1077 } |
947 } |
1078 } |
948 } |
1079 |
949 |
1080 #ifdef _DEBUG |
950 #ifdef _DEBUG |
1081 if ( !found ) |
951 if ( !found ) |
1082 { |
952 { |
1083 OstTrace0( TRACE_NORMAL, CFDF_HANDLEDEVICEDETACHMENT_DUP6, "no matching device proxy found" ); |
953 LOGTEXT(_L8("\tno matching device proxy found")); |
1084 } |
954 } |
1085 #endif |
955 #endif |
1086 |
|
1087 OstTraceFunctionExit0( CFDF_HANDLEDEVICEDETACHMENT_EXIT ); |
|
1088 } |
956 } |
1089 |
957 |
1090 void CFdf::HandleDevmonEvent(TInt aEvent) |
958 void CFdf::HandleDevmonEvent(TInt aEvent) |
1091 { |
959 { |
1092 OstTraceFunctionEntry0( CFDF_HANDLEDEVMONEVENT_ENTRY ); |
960 LOG_FUNC |
1093 OstTrace1( TRACE_NORMAL, CFDF_HANDLEDEVMONEVENT, "aEvent = %d", aEvent ); |
961 LOGTEXT2(_L8("\taEvent = %d"), aEvent); |
1094 |
962 |
1095 if(!iEventQueue) |
963 ASSERT_DEBUG(iEventQueue); |
1096 { |
|
1097 OstTrace0( TRACE_FATAL, CFDF_HANDLEDEVMONEVENT_DUP1, "Empty iEventQueue" ); |
|
1098 __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); |
|
1099 } |
|
1100 iEventQueue->AddDevmonEvent(aEvent); |
964 iEventQueue->AddDevmonEvent(aEvent); |
1101 OstTraceFunctionExit0( CFDF_HANDLEDEVMONEVENT_EXIT ); |
|
1102 } |
965 } |
1103 |
966 |
1104 void CFdf::TellFdcsOfDeviceDetachment(TUint aDeviceId) |
967 void CFdf::TellFdcsOfDeviceDetachment(TUint aDeviceId) |
1105 { |
968 { |
1106 OstTraceFunctionEntry0( CFDF_TELLFDCSOFDEVICEDETACHMENT_ENTRY ); |
969 LOG_FUNC |
1107 OstTrace1( TRACE_NORMAL, CFDF_TELLFDCSOFDEVICEDETACHMENT, "aDeviceId = %d", aDeviceId ); |
970 LOGTEXT2(_L8("\taDeviceId = %d"), aDeviceId); |
1108 |
971 |
1109 TSglQueIter<CFdcProxy> iter(iFunctionDrivers); |
972 TSglQueIter<CFdcProxy> iter(iFunctionDrivers); |
1110 iter.SetToFirst(); |
973 iter.SetToFirst(); |
1111 CFdcProxy* fdc; |
974 CFdcProxy* fdc; |
1112 while ( ( fdc = iter++ ) != NULL ) |
975 while ( ( fdc = iter++ ) != NULL ) |
1113 { |
976 { |
1117 iFunctionDrivers.Remove(*fdc); |
980 iFunctionDrivers.Remove(*fdc); |
1118 delete fdc; |
981 delete fdc; |
1119 } |
982 } |
1120 } |
983 } |
1121 |
984 |
1122 OstTraceFunctionExit0( CFDF_TELLFDCSOFDEVICEDETACHMENT_EXIT ); |
|
1123 } |
985 } |
1124 |
986 |
1125 TUint32 CFdf::TokenForInterface(TUint8 aInterface) |
987 TUint32 CFdf::TokenForInterface(TUint8 aInterface) |
1126 { |
988 { |
1127 OstTraceFunctionEntry0( CFDF_TOKENFORINTERFACE_ENTRY ); |
989 LOG_FUNC |
1128 OstTrace1( TRACE_NORMAL, CFDF_TOKENFORINTERFACE, "aInterface = %d", aInterface ); |
990 LOGTEXT2(_L8("\taInterface = %d"), aInterface); |
1129 |
|
1130 TUint32 token = 0; |
991 TUint32 token = 0; |
1131 |
992 |
1132 // Check that the interface was in the array given to the FD and mark it |
993 // Check that the interface was in the array given to the FD and mark it |
1133 // as claimed. |
994 // as claimed. |
1134 TBool found = EFalse; |
995 TBool found = EFalse; |
1135 const TUint interfaceCount = iInterfaces.Count(); |
996 const TUint interfaceCount = iInterfaces.Count(); |
1136 for ( TUint ii = 0 ; ii < interfaceCount ; ++ii ) |
997 for ( TUint ii = 0 ; ii < interfaceCount ; ++ii ) |
1137 { |
998 { |
1138 TInterfaceInfo* ifInfo = iInterfaces[ii]; |
999 TInterfaceInfo* ifInfo = iInterfaces[ii]; |
1139 if(!ifInfo) |
1000 ASSERT_DEBUG(ifInfo); |
1140 { |
|
1141 OstTrace0( TRACE_FATAL, CFDF_TOKENFORINTERFACE_DUP1, "Empty ifInfo" ); |
|
1142 __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); |
|
1143 } |
|
1144 if ( ifInfo->iNumber == aInterface ) |
1001 if ( ifInfo->iNumber == aInterface ) |
1145 { |
1002 { |
1146 found = ETrue; |
1003 found = ETrue; |
1147 // The FDC tried to claim an interface that was already claimed. |
1004 // The FDC tried to claim an interface that was already claimed. |
1148 if(ifInfo->iClaimed) |
1005 ASSERT_ALWAYS(!ifInfo->iClaimed); |
1149 { |
|
1150 OstTrace0( TRACE_FATAL, CFDF_TOKENFORINTERFACE_DUP2, "iClaimed error" ); |
|
1151 User::Panic(KPanicCategory,__LINE__); |
|
1152 } |
|
1153 ifInfo->iClaimed = ETrue; |
1006 ifInfo->iClaimed = ETrue; |
1154 break; |
1007 break; |
1155 } |
1008 } |
1156 } |
1009 } |
1157 // Could not find interface in the interface array- the FDC tried to claim |
1010 // Could not find interface in the interface array- the FDC tried to claim |
1158 // an interface it had not been offered. |
1011 // an interface it had not been offered. |
1159 if(!found) |
1012 ASSERT_ALWAYS(found); |
1160 { |
1013 |
1161 OstTrace0( TRACE_FATAL, CFDF_TOKENFORINTERFACE_DUP3, "not found" ); |
1014 ASSERT_DEBUG(iCurrentDevice); |
1162 User::Panic(KPanicCategory,__LINE__); |
|
1163 } |
|
1164 |
|
1165 if(!iCurrentDevice) |
|
1166 { |
|
1167 OstTrace0( TRACE_FATAL, CFDF_TOKENFORINTERFACE_DUP4, "Empty iCurrentDevice" ); |
|
1168 __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); |
|
1169 } |
|
1170 |
1015 |
1171 // GetTokenForInterface will return error in the following cases: |
1016 // GetTokenForInterface will return error in the following cases: |
1172 // 1/ KErrBadHandle: invalid device handle (the CDeviceProxy asserts that |
1017 // 1/ KErrBadHandle: invalid device handle (the CDeviceProxy asserts that |
1173 // the handle is valid) because the device has been detached while processing |
1018 // the handle is valid) because the device has been detached while processing |
1174 // may be due to too much current or cable has been removed |
1019 // may be due to too much current or cable has been removed |
1192 |
1037 |
1193 case KErrNone: // Fall through and do nothing |
1038 case KErrNone: // Fall through and do nothing |
1194 break; |
1039 break; |
1195 |
1040 |
1196 default: |
1041 default: |
1197 OstTraceExt2( TRACE_FATAL, CFDF_TOKENFORINTERFACE_DUP5, "Unexpected error %d when requesting token for aInterface %d",err,aInterface); |
1042 LOGTEXT3(_L8("\tUnexpected error %d when requesting token for aInterface %d"),err,aInterface); |
1198 User::Panic(KPanicCategory,__LINE__); |
1043 ASSERT_ALWAYS(0); |
1199 break; |
1044 break; |
1200 } |
1045 } |
1201 |
1046 |
1202 OstTraceExt2( TRACE_NORMAL, CFDF_TOKENFORINTERFACE_DUP6, |
1047 LOGTEXT3(_L8("\tToken for interface %d is = %d"),aInterface, token); |
1203 "Token for interface %hhu is = %u",aInterface, token); |
1048 |
1204 |
|
1205 OstTraceFunctionExit0( CFDF_TOKENFORINTERFACE_EXIT ); |
|
1206 return token; |
1049 return token; |
1207 } |
1050 } |
1208 |
1051 |
1209 CDeviceProxy* CFdf::DeviceProxyL(TUint aDeviceId) const |
1052 CDeviceProxy* CFdf::DeviceProxyL(TUint aDeviceId) const |
1210 { |
1053 { |
1211 OstTraceFunctionEntry0( CFDF_DEVICEPROXYL_ENTRY ); |
1054 LOG_FUNC |
1212 OstTrace1( TRACE_NORMAL, CFDF_DEVICEPROXYL, "aDeviceId = %d", aDeviceId ); |
1055 LOGTEXT2(_L8("\taDeviceId = %d"), aDeviceId); |
1213 |
1056 |
1214 TSglQueIter<CDeviceProxy> iter(const_cast<CFdf*>(this)->iDevices); |
1057 TSglQueIter<CDeviceProxy> iter(const_cast<CFdf*>(this)->iDevices); |
1215 iter.SetToFirst(); |
1058 iter.SetToFirst(); |
1216 CDeviceProxy* device = NULL; |
1059 CDeviceProxy* device = NULL; |
1217 while ( ( device = iter++ ) != NULL ) |
1060 while ( ( device = iter++ ) != NULL ) |
1218 { |
1061 { |
1219 if ( device->DeviceId() == aDeviceId ) |
1062 if ( device->DeviceId() == aDeviceId ) |
1220 { |
1063 { |
1221 OstTrace1( TRACE_NORMAL, CFDF_DEVICEPROXYL_DUP1, "device = 0x%08x", device ); |
1064 LOGTEXT2(_L8("\tdevice = 0x%08x"), device); |
1222 OstTraceFunctionExit0( CFDF_DEVICEPROXYL_EXIT ); |
|
1223 return device; |
1065 return device; |
1224 } |
1066 } |
1225 } |
1067 } |
1226 OstTrace0( TRACE_NORMAL, CFDF_DEVICEPROXYL_DUP2, "KErrNotFound"); |
1068 LEAVEL(KErrNotFound); |
1227 User::Leave(KErrNotFound); |
|
1228 OstTraceFunctionExit0( CFDF_DEVICEPROXYL_EXIT_DUP1 ); |
|
1229 return NULL; // avoid warning |
1069 return NULL; // avoid warning |
1230 } |
1070 } |
1231 |
1071 |
1232 const RArray<TUint>& CFdf::GetSupportedLanguagesL(TUint aDeviceId) const |
1072 const RArray<TUint>& CFdf::GetSupportedLanguagesL(TUint aDeviceId) const |
1233 { |
1073 { |
1234 OstTraceFunctionEntry0( CFDF_GETSUPPORTEDLANGUAGESL_ENTRY ); |
1074 LOG_FUNC |
1235 OstTrace1( TRACE_NORMAL, CFDF_GETSUPPORTEDLANGUAGESL, "aDeviceId = %d", aDeviceId ); |
1075 LOGTEXT2(_L8("\taDeviceId = %d"), aDeviceId); |
1236 |
1076 |
1237 CDeviceProxy* deviceProxy = DeviceProxyL(aDeviceId); |
1077 CDeviceProxy* deviceProxy = DeviceProxyL(aDeviceId); |
1238 return deviceProxy->GetSupportedLanguages(); |
1078 return deviceProxy->GetSupportedLanguages(); |
1239 } |
1079 } |
1240 |
1080 |
1241 void CFdf::GetManufacturerStringDescriptorL(TUint aDeviceId, TUint32 aLangId, TName& aString) const |
1081 void CFdf::GetManufacturerStringDescriptorL(TUint aDeviceId, TUint32 aLangId, TName& aString) const |
1242 { |
1082 { |
1243 OstTraceFunctionEntry0( CFDF_GETMANUFACTURERSTRINGDESCRIPTORL_ENTRY ); |
1083 LOG_FUNC |
1244 OstTraceExt2( TRACE_NORMAL, CFDF_GETMANUFACTURERSTRINGDESCRIPTORL, |
1084 LOGTEXT3(_L8("\taDeviceId = %d, aLangId = 0x%04x"), aDeviceId, aLangId); |
1245 "aDeviceId = %u, aLangId = 0x%08x", (TUint32)aDeviceId, aLangId ); |
1085 |
1246 |
|
1247 CDeviceProxy* deviceProxy = DeviceProxyL(aDeviceId); |
1086 CDeviceProxy* deviceProxy = DeviceProxyL(aDeviceId); |
1248 deviceProxy->GetManufacturerStringDescriptorL(aLangId, aString); |
1087 deviceProxy->GetManufacturerStringDescriptorL(aLangId, aString); |
1249 OstTraceExt1( TRACE_NORMAL, CFDF_GETMANUFACTURERSTRINGDESCRIPTORL_DUP1, "aString = \"%S\"", aString ); |
1088 LOGTEXT2(_L("\taString = \"%S\""), &aString); |
1250 OstTraceFunctionExit0( CFDF_GETMANUFACTURERSTRINGDESCRIPTORL_EXIT ); |
|
1251 } |
1089 } |
1252 |
1090 |
1253 void CFdf::GetProductStringDescriptorL(TUint aDeviceId, TUint32 aLangId, TName& aString) const |
1091 void CFdf::GetProductStringDescriptorL(TUint aDeviceId, TUint32 aLangId, TName& aString) const |
1254 { |
1092 { |
1255 OstTraceFunctionEntry0( CFDF_GETPRODUCTSTRINGDESCRIPTORL_ENTRY ); |
1093 LOG_FUNC |
1256 OstTraceExt2( TRACE_NORMAL, CFDF_GETPRODUCTSTRINGDESCRIPTORL, |
1094 LOGTEXT3(_L8("\taDeviceId = %d, aLangId = 0x%04x"), aDeviceId, aLangId); |
1257 "aDeviceId = %u, aLangId = 0x%04x", (TUint32)aDeviceId, aLangId ); |
|
1258 |
1095 |
1259 CDeviceProxy* deviceProxy = DeviceProxyL(aDeviceId); |
1096 CDeviceProxy* deviceProxy = DeviceProxyL(aDeviceId); |
1260 deviceProxy->GetProductStringDescriptorL(aLangId, aString); |
1097 deviceProxy->GetProductStringDescriptorL(aLangId, aString); |
1261 OstTraceExt1( TRACE_NORMAL, CFDF_GETPRODUCTSTRINGDESCRIPTORL_DUP1, "aString = \"%S\"", aString ); |
1098 LOGTEXT2(_L("\taString = \"%S\""), &aString); |
1262 OstTraceFunctionExit0( CFDF_GETPRODUCTSTRINGDESCRIPTORL_EXIT ); |
|
1263 } |
1099 } |
1264 |
1100 |
1265 void CFdf::GetOtgDeviceDescriptorL(TInt aDeviceId, TOtgDescriptor& aDescriptor) const |
1101 void CFdf::GetOtgDeviceDescriptorL(TInt aDeviceId, TOtgDescriptor& aDescriptor) const |
1266 { |
1102 { |
1267 OstTraceFunctionEntry0( CFDF_GETOTGDEVICEDESCRIPTORL_ENTRY ); |
1103 LOG_FUNC |
1268 |
1104 |
1269 DeviceProxyL(aDeviceId)->GetOtgDescriptorL(aDescriptor); |
1105 DeviceProxyL(aDeviceId)->GetOtgDescriptorL(aDescriptor); |
1270 OstTraceFunctionExit0( CFDF_GETOTGDEVICEDESCRIPTORL_EXIT ); |
|
1271 } |
1106 } |
1272 |
1107 |
1273 void CFdf::GetSerialNumberStringDescriptorL(TUint aDeviceId, TUint32 aLangId, TName& aString) const |
1108 void CFdf::GetSerialNumberStringDescriptorL(TUint aDeviceId, TUint32 aLangId, TName& aString) const |
1274 { |
1109 { |
1275 OstTraceFunctionEntry0( CFDF_GETSERIALNUMBERSTRINGDESCRIPTORL_ENTRY ); |
1110 LOG_FUNC |
1276 OstTraceExt2( TRACE_NORMAL, CFDF_GETSERIALNUMBERSTRINGDESCRIPTORL, |
1111 LOGTEXT3(_L8("\taDeviceId = %d, aLangId = 0x%04x"), aDeviceId, aLangId); |
1277 "aDeviceId = %u, aLangId = 0x%08x", (TUint32)aDeviceId, aLangId ); |
|
1278 |
1112 |
1279 CDeviceProxy* deviceProxy = DeviceProxyL(aDeviceId); |
1113 CDeviceProxy* deviceProxy = DeviceProxyL(aDeviceId); |
1280 deviceProxy->GetSerialNumberStringDescriptorL(aLangId, aString); |
1114 deviceProxy->GetSerialNumberStringDescriptorL(aLangId, aString); |
1281 OstTraceExt1( TRACE_NORMAL, CFDF_GETSERIALNUMBERSTRINGDESCRIPTORL_DUP1, "aString = \"%S\"", aString ); |
1115 LOGTEXT2(_L("\taString = \"%S\""), &aString); |
1282 OstTraceFunctionExit0( CFDF_GETSERIALNUMBERSTRINGDESCRIPTORL_EXIT ); |
|
1283 } |
1116 } |
1284 |
1117 |
1285 void CFdf::SearchForInterfaceFunctionDriversL(CDeviceProxy& aDevice, TBool& aAnySuccess, TInt& aCollectedErr) |
1118 void CFdf::SearchForInterfaceFunctionDriversL(CDeviceProxy& aDevice, TBool& aAnySuccess, TInt& aCollectedErr) |
1286 { |
1119 { |
1287 RArray<TUint> interfacesNumberArray; |
1120 RArray<TUint> interfacesNumberArray; |
1288 CleanupClosePushL(interfacesNumberArray); |
1121 CleanupClosePushL(interfacesNumberArray); |
|
1122 |
|
1123 |
1289 |
1124 |
1290 for ( TUint ii = 0 ; ii < iInterfaces.Count() ; ++ii ) |
1125 for ( TUint ii = 0 ; ii < iInterfaces.Count() ; ++ii ) |
1291 { |
1126 { |
1292 // At this point we have NOT done any interface level searching yet, |
1127 // At this point we have NOT done any interface level searching yet, |
1293 // and all interfaces should in the Unclaimed status, |
1128 // and all interfaces should in the Unclaimed status, |
1556 aSearchKey.Format(KTemplateIC_ISC(), aIfInfo.iClass, aIfInfo.iSubclass); |
1387 aSearchKey.Format(KTemplateIC_ISC(), aIfInfo.iClass, aIfInfo.iSubclass); |
1557 break; |
1388 break; |
1558 } |
1389 } |
1559 default: |
1390 default: |
1560 { |
1391 { |
1561 OstTrace1( TRACE_FATAL, CFDF_FORMATINTERFACESEARCHKEY, "Invalid aSearchKeys=%d", aSearchKeys ); |
1392 ASSERT_DEBUG(EFalse); |
1562 __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); |
1393 } |
1563 } |
1394 } |
1564 } |
1395 LOGTEXT2(_L8("\taSearchKey = \"%S\""), &aSearchKey); |
1565 OstTraceExt1( TRACE_NORMAL, CFDF_FORMATINTERFACESEARCHKEY_DUP1, "aSearchKey = \"%s\"", aSearchKey ); |
|
1566 OstTraceFunctionExit0( CFDF_FORMATINTERFACESEARCHKEY_EXIT ); |
|
1567 } |
1396 } |
1568 |
1397 |
1569 |
1398 |
1570 TUint CFdf::UnclaimedInterfaceCount() const |
1399 TUint CFdf::UnclaimedInterfaceCount() const |
1571 { |
1400 { |
1572 OstTraceFunctionEntry0( CFDF_UNCLAIMEDINTERFACECOUNT_ENTRY ); |
1401 LOG_FUNC |
1573 |
|
1574 TUint unclaimedInterfaces = 0; |
1402 TUint unclaimedInterfaces = 0; |
1575 for ( TUint ii = 0 ; ii < iInterfaces.Count() ; ++ii ) |
1403 for ( TUint ii = 0 ; ii < iInterfaces.Count() ; ++ii ) |
1576 { |
1404 { |
1577 TInterfaceInfo* ifInfo = iInterfaces[ii]; |
1405 TInterfaceInfo* ifInfo = iInterfaces[ii]; |
1578 |
1406 ASSERT_DEBUG(ifInfo); |
1579 if(!ifInfo) |
|
1580 { |
|
1581 OstTrace0( TRACE_FATAL, CFDF_UNCLAIMEDINTERFACECOUNT, "Empty ifInfo" ); |
|
1582 __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); |
|
1583 } |
|
1584 if ( !ifInfo->iClaimed ) |
1407 if ( !ifInfo->iClaimed ) |
1585 { |
1408 { |
1586 OstTrace1( TRACE_NORMAL, CFDF_UNCLAIMEDINTERFACECOUNT_DUP1, "unclaimed interface: ifInfo->iNumber = %d", ifInfo->iNumber ); |
1409 LOGTEXT2(_L8("\tunclaimed interface: ifInfo->iNumber = %d"), ifInfo->iNumber); |
1587 ++unclaimedInterfaces; |
1410 ++unclaimedInterfaces; |
1588 } |
1411 } |
1589 } |
1412 } |
1590 OstTrace1( TRACE_NORMAL, CFDF_UNCLAIMEDINTERFACECOUNT_DUP2, "unclaimedInterfaces = \"%d\"", unclaimedInterfaces ); |
1413 LOGTEXT2(_L("\tunclaimedInterfaces = \"%d\""), unclaimedInterfaces); |
1591 OstTraceFunctionExit0( CFDF_UNCLAIMEDINTERFACECOUNT_EXIT ); |
|
1592 return unclaimedInterfaces; |
1414 return unclaimedInterfaces; |
1593 } |
1415 } |
1594 |
1416 |
1595 |
1417 |
1596 void CFdf::SetFailureStatus(TInt aUnclaimedInterfaces, TInt aInterfaceCount, TBool aAnySuccess, TBool aCollectedErr, CDeviceProxy& aDevice) |
1418 void CFdf::SetFailureStatus(TInt aUnclaimedInterfaces, TInt aInterfaceCount, TBool aAnySuccess, TBool aCollectedErr, CDeviceProxy& aDevice) |