|
1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of the License "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <f32file.h> |
|
17 #include <d32usbdi_hubdriver.h> |
|
18 #include <d32usbdi.h> |
|
19 #include <d32otgdi.h> |
|
20 #include <d32usbdescriptors.h> |
|
21 #include <d32usbtransfers.h> |
|
22 |
|
23 #include <shared.h> |
|
24 |
|
25 #include "rusbhostmsdevice.h" |
|
26 |
|
27 #include "rextfilesystem.h" |
|
28 #include "usbtypes.h" |
|
29 #include "cusbmsmountmanager.h" |
|
30 #include "tmslog.h" |
|
31 #include "debug.h" |
|
32 |
|
33 |
|
34 CDevice* CDevice::NewL() |
|
35 { |
|
36 __MSFNSLOG |
|
37 CDevice* r = new (ELeave) CDevice(); |
|
38 CleanupStack::PushL(r); |
|
39 |
|
40 r->ConstructL(); |
|
41 CleanupStack::Pop(); |
|
42 return r; |
|
43 } |
|
44 |
|
45 |
|
46 void CDevice::ConstructL() |
|
47 { |
|
48 __MSFNLOG |
|
49 } |
|
50 |
|
51 |
|
52 CDevice::CDevice() |
|
53 { |
|
54 __MSFNLOG |
|
55 } |
|
56 |
|
57 |
|
58 CDevice::~CDevice() |
|
59 { |
|
60 __MSFNLOG |
|
61 __USBHOSTPRINT1(_L("~CDevice Token=%d"), iDeviceToken); |
|
62 } |
|
63 |
|
64 |
|
65 TToken CDevice::OpenDeviceL(TUint aDeviceHandle, RUsbHubDriver& aHub) |
|
66 { |
|
67 __MSFNLOG |
|
68 __USBHOSTPRINT1(_L("CDevice::OpenDeviceL Handle=%d"), aDeviceHandle); |
|
69 |
|
70 TInt err = iUsbDevice.Open(aHub, aDeviceHandle); |
|
71 __USBHOSTPRINT1(_L(" - returned %d\n"), err); |
|
72 User::LeaveIfError(err); |
|
73 |
|
74 /* Retrieve the device descriptor */ |
|
75 TUsbDeviceDescriptor devDescriptor; |
|
76 User::LeaveIfError(iUsbDevice.GetDeviceDescriptor(devDescriptor)); |
|
77 iUsbPrint.PrintDescriptor(devDescriptor, 0, &iUsbDevice); |
|
78 |
|
79 iUsbPrint.PrintTree(devDescriptor); |
|
80 |
|
81 /* Retrieve the configuration descriptor */ |
|
82 TUsbConfigurationDescriptor configDescriptor; |
|
83 User::LeaveIfError(iUsbDevice.GetConfigurationDescriptor(configDescriptor)); |
|
84 iUsbPrint.PrintDescriptor(configDescriptor, 0, &iUsbDevice); |
|
85 |
|
86 /* Get the token for interface 0 */ |
|
87 TUint32 token; |
|
88 err = iUsbDevice.GetTokenForInterface(0, token); |
|
89 __USBHOSTPRINT2(_L("RUsbDevice::GetTokenForInterface returned error %d, token %08x"), err, token); |
|
90 User::LeaveIfError(err); |
|
91 |
|
92 /* open the interface */ |
|
93 RUsbInterface interface_ep0; |
|
94 err = interface_ep0.Open(token); |
|
95 __USBHOSTPRINT1(_L("RUsbInterface::Open returned error %d"), err); |
|
96 User::LeaveIfError(err); |
|
97 |
|
98 /* Retrieve the interface and device descriptors */ |
|
99 TUsbInterfaceDescriptor ifDescriptor; |
|
100 User::LeaveIfError(interface_ep0.GetInterfaceDescriptor(ifDescriptor)); |
|
101 iUsbPrint.PrintDescriptor(ifDescriptor); |
|
102 |
|
103 if (!IsDeviceMassStorage(ifDescriptor, devDescriptor)) |
|
104 { |
|
105 RDebug::Print(_L("ATTACHED DEVICE IS NOT A MASS STORAGE DEVICE!\n")); |
|
106 User::Leave(KErrGeneral); |
|
107 } |
|
108 |
|
109 TUint8 iProtocolId = ifDescriptor.InterfaceSubClass(); |
|
110 TUint8 iTransportId = ifDescriptor.InterfaceProtocol(); |
|
111 |
|
112 interface_ep0.Close(); |
|
113 |
|
114 THostMassStorageConfig msConfig; |
|
115 msConfig.iInterfaceToken = token; |
|
116 msConfig.iProtocolId =iProtocolId; |
|
117 msConfig.iTransportId = iTransportId; |
|
118 msConfig.iStatusPollingInterval = 10; // 10 secs |
|
119 |
|
120 TUint32 numLun; |
|
121 |
|
122 TRequestStatus status; |
|
123 iUsbHostMsDevice.Add(msConfig, status); |
|
124 User::WaitForRequest(status); |
|
125 if (status.Int() != KErrNone) |
|
126 { |
|
127 __USBHOSTPRINT(_L("Add device failed")); |
|
128 User::Leave(status.Int()); |
|
129 } |
|
130 TInt r = iUsbHostMsDevice.GetNumLun(numLun); |
|
131 if (r != KErrNone) |
|
132 { |
|
133 __USBHOSTPRINT(_L("GetNumLun failed")); |
|
134 User::Leave(r); |
|
135 } |
|
136 |
|
137 if (numLun > KMaxLun) |
|
138 { |
|
139 __USBHOSTPRINT1(_L("Device MaxLun = %d. Error MaxLun > MAXLUN !"), numLun); |
|
140 User::Leave(KErrGeneral); |
|
141 } |
|
142 |
|
143 __USBHOSTPRINT1(_L("MSC registered with %d Luns"), numLun); |
|
144 |
|
145 iDeviceToken = token; |
|
146 iNumLuns = numLun; |
|
147 iDeviceHandle = aDeviceHandle; |
|
148 return token; |
|
149 } |
|
150 |
|
151 |
|
152 void CDevice::CloseDeviceL() |
|
153 { |
|
154 __MSFNLOG |
|
155 |
|
156 THostMassStorageConfig msConfig; |
|
157 msConfig.iInterfaceToken = iDeviceToken; |
|
158 |
|
159 iUsbHostMsDevice.Remove(); |
|
160 iUsbDevice.Close(); |
|
161 } |
|
162 |
|
163 |
|
164 void CDevice::MountLogicalUnitsL() |
|
165 { |
|
166 __MSFNLOG |
|
167 iExt.OpenL(); |
|
168 |
|
169 for (TInt lun = 0; lun < iNumLuns; lun++) |
|
170 { |
|
171 TDriveNumber driveNumber = iExt.GetDriveL(); |
|
172 __PRINT2(_L("Mounting drive=%d lun=%d..."), driveNumber, lun); |
|
173 RDebug::Print(_L("Mounting drive=%d lun=%d..."), driveNumber, lun); |
|
174 TRAPD(err, iExt.MountL(iUsbHostMsDevice, driveNumber, iDeviceToken, lun)); |
|
175 if (err == KErrNone || err == KErrNotReady || err == KErrCorrupt) |
|
176 { |
|
177 iLuList.Append(driveNumber); |
|
178 } |
|
179 __PRINT1(_L("%d"), err); |
|
180 RDebug::Print(_L("err=%d"), err); |
|
181 } |
|
182 } |
|
183 |
|
184 |
|
185 void CDevice::DismountLogicalUnitsL() |
|
186 { |
|
187 __MSFNLOG |
|
188 for (TInt lun = 0; lun < iLuList.Count(); lun++) |
|
189 { |
|
190 TDriveNumber driveNumber = iLuList[lun]; |
|
191 iExt.DismountL(iUsbHostMsDevice, driveNumber); |
|
192 } |
|
193 iLuList.Reset(); |
|
194 |
|
195 iExt.CloseL(); |
|
196 } |
|
197 |
|
198 |
|
199 TInt CDevice::GetEndpointAddress(RUsbInterface& aUsbInterface, |
|
200 TInt aInterfaceSetting, |
|
201 TUint8 aTransferType, |
|
202 TUint8 aDirection, |
|
203 TInt& aEndpointAddress) const |
|
204 { |
|
205 __MSFNSLOG |
|
206 |
|
207 // Get the interface descriptor |
|
208 RDebug::Print(_L("GetEndpointAddress : Getting the interface descriptor for this alternate setting")); |
|
209 |
|
210 TUsbInterfaceDescriptor alternateInterfaceDescriptor; |
|
211 TInt err = aUsbInterface.GetAlternateInterfaceDescriptor(aInterfaceSetting, alternateInterfaceDescriptor); |
|
212 |
|
213 if (err) |
|
214 { |
|
215 RDebug::Print(_L("GetEndpointAddress : <Error %d> Unable to get alternate interface (%d) descriptor"),err,aInterfaceSetting); |
|
216 return err; |
|
217 } |
|
218 |
|
219 // Parse the descriptor tree from the interface |
|
220 RDebug::Print(_L("Search the child descriptors for matching endpoint attributes")); |
|
221 |
|
222 TUsbGenericDescriptor* descriptor = alternateInterfaceDescriptor.iFirstChild; |
|
223 |
|
224 while (descriptor) |
|
225 { |
|
226 RDebug::Print(_L("GetEndpointAddress : Check descriptor type for endpoint")); |
|
227 |
|
228 // Cast the descriptor to an endpoint descriptor |
|
229 TUsbEndpointDescriptor* endpoint = TUsbEndpointDescriptor::Cast(descriptor); |
|
230 |
|
231 if (endpoint) |
|
232 { |
|
233 RDebug::Print(_L("GetEndpointAddress : Match attributes for transfer type")); |
|
234 |
|
235 if ( (endpoint->Attributes() & aTransferType) == aTransferType) |
|
236 { |
|
237 RDebug::Print(_L("GetEndpointAddress : Match attributes for endpoint direction")); |
|
238 |
|
239 if ( (endpoint->EndpointAddress() & 0x80) == aDirection) |
|
240 { |
|
241 aEndpointAddress = endpoint->EndpointAddress(); |
|
242 RDebug::Print(_L("GetEndpointAddress : Endpoint address found")); |
|
243 return KErrNone; |
|
244 } |
|
245 } |
|
246 } |
|
247 |
|
248 descriptor = descriptor->iNextPeer; |
|
249 } |
|
250 |
|
251 // Unable to find the endpoint address |
|
252 RDebug::Print(_L("GetEndpointAddress : Unable to find endpoint address matching the specified attributes")); |
|
253 |
|
254 return KErrNotFound; |
|
255 } |
|
256 |
|
257 |
|
258 TBool CDevice::IsDeviceMassStorage(const TUsbInterfaceDescriptor& aInterfaceDesc, |
|
259 const TUsbDeviceDescriptor& aDeviceDesc) const |
|
260 { |
|
261 __MSFNSLOG |
|
262 /* check the interface descriptor */ |
|
263 if(aInterfaceDesc.InterfaceClass() == 0x08 && |
|
264 aInterfaceDesc.InterfaceSubClass() == 0x06 && |
|
265 aInterfaceDesc.InterfaceProtocol() == 0x50) |
|
266 { |
|
267 if(aDeviceDesc.DeviceClass() == 0x00 && |
|
268 aDeviceDesc.DeviceSubClass() == 0x00 && |
|
269 aDeviceDesc.DeviceProtocol() == 0x00) |
|
270 return ETrue; |
|
271 } |
|
272 |
|
273 return EFalse; |
|
274 |
|
275 } |
|
276 |
|
277 |
|
278 TLun CDevice::DriveMap(TDriveMap& aDriveMap) const |
|
279 { |
|
280 __MSFNSLOG |
|
281 TDriveNumber driveNumber; |
|
282 RDebug::Printf("LuList.Count=%d", iLuList.Count()); |
|
283 for (TInt i = 0; i < iLuList.Count(); i++) |
|
284 { |
|
285 driveNumber = iLuList[i]; |
|
286 aDriveMap[driveNumber] = iDeviceToken; |
|
287 RDebug::Printf("Device %d token=%d driveNumber=%d", i, iDeviceToken, driveNumber); |
|
288 } |
|
289 |
|
290 return iNumLuns; |
|
291 } |
|
292 |
|
293 |
|
294 TLun CDevice::DeviceMap(TDeviceMap& aDeviceMap) const |
|
295 { |
|
296 __MSFNSLOG |
|
297 TDriveNumber driveNumber; |
|
298 RDebug::Printf("LuList.Count=%d", iLuList.Count()); |
|
299 for (TInt i = 0; i < iLuList.Count(); i++) |
|
300 { |
|
301 driveNumber = iLuList[i]; |
|
302 aDeviceMap[i] = driveNumber; |
|
303 RDebug::Printf("CDevice LUN=%d driveNumber=%d", i, driveNumber); |
|
304 } |
|
305 |
|
306 return iNumLuns; |
|
307 } |
|
308 |
|
309 |
|
310 CUsbMsMountManager* CUsbMsMountManager::NewL() |
|
311 { |
|
312 __MSFNSLOG |
|
313 CUsbMsMountManager* r = new (ELeave) CUsbMsMountManager(); |
|
314 CleanupStack::PushL(r); |
|
315 |
|
316 r->ConstructL(); |
|
317 CleanupStack::Pop(); |
|
318 return r; |
|
319 } |
|
320 |
|
321 |
|
322 void CUsbMsMountManager::ConstructL() |
|
323 { |
|
324 __MSFNLOG |
|
325 } |
|
326 |
|
327 |
|
328 CUsbMsMountManager::CUsbMsMountManager() |
|
329 { |
|
330 __MSFNLOG |
|
331 } |
|
332 |
|
333 |
|
334 CUsbMsMountManager::~CUsbMsMountManager() |
|
335 { |
|
336 __MSFNLOG |
|
337 iDeviceList.ResetAndDestroy(); |
|
338 } |
|
339 |
|
340 |
|
341 // adds new entry for this device |
|
342 void CUsbMsMountManager::AddDeviceL(CDevice* aDevice) |
|
343 { |
|
344 __MSFNLOG |
|
345 iDeviceList.Append(aDevice); |
|
346 } |
|
347 |
|
348 |
|
349 CDevice* CUsbMsMountManager::RemoveDeviceL(TUint aDeviceHandle) |
|
350 { |
|
351 __MSFNLOG |
|
352 TInt index = GetHandleIndexL(aDeviceHandle); |
|
353 CDevice* device = iDeviceList[index]; |
|
354 iDeviceList.Remove(index); |
|
355 return device; |
|
356 } |
|
357 |
|
358 void CUsbMsMountManager::CloseAllDevicesL() |
|
359 { |
|
360 __MSFNLOG |
|
361 for (TInt i = 0; i < iDeviceList.Count(); i++) |
|
362 { |
|
363 iDeviceList[i]->CloseDeviceL(); |
|
364 } |
|
365 } |
|
366 |
|
367 |
|
368 TInt CUsbMsMountManager::GetDeviceIndexL(TToken aDeviceToken) const |
|
369 { |
|
370 __MSFNSLOG |
|
371 TInt index; |
|
372 for (index = 0; index < iDeviceList.Count(); index++) |
|
373 { |
|
374 if (aDeviceToken == iDeviceList[index]->DeviceToken()) |
|
375 { |
|
376 break; |
|
377 } |
|
378 } |
|
379 |
|
380 if (index == iDeviceList.Count()) |
|
381 { |
|
382 User::Leave(KErrNotFound); |
|
383 } |
|
384 |
|
385 return index; |
|
386 } |
|
387 |
|
388 |
|
389 TInt CUsbMsMountManager::GetHandleIndexL(TUint aDeviceHandle) const |
|
390 { |
|
391 __MSFNSLOG |
|
392 TInt index; |
|
393 for (index = 0; index < iDeviceList.Count(); index++) |
|
394 { |
|
395 if (aDeviceHandle == iDeviceList[index]->DeviceHandle()) |
|
396 { |
|
397 break; |
|
398 } |
|
399 } |
|
400 |
|
401 if (index == iDeviceList.Count()) |
|
402 { |
|
403 User::Leave(KErrNotFound); |
|
404 } |
|
405 |
|
406 return index; |
|
407 } |
|
408 |
|
409 |
|
410 |
|
411 // mounts all LUNs for the device |
|
412 void CUsbMsMountManager::MountDeviceL(TUint aDeviceHandle) |
|
413 { |
|
414 __MSFNLOG |
|
415 TInt index = GetHandleIndexL(aDeviceHandle); |
|
416 iDeviceList[index]->MountLogicalUnitsL(); |
|
417 } |
|
418 |
|
419 |
|
420 |
|
421 // dismount all LUNs for this device |
|
422 void CUsbMsMountManager::DismountDeviceL(TUint aDeviceHandle) |
|
423 { |
|
424 __MSFNLOG |
|
425 TInt index = GetHandleIndexL(aDeviceHandle); |
|
426 iDeviceList[index]->DismountLogicalUnitsL(); |
|
427 } |
|
428 |
|
429 |
|
430 // dismount all LUNs |
|
431 void CUsbMsMountManager::DismountL() |
|
432 { |
|
433 __MSFNLOG |
|
434 for (TInt i = 0; i < iDeviceList.Count(); i++) |
|
435 { |
|
436 iDeviceList[i]->DismountLogicalUnitsL(); |
|
437 } |
|
438 } |
|
439 |
|
440 |
|
441 void CUsbMsMountManager::DriveMap(TDriveMap& aDriveMap) const |
|
442 { |
|
443 __MSFNSLOG |
|
444 TInt maxLun = 0; |
|
445 RDebug::Printf("DeviceList.Count=%d", iDeviceList.Count()); |
|
446 for (TInt i = 0; i < iDeviceList.Count(); i++) |
|
447 { |
|
448 maxLun = iDeviceList[i]->DriveMap(aDriveMap); |
|
449 RDebug::Printf("%d %d", i, maxLun); |
|
450 } |
|
451 } |
|
452 |
|
453 |
|
454 void CUsbMsMountManager::DeviceMap(TInt aDeviceIndex, TDeviceMap& aDeviceMap) const |
|
455 { |
|
456 __MSFNSLOG |
|
457 RDebug::Printf("Device=%d", aDeviceIndex); |
|
458 |
|
459 __ASSERT_DEBUG(aDeviceIndex < iDeviceList.Count(), User::Invariant()); |
|
460 iDeviceList[aDeviceIndex]->DeviceMap(aDeviceMap); |
|
461 } |
|
462 |
|
463 |
|
464 |
|
465 TUsbPrint::TUsbPrint() |
|
466 : iDebug(EFalse) |
|
467 { |
|
468 } |
|
469 |
|
470 void TUsbPrint::PrintTree(const TUsbGenericDescriptor& aDesc, TInt aDepth) |
|
471 { |
|
472 if (!iDebug) |
|
473 { |
|
474 return; |
|
475 } |
|
476 |
|
477 TBuf<20> buf; |
|
478 for(TInt depth=aDepth;depth>=0;--depth) |
|
479 { |
|
480 buf.Append(_L(" ")); |
|
481 } |
|
482 if(aDesc.iRecognisedAndParsed == TUsbGenericDescriptor::ERecognised) |
|
483 { |
|
484 RDebug::Print(_L("%S+0x%08x - %d 0x%02x"), &buf, &aDesc, aDesc.ibLength, aDesc.ibDescriptorType); |
|
485 } |
|
486 else |
|
487 { |
|
488 RDebug::Print(_L("%S-0x%08x - %d 0x%02x"), &buf, &aDesc, aDesc.ibLength, aDesc.ibDescriptorType); |
|
489 } |
|
490 HBufC* blob = HBufC::New(5*aDesc.iBlob.Length()); // 5* for " 0x" + 2*bytes for hex representation |
|
491 if(blob) |
|
492 { |
|
493 for(TInt i=0;i<aDesc.iBlob.Length();++i) |
|
494 { |
|
495 blob->Des().AppendFormat(_L("0x%02x "), aDesc.iBlob[i]); |
|
496 } |
|
497 RDebug::Print(_L("%S >%S"), &buf, blob); |
|
498 delete blob; |
|
499 } |
|
500 if(aDesc.iFirstChild) |
|
501 { |
|
502 RDebug::Print(_L("%S \\ "), &buf); |
|
503 PrintTree(*(aDesc.iFirstChild), aDepth+1); |
|
504 RDebug::Print(_L("%S / "), &buf); |
|
505 } |
|
506 if(aDesc.iNextPeer) |
|
507 { |
|
508 PrintTree(*(aDesc.iNextPeer), aDepth); |
|
509 } |
|
510 } |
|
511 |
|
512 |
|
513 static TUint16 gLangId = 0x0000; |
|
514 |
|
515 void TUsbPrint::SetLanguageToPrintL(RUsbDevice& aDevice) |
|
516 { |
|
517 if (!iDebug) return; |
|
518 |
|
519 // Try to set language to US Eng, otherwise take the first one listed. |
|
520 if(gLangId == 0x0000) // Only make the request if not been made before. |
|
521 { |
|
522 // Get string descriptor 0. |
|
523 TBuf8<256> stringBuf; |
|
524 TUsbStringDescriptor* stringDesc = NULL; |
|
525 User::LeaveIfError(aDevice.GetStringDescriptor(stringDesc, stringBuf, 0)); |
|
526 CleanupStack::PushL(*stringDesc); |
|
527 |
|
528 // Search for US English |
|
529 TBool usEngLang = EFalse; |
|
530 TInt langId = 0; |
|
531 TInt index = 0; |
|
532 const TUint16 KLangIdUsEng = 0x0409; |
|
533 while(!usEngLang && langId != KErrNotFound) |
|
534 { |
|
535 langId = stringDesc->GetLangId(index); |
|
536 usEngLang = (langId == KLangIdUsEng); |
|
537 index++; |
|
538 } |
|
539 |
|
540 // Set the language appropriately |
|
541 if(usEngLang) |
|
542 { |
|
543 gLangId = KLangIdUsEng; |
|
544 } |
|
545 else |
|
546 { |
|
547 gLangId = stringDesc->GetLangId(0); |
|
548 } |
|
549 |
|
550 CleanupStack::PopAndDestroy(); // stringDesc |
|
551 } |
|
552 } |
|
553 |
|
554 |
|
555 void TUsbPrint::PrintStringFromIndex(const TDesC& aFormatString, |
|
556 TInt aIndex, |
|
557 RUsbDevice* aDevice) |
|
558 { |
|
559 if (!iDebug) return; |
|
560 |
|
561 // If we have no device handle, we cannot go and get any strings. |
|
562 // If we have index 0, this indicates we don't have a string for this entry. |
|
563 if(aDevice && aIndex != 0) |
|
564 { |
|
565 TRAPD(err, SetLanguageToPrintL(*aDevice)); |
|
566 if(err == KErrNone) |
|
567 { |
|
568 TBuf8<255> stringBuf; |
|
569 TUsbStringDescriptor* stringDesc = NULL; |
|
570 err = aDevice->GetStringDescriptor(stringDesc, stringBuf, aIndex, gLangId); |
|
571 if(err == KErrNone) |
|
572 { |
|
573 TBuf<128> buf; |
|
574 stringDesc->StringData(buf); |
|
575 RDebug::Print(aFormatString, &buf); |
|
576 stringDesc->DestroyTree(); |
|
577 } |
|
578 delete stringDesc; |
|
579 } |
|
580 else |
|
581 { |
|
582 RDebug::Print(_L("Error while Selecting Langauge %d\n"), err); |
|
583 } |
|
584 } |
|
585 } |
|
586 |
|
587 |
|
588 void TUsbPrint::PrintDescriptor(const TUsbDeviceDescriptor& aDeviceDesc, |
|
589 TInt /*aVariant*/, |
|
590 RUsbDevice* aDevice) |
|
591 { |
|
592 if (!iDebug) return; |
|
593 |
|
594 RDebug::Print(_L("USBBcd = 0x%04x\n"), aDeviceDesc.USBBcd()); |
|
595 RDebug::Print(_L("DeviceClass = 0x%02x\n"), aDeviceDesc.DeviceClass()); |
|
596 RDebug::Print(_L("DeviceSubClass = 0x%02x\n"), aDeviceDesc.DeviceSubClass()); |
|
597 RDebug::Print(_L("DeviceProtocol = 0x%02x\n"), aDeviceDesc.DeviceProtocol()); |
|
598 RDebug::Print(_L("MaxPacketSize0 = 0x%02x\n"), aDeviceDesc.MaxPacketSize0()); |
|
599 RDebug::Print(_L("VendorId = 0x%04x\n"), aDeviceDesc.VendorId()); |
|
600 RDebug::Print(_L("ProductId = 0x%04x\n"), aDeviceDesc.ProductId()); |
|
601 RDebug::Print(_L("DeviceBcd = 0x%04x\n"), aDeviceDesc.DeviceBcd()); |
|
602 RDebug::Print(_L("ManufacturerIndex = 0x%02x\n"), aDeviceDesc.ManufacturerIndex()); |
|
603 PrintStringFromIndex(_L("ManufacturerString = %S\n"), aDeviceDesc.ManufacturerIndex(), aDevice); |
|
604 RDebug::Print(_L("ProductIndex = 0x%02x\n"), aDeviceDesc.ProductIndex()); |
|
605 PrintStringFromIndex(_L("ProductString = %S\n"), aDeviceDesc.ProductIndex(), aDevice); |
|
606 RDebug::Print(_L("SerialNumberIndex = 0x%02x\n"), aDeviceDesc.SerialNumberIndex()); |
|
607 PrintStringFromIndex(_L("SerialNumberString = %S\n"), aDeviceDesc.SerialNumberIndex(), aDevice); |
|
608 RDebug::Print(_L("NumConfigurations = 0x%02x\n"), aDeviceDesc.NumConfigurations()); |
|
609 } |
|
610 |
|
611 |
|
612 void TUsbPrint::PrintDescriptor(const TUsbConfigurationDescriptor& aConfigDesc, |
|
613 TInt /*aVariant*/, |
|
614 RUsbDevice* aDevice) |
|
615 { |
|
616 if (!iDebug) return; |
|
617 RDebug::Print(_L("TotalLength = 0x%04x\n"), aConfigDesc.TotalLength()); |
|
618 RDebug::Print(_L("NumInterfaces = 0x%02x\n"), aConfigDesc.NumInterfaces()); |
|
619 RDebug::Print(_L("ConfigurationValue = 0x%02x\n"), aConfigDesc.ConfigurationValue()); |
|
620 RDebug::Print(_L("ConfigurationIndex = 0x%02x\n"), aConfigDesc.ConfigurationIndex()); |
|
621 PrintStringFromIndex(_L("ConfigurationString = %S\n"), aConfigDesc.ConfigurationIndex(), aDevice); |
|
622 RDebug::Print(_L("Attributes = 0x%02x\n"), aConfigDesc.Attributes()); |
|
623 RDebug::Print(_L("MaxPower = 0x%02x\n"), aConfigDesc.MaxPower()); |
|
624 } |
|
625 |
|
626 |
|
627 void TUsbPrint::PrintDescriptor(const TUsbEndpointDescriptor& aEndpointDesc, |
|
628 TInt /*aVariant*/, |
|
629 RUsbDevice* /*aDevice*/) |
|
630 { |
|
631 if (!iDebug) return; |
|
632 RDebug::Print(_L("EndpointAddress = 0x%02x\n"), aEndpointDesc.EndpointAddress()); |
|
633 RDebug::Print(_L("Attributes = 0x%02x\n"), aEndpointDesc.Attributes()); |
|
634 RDebug::Print(_L("MaxPacketSize = 0x%04x\n"), aEndpointDesc.MaxPacketSize()); |
|
635 RDebug::Print(_L("Interval = 0x%02x\n"), aEndpointDesc.Interval()); |
|
636 } |
|
637 |
|
638 |
|
639 void TUsbPrint::PrintDescriptor(const TUsbInterfaceDescriptor& aInterfaceDesc, |
|
640 TInt /*aVariant*/, |
|
641 RUsbDevice* /*aDevice*/) |
|
642 { |
|
643 if (!iDebug) return; |
|
644 RDebug::Print(_L("InterfaceNumber = 0x%02x\n"), aInterfaceDesc.InterfaceNumber()); |
|
645 RDebug::Print(_L("AlternateSetting = 0x%02x\n"), aInterfaceDesc.AlternateSetting()); |
|
646 RDebug::Print(_L("NumEndpoints = 0x%02x\n"), aInterfaceDesc.NumEndpoints()); |
|
647 RDebug::Print(_L("InterfaceClass = 0x%02x\n"), aInterfaceDesc.InterfaceClass()); |
|
648 RDebug::Print(_L("InterfaceSubClass = 0x%02x\n"), aInterfaceDesc.InterfaceSubClass()); |
|
649 RDebug::Print(_L("InterfaceProtocol = 0x%02x\n"), aInterfaceDesc.InterfaceProtocol()); |
|
650 RDebug::Print(_L("Interface = 0x%02x\n"), aInterfaceDesc.Interface()); |
|
651 } |
|
652 |
|
653 |
|
654 void TUsbPrint::PrintDescriptor(const TUsbStringDescriptor& aStringDesc, |
|
655 TInt aVariant, |
|
656 RUsbDevice* /*aDevice*/) |
|
657 { |
|
658 if (!iDebug) return; |
|
659 if(aVariant == 0) |
|
660 { |
|
661 RDebug::Print(_L("String Descriptor Zero\n")); |
|
662 TInt index = 0; |
|
663 TInt langId = 0; |
|
664 while((langId = aStringDesc.GetLangId(index)) != KErrNotFound) |
|
665 { |
|
666 RDebug::Print(_L(" >0x%04x\n"), langId); |
|
667 ++index; |
|
668 } |
|
669 } |
|
670 else |
|
671 { |
|
672 RDebug::Print(_L("Generic String Descriptor\n")); |
|
673 HBufC16* string = HBufC16::New(128); |
|
674 if(string) |
|
675 { |
|
676 TPtr16 stringPtr = string->Des(); |
|
677 aStringDesc.StringData(stringPtr); |
|
678 RDebug::Print(_L(" >%S\n"), string); |
|
679 } |
|
680 delete string; |
|
681 } |
|
682 } |