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