|
1 /* |
|
2 * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * Class declaration for CBulkOnlyTransportUsbcLdd. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 /** |
|
21 @file |
|
22 @internalTechnology |
|
23 */ |
|
24 |
|
25 #ifndef __CBULKONLYTRANSPORTUSBCLDD_H__ |
|
26 #define __CBULKONLYTRANSPORTUSBCLDD_H__ |
|
27 |
|
28 #include "cbulkonlytransport.h" |
|
29 #include "cactivedevicestatenotifierbase.h" |
|
30 |
|
31 // Maximum size for SCSI Read10 Write10 and Verify10 commands |
|
32 // Windows requests size of 64K whereas MAC requests size of 128K |
|
33 static const TUint32 KMaxBufSize = 128 * 1024; |
|
34 |
|
35 //Forward Declaration |
|
36 class CBulkOnlyTransportUsbcLdd; |
|
37 |
|
38 /** |
|
39 Represent session with control endpoint (Ep0). |
|
40 handles the control interface, and responds to the class specific commands (RESET and GET_MAX_LUN). |
|
41 */ |
|
42 class CControlInterfaceUsbcLdd : public CActive |
|
43 { |
|
44 public: |
|
45 enum TControlState |
|
46 { |
|
47 ENone, |
|
48 EReadEp0Data, |
|
49 ESendMaxLun |
|
50 }; |
|
51 |
|
52 public: |
|
53 static CControlInterfaceUsbcLdd* NewL(CBulkOnlyTransportUsbcLdd& aParent); |
|
54 ~CControlInterfaceUsbcLdd(); |
|
55 TInt Start(); |
|
56 void Stop(); |
|
57 virtual void RunL(); |
|
58 virtual void DoCancel(); |
|
59 |
|
60 private: |
|
61 CControlInterfaceUsbcLdd(CBulkOnlyTransportUsbcLdd& aParent); |
|
62 void ConstructL(); |
|
63 TInt ReadEp0Data(); |
|
64 void DecodeEp0Data(); |
|
65 TInt ReadUsbEp0(); |
|
66 |
|
67 private: |
|
68 /** Buffer for request data*/ |
|
69 TBuf8<KRequestHdrSize> iData; |
|
70 |
|
71 TUsbRequestHdr iRequestHeader; |
|
72 |
|
73 /** reference to the CBulkOnlyTransport*/ |
|
74 CBulkOnlyTransportUsbcLdd& iParent; |
|
75 |
|
76 /** represent carrent state for state mashine */ |
|
77 TControlState iCurrentState; |
|
78 }; |
|
79 |
|
80 |
|
81 /** Transport Class that accessess the Non-SC LDD */ |
|
82 class CBulkOnlyTransportUsbcLdd : public CBulkOnlyTransport, public MLddDeviceStateNotification |
|
83 { |
|
84 public: |
|
85 CBulkOnlyTransportUsbcLdd(TInt aNumDrives,CUsbMassStorageController& aController); |
|
86 |
|
87 ~CBulkOnlyTransportUsbcLdd(); |
|
88 void ConstructL(); |
|
89 |
|
90 RDevUsbcClient& Ldd(); |
|
91 TInt BytesAvailable(); // from Mtransport base class |
|
92 |
|
93 TInt SetupConfigurationDescriptor(TBool aUnset = EFalse); |
|
94 TInt SetupInterfaceDescriptors(); |
|
95 void ReleaseInterface(); |
|
96 void CancelControlInterface(); |
|
97 TInt StartControlInterface(); |
|
98 void ActivateDeviceStateNotifier(); |
|
99 void CancelDeviceStateNotifier(); |
|
100 void CancelReadWriteRequests(); |
|
101 void AllocateEndpointResources(); |
|
102 TInt GetDeviceStatus(TUsbcDeviceState& deviceStatus); |
|
103 void FlushData(); |
|
104 void ReadAndDiscardData(TInt aBytes); |
|
105 void ReadCBW(); |
|
106 void ExpireData(TAny* aAddress = NULL); |
|
107 void ProcessCbwEvent(); |
|
108 void StallEndpointAndWaitForClear(); |
|
109 void ReadData(TUint aLength = 0); |
|
110 void WriteUsb(TRequestStatus& aStatus, TPtrC8& aDes, TUint aLength, TBool aZlpRequired = EFalse); |
|
111 void SetCbwPtr(); |
|
112 TPtr8& SetCommandBufPtr(TUint aLength); |
|
113 TPtr8& SetDataBufPtr(); |
|
114 void SetPaddingBufPtr(TUint aLength); |
|
115 void SetCswBufPtr(TUint aLength); |
|
116 void ProcessReadingDataEvent(); |
|
117 void DiscardData(TUint aLength); |
|
118 void WriteToClient(TUint aLength); |
|
119 void SetReadDataBufPtr(TUint aLength); |
|
120 |
|
121 #ifdef MSDC_MULTITHREADED |
|
122 virtual void GetBufferPointers(TPtr8& aDes1, TPtr8& aDes2); |
|
123 #endif |
|
124 |
|
125 void Activate(TRequestStatus& aStatus, TUint& aValue); |
|
126 void Cancel(); |
|
127 |
|
128 private: |
|
129 TInt ReadUsb(TUint aLength = 0); |
|
130 |
|
131 private: |
|
132 RDevUsbcClient iLdd; |
|
133 CControlInterfaceUsbcLdd* iControlInterface; |
|
134 CActiveDeviceStateNotifierBase* iDeviceStateNotifier; |
|
135 |
|
136 /** buffer for Command Block Wrapper */ |
|
137 TBuf8 <KCbwLength> iCbwBuf; |
|
138 |
|
139 TBuf8<KCommandBufferLength> iCommandBuf; // For Responses to commands |
|
140 |
|
141 TBuf8<KMaxBufSize> iDataBuf1; // For data transfers (Reading and Writing) |
|
142 |
|
143 TBuf8<KMaxBufSize> iDataBuf2; |
|
144 |
|
145 TBool iSwap; |
|
146 /** internal buffer for CSW */ |
|
147 TBuf8<KCswLength> iCswBuf; |
|
148 |
|
149 /** internal buffer for padding */ |
|
150 TBuf8<KBOTMaxBufSize> iBuf; |
|
151 |
|
152 /** internal buffer for garbage */ |
|
153 TBuf8<512> iDiscardBuf; |
|
154 }; |
|
155 |
|
156 #endif |
|
157 |
|
158 |
|
159 |
|
160 |
|
161 |