|
1 // Copyright (c) 2004-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 // f32test\testusbcldd\src\dtestusblogdev.cpp |
|
15 // |
|
16 // |
|
17 |
|
18 #include "dtestusblogdev.h" |
|
19 #include <d32usbc.h> |
|
20 |
|
21 // global Dfc Que |
|
22 TDynamicDfcQue* gDfcQ; |
|
23 |
|
24 // |
|
25 // DLL export number 1: Create a new LDD factory |
|
26 // |
|
27 DECLARE_STANDARD_LDD() |
|
28 { |
|
29 return(new DTestUsbcLogDevice); |
|
30 } |
|
31 |
|
32 DTestUsbcLogDevice::DTestUsbcLogDevice() : |
|
33 iEndpoints(KMaxEndpointsPerClient+1) |
|
34 { |
|
35 iParseMask = KDeviceAllowUnit; |
|
36 iUnitsMask = 0xffffffff; |
|
37 iVersion = TVersion(KTestUsbcMajorVersion, KTestUsbcMinorVersion, KTestUsbcBuildVersion); |
|
38 } |
|
39 |
|
40 DTestUsbcLogDevice::~DTestUsbcLogDevice() |
|
41 { |
|
42 for (TInt i = 0; i < iEndpoints.Count(); i++) |
|
43 { |
|
44 delete iEndpoints[i]; |
|
45 } |
|
46 iEndpoints.Reset(); |
|
47 iEndpoints.Close(); |
|
48 |
|
49 if (gDfcQ) |
|
50 gDfcQ->Destroy(); |
|
51 } |
|
52 |
|
53 const TInt KDSTestUsbThreadPriority = 27; |
|
54 _LIT(KDTestUsbThread,"DTestUsbThread"); |
|
55 |
|
56 TInt DTestUsbcLogDevice::Install() |
|
57 { |
|
58 // Allocate a kernel thread to run the DFC |
|
59 TInt r = Kern::DynamicDfcQCreate(gDfcQ, KDSTestUsbThreadPriority, KDTestUsbThread); |
|
60 |
|
61 if (r != KErrNone) |
|
62 return r; |
|
63 |
|
64 _LIT(KName, "usbc"); |
|
65 return SetName(&KName); |
|
66 } |
|
67 |
|
68 void DTestUsbcLogDevice::GetCaps(TDes8& aDes) const |
|
69 { |
|
70 TPckgBuf<TCapsDevUsbc> b; |
|
71 b().version=iVersion; |
|
72 Kern::InfoCopy(aDes, b); |
|
73 } |
|
74 |
|
75 TInt DTestUsbcLogDevice::Create(DLogicalChannelBase*& aChannel) |
|
76 { |
|
77 if (iEndpoints.Count() == 0) |
|
78 { |
|
79 for (TInt i = 0; i < KMaxEndpointsPerClient+1; i++) |
|
80 { |
|
81 DTestUsbcEndpoint* ep = new DTestUsbcEndpoint(); |
|
82 if (!ep) |
|
83 { |
|
84 return KErrNoMemory; |
|
85 } |
|
86 TInt err = ep->Create(DLddTestUsbcChannel::iEndpointData[i].iCaps); |
|
87 if (err != KErrNone) |
|
88 { |
|
89 return err; |
|
90 } |
|
91 iEndpoints.Append(ep); |
|
92 } |
|
93 } |
|
94 aChannel = new DLddTestUsbcChannel(iEndpoints); |
|
95 return aChannel ? KErrNone : KErrNoMemory; |
|
96 } |
|
97 |