297
|
1 |
// Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
|
0
|
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 |
/**
|
|
17 |
@file
|
|
18 |
@internalTechnology
|
|
19 |
*/
|
|
20 |
|
|
21 |
#include <e32std.h>
|
|
22 |
|
|
23 |
#include "msgservice.h"
|
|
24 |
#include "rusbhostmsdevice.h"
|
|
25 |
#include "rusbhostmslogicalunit.h"
|
297
|
26 |
|
|
27 |
#include "OstTraceDefinitions.h"
|
|
28 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
29 |
#include "rusbhostmslogicalunitTraces.h"
|
|
30 |
#endif
|
|
31 |
|
0
|
32 |
|
|
33 |
TVersion RUsbHostMsLogicalUnit::Version() const
|
297
|
34 |
{
|
|
35 |
return(TVersion(KUsbHostMsSrvMajorVersionNumber,
|
0
|
36 |
KUsbHostMsSrvMinorVersionNumber,
|
|
37 |
KUsbHostMsSrvBuildVersionNumber));
|
297
|
38 |
}
|
0
|
39 |
|
|
40 |
EXPORT_C RUsbHostMsLogicalUnit::RUsbHostMsLogicalUnit()
|
297
|
41 |
{
|
|
42 |
// Intentionally left blank
|
|
43 |
}
|
0
|
44 |
|
|
45 |
/**
|
|
46 |
Send a command to initialise the Mass Storage device.
|
|
47 |
|
|
48 |
@param aMsg
|
|
49 |
@param aDevHandleIndex
|
|
50 |
@param aLun
|
|
51 |
|
|
52 |
@return TInt
|
|
53 |
*/
|
|
54 |
EXPORT_C TInt RUsbHostMsLogicalUnit::Initialise(const RMessage2& aMsg,
|
|
55 |
TInt aDevHandleIndex,
|
297
|
56 |
TUint32 aLun)
|
|
57 |
{
|
|
58 |
TInt r = dev.Open(aMsg, aDevHandleIndex);
|
|
59 |
if (r != KErrNone)
|
|
60 |
{
|
|
61 |
OstTrace1(TRACE_SHOSTMASSSTORAGE_HOST, RUSBHOSTMSLOGICALUNIT_11,
|
|
62 |
"Session handle can not be opened %d", r);
|
|
63 |
return r;
|
|
64 |
}
|
0
|
65 |
|
297
|
66 |
r = CreateSubSession(dev, EUsbHostMsRegisterLun, TIpcArgs(aLun));
|
|
67 |
if (r != KErrNone)
|
|
68 |
{
|
|
69 |
OstTrace1(TRACE_SHOSTMASSSTORAGE_HOST, RUSBHOSTMSLOGICALUNIT_12,
|
|
70 |
"SubSession creation failed %d", r);
|
|
71 |
return r;
|
|
72 |
}
|
|
73 |
return r;
|
|
74 |
}
|
0
|
75 |
|
|
76 |
|
|
77 |
/**
|
|
78 |
Send a command to read the Mass Storage device.
|
|
79 |
|
|
80 |
@param aPos Position to start reading from
|
|
81 |
@param aLength Number of Bytes
|
|
82 |
@param aTrg Buffer to copy data to
|
|
83 |
|
|
84 |
@return TInt KErrNone, if the send operation is successful;
|
297
|
85 |
KErrServerTerminated, if the server no longer present; KErrServerBusy, if there are no message slots available;
|
|
86 |
KErrNoMemory, if there is insufficient memory available.
|
0
|
87 |
*/
|
|
88 |
EXPORT_C TInt RUsbHostMsLogicalUnit::Read(TInt64 aPos, TInt aLength, TDes8& aTrg)
|
297
|
89 |
{
|
|
90 |
TReadWrite data;
|
|
91 |
data.iPos = aPos;
|
|
92 |
data.iLen = aLength;
|
0
|
93 |
|
297
|
94 |
OstTraceExt3(TRACE_SHOSTMASSSTORAGE_HOST, RUSBHOSTMSLOGICALUNIT_21,
|
|
95 |
"pos = 0x%x %x, len = x%x", I64HIGH(data.iPos), I64LOW(data.iPos), data.iLen);
|
0
|
96 |
|
297
|
97 |
TPckg<TReadWrite> pckg(data);
|
|
98 |
/* We handle the message asynchronously in the thread modelled MSC */
|
|
99 |
TRequestStatus status;
|
|
100 |
SendReceive(EUsbHostMsRead, TIpcArgs(&pckg, &aTrg), status);
|
|
101 |
User::WaitForRequest(status);
|
|
102 |
OstTraceExt3(TRACE_SHOSTMASSSTORAGE_HOST, RUSBHOSTMSLOGICALUNIT_22,
|
|
103 |
"pos = 0x%x %x, len = x%x", I64HIGH(data.iPos), I64LOW(data.iPos), data.iLen);
|
|
104 |
return status.Int();
|
|
105 |
}
|
0
|
106 |
|
|
107 |
|
|
108 |
/**
|
|
109 |
Send a command to write to the Mass Storage device.
|
|
110 |
|
|
111 |
@param aPos Position to start reading from
|
|
112 |
@param aLength Number of Bytes
|
|
113 |
@param aTrg Buffer to copy data from
|
|
114 |
|
|
115 |
@return TInt KErrNone, if the send operation is successful;
|
297
|
116 |
KErrServerTerminated, if the server no longer present; KErrServerBusy, if there are no message slots available;
|
|
117 |
KErrNoMemory, if there is insufficient memory available.
|
0
|
118 |
available.
|
|
119 |
*/
|
|
120 |
EXPORT_C TInt RUsbHostMsLogicalUnit::Write(TInt64 aPos, TInt aLength, const TDesC8& aTrg)
|
297
|
121 |
{
|
|
122 |
TReadWrite data;
|
|
123 |
data.iPos = aPos;
|
|
124 |
data.iLen = aLength;
|
0
|
125 |
|
297
|
126 |
OstTraceExt3(TRACE_SHOSTMASSSTORAGE_HOST, RUSBHOSTMSLOGICALUNIT_23,
|
|
127 |
"pos = 0x%x %x, len = x%x", I64HIGH(data.iPos), I64LOW(data.iPos), data.iLen);
|
0
|
128 |
|
|
129 |
|
297
|
130 |
TPckg<TReadWrite> pckg(data);
|
|
131 |
/* We handle the message asynchronously in the thread modelled MSC */
|
|
132 |
TRequestStatus status;
|
|
133 |
SendReceive(EUsbHostMsWrite, TIpcArgs(&aTrg, &pckg), status);
|
|
134 |
User::WaitForRequest(status);
|
|
135 |
return status.Int();
|
|
136 |
}
|
0
|
137 |
|
|
138 |
|
|
139 |
/**
|
|
140 |
Send a command to erase an area of the Mass Storage device.
|
|
141 |
|
|
142 |
@param aPos Position to start reading from
|
|
143 |
@param aLength Number of Bytes
|
|
144 |
|
|
145 |
@return TInt KErrNone, if the send operation is successful;
|
297
|
146 |
KErrServerTerminated, if the server no longer present; KErrServerBusy, if there are no message slots available;
|
|
147 |
KErrNoMemory, if there is insufficient memory available.
|
0
|
148 |
available.
|
|
149 |
*/
|
|
150 |
EXPORT_C TInt RUsbHostMsLogicalUnit::Erase(TInt64 aPos, TInt aLength)
|
297
|
151 |
{
|
|
152 |
TReadWrite data;
|
|
153 |
data.iPos = aPos;
|
|
154 |
data.iLen = aLength;
|
0
|
155 |
|
297
|
156 |
OstTraceExt3(TRACE_SHOSTMASSSTORAGE_HOST, RUSBHOSTMSLOGICALUNIT_24,
|
|
157 |
"pos = 0x%x %x, len = x%x", I64HIGH(data.iPos), I64LOW(data.iPos), data.iLen);
|
0
|
158 |
|
297
|
159 |
TPckg<TReadWrite> pckg(data);
|
|
160 |
/* We handle the message asynchronously in the thread modelled MSC */
|
|
161 |
TRequestStatus status;
|
|
162 |
SendReceive(EUsbHostMsErase, TIpcArgs(&pckg), status);
|
|
163 |
User::WaitForRequest(status);
|
|
164 |
return status.Int();
|
|
165 |
}
|
0
|
166 |
|
|
167 |
|
|
168 |
/**
|
|
169 |
Send a command to get the nedia's capacity info.
|
|
170 |
|
|
171 |
@param aCapsInfo [OUT] A buffer to copy the capacity info to.
|
|
172 |
|
|
173 |
@return TInt KErrNone, if the send operation is successful;
|
|
174 |
KErrServerTerminated, if the server no longer present; KErrServerBusy, if there
|
|
175 |
are no message slots available; KErrNoMemory, if there is insufficient memory
|
|
176 |
available.
|
|
177 |
*/
|
|
178 |
EXPORT_C TInt RUsbHostMsLogicalUnit::Caps(TCapsInfo& aCapsInfo)
|
297
|
179 |
{
|
0
|
180 |
TPckg<TCapsInfo> data(aCapsInfo);
|
|
181 |
|
297
|
182 |
/* We handle the message asynchronously in the thread modelled MSC */
|
|
183 |
TRequestStatus status;
|
|
184 |
SendReceive(EUsbHostMsCapacity, TIpcArgs(&data),status);
|
|
185 |
User::WaitForRequest(status);
|
|
186 |
return status.Int();
|
|
187 |
}
|
0
|
188 |
|
|
189 |
/**
|
|
190 |
Request notification of media change to the file server
|
|
191 |
|
|
192 |
@param aChanged The descriptor pointing to iChanged flag in TDrive to be updated
|
|
193 |
when error occurs during read or write.
|
|
194 |
@param aStatus The request status This is set to KErrNone on completion, or KErrCancel when the logical unit is closed;
|
297
|
195 |
KErrServerTerminated, if the server no longer present; KErrServerBusy, if there are no message slots available;
|
|
196 |
KErrNoMemory, if there is insufficient memory available.
|
0
|
197 |
@return None
|
|
198 |
*/
|
|
199 |
EXPORT_C void RUsbHostMsLogicalUnit::NotifyChange(TDes8& aChanged, TRequestStatus &aStatus)
|
297
|
200 |
{
|
|
201 |
SendReceive(EUsbHostMsNotifyChange, TIpcArgs(&aChanged), aStatus);
|
|
202 |
}
|
0
|
203 |
|
|
204 |
/**
|
|
205 |
Request to suspend the logical unit associated with this drive
|
|
206 |
*/
|
|
207 |
EXPORT_C void RUsbHostMsLogicalUnit::SuspendLun()
|
297
|
208 |
{
|
|
209 |
SendReceive(EUsbHostMsSuspendLun, TIpcArgs(NULL));
|
|
210 |
}
|
0
|
211 |
|
|
212 |
/**
|
|
213 |
Close the sub-session.
|
|
214 |
|
|
215 |
@return TInt KErrNone
|
|
216 |
*/
|
|
217 |
EXPORT_C TInt RUsbHostMsLogicalUnit::UnInitialise()
|
297
|
218 |
{
|
|
219 |
CloseSubSession(EUsbHostMsUnRegisterLun);
|
|
220 |
dev.Close();
|
|
221 |
return KErrNone;
|
|
222 |
}
|
0
|
223 |
|
|
224 |
|
|
225 |
/**
|
|
226 |
Request that the drive is remounted.
|
|
227 |
|
|
228 |
@param aFlags Flags to be passed to the drive
|
|
229 |
|
|
230 |
@return EXPORT_C TInt KErrNone, if the send operation is successful;
|
|
231 |
KErrServerTerminated, if the server no longer present; KErrServerBusy, if there
|
|
232 |
are no message slots available; KErrNoMemory, if there is insufficient memory
|
|
233 |
available.
|
|
234 |
*/
|
|
235 |
EXPORT_C TInt RUsbHostMsLogicalUnit::ForceRemount(TUint aFlags)
|
297
|
236 |
{
|
|
237 |
OstTrace1(TRACE_SHOSTMASSSTORAGE_HOST, RUSBHOSTMSLOGICALUNIT_25,
|
|
238 |
"flags = %d", aFlags);
|
0
|
239 |
|
297
|
240 |
TRequestStatus status;
|
|
241 |
SendReceive(EUsbHostMsForceRemount, TIpcArgs(aFlags), status);
|
|
242 |
User::WaitForRequest(status);
|
|
243 |
return status.Int();
|
|
244 |
}
|
0
|
245 |
|
|
246 |
EXPORT_C void RUsbHostMsLogicalUnit::NotifyChangeCancel()
|
297
|
247 |
{
|
|
248 |
SendReceive(EUsbHostMsCancelChangeNotifier, TIpcArgs(NULL));
|
|
249 |
}
|