author | William Roberts <williamr@symbian.org> |
Tue, 06 Jul 2010 13:05:35 +0100 | |
branch | GCC_SURGE |
changeset 195 | 3411883d8fcf |
parent 109 | b3a1d9898418 |
child 139 | 95f71bcdcdb7 |
permissions | -rw-r--r-- |
102
ef2a444a7410
Revision: 201018
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1 |
// Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). |
ef2a444a7410
Revision: 201018
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2 |
// All rights reserved. |
ef2a444a7410
Revision: 201018
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3 |
// This component and the accompanying materials are made available |
ef2a444a7410
Revision: 201018
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4 |
// under the terms of the License "Eclipse Public License v1.0" |
ef2a444a7410
Revision: 201018
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5 |
// which accompanies this distribution, and is available |
ef2a444a7410
Revision: 201018
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
0 | 7 |
// |
102
ef2a444a7410
Revision: 201018
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
8 |
// Initial Contributors: |
ef2a444a7410
Revision: 201018
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
9 |
// Nokia Corporation - initial contribution. |
0 | 10 |
// |
102
ef2a444a7410
Revision: 201018
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
11 |
// Contributors: |
ef2a444a7410
Revision: 201018
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
12 |
// |
ef2a444a7410
Revision: 201018
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
13 |
// Description: |
ef2a444a7410
Revision: 201018
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
14 |
// This file system extension provides a way to access a drive on the MS system |
ef2a444a7410
Revision: 201018
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
15 |
// in "raw format". It can be used to test large files / drives |
0 | 16 |
// |
17 |
||
18 |
/** @file |
|
19 |
@internalTechnology |
|
20 |
*/ |
|
21 |
||
22 |
#include <f32fsys.h> |
|
23 |
||
24 |
#include "hostusbmsproxy.h" |
|
25 |
#include "debug.h" |
|
26 |
||
27 |
||
28 |
CUsbHostMsProxyDrive::CUsbHostMsProxyDrive(CMountCB* aMount, CExtProxyDriveFactory* aDevice) |
|
29 |
: CExtProxyDrive(aMount,aDevice) |
|
30 |
{ |
|
31 |
__MSFNSLOG |
|
32 |
} |
|
33 |
||
34 |
CUsbHostMsProxyDrive::~CUsbHostMsProxyDrive() |
|
35 |
{ |
|
36 |
__MSFNSLOG |
|
37 |
iUsbHostMsLun.UnInitialise(); |
|
38 |
} |
|
39 |
||
40 |
TInt CUsbHostMsProxyDrive::InitialiseOffset(TCapsInfo& aCapsInfo) |
|
41 |
{ |
|
42 |
__MSFNSLOG |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
43 |
RBuf8 partitionInfo; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
44 |
TInt r; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
45 |
TRAP(r, partitionInfo.CreateL(aCapsInfo.iBlockLength)); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
46 |
if (r != KErrNone) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
47 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
48 |
return r; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
49 |
} |
0 | 50 |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
51 |
r = iUsbHostMsLun.Read(0, aCapsInfo.iBlockLength, partitionInfo); |
0 | 52 |
if (r != KErrNone) |
53 |
{ |
|
54 |
__PXYPRINT1(_L("!! Reading medium failed with %d !!"), r); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
55 |
partitionInfo.Close(); |
0 | 56 |
return r; |
57 |
} |
|
58 |
TUint8 *iIntBuf = (TUint8 *) partitionInfo.Ptr(); |
|
59 |
||
60 |
// Read of the first sector successful so check for a Master Boot Record |
|
61 |
if (*(TUint16*)(&iIntBuf[KMBRSignatureOffset])!= KMBRSignature) |
|
62 |
{ |
|
63 |
__PXYPRINT(_L("MBR not present")); |
|
64 |
iMsDataMemMap.Reset(); |
|
65 |
} |
|
66 |
else |
|
67 |
{ |
|
68 |
// Move the partition entries to a 4 byte boundary |
|
69 |
memcpy(&iIntBuf[0],&iIntBuf[KMBRFirstPartitionOffset],(sizeof(TMBRPartitionEntry)<<2)); |
|
70 |
// Search for a x86 default boot partition - let this be the first |
|
71 |
TMBRPartitionEntry* pe = (TMBRPartitionEntry*)(&iIntBuf[0]); |
|
72 |
||
73 |
TInt firstValidPartitionCount = -1; |
|
74 |
TInt defaultPartitionNumber = -1; |
|
75 |
TInt partitionCount = 0; |
|
76 |
for (TInt i = 0; i < KMBRMaxPrimaryPartitions; i++, pe++) |
|
77 |
{ |
|
78 |
if (pe->IsValidDosPartition() || pe->IsValidFAT32Partition()) |
|
79 |
{ |
|
80 |
__PXYPRINT(_L("Found a Valid Partition")); |
|
81 |
partitionCount++; |
|
82 |
||
83 |
if (firstValidPartitionCount < 0) |
|
84 |
firstValidPartitionCount = i; |
|
85 |
||
86 |
if (pe->iX86BootIndicator == KBootIndicatorBootable) |
|
87 |
{ |
|
88 |
defaultPartitionNumber = i; |
|
89 |
break; |
|
90 |
} |
|
91 |
} |
|
92 |
else |
|
93 |
{ |
|
94 |
__PXYPRINT(_L("!! Invalid Partition !!")); |
|
95 |
} |
|
96 |
} |
|
97 |
||
98 |
// Check the validity of the partition address boundaries |
|
99 |
if (partitionCount > 0) |
|
100 |
{ |
|
101 |
__PXYPRINT1(_L("Using Partition %d"), partitionCount); |
|
102 |
pe = (TMBRPartitionEntry*)(&iIntBuf[0]); |
|
103 |
TInt partitionIndex = firstValidPartitionCount; |
|
104 |
if (defaultPartitionNumber > 0) |
|
105 |
{ |
|
106 |
partitionIndex = defaultPartitionNumber; |
|
107 |
} |
|
108 |
||
109 |
TMBRPartitionEntry& partitionEntry = pe[partitionIndex]; |
|
110 |
||
111 |
iMsDataMemMap.InitDataArea(partitionEntry.iFirstSector, |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
112 |
partitionEntry.iNumSectors, |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
113 |
aCapsInfo.iBlockLength); |
0 | 114 |
__PXYPRINT2(_L("paritioncount = %d defaultpartition = %d"), |
115 |
partitionCount, partitionIndex); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
116 |
__PXYPRINT3(_L("iFirstSector = x%x iNumSectors = x%x iSectorSize = x%x"), |
0 | 117 |
partitionEntry.iFirstSector, |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
118 |
partitionEntry.iNumSectors, |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
119 |
aCapsInfo.iBlockLength); |
0 | 120 |
} |
121 |
else |
|
122 |
{ |
|
123 |
__PXYPRINT(_L("No partition found")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
124 |
iMsDataMemMap.InitDataArea(0, aCapsInfo.iNumberOfBlocks, aCapsInfo.iBlockLength); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
125 |
__PXYPRINT3(_L("iFirstSector = x%x iNumSectors = x%x iSectorSize = x%x"), |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
126 |
0, |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
127 |
aCapsInfo.iNumberOfBlocks, |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
128 |
aCapsInfo.iBlockLength); |
0 | 129 |
} |
130 |
} |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
131 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
132 |
partitionInfo.Close(); |
0 | 133 |
return KErrNone; |
134 |
} |
|
135 |
||
136 |
/** |
|
137 |
Initialise the proxy drive. |
|
138 |
@return system wide error code. |
|
139 |
*/ |
|
140 |
TInt CUsbHostMsProxyDrive::Initialise() |
|
141 |
{ |
|
142 |
__MSFNSLOG |
|
143 |
__HOSTPRINT(_L(">>> CUsbHostMsProxyDrive::Initialise()")); |
|
144 |
||
145 |
if(Mount()) |
|
146 |
{ |
|
147 |
// as we can't currently handle remounting devices that have |
|
148 |
// been removed by unplugging the USB cable, disable critical notifiers |
|
149 |
// as there's no point in asking the user to re-insert the disk. |
|
150 |
Mount()->SetNotifyOff(); |
|
151 |
} |
|
152 |
||
153 |
// Check for media presence |
|
154 |
TCapsInfo capsInfo; |
|
155 |
TInt err = iUsbHostMsLun.Caps(capsInfo); |
|
156 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
157 |
if (err == KErrNone && capsInfo.iMediaType == EMediaHardDisk) |
0 | 158 |
{ |
159 |
err = InitialiseOffset(capsInfo); |
|
160 |
} |
|
161 |
||
162 |
__HOSTPRINT1(_L("<<< CUsbHostMsProxyDrive::Initialise() err = %d"), err); |
|
163 |
return err; |
|
164 |
} |
|
165 |
||
166 |
TInt CUsbHostMsProxyDrive::SetInfo(const RMessage2 &msg, TAny* aMessageParam2, TAny* aMessageParam3) |
|
167 |
{ |
|
168 |
__MSFNSLOG |
|
169 |
__HOSTPRINT(_L(">>> CUsbHostMsProxyDrive::SetInfo()")); |
|
170 |
TMassStorageUnitInfo iUnitInfo; |
|
171 |
TPckg<TMassStorageUnitInfo> infoPckg(iUnitInfo); |
|
172 |
TRAPD(err, msg.ReadL(2, infoPckg)); |
|
173 |
||
174 |
if(err != KErrNone) |
|
175 |
{ |
|
176 |
__PXYPRINT1(_L("Cant read from the RMessage %d"), err); |
|
177 |
__HOSTPRINT1(_L("<<< CUsbHostMsProxyDrive::SetInfo() err = %d"), err); |
|
178 |
return err; |
|
179 |
} |
|
180 |
||
181 |
err = iUsbHostMsLun.Initialise(msg, 3, iUnitInfo.iLunID); |
|
182 |
if(err != KErrNone) |
|
183 |
{ |
|
184 |
__PXYPRINT1(_L("Initialising logical unit failed %d"), err); |
|
185 |
__HOSTPRINT1(_L("<<< CUsbHostMsProxyDrive::SetInfo() err = %d"), err); |
|
186 |
return err; |
|
187 |
} |
|
188 |
||
189 |
__HOSTPRINT1(_L("<<< CUsbHostMsProxyDrive::SetInfo() err = %d"), err); |
|
190 |
return err; |
|
191 |
} |
|
192 |
||
193 |
TInt CUsbHostMsProxyDrive::Dismounted() |
|
194 |
{ |
|
195 |
__MSFNSLOG |
|
196 |
return KErrNone; |
|
197 |
} |
|
198 |
||
199 |
TInt CUsbHostMsProxyDrive::Enlarge(TInt /*aLength*/) |
|
200 |
{ |
|
201 |
__MSFNSLOG |
|
202 |
return KErrNotSupported; |
|
203 |
} |
|
204 |
||
205 |
||
206 |
TInt CUsbHostMsProxyDrive::ReduceSize(TInt /*aPos*/, TInt /*aLength*/) |
|
207 |
{ |
|
208 |
__MSFNSLOG |
|
209 |
return KErrNotSupported; |
|
210 |
} |
|
211 |
||
212 |
#define GetIndex(msg, aAddress, aIndex) \ |
|
213 |
aIndex = msg.Ptr0() == aAddress ? 0 : \ |
|
214 |
msg.Ptr1() == aAddress ? 1 : \ |
|
215 |
msg.Ptr1() == aAddress ? 2 : \ |
|
216 |
msg.Ptr1() == aAddress ? 3 : -1; |
|
217 |
||
218 |
/** |
|
219 |
Read from the proxy drive. |
|
220 |
||
221 |
@param aPos The address from where the read begins. |
|
222 |
@param aLength The length of the read. |
|
223 |
@param aTrg A descriptor of the memory buffer from which to read. |
|
224 |
@param aThreadHandle The handle-number representing the drive thread. |
|
225 |
@param aOffset Offset into aTrg to read the data from. |
|
226 |
||
227 |
@return system wide error code. |
|
228 |
*/ |
|
229 |
TInt CUsbHostMsProxyDrive::Read(TInt64 aPos, TInt aLength, |
|
230 |
const TAny* aTrg, TInt aThreadHandle, TInt aOffset) |
|
231 |
{ |
|
232 |
__MSFNSLOG |
|
233 |
__HOSTPRINT4(_L("\n>>> HOST Read Pos=0x%lx LBA=0x%lx 0x%x 0x%x"), |
|
234 |
aPos, aPos/KBlockSize, aLength, aOffset); |
|
235 |
||
236 |
TBool localMessage = (aThreadHandle == KLocalMessageHandle); |
|
237 |
||
238 |
// |
|
239 |
// Set file position to where we want to read... |
|
240 |
// |
|
241 |
if(!localMessage) |
|
242 |
{ |
|
243 |
RMessage2 msg(*(RMessagePtr2 *) &aThreadHandle); |
|
244 |
localMessage = (msg.Handle() == KLocalMessageHandle); |
|
245 |
} |
|
246 |
||
247 |
TInt index = 0; |
|
248 |
if (!localMessage) |
|
249 |
{ |
|
250 |
RMessage2 msg(*(RMessagePtr2 *) &aThreadHandle); |
|
251 |
GetIndex(msg, aTrg, index); |
|
252 |
||
253 |
if (index < 0) |
|
254 |
{ |
|
255 |
__HOSTPRINT1(_L("<<< HOST Read ret=%d"), KErrArgument); |
|
256 |
return KErrArgument; |
|
257 |
} |
|
258 |
} |
|
259 |
||
260 |
/* Calculate the end position */ |
|
261 |
TInt64 end = aPos + static_cast<TInt64>(aLength); |
|
262 |
||
263 |
/* check whether there is enough source data to write to the destination descriptor */ |
|
264 |
TInt64 truncate; |
|
265 |
if(localMessage) |
|
266 |
{ |
|
267 |
truncate = aLength - (((TPtr8* )aTrg)->MaxLength() - aOffset); |
|
268 |
__PXYPRINT1(_L("Descriptor length: %08x"), ((TPtr8* )aTrg)->MaxLength()); |
|
269 |
} |
|
270 |
else |
|
271 |
{ |
|
272 |
RMessage2 msg(*(RMessagePtr2 *) &aThreadHandle); |
|
273 |
truncate = aLength - (msg.GetDesMaxLength(index) - aOffset); |
|
274 |
__PXYPRINT1(_L("Descriptor length: %08x"), msg.GetDesMaxLength(index)); |
|
275 |
} |
|
276 |
||
277 |
__PXYPRINT1(_L("Offset: %08x"), aOffset); |
|
278 |
__PXYPRINT1(_L("Truncate: 0x%lx"), truncate); |
|
279 |
||
280 |
if (truncate > 0) |
|
281 |
{ |
|
282 |
end -= truncate; |
|
283 |
} |
|
284 |
||
285 |
iBuf.SetMax(); |
|
286 |
TInt r; |
|
287 |
TInt64 mediaPos; |
|
288 |
while (aPos < end) |
|
289 |
{ |
|
290 |
TInt len = end - aPos; |
|
291 |
mediaPos = aPos; |
|
292 |
r = iMsDataMemMap.CheckBlockInRange(mediaPos, len); |
|
293 |
if (r != KErrNone) |
|
294 |
{ |
|
295 |
__HOSTPRINT1(_L("<<< HOST Read ret=%d"), r); |
|
296 |
return r; |
|
297 |
} |
|
298 |
||
299 |
if (localMessage) |
|
300 |
{ |
|
301 |
TPtr8* pTrgPtr = (TPtr8*)aTrg; |
|
302 |
TPtr8 trgDes((TUint8*)(pTrgPtr->MidTPtr(aOffset).Ptr()), pTrgPtr->MaxLength() - aOffset); |
|
303 |
r = iUsbHostMsLun.Read(mediaPos, len, trgDes); |
|
304 |
if (r != KErrNone) |
|
305 |
return r; |
|
306 |
pTrgPtr->SetLength(aOffset + trgDes.Length()); |
|
307 |
} |
|
308 |
else |
|
309 |
{ |
|
310 |
if (len > iBuf.MaxLength()) |
|
311 |
len = iBuf.MaxLength(); |
|
312 |
||
313 |
r = iUsbHostMsLun.Read(mediaPos, len, iBuf); |
|
314 |
if (r != KErrNone) |
|
315 |
{ |
|
316 |
__HOSTPRINT1(_L("<<< HOST Read ret=%d"), r); |
|
317 |
return r; |
|
318 |
} |
|
319 |
||
320 |
iBuf.SetLength(len); |
|
321 |
||
322 |
RMessage2 msg(*(RMessagePtr2 *) &aThreadHandle); |
|
323 |
r = msg.Write(index, iBuf, aOffset); |
|
324 |
if (r != KErrNone) |
|
325 |
{ |
|
326 |
__HOSTPRINT1(_L("<<< HOST Read ret=%d"), r); |
|
327 |
return r; |
|
328 |
} |
|
329 |
} |
|
330 |
||
331 |
aPos += len; |
|
332 |
aOffset += len; |
|
333 |
} |
|
334 |
||
335 |
__HOSTPRINT1(_L("<<< HOST Read ret=%d"), KErrNone); |
|
336 |
return KErrNone; |
|
337 |
} |
|
338 |
||
339 |
||
340 |
/** |
|
341 |
Read from the proxy drive, and pass flags to driver. |
|
342 |
||
343 |
@param aPos The address from where the read begins. |
|
344 |
@param aLength The length of the read. |
|
345 |
@param aTrg A descriptor of the memory buffer from which to read. |
|
346 |
@param aThreadHandle The handle-number representing the drive thread. |
|
347 |
@param aOffset Offset into aTrg to read the data from. |
|
348 |
@param aFlags Flags to be passed into the driver. |
|
349 |
||
350 |
@return system wide error code. |
|
351 |
*/ |
|
352 |
TInt CUsbHostMsProxyDrive::Read(TInt64 aPos, TInt aLength, |
|
353 |
const TAny* aTrg, TInt aThreadHandle, TInt aOffset, TInt /* aFlags */) |
|
354 |
{ |
|
355 |
__MSFNSLOG |
|
356 |
return Read(aPos, aLength, aTrg, aThreadHandle, aOffset); |
|
357 |
} |
|
358 |
||
359 |
/** |
|
360 |
Read from the proxy drive. |
|
361 |
||
362 |
@param aPos The address from where the read begins. |
|
363 |
@param aLength The length of the read. |
|
364 |
@param aTrg A descriptor of the memory buffer from which to read. |
|
365 |
||
366 |
@return system wide error code. |
|
367 |
*/ |
|
368 |
TInt CUsbHostMsProxyDrive::Read(TInt64 aPos, TInt aLength, TDes8& aTrg) |
|
369 |
{ |
|
370 |
__MSFNSLOG |
|
371 |
__HOSTPRINT3(_L("\n>>> HOST Read Pos=0x%lx LBA=0x%lx 0x%x"), |
|
372 |
aPos, aPos/KBlockSize, aLength); |
|
373 |
return iUsbHostMsLun.Read(iMsDataMemMap.GetDataPos(aPos), aLength, aTrg); |
|
374 |
} |
|
375 |
||
376 |
/** |
|
377 |
Write to the proxy drive. |
|
378 |
||
379 |
@param aPos The address from where the write begins. |
|
380 |
@param aLength The length of the write. |
|
381 |
@param aSrc A descriptor of the memory buffer from which to write. |
|
382 |
@param aThreadHandle The handle-number representing the drive thread. |
|
383 |
@param aOffset Offset into aSrc to write the data to. |
|
384 |
||
385 |
@return system wide error code. |
|
386 |
*/ |
|
387 |
TInt CUsbHostMsProxyDrive::Write(TInt64 aPos, TInt aLength, |
|
388 |
const TAny* aSrc, TInt aThreadHandle, TInt aOffset) |
|
389 |
{ |
|
390 |
// |
|
391 |
// Set file position to where we want to write... |
|
392 |
// |
|
393 |
__MSFNSLOG |
|
394 |
__HOSTPRINT4(_L("\n>>> HOST Write Pos=0x%lx LBA=0%lx 0x%x 0x%x"), |
|
395 |
aPos, aPos/KBlockSize, aLength, aOffset); |
|
396 |
||
397 |
TBool localMessage = (aThreadHandle == KLocalMessageHandle); |
|
398 |
||
399 |
if(!localMessage) |
|
400 |
{ |
|
401 |
RMessage2 msg(*(RMessagePtr2 *) &aThreadHandle); |
|
402 |
localMessage = (msg.Handle() == KLocalMessageHandle); |
|
403 |
} |
|
404 |
||
405 |
TInt index = 0; |
|
406 |
if(!localMessage) |
|
407 |
{ |
|
408 |
RMessage2 msg(*(RMessagePtr2 *) &aThreadHandle); |
|
409 |
GetIndex(msg, aSrc, index); |
|
410 |
||
411 |
if (index < 0) |
|
412 |
return KErrArgument; |
|
413 |
} |
|
414 |
||
415 |
/* Calculate the end position */ |
|
416 |
TInt64 end = aPos + static_cast<TInt64>(aLength); |
|
417 |
/* check whether there is enough source data to read */ |
|
418 |
TInt64 truncate; |
|
419 |
if (localMessage) |
|
420 |
{ |
|
421 |
truncate = aLength - (((TPtr8* )aSrc)->Length() - aOffset); |
|
422 |
__PXYPRINT1(_L("Descriptor length: %08x"), ((TPtr8* )aSrc)->Length()); |
|
423 |
} |
|
424 |
else |
|
425 |
{ |
|
426 |
RMessage2 msg(*(RMessagePtr2 *) &aThreadHandle); |
|
427 |
truncate = aLength - (msg.GetDesLength(index) - aOffset); |
|
428 |
__PXYPRINT1(_L("Descriptor length: %08x"), msg.GetDesLength(index)); |
|
429 |
} |
|
430 |
||
431 |
__PXYPRINT1(_L("Offset: %08x"), aOffset); |
|
432 |
__PXYPRINT1(_L("Truncate: 0x%lx"), truncate); |
|
433 |
||
434 |
/* if truncate is > 0 we are short of source data as claimed by the aLength. Hence adjust the 'end' */ |
|
435 |
if (truncate > 0) |
|
436 |
{ |
|
437 |
end -= truncate; |
|
438 |
} |
|
439 |
||
440 |
iBuf.SetMax(); |
|
441 |
||
442 |
TInt r; |
|
443 |
TInt64 mediaPos; |
|
444 |
while (aPos < end) |
|
445 |
{ |
|
446 |
TInt len = end - aPos; |
|
447 |
mediaPos = aPos; |
|
448 |
r = iMsDataMemMap.CheckBlockInRange(mediaPos, len); |
|
449 |
if (r != KErrNone) |
|
450 |
{ |
|
451 |
__HOSTPRINT1(_L("<<< HOST Write ret=%d"), r); |
|
452 |
return r; |
|
453 |
} |
|
454 |
||
455 |
if (localMessage) |
|
456 |
{ |
|
457 |
r = iUsbHostMsLun.Write(mediaPos, len, ((TPtr8*)aSrc)->MidTPtr(aOffset)); |
|
458 |
||
459 |
if (r != KErrNone) |
|
460 |
{ |
|
461 |
__HOSTPRINT1(_L("<<< HOST Write ret=%d"), r); |
|
462 |
return r; |
|
463 |
} |
|
464 |
} |
|
465 |
else |
|
466 |
{ |
|
467 |
if (len > iBuf.Length()) |
|
468 |
len = iBuf.Length(); |
|
469 |
||
470 |
RMessage2 msg(*(RMessagePtr2 *) &aThreadHandle); |
|
471 |
r = msg.Read(index, iBuf, aOffset); |
|
472 |
if (r != KErrNone) |
|
473 |
{ |
|
474 |
__HOSTPRINT1(_L("<<< HOST Write ret=%d"), r); |
|
475 |
return r; |
|
476 |
} |
|
477 |
||
478 |
r = iUsbHostMsLun.Write(mediaPos, len, iBuf); |
|
479 |
if (r != KErrNone) |
|
480 |
{ |
|
481 |
__HOSTPRINT1(_L("<<< HOST Write ret=%d"), r); |
|
482 |
return r; |
|
483 |
} |
|
484 |
} |
|
485 |
||
486 |
aPos += len; |
|
487 |
aOffset += len; |
|
488 |
} |
|
489 |
||
490 |
__HOSTPRINT1(_L("<<< HOST Write ret=%d"), KErrNone); |
|
491 |
return KErrNone; |
|
492 |
} |
|
493 |
||
102
ef2a444a7410
Revision: 201018
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
494 |
|
0 | 495 |
/** |
496 |
Write to the proxy drive and pass flags to driver |
|
497 |
||
498 |
@param aPos The address from where the write begins. |
|
499 |
@param aLength The length of the write. |
|
500 |
@param aSrc A descriptor of the memory buffer from which to write. |
|
501 |
@param aThreadHandle The handle-number representing the drive thread. |
|
502 |
@param aOffset Offset into aSrc to write the data to. |
|
503 |
@param aFlags Flags to be passed into the driver. |
|
504 |
||
505 |
@return system wide error code. |
|
506 |
*/ |
|
507 |
TInt CUsbHostMsProxyDrive::Write(TInt64 aPos, TInt aLength, |
|
508 |
const TAny* aSrc, TInt aThreadHandle, TInt aOffset, TInt /* aFlags */) |
|
509 |
{ |
|
510 |
__MSFNSLOG |
|
511 |
return Write(aPos, aLength, aSrc, aThreadHandle, aOffset); |
|
512 |
} |
|
513 |
||
514 |
/** |
|
515 |
Write to the proxy drive. |
|
516 |
||
517 |
@param aPos The address from where the write begins. |
|
518 |
@param aSrc A descriptor of the memory buffer from which to write. |
|
519 |
||
520 |
@return system wide error code. |
|
521 |
*/ |
|
522 |
TInt CUsbHostMsProxyDrive::Write(TInt64 aPos,const TDesC8& aSrc) |
|
523 |
{ |
|
524 |
__MSFNSLOG |
|
525 |
__HOSTPRINT3(_L("\n>>> HOST Write Pos=0x%lx LBA=0x%lx 0x%x"), |
|
526 |
aPos, aPos/KBlockSize, aSrc.Length()); |
|
527 |
return iUsbHostMsLun.Write(iMsDataMemMap.GetDataPos(aPos), aSrc.Length(), aSrc); |
|
528 |
} |
|
529 |
||
102
ef2a444a7410
Revision: 201018
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
530 |
|
0 | 531 |
/** |
532 |
Get the proxy drive's capabilities information. |
|
533 |
||
534 |
@param anInfo A descriptor of the connected drives capabilities. |
|
535 |
||
536 |
@return system wide error code |
|
537 |
*/ |
|
538 |
TInt CUsbHostMsProxyDrive::Caps(TDes8& anInfo) |
|
539 |
{ |
|
540 |
__MSFNSLOG |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
541 |
__HOSTPRINT(_L(">>> HOST Caps")); |
0 | 542 |
TLocalDriveCapsV6Buf caps; |
543 |
caps.FillZ(); |
|
544 |
||
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
545 |
TLocalDriveCapsV6& c = caps(); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
546 |
|
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
547 |
c.iConnectionBusType = EConnectionBusUsb; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
548 |
c.iDriveAtt = KDriveAttLocal | KDriveAttRemovable | KDriveAttExternal; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
549 |
c.iMediaAtt = KMediaAttFormattable; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
550 |
c.iFileSystemId = KDriveFileSysFAT; |
0 | 551 |
|
552 |
TCapsInfo capsInfo; |
|
553 |
TInt r = iUsbHostMsLun.Caps(capsInfo); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
554 |
|
0 | 555 |
if (KErrNone == r) |
556 |
{ |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
557 |
c.iType = capsInfo.iMediaType; |
0 | 558 |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
559 |
if (capsInfo.iMediaType == EMediaHardDisk) |
0 | 560 |
{ |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
561 |
c.iBlockSize = capsInfo.iBlockLength; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
562 |
TUint64 size = iMsDataMemMap.DataSize(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
563 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
564 |
if (size == 0) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
565 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
566 |
// No valid partitions so specify the size of the disk |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
567 |
size = static_cast<TUint64>(capsInfo.iNumberOfBlocks) * capsInfo.iBlockLength; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
568 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
569 |
c.iSize = size; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
570 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
571 |
c.iEraseBlockSize = 0; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
572 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
573 |
if (capsInfo.iWriteProtect) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
574 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
575 |
c.iMediaAtt |= KMediaAttWriteProtected; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
576 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
577 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
578 |
static const TInt K512ByteSectorSize = 0x200; // 512 |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
579 |
if(K512ByteSectorSize != capsInfo.iBlockLength) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
580 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
581 |
// not formattable if sector size is not 512 |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
582 |
c.iMediaAtt &= ~KMediaAttFormattable; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
583 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
584 |
__HOSTPRINT4(_L("<<< HOST Caps Block[num=0x%x size=0x%x] Media[size=0x%lx WP=0x%x]"), |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
585 |
capsInfo.iNumberOfBlocks, capsInfo.iBlockLength, |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
586 |
caps().iSize, caps().iMediaAtt); |
0 | 587 |
} |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
588 |
else if (capsInfo.iMediaType == EMediaCdRom) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
589 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
590 |
// not formattable |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
591 |
c.iMediaAtt &= ~KMediaAttFormattable; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
592 |
__HOSTPRINT(_L(">>> HOST Caps MediaType = EMediaCdRom")); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
593 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
594 |
else |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
595 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
596 |
// do nothing |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
597 |
} |
0 | 598 |
} |
102
ef2a444a7410
Revision: 201018
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
599 |
else if (KErrNotReady) |
0 | 600 |
{ |
601 |
__HOSTPRINT(_L("<<< HOST Caps Media Not Present")); |
|
102
ef2a444a7410
Revision: 201018
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
602 |
c.iType = EMediaNotPresent; |
ef2a444a7410
Revision: 201018
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
603 |
r = KErrNone; |
ef2a444a7410
Revision: 201018
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
604 |
} |
ef2a444a7410
Revision: 201018
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
605 |
else |
ef2a444a7410
Revision: 201018
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
606 |
{ |
ef2a444a7410
Revision: 201018
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
607 |
__HOSTPRINT(_L("<<< HOST Caps Unknown Error")); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
608 |
c.iType = EMediaUnknown; |
102
ef2a444a7410
Revision: 201018
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
609 |
r = KErrUnknown; |
0 | 610 |
} |
611 |
anInfo = caps.Left(Min(caps.Length(),anInfo.MaxLength())); |
|
612 |
return r; |
|
613 |
} |
|
614 |
||
615 |
||
616 |
/** |
|
617 |
Format the proxy drive. The drive is assumed to be a single partition. The |
|
618 |
partition size is equivalent to the size of the media. |
|
619 |
||
620 |
@param aPos The position of the data which is being formatted. |
|
621 |
@param aLength [IN] The length of the data which is being formatted. [OUT] The |
|
622 |
length of data formatted, truncated when end of drive is reached. |
|
623 |
||
624 |
@return system wide error code. |
|
625 |
*/ |
|
626 |
TInt CUsbHostMsProxyDrive::Erase(TInt64 aPos, TInt& aLength) |
|
627 |
{ |
|
628 |
__MSFNSLOG |
|
629 |
__HOSTPRINT3(_L("\n HOST Erase Pos=0x%lx LBA=0x%lx 0x%x"), |
|
630 |
aPos, aPos/KBlockSize, aLength); |
|
631 |
TInt err = iMsDataMemMap.TranslateDataPos(aPos, aLength); |
|
632 |
||
633 |
if (err) |
|
634 |
return err; |
|
635 |
||
636 |
err = iUsbHostMsLun.Erase(aPos, aLength); |
|
637 |
return err; |
|
638 |
} |
|
639 |
||
640 |
||
641 |
/** |
|
642 |
Format the proxy drive. |
|
643 |
||
644 |
@param aPos The position of the data which is being formatted. |
|
645 |
@param aLength The length of the data which is being formatted. |
|
646 |
||
647 |
@return system wide error code. |
|
648 |
*/ |
|
649 |
TInt CUsbHostMsProxyDrive::Format(TInt64 aPos, TInt aLength) |
|
650 |
{ |
|
651 |
__MSFNSLOG |
|
652 |
return Erase(aPos, aLength); |
|
653 |
} |
|
654 |
||
655 |
||
656 |
/** |
|
657 |
Format the connected drive. |
|
658 |
||
659 |
@param anInfo Device specific format information. |
|
660 |
||
661 |
@return system wide error code. |
|
662 |
*/ |
|
663 |
TInt CUsbHostMsProxyDrive::Format(TFormatInfo& aInfo) |
|
664 |
{ |
|
665 |
__MSFNSLOG |
|
666 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
667 |
const TInt KDefaultMaxBytesPerFormat = 0x100 * iMsDataMemMap.BlockLength(); // 128K |
0 | 668 |
|
669 |
if (aInfo.i512ByteSectorsFormatted < 0) |
|
670 |
return KErrArgument; |
|
671 |
||
672 |
if (!aInfo.iFormatIsCurrent) |
|
673 |
{ |
|
674 |
aInfo.iFormatIsCurrent = ETrue; |
|
675 |
aInfo.i512ByteSectorsFormatted = 0; |
|
676 |
aInfo.iMaxBytesPerFormat = KDefaultMaxBytesPerFormat; |
|
677 |
||
678 |
TLocalDriveCapsV6Buf caps; |
|
679 |
TInt r = Caps(caps); |
|
680 |
if (r != KErrNone) |
|
681 |
return r; |
|
682 |
||
683 |
iMsDataMemMap.InitDataArea(caps().iSize); |
|
684 |
} |
|
685 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
686 |
TInt64 pos = static_cast<TInt64>(aInfo.i512ByteSectorsFormatted) << iMsDataMemMap.FormatSectorShift(); |
0 | 687 |
TInt length = aInfo.iMaxBytesPerFormat; |
688 |
TInt r = Erase(pos, length); |
|
689 |
||
690 |
if (r == KErrNone) |
|
691 |
{ |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
692 |
length += iMsDataMemMap.BlockLength() - 1; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
693 |
length >>= iMsDataMemMap.FormatSectorShift(); |
0 | 694 |
aInfo.i512ByteSectorsFormatted += length; |
695 |
} |
|
696 |
||
697 |
return r; |
|
698 |
} |
|
699 |
||
700 |
||
701 |
TInt CUsbHostMsProxyDrive::NotifyChange(TDes8 &aChanged,TRequestStatus* aStatus) |
|
702 |
{ |
|
703 |
__MSFNSLOG |
|
704 |
iUsbHostMsLun.NotifyChange(aChanged, *aStatus); |
|
705 |
||
706 |
if(*aStatus != KRequestPending) |
|
707 |
return KErrUnknown; |
|
708 |
||
709 |
return KErrNone; |
|
710 |
} |
|
711 |
||
712 |
void CUsbHostMsProxyDrive::NotifyChangeCancel() |
|
713 |
{ |
|
714 |
__MSFNSLOG |
|
715 |
iUsbHostMsLun.NotifyChangeCancel(); |
|
716 |
} |
|
717 |
||
718 |
TInt CUsbHostMsProxyDrive::SetMountInfo(const TDesC8* /*aMountInfo*/,TInt /*aMountInfoThreadHandle=KCurrentThreadHandle*/) |
|
719 |
{ |
|
720 |
__MSFNSLOG |
|
721 |
return KErrNone; |
|
722 |
} |
|
723 |
||
724 |
TInt CUsbHostMsProxyDrive::ForceRemount(TUint aFlags) |
|
725 |
{ |
|
726 |
__MSFNSLOG |
|
727 |
iUsbHostMsLun.ForceRemount(aFlags); |
|
728 |
return KErrNone; |
|
729 |
} |
|
730 |
||
731 |
TInt CUsbHostMsProxyDrive::Unlock(TMediaPassword& /*aPassword*/, TBool /*aStorePassword*/) |
|
732 |
{ |
|
733 |
__MSFNSLOG |
|
734 |
return KErrNotSupported; |
|
735 |
} |
|
736 |
||
737 |
TInt CUsbHostMsProxyDrive::Lock(TMediaPassword& /*aOldPassword*/, TMediaPassword& /*aNewPassword*/, TBool /*aStorePassword*/) |
|
738 |
{ |
|
739 |
__MSFNSLOG |
|
740 |
return KErrNotSupported; |
|
741 |
} |
|
742 |
||
743 |
TInt CUsbHostMsProxyDrive::Clear(TMediaPassword& /*aPassword*/) |
|
744 |
{ |
|
745 |
__MSFNSLOG |
|
746 |
return KErrNotSupported; |
|
747 |
} |
|
748 |
||
749 |
TInt CUsbHostMsProxyDrive::ErasePassword() |
|
750 |
{ |
|
751 |
__MSFNSLOG |
|
752 |
return KErrNotSupported; |
|
753 |
} |
|
754 |
||
755 |
TInt CUsbHostMsProxyDrive::GetInterface(TInt aInterfaceId,TAny*& aInterface,TAny* aInput) |
|
756 |
{ |
|
757 |
switch(aInterfaceId) |
|
758 |
{ |
|
759 |
case ELocalBufferSupport: |
|
760 |
return KErrNone; |
|
761 |
case EFinalised: |
|
762 |
{ |
|
763 |
TBool isFinalised = (TBool)aInput; |
|
764 |
if(isFinalised) |
|
765 |
{ |
|
766 |
iUsbHostMsLun.SuspendLun(); |
|
767 |
} |
|
768 |
} |
|
769 |
return KErrNone; |
|
770 |
default: |
|
771 |
return KErrNotSupported; |
|
772 |
} |
|
773 |
} |