author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 18 Aug 2010 11:08:29 +0300 | |
changeset 247 | d8d70de2bd36 |
parent 201 | 43365a9b78a3 |
child 259 | 57b9594f5772 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 1998-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 |
// e32\drivers\locmedia\locmedia.cpp |
|
15 |
// |
|
16 |
// |
|
17 |
||
18 |
#include "locmedia.h" |
|
19 |
#include <d32locd.h> |
|
20 |
#include "dmasupport.h" |
|
21 |
#include <kernel/cache.h> |
|
22 |
||
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
23 |
#include "OstTraceDefinitions.h" |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
24 |
#ifdef OST_TRACE_COMPILER_IN_USE |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
25 |
#include "locmedia_ost.h" |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
26 |
#ifdef __VC32__ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
27 |
#pragma warning(disable: 4127) // disabling warning "conditional expression is constant" |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
28 |
#endif |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
29 |
#include "locmediaTraces.h" |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
30 |
#endif |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
31 |
|
0 | 32 |
#if defined(_DEBUG) && defined(__DEMAND_PAGING__) |
33 |
//#define __DEBUG_DEMAND_PAGING__ |
|
34 |
#endif |
|
35 |
||
36 |
||
37 |
#if 0 |
|
38 |
#define CHECK_RET(r) if ((r)==KErrNotSupported && (KDebugNum(KSCRATCH))) {NKern::Lock(); *(TInt*)0xfaece5=0;} |
|
39 |
//#define CHECK_RET(r) |
|
40 |
#else |
|
41 |
#define CHECK_RET(r) |
|
42 |
#endif |
|
43 |
||
44 |
_LIT(KLddName,"LocDrv"); |
|
45 |
_LIT(KLitMediaDriverName, "Media.*"); |
|
46 |
_LIT(KLitLocMedia,"LocMedia"); |
|
47 |
||
48 |
#define LOCM_FAULT() Kern::Fault("LOCMEDIA",__LINE__) |
|
49 |
||
50 |
const TInt KMaxLocalDriveCapsLength=256; |
|
51 |
const TInt KMaxQueryDeviceLength=256; |
|
52 |
||
53 |
// The maximum amount of user-data which will be pinned. If a request is longer |
|
54 |
// than this value it will be split up into a number of requests |
|
55 |
// This value is a bit arbitrary - it needs to be sufficiently large so that transfer |
|
56 |
// rates don't suffer too much - but it can't be too big or we'd be "stealing" too much |
|
57 |
// memory from the demand paging pool and starving other processes |
|
58 |
const TInt KMaxPinData = 256*1024; |
|
59 |
||
60 |
// The number of locks available for pinning shared by all the drive threads in the system. |
|
61 |
// If all locks are in use then a single pre-allocated lock is used. |
|
62 |
const TInt KDynamicPagingLockCount = 8; |
|
63 |
||
64 |
TLocDrv* TheDrives[KMaxLocalDrives]; |
|
65 |
DMedia* TheMedia[KMaxLocalDrives]; |
|
66 |
HBuf* DriveNames[KMaxLocalDrives]; |
|
67 |
TInt UsedMedia=0; |
|
68 |
TPasswordStore* ThePasswordStore=NULL; |
|
69 |
||
70 |
class DPrimaryMediaBase::DBody : public DBase |
|
71 |
{ |
|
72 |
public: |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
73 |
DBody(DPrimaryMediaBase& aPrimaryMediaBase); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
74 |
public: |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
75 |
DPrimaryMediaBase& iPrimaryMediaBase; // ptr to parent |
0 | 76 |
TInt iPhysDevIndex; |
77 |
TInt iRequestCount; |
|
78 |
#ifdef __DEMAND_PAGING__ |
|
79 |
DMediaPagingDevice* iPagingDevice; |
|
80 |
TInt iPageSizeMsk; // Mask of page size (e.g. 4096-1 -> 4095) |
|
201
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
81 |
TInt iPageSizeLog2; // LOG2 of page size (i.e. 4096 -> 12) |
0 | 82 |
TInt iMediaChanges; |
83 |
#endif |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
84 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
85 |
// This bit mask indicates which local drives the media is attached to |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
86 |
TUint32 iRegisteredDriveMask; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
87 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
88 |
// Set to ETrue for media extension drivers |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
89 |
TBool iMediaExtension; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
90 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
91 |
// Media change DFCs to allow media change events from attached media |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
92 |
// to be handled in the context of an extension media's thread |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
93 |
TDfc iMediaChangeDfc; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
94 |
TDfc iMediaPresentDfc; |
0 | 95 |
}; |
96 |
||
97 |
#ifdef __DEMAND_PAGING__ |
|
98 |
DMediaPagingDevice* ThePagingDevices[KMaxLocalDrives]; |
|
99 |
DPrimaryMediaBase* TheRomPagingMedia = NULL; |
|
100 |
DPrimaryMediaBase* TheDataPagingMedia = NULL; |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
101 |
TLocDrv* TheDataPagingDrive = NULL; |
0 | 102 |
TBool DataPagingDeviceRegistered = EFalse; |
103 |
class DPinObjectAllocator; |
|
104 |
DPinObjectAllocator* ThePinObjectAllocator = NULL; |
|
105 |
||
106 |
// The paging media might share a DfcQ with other non-paging media (e.g. 2 MMC/SD cards sharing the same stack) |
|
107 |
// In this case, we need to avoid taking page faults on the non-paging media too, hence the need for these checks: |
|
108 |
inline TBool DataPagingDfcQ(DPrimaryMediaBase* aPrimaryMedia) |
|
109 |
{return TheDataPagingMedia && TheDataPagingMedia->iDfcQ == aPrimaryMedia->iDfcQ;} |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
110 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
111 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
112 |
TBool DataPagingMedia(DPrimaryMediaBase* aPrimaryMedia) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
113 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
114 |
for (TLocDrv* drv = TheDataPagingDrive; drv; drv = drv->iNextDrive) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
115 |
if (drv->iPrimaryMedia == aPrimaryMedia) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
116 |
return ETrue; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
117 |
return EFalse; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
118 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
119 |
|
0 | 120 |
inline TBool RomPagingDfcQ(DPrimaryMediaBase* aPrimaryMedia) |
121 |
{return TheRomPagingMedia && TheRomPagingMedia->iDfcQ == aPrimaryMedia->iDfcQ;} |
|
122 |
||
123 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
124 |
#if defined(_DEBUG) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
125 |
#define SETDEBUGFLAG(aBitNum) {Kern::SuperPage().iDebugMask[aBitNum >> 5] |= (1 << (aBitNum & 31));} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
126 |
#define CLRDEBUGFLAG(aBitNum) {Kern::SuperPage().iDebugMask[aBitNum >> 5] &= ~(1 << (aBitNum & 31));} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
127 |
#else |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
128 |
#define SETDEBUGFLAG(aBitNum) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
129 |
#define CLRDEBUGFLAG(aBitNum) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
130 |
#endif |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
131 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
132 |
|
0 | 133 |
|
134 |
/* |
|
135 |
DPinObjectAllocator |
|
136 |
||
137 |
Internal class which contains : |
|
138 |
(1) a queue of pre-allocated TVirtualPinObject's; |
|
139 |
(2) a single pre-allocated DFragmentationPagingLock object: |
|
140 |
this may be used if there are no TVirtualPinObject's available or if Kern::PinVirtualMemory() fails |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
141 |
@internalTechnology |
0 | 142 |
*/ |
143 |
NONSHARABLE_CLASS(DPinObjectAllocator) : public DBase |
|
144 |
{ |
|
145 |
public: |
|
146 |
/* |
|
147 |
SVirtualPinContainer |
|
148 |
Internal class encapsulating a TVirtualPinObject. |
|
149 |
Contains a SDblQueLink so that it may form part of a SDblQue |
|
150 |
*/ |
|
151 |
typedef struct |
|
152 |
{ |
|
153 |
TVirtualPinObject* iObject; |
|
154 |
SDblQueLink iLink; |
|
155 |
} SVirtualPinContainer; |
|
156 |
||
157 |
public: |
|
158 |
inline DPinObjectAllocator() {}; |
|
159 |
~DPinObjectAllocator(); |
|
160 |
TInt Construct(TInt aObjectCount, TUint aNumPages); |
|
161 |
||
162 |
SVirtualPinContainer* AcquirePinObject(); |
|
163 |
void ReleasePinObject(SVirtualPinContainer* aVirtualPinObject); |
|
164 |
||
165 |
inline DFragmentationPagingLock& PreAllocatedDataLock() {return *iPreAllocatedDataLock;} |
|
166 |
||
167 |
private: |
|
168 |
// array of SVirtualPinContainer's |
|
169 |
SVirtualPinContainer* iVirtualPinContainers; |
|
170 |
TInt iObjectCount; |
|
171 |
||
172 |
// queues containing SVirtualPinContainer's |
|
173 |
SDblQue iFreeQ; |
|
174 |
||
175 |
// pre-allocated (small) buffers for locking client data should Kern::PinVirtualMemory() fail |
|
176 |
DFragmentationPagingLock* iPreAllocatedDataLock; |
|
177 |
||
178 |
// A mutex to protect access to the pinning objects. |
|
179 |
NFastMutex iLock; |
|
180 |
||
181 |
public: |
|
182 |
TUint iFragmentGranularity; |
|
183 |
}; |
|
184 |
||
185 |
||
186 |
DPinObjectAllocator::~DPinObjectAllocator() |
|
187 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
188 |
OstTraceFunctionEntry1( DPINOBJECTALLOCATOR_DPINOBJECTALLOCATOR_ENTRY, this ); |
0 | 189 |
if (iPreAllocatedDataLock) |
190 |
{ |
|
191 |
iPreAllocatedDataLock->Cleanup(); |
|
192 |
delete iPreAllocatedDataLock; |
|
193 |
} |
|
194 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
195 |
for (TInt n=0; iVirtualPinContainers!= NULL && n<iObjectCount; n++) |
0 | 196 |
{ |
197 |
SVirtualPinContainer& virtualPinContainer = iVirtualPinContainers[n]; |
|
198 |
if (virtualPinContainer.iObject) |
|
199 |
Kern::DestroyVirtualPinObject(virtualPinContainer.iObject); |
|
200 |
} |
|
201 |
||
202 |
delete [] iVirtualPinContainers; |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
203 |
OstTraceFunctionExit1( DPINOBJECTALLOCATOR_DPINOBJECTALLOCATOR_EXIT, this ); |
0 | 204 |
} |
205 |
||
206 |
TInt DPinObjectAllocator::Construct(TInt aObjectCount, TUint aNumPages) |
|
207 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
208 |
OstTraceFunctionEntryExt( DPINOBJECTALLOCATOR_CONSTRUCT_ENTRY, this ); |
0 | 209 |
TInt pageSize = Kern::RoundToPageSize(1); |
210 |
iFragmentGranularity = pageSize * aNumPages; |
|
211 |
__KTRACE_OPT2(KBOOT,KLOCDPAGING,Kern::Printf("Fragmentation granularity set to 0x%x", iFragmentGranularity)); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
212 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DPINOBJECTALLOCATOR_CONSTRUCT, "Fragmentation granularity=0x%x", iFragmentGranularity); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
213 |
|
0 | 214 |
// construct the paging lock containing pre-allocated buffers |
215 |
||
216 |
iPreAllocatedDataLock = new DFragmentationPagingLock(); |
|
217 |
if(!iPreAllocatedDataLock) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
218 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
219 |
OstTraceFunctionExitExt( DPINOBJECTALLOCATOR_CONSTRUCT_EXIT1, this, KErrNoMemory ); |
0 | 220 |
return KErrNoMemory; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
221 |
} |
0 | 222 |
TInt r = iPreAllocatedDataLock->Construct(aNumPages); |
223 |
if (r != KErrNone) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
224 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
225 |
OstTraceFunctionExitExt( DPINOBJECTALLOCATOR_CONSTRUCT_EXIT2, this, r ); |
0 | 226 |
return r; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
227 |
} |
0 | 228 |
|
229 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
230 |
iVirtualPinContainers = new SVirtualPinContainer[aObjectCount]; |
0 | 231 |
if (iVirtualPinContainers == NULL) |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
232 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
233 |
OstTraceFunctionExitExt( DPINOBJECTALLOCATOR_CONSTRUCT_EXIT3, this, KErrNoMemory ); |
0 | 234 |
return KErrNoMemory; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
235 |
} |
0 | 236 |
memclr(iVirtualPinContainers, sizeof(SVirtualPinContainer) * aObjectCount); |
237 |
iObjectCount = aObjectCount; |
|
238 |
||
239 |
// construct the queue of dynamic paging locks |
|
240 |
for (TInt n=0; n<aObjectCount; n++) |
|
241 |
{ |
|
242 |
SVirtualPinContainer& pinContainer = iVirtualPinContainers[n]; |
|
243 |
||
244 |
TInt r = Kern::CreateVirtualPinObject(pinContainer.iObject); |
|
245 |
if (r != KErrNone) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
246 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
247 |
OstTraceFunctionExitExt( DPINOBJECTALLOCATOR_CONSTRUCT_EXIT4, this, KErrNoMemory ); |
0 | 248 |
return KErrNoMemory; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
249 |
} |
0 | 250 |
|
251 |
iFreeQ.Add(&pinContainer.iLink); |
|
252 |
} |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
253 |
|
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
254 |
OstTraceFunctionExitExt( DPINOBJECTALLOCATOR_CONSTRUCT_EXIT5, this, KErrNone ); |
0 | 255 |
return KErrNone; |
256 |
} |
|
257 |
||
258 |
/** |
|
259 |
returns a SVirtualPinContainer object or NULL if NULL available |
|
260 |
*/ |
|
261 |
DPinObjectAllocator::SVirtualPinContainer* DPinObjectAllocator::AcquirePinObject() |
|
262 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
263 |
OstTraceFunctionEntry1( DPINOBJECTALLOCATOR_ACQUIREPINOBJECT_ENTRY, this ); |
0 | 264 |
SVirtualPinContainer* pinContainer = NULL; |
265 |
||
266 |
NKern::FMWait(&iLock); |
|
267 |
||
268 |
if (!iFreeQ.IsEmpty()) |
|
269 |
{ |
|
270 |
SDblQueLink* link = iFreeQ.First(); |
|
271 |
pinContainer = _LOFF(link, SVirtualPinContainer, iLink); |
|
272 |
link->Deque(); |
|
273 |
} |
|
274 |
||
275 |
||
276 |
NKern::FMSignal(&iLock); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
277 |
OstTraceFunctionExit1( DPINOBJECTALLOCATOR_ACQUIREPINOBJECT_EXIT, this ); |
0 | 278 |
return pinContainer; |
279 |
} |
|
280 |
||
281 |
/** |
|
282 |
returns a SVirtualPinContainer object to the pool |
|
283 |
*/ |
|
284 |
void DPinObjectAllocator::ReleasePinObject(SVirtualPinContainer* aPinContainer) |
|
285 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
286 |
OstTraceFunctionEntry1( DPINOBJECTALLOCATOR_RELEASEPINOBJECT_ENTRY, this ); |
0 | 287 |
NKern::FMWait(&iLock); |
288 |
||
289 |
iFreeQ.Add(&aPinContainer->iLink); |
|
290 |
||
291 |
NKern::FMSignal(&iLock); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
292 |
OstTraceFunctionExit1( DPINOBJECTALLOCATOR_RELEASEPINOBJECT_EXIT, this ); |
0 | 293 |
} |
294 |
||
295 |
#endif // __DEMAND_PAGING__ |
|
296 |
||
297 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
298 |
/* |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
299 |
TDriveIterator |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
300 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
301 |
Internal class which supports iterating through all local drives (TLocDrv's) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
302 |
If there are media extensions present, then this will iterate through all attached drives. |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
303 |
@internalTechnology |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
304 |
*/ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
305 |
class TDriveIterator |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
306 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
307 |
public: |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
308 |
TDriveIterator(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
309 |
TLocDrv* NextDrive(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
310 |
inline TInt Index() |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
311 |
{return iIndex;} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
312 |
static TLocDrv* GetDrive(TInt aDriveNum, DPrimaryMediaBase* aPrimaryMedia); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
313 |
static TLocDrv* GetPhysicalDrive(TLocDrv* aDrv); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
314 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
315 |
#if defined(__DEMAND_PAGING__) && defined(__DEMAND_PAGING_BENCHMARKS__) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
316 |
static DMediaPagingDevice* PagingDevice(TInt aDriveNum, DPagingDevice::TType aType); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
317 |
#endif |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
318 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
319 |
private: |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
320 |
TInt iIndex; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
321 |
TLocDrv* iDrive; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
322 |
}; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
323 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
324 |
TDriveIterator::TDriveIterator() : |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
325 |
iIndex(0), iDrive(NULL) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
326 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
327 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
328 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
329 |
TLocDrv* TDriveIterator::NextDrive() |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
330 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
331 |
if (iDrive) // i.e. if not first time |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
332 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
333 |
if (iDrive->iNextDrive) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
334 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
335 |
iDrive = iDrive->iNextDrive; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
336 |
return iDrive; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
337 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
338 |
iIndex++; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
339 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
340 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
341 |
for (iDrive = NULL; iIndex < KMaxLocalDrives; iIndex++) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
342 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
343 |
iDrive = TheDrives[iIndex]; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
344 |
if (iDrive) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
345 |
break; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
346 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
347 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
348 |
return iDrive; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
349 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
350 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
351 |
/* |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
352 |
Returns the first TLocDrv in the chain of attached drives which matches DPrimaryMediaBase |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
353 |
*/ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
354 |
TLocDrv* TDriveIterator::GetDrive(TInt aDriveNum, DPrimaryMediaBase* aPrimaryMedia) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
355 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
356 |
TLocDrv* drive = TheDrives[aDriveNum]; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
357 |
while (drive && drive->iPrimaryMedia != aPrimaryMedia) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
358 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
359 |
drive = drive->iNextDrive ? drive->iNextDrive : NULL; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
360 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
361 |
return drive; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
362 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
363 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
364 |
/* |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
365 |
Returns the last TLocDrv in the chain of attached drives - |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
366 |
i.e. the TLocDrv attached to physical media rather than a TLocDrv corresponding to a media extension |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
367 |
*/ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
368 |
TLocDrv* TDriveIterator::GetPhysicalDrive(TLocDrv* aDrv) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
369 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
370 |
__ASSERT_DEBUG(aDrv, LOCM_FAULT()); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
371 |
while (aDrv->iNextDrive) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
372 |
aDrv = aDrv->iNextDrive; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
373 |
return aDrv; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
374 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
375 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
376 |
#if defined(__DEMAND_PAGING__) && defined(__DEMAND_PAGING_BENCHMARKS__) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
377 |
DMediaPagingDevice* TDriveIterator::PagingDevice(TInt aDriveNum, DPagingDevice::TType aType) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
378 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
379 |
TLocDrv* drive = TheDrives[aDriveNum]; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
380 |
DMediaPagingDevice* pagingDevice = drive ? drive->iPrimaryMedia->iBody->iPagingDevice : NULL; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
381 |
while (drive && (pagingDevice == NULL || (pagingDevice->iType & aType) == 0)) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
382 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
383 |
drive = drive->iNextDrive ? drive->iNextDrive : NULL; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
384 |
pagingDevice = drive ? drive->iPrimaryMedia->iBody->iPagingDevice : NULL; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
385 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
386 |
return pagingDevice; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
387 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
388 |
#endif |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
389 |
|
0 | 390 |
/******************************************** |
391 |
* Local drive device base class |
|
392 |
********************************************/ |
|
393 |
DECLARE_EXTENSION_LDD() |
|
394 |
{ |
|
395 |
return new DLocalDriveFactory; |
|
396 |
} |
|
397 |
||
398 |
DLocalDriveFactory::DLocalDriveFactory() |
|
399 |
// |
|
400 |
// Constructor |
|
401 |
// |
|
402 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
403 |
OstTraceFunctionEntry1( DLOCALDRIVEFACTORY_DLOCALDRIVEFACTORY_ENTRY, this ); |
0 | 404 |
iParseMask=KDeviceAllowUnit|KDeviceAllowInfo; |
405 |
iUnitsMask=~(0xffffffff<<KMaxLocalDrives); |
|
406 |
iVersion=TVersion(KLocalDriveMajorVersion,KLocalDriveMinorVersion,KLocalDriveBuildVersion); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
407 |
OstTraceFunctionExit1( DLOCALDRIVEFACTORY_DLOCALDRIVEFACTORY_EXIT, this ); |
0 | 408 |
} |
409 |
||
410 |
TInt DLocalDriveFactory::Install() |
|
411 |
// |
|
412 |
// Install the device driver. |
|
413 |
// |
|
414 |
{ |
|
415 |
return SetName(&KLddName); |
|
416 |
} |
|
417 |
||
418 |
void DLocalDriveFactory::GetCaps(TDes8& /*aDes*/) const |
|
419 |
// |
|
420 |
// Return the Comm capabilities. |
|
421 |
// |
|
422 |
{ |
|
423 |
// TCapsLocalDriveV01 b; |
|
424 |
// b.version=iVersion; |
|
425 |
// aDes.FillZ(aDes.MaxLength()); |
|
426 |
// aDes.Copy((TUint8 *)&b,Min(aDes.MaxLength(),sizeof(b))); |
|
427 |
} |
|
428 |
||
429 |
TInt DLocalDriveFactory::Create(DLogicalChannelBase*& aChannel) |
|
430 |
// |
|
431 |
// Create a channel on the device. |
|
432 |
// |
|
433 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
434 |
OstTraceFunctionEntry1( DLOCALDRIVEFACTORY_CREATE_ENTRY, this ); |
0 | 435 |
aChannel=new DLocalDrive; |
436 |
return aChannel?KErrNone:KErrNoMemory; |
|
437 |
} |
|
438 |
||
439 |
/******************************************** |
|
440 |
* Local drive interface class |
|
441 |
********************************************/ |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
442 |
DLocalDrive::DLocalDrive() : |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
443 |
iMediaChangeObserver(MediaChangeCallback, this, TCallBackLink::EDLocalDriveObject) |
0 | 444 |
{ |
445 |
// iLink.iNext=NULL; |
|
446 |
} |
|
447 |
||
448 |
DLocalDrive::~DLocalDrive() |
|
449 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
450 |
OstTraceFunctionEntry1( DLOCALDRIVE_DLOCALDRIVE_ENTRY, this ); |
0 | 451 |
if (iDrive) |
452 |
{ |
|
453 |
__KTRACE_OPT(KLOCDRV,Kern::Printf(">DLocalDrive::DoClose D:%d, M:%08x",iDrive->iDriveNumber,iDrive->iMedia)); |
|
454 |
iDrive->Disconnect(this); |
|
455 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("<DLocalDrive::DoClose D:%d, M:%08x",iDrive->iDriveNumber,iDrive->iMedia)); |
|
456 |
} |
|
457 |
DThread* pC=NULL; |
|
458 |
NKern::LockSystem(); |
|
459 |
if (iCleanup.iThread) |
|
460 |
{ |
|
461 |
pC=iCleanup.iThread; |
|
462 |
iCleanup.Remove(); |
|
463 |
iCleanup.iThread=NULL; |
|
464 |
} |
|
465 |
NKern::UnlockSystem(); |
|
466 |
if (pC) // original client may already have terminated |
|
467 |
{ |
|
468 |
if (iNotifyChangeRequest) |
|
469 |
Kern::QueueRequestComplete(pC,iNotifyChangeRequest,KErrCancel); |
|
470 |
pC->Close(NULL); // balances Open() in DoCreate |
|
471 |
} |
|
472 |
if (iNotifyChangeRequest) |
|
473 |
Kern::DestroyClientRequest(iNotifyChangeRequest); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
474 |
OstTraceFunctionExit1( DLOCALDRIVE_DLOCALDRIVE_EXIT, this ); |
0 | 475 |
} |
476 |
||
477 |
TInt DLocalDrive::DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer) |
|
478 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
479 |
OstTraceFunctionEntry1( DLOCALDRIVE_DOCREATE_ENTRY, this ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
480 |
|
0 | 481 |
if(!Kern::CurrentThreadHasCapability(ECapabilityTCB,__PLATSEC_DIAGNOSTIC_STRING("Checked by ELOCD.LDD (Local Media Driver)"))) |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
482 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
483 |
OstTraceFunctionExitExt( DLOCALDRIVE_DOCREATE_EXIT1, this, KErrPermissionDenied ); |
0 | 484 |
return KErrPermissionDenied; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
485 |
} |
0 | 486 |
if (!Kern::QueryVersionSupported(TVersion(KLocalDriveMajorVersion,KLocalDriveMinorVersion,KLocalDriveBuildVersion),aVer)) |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
487 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
488 |
OstTraceFunctionExitExt( DLOCALDRIVE_DOCREATE_EXIT2, this, KErrNotSupported ); |
0 | 489 |
return KErrNotSupported; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
490 |
} |
0 | 491 |
|
492 |
NKern::ThreadEnterCS(); |
|
493 |
TInt r = Kern::CreateClientDataRequest(iNotifyChangeRequest); |
|
494 |
NKern::ThreadLeaveCS(); |
|
495 |
if (r != KErrNone) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
496 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
497 |
OstTraceFunctionExitExt( DLOCALDRIVE_DOCREATE_EXIT3, this, r ); |
0 | 498 |
return r; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
499 |
} |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
500 |
|
0 | 501 |
DThread& t=Kern::CurrentThread(); |
502 |
NKern::LockSystem(); |
|
503 |
t.AddCleanup(&iCleanup); |
|
504 |
NKern::UnlockSystem(); |
|
505 |
t.Open(); |
|
506 |
iNotifyChangeRequest->SetDestPtr((TBool*) anInfo); |
|
507 |
||
508 |
iDrive=TheDrives[aUnit]; |
|
509 |
if (!iDrive) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
510 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
511 |
OstTraceFunctionExitExt( DLOCALDRIVE_DOCREATE_EXIT4, this, KErrNotSupported ); |
0 | 512 |
return KErrNotSupported; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
513 |
} |
0 | 514 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("DLocalDrive Create - connect to drive %d, M:%08x",iDrive->iDriveNumber,iDrive->iMedia)); |
515 |
r=iDrive->Connect(this); |
|
516 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("<DLocalDrive Create D:%d, M:%08x r:%d",iDrive->iDriveNumber,iDrive->iMedia,r)); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
517 |
|
0 | 518 |
if (r!=KErrNone) |
519 |
iDrive=NULL; // didn't connect so don't disconnect |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
520 |
|
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
521 |
OstTraceFunctionExitExt( DLOCALDRIVE_DOCREATE_EXIT5, this, r ); |
0 | 522 |
return r; |
523 |
} |
|
524 |
||
525 |
#if defined(_DEBUG) |
|
526 |
void DebugDumpDriveCaps(const TLocDrv* aDrive, const TAny* aCaps) |
|
527 |
{ |
|
528 |
const TLocalDriveCapsV5& c=*(const TLocalDriveCapsV5*)aCaps; |
|
529 |
Kern::Printf("Drive %d Caps:", aDrive->iDriveNumber); |
|
530 |
Kern::Printf("Size: %lx", c.iSize); |
|
531 |
Kern::Printf("Type: %08x", c.iType); |
|
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
532 |
Kern::Printf("Bus : %08x", c.iConnectionBusType); |
0 | 533 |
Kern::Printf("DAtt: %08x", c.iDriveAtt); |
534 |
Kern::Printf("MAtt: %08x", c.iMediaAtt); |
|
535 |
Kern::Printf("Base: %08x", c.iBaseAddress); |
|
536 |
Kern::Printf("FSID: %04x", c.iFileSystemId); |
|
537 |
Kern::Printf("PTYP: %04x", c.iPartitionType); |
|
538 |
Kern::Printf("HIDN: %08x", c.iHiddenSectors); |
|
539 |
Kern::Printf("EBSZ: %08x", c.iEraseBlockSize); |
|
540 |
//---------------- V5 ------------------// |
|
541 |
if (c.iSerialNumLength != 0) |
|
542 |
{ |
|
543 |
Kern::Printf("SN: length is %d", c.iSerialNumLength); |
|
544 |
TBuf8<2*KMaxSerialNumLength+20> snBuf; |
|
545 |
snBuf.Append(_L8("SN: content is ")); |
|
546 |
for (TUint i=0; i<c.iSerialNumLength; i++) |
|
547 |
snBuf.AppendNumFixedWidth(c.iSerialNum[i], EHex, 2); |
|
548 |
Kern::Printf((const char*)snBuf.Ptr()); |
|
549 |
} |
|
550 |
else |
|
551 |
Kern::Printf("SN: not supported"); |
|
552 |
} |
|
553 |
#endif |
|
554 |
||
555 |
/* |
|
556 |
* Requests are passed in message as follows: |
|
557 |
* iValue = request ID |
|
558 |
* iArg[0,1]= Position |
|
559 |
* iArg[2,3]= Length |
|
560 |
* iArg[4] = Pointer to remote thread (NULL if client) |
|
561 |
* iArg[5] = Pointer to remote descriptor |
|
562 |
* iArg[6] = Offset into remote descriptor |
|
563 |
* iArg[7] = Flags (whole media) |
|
564 |
* iArg[8] = Pointer to TLocDrv |
|
565 |
*/ |
|
566 |
||
567 |
TInt DLocalDrive::Request(TInt aFunction, TAny* a1, TAny* a2) |
|
568 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
569 |
OstTraceFunctionEntry1( DLOCALDRIVE_REQUEST_ENTRY, this ); |
0 | 570 |
__TRACE_TIMING(0); |
571 |
__KTRACE_OPT(KLOCDRV,Kern::Printf(">DLocalDrive::DoControl D:%d M:%08x F:%d A1:%08x A2:%08x", |
|
572 |
iDrive->iDriveNumber, iDrive->iMedia, aFunction, a1, a2)); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
573 |
OstTraceDefExt3( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST, "iMedia=0x%08x; iDriveNumber=%d; Request Id=%d", (TUint) iDrive->iMedia, (TInt) iDrive->iDriveNumber, (TInt) aFunction ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
574 |
|
0 | 575 |
TInt r=KErrNotSupported; |
576 |
TLocDrvRequest& m=TLocDrvRequest::Get(); |
|
577 |
m.Flags()=0; |
|
578 |
m.Drive()=iDrive; |
|
579 |
switch (aFunction) |
|
580 |
{ |
|
581 |
case RLocalDrive::EControlRead: |
|
582 |
{ |
|
583 |
m.Id()=ERead; |
|
584 |
r=m.ProcessMessageData(a1); |
|
585 |
__TRACE_TIMING(1); |
|
586 |
if (r==KErrNone) |
|
587 |
{ |
|
588 |
__TRACE_TIMING(2); |
|
200
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
152
diff
changeset
|
589 |
OstTraceDefExt2( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_READ, "ERead iDriveNumber=%d; TLocDrvRequest Object=0x%x", (TInt) iDrive->iDriveNumber, (TUint) &m); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
152
diff
changeset
|
590 |
OstTraceDefExt4( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_READ2, "ERead length=%x:%x, pos=%x:%x", (TUint) I64HIGH(m.Length()), (TUint) I64LOW(m.Length()), (TUint) I64HIGH(m.Pos()), (TUint) I64LOW(m.Pos())); |
0 | 591 |
r=iDrive->Request(m); |
592 |
__TRACE_TIMING(3); |
|
200
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
152
diff
changeset
|
593 |
OstTraceDefExt2( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_READ_RETURN, "ERead Return iDriveNumber=%d; TLocDrvRequest Object=0x%x", (TInt) iDrive->iDriveNumber, (TUint) &m ); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
152
diff
changeset
|
594 |
OstTraceDefExt4( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_READ_RETURN2, "ERead Return length=%x:%x, pos=%x:%x", (TUint) I64HIGH(m.Length()), (TUint) I64LOW(m.Length()), (TUint) I64HIGH(m.Pos()), (TUint) I64LOW(m.Pos())); |
0 | 595 |
} |
596 |
m.CloseRemoteThread(); |
|
597 |
break; |
|
598 |
} |
|
599 |
case RLocalDrive::EControlWrite: |
|
600 |
{ |
|
601 |
m.Id()=EWrite; |
|
602 |
r=m.ProcessMessageData(a1); |
|
603 |
if (r==KErrNone) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
604 |
{ |
200
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
152
diff
changeset
|
605 |
OstTraceDefExt2( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_WRITE, "EWrite iDriveNumber=%d; TLocDrvRequest Object=0x%x", (TInt) iDrive->iDriveNumber, (TUint) &m ); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
152
diff
changeset
|
606 |
OstTraceDefExt4( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_WRITE2, "EWrite length=%x:%x, pos=%x:%x", (TUint) I64HIGH(m.Length()), (TUint) I64LOW(m.Length()), (TUint) I64HIGH(m.Pos()), (TUint) I64LOW(m.Pos())); |
0 | 607 |
r=iDrive->Request(m); |
200
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
152
diff
changeset
|
608 |
OstTraceDefExt2( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_WRITE_RETURN, "EWrite Return iDriveNumber=%d; TLocDrvRequest Object=0x%x", (TInt) iDrive->iDriveNumber, (TUint) &m ); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
152
diff
changeset
|
609 |
OstTraceDefExt4( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_WRITE_RETURN2, "EWrite Return length=%x:%x, pos=%x:%x", (TUint) I64HIGH(m.Length()), (TUint) I64LOW(m.Length()), (TUint) I64HIGH(m.Pos()), (TUint) I64LOW(m.Pos())); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
610 |
} |
0 | 611 |
m.CloseRemoteThread(); |
612 |
break; |
|
613 |
} |
|
614 |
case RLocalDrive::EControlCaps: |
|
615 |
{ |
|
616 |
TBuf8<KMaxLocalDriveCapsLength> capsBuf; |
|
617 |
capsBuf.SetMax(); |
|
618 |
capsBuf.FillZ(); |
|
619 |
m.Id()=ECaps; |
|
620 |
m.RemoteDes()=(TAny*)capsBuf.Ptr(); // overload this |
|
621 |
m.Length()=KMaxLocalDriveCapsLength; // for pinning |
|
622 |
r=iDrive->Request(m); |
|
623 |
||
624 |
||
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
625 |
#if defined(OST_TRACE_COMPILER_IN_USE) && defined(_DEBUG) |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
626 |
const TLocalDriveCapsV5& caps=*(const TLocalDriveCapsV5*)capsBuf.Ptr(); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
627 |
#endif |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
628 |
|
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
629 |
OstTraceExt5( TRACE_INTERNALS, DLOCALDRIVE_REQUEST_CAPS1, "Device caps: iDriveNumber=%d; iSize=0x%x; iType=%d; iDriveAtt=%d; TLocDrvRequest Object=0x%x", (TInt)iDrive->iDriveNumber, (TUint) caps.iSize, (TInt) caps.iType, (TInt) caps.iDriveAtt, (TUint) &m); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
630 |
OstTraceExt5( TRACE_INTERNALS, DLOCALDRIVE_REQUEST_CAPS2, "Device caps: iBaseAddress=0x%x; iFileSystemId=%d; iPartitionType=%d; iHiddenSectors=0x%x; iEraseBlockSize=0x%x", (TUint) caps.iBaseAddress, (TInt) caps.iFileSystemId, (TUint) caps.iPartitionType, (TUint) caps.iHiddenSectors, (TUint) caps.iEraseBlockSize); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
631 |
|
0 | 632 |
#if defined(_DEBUG) |
633 |
__KTRACE_OPT(KLOCDRV,DebugDumpDriveCaps(iDrive,capsBuf.Ptr())); |
|
634 |
#endif |
|
635 |
Kern::InfoCopy(*(TDes8*)a1, capsBuf); |
|
636 |
break; |
|
637 |
} |
|
638 |
case RLocalDrive::EControlFormat: |
|
639 |
{ |
|
640 |
m.Id()=EFormat; |
|
641 |
r=m.ProcessMessageData(a1); |
|
642 |
if (r==KErrNone) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
643 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
644 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_FORMAT, "EFormat; TLocDrvRequest Object=0x%x", (TUint) &m); |
0 | 645 |
r=iDrive->Request(m); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
646 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_FORMAT_RETURN, "EFormat Return; TLocDrvRequest Object=0x%x", (TUint) &m); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
647 |
} |
0 | 648 |
break; |
649 |
} |
|
650 |
case RLocalDrive::EControlEnlarge: |
|
651 |
if ((TInt)a1<0) |
|
652 |
{ |
|
653 |
r=KErrArgument; |
|
654 |
break; |
|
655 |
} |
|
656 |
m.Length()=(TInt)a1; |
|
657 |
m.Id()=EEnlarge; |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
658 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_ENLARGE, "EEnlarge; TLocDrvRequest Object=0x%x", (TUint) &m); |
0 | 659 |
r=iDrive->Request(m); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
660 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_ENLARGE_RETURN, "EEnlarge Return; TLocDrvRequest Object=0x%x", (TUint) &m); |
0 | 661 |
break; |
662 |
case RLocalDrive::EControlReduce: |
|
663 |
{ |
|
664 |
if ((TInt)a1<0 || (TInt)a2<0) |
|
665 |
{ |
|
666 |
r=KErrArgument; |
|
667 |
break; |
|
668 |
} |
|
669 |
m.Pos()=(TInt)a1; |
|
670 |
m.Length()=(TInt)a2; |
|
671 |
m.Id()=EReduce; |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
672 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_REDUCE, "EReduce; TLocDrvRequest Object=0x%x", (TUint) &m); |
0 | 673 |
r=iDrive->Request(m); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
674 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_REDUCE_RETURN, "EReduce Return; TLocDrvRequest Object=0x%x", (TUint) &m); |
0 | 675 |
break; |
676 |
} |
|
677 |
case RLocalDrive::EControlForceMediaChange: |
|
678 |
m.Pos()=(TInt)a1; |
|
679 |
m.Id()=EForceMediaChange; |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
680 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_FORCEMEDIACHANGE, "EForceMediaChange; TLocDrvRequest Object=0x%x", (TUint) &m); |
0 | 681 |
r = iDrive->Request(m); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
682 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_FORCEMEDIACHANGE_RETURN, "EForceMediaChange Return; TLocDrvRequest Object=0x%x", (TUint) &m); |
0 | 683 |
break; |
684 |
case RLocalDrive::EControlMediaDevice: |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
685 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_CONTROLMEDIADEVICE, "EControlMediaDevice; TLocDrvRequest Object=0x%x", (TUint) &m); |
0 | 686 |
r=iDrive->iPrimaryMedia->iDevice; |
687 |
break; |
|
688 |
case RLocalDrive::EControlIsRemovable: |
|
689 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
690 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_CONTROLISREMOVABLE, "EControlIsRemovable; TLocDrvRequest Object=0x%x", (TUint) &m); |
0 | 691 |
TInt sockNum; |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
692 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
693 |
// Pass request on to last chained drive |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
694 |
TLocDrv* drv = TDriveIterator::GetPhysicalDrive(iDrive); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
695 |
r = drv->iPrimaryMedia->IsRemovableDevice(sockNum); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
696 |
|
0 | 697 |
if (r) |
698 |
kumemput32(a1,&sockNum,sizeof(TInt)); |
|
699 |
break; |
|
700 |
} |
|
701 |
case RLocalDrive::EControlControlIO: |
|
702 |
{ |
|
703 |
TLocalDriveControlIOData d; |
|
704 |
kumemget32(&d,a1,sizeof(d)); |
|
705 |
||
706 |
m.Id() = EControlIO; |
|
707 |
m.iArg[0] = (TAny*) d.iCommand; |
|
708 |
m.iArg[1] = d.iParam1; |
|
709 |
m.iArg[2] = d.iParam2; |
|
710 |
||
711 |
// if d.iHandle is == KLocalMessageHandle (-1), |
|
712 |
// d.aParam1 and d.aParam2 are TAny* pointers |
|
713 |
// |
|
714 |
// if d.iHandle is == 0, |
|
715 |
// d.aParam1 and d.aParam2 are TInts |
|
716 |
// |
|
717 |
// if d.iHandle is > 0, |
|
718 |
// d.aParam1 is a data pointer (TUint8*) |
|
719 |
// d.aParam2 is an optional extra paramater (TInt) |
|
720 |
// d.iHandle is a data length (TInt) |
|
721 |
m.iArg[3] = (TAny*) d.iHandle; |
|
722 |
||
723 |
//We're highjacking fields representing |
|
724 |
//length and position in a normal message, so |
|
725 |
//let's not have the dispatcher function attempt |
|
726 |
//to adjust for partition size. |
|
727 |
m.Flags() |= TLocDrvRequest::EAdjusted; |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
728 |
|
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
729 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_CONTROLCONTROLIO, "EControlControlIO; TLocDrvRequest Object=0x%x", (TUint) &m); |
0 | 730 |
r=iDrive->Request(m); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
731 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_CONTROLCONTROLIO_RETURN, "EControlControlIO Return; TLocDrvRequest Object=0x%x", (TUint) &m); |
0 | 732 |
break; |
733 |
} |
|
734 |
case RLocalDrive::EControlSetMountInfo: |
|
735 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
736 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_CONTROLSETMOUNTINFO, "EControlSetMountInfo; TLocDrvRequest Object=0x%x", (TUint) &m); |
0 | 737 |
m.Id()=ERead; |
738 |
r=m.ProcessMessageData(a1); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
739 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
740 |
// Pass request on to last chained drive |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
741 |
TLocDrv* drv = TDriveIterator::GetPhysicalDrive(iDrive); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
742 |
DPrimaryMediaBase* pM = drv->iPrimaryMedia; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
743 |
|
0 | 744 |
if(!pM || r!=KErrNone) |
745 |
break; |
|
746 |
||
747 |
if (pM->iMountInfo.iThread) |
|
748 |
{ |
|
749 |
NKern::ThreadEnterCS(); |
|
750 |
//Close original thread |
|
751 |
Kern::SafeClose((DObject*&) pM->iMountInfo.iThread,NULL); |
|
752 |
if (m.RemoteDes()!=NULL) |
|
753 |
{ |
|
754 |
//Set new mount info and leave setting thread open |
|
755 |
#ifdef __DEMAND_PAGING__ |
|
756 |
// lock the mount info if this is a data paging media - and keep it locked |
|
757 |
if ((DataPagingDfcQ(pM)) && ((r = LockMountInfo(*pM, m)) != KErrNone)) |
|
758 |
break; |
|
759 |
#endif |
|
760 |
pM->iMountInfo.iInfo=(TDesC8*)m.RemoteDes(); |
|
761 |
pM->iMountInfo.iThread=m.RemoteThread(); |
|
762 |
} |
|
763 |
else |
|
764 |
{ |
|
765 |
//Clear existing mount info and close setting thread |
|
766 |
||
767 |
#ifdef __DEMAND_PAGING__ |
|
768 |
// unlock the mount info if this is a data paging media |
|
769 |
UnlockMountInfo(*pM); |
|
770 |
#endif |
|
771 |
||
772 |
pM->iMountInfo.iInfo=NULL; |
|
773 |
pM->iMountInfo.iThread=NULL; |
|
774 |
m.CloseRemoteThread(); |
|
775 |
} |
|
776 |
NKern::ThreadLeaveCS(); |
|
777 |
r=KErrNone; |
|
778 |
} |
|
779 |
else |
|
780 |
{ |
|
781 |
//Setting mount info for the first time |
|
782 |
if (m.RemoteDes()==NULL) |
|
783 |
{ |
|
784 |
// if no mount info, close setting thread opened in ProcessMessageData() |
|
785 |
m.CloseRemoteThread(); |
|
786 |
break; |
|
787 |
} |
|
788 |
||
789 |
NKern::ThreadEnterCS(); |
|
790 |
#ifdef __DEMAND_PAGING__ |
|
791 |
// lock the mount info if this is a data paging media - and keep it locked |
|
792 |
if ((DataPagingDfcQ(pM)) && ((r = LockMountInfo(*pM, m)) != KErrNone)) |
|
793 |
break; |
|
794 |
#endif |
|
795 |
||
796 |
pM->iMountInfo.iInfo=(TDesC8*)m.RemoteDes(); |
|
797 |
pM->iMountInfo.iThread=m.RemoteThread(); |
|
798 |
NKern::ThreadLeaveCS(); |
|
799 |
r=KErrNone; |
|
800 |
} |
|
801 |
break; |
|
802 |
} |
|
803 |
case RLocalDrive::EControlPasswordLock: |
|
804 |
{ |
|
805 |
m.Id()=EPasswordLock; |
|
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
806 |
m.RemoteDes() = a1; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
807 |
|
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
808 |
TMediaPassword oldPasswd; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
809 |
TMediaPassword newPasswd; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
810 |
TLocalDrivePasswordData pswData; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
811 |
r = ReadPasswordData(m, pswData, oldPasswd, newPasswd); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
812 |
|
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
813 |
if (r == KErrNone) |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
814 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
815 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_PASSWORDLOCK, "EPasswordLock; TLocDrvRequest Object=0x%x", (TUint) &m); |
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
816 |
r = iDrive->Request(m); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
817 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_PASSWORDLOCK_RETURN, "EPasswordLock Return; TLocDrvRequest Object=0x%x", (TUint) &m); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
818 |
} |
0 | 819 |
break; |
820 |
} |
|
821 |
case RLocalDrive::EControlPasswordUnlock: |
|
822 |
{ |
|
823 |
m.Id()=EPasswordUnlock; |
|
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
824 |
m.RemoteDes() = a1; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
825 |
|
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
826 |
TMediaPassword oldPasswd; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
827 |
TMediaPassword newPasswd; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
828 |
TLocalDrivePasswordData pswData; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
829 |
r = ReadPasswordData(m, pswData, oldPasswd, newPasswd); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
830 |
|
0 | 831 |
if(r == KErrNone) |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
832 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
833 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_PASSWORDUNLOCK, "EPasswordUnLock; TLocDrvRequest Object=0x%x", (TUint) &m); |
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
834 |
r=iDrive->Request(m); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
835 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_PASSWORDUNLOCK_RETURN, "EPasswordUnLock Return; TLocDrvRequest Object=0x%x", (TUint) &m); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
836 |
} |
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
837 |
if (r == KErrNone) |
0 | 838 |
iDrive->iPrimaryMedia->iTotalPartitionsOpened = 0; |
839 |
break; |
|
840 |
} |
|
841 |
case RLocalDrive::EControlPasswordClear: |
|
842 |
{ |
|
843 |
m.Id()=EPasswordClear; |
|
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
844 |
m.RemoteDes() = a1; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
845 |
|
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
846 |
TMediaPassword oldPasswd; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
847 |
TMediaPassword newPasswd; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
848 |
TLocalDrivePasswordData pswData; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
849 |
r = ReadPasswordData(m, pswData, oldPasswd, newPasswd); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
850 |
|
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
851 |
if (r == KErrNone) |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
852 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
853 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_PASSWORDCLEAR, "EPasswordClear; TLocDrvRequest Object=0x%x", (TUint) &m); |
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
854 |
r = iDrive->Request(m); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
855 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_PASSWORDCLEAR_RETURN, "EPasswordClear Return; TLocDrvRequest Object=0x%x", (TUint) &m); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
856 |
} |
0 | 857 |
break; |
858 |
} |
|
859 |
case RLocalDrive::EControlPasswordErase: |
|
860 |
{ |
|
861 |
m.Id()=EPasswordErase; |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
862 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_PASSWORDERASE, "EPasswordErase; TLocDrvRequest Object=0x%x", (TUint) &m); |
0 | 863 |
r=iDrive->Request(m); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
864 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_PASSWORDERASE_RETURN, "EPasswordErase Return; TLocDrvRequest Object=0x%x", (TUint) &m); |
0 | 865 |
if(r == KErrNone) |
866 |
iDrive->iPrimaryMedia->iTotalPartitionsOpened = 0; |
|
867 |
break; |
|
868 |
} |
|
869 |
case RLocalDrive::EControlNotifyChange: |
|
870 |
if (iCleanup.iThread != &Kern::CurrentThread()) |
|
871 |
Kern::PanicCurrentThread(KLitLocMedia,KErrAccessDenied); |
|
872 |
r=KErrNone; |
|
873 |
if (!iNotifyChangeRequest->StatusPtr()) |
|
874 |
r = iNotifyChangeRequest->SetStatus((TRequestStatus*) a1); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
875 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_CONTROLNOTIFYCHANGE, "EControlNotifyChange; TLocDrvRequest Object=0x%x", (TUint) &m); |
0 | 876 |
break; |
877 |
case RLocalDrive::EControlNotifyChangeCancel: |
|
878 |
if (iCleanup.iThread != &Kern::CurrentThread()) |
|
879 |
Kern::PanicCurrentThread(KLitLocMedia,KErrAccessDenied); |
|
880 |
Kern::QueueRequestComplete(iCleanup.iThread,iNotifyChangeRequest,KErrCancel); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
881 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_CONTROLNOTIFYCHANGECANCEL, "EControlNotifyChangeCancel; TLocDrvRequest Object=0x%x", (TUint) &m); |
0 | 882 |
break; |
883 |
case RLocalDrive::EControlReadPasswordStore: |
|
884 |
{ |
|
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
885 |
TUint8 passData[TPasswordStore::EMaxPasswordLength]; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
886 |
m.RemoteDes() = (TAny*) passData; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
887 |
m.Length() = sizeof(passData); |
0 | 888 |
m.Id()=EReadPasswordStore; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
889 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_READPASSWORDSTORE, "EReadPasswordStore; TLocDrvRequest Object=0x%x", (TUint) &m); |
0 | 890 |
r=iDrive->Request(m); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
891 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_READPASSWORDSTORE_RETURN, "EReadPasswordStore Return; TLocDrvRequest Object=0x%x", (TUint) &m); |
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
892 |
if (r==KErrNone) |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
893 |
{ |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
894 |
TPtr8 pData(passData, (TInt) m.Length(), TPasswordStore::EMaxPasswordLength); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
895 |
m.RemoteDes()=(TDes8*)a1; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
896 |
r = m.WriteRemote(&pData,0); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
897 |
} |
0 | 898 |
break; |
899 |
} |
|
900 |
case RLocalDrive::EControlWritePasswordStore: |
|
901 |
{ |
|
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
902 |
TUint8 passData[TPasswordStore::EMaxPasswordLength]; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
903 |
TPtr8 pData(passData, TPasswordStore::EMaxPasswordLength); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
904 |
|
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
905 |
DThread* pT=m.RemoteThread(); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
906 |
if (!pT) |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
907 |
pT=m.Client(); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
908 |
|
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
909 |
m.RemoteDes() = (TDes8*)a1; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
910 |
r = Kern::ThreadGetDesLength(pT, m.RemoteDes()); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
911 |
if ( r > pData.MaxLength() ) |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
912 |
r = KErrOverflow; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
913 |
if ( r < KErrNone) |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
914 |
break; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
915 |
|
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
916 |
r = m.ReadRemote(&pData,0); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
917 |
if (r != KErrNone) |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
918 |
break; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
919 |
|
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
920 |
|
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
921 |
m.RemoteDes() = (TAny*) pData.Ptr(); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
922 |
m.Length() = pData.Length(); |
0 | 923 |
m.Id()=EWritePasswordStore; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
924 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_WRITEPASSWORDSTORE, "EWritePasswordStore; TLocDrvRequest Object=0x%x", (TUint) &m); |
0 | 925 |
r=iDrive->Request(m); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
926 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_WRITEPASSWORDSTORE_RETURN, "EReadPasswordStore Return; TLocDrvRequest Object=0x%x", (TUint) &m); |
0 | 927 |
if(r == KErrNone) |
928 |
iDrive->iPrimaryMedia->iTotalPartitionsOpened = 0; |
|
929 |
break; |
|
930 |
} |
|
931 |
case RLocalDrive::EControlPasswordStoreLengthInBytes: |
|
932 |
{ |
|
933 |
m.Id()=EPasswordStoreLengthInBytes; |
|
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
934 |
TInt length; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
935 |
m.RemoteDes() = (TAny*) &length; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
936 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_PASSWORDSTORELENGTH, "EPasswordStoreLengthInBytes; TLocDrvRequest Object=0x%x", (TUint) &m); |
0 | 937 |
r=iDrive->Request(m); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
938 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_PASSWORDSTORELENGTH_RETURN, "EPasswordStoreLengthInBytes Return; TLocDrvRequest Object=0x%x", (TUint) &m); |
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
939 |
|
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
940 |
if (r == KErrNone) |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
941 |
{ |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
942 |
m.RemoteDes()=a1; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
943 |
r = m.WriteRemoteRaw(&length,sizeof(TInt)); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
944 |
} |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
945 |
|
0 | 946 |
break; |
947 |
} |
|
948 |
case RLocalDrive::EControlGetLastErrorInfo: |
|
949 |
{ |
|
950 |
m.Id()=EGetLastErrorInfo; |
|
951 |
m.iArg[0]=this; |
|
952 |
TErrorInfoBuf errorInfoBuf; |
|
953 |
errorInfoBuf.SetMax(); |
|
954 |
errorInfoBuf.FillZ(); |
|
955 |
m.RemoteDes()=(TAny*) errorInfoBuf.Ptr(); // overload this |
|
956 |
m.Length() = errorInfoBuf.MaxLength(); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
957 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_GETLASTERRORINFO, "EGetLastErrorInfo; TLocDrvRequest Object=0x%x", (TUint) &m); |
0 | 958 |
r=iDrive->Request(m); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
959 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_CONTROLGETLASTERRORINFO_RETURN, "EControlGetLastErrorInfo Return; TLocDrvRequest Object=0x%x", (TUint) &m); |
0 | 960 |
Kern::InfoCopy(*(TDes8*)a1, errorInfoBuf); |
961 |
break; |
|
962 |
} |
|
963 |
case RLocalDrive::EControlDeleteNotify: |
|
964 |
{ |
|
965 |
m.Id()=EDeleteNotify; |
|
966 |
r=m.ProcessMessageData(a1); |
|
967 |
if (r==KErrNone) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
968 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
969 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_DELETENOTIFY, "EDeleteNotify; TLocDrvRequest Object=0x%x", (TUint) &m); |
0 | 970 |
r=iDrive->Request(m); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
971 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_DELETENOTIFY_RETURN, "EDeleteNotify Return; TLocDrvRequest Object=0x%x", (TUint) &m); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
972 |
} |
0 | 973 |
break; |
974 |
} |
|
975 |
||
976 |
case RLocalDrive::EControlQueryDevice: |
|
977 |
{ |
|
978 |
TBuf8<KMaxQueryDeviceLength> queryBuf; |
|
979 |
queryBuf.SetMax(); |
|
980 |
queryBuf.FillZ(); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
981 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
982 |
DThread* pT = m.Client(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
983 |
r = Kern::ThreadDesRead(pT, (TDes8*)a2, queryBuf, 0 ,KChunkShiftBy0); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
984 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
985 |
queryBuf.SetMax(); |
0 | 986 |
m.Id() = EQueryDevice; |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
987 |
m.iArg[0] = a1; // RLocalDrive::TQueryDevice |
0 | 988 |
m.RemoteDes() = (TAny*)queryBuf.Ptr(); // overload this |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
989 |
m.Length() = KMaxQueryDeviceLength; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
990 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_QUERYDEVICE, "EQueryDevice; TLocDrvRequest Object=0x%x", (TUint) &m); |
0 | 991 |
r=iDrive->Request(m); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
992 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_QUERYDEVICE_RETURN, "EQueryDevice Return; TLocDrvRequest Object=0x%x", (TUint) &m); |
0 | 993 |
Kern::InfoCopy(*(TDes8*)a2, queryBuf); |
994 |
break; |
|
995 |
} |
|
996 |
||
997 |
} |
|
998 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("<DLocalDrive::DoControl D:%d M:%08x ret %d",iDrive->iDriveNumber, iDrive->iMedia, r)); |
|
999 |
__TRACE_TIMING(4); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1000 |
OstTraceFunctionExitExt( DLOCALDRIVE_REQUEST_EXIT, this, r ); |
0 | 1001 |
return r; |
1002 |
} |
|
1003 |
||
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1004 |
TInt DLocalDrive::ReadPasswordData(TLocDrvRequest& aReq, TLocalDrivePasswordData& aPswData, TMediaPassword& aOldPasswd, TMediaPassword& aNewPasswd) |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1005 |
{ |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1006 |
TLocalDrivePasswordData clientData; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1007 |
TInt r = aReq.ReadRemoteRaw(&clientData, sizeof(TLocalDrivePasswordData)); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1008 |
|
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1009 |
DThread* pT = aReq.RemoteThread(); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1010 |
if (!pT) |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1011 |
pT = aReq.Client(); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1012 |
|
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1013 |
if (r == KErrNone) |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1014 |
r = Kern::ThreadDesRead(pT, clientData.iOldPasswd, aOldPasswd, 0 ,KChunkShiftBy0); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1015 |
if (r == KErrNone) |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1016 |
r = Kern::ThreadDesRead(pT, clientData.iNewPasswd, aNewPasswd, 0 ,KChunkShiftBy0); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1017 |
|
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1018 |
aPswData.iStorePasswd = clientData.iStorePasswd; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1019 |
aPswData.iOldPasswd = &aOldPasswd; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1020 |
aPswData.iNewPasswd = &aNewPasswd; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1021 |
|
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1022 |
|
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1023 |
aReq.RemoteDes() = (TAny*) &aPswData; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1024 |
aReq.Flags()|= TLocDrvRequest::EKernelBuffer; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1025 |
|
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1026 |
return r; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1027 |
} |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1028 |
|
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1029 |
|
0 | 1030 |
#ifdef __DEMAND_PAGING__ |
1031 |
TInt DLocalDrive::LockMountInfo(DPrimaryMediaBase& aPrimaryMedia, TLocDrvRequest& aReq) |
|
1032 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1033 |
OstTraceExt2(TRACE_FLOW, DLOCALDRIVE_LOCKMOUNTINFO_ENTRY, "> aPrimaryMedia=%x;aReq=%x", (TUint) &aPrimaryMedia, (TUint) &aReq ); |
0 | 1034 |
DMediaPagingDevice* pagingDevice = aPrimaryMedia.iBody->iPagingDevice; |
1035 |
if (pagingDevice == NULL) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1036 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1037 |
OstTraceFunctionExitExt( DLOCALDRIVE_LOCKMOUNTINFO_EXIT1, this, KErrNone ); |
0 | 1038 |
return KErrNone; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1039 |
} |
0 | 1040 |
|
1041 |
__ASSERT_DEBUG(pagingDevice->iMountInfoDataLock == NULL, LOCM_FAULT()); |
|
1042 |
__ASSERT_DEBUG(pagingDevice->iMountInfoDescHdrLock == NULL, LOCM_FAULT()); |
|
1043 |
__ASSERT_DEBUG(pagingDevice->iMountInfoDescLenLock == NULL, LOCM_FAULT()); |
|
1044 |
||
1045 |
DThread* pT = aReq.RemoteThread(); |
|
1046 |
if (!pT) |
|
1047 |
pT = &Kern::CurrentThread(); // e.g. when using TBusLocalDrive directly |
|
1048 |
||
1049 |
TInt length = 0; |
|
1050 |
TInt maxLength = 0; |
|
1051 |
TUint8* desAddress = NULL; |
|
1052 |
TInt r = Kern::ThreadGetDesInfo(pT,aReq.RemoteDes(),length,maxLength,desAddress,EFalse); // get descriptor length, maxlength and desAddress |
|
1053 |
if (r != KErrNone) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1054 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1055 |
OstTraceFunctionExitExt( DLOCALDRIVE_LOCKMOUNTINFO_EXIT2, this, r ); |
0 | 1056 |
return r; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1057 |
} |
0 | 1058 |
if (length == 0) |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1059 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1060 |
OstTraceFunctionExitExt( DLOCALDRIVE_LOCKMOUNTINFO_EXIT3, this, KErrNone ); |
0 | 1061 |
return KErrNone; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1062 |
} |
0 | 1063 |
|
1064 |
||
1065 |
static const TUint8 LengthLookup[16]={4,8,12,8,12,0,0,0,0,0,0,0,0,0,0,0}; |
|
1066 |
TUint32 desHdr; |
|
1067 |
r = Kern::ThreadRawRead(pT, aReq.RemoteDes(), &desHdr, sizeof(desHdr)); |
|
1068 |
if(r!=KErrNone) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1069 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1070 |
OstTraceFunctionExitExt( DLOCALDRIVE_LOCKMOUNTINFO_EXIT4, this, r ); |
0 | 1071 |
return r; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1072 |
} |
0 | 1073 |
TInt desType = desHdr >>KShiftDesType8; |
1074 |
TInt desHdrLen = LengthLookup[desType]; |
|
1075 |
if(!desHdrLen) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1076 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1077 |
OstTraceFunctionExitExt( DLOCALDRIVE_LOCKMOUNTINFO_EXIT5, this, KErrBadDescriptor ); |
0 | 1078 |
return KErrBadDescriptor; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1079 |
} |
0 | 1080 |
|
1081 |
||
1082 |
pagingDevice->iMountInfoDataLock = ThePinObjectAllocator->AcquirePinObject(); |
|
1083 |
pagingDevice->iMountInfoDescHdrLock = ThePinObjectAllocator->AcquirePinObject(); |
|
1084 |
pagingDevice->iMountInfoDescLenLock = ThePinObjectAllocator->AcquirePinObject(); |
|
1085 |
||
1086 |
if (pagingDevice->iMountInfoDataLock == NULL || |
|
1087 |
pagingDevice->iMountInfoDescHdrLock == NULL || |
|
1088 |
pagingDevice->iMountInfoDescLenLock == NULL) |
|
1089 |
{ |
|
1090 |
UnlockMountInfo(aPrimaryMedia); // tidy up |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1091 |
OstTraceFunctionExitExt( DLOCALDRIVE_LOCKMOUNTINFO_EXIT6, this, KErrNoMemory ); |
0 | 1092 |
return KErrNoMemory; |
1093 |
} |
|
1094 |
||
1095 |
||
1096 |
// First pin the descriptor header |
|
1097 |
DPinObjectAllocator::SVirtualPinContainer* lock; |
|
1098 |
lock = (DPinObjectAllocator::SVirtualPinContainer*) pagingDevice->iMountInfoDescHdrLock; |
|
1099 |
r = Kern::PinVirtualMemory(lock->iObject, (TLinAddr) (TUint8*) aReq.RemoteDes(), desHdrLen, pT); |
|
1100 |
if (r != KErrNone) |
|
1101 |
{ |
|
1102 |
UnlockMountInfo(aPrimaryMedia); // tidy up |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1103 |
OstTraceFunctionExitExt( DLOCALDRIVE_LOCKMOUNTINFO_EXIT7, this, KErrNoMemory ); |
0 | 1104 |
return KErrNoMemory; |
1105 |
} |
|
1106 |
||
1107 |
||
1108 |
||
1109 |
// For EBufCPtr-type descriptors, need to pin the extra length before the buffer (!) |
|
1110 |
lock = (DPinObjectAllocator::SVirtualPinContainer*) pagingDevice->iMountInfoDescLenLock; |
|
1111 |
if (desType == EBufCPtr) |
|
1112 |
{ |
|
1113 |
TLinAddr extraLenAddr = TLinAddr(desAddress) - aReq.RemoteDesOffset() - sizeof(TUint32); |
|
1114 |
r = Kern::PinVirtualMemory(lock->iObject, (TLinAddr) (TUint8*) extraLenAddr, sizeof(TUint32), pT); |
|
1115 |
if (r != KErrNone) |
|
1116 |
{ |
|
1117 |
UnlockMountInfo(aPrimaryMedia); // tidy up |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1118 |
OstTraceFunctionExitExt( DLOCALDRIVE_LOCKMOUNTINFO_EXIT8, this, KErrNoMemory ); |
0 | 1119 |
return KErrNoMemory; |
1120 |
} |
|
1121 |
} |
|
1122 |
||
1123 |
||
1124 |
// Now pin the descriptor contents |
|
1125 |
lock = (DPinObjectAllocator::SVirtualPinContainer*) pagingDevice->iMountInfoDataLock; |
|
1126 |
r = Kern::PinVirtualMemory(lock->iObject, (TLinAddr) desAddress, length, pT); |
|
1127 |
if (r != KErrNone) |
|
1128 |
{ |
|
1129 |
UnlockMountInfo(aPrimaryMedia); // tidy up |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1130 |
OstTraceFunctionExitExt( DLOCALDRIVE_LOCKMOUNTINFO_EXIT9, this, KErrNoMemory ); |
0 | 1131 |
return KErrNoMemory; |
1132 |
} |
|
1133 |
||
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1134 |
OstTraceFunctionExitExt( DLOCALDRIVE_LOCKMOUNTINFO_EXIT10, this, KErrNone ); |
0 | 1135 |
return KErrNone; |
1136 |
} |
|
1137 |
||
1138 |
||
1139 |
void DLocalDrive::UnlockMountInfo(DPrimaryMediaBase& aPrimaryMedia) |
|
1140 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1141 |
OstTrace1(TRACE_FLOW, DLOCALDRIVE_UNLOCKMOUNTINFO_ENTRY, "> DLocalDrive::UnlockMountInfo;aPrimaryMedia=%x", (TUint) &aPrimaryMedia); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1142 |
|
0 | 1143 |
DMediaPagingDevice* pagingDevice = aPrimaryMedia.iBody->iPagingDevice; |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1144 |
if (pagingDevice == NULL) |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1145 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1146 |
OstTraceFunctionExit1( DLOCALDRIVE_UNLOCKMOUNTINFO_EXIT1, this ); |
0 | 1147 |
return; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1148 |
} |
0 | 1149 |
|
1150 |
||
1151 |
if (pagingDevice->iMountInfoDataLock) |
|
1152 |
{ |
|
1153 |
Kern::UnpinVirtualMemory(((DPinObjectAllocator::SVirtualPinContainer*) pagingDevice->iMountInfoDataLock)->iObject); |
|
1154 |
ThePinObjectAllocator->ReleasePinObject((DPinObjectAllocator::SVirtualPinContainer*) pagingDevice->iMountInfoDataLock); |
|
1155 |
pagingDevice->iMountInfoDataLock = NULL; |
|
1156 |
} |
|
1157 |
||
1158 |
if (pagingDevice->iMountInfoDescHdrLock) |
|
1159 |
{ |
|
1160 |
Kern::UnpinVirtualMemory(((DPinObjectAllocator::SVirtualPinContainer*) pagingDevice->iMountInfoDescHdrLock)->iObject); |
|
1161 |
ThePinObjectAllocator->ReleasePinObject((DPinObjectAllocator::SVirtualPinContainer*) pagingDevice->iMountInfoDescHdrLock); |
|
1162 |
pagingDevice->iMountInfoDescHdrLock = NULL; |
|
1163 |
} |
|
1164 |
||
1165 |
if (pagingDevice->iMountInfoDescLenLock) |
|
1166 |
{ |
|
1167 |
Kern::UnpinVirtualMemory(((DPinObjectAllocator::SVirtualPinContainer*) pagingDevice->iMountInfoDescLenLock)->iObject); |
|
1168 |
ThePinObjectAllocator->ReleasePinObject((DPinObjectAllocator::SVirtualPinContainer*) pagingDevice->iMountInfoDescLenLock); |
|
1169 |
pagingDevice->iMountInfoDescLenLock = NULL; |
|
1170 |
} |
|
1171 |
||
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1172 |
OstTraceFunctionExit1( DLOCALDRIVE_UNLOCKMOUNTINFO_EXIT2, this ); |
0 | 1173 |
} |
1174 |
#endif // __DEMAND_PAGING__ |
|
1175 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1176 |
void DLocalDrive::NotifyChange() |
0 | 1177 |
{ |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1178 |
OstTrace0( TRACE_FLOW, DLOCALDRIVE_NOTIFYCHANGE_ENTRY, "> DLocalDrive::NotifyChange"); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1179 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1180 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1181 |
// Complete any notification request on media change |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1182 |
DThread* pC=NULL; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1183 |
NKern::LockSystem(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1184 |
if (iCleanup.iThread) |
0 | 1185 |
{ |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1186 |
pC=iCleanup.iThread; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1187 |
pC->Open(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1188 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1189 |
NKern::UnlockSystem(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1190 |
if (pC) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1191 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1192 |
TBool b = ETrue; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1193 |
// if change not yet queued, queue it now |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1194 |
if (iNotifyChangeRequest->IsReady()) |
0 | 1195 |
{ |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1196 |
*((TBool*) iNotifyChangeRequest->Buffer()) = b; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1197 |
Kern::QueueRequestComplete(pC,iNotifyChangeRequest,KErrNone); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1198 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1199 |
// If change has not even been requested by the client, maintain the pre-wdp behaviour |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1200 |
// and write data immediately back to client (possibly taking a page fault) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1201 |
// N.B. Must NOT do this on data paging media |
0 | 1202 |
#ifdef __DEMAND_PAGING__ |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1203 |
else if (!DataPagingDfcQ(iDrive->iPrimaryMedia)) |
0 | 1204 |
#else |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1205 |
else |
0 | 1206 |
#endif |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1207 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1208 |
Kern::ThreadRawWrite(pC, iNotifyChangeRequest->DestPtr(), &b, sizeof(b), NULL); |
0 | 1209 |
} |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1210 |
pC->AsyncClose(); |
0 | 1211 |
} |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1212 |
OstTraceFunctionExit1( DLOCALDRIVE_NOTIFYCHANGE_EXIT, this ); |
0 | 1213 |
} |
1214 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1215 |
// This function is called by the primary media when a media change occurs |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1216 |
TInt DLocalDrive::MediaChangeCallback(TAny* aLocalDrive, TInt /* aNotifyType*/) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1217 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1218 |
((DLocalDrive*) aLocalDrive)->NotifyChange(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1219 |
return KErrNone; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1220 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1221 |
|
0 | 1222 |
TLocalDriveCleanup::TLocalDriveCleanup() |
1223 |
{ |
|
1224 |
} |
|
1225 |
||
1226 |
// This will be called when the original client thread exits |
|
1227 |
// It is called in the context of the exiting thread with the system locked. |
|
1228 |
void TLocalDriveCleanup::Cleanup() |
|
1229 |
{ |
|
1230 |
DLocalDrive& d=LocalDrive(); |
|
1231 |
d.iNotifyChangeRequest=NULL; |
|
1232 |
DThread* pC=iThread; |
|
1233 |
Remove(); |
|
1234 |
iThread=NULL; |
|
1235 |
NKern::UnlockSystem(); |
|
1236 |
pC->Close(NULL); // balances Open() in DoCreate |
|
1237 |
NKern::LockSystem(); |
|
1238 |
} |
|
1239 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1240 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1241 |
EXPORT_C TInt DLocalDrive::Caps(TInt aDriveNumber, TDes8& aCaps) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1242 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1243 |
if(!Kern::CurrentThreadHasCapability(ECapabilityTCB,__PLATSEC_DIAGNOSTIC_STRING("Checked by ELOCD.LDD (Local Media Driver)"))) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1244 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1245 |
return KErrPermissionDenied; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1246 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1247 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1248 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1249 |
if (aDriveNumber >= KMaxLocalDrives) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1250 |
return KErrArgument; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1251 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1252 |
TLocDrv* drive = TheDrives[aDriveNumber]; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1253 |
if (!drive) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1254 |
return KErrNotSupported; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1255 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1256 |
TLocDrvRequest request; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1257 |
memclr(&request, sizeof(request)); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1258 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1259 |
request.Drive() = drive; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1260 |
request.Id() = DLocalDrive::ECaps; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1261 |
request.Length() = aCaps.Length(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1262 |
request.RemoteDes() = (TAny*) aCaps.Ptr(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1263 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1264 |
return request.SendReceive(&drive->iPrimaryMedia->iMsgQ); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1265 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1266 |
|
0 | 1267 |
/******************************************** |
1268 |
* Local drive request class |
|
1269 |
********************************************/ |
|
1270 |
||
1271 |
/** |
|
1272 |
Reads data from the descriptor specified in the request, from the requesting |
|
1273 |
thread's process. |
|
1274 |
||
1275 |
This is used by the media driver to read data from a descriptor in the |
|
1276 |
requesting thread. The remote data is copied into the specified descriptor, |
|
1277 |
starting at the specified offset within that descriptor's data area. |
|
1278 |
||
1279 |
@param aDes The target descriptor into which data from the remote thread |
|
1280 |
is to be put. |
|
1281 |
@param anOffset The offset within the target descriptor data area, where data |
|
1282 |
from the remote thread is to be put. Note that this parameter |
|
1283 |
may be useful when write operations to the media must be broken |
|
1284 |
up into smaller chunks than the length requested. |
|
1285 |
||
1286 |
@return KErrNone,if successful, otherwise one of the other |
|
1287 |
system-wide error codes. |
|
1288 |
||
1289 |
@see Kern::ThreadDesRead() |
|
1290 |
*/ |
|
1291 |
EXPORT_C TInt TLocDrvRequest::ReadRemote(TDes8* aDes, TInt anOffset) |
|
1292 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1293 |
OstTraceFunctionEntry1( TLOCDRVREQUEST_READREMOTE_ENTRY, this ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1294 |
TInt r; |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1295 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1296 |
if (Flags() & TLocDrvRequest::EKernelBuffer) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1297 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1298 |
(void)memcpy((TAny*) aDes->Ptr(), (TAny*)((TUint32)RemoteDes()+anOffset), aDes->MaxLength()); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1299 |
aDes->SetLength(aDes->MaxLength()); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1300 |
return KErrNone; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1301 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1302 |
|
0 | 1303 |
DThread* pT=RemoteThread(); |
1304 |
if (!pT) |
|
1305 |
pT=Client(); |
|
1306 |
||
1307 |
#ifdef __DEMAND_PAGING__ // only if driver has its own thread, we don't support paging in MD which run in the context of their clients |
|
1308 |
if (Flags() & ETClientBuffer) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1309 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1310 |
r = Kern::ThreadBufRead(pT, (TClientBuffer*) RemoteDes(),*aDes,anOffset+RemoteDesOffset(),KChunkShiftBy0); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1311 |
OstTraceFunctionExitExt( TLOCDRVREQUEST_READREMOTE_EXIT1, this, r ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1312 |
return r; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1313 |
} |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1314 |
|
0 | 1315 |
__ASSERT_ALWAYS((Flags() & ETClientBuffer) == 0, LOCM_FAULT()); |
1316 |
#endif |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1317 |
r = Kern::ThreadDesRead(pT,RemoteDes(),*aDes,anOffset+RemoteDesOffset(),KChunkShiftBy0); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1318 |
OstTraceFunctionExitExt( TLOCDRVREQUEST_READREMOTE_EXIT2, this, r ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1319 |
return r; |
0 | 1320 |
} |
1321 |
||
1322 |
||
1323 |
||
1324 |
||
1325 |
/** |
|
1326 |
Reads data from an arbitrary descriptor in the requesting thread's process. |
|
1327 |
||
1328 |
This is used by the media driver to read data from a descriptor in the |
|
1329 |
requesting thread. |
|
1330 |
||
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1331 |
NB This is NOT supported on datapaging media as there is no guarantee |
0 | 1332 |
that the remote descriptor won't be paged out. If this function is called and |
1333 |
data-paging is enabled the kernel will fault in debug mode and return |
|
1334 |
KErrNotSupported in release mode. |
|
1335 |
||
1336 |
@param aSrc A pointer to the source descriptor in the requesting thread's |
|
1337 |
address space. |
|
1338 |
@param aDes The target descriptor into which data from the remote thread |
|
1339 |
is to be put. |
|
1340 |
||
1341 |
@return KErrNone,if successful, |
|
1342 |
KErrNotSupported if data-paging is enabled |
|
1343 |
otherwise one of the other system-wide error codes. |
|
1344 |
||
1345 |
@see Kern::ThreadDesRead() |
|
1346 |
*/ |
|
1347 |
EXPORT_C TInt TLocDrvRequest::ReadRemote(const TAny* aSrc, TDes8* aDes) |
|
1348 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1349 |
OstTraceFunctionEntry1( TLOCDRVREQUEST_READ_REMOTE_ENTRY, this ); |
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1350 |
if (Flags() & TLocDrvRequest::EKernelBuffer) |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1351 |
{ |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1352 |
aDes->Copy(* (TDesC8*) aSrc); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1353 |
return KErrNone; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1354 |
} |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1355 |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1356 |
TInt r; |
0 | 1357 |
DThread* pT=RemoteThread(); |
1358 |
if (!pT) |
|
1359 |
pT=Client(); |
|
1360 |
||
1361 |
#ifdef __DEMAND_PAGING__ |
|
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1362 |
__ASSERT_DEBUG(!DataPagingDfcQ(Drive()->iPrimaryMedia), LOCM_FAULT()); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1363 |
|
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1364 |
if (DataPagingDfcQ(Drive()->iPrimaryMedia)) |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1365 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1366 |
OstTraceFunctionExitExt( TLOCDRVREQUEST_READ_REMOTE_EXIT1, this, KErrNotSupported ); |
0 | 1367 |
return KErrNotSupported; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1368 |
} |
0 | 1369 |
#endif |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1370 |
|
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1371 |
r = Kern::ThreadDesRead(pT,aSrc,*aDes,0,KChunkShiftBy0); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1372 |
OstTraceFunctionExitExt( TLOCDRVREQUEST_READ_REMOTE_EXIT2, this, r ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1373 |
return r; |
0 | 1374 |
} |
1375 |
||
1376 |
||
1377 |
||
1378 |
||
1379 |
/** |
|
1380 |
Reads raw data from the requesting thread's process. |
|
1381 |
||
1382 |
This is used by the media driver to read raw data from a location in requesting |
|
1383 |
thread's address space. The remote data is copied into the specified |
|
1384 |
buffer. |
|
1385 |
||
1386 |
@param aDest A pointer to the buffer where the data is to be written. |
|
1387 |
@param aSize The number of bytes to read. |
|
1388 |
||
1389 |
@return KErrNone,if successful, otherwise one of the other |
|
1390 |
system-wide error codes. |
|
1391 |
||
1392 |
@see Kern::ThreadRawRead() |
|
1393 |
*/ |
|
1394 |
EXPORT_C TInt TLocDrvRequest::ReadRemoteRaw(TAny* aDest, TInt aSize) |
|
1395 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1396 |
OstTraceFunctionEntry1( TLOCDRVREQUEST_READREMOTERAW_ENTRY, this ); |
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1397 |
if (Flags() & TLocDrvRequest::EKernelBuffer) |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1398 |
{ |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1399 |
(void)memcpy(aDest, (TAny*) RemoteDes(), aSize); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1400 |
return KErrNone; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1401 |
} |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1402 |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1403 |
TInt r; |
0 | 1404 |
DThread* pT=RemoteThread(); |
1405 |
if (!pT) |
|
1406 |
pT=Client(); |
|
1407 |
||
1408 |
#ifdef __DEMAND_PAGING__ |
|
1409 |
__ASSERT_ALWAYS((Flags() & ETClientBuffer) == 0, LOCM_FAULT()); |
|
1410 |
#endif |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1411 |
|
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1412 |
r = Kern::ThreadRawRead(pT,RemoteDes(),aDest,aSize); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1413 |
OstTraceFunctionExitExt( TLOCDRVREQUEST_READREMOTERAW_EXIT, this, r ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1414 |
return r; |
0 | 1415 |
} |
1416 |
||
1417 |
||
1418 |
/** |
|
1419 |
Writes data to a descriptor in the requesting thread's process. |
|
1420 |
||
1421 |
This is used by the media driver to write data to a descriptor in the requesting |
|
1422 |
thread. Data is copied from the specified descriptor, starting at the specified |
|
1423 |
offset within that descriptor's data area. |
|
1424 |
||
1425 |
@param aDes The source descriptor from which data is to be written to |
|
1426 |
the remote thread. |
|
1427 |
||
1428 |
@param anOffset The offset within the source descriptor data area, from where data |
|
1429 |
is to be written to the remote thread. Note that this parameter |
|
1430 |
may be useful when read operations from the media must be broken |
|
1431 |
up into smaller chunks than the length requested. |
|
1432 |
||
1433 |
@return KErrNone,if successful, otherwise one of the other |
|
1434 |
system-wide error codes. |
|
1435 |
||
1436 |
@see Kern::ThreadDesWrite() |
|
1437 |
*/ |
|
1438 |
EXPORT_C TInt TLocDrvRequest::WriteRemote(const TDesC8* aDes, TInt anOffset) |
|
1439 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1440 |
OstTraceFunctionEntry1( TLOCDRVREQUEST_WRITEREMOTE_ENTRY, this ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1441 |
TInt r; |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1442 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1443 |
if (Flags() & TLocDrvRequest::EKernelBuffer) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1444 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1445 |
(void)memcpy((TAny*)((TUint32)RemoteDes()+anOffset), (TAny*) aDes->Ptr(), aDes->Length()); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1446 |
OstTraceFunctionExitExt( TLOCDRVREQUEST_WRITEREMOTE_EXIT1, this, KErrNone ); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1447 |
return KErrNone; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1448 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1449 |
|
0 | 1450 |
DThread* pC=Client(); |
1451 |
DThread* pT=RemoteThread(); |
|
1452 |
if (!pT) |
|
1453 |
pT=pC; |
|
1454 |
||
1455 |
#ifdef __DEMAND_PAGING__ |
|
1456 |
if (Flags() & ETClientBuffer) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1457 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1458 |
r = Kern::ThreadBufWrite(pT, (TClientBuffer*) RemoteDes(),*aDes,anOffset+RemoteDesOffset(),KChunkShiftBy0,pC); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1459 |
OstTraceFunctionExitExt( TLOCDRVREQUEST_WRITEREMOTE_EXIT2, this, r ); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1460 |
return r; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1461 |
} |
0 | 1462 |
#endif |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1463 |
r = Kern::ThreadDesWrite(pT,RemoteDes(),*aDes,anOffset+RemoteDesOffset(),KChunkShiftBy0,pC); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1464 |
OstTraceFunctionExitExt( TLOCDRVREQUEST_WRITEREMOTE_EXIT3, this, r ); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1465 |
return r; |
0 | 1466 |
} |
1467 |
||
1468 |
||
1469 |
/** |
|
1470 |
Writes raw data to the requesting thread's process. |
|
1471 |
||
1472 |
This is used by the media driver to write raw data to a location in the |
|
1473 |
requesting thread's address space. |
|
1474 |
||
1475 |
@param aSrc The source addres from which data is to be written to |
|
1476 |
the remote thread. |
|
1477 |
||
1478 |
@param aSize The number of bytes to write. |
|
1479 |
||
1480 |
@return KErrNone,if successful, otherwise one of the other |
|
1481 |
system-wide error codes. |
|
1482 |
||
1483 |
@see Kern::ThreadRawWrite() |
|
1484 |
*/ |
|
1485 |
EXPORT_C TInt TLocDrvRequest::WriteRemoteRaw(const TAny* aSrc, TInt aSize) |
|
1486 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1487 |
OstTraceFunctionEntry1( TLOCDRVREQUEST_WRITEREMOTERAW_ENTRY, this ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1488 |
TInt r; |
0 | 1489 |
DThread* pC=Client(); |
1490 |
DThread* pT=RemoteThread(); |
|
1491 |
if (!pT) |
|
1492 |
pT=pC; |
|
1493 |
||
1494 |
#ifdef __DEMAND_PAGING__ |
|
1495 |
__ASSERT_ALWAYS((Flags() & ETClientBuffer) == 0, LOCM_FAULT()); |
|
1496 |
#endif |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1497 |
r = Kern::ThreadRawWrite(pT,RemoteDes(),aSrc,aSize,pC); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1498 |
OstTraceFunctionExitExt( TLOCDRVREQUEST_WRITEREMOTERAW_EXIT, this, r ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1499 |
return r; |
0 | 1500 |
} |
1501 |
||
1502 |
||
1503 |
TInt TLocDrvRequest::ProcessMessageData(TAny* aPtr) |
|
1504 |
// |
|
1505 |
// Get read/write parameters from client and open remote thread |
|
1506 |
// |
|
1507 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1508 |
OstTraceFunctionEntry1( TLOCDRVREQUEST_PROCESSMESSAGEDATA_ENTRY, this ); |
0 | 1509 |
RemoteThread()=NULL; |
1510 |
DThread& t=Kern::CurrentThread(); |
|
1511 |
TLocalDriveMessageData d; |
|
1512 |
kumemget32(&d,aPtr,sizeof(d)); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1513 |
OstTrace1( TRACE_INTERNALS, TLOCDRVREQUEST_PROCESSMESSAGEDATA, "Message handle=%d", d.iHandle ); |
0 | 1514 |
if (d.iHandle!=KLocalMessageHandle && Id()!=DLocalDrive::EFormat) |
1515 |
{ |
|
1516 |
NKern::LockSystem(); |
|
1517 |
DThread* pT = RMessageK::MessageK(d.iHandle)->iClient; |
|
1518 |
if (!pT || pT->Open()!=KErrNone) |
|
1519 |
{ |
|
1520 |
NKern::UnlockSystem(); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1521 |
OstTraceFunctionExitExt( TLOCDRVREQUEST_PROCESSMESSAGEDATA_EXIT1, this, KErrBadHandle ); |
0 | 1522 |
return KErrBadHandle; |
1523 |
} |
|
1524 |
t.iExtTempObj=pT; |
|
1525 |
RemoteThread()=pT; |
|
1526 |
NKern::UnlockSystem(); |
|
1527 |
} |
|
1528 |
Pos()=d.iPos; |
|
1529 |
Length()=d.iLength; |
|
1530 |
RemoteDes()=(TAny*)d.iPtr; |
|
1531 |
RemoteDesOffset()=d.iOffset; |
|
1532 |
DriverFlags()=d.iFlags; |
|
201
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
1533 |
|
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
1534 |
// EPhysAddrOnly should not be set for client requests |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
1535 |
Flags() &= ~TLocDrvRequest::EPhysAddrOnly; |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
1536 |
|
0 | 1537 |
if (Pos()<0 || Length()<0) |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1538 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1539 |
OstTraceFunctionExitExt( TLOCDRVREQUEST_PROCESSMESSAGEDATA_EXIT2, this, KErrArgument ); |
0 | 1540 |
return KErrArgument; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1541 |
} |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1542 |
OstTraceFunctionExitExt( TLOCDRVREQUEST_PROCESSMESSAGEDATA_EXIT3, this, KErrNone ); |
0 | 1543 |
return KErrNone; |
1544 |
} |
|
1545 |
||
1546 |
void TLocDrvRequest::CloseRemoteThread() |
|
1547 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1548 |
OstTraceFunctionEntry1( TLOCDRVREQUEST_CLOSEREMOTETHREAD_ENTRY, this ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1549 |
|
0 | 1550 |
if (!RemoteThread()) |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1551 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1552 |
OstTraceFunctionExit1( TLOCDRVREQUEST_CLOSEREMOTETHREAD_EXIT1, this ); |
0 | 1553 |
return; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1554 |
} |
0 | 1555 |
NKern::ThreadEnterCS(); |
1556 |
DThread& t=Kern::CurrentThread(); |
|
1557 |
RemoteThread()=NULL; |
|
1558 |
Kern::SafeClose((DObject*&)t.iExtTempObj,NULL); |
|
1559 |
NKern::ThreadLeaveCS(); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1560 |
OstTraceFunctionExit1( TLOCDRVREQUEST_CLOSEREMOTETHREAD_EXIT2, this ); |
0 | 1561 |
} |
1562 |
||
1563 |
EXPORT_C TInt TLocDrvRequest::CheckAndAdjustForPartition() |
|
1564 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1565 |
OstTraceFunctionEntry1( TLOCDRVREQUEST_CHECKANDADJUSTFORPARTITION_ENTRY, this ); |
0 | 1566 |
TLocDrv& d=*Drive(); |
1567 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("CheckAndAdjustForPartition drive %d partition len %lx",d.iDriveNumber,d.iPartitionLen)); |
|
200
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
152
diff
changeset
|
1568 |
OstTraceExt3( TRACE_INTERNALS, TLOCDRVREQUEST_CHECKANDADJUSTFORPARTITION1, "iDriveNumber=%d; partition length=%x:%x", d.iDriveNumber, (TInt) I64HIGH (d.iPartitionLen), (TInt) I64LOW (d.iPartitionLen)); |
0 | 1569 |
Flags() |= EAdjusted; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1570 |
TInt r; |
0 | 1571 |
switch (Id()) |
1572 |
{ |
|
1573 |
case DLocalDrive::ECaps: |
|
1574 |
case DLocalDrive::EForceMediaChange: |
|
1575 |
case DLocalDrive::EPasswordLock: |
|
1576 |
case DLocalDrive::EPasswordUnlock: |
|
1577 |
case DLocalDrive::EPasswordClear: |
|
1578 |
case DLocalDrive::EPasswordErase: |
|
1579 |
case DLocalDrive::EReadPasswordStore: |
|
1580 |
case DLocalDrive::EWritePasswordStore: |
|
1581 |
case DLocalDrive::EPasswordStoreLengthInBytes: |
|
1582 |
case DLocalDrive::EQueryDevice: |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1583 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1584 |
r = KErrNone; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1585 |
break; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1586 |
} |
0 | 1587 |
case DLocalDrive::EEnlarge: |
1588 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("Enlarge request %lx",Length())); |
|
200
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
152
diff
changeset
|
1589 |
OstTraceExt2( TRACE_INTERNALS, TLOCDRVREQUEST_CHECKANDADJUSTFORPARTITION2, "Enlarge request=%x:%x", (TInt) I64HIGH(Length()), (TInt) I64LOW(Length()) ); |
0 | 1590 |
if (Length()>KMaxTInt) |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1591 |
r = KErrArgument; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1592 |
else |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1593 |
r = KErrNone; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1594 |
break; |
0 | 1595 |
case DLocalDrive::EReduce: |
1596 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("Reduce request %lx@%lx",Length(),Pos())); |
|
200
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
152
diff
changeset
|
1597 |
OstTraceExt4( TRACE_INTERNALS, TLOCDRVREQUEST_CHECKANDADJUSTFORPARTITION3, "Reduce request length=%x:%x; position=%x:%x", (TUint) I64HIGH(Length()), (TUint) I64LOW(Length()), (TUint) I64HIGH (Pos()), (TUint) I64LOW (Pos()) ); |
0 | 1598 |
if (Pos()+Length()>d.iPartitionLen) |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1599 |
r = KErrArgument; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1600 |
else |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1601 |
r = KErrNone; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1602 |
break; |
0 | 1603 |
case DLocalDrive::EFormat: |
1604 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("Format request %lx@%lx",Length(),Pos())); |
|
200
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
152
diff
changeset
|
1605 |
OstTraceExt4( TRACE_INTERNALS, TLOCDRVREQUEST_CHECKANDADJUSTFORPARTITION4, "Format request length=%x:%x; position=%x:%x", (TUint) I64HIGH(Length()),(TUint) I64LOW(Length()), (TUint) I64HIGH (Pos()), (TUint) I64LOW (Pos()) ); |
0 | 1606 |
if (!(DriverFlags() & RLocalDrive::ELocDrvWholeMedia)) |
1607 |
{ |
|
1608 |
if (Pos()>d.iPartitionLen) |
|
1609 |
{ |
|
1610 |
Length()=0; |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1611 |
r = KErrEof; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1612 |
break; |
0 | 1613 |
} |
1614 |
Int64 left=d.iPartitionLen-Pos(); |
|
1615 |
if (left<Length()) |
|
1616 |
Length()=left; |
|
1617 |
Pos()+=d.iPartitionBaseAddr; |
|
1618 |
if (Length()==0) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1619 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1620 |
r = KErrEof; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1621 |
break; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1622 |
} |
0 | 1623 |
} |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1624 |
r = KErrNone; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1625 |
break; |
0 | 1626 |
|
1627 |
#ifdef __DEMAND_PAGING__ |
|
1628 |
case DMediaPagingDevice::ERomPageInRequest: |
|
1629 |
// if the ROM was reported to LOCM then it will also need to be adjusted.... |
|
1630 |
// Otherwise the media driver adjust it internally |
|
1631 |
case DMediaPagingDevice::ECodePageInRequest: |
|
1632 |
__KTRACE_OPT(KLOCDPAGING,Kern::Printf("Adjusted Paging read request %lx@%lx",Length(),Pos())); |
|
200
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
152
diff
changeset
|
1633 |
OstTraceDefExt4(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, TLOCDRVREQUESTCHECKANDADJUSTFORPARTITION5, "Adjusted Paging read request length=%x:%x; position=%x%:%x", (TUint) I64HIGH(Length()), (TUint) I64LOW(Length()), (TUint) I64HIGH (Pos()), (TUint) I64LOW (Pos())); |
0 | 1634 |
if (Pos()+Length()>d.iPartitionLen) |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1635 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1636 |
r = KErrArgument; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1637 |
break; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1638 |
} |
0 | 1639 |
Pos()+=d.iPartitionBaseAddr; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1640 |
r = KErrNone; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1641 |
break; |
0 | 1642 |
#endif |
1643 |
||
1644 |
default: // read or write or fragment |
|
1645 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("R/W request %lx@%lx",Length(),Pos())); |
|
200
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
152
diff
changeset
|
1646 |
OstTraceExt4( TRACE_INTERNALS, TLOCDRVREQUEST_CHECKANDADJUSTFORPARTITION6, "Read/Write request length=%x:%x; position=%x:%x", (TUint)I64HIGH (Length()), (TUint)I64LOW (Length()), (TUint) I64HIGH (Pos()), (TUint) I64LOW (Pos())); |
0 | 1647 |
if (DriverFlags() & RLocalDrive::ELocDrvWholeMedia) |
1648 |
{ |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1649 |
if (d.iMedia && d.iMedia->iDriver && Pos()+Length() > d.iMedia->iPartitionInfo.iMediaSizeInBytes) |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1650 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1651 |
r = KErrArgument; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1652 |
break; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1653 |
} |
0 | 1654 |
} |
1655 |
else |
|
1656 |
{ |
|
1657 |
if (Pos()+Length() > d.iPartitionLen) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1658 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1659 |
r = KErrArgument; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1660 |
break; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1661 |
} |
0 | 1662 |
Pos()+=d.iPartitionBaseAddr; |
1663 |
} |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1664 |
r = KErrNone; |
0 | 1665 |
} |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1666 |
OstTraceFunctionExitExt( TLOCDRVREQUEST_CHECKANDADJUSTFORPARTITION_EXIT, this, r ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1667 |
return r; |
0 | 1668 |
} |
1669 |
||
1670 |
/******************************************** |
|
1671 |
* Local drive class |
|
1672 |
********************************************/ |
|
1673 |
TLocDrv::TLocDrv(TInt aDriveNumber) |
|
1674 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1675 |
OstTraceFunctionEntryExt( TLOCDRV_TLOCDRV_ENTRY, this ); |
0 | 1676 |
memclr(this, sizeof(TLocDrv)); |
1677 |
iDriveNumber=aDriveNumber; |
|
1678 |
iPartitionNumber=-1; |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1679 |
iMediaChangeObserver.iFunction = MediaChangeCallback; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1680 |
iMediaChangeObserver.iPtr= this; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1681 |
iMediaChangeObserver.iObjectType = TCallBackLink::ETLocDrvObject; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1682 |
OstTraceFunctionExit1( TLOCDRV_TLOCDRV_EXIT, this ); |
0 | 1683 |
} |
1684 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1685 |
TInt TLocDrv::MediaChangeCallback(TAny* aLocDrv, TInt aNotifyType) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1686 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1687 |
__ASSERT_DEBUG(aNotifyType == DPrimaryMediaBase::EMediaChange || aNotifyType == DPrimaryMediaBase::EMediaPresent, LOCM_FAULT()); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1688 |
if (aNotifyType == DPrimaryMediaBase::EMediaPresent) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1689 |
return ((TLocDrv*) aLocDrv)->iPrimaryMedia->iBody->iMediaPresentDfc.Enque(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1690 |
else |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1691 |
return ((TLocDrv*) aLocDrv)->iPrimaryMedia->iBody->iMediaChangeDfc.Enque(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1692 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1693 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1694 |
|
0 | 1695 |
/** |
1696 |
Initialises the DMedia entity with the media device number and ID. |
|
1697 |
||
1698 |
@param aDevice The unique ID for this device. This can take one of the |
|
1699 |
enumerated values defined in TMediaDevice enum. |
|
1700 |
||
1701 |
@param aMediaId The unique ID to associate with this media entity. |
|
1702 |
||
1703 |
@return KErrNone,if successful, otherwise one of the other |
|
1704 |
system-wide error codes. |
|
1705 |
||
1706 |
@see TMediaDevice |
|
1707 |
*/ |
|
1708 |
EXPORT_C TInt DMedia::Create(TMediaDevice aDevice, TInt aMediaId, TInt) |
|
1709 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1710 |
OstTraceFunctionEntry1( DMEDIA_CREATE_ENTRY, this ); |
0 | 1711 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("DMedia::Create media %d device %d",aMediaId,aDevice)); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1712 |
OstTraceExt2(TRACE_INTERNALS, DMEDIA_CREATE, "media=%d; device=%d", aMediaId, (TUint) aDevice); |
0 | 1713 |
iMediaId=aMediaId; |
1714 |
iDevice=aDevice; |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1715 |
OstTraceFunctionExitExt( DMEDIA_CREATE_EXIT, this, KErrNone ); |
0 | 1716 |
return KErrNone; |
1717 |
} |
|
1718 |
||
1719 |
/******************************************** |
|
1720 |
* Primary Media Class |
|
1721 |
********************************************/ |
|
1722 |
void asyncDfc(TAny* aPtr) |
|
1723 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1724 |
OstTraceFunctionEntry0( _ASYNCDFC_ENTRY ); |
0 | 1725 |
DPrimaryMediaBase* pM=(DPrimaryMediaBase*)aPtr; |
1726 |
if (pM->iState==DMedia::EOpening) |
|
1727 |
pM->DoOpenMediaDriverComplete(pM->iAsyncErrorCode); |
|
1728 |
else if (pM->iState==DMedia::EReadPartitionInfo) |
|
1729 |
pM->DoPartitionInfoComplete(pM->iAsyncErrorCode); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1730 |
OstTraceFunctionExit0( _ASYNCDFC_EXIT ); |
0 | 1731 |
} |
1732 |
||
1733 |
void handleMsg(TAny* aPtr) |
|
1734 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1735 |
OstTraceFunctionEntry0( _HANDLEMSG_ENTRY ); |
0 | 1736 |
DPrimaryMediaBase* primaryMedia=(DPrimaryMediaBase*)aPtr; |
1737 |
||
1738 |
for(TLocDrvRequest* m = (TLocDrvRequest*) primaryMedia->iMsgQ.iMessage; |
|
1739 |
m != NULL; |
|
1740 |
m = (TLocDrvRequest*) primaryMedia->iMsgQ.Poll()) |
|
1741 |
{ |
|
1742 |
#if defined(_DEBUG) |
|
1743 |
if (!primaryMedia->iMsgQ.iQ.IsEmpty()) |
|
1744 |
__KTRACE_OPT(KLOCDRV, Kern::Printf("TRACE: handleMsg, queue not empty %08X", m)); |
|
1745 |
#endif |
|
1746 |
primaryMedia->HandleMsg(*m); |
|
1747 |
||
1748 |
#ifdef __DEMAND_PAGING__ |
|
1749 |
// don't empty the queue if this media is paging as there |
|
1750 |
// may be a (higher-priority) paging DFC waiting to run... |
|
1751 |
if (primaryMedia->iPagingMedia) |
|
1752 |
break; |
|
1753 |
#endif |
|
1754 |
} |
|
1755 |
||
1756 |
||
1757 |
primaryMedia->iMsgQ.Receive(); // allow reception of more messages |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1758 |
OstTraceFunctionExit0( _HANDLEMSG_EXIT ); |
0 | 1759 |
} |
1760 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1761 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1762 |
void mediaChangeDfc(TAny* aPtr) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1763 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1764 |
DPrimaryMediaBase* pM = (DPrimaryMediaBase*)aPtr; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1765 |
pM->NotifyMediaChange(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1766 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1767 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1768 |
void mediaPresentDfc(TAny* aPtr) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1769 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1770 |
DPrimaryMediaBase* pM = (DPrimaryMediaBase*)aPtr; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1771 |
pM->NotifyMediaPresent(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1772 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1773 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1774 |
DPrimaryMediaBase::DBody::DBody(DPrimaryMediaBase& aPrimaryMediaBase) : |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1775 |
iPrimaryMediaBase(aPrimaryMediaBase), |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1776 |
iMediaChangeDfc(mediaChangeDfc, &aPrimaryMediaBase, KMaxDfcPriority), |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1777 |
iMediaPresentDfc(mediaPresentDfc, &aPrimaryMediaBase, KMaxDfcPriority) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1778 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1779 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1780 |
|
0 | 1781 |
EXPORT_C DPrimaryMediaBase::DPrimaryMediaBase() |
1782 |
: iMsgQ(handleMsg, this, NULL, 1), |
|
1783 |
iDeferred(NULL, NULL, NULL, 0), // callback never used |
|
1784 |
iWaitMedChg(NULL, NULL, NULL, 0), // callback never used |
|
1785 |
iAsyncDfc(asyncDfc, this, 1) |
|
1786 |
/** |
|
1787 |
Constructor of DPrimaryMediaBase class. |
|
1788 |
Initialises the media state as closed. |
|
1789 |
*/ |
|
1790 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1791 |
OstTraceFunctionEntry1( DPRIMARYMEDIABASE_DPRIMARYMEDIABASE_ENTRY, this ); |
0 | 1792 |
iState = EClosed; |
1793 |
} |
|
1794 |
||
1795 |
||
1796 |
||
1797 |
EXPORT_C TInt DPrimaryMediaBase::Create(TMediaDevice aDevice, TInt aMediaId, TInt aLastMediaId) |
|
1798 |
/** |
|
1799 |
Called from LocDrv::RegisterMediaDevice() function. |
|
1800 |
Calls DMedia::Create() |
|
1801 |
||
1802 |
@param aDevice Local media ID |
|
1803 |
@param aMediaId Media Id (unique for a media subsystem) |
|
1804 |
@param aLastMediaId This indicates number of used media ids+ number of DMedia objects to be associated with the media driver. |
|
1805 |
||
1806 |
@return KErrNone |
|
1807 |
@see TMediaDevice |
|
1808 |
||
1809 |
*/ |
|
1810 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1811 |
OstTraceFunctionEntry1( DPRIMARYMEDIABASE_CREATE_ENTRY, this ); |
0 | 1812 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase::Create media %d-%d device %d",aMediaId,aLastMediaId,aDevice)); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1813 |
OstTraceExt3( TRACE_INTERNALS, DPRIMARYMEDIABASE_CREATE, "aMediaId=%d; aLastMediaId=%d; aDevice=%d ", aMediaId, aLastMediaId, (TUint) aDevice ); |
0 | 1814 |
TInt r=DMedia::Create(aDevice,aMediaId,0); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1815 |
|
0 | 1816 |
if (r != KErrNone) |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1817 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1818 |
OstTraceFunctionExitExt( DPRIMARYMEDIABASE_CREATE_EXIT1, this, r ); |
0 | 1819 |
return r; |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1820 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1821 |
iBody = new DBody(*this); |
0 | 1822 |
if (iBody == NULL) |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1823 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1824 |
OstTraceFunctionExitExt( DPRIMARYMEDIABASE_CREATE_EXIT2, this, KErrNoMemory ); |
0 | 1825 |
return KErrNoMemory; |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1826 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1827 |
if (iDfcQ) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1828 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1829 |
iBody->iMediaChangeDfc.SetDfcQ(iDfcQ); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1830 |
iBody->iMediaPresentDfc.SetDfcQ(iDfcQ); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1831 |
} |
0 | 1832 |
|
1833 |
#ifdef __DEMAND_PAGING__ |
|
1834 |
TInt pageSize = Kern::RoundToPageSize(1); |
|
1835 |
iBody->iPageSizeMsk = pageSize-1; |
|
201
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
1836 |
iBody->iPageSizeLog2 = __e32_find_ms1_32(pageSize); |
0 | 1837 |
#endif |
1838 |
||
1839 |
iLastMediaId=aLastMediaId; |
|
1840 |
if (r==KErrNone && iDfcQ) |
|
1841 |
{ |
|
1842 |
iMsgQ.SetDfcQ(iDfcQ); |
|
1843 |
iDeferred.SetDfcQ(iDfcQ); |
|
1844 |
iWaitMedChg.SetDfcQ(iDfcQ); |
|
1845 |
iAsyncDfc.SetDfcQ(iDfcQ); |
|
1846 |
} |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1847 |
OstTraceFunctionExitExt( DPRIMARYMEDIABASE_CREATE_EXIT3, this, KErrNone ); |
0 | 1848 |
return KErrNone; |
1849 |
} |
|
1850 |
||
1851 |
||
1852 |
EXPORT_C TInt DPrimaryMediaBase::Connect(DLocalDrive* aLocalDrive) |
|
1853 |
/** |
|
1854 |
Connects to a local drive |
|
1855 |
||
1856 |
@param aLocalDrive Local drive logical channel abstraction |
|
1857 |
||
1858 |
@pre Kernel must be unlocked |
|
1859 |
@pre Current thread in critical section |
|
1860 |
||
1861 |
@post Kernel must be unlocked |
|
1862 |
||
1863 |
@return KErrNone, if successful |
|
1864 |
KErrNotFound, If no PDD matches criteria while getting driver list |
|
1865 |
KErrNoMemory, If the array could not be expanded at some point while getting driver list or ran out of memory while opening media driver |
|
1866 |
KErrNotReady, If not ready when trying to open media driver |
|
1867 |
otherwise, one of the other system wide error codes. |
|
1868 |
||
1869 |
@see DLocalDrive |
|
1870 |
*/ |
|
1871 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1872 |
OstTraceFunctionEntryExt( DPRIMARYMEDIABASE_CONNECT_ENTRY, this ); |
0 | 1873 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase(%d)::Connect %O",iMediaId,aLocalDrive)); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1874 |
OstTraceExt2( TRACE_MEDIACHANGE, DPRIMARYMEDIABASE_CONNECT, "iMediaId=%d; iDriveNumber=%d", iMediaId, aLocalDrive->iDrive->iDriveNumber ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1875 |
|
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1876 |
TInt r=KErrNone; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1877 |
|
0 | 1878 |
if (iDfcQ) |
1879 |
{ |
|
1880 |
TThreadMessage& m=Kern::Message(); |
|
1881 |
m.iValue=EConnect; |
|
1882 |
m.iArg[0]=aLocalDrive; |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1883 |
r=m.SendReceive(&iMsgQ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1884 |
OstTraceFunctionExitExt( DPRIMARYMEDIABASE_CONNECT_EXIT1, this, r ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1885 |
return r; |
0 | 1886 |
} |
1887 |
||
1888 |
// If no DFC queue, must be a fixed media device |
|
1889 |
// If this is the first connection, open media driver now |
|
1890 |
// Assume no non-primary media exist on this device |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1891 |
|
0 | 1892 |
NKern::LockSystem(); |
1893 |
TBool first=iConnectionQ.IsEmpty(); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1894 |
iConnectionQ.Add(&aLocalDrive->iMediaChangeObserver.iLink); |
0 | 1895 |
NKern::UnlockSystem(); |
1896 |
if (first) |
|
1897 |
{ |
|
1898 |
r=OpenMediaDriver(); |
|
1899 |
if (r!=KErrNone) |
|
1900 |
{ |
|
1901 |
NKern::LockSystem(); |
|
1902 |
aLocalDrive->Deque(); |
|
1903 |
NKern::UnlockSystem(); |
|
1904 |
} |
|
1905 |
} |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1906 |
|
0 | 1907 |
if (r==KErrNone) |
1908 |
aLocalDrive->iDrive->iMedia=this; |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1909 |
OstTraceFunctionExitExt( DPRIMARYMEDIABASE_CONNECT_EXIT2, this, r ); |
0 | 1910 |
return r; |
1911 |
} |
|
1912 |
||
1913 |
||
1914 |
||
1915 |
||
1916 |
EXPORT_C void DPrimaryMediaBase::Disconnect(DLocalDrive* aLocalDrive) |
|
1917 |
/** |
|
1918 |
Disconnects from a local drive |
|
1919 |
||
1920 |
@param aLocalDrive Local drive logical channel abstraction |
|
1921 |
||
1922 |
@pre Kernel must be unlocked |
|
1923 |
@pre Current thread in critical section |
|
1924 |
||
1925 |
@post Kernel must be unlocked |
|
1926 |
@see DLocalDrive |
|
1927 |
*/ |
|
1928 |
||
1929 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1930 |
OstTraceFunctionEntryExt( DPRIMARYMEDIABASE_DISCONNECT_ENTRY, this ); |
0 | 1931 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase(%d)::Disconnect %O",iMediaId,aLocalDrive)); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1932 |
OstTraceExt2( TRACE_MEDIACHANGE, DPRIMARYMEDIABASE_DISCONNECT, "iMediaId=%d; iDriveNumber=%d", iMediaId, aLocalDrive->iDrive->iDriveNumber ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1933 |
|
0 | 1934 |
if (iDfcQ) |
1935 |
{ |
|
1936 |
TThreadMessage& m=Kern::Message(); |
|
1937 |
m.iValue=EDisconnect; |
|
1938 |
m.iArg[0]=aLocalDrive; |
|
1939 |
m.SendReceive(&iMsgQ); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1940 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_DISCONNECT_EXIT1, this ); |
0 | 1941 |
return; |
1942 |
} |
|
1943 |
||
1944 |
// If no DFC queue, must be a fixed media device |
|
1945 |
// If this is the last connection, close media driver now |
|
1946 |
// Assume no non-primary media exist on this device |
|
1947 |
DMediaDriver* pD=NULL; |
|
1948 |
NKern::LockSystem(); |
|
1949 |
aLocalDrive->iDrive->iMedia=NULL; |
|
1950 |
aLocalDrive->Deque(); |
|
1951 |
if (iConnectionQ.IsEmpty()) |
|
1952 |
{ |
|
1953 |
pD=iDriver; |
|
1954 |
iDriver=NULL; |
|
1955 |
} |
|
1956 |
NKern::UnlockSystem(); |
|
1957 |
if (pD) |
|
1958 |
pD->Close(); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1959 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_DISCONNECT_EXIT2, this ); |
0 | 1960 |
} |
1961 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1962 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1963 |
/** |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1964 |
Connects a TLocDrv containing a media extension to the next primary media in the chain |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1965 |
*/ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1966 |
TInt DPrimaryMediaBase::Connect(TLocDrv* aLocDrv) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1967 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1968 |
TInt r = KErrNone; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1969 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1970 |
NKern::LockSystem(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1971 |
TBool first = iConnectionQ.IsEmpty(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1972 |
iConnectionQ.Add(&aLocDrv->iMediaChangeObserver.iLink); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1973 |
NKern::UnlockSystem(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1974 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1975 |
if (first && !iDfcQ) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1976 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1977 |
r = OpenMediaDriver(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1978 |
if (r!=KErrNone) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1979 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1980 |
NKern::LockSystem(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1981 |
aLocDrv->iMediaChangeObserver.iLink.Deque(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1982 |
NKern::UnlockSystem(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1983 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1984 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1985 |
return r; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1986 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1987 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1988 |
TInt DPrimaryMediaBase::HandleMediaNotPresent(TLocDrvRequest& aReq) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1989 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1990 |
TInt reqId = aReq.Id(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1991 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1992 |
if (reqId == DLocalDrive::ECaps) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1993 |
DefaultDriveCaps(*(TLocalDriveCapsV2*)aReq.RemoteDes()); // fill in stuff we know even if no media present |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1994 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1995 |
TInt r = QuickCheckStatus(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1996 |
if (r != KErrNone && |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1997 |
reqId != DLocalDrive::EForceMediaChange && // EForceMediaChange, and |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1998 |
reqId != DLocalDrive::EReadPasswordStore && // Password store operations |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1999 |
reqId != DLocalDrive::EWritePasswordStore && // do not require the media |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2000 |
reqId != DLocalDrive::EPasswordStoreLengthInBytes) // to be ready.) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2001 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2002 |
return r; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2003 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2004 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2005 |
return KErrNone; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2006 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2007 |
|
0 | 2008 |
EXPORT_C TInt DPrimaryMediaBase::Request(TLocDrvRequest& aReq) |
2009 |
/** |
|
2010 |
Issues a local drive request. It is called from TLocDrv::Request() function . |
|
2011 |
Each local drive request is encapsulated as a TLocDrvRequest- a class derived from TThreadMessage, the kernel message class. |
|
2012 |
TLocDrvRequest contains information pertaining to the request, including the ID and any associated parameters such as drive position, length and source/destination location. |
|
2013 |
Passes the request through to the media driver. |
|
2014 |
||
2015 |
@param m Encapsulates the request information received from the client |
|
2016 |
||
2017 |
@pre Enter with kernel unlocked |
|
2018 |
||
2019 |
@post Leave with Kernel unlocked |
|
2020 |
||
2021 |
@return KErrNone,if successful |
|
2022 |
KErrBadDescriptor, if request encapsulates a bad descriptor |
|
2023 |
Otherwise, one of the other system wide error codes. |
|
2024 |
||
2025 |
@see TLocDrvRequest |
|
2026 |
*/ |
|
2027 |
{ |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2028 |
OstTraceFunctionEntry1( DPRIMARYMEDIABASE_REQUEST_ENTRY, this ); |
0 | 2029 |
|
2030 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase(%d)::Request(%08x)",iMediaId,&aReq)); |
|
2031 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("this=%x, ReqId=%d, Pos=%lx, Len=%lx, remote thread %O",this,aReq.Id(),aReq.Pos(),aReq.Length(),aReq.RemoteThread())); |
|
2032 |
||
200
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
152
diff
changeset
|
2033 |
OstTraceDefExt2(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DPRIMARYMEDIABASE_REQUEST, "reqId=%d; remote thread=0x%x", (TInt) aReq.Id(), (TUint) aReq.RemoteThread()); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
152
diff
changeset
|
2034 |
OstTraceDefExt4(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DPRIMARYMEDIABASE_REQUEST2, "length=%x:%x; position=%x:%x", (TUint) I64HIGH(aReq.Length()), (TUint) I64LOW(aReq.Length()), (TUint) I64HIGH(aReq.Pos()), (TUint) I64LOW(aReq.Pos())); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2035 |
|
0 | 2036 |
TInt reqId = aReq.Id(); |
2037 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2038 |
TInt r = HandleMediaNotPresent(aReq); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2039 |
if (r != KErrNone) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2040 |
{ |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2041 |
OstTraceFunctionExitExt( DPRIMARYMEDIABASE_REQUEST_EXIT, this, r ); |
0 | 2042 |
return r; |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2043 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2044 |
|
0 | 2045 |
|
2046 |
||
2047 |
// for ERead & EWrite requests, get the linear address for pinning & DMA |
|
2048 |
TUint8* linAddress = NULL; |
|
2049 |
TClientBuffer clientBuffer; |
|
2050 |
DThread* pT = NULL; |
|
2051 |
||
2052 |
if (reqId == DLocalDrive::ERead || reqId == DLocalDrive::EWrite) |
|
2053 |
{ |
|
2054 |
pT = aReq.RemoteThread(); |
|
2055 |
if (!pT) |
|
2056 |
pT = &Kern::CurrentThread(); // e.g. when using TBusLocalDrive directly |
|
2057 |
||
2058 |
// for silly zero-length requests, return immediately, setting the client |
|
2059 |
// descriptor length to zero if it's a read request |
|
2060 |
if (aReq.Length() == 0) |
|
2061 |
{ |
|
2062 |
DThread* pC = &Kern::CurrentThread(); |
|
2063 |
r = KErrNone; |
|
2064 |
if (reqId == DLocalDrive::ERead) |
|
2065 |
{ |
|
2066 |
TPtrC8 ptr(NULL, 0); |
|
2067 |
r = Kern::ThreadDesWrite(pT, aReq.RemoteDes(), ptr, aReq.RemoteDesOffset(), KChunkShiftBy0,pC); |
|
2068 |
} |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2069 |
OstTraceFunctionExitExt( DPRIMARYMEDIABASE_REQUEST_EXIT2, this, r ); |
0 | 2070 |
return r; |
2071 |
} |
|
2072 |
||
2073 |
clientBuffer.SetFromDescriptor(aReq.RemoteDes(), pT); |
|
2074 |
||
2075 |
TInt length = 0; |
|
2076 |
TInt maxLength = 0; |
|
2077 |
TInt r = Kern::ThreadGetDesInfo(pT,aReq.RemoteDes(),length,maxLength,linAddress,EFalse); // get descriptor length, maxlength and linAddress |
|
2078 |
if (r != KErrNone) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2079 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2080 |
OstTraceFunctionExitExt( DPRIMARYMEDIABASE_REQUEST_EXIT3, this, r ); |
0 | 2081 |
return r; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2082 |
} |
0 | 2083 |
linAddress+= aReq.RemoteDesOffset(); |
2084 |
||
2085 |
#ifdef __DEMAND_PAGING__ |
|
2086 |
// NB change in behavior IF DATA PAGING IS ENABLED: TLocDrvRequest::RemoteDes() points |
|
2087 |
// to a TClientBuffer rather than the client's remote descriptor |
|
2088 |
if (DataPagingDeviceRegistered) |
|
2089 |
{ |
|
2090 |
aReq.RemoteDes() = &clientBuffer; |
|
2091 |
aReq.Flags() |= TLocDrvRequest::ETClientBuffer; |
|
2092 |
} |
|
2093 |
#endif |
|
2094 |
} |
|
2095 |
||
2096 |
if (iDfcQ) |
|
2097 |
{ |
|
2098 |
__TRACE_TIMING(0x10); |
|
2099 |
||
2100 |
||
2101 |
#ifdef __DEMAND_PAGING__ |
|
2102 |
// If this is a ROM/Code paging media, pin writes |
|
2103 |
// If there is a Data paging media registered, pin all requests with descriptors |
|
2104 |
if ( (DataPagingDeviceRegistered) || (reqId == DLocalDrive::EWrite && RomPagingDfcQ(this)) ) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2105 |
{ |
0 | 2106 |
r = PinSendReceive(aReq, (TLinAddr) linAddress); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2107 |
} |
0 | 2108 |
else |
2109 |
#endif // __DEMAND_PAGING__ |
|
2110 |
r = SendReceive(aReq, (TLinAddr) linAddress); |
|
2111 |
} |
|
2112 |
else |
|
2113 |
{ |
|
2114 |
// If no DFC queue, must be a fixed media device |
|
2115 |
// Media driver must already have been opened |
|
2116 |
// Assume no non-primary media exist on this device |
|
2117 |
// Just pass request straight through to media driver |
|
2118 |
r = aReq.CheckAndAdjustForPartition(); |
|
2119 |
if (r == KErrNone) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2120 |
r = iDriver->Request(aReq); |
0 | 2121 |
} |
2122 |
||
2123 |
#ifdef __DEMAND_PAGING__ |
|
2124 |
// NB change in behavior IF DATA PAGING IS ENABLED: TLocDrvRequest::RemoteDes() points |
|
2125 |
// to a TClientBuffer rather than the client's remote descriptor |
|
2126 |
if (reqId == DLocalDrive::ERead && DataPagingDeviceRegistered && r == KErrNone) |
|
2127 |
{ |
|
2128 |
r = clientBuffer.UpdateDescriptorLength(pT); |
|
2129 |
} |
|
2130 |
#endif |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2131 |
OstTraceFunctionExitExt( DPRIMARYMEDIABASE_REQUEST_EXIT4, this, r ); |
0 | 2132 |
return r; |
2133 |
} |
|
2134 |
||
2135 |
||
2136 |
#ifdef __DEMAND_PAGING__ |
|
2137 |
TInt DPrimaryMediaBase::PinSendReceive(TLocDrvRequest& aReq, TLinAddr aLinAddress) |
|
2138 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2139 |
OstTraceExt2(TRACE_FLOW, DPRIMARYMEDIABASE_PINSENDRECEIVE_ENTRY, "> DPrimaryMediaBase::PinSendReceive;aReq=%x;aLinAddress=%x;", (TUint) &aReq, (TUint) &aLinAddress ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2140 |
|
0 | 2141 |
__ASSERT_DEBUG(ThePinObjectAllocator, LOCM_FAULT()); |
2142 |
||
2143 |
||
2144 |
TInt msgId = aReq.Id(); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2145 |
TInt r; |
0 | 2146 |
|
2147 |
switch(msgId) |
|
2148 |
{ |
|
2149 |
case DLocalDrive::EControlIO: |
|
2150 |
{ |
|
2151 |
TInt controlIoType = aReq.Int3(); |
|
2152 |
switch(controlIoType) |
|
2153 |
{ |
|
2154 |
case KLocalMessageHandle: |
|
2155 |
// ControlIo is not supported if either of the two bare (TAny*) pointers are non-NULL |
|
2156 |
// as it's not possible to determine what the pointers are pointing at... |
|
2157 |
if (aReq.Int1() || aReq.Int2()) |
|
2158 |
{ |
|
2159 |
__KTRACE_OPT(KDATAPAGEWARN, Kern::Printf("Data paging: Naked EControlIO not supported on paging device: fn=%x", aReq.Int0())); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2160 |
r = KErrNotSupported; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2161 |
break; |
0 | 2162 |
} |
2163 |
// fall into... |
|
2164 |
case 0: |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2165 |
r = SendReceive(aReq); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2166 |
break; |
0 | 2167 |
|
2168 |
default: |
|
2169 |
// if Int3() is > 0, Int1() is a data pointer, and Int3() is a length |
|
2170 |
if (controlIoType > (TInt) ThePinObjectAllocator->iFragmentGranularity) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2171 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2172 |
r = KErrTooBig; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2173 |
break; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2174 |
} |
0 | 2175 |
if (controlIoType < 0) |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2176 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2177 |
r = KErrArgument; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2178 |
break; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2179 |
} |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2180 |
r = PinFragmentSendReceive(aReq, (TLinAddr) aReq.Ptr1(), controlIoType); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2181 |
break; |
0 | 2182 |
} |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2183 |
break; |
0 | 2184 |
} |
2185 |
||
2186 |
case DLocalDrive::ERead: |
|
2187 |
case DLocalDrive::EWrite: |
|
2188 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2189 |
r = PinFragmentSendReceive(aReq, aLinAddress, aReq.Length()); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2190 |
break; |
0 | 2191 |
} |
2192 |
||
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2193 |
// For all these requests, aReq.RemoteDes() points to a buffer on the stack in DLocalDrive::Request() |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2194 |
// This is a kernel stack & so should be unpaged & not require pinning... |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2195 |
case DLocalDrive::ECaps: |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2196 |
case DLocalDrive::EGetLastErrorInfo: |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2197 |
case DLocalDrive::EQueryDevice: |
0 | 2198 |
case DLocalDrive::EPasswordLock: |
2199 |
case DLocalDrive::EPasswordUnlock: |
|
2200 |
case DLocalDrive::EPasswordClear: |
|
2201 |
case DLocalDrive::EReadPasswordStore: |
|
2202 |
case DLocalDrive::EWritePasswordStore: |
|
2203 |
case DLocalDrive::EPasswordStoreLengthInBytes: |
|
2204 |
case DLocalDrive::EPasswordErase: |
|
2205 |
||
2206 |
default: |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2207 |
r = SendReceive(aReq); |
0 | 2208 |
} |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2209 |
OstTraceFunctionExitExt( DPRIMARYMEDIABASE_PINSENDRECEIVE_EXIT, this, r ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2210 |
return r; |
0 | 2211 |
} |
2212 |
||
2213 |
TInt DPrimaryMediaBase::PinFragmentSendReceive(TLocDrvRequest& aReq, TLinAddr aLinAddress, TInt aLength) |
|
2214 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2215 |
OstTraceExt3(TRACE_FLOW, DPRIMARYMEDIABASE_PINFRAGMENTSENDRECEIVE_ENTRY, "> DPrimaryMediaBase::PinFragmentSendReceive;aReq=%x;aLinAddress=%x;aLength=%d;", (TUint) &aReq, (TUint) &aLinAddress, aLength ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2216 |
|
0 | 2217 |
TLocDrvRequest fragment = aReq; // create a request on the stack for use during fragmentation, pre-fill with the original req args, leave original Kernel message as repository (thread will block, message contents won't change) |
2218 |
TInt r = KErrNone; |
|
2219 |
||
2220 |
// Kern::Printf(">PFSR %02X aReq %08X aLinAddress %08X aLen %08X offset %08X", aReq.Id(), &aReq, aLinAddress, aLength, aReq.RemoteDesOffset()); |
|
2221 |
||
2222 |
DThread* pT = aReq.RemoteThread(); |
|
2223 |
if (!pT) |
|
2224 |
pT=&Kern::CurrentThread(); // e.g. when using TBusLocalDrive directly |
|
2225 |
||
2226 |
__KTRACE_OPT2(KLOCDPAGING,KLOCDRV,Kern::Printf("Fragmenting Read/Write Request(0x%08x) on drive(%d), remote des(0x%x), offset into des(0x%x), original req Length(0x%x)",&aReq,aReq.Drive()->iDriveNumber,(TInt)(aReq.RemoteDes()),aReq.RemoteDesOffset(),aLength)); |
|
2227 |
__KTRACE_OPT(KLOCDPAGING,Kern::Printf("Remote thread(0x%08x), current thread(0x%08x), start of data to write(0x%08x)",aReq.RemoteThread(),&Kern::CurrentThread(),(TInt)aLinAddress)); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2228 |
OstTraceDefExt5(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DPRIMARYMEDIABASE_PINFRAGMENTSENDRECEIVE1, "Fragmenting Read/Write Request=0x%08x; drive=%d; remote des=0x%x; offset into des=0x%x; original length=0x%x", (TUint) &aReq, (TUint) aReq.Drive()->iDriveNumber, (TInt) (aReq.RemoteDes()), (TInt) aReq.RemoteDesOffset(), (TInt) aLength ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2229 |
OstTraceDefExt3(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DPRIMARYMEDIABASE_PINFRAGMENTSENDRECEIVE2, "Remote Thread=0x%08x; current Thread=0x%x; start of data to write=0x%08x", (TUint) aReq.RemoteThread(), (TUint) &Kern::CurrentThread(),(TUint)aLinAddress ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2230 |
|
0 | 2231 |
// don't want this thread to be terminated until last fragment is sent to MD and mem can be free'd up |
2232 |
NKern::ThreadEnterCS(); |
|
2233 |
||
2234 |
__ASSERT_DEBUG(ThePinObjectAllocator, LOCM_FAULT()); |
|
2235 |
||
2236 |
TUint fragmentGranularity = ThePinObjectAllocator->iFragmentGranularity; |
|
2237 |
TInt dataLockResult = 0; |
|
2238 |
// fragmentation only allowed for read/write requests |
|
2239 |
__ASSERT_DEBUG(aLength <= (TInt) fragmentGranularity || (aReq.Id() == DLocalDrive::EWrite || aReq.Id() == DLocalDrive::ERead), LOCM_FAULT()); |
|
2240 |
||
2241 |
// Pin the client buffer |
|
2242 |
TInt pinnedLen; |
|
2243 |
for (TInt pos = 0; pos < aLength; pos+= pinnedLen, aLinAddress+= pinnedLen) |
|
2244 |
{ |
|
2245 |
pinnedLen = 0; |
|
2246 |
||
2247 |
// pin memory |
|
2248 |
TInt remainingLen = aLength - pos; // remaining length |
|
2249 |
||
2250 |
// first attempt to pin memory with no pre-allocated buffers (which may fail) |
|
2251 |
DPinObjectAllocator::SVirtualPinContainer* pinDataObject = ThePinObjectAllocator->AcquirePinObject(); |
|
2252 |
||
2253 |
if (pinDataObject) |
|
2254 |
{ |
|
2255 |
TInt lenToPin = Min(KMaxPinData, remainingLen); |
|
2256 |
||
2257 |
TInt r = Kern::PinVirtualMemory(pinDataObject->iObject, aLinAddress, lenToPin, pT); |
|
2258 |
if (r == KErrNone) |
|
2259 |
{ |
|
2260 |
pinnedLen = lenToPin; |
|
2261 |
} |
|
2262 |
else |
|
2263 |
{ |
|
2264 |
#ifdef __DEBUG_DEMAND_PAGING__ |
|
2265 |
Kern::Printf("Kern::PinVirtualMemory() error %d", r); |
|
2266 |
#endif |
|
2267 |
// pin failed, so use preallocated buffer instead |
|
2268 |
ThePinObjectAllocator->ReleasePinObject(pinDataObject); |
|
2269 |
pinDataObject = NULL; |
|
2270 |
} |
|
2271 |
} |
|
2272 |
||
2273 |
if (!pinDataObject) |
|
2274 |
{ |
|
2275 |
ThePinObjectAllocator->PreAllocatedDataLock().LockFragmentation(); |
|
2276 |
||
2277 |
TLinAddr start = aLinAddress; |
|
2278 |
do |
|
2279 |
{ |
|
2280 |
TInt lenToPin = Min((TInt) fragmentGranularity, remainingLen - pinnedLen); |
|
2281 |
||
2282 |
#ifdef __DEBUG_DEMAND_PAGING__ |
|
2283 |
Kern::Printf(">SR PinS Id %d aLinAddress %08X lenToPin %08X offset %08X", aReq.Id(), aLinAddress, lenToPin); |
|
2284 |
#endif |
|
2285 |
||
2286 |
dataLockResult = ThePinObjectAllocator->PreAllocatedDataLock().Lock(pT, start, lenToPin); |
|
2287 |
||
2288 |
#ifdef __DEBUG_DEMAND_PAGING__ |
|
2289 |
Kern::Printf("<SR PinS Id %d aLinAddress %08X lenToPin %08X offset %08X r %d", aReq.Id(), aLinAddress, lenToPin, r); |
|
2290 |
#endif |
|
2291 |
||
2292 |
start+= lenToPin; |
|
2293 |
pinnedLen+= lenToPin; |
|
2294 |
} |
|
2295 |
while (dataLockResult == 0 && pinnedLen < remainingLen); |
|
2296 |
||
2297 |
// if nothing pinned (dataLockResult == 0) or error (dataLockResult <0), release the mutex, |
|
2298 |
// otherwise (dataLockResult > 0) release it after calling SendReceive() |
|
2299 |
if (dataLockResult <= 0) |
|
2300 |
ThePinObjectAllocator->PreAllocatedDataLock().UnlockFragmentation(); |
|
2301 |
||
2302 |
#ifdef __DEBUG_DEMAND_PAGING__ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2303 |
if (dataLockResult < 0) |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2304 |
Kern::Printf("DFragmentationPagingLock::Lock() %d", dataLockResult); |
0 | 2305 |
#endif |
2306 |
||
2307 |
if (dataLockResult < 0) // if lock returned an error then give up |
|
2308 |
{ |
|
2309 |
r = dataLockResult; |
|
2310 |
break; |
|
2311 |
} |
|
2312 |
} |
|
2313 |
||
2314 |
// fragment request Id defaults to same as original request |
|
2315 |
fragment.Id() = aReq.Id(); |
|
2316 |
fragment.Length() = Int64(pinnedLen); |
|
2317 |
fragment.RemoteDesOffset() = aReq.RemoteDesOffset() + pos; |
|
2318 |
fragment.Pos() = aReq.Pos() + pos; |
|
2319 |
fragment.Flags() = aReq.Flags(); |
|
2320 |
||
2321 |
__KTRACE_OPT2(KLOCDPAGING,KLOCDRV,Kern::Printf("Send fragment (0x%08x) type(%d), length(0x%x), offset within original req(0x%x), pos in media(0x%lx)",&fragment,fragment.Id(), pinnedLen, pos, fragment.Pos())); |
|
200
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
152
diff
changeset
|
2322 |
OstTraceDefExt4(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DPRIMARYMEDIABASE_PINFRAGMENTSENDRECEIVE3, "Send fragment 0x%08x; type=%d; length=0x%x; offset within original req=0x%x", (TUint) &fragment, (TInt) fragment.Id(), (TUint) pinnedLen, (TUint) pos); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
152
diff
changeset
|
2323 |
OstTraceDefExt3(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DPRIMARYMEDIABASE_PINFRAGMENTSENDRECEIVE4, "Send fragment 0x%08x; position in media=%x:%x",(TUint) &fragment, (TUint) I64HIGH(fragment.Pos()), (TUint) I64LOW(fragment.Pos())); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2324 |
|
0 | 2325 |
#ifdef BTRACE_PAGING_MEDIA |
2326 |
TInt buf[4]; |
|
2327 |
buf[0] = pinnedLen; // fragment length |
|
2328 |
buf[1] = pos; // offset within original request |
|
2329 |
buf[2] = fragment.Pos(); // offset in media |
|
2330 |
buf[3] = (TInt)&pT->iNThread; // thread that issued the original write req |
|
2331 |
BTraceContextN(BTrace::EPagingMedia,BTrace::EPagingMediaLocMedFragmentBegin,&fragment,fragment.Id(),buf,sizeof(buf)); |
|
2332 |
#endif |
|
2333 |
r = SendReceive(fragment, aLinAddress); // only come back here when message (fragment) has been completed |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2334 |
|
0 | 2335 |
// unpin memory |
2336 |
if (pinDataObject) |
|
2337 |
{ |
|
2338 |
Kern::UnpinVirtualMemory(pinDataObject->iObject); |
|
2339 |
ThePinObjectAllocator->ReleasePinObject(pinDataObject); |
|
2340 |
} |
|
2341 |
else if (dataLockResult > 0) // pinDataObject = NULL |
|
2342 |
{ |
|
2343 |
__ASSERT_DEBUG(dataLockResult == 1, LOCM_FAULT()); |
|
2344 |
ThePinObjectAllocator->PreAllocatedDataLock().Unlock(); |
|
2345 |
ThePinObjectAllocator->PreAllocatedDataLock().UnlockFragmentation(); |
|
2346 |
} |
|
2347 |
||
2348 |
#ifdef BTRACE_PAGING_MEDIA |
|
2349 |
BTraceContext8(BTrace::EPagingMedia,BTrace::EPagingMediaLocMedFragmentEnd,&fragment,r); |
|
2350 |
#endif |
|
2351 |
||
2352 |
if (r != KErrNone) |
|
2353 |
break; |
|
2354 |
} |
|
2355 |
||
2356 |
NKern::ThreadLeaveCS(); |
|
2357 |
||
2358 |
// Kern::Printf("<PFSR %02X aReq %08X aLinAddress %08X aLen %08X offset %08X", aReq.Id(), &aReq, aLinAddress, aLength, aReq.RemoteDesOffset()); |
|
2359 |
||
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2360 |
OstTraceFunctionExitExt( DPRIMARYMEDIABASE_PINFRAGMENTSENDRECEIVE_EXIT, this, r ); |
0 | 2361 |
return r; |
2362 |
} |
|
2363 |
||
2364 |
#endif // __DEMAND_PAGING__ |
|
2365 |
||
2366 |
||
2367 |
TInt DPrimaryMediaBase::SendReceive(TLocDrvRequest& aReq, TLinAddr aLinAddress) |
|
2368 |
/** |
|
2369 |
* If a Physical memory helper object is present for given drive, |
|
2370 |
* then message is routed via helper; |
|
2371 |
* |
|
2372 |
* @return KErrNone, if successful; |
|
2373 |
* otherwise, one of the other system wide error codes. |
|
2374 |
* |
|
2375 |
* @see TLocDrvRequest::SendReceive() |
|
2376 |
* @see DDmaHelper::SendReceive() |
|
2377 |
*/ |
|
2378 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2379 |
OstTraceExt2( TRACE_FLOW, DPRIMARYMEDIABASE_SENDRECEIVE_ENTRY, "> DPrimaryMediaBase::SendReceive;aReq=%x;aLinAddress=%x", (TUint) &aReq, (TUint) &aLinAddress ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2380 |
|
0 | 2381 |
DDmaHelper* dmaHelper = aReq.Drive()->iDmaHelper; |
2382 |
||
2383 |
#ifdef __DEMAND_PAGING__ |
|
2384 |
RequestCountInc(); |
|
2385 |
#endif |
|
2386 |
||
2387 |
TInt r; |
|
2388 |
||
2389 |
if (dmaHelper) |
|
2390 |
r = dmaHelper->SendReceive(aReq, aLinAddress); |
|
2391 |
else |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2392 |
{ |
0 | 2393 |
r = aReq.SendReceive(&iMsgQ); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2394 |
} |
0 | 2395 |
#ifdef __DEMAND_PAGING__ |
2396 |
RequestCountDec(); |
|
2397 |
#endif |
|
2398 |
||
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2399 |
OstTraceFunctionExitExt( DPRIMARYMEDIABASE_SENDRECEIVE_EXIT, this, r ); |
0 | 2400 |
return r; |
2401 |
} |
|
2402 |
||
2403 |
||
2404 |
||
2405 |
EXPORT_C TInt DPrimaryMediaBase::ForceMediaChange(TInt) |
|
2406 |
/** |
|
2407 |
Forces a media change.The method can be overridden in the derived classes. |
|
2408 |
@param mode Media change mode |
|
2409 |
||
2410 |
@return KErrNotSupported, in the default implementation |
|
2411 |
KErrNone, if successful |
|
2412 |
Otherwise, one of the other system wide error codes. |
|
2413 |
||
2414 |
*/ |
|
2415 |
{ |
|
2416 |
// default implementation |
|
2417 |
return KErrNotSupported; |
|
2418 |
} |
|
2419 |
||
2420 |
EXPORT_C TInt DPrimaryMediaBase::InitiatePowerUp() |
|
2421 |
/** |
|
2422 |
Initiates Power up sequence |
|
2423 |
@return KErrCompletion, operation is complete successfully or otherwise |
|
2424 |
KErrNone, if successful |
|
2425 |
Otherwise, one of the other system wide error codes. |
|
2426 |
||
2427 |
*/ |
|
2428 |
{ |
|
2429 |
// default implementation, this is the default implementation. |
|
2430 |
return KErrCompletion; |
|
2431 |
} |
|
2432 |
||
2433 |
EXPORT_C TInt DPrimaryMediaBase::QuickCheckStatus() |
|
2434 |
/** |
|
2435 |
Checks the status of the media device, whether the device is present,absent,not ready,etc. |
|
2436 |
The function can be overridden in the derived classes |
|
2437 |
||
2438 |
@return KErrNone, if successful |
|
2439 |
Otherwise, one of the other system wide error codes. |
|
2440 |
||
2441 |
*/ |
|
2442 |
{ |
|
2443 |
// default implementation |
|
2444 |
return KErrNone; |
|
2445 |
} |
|
2446 |
||
2447 |
EXPORT_C void DPrimaryMediaBase::DefaultDriveCaps(TLocalDriveCapsV2& aCaps) |
|
2448 |
/** |
|
2449 |
Fills in the default drive capabilities in TLocalDriveCapsV2 . |
|
2450 |
It initializes media type of drive as unknown and has to be overridden in the derived class. Called from the Request ( ) function of the same class. |
|
2451 |
||
2452 |
@param aCaps Media drive capability fields. Extension to Capabilities fields(i.e) in addition to TLocalDriveCaps mainly to support Nor flash |
|
2453 |
@see TLocalDriveCapsV2 |
|
2454 |
*/ |
|
2455 |
||
2456 |
{ |
|
2457 |
// default implementation |
|
2458 |
// aCaps is zeroed beforehand |
|
2459 |
aCaps.iType = EMediaUnknown; |
|
2460 |
} |
|
2461 |
||
2462 |
EXPORT_C TBool DPrimaryMediaBase::IsRemovableDevice(TInt& /*aSocketNum*/) |
|
2463 |
/** |
|
2464 |
Checks whether it is a removable device or not |
|
2465 |
@param aSocketNum Socket number |
|
2466 |
@return ETrue=Removable Device |
|
2467 |
EFalse=Non-Removable device, default implementation |
|
2468 |
||
2469 |
*/ |
|
2470 |
{ |
|
2471 |
// default implementation |
|
2472 |
return(EFalse); |
|
2473 |
} |
|
2474 |
||
2475 |
EXPORT_C void DPrimaryMediaBase::HandleMsg(TLocDrvRequest& m) |
|
2476 |
/** |
|
2477 |
It handles the drive request encapsulated in TLocDrvRequest depending on the message id. |
|
2478 |
||
2479 |
@param aRequest Encapsulates the request information received from the client |
|
2480 |
@see TLocDrvRequest |
|
2481 |
*/ |
|
2482 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2483 |
OstTrace1( TRACE_FLOW, DPRIMARYMEDIABASE_HANDLEMSG_ENTRY, "> DPrimaryMediaBase::HandleMsg;m=%x;", (TUint) &m); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2484 |
|
0 | 2485 |
switch (m.iValue) |
2486 |
{ |
|
2487 |
case EConnect: |
|
2488 |
{ |
|
2489 |
DLocalDrive* pD=(DLocalDrive*)m.Ptr0(); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2490 |
iConnectionQ.Add(&pD->iMediaChangeObserver.iLink); |
0 | 2491 |
m.Complete(KErrNone, EFalse); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2492 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_HANDLEMSG_EXIT1, this ); |
0 | 2493 |
return; |
2494 |
} |
|
2495 |
case EDisconnect: |
|
2496 |
{ |
|
2497 |
DLocalDrive* pD=(DLocalDrive*)m.Ptr0(); |
|
2498 |
TLocDrv* pL=pD->iDrive; |
|
2499 |
DMedia* media=pL->iMedia; |
|
2500 |
if (iState==EReady && media && media->iDriver) |
|
2501 |
media->iDriver->Disconnect(pD,&m); |
|
2502 |
else |
|
2503 |
{ |
|
2504 |
pD->Deque(); |
|
2505 |
m.Complete(KErrNone, EFalse); |
|
2506 |
} |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2507 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_HANDLEMSG_EXIT2, this ); |
0 | 2508 |
return; |
2509 |
} |
|
2510 |
case DLocalDrive::EForceMediaChange: |
|
2511 |
{ |
|
2512 |
TUint flags = (TUint) m.Pos(); |
|
2513 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2514 |
#ifdef __DEMAND_PAGING__ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2515 |
// if this is a paging media (ROM,code or data), turn off the KMediaRemountForceMediaChange flag |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2516 |
// as this normally results in a call to DPBusSocket::ForceMediaChange() which effectively disables |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2517 |
// the media for a small time period - which would be disasterous if a paging request arrived |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2518 |
if (iBody->iPagingDevice) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2519 |
flags&= ~KMediaRemountForceMediaChange; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2520 |
#endif |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2521 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2522 |
// For media extension drivers, send a copy of the request to the next drive in the chain and wait for it. |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2523 |
TLocDrv* drv = m.Drive(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2524 |
if (drv->iNextDrive) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2525 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2526 |
TLocDrvRequest request; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2527 |
request.Drive() = drv->iNextDrive; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2528 |
request.Id() = DLocalDrive::EForceMediaChange; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2529 |
request.Pos() = m.Pos(); // flags |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2530 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2531 |
request.SendReceive(&drv->iNextDrive->iPrimaryMedia->iMsgQ); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2532 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2533 |
CompleteRequest(m, request.iValue); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2534 |
return; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2535 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2536 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2537 |
|
0 | 2538 |
// if KForceMediaChangeReOpenDriver specified wait for power up, |
2539 |
// and then re-open this drive's media driver |
|
2540 |
__KTRACE_OPT(KLOCDRV, Kern::Printf("EForceMediaChange, flags %08X\n", flags)); |
|
2541 |
if (flags == (TUint) KForceMediaChangeReOpenMediaDriver) |
|
2542 |
{ |
|
2543 |
TInt sock; |
|
2544 |
if (!IsRemovableDevice(sock)) |
|
2545 |
{ |
|
2546 |
CompleteRequest(m, KErrNotSupported); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2547 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_HANDLEMSG_EXIT3, this ); |
0 | 2548 |
return; |
2549 |
} |
|
2550 |
// wait for power up and then call DPrimaryMediaBase::DoRequest() |
|
2551 |
break; |
|
2552 |
} |
|
2553 |
||
2554 |
TInt r=ForceMediaChange(flags); |
|
2555 |
if (r==KErrNone) |
|
2556 |
{ |
|
2557 |
// wait for media change notification to complete message |
|
2558 |
m.Forward(&iWaitMedChg,EFalse); |
|
2559 |
} |
|
2560 |
else |
|
2561 |
{ |
|
2562 |
if (r==KErrNotSupported || r==KErrCompletion) |
|
2563 |
r=KErrNone; |
|
2564 |
CompleteRequest(m, r); |
|
2565 |
} |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2566 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_HANDLEMSG_EXIT4, this ); |
0 | 2567 |
return; |
2568 |
} |
|
2569 |
case DLocalDrive::ECaps: |
|
2570 |
if (iState==EPoweredDown) |
|
2571 |
{ |
|
2572 |
// The media is powered down, but the media driver still exists. |
|
2573 |
// - Issue the ECaps request without powering the media back up. |
|
2574 |
DoRequest(m); |
|
2575 |
__TRACE_TIMING(0x101); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2576 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_HANDLEMSG_EXIT5, this ); |
0 | 2577 |
return; |
2578 |
} |
|
2579 |
break; |
|
2580 |
||
2581 |
case DLocalDrive::ERead: |
|
2582 |
case DLocalDrive::EWrite: |
|
2583 |
case DLocalDrive::EFormat: |
|
2584 |
case DLocalDrive::EEnlarge: |
|
2585 |
case DLocalDrive::EReduce: |
|
2586 |
case DLocalDrive::EPasswordLock: |
|
2587 |
case DLocalDrive::EPasswordUnlock: |
|
2588 |
case DLocalDrive::EPasswordClear: |
|
2589 |
case DLocalDrive::EPasswordErase: |
|
2590 |
case DLocalDrive::EControlIO: |
|
2591 |
case DLocalDrive::EDeleteNotify: |
|
2592 |
case DLocalDrive::EQueryDevice: |
|
2593 |
||
2594 |
#ifdef __DEMAND_PAGING__ |
|
2595 |
case DMediaPagingDevice::ERomPageInRequest: |
|
2596 |
case DMediaPagingDevice::ECodePageInRequest: |
|
2597 |
#endif |
|
2598 |
break; |
|
2599 |
case DLocalDrive::EGetLastErrorInfo: |
|
2600 |
{ |
|
2601 |
DLocalDrive* pD=(DLocalDrive*)m.Ptr0(); |
|
2602 |
TLocDrv* pL=pD->iDrive; |
|
2603 |
*((TErrorInfo*) m.RemoteDes()) = pL->iLastErrorInfo; |
|
2604 |
CompleteRequest(m, KErrNone); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2605 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_HANDLEMSG_EXIT6, this ); |
0 | 2606 |
return; |
2607 |
} |
|
2608 |
case DLocalDrive::EReadPasswordStore: |
|
2609 |
{ |
|
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2610 |
TPtr8 pswData ((TUint8*) m.RemoteDes(), (TInt) m.Length()); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2611 |
TInt r = ThePasswordStore->ReadPasswordData(pswData); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2612 |
m.Length() = pswData.Length(); |
0 | 2613 |
CompleteRequest(m, r); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2614 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_HANDLEMSG_EXIT7, this ); |
0 | 2615 |
return; |
2616 |
} |
|
2617 |
case DLocalDrive::EWritePasswordStore: |
|
2618 |
{ |
|
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2619 |
TPtrC8 pData((TUint8*) m.RemoteDes(), (TInt) m.Length()); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2620 |
TInt r = ThePasswordStore->WritePasswordData(pData); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2621 |
|
0 | 2622 |
if(r != KErrNone) |
2623 |
{ |
|
2624 |
CompleteRequest(m, r); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2625 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_HANDLEMSG_EXIT8, this ); |
0 | 2626 |
return; |
2627 |
} |
|
2628 |
||
2629 |
r = QuickCheckStatus(); |
|
2630 |
if(r != KErrNone) |
|
2631 |
{ |
|
2632 |
// Don't try to power up the device if it's not ready. |
|
2633 |
// - Note that this isn't an error that needs to be returned to the client. |
|
2634 |
CompleteRequest(m, KErrNone); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2635 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_HANDLEMSG_EXIT9, this ); |
0 | 2636 |
return; |
2637 |
} |
|
2638 |
||
2639 |
break; |
|
2640 |
} |
|
2641 |
case DLocalDrive::EPasswordStoreLengthInBytes: |
|
2642 |
{ |
|
2643 |
TInt length = ThePasswordStore->PasswordStoreLengthInBytes(); |
|
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2644 |
*(TInt*) m.RemoteDes() = length; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2645 |
CompleteRequest(m, KErrNone); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2646 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_HANDLEMSG_EXIT10, this ); |
0 | 2647 |
return; |
2648 |
} |
|
2649 |
default: |
|
2650 |
CHECK_RET(KErrNotSupported); |
|
2651 |
CompleteRequest(m, KErrNotSupported); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2652 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_HANDLEMSG_EXIT11, this ); |
0 | 2653 |
return; |
2654 |
} |
|
2655 |
||
2656 |
__KTRACE_OPT(KFAIL,Kern::Printf("mdrq %d",m.Id())); |
|
2657 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase(%d)::HandleMsg state %d req %d",iMediaId,iState,m.Id())); |
|
2658 |
||
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2659 |
OstTraceDefExt3( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DPRIMARYMEDIABASE_HANDLEMSG2, "iMediaId=%d; iState=%d; req Id=%d", iMediaId, iState, m.Id()); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2660 |
|
0 | 2661 |
// if media driver already open, pass request through |
2662 |
if (iState==EReady) |
|
2663 |
{ |
|
2664 |
DoRequest(m); |
|
2665 |
__TRACE_TIMING(0x101); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2666 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_HANDLEMSG_EXIT12, this ); |
0 | 2667 |
return; |
2668 |
} |
|
2669 |
||
2670 |
// if open or close in progress, defer this message |
|
2671 |
if (iState!=EClosed && iState!=EPoweredDown) |
|
2672 |
{ |
|
2673 |
#ifdef __DEMAND_PAGING__ |
|
2674 |
if (DMediaPagingDevice::PagingRequest(m)) |
|
2675 |
{ |
|
2676 |
__ASSERT_ALWAYS(iPagingMedia,LOCM_FAULT()); |
|
2677 |
__ASSERT_DEBUG(iBody->iPagingDevice,LOCM_FAULT()); |
|
2678 |
__ASSERT_ALWAYS( ((m.Flags() & TLocDrvRequest::ECodePaging) == 0) || (m.Drive()->iPagingDrv), LOCM_FAULT()); |
|
2679 |
||
2680 |
__KTRACE_OPT2(KLOCDPAGING,KLOCDRV,Kern::Printf("Deferring PageIn request 0x%08x because opening or closing",&m)); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2681 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DPRIMARYMEDIABASE_HANDLEMSG3, "Deferring PageIn request 0x%08x because opening or closing", &m); |
0 | 2682 |
iBody->iPagingDevice->SendToDeferredQ(&m); |
2683 |
} |
|
2684 |
else |
|
2685 |
#endif |
|
2686 |
m.Forward(&iDeferred,EFalse); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2687 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_HANDLEMSG_EXIT13, this ); |
0 | 2688 |
return; |
2689 |
} |
|
2690 |
||
2691 |
// nothing is open, so try to open something |
|
2692 |
__ASSERT_ALWAYS(!iCurrentReq,LOCM_FAULT()); |
|
2693 |
||
2694 |
#ifdef __DEMAND_PAGING__ |
|
2695 |
||
2696 |
#ifdef BTRACE_PAGING_MEDIA |
|
2697 |
if (DMediaPagingDevice::PagingRequest(m)) |
|
2698 |
BTraceContext12(BTrace::EPagingMedia,BTrace::EPagingMediaLocMedPageInQuietlyDeferred,&m,iState,m.iValue); |
|
2699 |
#endif // BTRACE_PAGING_MEDIA |
|
2700 |
||
2701 |
#ifdef _DEBUG |
|
2702 |
__ASSERT_ALWAYS( ((m.Flags() & TLocDrvRequest::ECodePaging) == 0) || (m.Drive()->iPagingDrv), LOCM_FAULT()); |
|
2703 |
||
2704 |
if (DMediaPagingDevice::PagingRequest(m)) |
|
2705 |
{ |
|
2706 |
__ASSERT_DEBUG(iPagingMedia,LOCM_FAULT()); |
|
2707 |
__ASSERT_DEBUG(iBody->iPagingDevice,LOCM_FAULT()); |
|
2708 |
__KTRACE_OPT(KLOCDPAGING,Kern::Printf("Page request 0x%08x received -> opening MD",&m)); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2709 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DPRIMARYMEDIABASE_HANDLEMSG4, "Page request 0x%08x received; opening MD", &m); |
0 | 2710 |
} |
2711 |
#endif // _DEBUG |
|
2712 |
||
2713 |
#endif // __DEMAND_PAGING__ |
|
2714 |
||
2715 |
iCurrentReq=&m; |
|
2716 |
if(iState == EClosed) |
|
2717 |
{ |
|
2718 |
iState=EPoweringUp1; |
|
2719 |
} |
|
2720 |
else if (iState == EPoweredDown) |
|
2721 |
{ |
|
2722 |
iState=EPoweringUp2; |
|
2723 |
} |
|
2724 |
||
2725 |
TInt r=InitiatePowerUp(); |
|
2726 |
if (r==KErrNone || r==KErrServerBusy) |
|
2727 |
{ |
|
2728 |
// wait for completion of power up request |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2729 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_HANDLEMSG_EXIT14, this ); |
0 | 2730 |
return; |
2731 |
} |
|
2732 |
if (r==KErrCompletion) |
|
2733 |
r=KErrNone; // device already powered up |
|
2734 |
PowerUpComplete(r); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2735 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_HANDLEMSG_EXIT15, this ); |
0 | 2736 |
} |
2737 |
||
2738 |
EXPORT_C TInt DPrimaryMediaBase::DoRequest(TLocDrvRequest& m) |
|
2739 |
/** |
|
2740 |
If the media exists, it tries to get the partition information if not there. |
|
2741 |
It then passes on the request to the media driver by calling its Request( ) function. |
|
2742 |
Then it completes the kernel thread message and the reference count of the thread is closed asynchronously. |
|
2743 |
||
2744 |
@param aRequest Encapsulates the request information received from the client |
|
2745 |
||
2746 |
@return KErrNone, if successful |
|
2747 |
KErrNotReady, if missing partitions on removable media |
|
2748 |
KErrNotSupported, if missing partitions on fixed media |
|
2749 |
KErrArgument Out of range argument ,encapsulated in Local drive request , passed while checking and adjusting for partition |
|
2750 |
KErrEOF, Reached the end of file |
|
2751 |
KErrBadDescriptor, if request encapsulates a bad descriptor |
|
2752 |
Otherwise, one of the other system wide error codes. |
|
2753 |
||
2754 |
*/ |
|
2755 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2756 |
OstTraceFunctionEntry1( DPRIMARYMEDIABASE_DOREQUEST_ENTRY, this ); |
0 | 2757 |
__KTRACE_OPT2(KLOCDRV,KLOCDPAGING,Kern::Printf("DPrimaryMediaBase::DoRequest %d",m.Id())); |
2758 |
TLocDrv* pL=m.Drive(); |
|
2759 |
DMedia* media=pL->iMedia; |
|
2760 |
TInt r=KErrNone; |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2761 |
|
200
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
152
diff
changeset
|
2762 |
OstTraceDefExt5( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DPRIMARYMEDIABASE_DOREQUEST, "req Id=%d; length=%x:%x; position=%x:%x", (TInt) m.Id(), (TUint) I64HIGH(m.Length()), (TUint) I64LOW(m.Length()), (TUint) I64HIGH(m.Pos()), (TUint) I64LOW(m.Pos()) ); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2763 |
|
0 | 2764 |
// re-open this drive's media driver ? |
2765 |
if (m.iValue == DLocalDrive::EForceMediaChange) |
|
2766 |
{ |
|
2767 |
__ASSERT_DEBUG(((TUint) m.Pos()) == (TUint) KForceMediaChangeReOpenMediaDriver, LOCM_FAULT()); |
|
2768 |
iCurrentReq=NULL; |
|
2769 |
||
2770 |
TLocDrv* pL = m.Drive(); |
|
2771 |
DMedia* media = pL->iMedia; |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2772 |
|
0 | 2773 |
if (media && media->iDriver) |
2774 |
CloseMediaDrivers(media); |
|
2775 |
||
2776 |
iState=EOpening; |
|
2777 |
StartOpenMediaDrivers(); |
|
2778 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2779 |
NotifyClients(EMediaChange, pL); |
0 | 2780 |
CompleteRequest(m, r); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2781 |
OstTraceFunctionExitExt( DPRIMARYMEDIABASE_DOREQUEST_EXIT, this, r ); |
0 | 2782 |
return r; |
2783 |
} |
|
2784 |
||
2785 |
if (!media || !media->iDriver || iState == EClosed) |
|
2786 |
{ |
|
2787 |
// Return KErrNotReady for missing partitions on removable media |
|
2788 |
// as opposed to KErrNotSupported for missing partitions on fixed media |
|
2789 |
// since the latter don't exist whereas the former might exist at some time. |
|
2790 |
TInt sock; |
|
2791 |
r=IsRemovableDevice(sock) ? KErrNotReady : KErrNotSupported; |
|
2792 |
} |
|
2793 |
||
2794 |
iCurrentReq=&m; |
|
2795 |
if (r==KErrNone) |
|
2796 |
{ |
|
2797 |
if(iTotalPartitionsOpened == 0) |
|
2798 |
{ |
|
2799 |
UpdatePartitionInfo(); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2800 |
OstTraceFunctionExitExt( DPRIMARYMEDIABASE_DOREQUEST_EXIT2, this, KErrNone ); |
0 | 2801 |
return KErrNone; |
2802 |
} |
|
2803 |
if (!(m.Flags() & TLocDrvRequest::EAdjusted)) |
|
2804 |
{ |
|
2805 |
// If this isn't the only partition, don't allow access to the whole media |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2806 |
if (TDriveIterator::GetPhysicalDrive(m.Drive())->iPrimaryMedia->iTotalPartitionsOpened > 1) |
0 | 2807 |
m.DriverFlags() &= ~RLocalDrive::ELocDrvWholeMedia; |
2808 |
r=m.CheckAndAdjustForPartition(); |
|
2809 |
} |
|
2810 |
if (r==KErrNone) |
|
2811 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2812 |
OstTraceDefExt2( OST_TRACE_CATEGORY_RND, TRACE_INTERNALS, DPRIMARYMEDIABASE_DOREQUEST_START, "req Id=%d; Remote Thread=0x%x", (TInt) m.Id(), (TUint) m.RemoteThread()); |
0 | 2813 |
r=media->iDriver->Request(m); |
2814 |
if (r>0) |
|
2815 |
{ |
|
2816 |
// defer request |
|
2817 |
#ifdef __DEMAND_PAGING__ |
|
2818 |
if (DMediaPagingDevice::PagingRequest(m)) |
|
2819 |
{ |
|
2820 |
__ASSERT_ALWAYS(iPagingMedia,LOCM_FAULT()); |
|
2821 |
__ASSERT_ALWAYS( ((m.Flags() & TLocDrvRequest::ECodePaging) == 0) || (m.Drive()->iPagingDrv), LOCM_FAULT()); |
|
2822 |
__ASSERT_DEBUG(iBody->iPagingDevice,LOCM_FAULT()); |
|
2823 |
__KTRACE_OPT2(KLOCDPAGING,KLOCDRV,Kern::Printf("Defer PageIn request 0x%08x",&m)); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2824 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DPRIMARYMEDIABASE_DOREQUEST2, "Defer PageIn request 0x%08x", &m); |
0 | 2825 |
DMediaPagingDevice* pagingdevice=iBody->iPagingDevice; |
2826 |
||
2827 |
#ifdef __CONCURRENT_PAGING_INSTRUMENTATION__ |
|
2828 |
TInt id=m.iValue; |
|
2829 |
if (id==DMediaPagingDevice::ERomPageInRequest) |
|
2830 |
{ |
|
2831 |
NKern::FMWait(&pagingdevice->iInstrumentationLock); |
|
2832 |
if(pagingdevice->iEmptyingQ & DMediaPagingDevice::EDeferredQ) |
|
2833 |
pagingdevice->iROMStats.iTotalReDeferrals++; |
|
2834 |
else if(pagingdevice->iEmptyingQ & DMediaPagingDevice::EMainQ) |
|
2835 |
pagingdevice->iROMStats.iTotalSynchDeferredFromMainQ++; |
|
2836 |
NKern::FMSignal(&pagingdevice->iInstrumentationLock); |
|
2837 |
} |
|
2838 |
else if (m.Flags() & TLocDrvRequest::ECodePaging) |
|
2839 |
{ |
|
2840 |
NKern::FMWait(&pagingdevice->iInstrumentationLock); |
|
2841 |
if(pagingdevice->iEmptyingQ & DMediaPagingDevice::EDeferredQ) |
|
2842 |
pagingdevice->iCodeStats.iTotalReDeferrals++; |
|
2843 |
else if(pagingdevice->iEmptyingQ & DMediaPagingDevice::EMainQ) |
|
2844 |
pagingdevice->iCodeStats.iTotalSynchDeferredFromMainQ++; |
|
2845 |
NKern::FMSignal(&pagingdevice->iInstrumentationLock); |
|
2846 |
} |
|
2847 |
else if (m.Flags() & TLocDrvRequest::EDataPaging) |
|
2848 |
{ |
|
2849 |
NKern::FMWait(&pagingdevice->iInstrumentationLock); |
|
2850 |
if(pagingdevice->iEmptyingQ & DMediaPagingDevice::EDeferredQ) |
|
2851 |
pagingdevice->iDataStats.iTotalReDeferrals++; |
|
2852 |
else if(pagingdevice->iEmptyingQ & DMediaPagingDevice::EMainQ) |
|
2853 |
pagingdevice->iDataStats.iTotalSynchDeferredFromMainQ++; |
|
2854 |
NKern::FMSignal(&pagingdevice->iInstrumentationLock); |
|
2855 |
} |
|
2856 |
#endif |
|
2857 |
pagingdevice->SendToDeferredQ(&m); |
|
2858 |
} |
|
2859 |
else |
|
2860 |
#endif |
|
2861 |
m.Forward(&iDeferred,EFalse); |
|
2862 |
r=KErrNone; |
|
2863 |
} |
|
2864 |
#if defined(__DEMAND_PAGING__) && defined(_DEBUG) |
|
2865 |
else if (r == KErrNone && DMediaPagingDevice::PagingRequest(m)) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2866 |
{ |
0 | 2867 |
__KTRACE_OPT(KLOCDPAGING,Kern::Printf("PageIn req 0x%08x completing asynchronously",&m)); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2868 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DPRIMARYMEDIABASE_DOREQUEST3, "PageIn req 0x%08x completing asynchronously", &m); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2869 |
} |
0 | 2870 |
#endif |
2871 |
} |
|
2872 |
} |
|
2873 |
||
2874 |
if (r!=KErrNone && iCurrentReq) |
|
2875 |
{ |
|
2876 |
TInt s=(r==KErrCompletion)?KErrNone:r; |
|
2877 |
CHECK_RET(s); |
|
2878 |
||
2879 |
#ifdef __DEMAND_PAGING__ |
|
2880 |
// got here because media driver cannot service or defer this request or did service it synchronously |
|
2881 |
if (DMediaPagingDevice::PagingRequest(m)) |
|
2882 |
{ |
|
2883 |
__ASSERT_ALWAYS(iPagingMedia,LOCM_FAULT()); |
|
2884 |
__ASSERT_ALWAYS( ((m.Flags() & TLocDrvRequest::ECodePaging) == 0) || (m.Drive()->iPagingDrv), LOCM_FAULT()); |
|
2885 |
__ASSERT_DEBUG(iBody->iPagingDevice,LOCM_FAULT()); |
|
2886 |
__KTRACE_OPT(KLOCDPAGING,Kern::Printf("media driver cannot service or defer PageIn request 0x%08x or serviced it synchronously (%d)",&m, s)); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2887 |
OstTraceDefExt2(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DPRIMARYMEDIABASE_DOREQUEST4, "Media driver cannot service or defer PageIn request 0x%08x or serviced it synchronously; retval=%d",(TUint) &m, s); |
0 | 2888 |
iBody->iPagingDevice->CompleteRequest(&m, s); |
2889 |
} |
|
2890 |
else |
|
2891 |
#endif |
|
152
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
2892 |
{ |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
2893 |
CompleteRequest(m, s); |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
2894 |
OstTraceDefExt2( OST_TRACE_CATEGORY_RND, TRACE_INTERNALS, DPRIMARYMEDIABASE_DOREQUEST_RETURN, "Return Remote Thread=0x%x; retval=%d", (TUint) m.RemoteThread(), (TInt) s); |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
2895 |
} |
0 | 2896 |
} |
2897 |
||
2898 |
iCurrentReq=NULL; |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2899 |
OstTraceFunctionExitExt( DPRIMARYMEDIABASE_DOREQUEST_EXIT3, this, r ); |
0 | 2900 |
return r; |
2901 |
} |
|
2902 |
||
2903 |
EXPORT_C void DPrimaryMediaBase::PowerUpComplete(TInt anError) |
|
2904 |
/** |
|
2905 |
Called after the device is powered up or there is some error while powering up the device. |
|
2906 |
If there is an error powering up the devices then it just completes the current running requests with an error |
|
2907 |
and also completes the outstanding requests on the iDeferred message queue by calling SetClosed( ). |
|
2908 |
If the device is powered up OK then it either opens the media drivers |
|
2909 |
and if they are already open then it handles the current/pending requests. |
|
2910 |
||
2911 |
@param anError Error code to be passed on while completing outstanding requests. |
|
2912 |
*/ |
|
2913 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2914 |
OstTraceFunctionEntry1( DPRIMARYMEDIABASE_POWERUPCOMPLETE_ENTRY, this ); |
0 | 2915 |
__KTRACE_OPT(KLOCDRV,Kern::Printf(">DPrimaryMediaBase(%d)::PowerUpComplete err %d iState %d",iMediaId,anError,iState)); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2916 |
|
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2917 |
OstTraceExt3( TRACE_INTERNALS, DPRIMARYMEDIABASE_POWERUPCOMPLETE, "iMediaId=%d; anError=%d; iState=%d", iMediaId, anError, iState ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2918 |
|
0 | 2919 |
if (anError!=KErrNone) |
2920 |
{ |
|
2921 |
// error powering up device |
|
2922 |
if (iState==EPoweringUp1 || iState==EPoweringUp2) |
|
2923 |
SetClosed(anError); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2924 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_POWERUPCOMPLETE_EXIT, this ); |
0 | 2925 |
return; |
2926 |
} |
|
2927 |
||
2928 |
// Powered up OK - now open media drivers |
|
2929 |
if (iState==EPoweringUp1) |
|
2930 |
{ |
|
2931 |
iState=EOpening; |
|
2932 |
StartOpenMediaDrivers(); |
|
2933 |
} |
|
2934 |
else if (iState==EPoweringUp2) |
|
2935 |
{ |
|
2936 |
// media is powered up and ready, so handle the current/pending requests |
|
2937 |
MediaReadyHandleRequest(); |
|
2938 |
} |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2939 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_POWERUPCOMPLETE_EXIT2, this ); |
0 | 2940 |
} |
2941 |
||
2942 |
void DPrimaryMediaBase::CloseMediaDrivers(DMedia* aMedia) |
|
2943 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2944 |
OstTraceFunctionEntry1( DPRIMARYMEDIABASE_CLOSEMEDIADRIVERS_ENTRY, this ); |
0 | 2945 |
__KTRACE_OPT(KLOCDRV,Kern::Printf(">DPrimaryMediaBase(%d)::CloseMediaDrivers",iMediaId)); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2946 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_MEDIACHANGE, DPRIMARYMEDIABASE_CLOSEMEDIADRIVERS1, "DPrimaryMediaBase iMediaId=%d", iMediaId ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2947 |
|
0 | 2948 |
// we mustn't ever close the media driver if it's responsible for data paging as re-opening the drive |
2949 |
// would involve memory allocation which might cause deadlock if the kernel heap were to grow |
|
2950 |
#ifdef __DEMAND_PAGING__ |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2951 |
if (DataPagingMedia(this)) |
0 | 2952 |
{ |
2953 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("CloseMediaDrivers aborting for data paging media %08X", this)); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2954 |
OstTrace1(TRACE_FLOW, DPRIMARYMEDIABASE_CLOSEMEDIADRIVERS_EXIT1, "CloseMediaDrivers aborting for data paging media 0x%08x", this); |
0 | 2955 |
return; |
2956 |
} |
|
2957 |
#endif |
|
2958 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2959 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2960 |
// Don't close any media extension drivers either, since it won't serve any purpose |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2961 |
// and keeping the driver open allows it to maintain internal state |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2962 |
if (iBody->iMediaExtension) |
0 | 2963 |
{ |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2964 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("CloseMediaDrivers aborting for extension media %08X", this)); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2965 |
return; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2966 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2967 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2968 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2969 |
TDriveIterator driveIter; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2970 |
for (TLocDrv* pL = driveIter.NextDrive(); pL != NULL; pL = driveIter.NextDrive()) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2971 |
{ |
0 | 2972 |
if (pL && pL->iPrimaryMedia==this) |
2973 |
{ |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2974 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("Drive %d",driveIter.Index())); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2975 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_MEDIACHANGE, DPRIMARYMEDIABASE_CLOSEMEDIADRIVERS2, "Drive=%d", driveIter.Index()); |
0 | 2976 |
if (aMedia == NULL || pL->iMedia == aMedia) |
2977 |
{ |
|
2978 |
pL->iMedia=NULL; |
|
2979 |
} |
|
2980 |
} |
|
2981 |
} |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2982 |
for (TInt i=iLastMediaId; i>=iMediaId; i--) |
0 | 2983 |
{ |
2984 |
DMedia* pM=TheMedia[i]; |
|
2985 |
if (aMedia == NULL || pM == aMedia) |
|
2986 |
{ |
|
2987 |
DMediaDriver* pD=pM->iDriver; |
|
2988 |
pM->iDriver=NULL; |
|
2989 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("DMedia[%d] @ %08x Driver @ %08x",i,pM,pD)); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2990 |
OstTraceDefExt3( OST_TRACE_CATEGORY_RND, TRACE_MEDIACHANGE, DPRIMARYMEDIABASE_CLOSEMEDIADRIVERS3, "MediaId=%d; DMedia=0x%08x; MediaDriver=0x%08x", (TInt) i, (TUint) pM, (TUint) pD ); |
0 | 2991 |
if (pD) |
2992 |
pD->Close(); |
|
2993 |
} |
|
2994 |
} |
|
2995 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("<DPrimaryMediaBase(%d)::CloseMediaDrivers",iMediaId)); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2996 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_CLOSEMEDIADRIVERS_EXIT2, this ); |
0 | 2997 |
} |
2998 |
||
2999 |
void DPrimaryMediaBase::StartOpenMediaDrivers() |
|
3000 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3001 |
OstTraceFunctionEntry1( DPRIMARYMEDIABASE_STARTOPENMEDIADRIVERS_ENTRY, this ); |
0 | 3002 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase(%d)::StartOpenMediaDrivers",iMediaId)); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3003 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_MEDIACHANGE, DPRIMARYMEDIABASE_STARTOPENMEDIADRIVERS, "DPrimaryMediaBase iMediaId=%d ",iMediaId); |
0 | 3004 |
TVersion ver(KMediaDriverInterfaceMajorVersion,KMediaDriverInterfaceMinorVersion,KMediaDriverInterfaceBuildVersion); |
3005 |
||
3006 |
// Get a list of all currently loaded media drivers |
|
3007 |
// Most media drivers do not make use of the pointer iMountInfo.iInfo when |
|
3008 |
// their Validate() procedures are called from RPhysicalDeviceArray::GetDriverList(). |
|
3009 |
// However, a group of media drivers sharing the same id (passed in iDevice) may use |
|
3010 |
// the additional information pointed to by iMountInfo.iInfo to distinguish |
|
3011 |
// group members. This information is passed when the media driver is registered |
|
3012 |
// using LocDrv::RegisterMediaDevice(). |
|
3013 |
TInt r=iPhysDevArray.GetDriverList(KLitMediaDriverName,iDevice,iMountInfo.iInfo,ver); |
|
3014 |
if (r!=KErrNone) |
|
3015 |
{ |
|
3016 |
// out of memory or no driver exists |
|
3017 |
SetClosed(r); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3018 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_STARTOPENMEDIADRIVERS_EXIT1, this ); |
0 | 3019 |
return; |
3020 |
} |
|
3021 |
||
3022 |
// Go through them starting with highest priority |
|
3023 |
iNextMediaId=iMediaId; |
|
3024 |
iBody->iPhysDevIndex=iPhysDevArray.Count()-1; |
|
3025 |
iTotalPartitionsOpened=0; |
|
3026 |
iMediaDriversOpened=0; |
|
3027 |
iNextMediaDriver=NULL; |
|
3028 |
OpenNextMediaDriver(); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3029 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_STARTOPENMEDIADRIVERS_EXIT2, this ); |
0 | 3030 |
} |
3031 |
||
3032 |
void DPrimaryMediaBase::OpenNextMediaDriver() |
|
3033 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3034 |
OstTraceFunctionEntry1( DPRIMARYMEDIABASE_OPENNEXTMEDIADRIVER_ENTRY, this ); |
0 | 3035 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase(%d)::OpenNextMediaDriver, this %x mediaId %d iBody->iPhysDevIndex %d",iNextMediaId, this, iMediaId, iBody->iPhysDevIndex)); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3036 |
OstTraceDefExt4(OST_TRACE_CATEGORY_RND, TRACE_MEDIACHANGE, DPRIMARYMEDIABASE_OPENNEXTMEDIADRIVER, "DPrimaryMediaBase iNextMediaId=%d; this=%x; imediaId=%d; iBody->iPhysDevIndex=%d",iNextMediaId, (TUint) this, iMediaId, iBody->iPhysDevIndex); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3037 |
|
0 | 3038 |
TVersion ver(KMediaDriverInterfaceMajorVersion,KMediaDriverInterfaceMinorVersion,KMediaDriverInterfaceBuildVersion); |
3039 |
SPhysicalDeviceEntry& e=iPhysDevArray[iBody->iPhysDevIndex]; |
|
3040 |
DPhysicalDevice* pD=e.iPhysicalDevice; |
|
3041 |
||
3042 |
iState = EOpening; |
|
3043 |
||
3044 |
DMedia* pM=TheMedia[iNextMediaId]; |
|
3045 |
if (pM && pM->iDriver != NULL) |
|
3046 |
{ |
|
3047 |
iNextMediaDriver = pM->iDriver; |
|
3048 |
DoOpenMediaDriverComplete(KErrNone); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3049 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_OPENNEXTMEDIADRIVER_EXIT1, this ); |
0 | 3050 |
return; |
3051 |
} |
|
3052 |
||
3053 |
// this may be asynchronous |
|
3054 |
TInt s=pD->Create( (DBase*&)iNextMediaDriver, iMediaId, (TDesC8*) &iMountInfo, ver); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3055 |
|
0 | 3056 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("Media:Open-Opening %o(PRI:%d)-%d",pD,e.iPriority,s)); |
3057 |
if (s!=KErrNone) |
|
3058 |
{ |
|
3059 |
iAsyncErrorCode=s; |
|
3060 |
iAsyncDfc.Enque(); |
|
3061 |
} |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3062 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_OPENNEXTMEDIADRIVER_EXIT2, this ); |
0 | 3063 |
} |
3064 |
||
3065 |
// Called when a media driver has responded to the Open request |
|
3066 |
void DPrimaryMediaBase::DoOpenMediaDriverComplete(TInt anError) |
|
3067 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3068 |
OstTraceFunctionEntry1( DPRIMARYMEDIABASE_DOOPENMEDIADRIVERCOMPLETE_ENTRY, this ); |
0 | 3069 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase(%d)::DoOpenMediaDriverComplete error %d iNextMediaDriver %x",iNextMediaId,anError,iNextMediaDriver)); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3070 |
OstTraceDefExt3( OST_TRACE_CATEGORY_RND, TRACE_MEDIACHANGE, DPRIMARYMEDIABASE_DOOPENMEDIADRIVERCOMPLETE, "iMediaId=%d; anError=%d; iNextMediaDriver=0x%x", (TInt) iNextMediaId, (TInt) anError, (TUint) iNextMediaDriver); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3071 |
|
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3072 |
|
0 | 3073 |
if (anError!=KErrNone) |
3074 |
{ |
|
3075 |
DMediaDriver* md = iNextMediaDriver; |
|
3076 |
iNextMediaDriver = NULL; |
|
3077 |
if (md) |
|
3078 |
md->Close(); |
|
3079 |
} |
|
3080 |
if (anError==KErrNotReady || anError==KErrNoMemory) |
|
3081 |
{ |
|
3082 |
// if it's not ready or we're out of memory, abort |
|
3083 |
CloseMediaDrivers(); |
|
3084 |
SetClosed(anError); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3085 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_DOOPENMEDIADRIVERCOMPLETE_EXIT1, this ); |
0 | 3086 |
return; |
3087 |
} |
|
3088 |
if (anError==KErrNone) |
|
3089 |
{ |
|
3090 |
DMedia* pM=TheMedia[iNextMediaId]; |
|
3091 |
pM->iDriver=iNextMediaDriver; |
|
3092 |
DPhysicalDevice*& pD=iPhysDevArray[iBody->iPhysDevIndex].iPhysicalDevice; |
|
3093 |
iNextMediaDriver->iPhysicalDevice=pD; |
|
3094 |
pD=NULL; // so it won't be closed when we tidy up |
|
3095 |
++iMediaDriversOpened; |
|
3096 |
} |
|
3097 |
||
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3098 |
|
0 | 3099 |
// if no error, read partition info on media |
3100 |
iState = EReadPartitionInfo; |
|
3101 |
||
3102 |
if (anError == KErrNone) |
|
3103 |
{ |
|
3104 |
DMedia* pM=TheMedia[iNextMediaId]; |
|
3105 |
TInt r = pM->iDriver->PartitionInfo(pM->iPartitionInfo); |
|
3106 |
if (r!=KErrNone) |
|
3107 |
{ |
|
3108 |
if (r==KErrCompletion) |
|
3109 |
r=KErrNone; |
|
3110 |
DoPartitionInfoComplete(r); |
|
3111 |
} |
|
3112 |
} |
|
3113 |
else |
|
3114 |
{ |
|
3115 |
DoPartitionInfoComplete(anError); |
|
3116 |
} |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3117 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_DOOPENMEDIADRIVERCOMPLETE_EXIT2, this ); |
0 | 3118 |
} |
3119 |
||
3120 |
void DPrimaryMediaBase::DoPartitionInfoComplete(TInt anError) |
|
3121 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3122 |
OstTraceFunctionEntry1( DPRIMARYMEDIABASE_DOPARTITIONINFOCOMPLETE_ENTRY, this ); |
0 | 3123 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase(%d)::DoPartitionInfoComplete error %d",iNextMediaId,anError)); |
3124 |
||
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3125 |
OstTraceExt2( TRACE_INTERNALS, DPRIMARYMEDIABASE_DOPARTITIONINFOCOMPLETE1, "iNextMediaId=%d; anError=%d", iNextMediaId, anError ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3126 |
|
0 | 3127 |
DMedia* pM=TheMedia[iNextMediaId]; |
3128 |
if (anError==KErrNone || anError == KErrLocked) |
|
3129 |
{ |
|
3130 |
// successfully read partition info |
|
3131 |
iTotalPartitionsOpened+=pM->PartitionCount(); |
|
3132 |
} |
|
3133 |
else |
|
3134 |
{ |
|
3135 |
// couldn't read partition info or driver failed to open |
|
3136 |
if (pM->iDriver) |
|
3137 |
{ |
|
3138 |
#ifdef __DEMAND_PAGING__ |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3139 |
if (DataPagingMedia(this)) |
0 | 3140 |
{ |
3141 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("DoPartitionInfoComplete(%d) Close Media Driver aborted for data paging media %08X", this)); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3142 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DPRIMARYMEDIABASE_DOPARTITIONINFOCOMPLETE2, "Close Media Driver for data paging media 0x%08x", this); |
0 | 3143 |
} |
3144 |
else |
|
3145 |
#endif |
|
3146 |
{ |
|
3147 |
pM->iDriver->Close(); |
|
3148 |
pM->iDriver=NULL; |
|
3149 |
} |
|
3150 |
} |
|
3151 |
if (anError==KErrNotReady || anError==KErrNoMemory) |
|
3152 |
{ |
|
3153 |
// if it's not ready or we're out of memory, or the drive is locked, abort |
|
3154 |
CloseMediaDrivers(); |
|
3155 |
SetClosed(anError); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3156 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_DOPARTITIONINFOCOMPLETE_EXIT, this ); |
0 | 3157 |
return; |
3158 |
} |
|
3159 |
} |
|
3160 |
||
3161 |
// Open next media driver, if there is one |
|
3162 |
TBool complete = EFalse; |
|
3163 |
if (++iNextMediaId>iLastMediaId) |
|
3164 |
complete=ETrue; |
|
3165 |
if (iBody->iPhysDevIndex==0) |
|
3166 |
complete=ETrue; |
|
3167 |
else |
|
3168 |
iBody->iPhysDevIndex--; |
|
3169 |
if (!complete) |
|
3170 |
{ |
|
3171 |
OpenNextMediaDriver(); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3172 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_DOPARTITIONINFOCOMPLETE_EXIT2, this ); |
0 | 3173 |
return; |
3174 |
} |
|
3175 |
||
3176 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase %d All media drivers open & partitions read",iMediaId)); |
|
3177 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("%d media drivers opened",iMediaDriversOpened)); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3178 |
OstTrace1( TRACE_INTERNALS, DPRIMARYMEDIABASE_DOPARTITIONINFOCOMPLETE3, "iMediaDriversOpened=%d", iMediaDriversOpened ); |
0 | 3179 |
if (iMediaDriversOpened==0) |
3180 |
{ |
|
3181 |
SetClosed(KErrNotSupported); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3182 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_DOPARTITIONINFOCOMPLETE_EXIT3, this ); |
0 | 3183 |
return; |
3184 |
} |
|
3185 |
||
3186 |
// we are now finished with media driver list |
|
3187 |
iPhysDevArray.Close(); |
|
3188 |
||
3189 |
// Finished reading partition info |
|
3190 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase %d Read partition info complete",iMediaId)); |
|
3191 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("%d total partitions",iTotalPartitionsOpened)); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3192 |
OstTraceExt2( TRACE_INTERNALS, DPRIMARYMEDIABASE_DOPARTITIONINFOCOMPLETE4, "Read partition info complete iMediaId=%d; iPartitionsOpened=%d", iMediaId, iTotalPartitionsOpened ); |
0 | 3193 |
if (iTotalPartitionsOpened==0) |
3194 |
{ |
|
3195 |
SetClosed(KErrNotSupported); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3196 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_DOPARTITIONINFOCOMPLETE_EXIT4, this ); |
0 | 3197 |
return; |
3198 |
} |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3199 |
|
0 | 3200 |
// work out mapping of drives to partitions/media |
3201 |
TInt totalPartitions=iTotalPartitionsOpened; |
|
3202 |
TInt id=iMediaId; // start with primary media |
|
3203 |
TInt partitionsOnThisMedia=PartitionCount(); |
|
3204 |
TInt partition=0; |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3205 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3206 |
TDriveIterator driveIter; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3207 |
for (TLocDrv* pD = driveIter.NextDrive(); pD != NULL; pD = driveIter.NextDrive()) |
0 | 3208 |
{ |
3209 |
if (pD && pD->iPrimaryMedia==this) |
|
3210 |
{ |
|
3211 |
if (totalPartitions==0) |
|
3212 |
{ |
|
3213 |
pD->iMedia=NULL; |
|
3214 |
continue; |
|
3215 |
} |
|
3216 |
if (partition==partitionsOnThisMedia) |
|
3217 |
{ |
|
3218 |
id++; |
|
3219 |
partition=0; |
|
3220 |
partitionsOnThisMedia=TheMedia[id]->PartitionCount(); |
|
3221 |
} |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3222 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("Drive %d = Media %d Partition %d",driveIter.Index(),id,partition)); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3223 |
OstTraceExt3( TRACE_INTERNALS, DPRIMARYMEDIABASE_DOPARTITIONINFOCOMPLETE5, "Local Drive=%d; iMediaId=%d; partition=%d", driveIter.Index(), id, partition ); |
0 | 3224 |
pD->iMedia=TheMedia[id]; |
3225 |
pD->iPartitionNumber=partition; |
|
3226 |
memcpy(pD, pD->iMedia->iPartitionInfo.iEntry+partition, sizeof(TPartitionEntry)); |
|
3227 |
partition++; |
|
3228 |
totalPartitions--; |
|
3229 |
} |
|
3230 |
} |
|
3231 |
||
3232 |
// media is now ready - handle current or deferred requests |
|
3233 |
MediaReadyHandleRequest(); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3234 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_DOPARTITIONINFOCOMPLETE_EXIT5, this ); |
0 | 3235 |
} |
3236 |
||
3237 |
void DPrimaryMediaBase::MediaReadyHandleRequest() |
|
3238 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3239 |
OstTraceFunctionEntry1( DPRIMARYMEDIABASE_MEDIAREADYHANDLEREQUEST_ENTRY, this ); |
0 | 3240 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase::MediaReadyHandleRequest() this %x", this)); |
3241 |
iState = EReady; |
|
3242 |
||
3243 |
// now we can process the current request |
|
3244 |
// careful - thread may have exited while we were powering up |
|
3245 |
if (iCurrentReq) |
|
3246 |
{ |
|
3247 |
DoRequest(*iCurrentReq); // this sets iCurrentReq=NULL |
|
3248 |
} |
|
3249 |
||
3250 |
// see if we can process any other requests concurrently |
|
3251 |
RunDeferred(); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3252 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_MEDIAREADYHANDLEREQUEST_EXIT, this ); |
0 | 3253 |
} |
3254 |
||
3255 |
void DPrimaryMediaBase::UpdatePartitionInfo() |
|
3256 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3257 |
OstTraceFunctionEntry1( DPRIMARYMEDIABASE_UPDATEPARTITIONINFO_ENTRY, this ); |
0 | 3258 |
iState=EReadPartitionInfo; |
3259 |
iNextMediaId=iMediaId; |
|
3260 |
DMedia* pM=TheMedia[iNextMediaId]; |
|
3261 |
TInt r=pM->iDriver->PartitionInfo(pM->iPartitionInfo); |
|
3262 |
if (r!=KErrNone) |
|
3263 |
{ |
|
3264 |
if (r==KErrCompletion) |
|
3265 |
r=KErrNone; |
|
3266 |
DoPartitionInfoComplete(r); |
|
3267 |
} |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3268 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_UPDATEPARTITIONINFO_EXIT, this ); |
0 | 3269 |
} |
3270 |
||
3271 |
void DPrimaryMediaBase::CompleteCurrent(TInt anError) |
|
3272 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3273 |
OstTraceFunctionEntryExt( DPRIMARYMEDIABASE_COMPLETECURRENT_ENTRY, this ); |
0 | 3274 |
if (iCurrentReq) |
3275 |
{ |
|
3276 |
CHECK_RET(anError); |
|
3277 |
#ifdef __DEMAND_PAGING__ |
|
3278 |
// got here because it was powered down when powering up, or failed powering up or failed opening MD or got media change |
|
3279 |
if (DMediaPagingDevice::PagingRequest(*iCurrentReq)) |
|
3280 |
{ |
|
3281 |
__ASSERT_ALWAYS(iPagingMedia,LOCM_FAULT()); |
|
3282 |
__ASSERT_DEBUG(iBody->iPagingDevice,LOCM_FAULT()); |
|
3283 |
__ASSERT_ALWAYS( ((iCurrentReq->Flags() & TLocDrvRequest::ECodePaging) == 0) || (iCurrentReq->Drive()->iPagingDrv), LOCM_FAULT()); |
|
3284 |
||
3285 |
__KTRACE_OPT2(KLOCDPAGING,KFAIL,Kern::Printf("Got here because it was powered down when powering up, or failed powering up or failed opening MD or got media change")); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3286 |
OstTraceDef0(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DPRIMARYMEDIABASE_COMPLETECURRENT, "Completed request due to powered down when powering up, or failed powering up or failed opening MD or got media change"); |
0 | 3287 |
iBody->iPagingDevice->CompleteRequest(iCurrentReq, anError); |
3288 |
} |
|
3289 |
else |
|
3290 |
#endif |
|
3291 |
CompleteRequest(*iCurrentReq, anError); |
|
3292 |
iCurrentReq=NULL; |
|
3293 |
} |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3294 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_COMPLETECURRENT_EXIT, this ); |
0 | 3295 |
} |
3296 |
||
3297 |
||
3298 |
void DPrimaryMediaBase::CompleteRequest(TLocDrvRequest& aMsg, TInt aResult) |
|
3299 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3300 |
OstTraceFunctionEntry1( DPRIMARYMEDIABASE_COMPLETEREQUEST_ENTRY, this ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3301 |
OstTraceDefExt2(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DPRIMARYMEDIABASE_COMPLETEREQUEST1, "TLocDrvRequest Object=0x%x; aResult=%d", (TUint) &aMsg, aResult); |
0 | 3302 |
aMsg.Complete(aResult,EFalse); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3303 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_COMPLETEREQUEST_EXIT, this ); |
0 | 3304 |
} |
3305 |
||
3306 |
EXPORT_C void DPrimaryMediaBase::RunDeferred() |
|
3307 |
/** |
|
3308 |
Runs deferred Requests. Initiated from DPrimaryMediaBase::PowerUpComplete() function |
|
3309 |
to see if any other requests can be processed concurrently. |
|
3310 |
Can also be called from DPrimaryMediaBase::NotifyPowerDown |
|
3311 |
or DPrimaryMediaBase::NotifyEmergencyPowerDown() function or DMediaDriver::Complete() |
|
3312 |
*/ |
|
3313 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3314 |
OstTraceFunctionEntry1( DPRIMARYMEDIABASE_RUNDEFERRED_ENTRY, this ); |
0 | 3315 |
// Do nothing if an open or close is in progress - this might be the case, for example, |
3316 |
// if a EForceMediaChange request (with the KForceMediaChangeReOpenMediaDriver flag) |
|
3317 |
// has recently been processed |
|
3318 |
if (iState!=EReady && iState!=EClosed && iState!=EPoweredDown) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3319 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3320 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_RUNDEFERRED_EXIT1, this ); |
0 | 3321 |
return; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3322 |
} |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3323 |
|
0 | 3324 |
// rerun deferred requests; |
3325 |
#ifdef __DEMAND_PAGING__ |
|
3326 |
#ifdef __CONCURRENT_PAGING_INSTRUMENTATION__ |
|
3327 |
TInt countROM=0; |
|
3328 |
TInt countCode=0; |
|
3329 |
#endif |
|
3330 |
||
3331 |
if(iPagingMedia) |
|
3332 |
{ |
|
3333 |
__ASSERT_DEBUG(iBody->iPagingDevice,LOCM_FAULT()); |
|
3334 |
if(iBody->iPagingDevice->iEmptyingQ & DMediaPagingDevice::EDeferredQ) // if already emptying deferred page in queue, don't reenter |
|
3335 |
{ |
|
3336 |
__KTRACE_OPT(KLOCDPAGING,Kern::Printf("Already emptying deferred queue")); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3337 |
OstTrace0(TRACE_FLOW, DPRIMARYMEDIABASE_RUNDEFERRED_EXIT2, "< Already emptying deferred queue"); |
0 | 3338 |
return; |
3339 |
} |
|
3340 |
||
3341 |
DMediaPagingDevice* pagingdevice=iBody->iPagingDevice; |
|
3342 |
TLocDrvRequest* pL = (TLocDrvRequest*) pagingdevice->iDeferredQ.Last(); |
|
3343 |
if(pL) |
|
3344 |
{ |
|
3345 |
pagingdevice->iEmptyingQ|= DMediaPagingDevice::EDeferredQ; // prevent reentering when already emptying this queue |
|
3346 |
TLocDrvRequest* pM=NULL; |
|
3347 |
while (pM != pL && (pM = (TLocDrvRequest*) pagingdevice->iDeferredQ.Poll()) != NULL) // synchronously empty deferred queue but ignore re-deferrals |
|
3348 |
{ |
|
3349 |
__ASSERT_ALWAYS( DMediaPagingDevice::PagingRequest(*pL), LOCM_FAULT() ); |
|
3350 |
||
3351 |
#ifdef __CONCURRENT_PAGING_INSTRUMENTATION__ |
|
3352 |
(pM->iValue==DMediaPagingDevice::ERomPageInRequest)?(countROM++):(countCode++); |
|
3353 |
if(pM==pL) |
|
3354 |
{ |
|
3355 |
NKern::FMWait(&pagingdevice->iInstrumentationLock); |
|
3356 |
if(pM->iValue==DMediaPagingDevice::ERomPageInRequest && pagingdevice->iROMStats.iMaxReqsInDeferred<countROM) |
|
3357 |
pagingdevice->iROMStats.iMaxReqsInDeferred=countROM; |
|
3358 |
else if ((pM->Flags() & TLocDrvRequest::ECodePaging) && pagingdevice->iCodeStats.iMaxReqsInDeferred<countCode) |
|
3359 |
pagingdevice->iCodeStats.iMaxReqsInDeferred=countCode; |
|
3360 |
else if ((pM->Flags() & TLocDrvRequest::EDataPaging) && pagingdevice->iDataStats.iMaxReqsInDeferred<countCode) |
|
3361 |
pagingdevice->iDataStats.iMaxReqsInDeferred=countCode; |
|
3362 |
NKern::FMSignal(&pagingdevice->iInstrumentationLock); |
|
3363 |
} |
|
3364 |
#endif |
|
3365 |
__KTRACE_OPT(KLOCDPAGING,Kern::Printf("RunDeferred: process req 0x%08x, last in deferred queue 0x%08x",pM,pL)); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3366 |
OstTraceDefExt2(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DPRIMARYMEDIABASE_RUNDEFERRED2, "process req=0x%08x; last in deferred queue=0x%08x",(TUint) pM, (TUint) pL); |
0 | 3367 |
#ifdef BTRACE_PAGING_MEDIA |
3368 |
BTraceContext8(BTrace::EPagingMedia,BTrace::EPagingMediaLocMedPageInDeferredReposted,pM,pM->iValue); |
|
3369 |
#endif |
|
3370 |
// if Page In requests are synchronous this services them all in sequence, |
|
3371 |
// if they're asynch it re-defers them |
|
3372 |
DoRequest(*(TLocDrvRequest*)pM); |
|
3373 |
} |
|
3374 |
pagingdevice->iEmptyingQ&= ~DMediaPagingDevice::EDeferredQ; |
|
3375 |
} |
|
3376 |
||
3377 |
// the reason we now try an empty the main Page In queue is there is at least one type of Page In request |
|
3378 |
// serviced synchronously in which case when we empty the deferred Page In queue as above, received Page In |
|
3379 |
// requests are left in the main queue (not deferred) and we don't want to start processing deferred normal |
|
3380 |
// requests before these Page In requests. If all deferred normal requests are synchronous, the received Page |
|
3381 |
// In requests will have to wait until all are serviced. NB: requests may be deferred even if the MD services |
|
3382 |
// all requests synchronously, but runs background tasks that cannot be interrupted. In this last case the |
|
3383 |
// normal deferred queue may have some very long latency requests. |
|
3384 |
if(pagingdevice->iEmptyingQ & DMediaPagingDevice::EMainQ) // already emptying main Page In queue, skip (any Page In requests will be deferred) |
|
3385 |
{ |
|
3386 |
__KTRACE_OPT(KLOCDPAGING,Kern::Printf("Already emptying main queue")); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3387 |
OstTrace0(TRACE_FLOW, DPRIMARYMEDIABASE_RUNDEFERRED_EXIT3, "< Already emptying main queue"); |
0 | 3388 |
return; |
3389 |
} |
|
3390 |
||
3391 |
TLocDrvRequest* pM=NULL; |
|
3392 |
if (!pagingdevice->iMainQ.iReady) // if it's ready, then queue is empty |
|
3393 |
{ |
|
3394 |
pM = (TLocDrvRequest*) pagingdevice->iMainQ.iMessage; |
|
3395 |
pagingdevice->iMainQ.iMessage = NULL; |
|
3396 |
if (pM == NULL) |
|
3397 |
pM = (TLocDrvRequest*) pagingdevice->iMainQ.Poll(); |
|
3398 |
} |
|
3399 |
||
3400 |
#ifdef __CONCURRENT_PAGING_INSTRUMENTATION__ |
|
3401 |
countROM = countCode=0; |
|
3402 |
#endif |
|
3403 |
if(pM) |
|
3404 |
{ |
|
3405 |
#ifdef __CONCURRENT_PAGING_INSTRUMENTATION__ |
|
3406 |
__e32_atomic_add_ord32(&pagingdevice->iROMStats.iTotalSynchEmptiedMainQ, 1); |
|
3407 |
#endif |
|
3408 |
pagingdevice->iEmptyingQ|=DMediaPagingDevice::EMainQ; |
|
3409 |
for ( ; pM != NULL; pM = (TLocDrvRequest*) pagingdevice->iMainQ.Poll()) |
|
3410 |
{ |
|
3411 |
__ASSERT_ALWAYS(DMediaPagingDevice::PagingRequest(*pM), LOCM_FAULT()); |
|
3412 |
||
3413 |
#ifdef __CONCURRENT_PAGING_INSTRUMENTATION__ |
|
3414 |
(pM->iValue==DMediaPagingDevice::ERomPageInRequest)?(countROM++):(countCode++); |
|
3415 |
#endif |
|
3416 |
||
3417 |
__KTRACE_OPT(KLOCDPAGING,Kern::Printf("RunDeferred: process req 0x%08x",pM)); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3418 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DPRIMARYMEDIABASE_RUNDEFERRED4, "process req=0x%08x", pM); |
0 | 3419 |
DoRequest(*(TLocDrvRequest*)pM); // if Page In requests are synchronous this services them all in sequence, if they're asynch it defers them |
3420 |
} |
|
3421 |
||
3422 |
pagingdevice->iEmptyingQ&= ~DMediaPagingDevice::EMainQ; |
|
3423 |
||
3424 |
||
3425 |
#ifdef __CONCURRENT_PAGING_INSTRUMENTATION__ |
|
3426 |
NKern::FMWait(&pagingdevice->iInstrumentationLock); |
|
3427 |
pagingdevice->iROMStats.iTotalSynchServicedFromMainQ+=countROM; |
|
3428 |
if(pagingdevice->iROMStats.iMaxReqsInPending<countROM) |
|
3429 |
pagingdevice->iROMStats.iMaxReqsInPending=countROM; |
|
3430 |
pagingdevice->iCodeStats.iTotalSynchServicedFromMainQ+=countCode; |
|
3431 |
if(pagingdevice->iCodeStats.iMaxReqsInPending<countCode) |
|
3432 |
pagingdevice->iCodeStats.iMaxReqsInPending=countCode; |
|
3433 |
NKern::FMSignal(&pagingdevice->iInstrumentationLock); |
|
3434 |
#endif |
|
3435 |
} // if (pM) |
|
3436 |
} // if(iPagingMedia) |
|
3437 |
#endif |
|
3438 |
if (iRunningDeferred) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3439 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3440 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_RUNDEFERRED_EXIT4, this ); |
0 | 3441 |
return; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3442 |
} |
0 | 3443 |
TMessageBase* pL = iDeferred.Last(); |
3444 |
if (!pL) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3445 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3446 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_RUNDEFERRED_EXIT5, this ); |
0 | 3447 |
return; // no deferred requests |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3448 |
} |
0 | 3449 |
iRunningDeferred=1; |
3450 |
TMessageBase* pM=NULL; |
|
3451 |
||
3452 |
while( pM != pL && (pM=iDeferred.Poll()) != NULL) // stop after processing last one (requests may be re-deferred) |
|
3453 |
DoRequest(*(TLocDrvRequest*)pM); |
|
3454 |
iRunningDeferred=0; |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3455 |
|
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3456 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_RUNDEFERRED_EXIT6, this ); |
0 | 3457 |
} |
3458 |
||
3459 |
void DPrimaryMediaBase::SetClosed(TInt anError) |
|
3460 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3461 |
OstTraceFunctionEntry1( DPRIMARYMEDIABASE_SETCLOSED_ENTRY, this ); |
0 | 3462 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase(%d)::SetClosed error %d",iMediaId,anError)); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3463 |
OstTraceExt2( TRACE_MEDIACHANGE, DPRIMARYMEDIABASE_SETCLOSED, "iMediaId=%d; anError=%d", iMediaId, anError ); |
0 | 3464 |
CHECK_RET(anError); |
3465 |
||
3466 |
// cancel DMediaDriver::OpenMediaDriverComplete() / DMediaDriver::PartitionInfoComplete() DFC |
|
3467 |
iAsyncDfc.Cancel(); |
|
3468 |
||
3469 |
iDeferred.CompleteAll(anError); |
|
3470 |
||
3471 |
#ifdef __DEMAND_PAGING__ |
|
3472 |
if(iPagingMedia) |
|
3473 |
iBody->iPagingDevice->iDeferredQ.CompleteAll(anError); |
|
3474 |
#endif |
|
3475 |
||
3476 |
CompleteCurrent(anError); |
|
3477 |
||
3478 |
||
3479 |
||
3480 |
if (iState==EOpening) |
|
3481 |
iPhysDevArray.Close(); |
|
3482 |
||
3483 |
iState = EClosed; |
|
3484 |
||
3485 |
iWaitMedChg.CompleteAll(KErrNone); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3486 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_SETCLOSED_EXIT, this ); |
0 | 3487 |
} |
3488 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3489 |
void DPrimaryMediaBase::NotifyClients(TNotifyType aNotifyType, TLocDrv* aLocDrv) |
0 | 3490 |
|
3491 |
// |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3492 |
// Notify all clients of a media change or media present event |
0 | 3493 |
// |
3494 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3495 |
OstTraceFunctionEntryExt( DPRIMARYMEDIABASE_NOTIFYCLIENTS_ENTRY, this ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3496 |
|
0 | 3497 |
SDblQueLink* pL=iConnectionQ.iA.iNext; |
3498 |
while (pL!=&iConnectionQ.iA) |
|
3499 |
{ |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3500 |
// Get pointer to TCallBackLink |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3501 |
TCallBackLink* pCallBackLink = _LOFF(pL,TCallBackLink,iLink); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3502 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3503 |
// The link is embedded in either a TLocDrv or a DLocalDrive object; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3504 |
// find out which one it is and then get TLocDrv pointer from that |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3505 |
__ASSERT_DEBUG(pCallBackLink->iObjectType == TCallBackLink::EDLocalDriveObject || pCallBackLink->iObjectType == TCallBackLink::ETLocDrvObject, LOCM_FAULT()); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3506 |
TLocDrv* locDrv; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3507 |
if (pCallBackLink->iObjectType == TCallBackLink::EDLocalDriveObject) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3508 |
locDrv = ((DLocalDrive*) _LOFF(pCallBackLink,DLocalDrive, iMediaChangeObserver))->iDrive; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3509 |
else |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3510 |
locDrv = ((TLocDrv*) _LOFF(pCallBackLink,TLocDrv, iMediaChangeObserver))->iNextDrive; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3511 |
|
0 | 3512 |
// Issue the notification if the caller wants to notify all drives (aLocDrv == NULL) or |
3513 |
// the specified drive matches this one |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3514 |
if (aLocDrv == NULL || aLocDrv == locDrv) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3515 |
pCallBackLink->CallBack(aNotifyType); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3516 |
|
0 | 3517 |
pL=pL->iNext; |
3518 |
} |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3519 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_NOTIFYCLIENTS_EXIT, this ); |
0 | 3520 |
} |
3521 |
||
3522 |
EXPORT_C void DPrimaryMediaBase::NotifyMediaChange() |
|
3523 |
/** |
|
3524 |
Closes all media drivers on this device and notifies all connections that media change has occurred |
|
3525 |
and completes any outstanding requests with KErrNotReady. |
|
3526 |
This also completes any force media change requests with KErrNone. |
|
3527 |
*/ |
|
3528 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3529 |
OstTraceFunctionEntry1( DPRIMARYMEDIABASE_NOTIFYMEDIACHANGE_ENTRY, this ); |
0 | 3530 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase(%d)::NotifyMediaChange state %d",iMediaId,iState)); |
3531 |
||
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3532 |
OstTraceDefExt2( OST_TRACE_CATEGORY_RND, TRACE_MEDIACHANGE, DPRIMARYMEDIABASE_NOTIFYMEDIACHANGE, "iMediaId=%d; iState=%d", iMediaId, iState ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3533 |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3534 |
// This should only be called in the context of the media thread |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3535 |
__ASSERT_ALWAYS(NKern::CurrentThread() == iDfcQ->iThread, LOCM_FAULT()); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3536 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3537 |
MediaChange(); |
0 | 3538 |
|
3539 |
// notify all connections that media change has occurred |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3540 |
NotifyClients(EMediaChange); |
0 | 3541 |
|
3542 |
// complete any force media change requests |
|
3543 |
iWaitMedChg.CompleteAll(KErrNone); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3544 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_NOTIFYMEDIACHANGE_EXIT, this ); |
0 | 3545 |
} |
3546 |
||
3547 |
||
3548 |
EXPORT_C void DPrimaryMediaBase::NotifyPowerDown() |
|
3549 |
/** |
|
3550 |
Called on machine power-down. Notifies all media drivers on this device. |
|
3551 |
If device is not ready then it completes current requests but leaves other outstanding requests |
|
3552 |
If ready, media driver should complete current request. |
|
3553 |
||
3554 |
*/ |
|
3555 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3556 |
OstTraceFunctionEntry1( DPRIMARYMEDIABASE_NOTIFYPOWERDOWN_ENTRY, this ); |
0 | 3557 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase(%d)::NotifyPowerDown state %d",iMediaId,iState)); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3558 |
|
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3559 |
OstTraceExt2( TRACE_INTERNALS, DPRIMARYMEDIABASE_NOTIFYPOWERDOWN, "iMediaId=%d; iState=%d", iMediaId, iState ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3560 |
|
0 | 3561 |
TInt id; |
3562 |
TBool allPersistent = ETrue; |
|
3563 |
TBool allOpen = ETrue; |
|
3564 |
||
3565 |
// notify all media drivers on this device |
|
3566 |
for (id=iMediaId; id<=iLastMediaId; id++) |
|
3567 |
{ |
|
3568 |
DMedia* pM = TheMedia[id]; |
|
3569 |
DMediaDriver* pD = pM->iDriver; |
|
3570 |
||
3571 |
if ((pD) && (iState==EReady || iState==EReadPartitionInfo || iState==EOpening || iState==EPoweringUp2 || iState==ERecovering)) |
|
3572 |
pD->NotifyPowerDown(); |
|
3573 |
||
3574 |
if (pD == NULL || pD->iPhysicalDevice == NULL) |
|
3575 |
allOpen = EFalse; |
|
3576 |
else if (pD->iPhysicalDevice->Info(DPhysicalDevice::EMediaDriverPersistent, NULL) != KErrNone) |
|
3577 |
{ |
|
3578 |
// We must NOT destroy the media driver if this media is responsible for data paging as |
|
3579 |
// re-opening the media driver would involve memory allocation which might cause a deadlock |
|
3580 |
#ifdef __DEMAND_PAGING__ |
|
3581 |
__ASSERT_ALWAYS(!DataPagingDfcQ(this), LOCM_FAULT()); |
|
3582 |
#endif |
|
3583 |
allPersistent = EFalse; |
|
3584 |
} |
|
3585 |
} |
|
3586 |
||
3587 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("allPersistent(%d)::allOpen %d",allPersistent, allOpen)); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3588 |
OstTraceExt2( TRACE_INTERNALS, DPRIMARYMEDIABASE_NOTIFYPOWERDOWN2, "allPersistent=%d; allOpen=%d", allPersistent, allOpen ); |
0 | 3589 |
|
3590 |
if (allPersistent && allOpen && iState == EReady) |
|
3591 |
{ |
|
3592 |
// |
|
3593 |
// The EPoweredDown state indicates that the media is powered down, but the media driver still exists. |
|
3594 |
// |
|
3595 |
// - This allows the media driver to still be accessed (ie - to determine driver capabilities) without |
|
3596 |
// the need to power up the device, which can be a lengthy operation. |
|
3597 |
// |
|
3598 |
// - NOTE : This will need re-visiting if we ever re-enable standby mode on a platform that is not capable |
|
3599 |
// of detecting door interrupts while in standby. In such a scenario, problems could occur as |
|
3600 |
// the device capabilities may change without the local media subsystem recognising. |
|
3601 |
// |
|
3602 |
iState=EPoweredDown; |
|
3603 |
} |
|
3604 |
else |
|
3605 |
{ |
|
3606 |
CloseMediaDrivers(); |
|
3607 |
SetClosed(KErrNotReady); |
|
3608 |
} |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3609 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_NOTIFYPOWERDOWN_EXIT, this ); |
0 | 3610 |
} |
3611 |
||
3612 |
||
3613 |
EXPORT_C void DPrimaryMediaBase::NotifyPsuFault(TInt anError) |
|
3614 |
/** |
|
3615 |
Closes all media drivers on this device and completes any outstanding requests with error code. |
|
3616 |
@param anError Error code to be passed on while closing media drivers and completing outstanding requests. |
|
3617 |
*/ |
|
3618 |
||
3619 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3620 |
OstTraceFunctionEntry1( DPRIMARYMEDIABASE_NOTIFYPSUFAULT_ENTRY, this ); |
0 | 3621 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase(%d)::NotifyPsuFault state %d, err %d",iMediaId,iState,anError)); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3622 |
OstTraceExt3( TRACE_INTERNALS, DPRIMARYMEDIABASE_NOTIFYPSUFAULT, "iMediaId=%d; iState=%d; anError=%d", iMediaId, iState, anError ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3623 |
|
0 | 3624 |
if (iState>=EOpening) |
3625 |
{ |
|
3626 |
CloseMediaDrivers(); |
|
3627 |
} |
|
3628 |
||
3629 |
// complete any outstanding requests with error |
|
3630 |
SetClosed(anError); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3631 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_NOTIFYPSUFAULT_EXIT, this ); |
0 | 3632 |
} |
3633 |
||
3634 |
EXPORT_C void DPrimaryMediaBase::NotifyEmergencyPowerDown() |
|
3635 |
/** |
|
3636 |
Called on emergency power down. Notifies all media drivers on this device. |
|
3637 |
If it is not in a ready state then it completes the current request but leaves other outstanding requests. |
|
3638 |
If it is ready then the media driver should complete the current request. |
|
3639 |
It closes all media drivers and notifies all clients of a power down event. |
|
3640 |
*/ |
|
3641 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3642 |
OstTraceFunctionEntry1( DPRIMARYMEDIABASE_NOTIFYEMERGENCYPOWERDOWN_ENTRY, this ); |
0 | 3643 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase(%d)::NotifyEmergencyPowerDown state %d",iMediaId,iState)); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3644 |
OstTraceExt2( TRACE_INTERNALS, DPRIMARYMEDIABASE_NOTIFYEMERGENCYPOWERDOWN, "iMediaId=%d; iState=%d", iMediaId, iState ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3645 |
|
0 | 3646 |
TBool recover=EFalse; |
3647 |
if (iState==EReady && iCritical!=0) |
|
3648 |
{ |
|
3649 |
// check if emergency power recovery supported |
|
3650 |
; |
|
3651 |
} |
|
3652 |
if (recover) |
|
3653 |
{ |
|
3654 |
} |
|
3655 |
||
3656 |
// else just return KErrAbort |
|
3657 |
// notify all media drivers on this device |
|
3658 |
if (iState==EReady || iState==EOpening || iState==EPoweringUp2 || iState==ERecovering) |
|
3659 |
{ |
|
3660 |
TInt id; |
|
3661 |
for (id=iMediaId; id<=iLastMediaId; id++) |
|
3662 |
{ |
|
3663 |
DMedia* pM=TheMedia[id]; |
|
3664 |
DMediaDriver* pD=pM->iDriver; |
|
3665 |
if (pD) |
|
3666 |
pD->NotifyEmergencyPowerDown(); |
|
3667 |
} |
|
3668 |
} |
|
3669 |
||
3670 |
if (iState!=EReady) |
|
3671 |
{ |
|
3672 |
// complete current request but leave other outstanding requests |
|
3673 |
// if ready, media driver should complete current request |
|
3674 |
CompleteCurrent(KErrNotReady); |
|
3675 |
} |
|
3676 |
CloseMediaDrivers(); |
|
3677 |
SetClosed(KErrNotReady); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3678 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_NOTIFYEMERGENCYPOWERDOWN_EXIT, this ); |
0 | 3679 |
} |
3680 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3681 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3682 |
/** |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3683 |
Called by NotifyMediaPresent() and NotifyMediaChange() to ensure the media is in the correct state |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3684 |
*/ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3685 |
void DPrimaryMediaBase::MediaChange() |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3686 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3687 |
// Media has been inserted, so we need to cancel any outstanding requests and |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3688 |
// ensure that the partition info is read again |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3689 |
TInt state = iState; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3690 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3691 |
__ASSERT_DEBUG(iBody, LOCM_FAULT()); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3692 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3693 |
#ifdef __DEMAND_PAGING__ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3694 |
iBody->iMediaChanges++; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3695 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3696 |
// As data paging media never close, need to ensure the media driver cancels |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3697 |
// any requests it owns as the stack may be powered down by DPBusPrimaryMedia::ForceMediaChange(). |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3698 |
// DMediaDriver::NotifyPowerDown() should do this |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3699 |
if (DataPagingMedia(this)) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3700 |
NotifyPowerDown(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3701 |
#endif |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3702 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3703 |
// complete any outstanding requests with KErrNotReady |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3704 |
// and any force media change requests with KErrNone |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3705 |
SetClosed(KErrNotReady); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3706 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3707 |
// close all media drivers on this device |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3708 |
if (state>=EOpening) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3709 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3710 |
CloseMediaDrivers(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3711 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3712 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3713 |
|
0 | 3714 |
EXPORT_C void DPrimaryMediaBase::NotifyMediaPresent() |
3715 |
/** |
|
3716 |
Notifies clients of a media change by calling NotifyClients ( ) function to indicate that media is present. |
|
3717 |
*/ |
|
3718 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3719 |
OstTraceFunctionEntry1( DPRIMARYMEDIABASE_NOTIFYMEDIAPRESENT_ENTRY, this ); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3720 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase(%d)::NotifyMediaPresent state %d",iMediaId,iState)); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3721 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3722 |
// This should only be called in the context of the media thread |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3723 |
__ASSERT_ALWAYS(NKern::CurrentThread() == iDfcQ->iThread, LOCM_FAULT()); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3724 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3725 |
MediaChange(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3726 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3727 |
NotifyClients(EMediaPresent); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3728 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_NOTIFYMEDIAPRESENT_EXIT, this ); |
0 | 3729 |
} |
3730 |
||
3731 |
EXPORT_C TInt DPrimaryMediaBase::DoInCritical() |
|
3732 |
/** |
|
3733 |
Flags the media driver as entering a critical part of its processing. |
|
3734 |
||
3735 |
In this context, critical means that the driver must be allowed to complete |
|
3736 |
its current activity. |
|
3737 |
For example, a request to power down the device must be deferred until |
|
3738 |
the driver exits the critical part. |
|
3739 |
||
3740 |
@return KErrNone, if the driver has been successfully flagged as being in |
|
3741 |
a critical part; otherwise, one of the other system-wide error codes. |
|
3742 |
The default implementation just returns KErrNone and can be overridden in the derived class |
|
3743 |
@see DPrimaryMediaBase::DoEndInCritical() |
|
3744 |
*/ |
|
3745 |
||
3746 |
{ |
|
3747 |
return KErrNone; |
|
3748 |
} |
|
3749 |
||
3750 |
EXPORT_C void DPrimaryMediaBase::DoEndInCritical() |
|
3751 |
/** |
|
3752 |
Flags the media driver as leaving a critical part of its processing. |
|
3753 |
||
3754 |
Default implementation does nothing |
|
3755 |
@see DPrimaryMediaBase::DoEndInCritical() |
|
3756 |
*/ |
|
3757 |
{ |
|
3758 |
} |
|
3759 |
||
3760 |
TInt DPrimaryMediaBase::InCritical() |
|
3761 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3762 |
OstTraceFunctionEntry1( DPRIMARYMEDIABASE_INCRITICAL_ENTRY, this ); |
0 | 3763 |
if (iCritical==0) |
3764 |
{ |
|
3765 |
TInt r=DoInCritical(); |
|
3766 |
if (r!=KErrNone) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3767 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3768 |
OstTraceFunctionExitExt( DPRIMARYMEDIABASE_INCRITICAL_EXIT1, this, r ); |
0 | 3769 |
return r; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3770 |
} |
0 | 3771 |
} |
3772 |
++iCritical; |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3773 |
OstTraceFunctionExitExt( DPRIMARYMEDIABASE_INCRITICAL_EXIT2, this, KErrNone ); |
0 | 3774 |
return KErrNone; |
3775 |
} |
|
3776 |
||
3777 |
void DPrimaryMediaBase::EndInCritical() |
|
3778 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3779 |
OstTraceFunctionEntry1( DPRIMARYMEDIABASE_ENDINCRITICAL_ENTRY, this ); |
0 | 3780 |
if (--iCritical==0) |
3781 |
DoEndInCritical(); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3782 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_ENDINCRITICAL_EXIT, this ); |
0 | 3783 |
} |
3784 |
||
3785 |
EXPORT_C void DPrimaryMediaBase::DeltaCurrentConsumption(TInt /*aCurrent*/) |
|
3786 |
/** |
|
3787 |
Sets the incremental value of current consumption to aCurrent. |
|
3788 |
The default implementation does nothing . |
|
3789 |
||
3790 |
@param aCurrent Delta Current in Milliamps |
|
3791 |
*/ |
|
3792 |
{ |
|
3793 |
// default implementation |
|
3794 |
} |
|
3795 |
||
3796 |
TInt DPrimaryMediaBase::OpenMediaDriver() |
|
3797 |
// |
|
3798 |
// Synchronous open for devices with no DFC queue (e.g. IRAM) |
|
3799 |
// |
|
3800 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3801 |
OstTraceFunctionEntry1( DPRIMARYMEDIABASE_OPENMEDIADRIVER_ENTRY, this ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3802 |
|
0 | 3803 |
__KTRACE_OPT(KLOCDRV,Kern::Printf(">DPrimaryMediaBase:OpenMediaDriver-%d",iMediaId)); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3804 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_MEDIACHANGE, DPRIMARYMEDIABASE_OPENMEDIADRIVER1, "iMediaId=%d", iMediaId); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3805 |
|
0 | 3806 |
TVersion ver(KMediaDriverInterfaceMajorVersion,KMediaDriverInterfaceMinorVersion,KMediaDriverInterfaceBuildVersion); |
3807 |
||
3808 |
// Get a list of all currently loaded media drivers |
|
3809 |
// Most media drivers do not make use of the pointer iMountInfo.iInfo when |
|
3810 |
// their Validate() procedures are called from RPhysicalDeviceArray::GetDriverList(). |
|
3811 |
// However, a group of media drivers sharing the same id (passed in iDevice) may use |
|
3812 |
// the additional information pointed to by iMountInfo.iInfo to distinguish |
|
3813 |
// group members. This information is passed when the media driver is registered |
|
3814 |
// using LocDrv::RegisterMediaDevice(). |
|
3815 |
TInt r=iPhysDevArray.GetDriverList(KLitMediaDriverName,iDevice,iMountInfo.iInfo,ver); |
|
3816 |
if (r!=KErrNone) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3817 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3818 |
OstTraceFunctionExitExt( DPRIMARYMEDIABASE_OPENMEDIADRIVER_EXIT1, this, r ); |
0 | 3819 |
return r; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3820 |
} |
0 | 3821 |
// Go through them starting with highest priority |
3822 |
TInt totalPartitions=0; |
|
3823 |
TInt c=iPhysDevArray.Count(); // can't be zero |
|
3824 |
TInt i=c-1; |
|
3825 |
r=KErrNotSupported; |
|
3826 |
for (iNextMediaId=iMediaId; i>=0 && iNextMediaId<=iLastMediaId && r!=KErrNotReady; i--) |
|
3827 |
{ |
|
3828 |
DPhysicalDevice* pD=iPhysDevArray[i].iPhysicalDevice; |
|
3829 |
DMediaDriver *pM=NULL; |
|
3830 |
||
3831 |
// try to open media driver |
|
3832 |
TInt s=pD->Create( (DBase*&)pM, iMediaId, NULL, ver); |
|
3833 |
||
3834 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("Media:Open-Opening %o(PRI:%d)-%d",pD,iPhysDevArray[i].iPriority,s)); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3835 |
OstTraceDefExt3(OST_TRACE_CATEGORY_RND, TRACE_MEDIACHANGE, DPRIMARYMEDIABASE_OPENMEDIADRIVER2, "Media:Open-Opening 0x%x iPriority=%d; retval=%d", (TUint) pD, (TUint) iPhysDevArray[i].iPriority, (TUint) s); |
0 | 3836 |
if (s!=KErrNone && pM) |
3837 |
{ |
|
3838 |
pM->Close(); |
|
3839 |
pM=NULL; |
|
3840 |
} |
|
3841 |
if (s==KErrNotReady) |
|
3842 |
{ |
|
3843 |
r=KErrNotReady; // If it isn't ready - nothing will open. |
|
3844 |
break; |
|
3845 |
} |
|
3846 |
if (s==KErrNoMemory) |
|
3847 |
{ |
|
3848 |
r=KErrNoMemory; // If we are out of memory, give up now |
|
3849 |
break; |
|
3850 |
} |
|
3851 |
if (s==KErrNone) |
|
3852 |
{ |
|
3853 |
// Found a media driver for this device - check for valid partitions. |
|
3854 |
DMedia* media=TheMedia[iNextMediaId]; |
|
3855 |
s=pM->PartitionInfo(media->iPartitionInfo); |
|
3856 |
if (s==KErrNone) |
|
3857 |
{ |
|
3858 |
r=KErrNone; |
|
3859 |
media->iDriver=pM; |
|
3860 |
pM->iPhysicalDevice=pD; |
|
3861 |
iPhysDevArray[i].iPhysicalDevice=NULL; // so it won't be closed when we tidy up |
|
3862 |
totalPartitions+=media->PartitionCount(); |
|
3863 |
} |
|
3864 |
else |
|
3865 |
pM->Close(); |
|
3866 |
} |
|
3867 |
} |
|
3868 |
||
3869 |
// we are now finished with media driver list |
|
3870 |
iPhysDevArray.Close(); |
|
3871 |
||
3872 |
// if driver opened OK, work out mapping of drives to partitions/media |
|
3873 |
if (r==KErrNone) |
|
3874 |
{ |
|
3875 |
TInt id=iMediaId; // start with primary media |
|
3876 |
TInt partitionsOnThisMedia=PartitionCount(); |
|
3877 |
TInt partition=0; |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3878 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3879 |
TDriveIterator driveIter; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3880 |
for (TLocDrv* pD = driveIter.NextDrive(); pD != NULL; pD = driveIter.NextDrive()) |
0 | 3881 |
{ |
3882 |
if (pD && pD->iPrimaryMedia==this) |
|
3883 |
{ |
|
3884 |
if (totalPartitions==0) |
|
3885 |
{ |
|
3886 |
pD->iMedia=NULL; |
|
3887 |
continue; |
|
3888 |
} |
|
3889 |
if (partition==partitionsOnThisMedia) |
|
3890 |
{ |
|
3891 |
id++; |
|
3892 |
partition=0; |
|
3893 |
partitionsOnThisMedia=TheMedia[id]->PartitionCount(); |
|
3894 |
} |
|
3895 |
pD->iMedia=TheMedia[id]; |
|
3896 |
pD->iPartitionNumber=partition; |
|
3897 |
memcpy(pD, pD->iMedia->iPartitionInfo.iEntry+partition, sizeof(TPartitionEntry)); |
|
3898 |
partition++; |
|
3899 |
totalPartitions--; |
|
3900 |
} |
|
3901 |
} |
|
3902 |
} |
|
3903 |
||
3904 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("<DPrimaryMediaBase:OpenMediaDriver-%d",r)); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3905 |
OstTraceFunctionExitExt( DPRIMARYMEDIABASE_OPENMEDIADRIVER_EXIT2, this, r ); |
0 | 3906 |
return r; |
3907 |
} |
|
3908 |
||
3909 |
#ifdef __DEMAND_PAGING__ |
|
3910 |
// RequestCountInc() |
|
3911 |
// |
|
3912 |
// Counts the number of outstanding requests |
|
3913 |
// For data-paging media, calls DPagingDevice::NotifyBusy() when count goes positive |
|
3914 |
// |
|
3915 |
void DPrimaryMediaBase::RequestCountInc() |
|
3916 |
{ |
|
3917 |
__ASSERT_DEBUG(iBody, LOCM_FAULT()); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
3918 |
if (iBody->iPagingDevice) |
0 | 3919 |
{ |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
3920 |
NFastMutex* lock = iBody->iPagingDevice->NotificationLock(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
3921 |
NKern::FMWait(lock); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
3922 |
TInt oldVal = iBody->iRequestCount++; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
3923 |
//Kern::Printf("RCINC: this %x cnt %d, old %d", this, iBody->iRequestCount, oldVal); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
3924 |
OstTraceDefExt2( OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DPRIMARYMEDIABASE_REQUESTCOUNTINC, "new count=%d; old count=%d", iBody->iRequestCount, oldVal ); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
3925 |
if (oldVal == 0) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
3926 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
3927 |
//Kern::Printf("RCINC: NotifyBusy()"); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
3928 |
iBody->iPagingDevice->NotifyBusy(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
3929 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
3930 |
NKern::FMSignal(lock); |
0 | 3931 |
} |
3932 |
} |
|
3933 |
||
3934 |
// RequestCountDec() |
|
3935 |
// |
|
3936 |
// Counts the number of outstanding requests |
|
3937 |
// For data-paging media, calls DPagingDevice::NotifyIdle() when count reaches zero |
|
3938 |
// |
|
3939 |
void DPrimaryMediaBase::RequestCountDec() |
|
3940 |
{ |
|
3941 |
__ASSERT_DEBUG(iBody, LOCM_FAULT()); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
3942 |
if (iBody->iPagingDevice) |
0 | 3943 |
{ |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
3944 |
NFastMutex* lock = iBody->iPagingDevice->NotificationLock(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
3945 |
NKern::FMWait(lock); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
3946 |
TInt oldVal = iBody->iRequestCount--; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
3947 |
//Kern::Printf("RCDEC: this %x cnt %d, old %d", this, iBody->iRequestCount, oldVal); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
3948 |
OstTraceDefExt2( OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DPRIMARYMEDIABASE_REQUESTCOUNTDEC, "new count=%d; old count=%d", iBody->iRequestCount, oldVal ); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
3949 |
if (oldVal == 1) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
3950 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
3951 |
//Kern::Printf("RCDEC: NotifyIdle()"); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
3952 |
iBody->iPagingDevice->NotifyIdle(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
3953 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
3954 |
NKern::FMSignal(lock); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
3955 |
__ASSERT_DEBUG(iBody->iRequestCount >= 0, LOCM_FAULT()); |
0 | 3956 |
} |
3957 |
} |
|
3958 |
#endif // __DEMAND_PAGING__ |
|
3959 |
||
3960 |
TPartitionInfo::TPartitionInfo() |
|
3961 |
// |
|
3962 |
// Constructor |
|
3963 |
// |
|
3964 |
{ |
|
3965 |
memclr(this, sizeof(TPartitionInfo)); |
|
3966 |
} |
|
3967 |
||
3968 |
#ifdef __DEMAND_PAGING__ |
|
3969 |
||
3970 |
void pageInDfc(TAny* aPtr) |
|
3971 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3972 |
OstTraceFunctionEntry0( _PAGEINDFC_ENTRY ); |
0 | 3973 |
__KTRACE_OPT2(KLOCDRV,KLOCDPAGING,Kern::Printf("pageInDfc")); |
3974 |
DPrimaryMediaBase* primaryMedia=(DPrimaryMediaBase*)aPtr; |
|
3975 |
__ASSERT_ALWAYS(primaryMedia && primaryMedia->iPagingMedia && primaryMedia->iBody->iPagingDevice,LOCM_FAULT()); |
|
3976 |
DMediaPagingDevice* pagingdevice=primaryMedia->iBody->iPagingDevice; |
|
3977 |
||
3978 |
TLocDrvRequest* m = (TLocDrvRequest*) pagingdevice->iMainQ.iMessage; |
|
3979 |
pagingdevice->iMainQ.iMessage = NULL; |
|
3980 |
||
3981 |
#ifdef __CONCURRENT_PAGING_INSTRUMENTATION__ |
|
3982 |
if (!m) |
|
3983 |
__e32_atomic_add_ord8(&pagingdevice->iROMStats.iTotalRunDry, 1); |
|
3984 |
#endif |
|
3985 |
||
3986 |
#ifdef __CONCURRENT_PAGING_INSTRUMENTATION__ |
|
3987 |
TInt countROM=0; |
|
3988 |
TInt countCode=0; |
|
3989 |
#endif |
|
3990 |
||
3991 |
for ( ; m != NULL; m = (TLocDrvRequest*) pagingdevice->iMainQ.Poll()) |
|
3992 |
{ |
|
3993 |
__ASSERT_ALWAYS(DMediaPagingDevice::PagingRequest(*m), LOCM_FAULT()); |
|
3994 |
||
3995 |
#ifdef __CONCURRENT_PAGING_INSTRUMENTATION__ |
|
3996 |
(m->iValue == DMediaPagingDevice::ERomPageInRequest)?(countROM++):(countCode++); |
|
3997 |
#endif |
|
3998 |
__KTRACE_OPT(KLOCDPAGING, Kern::Printf("pageInDfc: process request 0x%08x, last in queue 0x%08x",m, pagingdevice->iMainQ.Last()) ); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3999 |
OstTraceDefExt2(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, PAGEINDFC2, "process request=0x%08x; last in queue=0x%08x",(TUint) m, (TUint) pagingdevice->iMainQ.Last()); |
0 | 4000 |
|
4001 |
primaryMedia->HandleMsg(*m); |
|
4002 |
} |
|
4003 |
||
4004 |
#ifdef __CONCURRENT_PAGING_INSTRUMENTATION__ |
|
4005 |
NKern::FMWait(&pagingdevice->iInstrumentationLock); |
|
4006 |
if (pagingdevice->iROMStats.iMaxReqsInPending<countROM) |
|
4007 |
pagingdevice->iROMStats.iMaxReqsInPending=countROM; |
|
4008 |
if (pagingdevice->iCodeStats.iMaxReqsInPending<countCode) |
|
4009 |
pagingdevice->iCodeStats.iMaxReqsInPending=countCode; |
|
4010 |
NKern::FMSignal(&pagingdevice->iInstrumentationLock); |
|
4011 |
#endif |
|
4012 |
||
4013 |
pagingdevice->iMainQ.Receive(); // allow reception of more messages |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4014 |
OstTraceFunctionExit0( _PAGEINDFC_EXIT ); |
0 | 4015 |
} |
4016 |
||
4017 |
DMediaPagingDevice::DMediaPagingDevice(DPrimaryMediaBase* aPtr) |
|
4018 |
: iMainQ(pageInDfc, aPtr, NULL, KMaxDfcPriority), |
|
4019 |
iDeferredQ(NULL, NULL, NULL, 0), // callback never used |
|
4020 |
iEmptyingQ(NULL), |
|
4021 |
iInstrumentationLock() |
|
4022 |
#ifdef __CONCURRENT_PAGING_INSTRUMENTATION__ |
|
4023 |
,iServicingROM(NULL), iServicingCode(NULL) |
|
4024 |
#endif |
|
4025 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4026 |
OstTraceFunctionEntry1( DMEDIAPAGINGDEVICE_DMEDIAPAGINGDEVICE_CONSTRUCTOR_ENTRY, this ); |
0 | 4027 |
iPrimaryMedia = aPtr; |
4028 |
if (iPrimaryMedia->iDfcQ) // media driver has its own thread |
|
4029 |
{ |
|
4030 |
iMainQ.SetDfcQ(iPrimaryMedia->iDfcQ); |
|
4031 |
} |
|
4032 |
#ifdef __CONCURRENT_PAGING_INSTRUMENTATION__ |
|
4033 |
memclr((TAny*)&iROMStats,sizeof(SMediaROMPagingConcurrencyInfo)+sizeof(SMediaCodePagingConcurrencyInfo)); |
|
4034 |
#endif |
|
4035 |
#ifdef __DEMAND_PAGING_BENCHMARKS__ |
|
4036 |
iROMBenchmarkData.iCount=iROMBenchmarkData.iTotalTime=iROMBenchmarkData.iMaxTime=0; |
|
4037 |
iROMBenchmarkData.iMinTime = KMaxTInt; |
|
4038 |
iCodeBenchmarkData.iCount=iCodeBenchmarkData.iTotalTime=iCodeBenchmarkData.iMaxTime=0; |
|
4039 |
iCodeBenchmarkData.iMinTime = KMaxTInt; |
|
4040 |
iDataInBenchmarkData.iCount=iDataInBenchmarkData.iTotalTime=iDataInBenchmarkData.iMaxTime=0; |
|
4041 |
iDataInBenchmarkData.iMinTime = KMaxTInt; |
|
4042 |
iDataOutBenchmarkData.iCount=iDataOutBenchmarkData.iTotalTime=iDataOutBenchmarkData.iMaxTime=0; |
|
4043 |
iDataOutBenchmarkData.iMinTime = KMaxTInt; |
|
4044 |
#endif |
|
4045 |
||
4046 |
iMainQ.Receive(); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4047 |
OstTraceFunctionExit1( DMEDIAPAGINGDEVICE_DMEDIAPAGINGDEVICE_CONSTRUCTOR_EXIT, this ); |
0 | 4048 |
} |
4049 |
||
4050 |
DMediaPagingDevice::~DMediaPagingDevice() |
|
4051 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4052 |
OstTraceFunctionEntry1( DMEDIAPAGINGDEVICE_DMEDIAPAGINGDEVICE_DESTRUCTOR_ENTRY, this ); |
0 | 4053 |
|
4054 |
if (iMountInfoDataLock) |
|
4055 |
ThePinObjectAllocator->ReleasePinObject((DPinObjectAllocator::SVirtualPinContainer*) iMountInfoDataLock); |
|
4056 |
||
4057 |
if (iMountInfoDescHdrLock) |
|
4058 |
ThePinObjectAllocator->ReleasePinObject((DPinObjectAllocator::SVirtualPinContainer*) iMountInfoDescHdrLock); |
|
4059 |
||
4060 |
if (iMountInfoDescLenLock) |
|
4061 |
ThePinObjectAllocator->ReleasePinObject((DPinObjectAllocator::SVirtualPinContainer*) iMountInfoDescLenLock); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4062 |
OstTraceFunctionExit1( DMEDIAPAGINGDEVICE_DMEDIAPAGINGDEVICE_DESTRUCTOR_EXIT, this ); |
0 | 4063 |
} |
4064 |
||
4065 |
||
4066 |
void DMediaPagingDevice::SendToMainQueueDfcAndBlock(TThreadMessage* aMsg) |
|
4067 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4068 |
OstTraceFunctionEntryExt( DMEDIAPAGINGDEVICE_SENDTOMAINQUEUEDFCANDBLOCK_ENTRY, this ); |
0 | 4069 |
__KTRACE_OPT2(KLOCDRV,KLOCDPAGING,Kern::Printf("Send request 0x%08x to main queue",aMsg)); |
4070 |
__ASSERT_ALWAYS(aMsg->iState==TMessageBase::EFree,LOCM_FAULT()); // check that message was previously completed or never queued |
|
4071 |
||
4072 |
// if drive supports DMA, turn on Physical memory flag & sync memory |
|
4073 |
TLocDrvRequest& m=*(TLocDrvRequest*)(aMsg); |
|
4074 |
||
4075 |
TLinAddr addr = (TLinAddr) m.RemoteDes(); |
|
4076 |
TInt len = I64LOW(m.Length()); |
|
4077 |
||
4078 |
TBool needSyncAfterRead = EFalse; |
|
201
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4079 |
if (m.Drive()->iDmaHelper) |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4080 |
{ |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4081 |
m.Flags() |= TLocDrvRequest::EPhysAddr; |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4082 |
// don't cache sync for zero mapping... |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4083 |
if (!(m.Flags() & TLocDrvRequest::EPhysAddrOnly)) |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4084 |
{ |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4085 |
if (m.Id() == DLocalDrive::EWrite) |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4086 |
{ |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4087 |
Cache::SyncMemoryBeforeDmaWrite(addr, len); |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4088 |
} |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4089 |
else |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4090 |
{ |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4091 |
Cache::SyncMemoryBeforeDmaRead(addr, len); |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4092 |
needSyncAfterRead = ETrue; |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4093 |
} |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4094 |
} |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4095 |
} |
0 | 4096 |
|
4097 |
// Count the number of outstanding requests if this is the data-paging media, so that |
|
4098 |
// we can call DPagingDevice::NotifyBusy() / DPagingDevice::NotifyIdle() |
|
4099 |
if ((m.Flags() & TLocDrvRequest::EBackgroundPaging) == 0) |
|
4100 |
iPrimaryMedia->RequestCountInc(); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4101 |
|
0 | 4102 |
aMsg->SendReceive(&iMainQ); |
4103 |
||
4104 |
#ifdef __DEMAND_PAGING__ |
|
4105 |
if ((m.Flags() & TLocDrvRequest::EBackgroundPaging) == 0) |
|
4106 |
iPrimaryMedia->RequestCountDec(); |
|
4107 |
#endif |
|
4108 |
||
4109 |
if (needSyncAfterRead) |
|
4110 |
{ |
|
4111 |
Cache::SyncMemoryAfterDmaRead(addr, len); |
|
4112 |
} |
|
4113 |
||
4114 |
||
4115 |
// come back here when request is completed |
|
4116 |
__ASSERT_DEBUG(aMsg->iState==TMessageBase::EFree,LOCM_FAULT()); // check message has been completed |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4117 |
OstTraceFunctionExit1( DMEDIAPAGINGDEVICE_SENDTOMAINQUEUEDFCANDBLOCK_EXIT, this ); |
0 | 4118 |
} |
4119 |
||
4120 |
void DMediaPagingDevice::SendToDeferredQ(TThreadMessage* aMsg) |
|
4121 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4122 |
OstTraceFunctionEntryExt( DMEDIAPAGINGDEVICE_SENDTODEFERREDQ_ENTRY, this ); |
0 | 4123 |
// This queue is only accessed from MD thread |
4124 |
__ASSERT_ALWAYS(aMsg->iState==TMessageBase::EAccepted,LOCM_FAULT()); // check that message was previously dequeued |
|
4125 |
#ifdef BTRACE_PAGING_MEDIA |
|
4126 |
if(iEmptyingQ&DMediaPagingDevice::EDeferredQ) // already deferring |
|
4127 |
BTraceContext8(BTrace::EPagingMedia,BTrace::EPagingMediaLocMedPageInReDeferred,aMsg,aMsg->iValue); |
|
4128 |
else |
|
4129 |
BTraceContext8(BTrace::EPagingMedia,BTrace::EPagingMediaLocMedPageInDeferred,aMsg,aMsg->iValue); |
|
4130 |
#endif |
|
4131 |
||
4132 |
aMsg->Forward(&iDeferredQ, EFalse); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4133 |
OstTraceFunctionExit1( DMEDIAPAGINGDEVICE_SENDTODEFERREDQ_EXIT, this ); |
0 | 4134 |
} |
4135 |
||
4136 |
||
4137 |
void DMediaPagingDevice::CompleteRequest(TThreadMessage* aMsg, TInt aResult) |
|
4138 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4139 |
OstTraceFunctionEntryExt( DMEDIAPAGINGDEVICE_COMPLETEREQUEST_ENTRY, this ); |
0 | 4140 |
__KTRACE_OPT2(KLOCDRV,KLOCDPAGING,Kern::Printf("DMediaPagingDevice::CompleteRequest, request 0x%08x result %d", aMsg, aResult)); |
4141 |
__ASSERT_DEBUG(aMsg->iState==TMessageBase::EAccepted,LOCM_FAULT()); |
|
4142 |
||
4143 |
#ifdef BTRACE_PAGING_MEDIA |
|
4144 |
BTraceContext12(BTrace::EPagingMedia,BTrace::EPagingMediaLocMedPageInPagedIn,aMsg,aResult,aMsg->iValue); |
|
4145 |
#endif |
|
4146 |
||
4147 |
iPrimaryMedia->CompleteRequest(*((TLocDrvRequest*) aMsg), aResult); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4148 |
OstTraceFunctionExit1( DMEDIAPAGINGDEVICE_COMPLETEREQUEST_EXIT, this ); |
0 | 4149 |
} |
4150 |
||
4151 |
TInt DMediaPagingDevice::Read(TThreadMessage* aReq,TLinAddr aBuffer,TUint aOffset,TUint aSize,TInt aDrvNumber) |
|
201
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4152 |
{ |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4153 |
return BaseRead(aReq,(TUint32)aBuffer,aOffset,aSize,aDrvNumber,EFalse); |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4154 |
} |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4155 |
|
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4156 |
TInt DMediaPagingDevice::ReadPhysical(TThreadMessage* aReq, TPhysAddr* aPageArray, TUint aPageCount, TUint aOffset, TInt aDrvNumber) |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4157 |
{ |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4158 |
TUint adjSize = (aPageCount << iPrimaryMedia->iBody->iPageSizeLog2) >> iReadUnitShift; // translate to Read Units |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4159 |
return BaseRead(aReq,(TUint32)aPageArray,aOffset,adjSize,aDrvNumber,ETrue); |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4160 |
} |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4161 |
|
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4162 |
TInt DMediaPagingDevice::BaseRead(TThreadMessage* aReq,TUint32 aBuffer,TUint aOffset,TUint aSize,TInt aDrvNumber, TBool aPhysAddr) |
0 | 4163 |
{ |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4164 |
OstTraceFunctionEntry1( DMEDIAPAGINGDEVICE_READ_ENTRY, this ); |
0 | 4165 |
__ASSERT_ALWAYS(NKern::CurrentThread()!=iPrimaryMedia->iDfcQ->iThread,LOCM_FAULT()); // that would lock up the system, thus better die now |
4166 |
__ASSERT_ALWAYS(aReq,LOCM_FAULT()); |
|
4167 |
__ASSERT_CRITICAL |
|
4168 |
||
4169 |
#ifdef __DEMAND_PAGING_BENCHMARKS__ |
|
4170 |
TUint32 bmStart = NKern::FastCounter(); |
|
4171 |
#endif |
|
4172 |
||
4173 |
#ifdef __CONCURRENT_PAGING_INSTRUMENTATION__ |
|
4174 |
TUint8* servicingCount; |
|
4175 |
NKern::FMWait(&iInstrumentationLock); |
|
4176 |
if(aDrvNumber == EDriveRomPaging) // ROM paging |
|
4177 |
{ |
|
4178 |
servicingCount = &iServicingROM; |
|
4179 |
if(iServicingROM) |
|
4180 |
iROMStats.iTotalConcurrentReqs++; |
|
4181 |
if(!(++iServicingROM)) |
|
4182 |
{ |
|
4183 |
iServicingROM=1; // overflow... |
|
4184 |
iROMStats.iTotalConcurrentReqs=0; // ...reset this |
|
4185 |
} |
|
4186 |
TBool empty = iMainQ.iReady && iDeferredQ.iQ.IsEmpty(); |
|
4187 |
if(!empty) |
|
4188 |
iROMStats.iTotalReqIssuedNonEmptyQ++; |
|
4189 |
} |
|
4190 |
else if (aDrvNumber == EDriveDataPaging) // Data paging |
|
4191 |
{ |
|
4192 |
servicingCount = &iServicingDataIn; |
|
4193 |
if(iServicingDataIn) |
|
4194 |
iDataStats.iTotalConcurrentReqs++; |
|
4195 |
if(!(++iServicingDataIn)) |
|
4196 |
{ |
|
4197 |
iServicingDataIn=1; // overflow... |
|
4198 |
iDataStats.iTotalConcurrentReqs=0; // ...reset this |
|
4199 |
} |
|
4200 |
TBool empty = iMainQ.iReady && iDeferredQ.iQ.IsEmpty(); |
|
4201 |
if(!empty) |
|
4202 |
iDataStats.iTotalReqIssuedNonEmptyQ++; |
|
4203 |
} |
|
4204 |
else |
|
4205 |
{ |
|
4206 |
servicingCount = &iServicingCode; |
|
4207 |
if(iServicingCode) |
|
4208 |
iCodeStats.iTotalConcurrentReqs++; |
|
4209 |
if(!(++iServicingCode)) |
|
4210 |
{ |
|
4211 |
iServicingCode=1; // overflow... |
|
4212 |
iCodeStats.iTotalConcurrentReqs=0; // ...reset this |
|
4213 |
} |
|
4214 |
TBool empty = iMainQ.iReady && iDeferredQ.iQ.IsEmpty(); |
|
4215 |
if(!empty) |
|
4216 |
iCodeStats.iTotalReqIssuedNonEmptyQ++; |
|
4217 |
} |
|
4218 |
NKern::FMSignal(&iInstrumentationLock); |
|
4219 |
#endif |
|
4220 |
||
4221 |
TUint offset=aOffset<<iReadUnitShift; |
|
4222 |
TUint size=aSize<<iReadUnitShift; |
|
4223 |
||
4224 |
#ifdef BTRACE_PAGING_MEDIA |
|
4225 |
TInt buf[3]; |
|
4226 |
buf[0]=size; // page in request length |
|
4227 |
buf[1]=aDrvNumber; // local drive number (-1 if ROM) |
|
4228 |
buf[2]=(TInt)aReq; // address of request object |
|
4229 |
BTraceContextN(BTrace::EPagingMedia,BTrace::EPagingMediaLocMedPageInBegin,aBuffer,offset,buf,sizeof(buf)); |
|
4230 |
#endif |
|
4231 |
||
4232 |
__KTRACE_OPT2(KLOCDRV,KLOCDPAGING,Kern::Printf("DMediaPagingDevice::Read, Req(0x%08x), Buff(0x%x),Offset(%d),Size(%d),DrvNo(%d)",aReq,aBuffer,offset,size,aDrvNumber)); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4233 |
OstTraceDefExt5(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DMEDIAPAGINGDEVICE_READ1, "req=0x%08x; aBuffer=0x%x; offset=%d; size=%d; aDrvNumber=%d", (TUint) aReq, (TInt) aBuffer, (TInt) offset, (TUint) size, (TUint) aDrvNumber); |
0 | 4234 |
|
4235 |
// no DFCQ, media driver executes in the context of calling thread |
|
4236 |
if (!iPrimaryMedia->iDfcQ) |
|
4237 |
{ |
|
4238 |
LOCM_FAULT(); // don't allow paging |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4239 |
OstTraceFunctionExitExt( DMEDIAPAGINGDEVICE_READ_EXIT, this, KErrNone ); |
0 | 4240 |
return KErrNone; // keep compiler happy |
4241 |
} |
|
4242 |
||
4243 |
||
4244 |
TLocDrvRequest& m=*(TLocDrvRequest*)(aReq); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4245 |
|
0 | 4246 |
|
4247 |
#ifdef __DEMAND_PAGING_BENCHMARKS__ |
|
4248 |
SPagingBenchmarkInfo* info = NULL; |
|
4249 |
#endif |
|
4250 |
||
4251 |
||
4252 |
// Read from the media and allow for retries in the unlikely event of an error. |
|
4253 |
const TInt KPageInRetries = 5; |
|
4254 |
TInt retVal = KErrGeneral; |
|
4255 |
for (TInt i=0; retVal != KErrNone && i < KPageInRetries; i++) |
|
4256 |
{ |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4257 |
m.Flags() = TLocDrvRequest::EKernelBuffer | TLocDrvRequest::EPaging; |
0 | 4258 |
TLocDrv* pL=NULL; |
4259 |
if(aDrvNumber == EDriveRomPaging) // ROM paging |
|
4260 |
{ |
|
4261 |
m.Id() = DMediaPagingDevice::ERomPageInRequest; |
|
4262 |
if (iRomPagingDriveNumber == KErrNotFound) |
|
4263 |
{ |
|
4264 |
// ROM partition has not been reported by the media driver |
|
4265 |
// it is assumed that the media driver will adjust the request accordingly |
|
4266 |
m.Flags() |= TLocDrvRequest::EAdjusted; |
|
4267 |
// Use a media drive number so the request reaches the correct media... |
|
4268 |
m.Drive() = TheDrives[iFirstLocalDriveNumber]; |
|
4269 |
} |
|
4270 |
else |
|
4271 |
{ |
|
4272 |
//ROM partition has been reported |
|
4273 |
//Set drive for use with CheckAndAdjustForPartition |
|
4274 |
m.Drive() = TheDrives[iRomPagingDriveNumber]; |
|
4275 |
} |
|
4276 |
#ifdef __DEMAND_PAGING_BENCHMARKS__ |
|
4277 |
__e32_atomic_add_ord32(&iMediaPagingInfo.iRomPageInCount, (TUint) 1); |
|
4278 |
info = &iROMBenchmarkData; |
|
4279 |
#endif |
|
4280 |
} |
|
4281 |
else if(aDrvNumber == EDriveDataPaging) // Data paging |
|
4282 |
{ |
|
4283 |
m.Id() = DLocalDrive::ERead; |
|
4284 |
m.Flags() |= TLocDrvRequest::EDataPaging; |
|
4285 |
m.Drive() = TheDrives[iDataPagingDriveNumber]; |
|
4286 |
#ifdef __DEMAND_PAGING_BENCHMARKS__ |
|
4287 |
__e32_atomic_add_ord32(&iMediaPagingInfo.iDataPageInCount, (TUint) 1); |
|
4288 |
info = &iDataInBenchmarkData; |
|
4289 |
#endif |
|
4290 |
} |
|
4291 |
else if ((aDrvNumber >=0) && (aDrvNumber<KMaxLocalDrives)) // Code paging |
|
4292 |
{ |
|
4293 |
m.Id() = DMediaPagingDevice::ECodePageInRequest; |
|
4294 |
m.Flags() |= TLocDrvRequest::ECodePaging; |
|
4295 |
pL=TheDrives[aDrvNumber]; |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4296 |
__ASSERT_DEBUG(pL && TDriveIterator::GetDrive(aDrvNumber, iPrimaryMedia) ,LOCM_FAULT()); // valid drive number? |
0 | 4297 |
m.Drive()=pL; |
4298 |
#ifdef __DEMAND_PAGING_BENCHMARKS__ |
|
4299 |
__e32_atomic_add_ord32(&iMediaPagingInfo.iCodePageInCount, (TUint) 1); |
|
4300 |
info = &iCodeBenchmarkData; |
|
4301 |
#endif |
|
4302 |
} |
|
4303 |
else |
|
4304 |
LOCM_FAULT(); // invalid drive number |
|
4305 |
||
4306 |
m.RemoteThread()=NULL; |
|
4307 |
m.Pos()=offset; |
|
4308 |
m.Length()=Int64(size); |
|
4309 |
m.RemoteDes()=(TAny*)aBuffer; |
|
4310 |
m.RemoteDesOffset()=0; // pre-aligned |
|
201
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4311 |
m.DriverFlags() = 0; |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4312 |
if (aPhysAddr) |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4313 |
m.Flags() |= TLocDrvRequest::EPhysAddrOnly; |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4314 |
|
0 | 4315 |
__KTRACE_OPT2(KLOCDRV,KLOCDPAGING,Kern::Printf("ReqId=%d, Pos=0x%lx, Len=0x%lx, remote Des 0x%x",m.Id(),m.Pos(),m.Length(),m.RemoteDes())); |
200
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
152
diff
changeset
|
4316 |
OstTraceDefExt2(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DMEDIAPAGINGDEVICE_READ2, "reqId=%d; remote Des=0x%x", (TInt) m.Id(), (TUint) m.RemoteDes()); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
152
diff
changeset
|
4317 |
OstTraceDefExt4(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DMEDIAPAGINGDEVICE_READ3, "length=%x:%x, pos=%x:%x", (TUint) I64HIGH(m.Length()), (TUint) I64LOW(m.Length()), (TUint) I64HIGH(m.Pos()), (TUint) I64LOW(m.Pos())); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4318 |
|
0 | 4319 |
__ASSERT_DEBUG(iPrimaryMedia->iBody, LOCM_FAULT()); |
4320 |
TInt mediaChanges = iPrimaryMedia->iBody->iMediaChanges; |
|
4321 |
||
4322 |
SendToMainQueueDfcAndBlock(&m); // queues request, sets and opens client thread, queues dfc and blocks thread until request is completed |
|
4323 |
retVal = m.iValue; |
|
4324 |
||
4325 |
#ifdef __DEBUG_DEMAND_PAGING__ |
|
4326 |
if (retVal != KErrNone) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4327 |
{ |
0 | 4328 |
Kern::Printf("Pagin Failure %d, retry %d", retVal, i); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4329 |
} |
0 | 4330 |
#endif |
4331 |
||
4332 |
// reset retry count if there's ben a media change |
|
4333 |
if (retVal != KErrNone && mediaChanges != iPrimaryMedia->iBody->iMediaChanges) |
|
4334 |
i = 0; |
|
4335 |
} // for () |
|
4336 |
||
4337 |
#ifdef __CONCURRENT_PAGING_INSTRUMENTATION__ |
|
4338 |
NKern::FMWait(&iInstrumentationLock); |
|
4339 |
if (*servicingCount) |
|
4340 |
(*servicingCount)--; |
|
4341 |
NKern::FMSignal(&iInstrumentationLock); |
|
4342 |
#endif |
|
4343 |
||
4344 |
#ifdef __DEMAND_PAGING_BENCHMARKS__ |
|
4345 |
TUint32 bmEnd = NKern::FastCounter(); |
|
4346 |
++info->iCount; |
|
4347 |
#if !defined(HIGHIGH_RES_TIMER) || defined(HIGH_RES_TIMER_COUNTS_UP) |
|
4348 |
TInt64 elapsed=bmEnd-bmStart; |
|
4349 |
#else |
|
4350 |
TInt64 elapsed=bmStart-bmEnd; |
|
4351 |
#endif |
|
4352 |
info->iTotalTime += elapsed; |
|
4353 |
if (elapsed > info->iMaxTime) |
|
4354 |
info->iMaxTime = elapsed; |
|
4355 |
if (elapsed < info->iMinTime) |
|
4356 |
info->iMinTime = elapsed; |
|
4357 |
#endif // __DEMAND_PAGING_BENCHMARKS__ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4358 |
OstTraceFunctionExitExt( DMEDIAPAGINGDEVICE_READ_EXIT2, this, retVal ); |
0 | 4359 |
return retVal; |
4360 |
} |
|
4361 |
||
4362 |
TInt DMediaPagingDevice::Write(TThreadMessage* aReq,TLinAddr aBuffer,TUint aOffset,TUint aSize,TBool aBackground) |
|
201
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4363 |
{ |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4364 |
return BaseWrite(aReq,(TUint32)aBuffer,aOffset,aSize,aBackground,EFalse); |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4365 |
} |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4366 |
|
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4367 |
TInt DMediaPagingDevice::WritePhysical(TThreadMessage* aReq, TPhysAddr* aPageArray, TUint aPageCount, TUint aOffset, TBool aBackground) |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4368 |
{ |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4369 |
TUint adjSize = (aPageCount << iPrimaryMedia->iBody->iPageSizeLog2) >> iReadUnitShift; // translate to Read Units |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4370 |
return BaseWrite(aReq,(TUint32)aPageArray,aOffset,adjSize,aBackground,ETrue); |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4371 |
} |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4372 |
|
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4373 |
TInt DMediaPagingDevice::BaseWrite(TThreadMessage* aReq,TUint32 aBuffer,TUint aOffset,TUint aSize,TBool aBackground, TBool aPhysAddr) |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4374 |
{ |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4375 |
OstTraceFunctionEntry1( DMEDIAPAGINGDEVICE_WRITE_ENTRY, this ); |
0 | 4376 |
__ASSERT_ALWAYS(NKern::CurrentThread()!=iPrimaryMedia->iDfcQ->iThread,LOCM_FAULT()); // that would lock up the system, thus better die now |
4377 |
__ASSERT_ALWAYS(aReq,LOCM_FAULT()); |
|
4378 |
__ASSERT_CRITICAL |
|
4379 |
||
4380 |
#ifdef __DEMAND_PAGING_BENCHMARKS__ |
|
4381 |
TUint32 bmStart = NKern::FastCounter(); |
|
4382 |
#endif |
|
4383 |
||
4384 |
#ifdef __CONCURRENT_PAGING_INSTRUMENTATION__ |
|
4385 |
NKern::FMWait(&iInstrumentationLock); |
|
4386 |
if(iServicingDataOut) |
|
4387 |
iDataStats.iTotalConcurrentReqs++; |
|
4388 |
if(!(++iServicingDataOut)) |
|
4389 |
{ |
|
4390 |
iServicingDataOut=1; // overflow... |
|
4391 |
iDataStats.iTotalConcurrentReqs=0; // ...reset this |
|
4392 |
} |
|
4393 |
TBool empty = iMainQ.iReady && iDeferredQ.iQ.IsEmpty(); |
|
4394 |
if(!empty) |
|
4395 |
iDataStats.iTotalReqIssuedNonEmptyQ++; |
|
4396 |
NKern::FMSignal(&iInstrumentationLock); |
|
4397 |
#endif |
|
4398 |
||
4399 |
TUint offset=aOffset<<iReadUnitShift; |
|
4400 |
TUint size=aSize<<iReadUnitShift; |
|
4401 |
||
4402 |
#ifdef BTRACE_PAGING_MEDIA |
|
4403 |
TInt buf[2]; |
|
4404 |
buf[0] = size; // page out request length |
|
4405 |
buf[1] = (TInt)aReq; // address of request object |
|
4406 |
BTraceContextN(BTrace::EPagingMedia,BTrace::EPagingMediaLocMedPageOutBegin,aBuffer,offset,buf,sizeof(buf)); |
|
4407 |
#endif |
|
4408 |
||
4409 |
__KTRACE_OPT2(KLOCDRV,KLOCDPAGING,Kern::Printf("DMediaPagingDevice::Write, Req(0x%08x), Buff(0x%x),Offset(%d),Size(%d)",aReq,aBuffer,offset,size)); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4410 |
OstTraceDefExt4(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DMEDIAPAGINGDEVICE_WRITE1, "req=0x%08x; aBuffer=0x%x; offset=%d; size=%d", (TUint) aReq, (TUint) aBuffer, offset, size); |
0 | 4411 |
|
4412 |
// no DFCQ, media driver executes in the context of calling thread |
|
4413 |
if (!iPrimaryMedia->iDfcQ) |
|
4414 |
{ |
|
4415 |
LOCM_FAULT(); // don't allow paging |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4416 |
OstTraceFunctionExitExt( DMEDIAPAGINGDEVICE_WRITE_EXIT, this, KErrNone ); |
0 | 4417 |
return KErrNone; // keep compiler happy |
4418 |
} |
|
4419 |
||
4420 |
||
4421 |
TLocDrvRequest& m=*(TLocDrvRequest*)(aReq); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4422 |
|
0 | 4423 |
#ifdef __DEMAND_PAGING_BENCHMARKS__ |
4424 |
__e32_atomic_add_ord32(&iMediaPagingInfo.iDataPageOutCount, (TUint) 1); |
|
4425 |
if (aBackground) |
|
4426 |
__e32_atomic_add_ord32(&iMediaPagingInfo.iDataPageOutBackgroundCount, (TUint) 1); |
|
4427 |
#endif |
|
4428 |
||
4429 |
// Write to the media and allow for retries in the unlikely event of an error. |
|
4430 |
const TInt KPageOutRetries = 5; |
|
4431 |
TInt retVal = KErrGeneral; |
|
4432 |
for (TInt i=0; retVal != KErrNone && i < KPageOutRetries; i++) |
|
4433 |
{ |
|
201
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4434 |
m.Flags() = TLocDrvRequest::EKernelBuffer | |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4435 |
TLocDrvRequest::EPaging | |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4436 |
TLocDrvRequest::EDataPaging | |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4437 |
(aBackground ? TLocDrvRequest::EBackgroundPaging : 0) | |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4438 |
(aPhysAddr ? TLocDrvRequest::EPhysAddrOnly : 0); |
0 | 4439 |
|
4440 |
m.Id() = DLocalDrive::EWrite; |
|
4441 |
m.Drive() = TheDrives[iDataPagingDriveNumber]; |
|
4442 |
||
4443 |
m.RemoteThread()=NULL; |
|
4444 |
m.Pos()=offset; |
|
4445 |
m.Length()=Int64(size); |
|
4446 |
m.RemoteDes()=(TAny*)aBuffer; |
|
4447 |
m.RemoteDesOffset()=0; // pre-aligned |
|
201
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4448 |
m.DriverFlags() = 0; |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
4449 |
|
0 | 4450 |
__KTRACE_OPT2(KLOCDRV,KLOCDPAGING,Kern::Printf("ReqId=%d, Pos=0x%lx, Len=0x%lx, remote Des 0x%x",m.Id(),m.Pos(),m.Length(),m.RemoteDes())); |
200
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
152
diff
changeset
|
4451 |
OstTraceDefExt2(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DMEDIAPAGINGDEVICE_WRITE2, "reqId=%d; remote Des=0x%x", (TInt) m.Id(), (TUint) m.RemoteDes()); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
152
diff
changeset
|
4452 |
OstTraceDefExt4(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DMEDIAPAGINGDEVICE_WRITE3, "length=%x:%x, pos=%x:%x", (TUint) I64HIGH(m.Length()), (TUint) I64LOW(m.Length()), (TUint) I64HIGH(m.Pos()), (TUint) I64LOW(m.Pos())); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4453 |
|
0 | 4454 |
__ASSERT_DEBUG(iPrimaryMedia->iBody, LOCM_FAULT()); |
4455 |
TInt mediaChanges = iPrimaryMedia->iBody->iMediaChanges; |
|
4456 |
||
4457 |
SendToMainQueueDfcAndBlock(&m); // queues request, sets and opens client thread, queues dfc and blocks thread until request is completed |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4458 |
|
0 | 4459 |
retVal = m.iValue; |
4460 |
||
4461 |
#ifdef __DEBUG_DEMAND_PAGING__ |
|
4462 |
if (retVal != KErrNone) |
|
4463 |
Kern::Printf("Pagout Failure %d, retry %d", retVal, i); |
|
4464 |
#endif |
|
4465 |
// reset retry count if there's ben a media change |
|
4466 |
if (retVal != KErrNone && mediaChanges != iPrimaryMedia->iBody->iMediaChanges) |
|
4467 |
i = 0; |
|
4468 |
} // for () |
|
4469 |
||
4470 |
#ifdef __CONCURRENT_PAGING_INSTRUMENTATION__ |
|
4471 |
NKern::FMWait(&iInstrumentationLock); |
|
4472 |
if (iServicingDataOut) |
|
4473 |
iServicingDataOut--; |
|
4474 |
NKern::FMSignal(&iInstrumentationLock); |
|
4475 |
#endif |
|
4476 |
||
4477 |
#ifdef __DEMAND_PAGING_BENCHMARKS__ |
|
4478 |
SPagingBenchmarkInfo& info = iDataOutBenchmarkData; |
|
4479 |
TUint32 bmEnd = NKern::FastCounter(); |
|
4480 |
++info.iCount; |
|
4481 |
#if !defined(HIGHIGH_RES_TIMER) || defined(HIGH_RES_TIMER_COUNTS_UP) |
|
4482 |
TInt64 elapsed=bmEnd-bmStart; |
|
4483 |
#else |
|
4484 |
TInt64 elapsed=bmStart-bmEnd; |
|
4485 |
#endif |
|
4486 |
info.iTotalTime += elapsed; |
|
4487 |
if (elapsed > info.iMaxTime) |
|
4488 |
info.iMaxTime = elapsed; |
|
4489 |
if (elapsed < info.iMinTime) |
|
4490 |
info.iMinTime = elapsed; |
|
4491 |
#endif // __DEMAND_PAGING_BENCHMARKS__ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4492 |
|
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4493 |
OstTraceFunctionExitExt( DMEDIAPAGINGDEVICE_WRITE_EXIT2, this, retVal ); |
0 | 4494 |
return retVal; |
4495 |
} |
|
4496 |
||
4497 |
||
4498 |
TInt DMediaPagingDevice::DeleteNotify(TThreadMessage* aReq,TUint aOffset,TUint aSize) |
|
4499 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4500 |
OstTraceFunctionEntry1( DMEDIAPAGINGDEVICE_DELETENOTIFY_ENTRY, this ); |
0 | 4501 |
if (iDeleteNotifyNotSupported) |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4502 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4503 |
OstTraceFunctionExitExt( DMEDIAPAGINGDEVICE_DELETENOTIFY_EXIT1, this, KErrNotSupported ); |
0 | 4504 |
return KErrNotSupported; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4505 |
} |
0 | 4506 |
|
4507 |
__ASSERT_ALWAYS(NKern::CurrentThread()!=iPrimaryMedia->iDfcQ->iThread,LOCM_FAULT()); // that would lock up the system, thus better die now |
|
4508 |
__ASSERT_ALWAYS(aReq,LOCM_FAULT()); |
|
4509 |
__ASSERT_ALWAYS(DataPagingDfcQ(iPrimaryMedia),LOCM_FAULT()); |
|
4510 |
__ASSERT_CRITICAL |
|
4511 |
||
4512 |
TUint offset = aOffset<<iReadUnitShift; |
|
4513 |
TUint size = aSize<<iReadUnitShift; |
|
4514 |
||
4515 |
#ifdef BTRACE_PAGING_MEDIA |
|
4516 |
TInt buf[2]; |
|
4517 |
buf[0] = size; // delete notify length |
|
4518 |
buf[1] = (TInt)aReq; // address of request object |
|
4519 |
BTraceContextN(BTrace::EPagingMedia,BTrace::EPagingMediaLocMedDeleteNotifyBegin,NULL,offset,buf,sizeof(buf)); |
|
4520 |
#endif |
|
4521 |
||
4522 |
__KTRACE_OPT2(KLOCDRV,KLOCDPAGING,Kern::Printf("DMediaPagingDevice::Write, Req(0x%08x), Offset(%d),Size(%d)",aReq,offset,size)); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4523 |
OstTraceDefExt3(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DMEDIAPAGINGDEVICE_DELETENOTIFY1 , "req=0x%08x; offset=%d; size=%d", (TUint) aReq, offset, size); |
0 | 4524 |
|
4525 |
// no DFCQ, media driver executes in the context of calling thread |
|
4526 |
if (!iPrimaryMedia->iDfcQ) |
|
4527 |
{ |
|
4528 |
LOCM_FAULT(); // don't allow paging |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4529 |
OstTraceFunctionExitExt( DMEDIAPAGINGDEVICE_DELETENOTIFY_EXIT2, this, KErrNone ); |
0 | 4530 |
return KErrNone; // keep compiler happy |
4531 |
} |
|
4532 |
||
4533 |
TLocDrvRequest& m=*(TLocDrvRequest*)(aReq); |
|
4534 |
||
4535 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4536 |
m.Flags() = TLocDrvRequest::EKernelBuffer | TLocDrvRequest::EPaging | TLocDrvRequest::EDataPaging; |
0 | 4537 |
m.Id() = DLocalDrive::EDeleteNotify; |
4538 |
m.Drive() = TheDrives[iDataPagingDriveNumber]; |
|
4539 |
||
4540 |
m.RemoteThread() = NULL; |
|
4541 |
m.Pos() = offset; |
|
4542 |
m.Length() = Int64(size); |
|
4543 |
m.RemoteDes() = NULL; |
|
4544 |
m.RemoteDesOffset() = 0; // pre-aligned |
|
4545 |
m.DriverFlags()=0; |
|
4546 |
__KTRACE_OPT2(KLOCDRV,KLOCDPAGING,Kern::Printf("ReqId=%d, Pos=0x%lx, Len=0x%lx, remote Des 0x%x",m.Id(),m.Pos(),m.Length(),m.RemoteDes())); |
|
200
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
152
diff
changeset
|
4547 |
OstTraceDefExt2(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DMEDIAPAGINGDEVICE_DELETENOTIFY2 , "reqId=%d; remote Des=0x%x", m.Id(),(TUint) m.RemoteDes()); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
152
diff
changeset
|
4548 |
OstTraceDefExt4(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DMEDIAPAGINGDEVICE_DELETENOTIFY3 , "length=%x:%x, pos=%x:%x", (TUint) I64HIGH(m.Length()), (TUint) I64LOW(m.Length()), (TUint) I64HIGH(m.Pos()), (TUint) I64LOW(m.Pos())); |
0 | 4549 |
// send request aynchronously as we don't particularly care about the result |
4550 |
// and waiting would slow down the thread taking the page fault |
|
4551 |
iPrimaryMedia->RequestCountInc(); |
|
4552 |
||
4553 |
m.SendReceive(&iMainQ); // send request synchronously |
|
4554 |
||
4555 |
#ifdef __DEMAND_PAGING__ |
|
4556 |
iPrimaryMedia->RequestCountDec(); |
|
4557 |
#endif |
|
4558 |
||
4559 |
TInt retVal = m.iValue; |
|
4560 |
||
4561 |
if (retVal == KErrNotSupported) |
|
4562 |
iDeleteNotifyNotSupported = ETrue; |
|
4563 |
||
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4564 |
OstTraceFunctionExitExt( DMEDIAPAGINGDEVICE_DELETENOTIFY_EXIT3, this, retVal ); |
0 | 4565 |
return retVal; |
4566 |
} |
|
4567 |
||
4568 |
||
4569 |
EXPORT_C TInt TLocDrvRequest::WriteToPageHandler(const TAny* aSrc, TInt aSize, TInt anOffset) |
|
4570 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4571 |
OstTraceFunctionEntry1( TLOCDRVREQUEST_WRITETOPAGEHANDLER_ENTRY, this ); |
0 | 4572 |
#ifdef BTRACE_PAGING_MEDIA |
4573 |
TMediaDevice medDev=Drive()->iMedia->iDevice; |
|
4574 |
TInt buf[3]; |
|
4575 |
buf[0]=(TUint32)RemoteDes(); |
|
4576 |
buf[1]=anOffset; |
|
4577 |
buf[2]=aSize; |
|
4578 |
BTraceContextN(BTrace::EPagingMedia,BTrace::EPagingMediaMedDrvWriteBack,medDev,this,buf,sizeof(buf)); |
|
4579 |
#endif |
|
4580 |
__KTRACE_OPT2(KLOCDRV,KLOCDPAGING,Kern::Printf("TLocDrvRequest::WriteToPageHandler, memcpy((aTrg)%08x, (aSrc)%08x, (aLength)%08x)",(TUint32)RemoteDes()+anOffset,aSrc,aSize)); |
|
4581 |
(void)memcpy((TAny*)((TUint32)RemoteDes()+anOffset), aSrc, aSize); // maybe in later versions this could be something else |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4582 |
OstTraceFunctionExitExt( TLOCDRVREQUEST_WRITETOPAGEHANDLER_EXIT, this, KErrNone ); |
0 | 4583 |
return KErrNone; |
4584 |
} |
|
4585 |
||
4586 |
EXPORT_C TInt TLocDrvRequest::ReadFromPageHandler(TAny* aDst, TInt aSize, TInt anOffset) |
|
4587 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4588 |
OstTraceFunctionEntry1( TLOCDRVREQUEST_READFROMPAGEHANDLER_ENTRY, this ); |
0 | 4589 |
#ifdef BTRACE_PAGING_MEDIA |
4590 |
TMediaDevice medDev=Drive()->iMedia->iDevice; |
|
4591 |
TInt buf[3]; |
|
4592 |
buf[0]=(TUint32)RemoteDes(); |
|
4593 |
buf[1]=anOffset; |
|
4594 |
buf[2]=aSize; |
|
4595 |
BTraceContextN(BTrace::EPagingMedia,BTrace::EPagingMediaMedDrvRead,medDev,this,buf,sizeof(buf)); |
|
4596 |
#endif |
|
4597 |
__KTRACE_OPT2(KLOCDRV,KLOCDPAGING,Kern::Printf("TLocDrvRequest::ReadFromPageHandler, memcpy((aDst)%08x, (aTrg)%08x, (aLength)%08x)",aDst,(TUint32)RemoteDes()+anOffset,aSize)); |
|
4598 |
(void)memcpy(aDst, (TAny*)((TUint32)RemoteDes()+anOffset), aSize); // maybe in later versions this could be something else |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4599 |
OstTraceFunctionExitExt( TLOCDRVREQUEST_READFROMPAGEHANDLER_EXIT, this, KErrNone ); |
0 | 4600 |
return KErrNone; |
4601 |
} |
|
4602 |
||
4603 |
_LIT(KLitFragmentationMutexName, "FRAGMENTATION_MUTEX"); |
|
4604 |
||
4605 |
TInt DFragmentationPagingLock::Construct(TUint aNumPages) |
|
4606 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4607 |
OstTraceFunctionEntryExt( DFRAGMENTATIONPAGINGLOCK_CONSTRUCT_ENTRY, this ); |
0 | 4608 |
TInt r=KErrNone; |
4609 |
__KTRACE_OPT2(KBOOT,KLOCDPAGING,Kern::Printf("Fragmentation Lock: creating Mutex")); |
|
4610 |
r=Kern::MutexCreate(this->iFragmentationMutex, KLitFragmentationMutexName, KMutexOrdNone); |
|
4611 |
if (r!=KErrNone) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4612 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4613 |
OstTraceFunctionExitExt( DFRAGMENTATIONPAGINGLOCK_CONSTRUCT_EXIT1, this, r ); |
0 | 4614 |
return r; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4615 |
} |
0 | 4616 |
__KTRACE_OPT2(KBOOT,KLOCDPAGING,Kern::Printf("Fragmentation Lock: Mutex created OK")); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4617 |
OstTraceDef0(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DFRAGMENTATIONPAGINGLOCK_CONSTRUCT1 , "Fragmentation Lock: Mutex created OK"); |
0 | 4618 |
|
4619 |
iFragmentGranularity = 0; |
|
4620 |
if (aNumPages == 0) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4621 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4622 |
OstTraceFunctionExitExt( DFRAGMENTATIONPAGINGLOCK_CONSTRUCT_EXIT2, this, KErrNone ); |
0 | 4623 |
return KErrNone; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4624 |
} |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4625 |
|
0 | 4626 |
// in CS |
4627 |
TInt pageSize=Kern::RoundToPageSize(1); |
|
4628 |
LockFragmentation(); |
|
4629 |
r=Alloc(pageSize*aNumPages); // alloc pages |
|
4630 |
UnlockFragmentation(); |
|
4631 |
||
4632 |
if(r==KErrNone) |
|
4633 |
{ |
|
4634 |
iFragmentGranularity = pageSize * aNumPages; |
|
4635 |
__KTRACE_OPT2(KBOOT,KLOCDPAGING,Kern::Printf("Fragmentation granularity set to 0x%x", iFragmentGranularity)); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4636 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DFRAGMENTATIONPAGINGLOCK_CONSTRUCT2, "Fragmentation granularity=0x%x", iFragmentGranularity); |
0 | 4637 |
} |
4638 |
||
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4639 |
OstTraceFunctionExitExt( DFRAGMENTATIONPAGINGLOCK_CONSTRUCT_EXIT3, this, r ); |
0 | 4640 |
return r; |
4641 |
} |
|
4642 |
||
4643 |
void DFragmentationPagingLock::Cleanup() |
|
4644 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4645 |
OstTraceFunctionEntry1( DFRAGMENTATIONPAGINGLOCK_CLEANUP_ENTRY, this ); |
0 | 4646 |
// in CS |
4647 |
if (iFragmentationMutex) |
|
4648 |
{ |
|
4649 |
LockFragmentation(); |
|
4650 |
Free(); // at last! |
|
4651 |
UnlockFragmentation(); |
|
4652 |
Kern::SafeClose((DObject*&)iFragmentationMutex,NULL); |
|
4653 |
} |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4654 |
OstTraceFunctionExit1( DFRAGMENTATIONPAGINGLOCK_CLEANUP_EXIT, this ); |
0 | 4655 |
} |
4656 |
||
4657 |
#else |
|
4658 |
#if !defined(__WINS__) |
|
4659 |
EXPORT_C TInt TLocDrvRequest::WriteToPageHandler(const TAny* , TInt , TInt) |
|
4660 |
{ |
|
4661 |
return KErrNone; // stub for def file |
|
4662 |
} |
|
4663 |
#endif // __WINS__ |
|
4664 |
#endif //__DEMAND_PAGING__ |
|
4665 |
/******************************************** |
|
4666 |
* Media driver base class |
|
4667 |
********************************************/ |
|
4668 |
||
4669 |
||
4670 |
||
4671 |
||
4672 |
/** |
|
4673 |
Constructor. |
|
4674 |
||
4675 |
This is called, typically, by a derived class constructor in its ctor list. |
|
4676 |
||
4677 |
@param aMediaId The value of the unique media ID assigned when the media |
|
4678 |
driver is registered. |
|
4679 |
||
4680 |
@see LocDrv::RegisterMediaDevice() |
|
4681 |
*/ |
|
4682 |
EXPORT_C DMediaDriver::DMediaDriver(TInt aMediaId) |
|
4683 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4684 |
OstTraceFunctionEntryExt( DMEDIADRIVER_DMEDIADRIVER_ENTRY, this ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4685 |
|
0 | 4686 |
// iPhysicalDevice=NULL; |
4687 |
// iTotalSizeInBytes=0; |
|
4688 |
// iCurrentConsumption=0; |
|
4689 |
// iPrimaryMedia=NULL; |
|
4690 |
// iCritical=EFalse; |
|
4691 |
iPrimaryMedia=(DPrimaryMediaBase*)TheMedia[aMediaId]; |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4692 |
OstTraceFunctionExit1( DMEDIADRIVER_DMEDIADRIVER_EXIT, this ); |
0 | 4693 |
} |
4694 |
||
4695 |
||
4696 |
||
4697 |
||
4698 |
/** |
|
4699 |
Destructor. |
|
4700 |
||
4701 |
Sets the device's current consumption to zero, and calls Close() on |
|
4702 |
the PDD factory object. |
|
4703 |
||
4704 |
@see DObject::Close() |
|
4705 |
*/ |
|
4706 |
EXPORT_C DMediaDriver::~DMediaDriver() |
|
4707 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4708 |
OstTraceFunctionEntry1( DMEDIADRIVER_DMEDIADRIVER_DESTRUCTOR_ENTRY, this ); |
0 | 4709 |
SetCurrentConsumption(0); |
4710 |
Kern::SafeClose((DObject*&)iPhysicalDevice,NULL); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4711 |
OstTraceFunctionExit1( DMEDIADRIVER_DMEDIADRIVER_DESTRUCTOR_EXIT, this ); |
0 | 4712 |
} |
4713 |
||
4714 |
||
4715 |
||
4716 |
||
4717 |
/** |
|
4718 |
Closes the media driver. |
|
4719 |
||
4720 |
This default implementation simply deletes this DMediaDriver object. |
|
4721 |
||
4722 |
Media drivers can provide their own implementation, which gives them |
|
4723 |
the opportunity to clean up resources before closure; for example, |
|
4724 |
cancelling a DFC. |
|
4725 |
Any replacement function must call this base class function as |
|
4726 |
the last instruction. |
|
4727 |
*/ |
|
4728 |
EXPORT_C void DMediaDriver::Close() |
|
4729 |
{ |
|
4730 |
delete this; |
|
4731 |
} |
|
4732 |
||
4733 |
||
4734 |
||
4735 |
||
4736 |
/** |
|
4737 |
Sets the total size of the media device. |
|
4738 |
||
4739 |
The function must be called by the media driver's implementation of PartitionInfo(). |
|
4740 |
||
4741 |
@param aTotalSizeInBytes The total size of the media, in bytes. |
|
4742 |
@param aLocDrv This is not used by media drivers; the class |
|
4743 |
definition provides a default value. |
|
4744 |
||
4745 |
@see DMediaDriver::PartitionInfo() |
|
4746 |
*/ |
|
4747 |
EXPORT_C void DMediaDriver::SetTotalSizeInBytes(Int64 aTotalSizeInBytes, TLocDrv* aLocDrv) |
|
4748 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4749 |
OstTraceFunctionEntry1( DMEDIADRIVER_SETTOTALSIZEINBYTES_ENTRY, this ); |
0 | 4750 |
iTotalSizeInBytes=aTotalSizeInBytes; |
4751 |
if (aLocDrv) |
|
4752 |
aLocDrv->iPartitionLen=aTotalSizeInBytes; |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4753 |
OstTraceFunctionExit1( DMEDIADRIVER_SETTOTALSIZEINBYTES_EXIT, this ); |
0 | 4754 |
} |
4755 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4756 |
/** |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4757 |
For non NAND devices, i.e. devices which don't set TLocalDriveCapsV4::iNumOfBlocks, |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4758 |
set iSectorSizeInBytes, iNumberOfSectors & iNumPagesPerBlock appropriately to allow |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4759 |
TLocalDriveCapsV4::MediaSizeInBytes() to correctly return the media size |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4760 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4761 |
Media drivers should call this when they receive a DLocalDrive::ECaps request |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4762 |
*/ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4763 |
EXPORT_C void DMediaDriver::SetTotalSizeInBytes(TLocalDriveCapsV4& aCaps) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4764 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4765 |
if (aCaps.iNumOfBlocks == 0) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4766 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4767 |
aCaps.iSectorSizeInBytes = 512; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4768 |
aCaps.iNumPagesPerBlock = 1; // ...to ensure compatibility with NAND semantics |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4769 |
Int64 numberOfSectors = iTotalSizeInBytes >> 9; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4770 |
while (I64HIGH(numberOfSectors) > 0) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4771 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4772 |
aCaps.iNumPagesPerBlock<<= 1; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4773 |
numberOfSectors>>= 1; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4774 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4775 |
aCaps.iNumberOfSectors = I64LOW(numberOfSectors); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4776 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4777 |
} |
0 | 4778 |
|
4779 |
||
4780 |
||
4781 |
/** |
|
4782 |
Gets the total size of the media. |
|
4783 |
||
4784 |
@return The total size of the media, in bytes. |
|
4785 |
||
4786 |
@see DMediaDriver::SetTotalSizeInBytes() |
|
4787 |
*/ |
|
4788 |
EXPORT_C Int64 DMediaDriver::TotalSizeInBytes() |
|
4789 |
{ |
|
4790 |
return iTotalSizeInBytes; |
|
4791 |
} |
|
4792 |
||
4793 |
||
4794 |
||
4795 |
||
4796 |
/** |
|
4797 |
Flags the media driver as entering a critical part of its processing. |
|
4798 |
||
4799 |
In this context, critical means that the driver must be allowed to complete |
|
4800 |
its current activity. |
|
4801 |
For example, a request to power down the device must be deferred until |
|
4802 |
the driver exits the critical part. |
|
4803 |
||
4804 |
@return KErrNone, if the driver has been successfully flagged as being in |
|
4805 |
a critical part; otherwise, one of the other system-wide error codes. |
|
4806 |
||
4807 |
@see DMediaDriver::EndInCritical() |
|
4808 |
*/ |
|
4809 |
EXPORT_C TInt DMediaDriver::InCritical() |
|
4810 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4811 |
OstTraceFunctionEntry1( DMEDIADRIVER_INCRITICAL_ENTRY, this ); |
0 | 4812 |
if (!iCritical) |
4813 |
{ |
|
4814 |
TInt r=iPrimaryMedia->InCritical(); |
|
4815 |
if (r!=KErrNone) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4816 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4817 |
OstTraceFunctionExitExt( DMEDIADRIVER_INCRITICAL_EXIT, this, r ); |
0 | 4818 |
return r; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4819 |
} |
0 | 4820 |
iCritical=ETrue; |
4821 |
} |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4822 |
OstTraceFunctionExitExt( DMEDIADRIVER_INCRITICAL_EXIT2, this, KErrNone ); |
0 | 4823 |
return KErrNone; |
4824 |
} |
|
4825 |
||
4826 |
||
4827 |
||
4828 |
||
4829 |
/** |
|
4830 |
Flags the media driver as leaving a critical part of its processing. |
|
4831 |
||
4832 |
@see DMediaDriver::InCritical() |
|
4833 |
*/ |
|
4834 |
EXPORT_C void DMediaDriver::EndInCritical() |
|
4835 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4836 |
OstTraceFunctionEntry1( DMEDIADRIVER_ENDINCRITICAL_ENTRY, this ); |
0 | 4837 |
if (iCritical) |
4838 |
{ |
|
4839 |
iCritical=EFalse; |
|
4840 |
iPrimaryMedia->EndInCritical(); |
|
4841 |
} |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4842 |
OstTraceFunctionExit1( DMEDIADRIVER_ENDINCRITICAL_EXIT, this ); |
0 | 4843 |
} |
4844 |
||
4845 |
||
4846 |
||
4847 |
||
4848 |
/** |
|
4849 |
@internalComponent |
|
4850 |
*/ |
|
4851 |
EXPORT_C void DMediaDriver::SetCurrentConsumption(TInt aValue) |
|
4852 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4853 |
OstTraceFunctionEntryExt( DMEDIADRIVER_SETCURRENTCONSUMPTION_ENTRY, this ); |
0 | 4854 |
TInt old = (TInt)__e32_atomic_swp_ord32(&iCurrentConsumption, aValue); |
4855 |
TInt delta = aValue - old; |
|
4856 |
iPrimaryMedia->DeltaCurrentConsumption(delta); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4857 |
OstTraceFunctionExit1( DMEDIADRIVER_SETCURRENTCONSUMPTION_EXIT, this ); |
0 | 4858 |
} |
4859 |
||
4860 |
||
4861 |
||
4862 |
||
4863 |
/** |
|
4864 |
Informs the media driver subsystem that an asynchronous request is complete. |
|
4865 |
||
4866 |
@param m The request that this call is completing. |
|
4867 |
@param aResult The return code for the asynchronous request. Typically, this |
|
4868 |
is KErrNone to report success, or one of the other system-wide |
|
4869 |
error codes to report failure or other problems. |
|
4870 |
*/ |
|
4871 |
EXPORT_C void DMediaDriver::Complete(TLocDrvRequest& m, TInt aResult) |
|
4872 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4873 |
OstTraceExt2( TRACE_FLOW, DMEDIADRIVER_COMPLETE_ENTRY, "m=%x;aResult=%d", (TUint) &m, aResult ); |
0 | 4874 |
CHECK_RET(aResult); |
4875 |
#ifdef __DEMAND_PAGING__ |
|
4876 |
if (DMediaPagingDevice::PagingRequest(m)) |
|
4877 |
{ |
|
4878 |
__ASSERT_ALWAYS(iPrimaryMedia && iPrimaryMedia->iPagingMedia && iPrimaryMedia->iBody->iPagingDevice,LOCM_FAULT()); |
|
4879 |
__ASSERT_ALWAYS( ((m.Flags() & TLocDrvRequest::ECodePaging) == 0) || (m.Drive()->iPagingDrv), LOCM_FAULT()); |
|
4880 |
DMediaPagingDevice* pagingdevice = iPrimaryMedia->iBody->iPagingDevice; |
|
4881 |
pagingdevice->CompleteRequest(&m, aResult); |
|
4882 |
} |
|
4883 |
else |
|
4884 |
#endif |
|
4885 |
iPrimaryMedia->CompleteRequest(m, aResult); |
|
4886 |
||
4887 |
if (&m == iPrimaryMedia->iCurrentReq) // Complete() called on request serviced synchronously |
|
4888 |
iPrimaryMedia->iCurrentReq = NULL; |
|
4889 |
||
4890 |
iPrimaryMedia->RunDeferred(); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4891 |
OstTraceFunctionExit1( DMEDIADRIVER_COMPLETE_EXIT, this ); |
0 | 4892 |
} |
4893 |
||
4894 |
||
4895 |
||
4896 |
||
4897 |
/** |
|
4898 |
Informs the media driver subsystem that the media driver is open |
|
4899 |
and has been initialised. |
|
4900 |
||
4901 |
This can be called from the PDD factory function Create(), if opening and |
|
4902 |
initialising the media driver is synchronous, otherwise it should be called by |
|
4903 |
the asynchronous media driver function that is responsible for opening and |
|
4904 |
initialising the driver. |
|
4905 |
||
4906 |
@param anError KErrNone if successful, otherwise one of the other system wide |
|
4907 |
error codes. |
|
4908 |
*/ |
|
4909 |
EXPORT_C void DMediaDriver::OpenMediaDriverComplete(TInt anError) |
|
4910 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4911 |
OstTraceFunctionEntry1( DMEDIADRIVER_OPENMEDIADRIVERCOMPLETE_ENTRY, this ); |
0 | 4912 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("DMediaDriver::OpenMediaDriverComplete(%d) this %x iPrimaryMedia %x", anError, this, iPrimaryMedia)); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4913 |
OstTraceDefExt3(OST_TRACE_CATEGORY_RND, TRACE_MEDIACHANGE, DMEDIADRIVER_OPENMEDIADRIVERCOMPLETE, "anError %d this 0x%x iPrimaryMedia 0x%x", anError, (TUint) this, (TUint) iPrimaryMedia); |
0 | 4914 |
DPrimaryMediaBase* pM=iPrimaryMedia; |
4915 |
pM->iAsyncErrorCode=anError; |
|
4916 |
pM->iAsyncDfc.Enque(); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4917 |
OstTraceFunctionExit1( DMEDIADRIVER_OPENMEDIADRIVERCOMPLETE_EXIT, this ); |
0 | 4918 |
} |
4919 |
||
4920 |
||
4921 |
||
4922 |
||
4923 |
/** |
|
4924 |
Informs the media driver subsystem that the media driver has completed |
|
4925 |
the provision of partition information. |
|
4926 |
||
4927 |
The media driver provides partition information in its implementation |
|
4928 |
of PartitionInfo(). |
|
4929 |
||
4930 |
@param anError KErrNone if successful, otherwise one of the other system wide |
|
4931 |
error codes. |
|
4932 |
||
4933 |
@see DMediaDriver::PartitionInfo() |
|
4934 |
*/ |
|
4935 |
EXPORT_C void DMediaDriver::PartitionInfoComplete(TInt anError) |
|
4936 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4937 |
OstTraceFunctionEntry1( DMEDIADRIVER_PARTITIONINFOCOMPLETE_ENTRY, this ); |
0 | 4938 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("DMediaDriver::PartitionInfoComplete(%d) anError %d this %x iPrimaryMedia %x", anError, this, iPrimaryMedia)); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4939 |
OstTraceExt3( TRACE_INTERNALS, DMDEDIADRIVER_PARTITIONINFOCOMPLETE, "anError=%d; this=%x; iPrimaryMedia=%x", anError, (TUint) this, (TUint) iPrimaryMedia ); |
0 | 4940 |
DPrimaryMediaBase* pM=iPrimaryMedia; |
4941 |
pM->iAsyncErrorCode=anError; |
|
4942 |
pM->iAsyncDfc.Enque(); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4943 |
OstTraceFunctionExit1( DMEDIADRIVER_PARTITIONINFOCOMPLETE_EXIT, this ); |
0 | 4944 |
} |
4945 |
||
4946 |
||
4947 |
||
4948 |
||
4949 |
/** |
|
4950 |
@internalComponent |
|
4951 |
*/ |
|
4952 |
// Default implementation |
|
4953 |
EXPORT_C void DMediaDriver::Disconnect(DLocalDrive* aLocalDrive, TThreadMessage* aMsg) |
|
4954 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4955 |
OstTraceFunctionEntryExt( DMEDIADRIVER_DISCONNECT_ENTRY, this ); |
0 | 4956 |
// don't need to worry about DLocalDrive going away |
4957 |
aLocalDrive->Deque(); |
|
4958 |
||
4959 |
aMsg->Complete(KErrNone, EFalse); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4960 |
OstTraceFunctionExit1( DMEDIADRIVER_DISCONNECT_EXIT, this ); |
0 | 4961 |
} |
4962 |
||
4963 |
||
4964 |
||
4965 |
||
4966 |
/** |
|
4967 |
Registers a media driver with the Local Media Subsystem, and provides |
|
4968 |
information about the number of supported drives, partitions, |
|
4969 |
names and drive numbers. |
|
4970 |
||
4971 |
@param aDevice The unique Media ID for this device. |
|
4972 |
This can take one of the enumerated values defined |
|
4973 |
by the TMediaDevice enum. |
|
4974 |
@param aDriveCount Specifies the number of local drive objects to be assigned |
|
4975 |
to the media driver. Drives that support more than one |
|
4976 |
partition must specify a number greater than 1. |
|
4977 |
@param aDriveList A pointer to an array of TInt values, which define |
|
4978 |
the drive numbers that are to be allocated to each partition. |
|
4979 |
0 signifies Drive C, 1 signifies drive D, etc. For example, |
|
4980 |
to allocate drive letters J and K, specify an array |
|
4981 |
containing the values [7,8]. |
|
4982 |
Note that the size of this array must be the same as the value |
|
4983 |
specified by aDriveCount. |
|
4984 |
@param aPrimaryMedia A pointer to the primary DPrimaryMedia object to be |
|
4985 |
associated with the media. This object is responsible for |
|
4986 |
the overall state of the media, i.e. powering up, reading |
|
4987 |
partition information etc. It also has overall control over |
|
4988 |
all partitions as represented by the additional (aNumMedia-1) |
|
4989 |
DMedia objects. |
|
4990 |
@param aNumMedia Specifies the total number of DMedia objects to be |
|
4991 |
associated with the media driver. This number includes the |
|
4992 |
primary DPrimaryMedia object referred to by aPrimaryMedia, |
|
4993 |
plus all of the DMedia objects that are created for each |
|
4994 |
additional drive, and which hold basic information about |
|
4995 |
partitions. |
|
4996 |
@param aName The name of the media driver, for example: PCCard |
|
4997 |
||
4998 |
@return KErrNone, if successful; |
|
4999 |
KErrInUse, if a drive is already in use; |
|
5000 |
KErrNoMemory, if there is insufficient memory; |
|
5001 |
or one of the other system-wide error codes. |
|
5002 |
*/ |
|
5003 |
EXPORT_C TInt LocDrv::RegisterMediaDevice(TMediaDevice aDevice, TInt aDriveCount, const TInt* aDriveList, DPrimaryMediaBase* aPrimaryMedia, TInt aNumMedia, const TDesC& aName) |
|
5004 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5005 |
OstTraceFunctionEntry0( LOCDRV_REGISTERMEDIADEVICE_ENTRY ); |
0 | 5006 |
// Create TLocDrv / DMedia objects to handle a media device |
152
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
5007 |
__KTRACE_OPT(KBOOT,Kern::Printf("RegisterMediaDevice %S dev=%1d #drives=%d 1st=%d PM=%08x #media=%d",&aName,aDevice,aDriveCount,*aDriveList,aPrimaryMedia,aNumMedia)); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5008 |
OstTraceExt5( TRACE_INTERNALS, LOCDRV_REGISTERMEDIADEVICE1, "aDevice=%d; aDriveCount=%d; aDriveList=%d; aPrimaryMedia=0x%08x; aNumMedia=%d", (TInt) aDevice, (TInt) aDriveCount, (TInt) *aDriveList, (TUint) aPrimaryMedia, (TInt) aNumMedia ); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5009 |
|
0 | 5010 |
if (UsedMedia+aNumMedia>KMaxLocalDrives) |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5011 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5012 |
OstTrace0(TRACE_FLOW, LOCDRV_REGISTERMEDIADEVICE_EXIT1, "< KErrInUse"); |
0 | 5013 |
return KErrInUse; |
5014 |
} |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5015 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5016 |
// make a local copy of the name |
0 | 5017 |
HBuf* pN=HBuf::New(aName); |
5018 |
if (!pN) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5019 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5020 |
OstTrace0(TRACE_FLOW, LOCDRV_REGISTERMEDIADEVICE_EXIT3, "< KErrNoMemory"); |
0 | 5021 |
return KErrNoMemory; |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5022 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5023 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5024 |
// Register the primary media and any secondary media |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5025 |
TInt lastMedia = UsedMedia+aNumMedia-1; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5026 |
TInt i; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5027 |
TInt r=0; |
0 | 5028 |
for (i=UsedMedia; i<=lastMedia; ++i) |
5029 |
{ |
|
5030 |
if (i==UsedMedia) |
|
5031 |
TheMedia[i]=aPrimaryMedia; |
|
5032 |
else |
|
5033 |
TheMedia[i]=new DMedia; |
|
5034 |
if (!TheMedia[i]) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5035 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5036 |
OstTrace0(TRACE_FLOW, LOCDRV_REGISTERMEDIADEVICE_EXIT4, "< KErrNoMemory"); |
0 | 5037 |
return KErrNoMemory; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5038 |
} |
0 | 5039 |
r=TheMedia[i]->Create(aDevice,i,lastMedia); |
5040 |
__KTRACE_OPT(KBOOT,Kern::Printf("Media %d Create() returns %d",i,r)); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5041 |
OstTraceExt2( TRACE_INTERNALS, LOCDRV_REGISTERMEDIADEVICE3, "Media=%d Create(); retval=%d", i, r ); |
0 | 5042 |
if (r!=KErrNone) |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5043 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5044 |
OstTrace1(TRACE_FLOW, LOCDRV_REGISTERMEDIADEVICE_EXIT5, "< retval=%d", r); |
0 | 5045 |
return r; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5046 |
} |
0 | 5047 |
} |
5048 |
__KTRACE_OPT(KBOOT,Kern::Printf("FirstMedia %d LastMedia %d",UsedMedia,lastMedia)); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5049 |
OstTraceExt2( TRACE_INTERNALS, LOCDRV_REGISTERMEDIADEVICE4, "FirstMedia=%d; LastMedia=%d", UsedMedia, lastMedia ); |
0 | 5050 |
UsedMedia+=aNumMedia; |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5051 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5052 |
if (__IS_EXTENSION(aDevice)) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5053 |
aPrimaryMedia->iBody->iMediaExtension = ETrue; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5054 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5055 |
// Register the drives |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5056 |
const TInt* p=aDriveList; |
0 | 5057 |
for (i=0; i<aDriveCount; ++i) |
5058 |
{ |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5059 |
TInt drv = *p++; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5060 |
// -1 means not used; this is to enable Dual-slot MMC support |
0 | 5061 |
if (drv == -1) |
5062 |
continue; |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5063 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5064 |
__KTRACE_OPT(KBOOT,Kern::Printf("Registering drive %d", drv)); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5065 |
if (!__IS_EXTENSION(aDevice) && TheDrives[drv]) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5066 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5067 |
__KTRACE_OPT(KBOOT,Kern::Printf("Drive %d already in use", drv)); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5068 |
return KErrInUse; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5069 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5070 |
else if (__IS_EXTENSION(aDevice) && !TheDrives[drv]) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5071 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5072 |
__KTRACE_OPT(KBOOT,Kern::Printf("Drive %d not initialized", drv)); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5073 |
return KErrNotReady; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5074 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5075 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5076 |
TLocDrv* pNewDrive = new TLocDrv(drv); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5077 |
if (!pNewDrive) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5078 |
{ |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5079 |
OstTrace0(TRACE_FLOW, LOCDRV_REGISTERMEDIADEVICE_EXIT6, "< KErrNoMemory"); |
0 | 5080 |
return KErrNoMemory; |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5081 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5082 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5083 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5084 |
TLocDrv* pOldDrive = TheDrives[drv]; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5085 |
aPrimaryMedia->iBody->iRegisteredDriveMask|= (0x1 << drv); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5086 |
pNewDrive->iNextDrive = pOldDrive; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5087 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5088 |
TheDrives[drv] = pNewDrive; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5089 |
DriveNames[drv] = pN; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5090 |
pNewDrive->iPrimaryMedia = aPrimaryMedia; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5091 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5092 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5093 |
if (pOldDrive) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5094 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5095 |
TInt r = pOldDrive->iPrimaryMedia->Connect(pNewDrive); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5096 |
if (r != KErrNone) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5097 |
return r; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5098 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5099 |
#ifdef __DEMAND_PAGING__ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5100 |
// If we've hooked a drive letter which is being used for ROM paging by a media driver |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5101 |
// which does not report the ROM partition, then we need to change iFirstLocalDriveNumber |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5102 |
// so that ROM page-in requests go directly to that driver |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5103 |
DMediaPagingDevice* oldPagingDevice = pOldDrive->iPrimaryMedia->iBody->iPagingDevice; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5104 |
if (oldPagingDevice && |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5105 |
(oldPagingDevice->iType & DPagingDevice::ERom) && |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5106 |
oldPagingDevice->iRomPagingDriveNumber == KErrNotFound && |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5107 |
oldPagingDevice->iFirstLocalDriveNumber == drv) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5108 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5109 |
__KTRACE_OPT2(KBOOT,KLOCDPAGING, Kern::Printf("TRACE: hooking ROM paging device with no defined ROM partition")); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5110 |
TInt n; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5111 |
for (n=0; n<KMaxLocalDrives; ++n) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5112 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5113 |
if(TheDrives[n] && TheDrives[n]->iPrimaryMedia == pOldDrive->iPrimaryMedia) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5114 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5115 |
__KTRACE_OPT2(KBOOT,KLOCDPAGING, Kern::Printf("TRACE: Changing iFirstLocalDriveNumber from %d to %d", oldPagingDevice->iFirstLocalDriveNumber, n)); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5116 |
oldPagingDevice->iFirstLocalDriveNumber = n; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5117 |
break; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5118 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5119 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5120 |
__ASSERT_ALWAYS(n < KMaxLocalDrives, LOCM_FAULT()); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5121 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5122 |
#endif |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5123 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5124 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5125 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5126 |
__KTRACE_OPT(KBOOT,Kern::Printf("Drive %d: TLocDrv @ %08x",drv,pNewDrive)); |
0 | 5127 |
} |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5128 |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5129 |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5130 |
OstTraceFunctionExit0( LOCDRV_REGISTERMEDIADEVICE_EXIT7 ); |
0 | 5131 |
return KErrNone; |
5132 |
} |
|
5133 |
||
5134 |
||
5135 |
||
5136 |
||
5137 |
/** |
|
5138 |
A utility function that is used internally to register the specified |
|
5139 |
password store. |
|
5140 |
||
5141 |
The password store is used to save passwords for local media. |
|
5142 |
||
5143 |
@param aStore A pointer to the password store to be registered. |
|
5144 |
||
5145 |
@return KErrNone, if successful; |
|
5146 |
KErrAlreadyExists, if a password store has already been registered. |
|
5147 |
*/ |
|
5148 |
EXPORT_C TInt LocDrv::RegisterPasswordStore(TPasswordStore* aStore) |
|
5149 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5150 |
OstTraceFunctionEntry0( LOCDRV_REGISTERPASSWORDSTORE_ENTRY ); |
0 | 5151 |
// Create TLocDrv / DMedia objects to handle a media device |
5152 |
__KTRACE_OPT(KBOOT,Kern::Printf("RegisterPasswordStore")); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5153 |
|
0 | 5154 |
TInt r = KErrNone; |
5155 |
||
5156 |
if(ThePasswordStore == NULL) |
|
5157 |
ThePasswordStore = aStore; |
|
5158 |
else |
|
5159 |
r = KErrAlreadyExists; |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5160 |
OstTrace1(TRACE_INTERNALS, LOCDRV_REGISTERPASSWORDSTORE, "retval=%d", r); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5161 |
OstTraceFunctionExit0( LOCDRV_REGISTERPASSWORDSTORE_EXIT ); |
0 | 5162 |
return r; |
5163 |
} |
|
5164 |
||
5165 |
/** |
|
5166 |
Returns a pointer to the registered password store. |
|
5167 |
||
5168 |
The password store is used to save passwords for local media. |
|
5169 |
||
5170 |
@return A pointer to the registered password store. |
|
5171 |
*/ |
|
5172 |
EXPORT_C TPasswordStore* LocDrv::PasswordStore() |
|
5173 |
{ |
|
5174 |
return ThePasswordStore; |
|
5175 |
} |
|
5176 |
||
5177 |
#ifdef __DEMAND_PAGING__ |
|
5178 |
/** |
|
5179 |
Registers a paging device with the Local Media Subsystem, and provides |
|
5180 |
information about drive numbers used in Code Paging. |
|
5181 |
||
5182 |
@param aPrimaryMedia A pointer to the primary DPrimaryMedia object associated |
|
5183 |
with the media. |
|
5184 |
@param aPagingDriveList A pointer to an array of TInt values, which define |
|
5185 |
the drive numbers used as Code backup in Code Paging, which |
|
5186 |
are the target of Page In requests. For NAND these will |
|
5187 |
will be usually associated with ROFS and/or User Data drives. |
|
5188 |
In ROM pagigng systems no drive is specified, it is assumed |
|
5189 |
a fixed media for which no non-primary media exists, will be |
|
5190 |
used. |
|
5191 |
@param aDriveCount Specifies the number of local drives associated with this |
|
5192 |
media device which can be used for code paging. |
|
5193 |
@param aPagingType Identifies the type of Paging this media device is capable |
|
5194 |
of servicing. |
|
5195 |
@param aReadShift Log2 of the read unit size. A read unit is the number of bytes |
|
5196 |
which the device can optimally read from the underlying media. |
|
5197 |
E.g. for small block NAND, a read unit would be equal to the |
|
5198 |
page size, 512 bytes, therefore iReadShift would be set to 9. |
|
5199 |
@param aNumPages The number of pages to alloc for each drive associated with this |
|
5200 |
media driver. The pages are used in request fragmentation. |
|
5201 |
||
5202 |
@return KErrNone, if successful; |
|
5203 |
KErrNotFound, if at least one of the drive numbers |
|
5204 |
specified has not yet been mapped. |
|
5205 |
KErrArgument, if the passed in an invalid argument. |
|
5206 |
KErrNotSupported, if at least one of the drive numbers |
|
5207 |
specifed is not associated with this Primary Media. |
|
5208 |
KErrNoMemory, if there is insufficient memory; |
|
5209 |
or one of the other system-wide error codes. |
|
5210 |
*/ |
|
5211 |
EXPORT_C TInt LocDrv::RegisterPagingDevice(DPrimaryMediaBase* aPrimaryMedia, const TInt* aPagingDriveList, TInt aDriveCount, TUint aPagingType, TInt aReadShift, TUint aNumPages) |
|
5212 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5213 |
OstTraceFunctionEntry0( LOCDRV_REGISTERPAGINGDEVICE_ENTRY ); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5214 |
// SETDEBUGFLAG(KLOCDPAGING); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5215 |
|
0 | 5216 |
__KTRACE_OPT2(KBOOT,KLOCDPAGING,Kern::Printf(">RegisterPagingDevice: paging type=%d PM=0x%x read shift=%d",aPagingType,aPrimaryMedia,aReadShift)); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5217 |
OstTraceDefExt3( OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, LOCDRV_REGISTERPAGINGDEVICE1, "aPagingType=%d; aPrimaryMedia=0x%x; aReadShift=%d", (TInt) aPagingType, (TUint) aPrimaryMedia, (TInt) aReadShift); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5218 |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5219 |
TInt i = 0; |
0 | 5220 |
|
5221 |
if(!aPagingType || (aPagingType&~(DPagingDevice::ERom | DPagingDevice::ECode | DPagingDevice::EData))) |
|
5222 |
{ |
|
5223 |
__KTRACE_OPT2(KBOOT,KLOCDPAGING,Kern::Printf("Unsupported paging type, exiting")); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5224 |
OstTrace0(TRACE_FLOW, LOVDRV_REGISTERPAGINGDEVICE_EXIT1, "< Unsupported paging type; KErrArgument"); |
0 | 5225 |
return KErrArgument; |
5226 |
} |
|
5227 |
||
5228 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5229 |
// Check for duplicate drives |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5230 |
if (!aPrimaryMedia->iBody->iMediaExtension) |
0 | 5231 |
{ |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5232 |
for(i=0; i<KMaxLocalDrives; i++) |
0 | 5233 |
{ |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5234 |
if (ThePagingDevices[i] == NULL) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5235 |
continue; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5236 |
if ((ThePagingDevices[i]->iType&DPagingDevice::ERom) && (aPagingType & DPagingDevice::ERom)) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5237 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5238 |
aPagingType&=~DPagingDevice::ERom; // already have a ROM paging device |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5239 |
__KTRACE_OPT2(KBOOT,KLOCDPAGING,Kern::Printf("Already has ROM pager on locdrv no %d",i)); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5240 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5241 |
if ((ThePagingDevices[i]->iType&DPagingDevice::EData) && (aPagingType & DPagingDevice::EData)) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5242 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5243 |
aPagingType&=~DPagingDevice::EData; // already have a Data paging device |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5244 |
__KTRACE_OPT2(KBOOT,KLOCDPAGING,Kern::Printf("Already has Data pager on locdrv no %d",i)); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5245 |
} |
0 | 5246 |
} |
5247 |
} |
|
5248 |
||
5249 |
||
5250 |
if (aPagingType == 0) |
|
5251 |
{ |
|
5252 |
// there's already a ROM or Data paging device & this doesn't support code paging so quietly exit without further addo |
|
5253 |
__KTRACE_OPT2(KBOOT,KLOCDPAGING,Kern::Printf("Nothing left to register on locdrv no %d, exiting",i)); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5254 |
OstTrace1(TRACE_FLOW, LOVDRV_REGISTERPAGINGDEVICE_EXIT2, "< Nothing left to register on locdrv no %d; KErrNone",i); |
0 | 5255 |
return KErrNone; |
5256 |
} |
|
5257 |
||
5258 |
const TInt* p=aPagingDriveList; |
|
5259 |
if(aPagingType&DPagingDevice::ECode) // supports code paging, do argument check |
|
5260 |
{ |
|
5261 |
if(!aDriveCount || (aDriveCount>=KMaxLocalDrives)) |
|
5262 |
{ |
|
5263 |
__KTRACE_OPT2(KBOOT,KLOCDPAGING,Kern::Printf("Invalid code paging drive count: %d", aDriveCount)); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5264 |
OstTrace1(TRACE_FLOW, LOVDRV_REGISTERPAGINGDEVICE_EXIT3, "< Invalid code paging drive count=%d; KErrArgument", aDriveCount); |
0 | 5265 |
return KErrArgument; |
5266 |
} |
|
5267 |
||
5268 |
TInt drvCount=0; |
|
5269 |
for(i=0; i<KMaxLocalDrives; i++) |
|
5270 |
if(TheDrives[i] && TheDrives[i]->iPrimaryMedia==aPrimaryMedia) |
|
5271 |
drvCount++; |
|
5272 |
if(aDriveCount>drvCount) // can't exceed number of drives registered by this device |
|
5273 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5274 |
__KTRACE_OPT2(KBOOT,KLOCDPAGING,Kern::Printf("Invalid code paging drive count=%d; total=%d", aDriveCount, drvCount)); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5275 |
OstTraceExt2(TRACE_FLOW, LOVDRV_REGISTERPAGINGDEVICE_EXIT4, "< Invalid code paging drive count=%d; total=%d; KErrArgument", aDriveCount, drvCount); |
0 | 5276 |
return KErrArgument; |
5277 |
} |
|
5278 |
||
5279 |
for (i=0; i<aDriveCount; ++i) |
|
5280 |
{ |
|
5281 |
__KTRACE_OPT(KBOOT,Kern::Printf("RegisterPagingDevice: registering drive=%d ",*p)); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5282 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, LOCDRV_REGISTERPAGINGDEVICE2, "Registering Drive=%d", *p ); |
0 | 5283 |
TInt drv=*p++; |
5284 |
if(drv>=KMaxLocalDrives) |
|
5285 |
{ |
|
5286 |
__KTRACE_OPT2(KBOOT,KLOCDPAGING,Kern::Printf("Invalid code paging drive number: %d", drv)); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5287 |
OstTrace1(TRACE_FLOW, LOVDRV_REGISTERPAGINGDEVICE_EXIT5, "< Invalid code paging drive number=%d; KErrArgument", drv); |
0 | 5288 |
return KErrArgument; |
5289 |
} |
|
5290 |
TLocDrv* pD=TheDrives[drv]; |
|
5291 |
if (!pD) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5292 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5293 |
OstTrace0(TRACE_FLOW, LOCRV_REGISTERPAGINGDEVICE_EXIT6, "< KErrNotFound"); |
0 | 5294 |
return KErrNotFound; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5295 |
} |
0 | 5296 |
if (pD->iPrimaryMedia!=aPrimaryMedia) |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5297 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5298 |
OstTrace0(TRACE_FLOW, LOCRV_REGISTERPAGINGDEVICE_EXIT7, "< KErrNotSupported"); |
0 | 5299 |
return KErrNotSupported; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5300 |
} |
0 | 5301 |
} |
5302 |
} |
|
5303 |
||
5304 |
||
5305 |
TInt firstLocalDriveNumber = KErrNotFound; |
|
5306 |
TInt romPagingDriveNumber = KErrNotFound; |
|
5307 |
||
5308 |
TInt dataPagingDriveNumber = KErrNotFound; |
|
5309 |
TInt swapSize = 0; |
|
201
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
5310 |
TInt blockSize = 0; |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
5311 |
TUint16 flags = 0; |
0 | 5312 |
|
5313 |
// find the local drive assocated with the primary media |
|
5314 |
for (i=0; i<KMaxLocalDrives; ++i) |
|
5315 |
{ |
|
5316 |
if(TheDrives[i] && TheDrives[i]->iPrimaryMedia == aPrimaryMedia) |
|
5317 |
{ |
|
5318 |
firstLocalDriveNumber = i; |
|
5319 |
break; |
|
5320 |
} |
|
5321 |
} |
|
5322 |
__ASSERT_ALWAYS(i < KMaxLocalDrives, LOCM_FAULT()); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5323 |
__KTRACE_OPT2(KBOOT,KLOCDPAGING,Kern::Printf("DMediaPagingDevice(), firstLocalDriveNumber %d", firstLocalDriveNumber)); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5324 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, LOCDRV_REGISTERPAGINGDEVICE3, "firstLocalDriveNumber=%d", firstLocalDriveNumber ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5325 |
|
0 | 5326 |
// Send an ECaps message to wake up the media driver & ensure all partitions are |
5327 |
// reported, then search for paged-data or paged-ROM partitions |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5328 |
// NB: older media drivers supporting ROM and/or code paging only may not have started their DFC queues, |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5329 |
// so for these media drivers, use the first local drive supported for ROM-pagin-in requests and |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5330 |
// assume the media driver itself will adjust the request position internally to match the ROM partition |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5331 |
// @see DMediaPagingDevice::Read() |
0 | 5332 |
if ((aPagingType & DPagingDevice::EData) || |
5333 |
(aPagingType & DPagingDevice::ERom && aPrimaryMedia->iDfcQ && aPrimaryMedia->iMsgQ.iReady)) |
|
5334 |
{ |
|
5335 |
// the message queue must have been started already (by the media driver calling iMsgQ.Receive()) |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5336 |
// otherwise we can't send the DLocalDrive::ECaps request |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5337 |
if (!aPrimaryMedia->iDfcQ || !aPrimaryMedia->iMsgQ.iReady) |
0 | 5338 |
{ |
5339 |
__KTRACE_OPT2(KBOOT,KLOCDPAGING,Kern::Printf("RegisterPagingDevice: Message queue not started")); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5340 |
OstTrace0(TRACE_FLOW, LOVDRV_REGISTERPAGINGDEVICE_EXIT8, "< RegisterPagingDevice: Message queue not started; KErrNotReady"); |
0 | 5341 |
return KErrNotReady; |
5342 |
} |
|
5343 |
||
5344 |
||
5345 |
TLocDrvRequest m; |
|
201
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
5346 |
TBuf8<KMaxLocalDriveCapsLength> capsBuf; |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
5347 |
|
0 | 5348 |
memclr(&m, sizeof(m)); |
5349 |
||
5350 |
// Get the Caps from the device. NB for MMC/SD we may need to retry as some PSLs start up |
|
5351 |
// in "door open" or "media not present" state which can result in the cancellation of requests |
|
5352 |
TInt i; |
|
5353 |
const TInt KRetries = 5; |
|
5354 |
TInt r = KErrNotReady; |
|
5355 |
for (i=0; r == KErrNotReady && i < KRetries; i++) |
|
5356 |
{ |
|
5357 |
capsBuf.SetMax(); |
|
5358 |
capsBuf.FillZ(); |
|
5359 |
m.Drive() = TheDrives[firstLocalDriveNumber]; |
|
5360 |
m.Id() = DLocalDrive::ECaps; |
|
5361 |
m.RemoteDes() = (TAny*)capsBuf.Ptr(); // overload this |
|
5362 |
m.Length() = KMaxLocalDriveCapsLength; // for pinning |
|
5363 |
r = aPrimaryMedia->Request(m); |
|
5364 |
||
5365 |
//Kern::Printf("EQueryPageDeviceInfo: i %d: r %d ", i, r); |
|
5366 |
__KTRACE_OPT2(KBOOT,KLOCDPAGING, Kern::Printf("Paging device ECaps: i %d: r %d ", i, r)); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5367 |
OstTraceDefExt2( OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, LOCDRV_REGISTERPAGINGDEVICE4, "Paging device ECaps: i %d retval=%d", i, r); |
0 | 5368 |
} |
5369 |
||
5370 |
if (r != KErrNone) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5371 |
{ |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5372 |
OstTrace1(TRACE_FLOW, LOCRV_REGISTERPAGINGDEVICE_EXIT9, "< retval=%d",r); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
5373 |
// Media driver failure; media maybe recoverable after boot. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
5374 |
// Can't register any page drives so return not supported. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
5375 |
return KErrNotSupported; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5376 |
} |
0 | 5377 |
|
201
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
5378 |
TLocalDriveCapsV6& caps = *(TLocalDriveCapsV6*)capsBuf.Ptr(); |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
5379 |
blockSize = caps.iBlockSize; |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
5380 |
__ASSERT_DEBUG(blockSize,LOCM_FAULT()); |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
5381 |
__ASSERT_DEBUG(__e32_bit_count_32(blockSize)==1,LOCM_FAULT()); |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
5382 |
|
0 | 5383 |
TLocDrv* drive; |
5384 |
for (i=0; i<KMaxLocalDrives; ++i) |
|
5385 |
{ |
|
5386 |
drive = TheDrives[i]; |
|
5387 |
if(drive && drive->iPrimaryMedia == aPrimaryMedia) |
|
5388 |
{ |
|
152
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
5389 |
__KTRACE_OPT2(KBOOT,KLOCDPAGING, Kern::Printf("RegisterPagingDevice: local drive %d, partition type %x base %lx size %lx name %S", i, drive->iPartitionType, drive->iPartitionBaseAddr, drive->iPartitionLen, DriveNames[i] ? DriveNames[i] : &KNullDesC8)); |
0 | 5390 |
// ROM partition ? |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5391 |
if ((romPagingDriveNumber == KErrNotFound) && |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5392 |
(drive->iPartitionType == KPartitionTypeROM) && |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5393 |
(aPagingType & DPagingDevice::ERom)) |
0 | 5394 |
{ |
5395 |
__KTRACE_OPT2(KBOOT,KLOCDPAGING, Kern::Printf("Found ROM partition on local drive %d, size %x", i, I64LOW(drive->iPartitionLen))); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5396 |
OstTraceDefExt2( OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, LOCDRV_REGISTERPAGINGDEVICE5, "Found ROM partition on local drive=%d; size=0x%x", (TInt) i, (TUint) I64LOW(drive->iPartitionLen)); |
0 | 5397 |
romPagingDriveNumber = i; |
5398 |
} |
|
5399 |
// swap partition ? |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5400 |
else if ((dataPagingDriveNumber == KErrNotFound) && |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5401 |
(drive->iPartitionType == KPartitionTypePagedData) && |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5402 |
(aPagingType & DPagingDevice::EData)) |
0 | 5403 |
{ |
5404 |
__KTRACE_OPT2(KBOOT,KLOCDPAGING, Kern::Printf("Found swap partition on local drive %d, size %x", i, I64LOW(drive->iPartitionLen))); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5405 |
OstTraceDefExt2( OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, LOCDRV_REGISTERPAGINGDEVICE6, "Found SWAP partition on local drive=%d; size=0x%x", (TInt) i, (TUint) I64LOW(drive->iPartitionLen) ); |
0 | 5406 |
dataPagingDriveNumber = i; |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5407 |
TheDataPagingDrive = drive; |
0 | 5408 |
swapSize = drive->iPartitionLen >> aReadShift; |
201
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
5409 |
|
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
5410 |
// Mark Paging Device capable of utilising physical addresss only accesses |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
5411 |
if (drive->iDmaHelper) |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
5412 |
flags |= DPagingDevice::ESupportsPhysicalAccess; |
0 | 5413 |
} |
5414 |
} |
|
5415 |
} |
|
5416 |
||
5417 |
if (swapSize == 0) |
|
5418 |
{ |
|
5419 |
__KTRACE_OPT2(KBOOT,KLOCDPAGING, Kern::Printf("Disabling data paging")); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5420 |
OstTraceDef0(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, LOCDRV_REGISTERPAGINGDEVICE7, "Disabling data paging"); |
0 | 5421 |
aPagingType &= ~DPagingDevice::EData; |
5422 |
} |
|
5423 |
||
5424 |
} |
|
5425 |
||
5426 |
||
5427 |
// create and set up a DPagingDevice to allow PageIn request servicing |
|
5428 |
DMediaPagingDevice* pagingDevice = new DMediaPagingDevice(aPrimaryMedia); |
|
5429 |
if(!pagingDevice) |
|
5430 |
{ |
|
5431 |
__KTRACE_OPT2(KBOOT,KLOCDPAGING,Kern::Printf("RegisterPagingDevice: could not create paging device")); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5432 |
OstTrace0(TRACE_FLOW, LOVDRV_REGISTERPAGINGDEVICE_EXIT_EXIT10, "< RegisterPagingDevice: could not create paging device; KErrNoMemory"); |
0 | 5433 |
return KErrNoMemory; |
5434 |
} |
|
5435 |
||
5436 |
pagingDevice->iType = aPagingType; |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5437 |
if (aPrimaryMedia->iBody->iMediaExtension) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5438 |
pagingDevice->iType|= DPagingDevice::EMediaExtension; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5439 |
|
0 | 5440 |
pagingDevice->iReadUnitShift = aReadShift; |
5441 |
||
5442 |
pagingDevice->iFirstLocalDriveNumber = firstLocalDriveNumber; |
|
5443 |
pagingDevice->iRomPagingDriveNumber = romPagingDriveNumber; |
|
5444 |
||
5445 |
pagingDevice->iDataPagingDriveNumber = dataPagingDriveNumber; |
|
5446 |
pagingDevice->iSwapSize = swapSize; |
|
201
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
5447 |
|
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
5448 |
pagingDevice->iPreferredWriteShift = (blockSize) ? __e32_find_ms1_32(blockSize) : 0; |
0 | 5449 |
|
5450 |
#ifdef __DEBUG_DEMAND_PAGING__ |
|
5451 |
Kern::Printf("PagingDevice :"); |
|
152
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
5452 |
Kern::Printf("Name %S", firstLocalDriveNumber >= 0 && DriveNames[firstLocalDriveNumber] ? DriveNames[firstLocalDriveNumber] : &KNullDesC8); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5453 |
Kern::Printf("iType 0x%x", pagingDevice->iType); |
201
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
5454 |
Kern::Printf("iFlags 0x%x\n", pagingDevice->iFlags); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5455 |
Kern::Printf("iReadUnitShift 0x%x", pagingDevice->iReadUnitShift); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5456 |
Kern::Printf("iFirstLocalDriveNumber 0x%x", pagingDevice->iFirstLocalDriveNumber); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5457 |
Kern::Printf("iRomPagingDriveNumber 0x%x", pagingDevice->iRomPagingDriveNumber); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5458 |
Kern::Printf("iDataPagingDriveNumber 0x%x", pagingDevice->iDataPagingDriveNumber); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5459 |
Kern::Printf("iSwapSize 0x%x", pagingDevice->iSwapSize); |
201
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
200
diff
changeset
|
5460 |
Kern::Printf("iPreferredWriteShift 0x%x\n", pagingDevice->iPreferredWriteShift); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
5461 |
#endif |
0 | 5462 |
|
5463 |
||
5464 |
// This table is indexed by DPagingDevice::TType |
|
5465 |
const char* DeviceName[] = |
|
5466 |
{ |
|
5467 |
"Error", |
|
5468 |
"RomPagingDevice", |
|
5469 |
"CodePagingDevice", |
|
5470 |
"RomAndCodePagingDevice", |
|
5471 |
"DataPagingDevice", |
|
5472 |
"RomAndDataPagingDevice", |
|
5473 |
"CodeAndDataPagingDevice", |
|
5474 |
"RomAndCodeAndDataPagingDevice" |
|
5475 |
}; |
|
5476 |
||
5477 |
||
5478 |
if(aPagingType & DPagingDevice::ECode) |
|
5479 |
{ |
|
5480 |
for (i=0; i<aDriveCount; ++i) |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5481 |
pagingDevice->iDrivesSupported |= (0x1<<aPagingDriveList[i]); |
0 | 5482 |
} |
5483 |
pagingDevice->iName = DeviceName[aPagingType]; |
|
5484 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5485 |
// If ThePinObjectAllocator has already been created with a smaller number of pages, |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5486 |
// delete it & then re-create it |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5487 |
__KTRACE_OPT2(KBOOT,KLOCDPAGING,Kern::Printf("RegisterPagingDevice: ThePinObjectAllocator %x", ThePinObjectAllocator)); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5488 |
if (ThePinObjectAllocator && ThePinObjectAllocator->iFragmentGranularity < Kern::RoundToPageSize(1) * aNumPages) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5489 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5490 |
__KTRACE_OPT2(KBOOT,KLOCDPAGING,Kern::Printf("RegisterPagingDevice: Recreating ThePinObjectAllocator...")); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5491 |
delete ThePinObjectAllocator; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5492 |
ThePinObjectAllocator = NULL; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5493 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5494 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5495 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5496 |
TInt r; |
0 | 5497 |
if (ThePinObjectAllocator == NULL) |
5498 |
{ |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5499 |
ThePinObjectAllocator = new DPinObjectAllocator(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5500 |
if(!ThePinObjectAllocator) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5501 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5502 |
__KTRACE_OPT2(KBOOT,KLOCDPAGING,Kern::Printf("RegisterPagingDevice: could not create ThePinObjectAllocator")); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5503 |
OstTrace0(TRACE_FLOW, LOVDRV_REGISTERPAGINGDEVICE_EXIT11, "RegisterPagingDevice: could not create ThePinObjectAllocator; KErrNoMemory"); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5504 |
return KErrNoMemory; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5505 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5506 |
r = ThePinObjectAllocator->Construct(KDynamicPagingLockCount, aNumPages); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5507 |
if (r != KErrNone) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5508 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5509 |
__KTRACE_OPT2(KBOOT,KLOCDPAGING,Kern::Printf("RegisterPagingDevice: could not construct ThePinObjectAllocator")); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5510 |
OstTrace1(TRACE_FLOW, LOVDRV_REGISTERPAGINGDEVICE_EXIT12, "< RegisterPagingDevice: could not construct ThePinObjectAllocator; retval=%d",r); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5511 |
return r; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5512 |
} |
0 | 5513 |
} |
5514 |
||
5515 |
||
5516 |
// Register our DPagingDevice with the Kernel |
|
5517 |
r=Kern::InstallPagingDevice(pagingDevice); |
|
5518 |
||
5519 |
#ifdef __DEBUG_DEMAND_PAGING__ |
|
5520 |
Kern::Printf("Kern::InstallPagingDevice() r %d", r); |
|
5521 |
#endif |
|
5522 |
||
5523 |
if (r!=KErrNone) |
|
5524 |
{ |
|
5525 |
__KTRACE_OPT2(KBOOT,KLOCDPAGING,Kern::Printf("RegisterPagingDevice: could not install paging device")); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5526 |
OstTrace1(TRACE_FLOW, LOVDRV_REGISTERPAGINGDEVICE_EXIT13, "< RegisterPagingDevice: could not install paging device; retval=%d", r); |
0 | 5527 |
delete pagingDevice; |
5528 |
return r; |
|
5529 |
} |
|
5530 |
||
5531 |
// all hunky dory, save paging device and mark our media as pageable |
|
5532 |
ThePagingDevices[aPrimaryMedia->iMediaId] = pagingDevice; // association created between PrimaryMedia and PagingDevice via iMediaId |
|
5533 |
aPrimaryMedia->iPagingMedia = 1; |
|
5534 |
||
5535 |
// mark our drives as pageable |
|
5536 |
p=aPagingDriveList; |
|
5537 |
if (aPagingType&DPagingDevice::ECode) |
|
5538 |
{ |
|
5539 |
for (i=0; i<aDriveCount; ++i) |
|
5540 |
{ |
|
5541 |
TLocDrv* pD=TheDrives[*p++]; |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5542 |
pD->iPagingDrv = 1; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5543 |
// mark all attached drives as pageable too - this is really |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5544 |
// only to avoid hitting an ASSERT in DMediaDriver::Complete() |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5545 |
while (pD->iNextDrive) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5546 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5547 |
pD->iNextDrive->iPagingDrv = 1; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5548 |
pD = pD->iNextDrive; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5549 |
} |
0 | 5550 |
} |
5551 |
} |
|
5552 |
||
5553 |
// Flags to indicate that a paging device is registered and pinning of user requests may be required |
|
5554 |
aPrimaryMedia->iPagingMedia = 1; |
|
5555 |
||
5556 |
// point the primary media to the paging device |
|
5557 |
aPrimaryMedia->iBody->iPagingDevice = pagingDevice; |
|
5558 |
||
5559 |
if (aPagingType & DPagingDevice::ERom) |
|
5560 |
{ |
|
5561 |
aPrimaryMedia->iRomPagingMedia = 1; |
|
5562 |
TheRomPagingMedia = aPrimaryMedia; |
|
5563 |
} |
|
5564 |
||
5565 |
// Is data paging enabled in this ROM ? |
|
5566 |
TInt memModelAttributes = Kern::HalFunction(EHalGroupKernel, EKernelHalMemModelInfo, NULL, NULL); |
|
5567 |
TBool dataPagingSupported = memModelAttributes & EMemModelAttrDataPaging; |
|
5568 |
#ifdef __DEBUG_DEMAND_PAGING__ |
|
5569 |
Kern::Printf("memModelAttributes %08X", memModelAttributes); |
|
5570 |
Kern::Printf("DataPagingSupported %d", dataPagingSupported); |
|
5571 |
#endif |
|
5572 |
if (!dataPagingSupported) |
|
5573 |
{ |
|
5574 |
#ifdef __DEBUG_DEMAND_PAGING__ |
|
5575 |
if (aPagingType & DPagingDevice::EData) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5576 |
{ |
0 | 5577 |
Kern::Printf("Disabling data paging, not supported in this ROM"); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5578 |
} |
0 | 5579 |
#endif |
5580 |
aPagingType&= ~DPagingDevice::EData; |
|
5581 |
} |
|
5582 |
||
5583 |
||
5584 |
if (aPagingType & DPagingDevice::EData) |
|
5585 |
{ |
|
5586 |
DataPagingDeviceRegistered = ETrue; |
|
5587 |
aPrimaryMedia->iDataPagingMedia = 1; |
|
5588 |
TheDataPagingMedia = aPrimaryMedia; |
|
5589 |
} |
|
5590 |
||
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5591 |
__KTRACE_OPT2(KBOOT,KLOCDPAGING,Kern::Printf("< RegisterPagingDevice")); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5592 |
OstTraceFunctionExit0( LOCDRV_REGISTERPAGINGDEVICE_EXIT14 ); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5593 |
// CLRDEBUGFLAG(KLOCDPAGING); |
0 | 5594 |
return KErrNone; |
5595 |
} |
|
5596 |
||
5597 |
#else //__DEMAND_PAGING__ |
|
5598 |
||
5599 |
#if !defined(__WINS__) |
|
5600 |
EXPORT_C TInt LocDrv::RegisterPagingDevice(DPrimaryMediaBase* , const TInt* , TInt , TUint , TInt , TUint ) |
|
5601 |
{ |
|
5602 |
return KErrNotSupported; |
|
5603 |
} // stub for def file |
|
5604 |
#endif // __WINS__ |
|
5605 |
||
5606 |
#endif //__DEMAND_PAGING__ |
|
5607 |
||
5608 |
||
5609 |
/** |
|
5610 |
Registers a media device with physical memory addressing capabilities with the |
|
5611 |
Local Media Subsystem. |
|
5612 |
||
5613 |
@param aPrimaryMedia A pointer to the primary DPrimaryMedia object associated |
|
5614 |
with the media device. |
|
5615 |
@param aMediaBlockSize The Minimum transfer size (bytes) for the media device. |
|
5616 |
@param aDmaMaxAddressable The Maximum Addressing Range for the media device's DMA controller, 0 if None. |
|
5617 |
@param aDmaAlignment The required memory alignment for the media device's DMA controller. |
|
5618 |
||
5619 |
@return KErrNone, Always; |
|
5620 |
*/ |
|
5621 |
EXPORT_C TInt LocDrv::RegisterDmaDevice(DPrimaryMediaBase* aPrimaryMedia, |
|
5622 |
TInt aMediaBlockSize, // Minimum transfer size (bytes) for the media |
|
5623 |
TInt aDmaMaxAddressable, // Max Addressing Range for DMA controller, 0 if None. |
|
5624 |
TInt aDmaAlignment) // DMA Alignment e.g. word alignment required = 2 |
|
5625 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5626 |
OstTraceFunctionEntry0( LOCDRV_REGISTERDMADEVICE_ENTRY ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5627 |
|
0 | 5628 |
__KTRACE_OPT(KBOOT ,Kern::Printf("RegisterPhysicalAddrDevice: PM=0x%x BS=%d MaxAddr=%d DMA=%d", |
5629 |
aPrimaryMedia, aMediaBlockSize, aDmaMaxAddressable, aDmaAlignment)); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5630 |
OstTraceExt4( TRACE_INTERNALS, LOCDRV_REGISTERDMADEVICE, "aPrimaryMedia=0x%x; aMediaBlockSize=%d; aDmaMaxAddressable=%d; aDmaAlignment=%d", (TUint) aPrimaryMedia, (TInt) aMediaBlockSize, (TInt) aDmaMaxAddressable, (TInt) aDmaAlignment ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5631 |
|
0 | 5632 |
for (TInt i=0; i<KMaxLocalDrives; ++i) |
5633 |
{ |
|
5634 |
TLocDrv* pL=TheDrives[i]; |
|
5635 |
if (pL && pL->iPrimaryMedia == aPrimaryMedia && pL->iDmaHelper == NULL) |
|
5636 |
{ |
|
5637 |
pL->iDmaHelper = new DDmaHelper; |
|
5638 |
__ASSERT_ALWAYS(pL != NULL, LOCM_FAULT()); |
|
5639 |
||
5640 |
// if no limit stated on addressing range use 1MB |
|
5641 |
TInt MaxAddress = aDmaMaxAddressable ? (1024*1024) : aDmaMaxAddressable; |
|
5642 |
||
5643 |
TInt r = pL->iDmaHelper->Construct(MaxAddress, aMediaBlockSize, aDmaAlignment); |
|
5644 |
__ASSERT_ALWAYS(r == KErrNone, LOCM_FAULT()); |
|
5645 |
} |
|
5646 |
} |
|
5647 |
||
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5648 |
OstTraceFunctionExit0( LOCDRV_REGISTERDMADEVICE_EXIT ); |
0 | 5649 |
return KErrNone; |
5650 |
} |
|
5651 |
||
5652 |
void GetDriveInfo(TDriveInfoV1& info) |
|
5653 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5654 |
OstTraceFunctionEntry1( GETDRIVEINFO_ENTRY, ( TUint )&( info ) ); |
0 | 5655 |
TInt i; |
5656 |
TInt drives=0; |
|
5657 |
TUint32 sock_mask=0; |
|
5658 |
TInt sockets=0; |
|
5659 |
||
5660 |
info.iRegisteredDriveBitmask = 0; |
|
5661 |
||
5662 |
for (i=0; i<KMaxPBusSockets; ++i) |
|
5663 |
info.iSocketName[i].Zero(); |
|
5664 |
for (i=0; i<KMaxLocalDrives; ++i) |
|
5665 |
{ |
|
5666 |
TLocDrv* pL=TheDrives[i]; |
|
5667 |
if (pL) |
|
5668 |
{ |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5669 |
pL = TDriveIterator::GetPhysicalDrive(TheDrives[i]); |
0 | 5670 |
++drives; |
5671 |
TInt sockNum; |
|
5672 |
DPrimaryMediaBase* pM=pL->iPrimaryMedia; |
|
5673 |
if (pM->IsRemovableDevice(sockNum)) |
|
5674 |
{ |
|
5675 |
if (!(sock_mask & (1<<sockNum))) |
|
5676 |
{ |
|
5677 |
info.iSocketName[sockNum]=*DriveNames[i]; |
|
152
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
5678 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("Socket %d device %d name %S", sockNum, pM->iDevice, DriveNames[i])); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5679 |
OstTraceExt2( TRACE_INTERNALS, GETDRIVEINFO1, "Socket=%d; device=%d", sockNum, (TUint) pM->iDevice ); |
0 | 5680 |
if ( (sockNum + 1) > sockets ) |
5681 |
sockets = sockNum + 1; |
|
5682 |
} |
|
5683 |
sock_mask |= (1<<sockNum); |
|
5684 |
} |
|
5685 |
info.iDriveName[i]=*DriveNames[i]; |
|
152
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
5686 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("Drive %d device %d name %S",i,pM->iDevice,DriveNames[i])); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5687 |
OstTraceExt2( TRACE_INTERNALS, GETDRIVEINFO2, "Drive=%d; device=%d", i, (TUint) pM->iDevice ); |
0 | 5688 |
|
5689 |
info.iRegisteredDriveBitmask |= (0x01 << i); |
|
5690 |
} |
|
5691 |
} |
|
5692 |
info.iTotalSupportedDrives=drives; |
|
5693 |
info.iTotalSockets=sockets; |
|
5694 |
info.iRuggedFileSystem=ETrue; |
|
5695 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("Total drives=%d, sockets=%d",drives,sockets)); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5696 |
OstTraceExt2( TRACE_INTERNALS, GETDRIVEINFO3, "Total drives=%d; sockets=%d", drives, sockets ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5697 |
OstTraceFunctionExit0( GETDRIVEINFO_EXIT ); |
0 | 5698 |
} |
5699 |
||
5700 |
#if defined(__DEMAND_PAGING__) && defined(__CONCURRENT_PAGING_INSTRUMENTATION__) |
|
5701 |
void ResetConcurrencyStats(DMediaPagingDevice* aDevice, TMediaPagingStats aStats) |
|
5702 |
{ |
|
5703 |
NKern::FMWait(&aDevice->iInstrumentationLock); |
|
5704 |
switch(aStats) |
|
5705 |
{ |
|
5706 |
case EMediaPagingStatsRom: |
|
5707 |
aDevice->iServicingROM=0; |
|
5708 |
memclr(&aDevice->iROMStats,sizeof(SMediaROMPagingConcurrencyInfo)); |
|
5709 |
break; |
|
5710 |
case EMediaPagingStatsCode: |
|
5711 |
aDevice->iServicingCode=0; |
|
5712 |
memclr(&aDevice->iCodeStats,sizeof(SMediaCodePagingConcurrencyInfo)); |
|
5713 |
break; |
|
5714 |
case EMediaPagingStatsDataIn: |
|
5715 |
aDevice->iServicingDataIn=0; |
|
5716 |
memclr(&aDevice->iDataStats,sizeof(SMediaDataPagingConcurrencyInfo)); |
|
5717 |
break; |
|
5718 |
case EMediaPagingStatsDataOut: |
|
5719 |
aDevice->iServicingDataOut=0; |
|
5720 |
memclr(&aDevice->iDataStats,sizeof(SMediaDataPagingConcurrencyInfo)); |
|
5721 |
break; |
|
5722 |
case EMediaPagingStatsAll: |
|
5723 |
aDevice->iServicingROM=0; |
|
5724 |
aDevice->iServicingCode=0; |
|
5725 |
aDevice->iServicingDataIn=0; |
|
5726 |
aDevice->iServicingDataOut=0; |
|
5727 |
memclr(&aDevice->iROMStats,sizeof(SMediaROMPagingConcurrencyInfo)); |
|
5728 |
memclr(&aDevice->iCodeStats,sizeof(SMediaCodePagingConcurrencyInfo)); |
|
5729 |
memclr(&aDevice->iDataStats,sizeof(SMediaDataPagingConcurrencyInfo)); |
|
5730 |
break; |
|
5731 |
} |
|
5732 |
NKern::FMSignal(&aDevice->iInstrumentationLock); |
|
5733 |
} |
|
5734 |
#endif |
|
5735 |
#if defined(__DEMAND_PAGING__) && defined(__DEMAND_PAGING_BENCHMARKS__) |
|
5736 |
void ResetBenchmarkStats(DMediaPagingDevice* aDevice, TMediaPagingStats aStats) |
|
5737 |
{ |
|
5738 |
NKern::FMWait(&aDevice->iInstrumentationLock); |
|
5739 |
switch(aStats) |
|
5740 |
{ |
|
5741 |
case EMediaPagingStatsRom: |
|
5742 |
aDevice->iROMBenchmarkData.iCount = 0; |
|
5743 |
aDevice->iROMBenchmarkData.iTotalTime = 0; |
|
5744 |
aDevice->iROMBenchmarkData.iMaxTime = 0; |
|
5745 |
aDevice->iROMBenchmarkData.iMinTime = KMaxTInt; |
|
5746 |
break; |
|
5747 |
case EMediaPagingStatsCode: |
|
5748 |
aDevice->iCodeBenchmarkData.iCount = 0; |
|
5749 |
aDevice->iCodeBenchmarkData.iTotalTime = 0; |
|
5750 |
aDevice->iCodeBenchmarkData.iMaxTime = 0; |
|
5751 |
aDevice->iCodeBenchmarkData.iMinTime = KMaxTInt; |
|
5752 |
break; |
|
5753 |
case EMediaPagingStatsDataIn: |
|
5754 |
aDevice->iDataInBenchmarkData.iCount = 0; |
|
5755 |
aDevice->iDataInBenchmarkData.iTotalTime = 0; |
|
5756 |
aDevice->iDataInBenchmarkData.iMaxTime = 0; |
|
5757 |
aDevice->iDataInBenchmarkData.iMinTime = KMaxTInt; |
|
5758 |
break; |
|
5759 |
case EMediaPagingStatsDataOut: |
|
5760 |
aDevice->iDataOutBenchmarkData.iCount = 0; |
|
5761 |
aDevice->iDataOutBenchmarkData.iTotalTime = 0; |
|
5762 |
aDevice->iDataOutBenchmarkData.iMaxTime = 0; |
|
5763 |
aDevice->iDataOutBenchmarkData.iMinTime = KMaxTInt; |
|
5764 |
break; |
|
5765 |
case EMediaPagingStatsAll: |
|
5766 |
aDevice->iDataInBenchmarkData.iCount = 0; |
|
5767 |
aDevice->iDataInBenchmarkData.iTotalTime = 0; |
|
5768 |
aDevice->iDataInBenchmarkData.iMaxTime = 0; |
|
5769 |
aDevice->iDataInBenchmarkData.iMinTime = KMaxTInt; |
|
5770 |
||
5771 |
aDevice->iDataOutBenchmarkData.iCount = 0; |
|
5772 |
aDevice->iDataOutBenchmarkData.iTotalTime = 0; |
|
5773 |
aDevice->iDataOutBenchmarkData.iMaxTime = 0; |
|
5774 |
aDevice->iDataOutBenchmarkData.iMinTime = KMaxTInt; |
|
5775 |
||
5776 |
aDevice->iROMBenchmarkData.iCount = 0; |
|
5777 |
aDevice->iROMBenchmarkData.iTotalTime = 0; |
|
5778 |
aDevice->iROMBenchmarkData.iMaxTime = 0; |
|
5779 |
aDevice->iROMBenchmarkData.iMinTime = KMaxTInt; |
|
5780 |
||
5781 |
aDevice->iCodeBenchmarkData.iCount = 0; |
|
5782 |
aDevice->iCodeBenchmarkData.iTotalTime = 0; |
|
5783 |
aDevice->iCodeBenchmarkData.iMaxTime = 0; |
|
5784 |
aDevice->iCodeBenchmarkData.iMinTime = KMaxTInt; |
|
5785 |
break; |
|
5786 |
} |
|
5787 |
NKern::FMSignal(&aDevice->iInstrumentationLock); |
|
5788 |
} |
|
5789 |
#endif |
|
5790 |
||
5791 |
TInt MediaHalFunction(TAny*, TInt aFunction, TAny* a1, TAny* a2) |
|
5792 |
{ |
|
5793 |
TInt r=KErrNotSupported; |
|
5794 |
switch (aFunction) |
|
5795 |
{ |
|
5796 |
case EMediaHalDriveInfo: |
|
5797 |
{ |
|
5798 |
(void) a2; |
|
5799 |
TDriveInfoV1Buf infoBuf; |
|
5800 |
TDriveInfoV1& info=infoBuf(); |
|
5801 |
GetDriveInfo(info); |
|
5802 |
Kern::InfoCopy(*(TDes8*)a1,infoBuf); |
|
5803 |
r=KErrNone; |
|
5804 |
break; |
|
5805 |
} |
|
5806 |
#if defined(__DEMAND_PAGING__) && defined(__CONCURRENT_PAGING_INSTRUMENTATION__) |
|
5807 |
case EMediaHalGetROMConcurrencyInfo: |
|
5808 |
{ |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5809 |
DMediaPagingDevice* device = TDriveIterator::PagingDevice((TInt)a1, DPagingDevice::ERom); |
0 | 5810 |
if(!device) |
5811 |
break; |
|
5812 |
NKern::FMWait(&device->iInstrumentationLock); |
|
5813 |
SMediaROMPagingConcurrencyInfo info=device->iROMStats; |
|
5814 |
NKern::FMSignal(&device->iInstrumentationLock); |
|
5815 |
kumemput32(a2,&info,sizeof(info)); |
|
5816 |
r=KErrNone; |
|
5817 |
break; |
|
5818 |
} |
|
5819 |
case EMediaHalGetCodeConcurrencyInfo: |
|
5820 |
{ |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5821 |
DMediaPagingDevice* device = TDriveIterator::PagingDevice((TInt)a1, DPagingDevice::ECode); |
0 | 5822 |
if(!device) |
5823 |
break; |
|
5824 |
NKern::FMWait(&device->iInstrumentationLock); |
|
5825 |
SMediaCodePagingConcurrencyInfo info=device->iCodeStats; |
|
5826 |
NKern::FMSignal(&device->iInstrumentationLock); |
|
5827 |
kumemput32(a2,&info,sizeof(info)); |
|
5828 |
r=KErrNone; |
|
5829 |
break; |
|
5830 |
} |
|
5831 |
case EMediaHalGetDataConcurrencyInfo: |
|
5832 |
{ |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5833 |
DMediaPagingDevice* device = TDriveIterator::PagingDevice((TInt)a1, DPagingDevice::EData); |
0 | 5834 |
if(!device) |
5835 |
break; |
|
5836 |
NKern::FMWait(&device->iInstrumentationLock); |
|
5837 |
SMediaDataPagingConcurrencyInfo info=device->iDataStats; |
|
5838 |
NKern::FMSignal(&device->iInstrumentationLock); |
|
5839 |
kumemput32(a2,&info,sizeof(info)); |
|
5840 |
r=KErrNone; |
|
5841 |
break; |
|
5842 |
} |
|
5843 |
case EMediaHalResetConcurrencyInfo: |
|
5844 |
{ |
|
5845 |
TUint index=(TInt)a2; |
|
5846 |
if(index>EMediaPagingStatsCode) |
|
5847 |
break; |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5848 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5849 |
DMediaPagingDevice* device = TDriveIterator::PagingDevice((TInt)a1, DPagingDevice::ERom); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5850 |
if (device) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5851 |
ResetConcurrencyStats(device, (TMediaPagingStats)index); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5852 |
device = TDriveIterator::PagingDevice((TInt)a1, DPagingDevice::ECode); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5853 |
if (device) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5854 |
ResetConcurrencyStats(device, (TMediaPagingStats)index); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5855 |
device = TDriveIterator::PagingDevice((TInt)a1, DPagingDevice::EData); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5856 |
if (device) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5857 |
ResetConcurrencyStats(device, (TMediaPagingStats)index); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5858 |
|
0 | 5859 |
r=KErrNone; |
5860 |
break; |
|
5861 |
} |
|
5862 |
#endif |
|
5863 |
#if defined(__DEMAND_PAGING__) && defined(__DEMAND_PAGING_BENCHMARKS__) |
|
5864 |
case EMediaHalGetROMPagingBenchmark: |
|
5865 |
{ |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5866 |
DMediaPagingDevice* device = TDriveIterator::PagingDevice((TInt)a1, DPagingDevice::ERom); |
0 | 5867 |
if(!device) |
5868 |
break; |
|
5869 |
NKern::FMWait(&device->iInstrumentationLock); |
|
5870 |
SPagingBenchmarkInfo info = device->iROMBenchmarkData; |
|
5871 |
NKern::FMSignal(&device->iInstrumentationLock); |
|
5872 |
kumemput32(a2,&info,sizeof(info)); |
|
5873 |
r=KErrNone; |
|
5874 |
break; |
|
5875 |
} |
|
5876 |
case EMediaHalGetCodePagingBenchmark: |
|
5877 |
{ |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5878 |
DMediaPagingDevice* device = TDriveIterator::PagingDevice((TInt)a1, DPagingDevice::ECode); |
0 | 5879 |
if(!device) |
5880 |
break; |
|
5881 |
NKern::FMWait(&device->iInstrumentationLock); |
|
5882 |
SPagingBenchmarkInfo info = device->iCodeBenchmarkData; |
|
5883 |
NKern::FMSignal(&device->iInstrumentationLock); |
|
5884 |
kumemput32(a2,&info,sizeof(info)); |
|
5885 |
r=KErrNone; |
|
5886 |
break; |
|
5887 |
} |
|
5888 |
case EMediaHalGetDataInPagingBenchmark: |
|
5889 |
{ |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5890 |
DMediaPagingDevice* device = TDriveIterator::PagingDevice((TInt)a1, DPagingDevice::EData); |
0 | 5891 |
if(!device) |
5892 |
break; |
|
5893 |
NKern::FMWait(&device->iInstrumentationLock); |
|
5894 |
SPagingBenchmarkInfo info = device->iDataInBenchmarkData; |
|
5895 |
NKern::FMSignal(&device->iInstrumentationLock); |
|
5896 |
kumemput32(a2,&info,sizeof(info)); |
|
5897 |
r=KErrNone; |
|
5898 |
break; |
|
5899 |
} |
|
5900 |
case EMediaHalGetDataOutPagingBenchmark: |
|
5901 |
{ |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5902 |
DMediaPagingDevice* device = TDriveIterator::PagingDevice((TInt)a1, DPagingDevice::EData); |
0 | 5903 |
if(!device) |
5904 |
break; |
|
5905 |
NKern::FMWait(&device->iInstrumentationLock); |
|
5906 |
SPagingBenchmarkInfo info = device->iDataOutBenchmarkData; |
|
5907 |
NKern::FMSignal(&device->iInstrumentationLock); |
|
5908 |
kumemput32(a2,&info,sizeof(info)); |
|
5909 |
r=KErrNone; |
|
5910 |
break; |
|
5911 |
} |
|
5912 |
case EMediaHalResetPagingBenchmark: |
|
5913 |
{ |
|
5914 |
TUint index=(TInt)a2; |
|
5915 |
if(index>EMediaPagingStatsCode) |
|
5916 |
break; |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5917 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5918 |
DMediaPagingDevice* device = TDriveIterator::PagingDevice((TInt)a1, DPagingDevice::ERom); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5919 |
if (device) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5920 |
ResetBenchmarkStats(device, (TMediaPagingStats)index); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5921 |
device = TDriveIterator::PagingDevice((TInt)a1, DPagingDevice::ECode); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5922 |
if (device) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5923 |
ResetBenchmarkStats(device, (TMediaPagingStats)index); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5924 |
device = TDriveIterator::PagingDevice((TInt)a1, DPagingDevice::EData); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5925 |
if (device) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5926 |
ResetBenchmarkStats(device, (TMediaPagingStats)index); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5927 |
|
0 | 5928 |
r=KErrNone; |
5929 |
break; |
|
5930 |
} |
|
5931 |
case EMediaHalGetPagingInfo: |
|
5932 |
{ |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5933 |
DMediaPagingDevice* device = TDriveIterator::PagingDevice((TInt)a1, (DPagingDevice::TType) 0xFF); |
0 | 5934 |
if(!device) |
5935 |
break; |
|
5936 |
NKern::FMWait(&device->iInstrumentationLock); |
|
5937 |
SMediaPagingInfo info = device->iMediaPagingInfo; |
|
5938 |
NKern::FMSignal(&device->iInstrumentationLock); |
|
5939 |
kumemput32(a2,&info,sizeof(info)); |
|
5940 |
r=KErrNone; |
|
5941 |
break; |
|
5942 |
} |
|
5943 |
#endif |
|
5944 |
default: |
|
5945 |
break; |
|
5946 |
} |
|
5947 |
return r; |
|
5948 |
} |
|
5949 |
||
5950 |
||
5951 |
/****************************************************************************** |
|
5952 |
Partition table scanner |
|
5953 |
******************************************************************************/ |
|
5954 |
||
5955 |
#ifdef _DEBUG |
|
5956 |
#define DMEMDUMP(base,size) DbgMemDump((TLinAddr)base,size) |
|
5957 |
void DbgMemDump(TLinAddr aBase, TInt aSize) |
|
5958 |
{ |
|
5959 |
TInt off; |
|
5960 |
const TUint8* p=(const TUint8*)aBase; |
|
5961 |
NKern::Lock(); |
|
5962 |
for (off=0; off<aSize; off+=16, p+=16) |
|
5963 |
{ |
|
5964 |
Kern::Printf("%04x: %02x %02x %02x %02x %02x %02x %02x %02x | %02x %02x %02x %02x %02x %02x %02x %02x", |
|
5965 |
off, p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], |
|
5966 |
p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]); |
|
5967 |
} |
|
5968 |
NKern::Unlock(); |
|
5969 |
} |
|
5970 |
#else |
|
5971 |
#define DMEMDUMP(base,size) |
|
5972 |
#endif |
|
5973 |
||
5974 |
EXPORT_C void TPartitionTableScanner::Set(TUint8* aSectorBuffer, TPartitionEntry* aEntry, TInt aMaxPartitions, TInt64 aMediaSize) |
|
5975 |
{ |
|
5976 |
__KTRACE_OPT(KLOCDRV, Kern::Printf("TPartitionTableScanner @ %08x : buf %08x entry %08x max %d sz %08x %08x", |
|
5977 |
this, aSectorBuffer, aEntry, aMaxPartitions, I64HIGH(aMediaSize), I64LOW(aMediaSize))); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5978 |
OstTraceExt4( TRACE_INTERNALS, TPARTITIONTABLESCANNER_SET, "TPartitionTableScanner at 0x%08x; aSectorBuffer=0x%08x; aEntry=0x%08x; aMaxPartitions=%d", (TUint) this, (TUint) aSectorBuffer, (TUint) aEntry, aMaxPartitions ); |
0 | 5979 |
__ASSERT_ALWAYS(aMaxPartitions>0, LOCM_FAULT()); |
5980 |
memclr(this, sizeof(TPartitionTableScanner)); |
|
5981 |
iLBA = -1; |
|
5982 |
iSectorBuffer = aSectorBuffer; |
|
5983 |
iFirstEntry = aEntry; |
|
5984 |
iNextEntry = aEntry; |
|
5985 |
iLimit = aEntry + aMaxPartitions; |
|
5986 |
iMediaSize = aMediaSize; |
|
5987 |
} |
|
5988 |
||
5989 |
EXPORT_C TInt TPartitionTableScanner::NumberOfPartitionsFound() const |
|
5990 |
{ |
|
5991 |
TInt n = iNextEntry - iFirstEntry; |
|
5992 |
__KTRACE_OPT(KLOCDRV, Kern::Printf("TPartitionTableScanner N=%d", n)); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5993 |
OstTrace1( TRACE_INTERNALS, TPARTITIONTABLESCANNER_NUMBERPARTITIONS, "Number of partitions=%d", n ); |
0 | 5994 |
return n; |
5995 |
} |
|
5996 |
||
5997 |
TPartitionTableScanner::SPart::SPart(const TUint8* a) |
|
5998 |
{ |
|
5999 |
iBootInd = a[0]; |
|
6000 |
iType = a[4]; |
|
6001 |
iRSS = a[8]|(a[9]<<8)|(a[10]<<16)|(a[11]<<24); |
|
6002 |
iSectors = a[12]|(a[13]<<8)|(a[14]<<16)|(a[15]<<24); |
|
6003 |
__KTRACE_OPT(KLOCDRV, Kern::Printf("SPart: BI=%02x TYPE=%02x RSS=%08x SIZE=%08x", iBootInd, iType, iRSS, iSectors)); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
6004 |
OstTraceExt4(TRACE_INTERNALS, TPARTITIONTABLESCANNER_SPART_SPART, "SPart: iBootInd=%02x; iType=%02x; iRSS=%08x; iSectors=%08x", (TUint) iBootInd, (TUint) iType, (TUint) iRSS, (TUint) iSectors); |
0 | 6005 |
} |
6006 |
||
6007 |
TInt TPartitionTableScanner::MakeEntry(const SPart& a) |
|
6008 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
6009 |
OstTraceFunctionEntry1( TPARTITIONTABLESCANNER_MAKEENTRY_ENTRY, this ); |
0 | 6010 |
if (iNextEntry == iLimit) |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
6011 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
6012 |
OstTraceFunctionExitExt( TPARTITIONTABLESCANNER_MAKEENTRY_EXIT1, this, KErrOverflow ); |
0 | 6013 |
return KErrOverflow; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
6014 |
} |
0 | 6015 |
if (a.iRSS<=0 || a.iSectors<=0 || a.iRSS>=iMediaSize) |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
6016 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
6017 |
OstTraceFunctionExitExt( TPARTITIONTABLESCANNER_MAKEENTRY_EXIT2, this, KErrCorrupt ); |
0 | 6018 |
return KErrCorrupt; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
6019 |
} |
0 | 6020 |
if (TUint64(a.iRSS) + TUint64(a.iSectors) > TUint64(iMediaSize)) |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
6021 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
6022 |
OstTraceFunctionExitExt( TPARTITIONTABLESCANNER_MAKEENTRY_EXIT3, this, KErrCorrupt ); |
0 | 6023 |
return KErrCorrupt; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
6024 |
} |
0 | 6025 |
iNextEntry->iBootIndicator = a.iBootInd; |
6026 |
iNextEntry->iPartitionType = a.iType; |
|
6027 |
iNextEntry->iPartitionBaseAddr = TInt64(a.iRSS)<<ESectorShift; |
|
6028 |
iNextEntry->iPartitionLen = TInt64(a.iSectors)<<ESectorShift; |
|
6029 |
++iNextEntry; |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
6030 |
OstTraceFunctionExitExt( TPARTITIONTABLESCANNER_MAKEENTRY_EXIT4, this, KErrNone ); |
0 | 6031 |
return KErrNone; |
6032 |
} |
|
6033 |
||
6034 |
EXPORT_C TInt64 TPartitionTableScanner::NextLBA() |
|
6035 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
6036 |
OstTraceFunctionEntry0( TPARTITIONTABLESCANNER_NEXTLBA_ENTRY ); |
0 | 6037 |
__KTRACE_OPT(KLOCDRV, Kern::Printf(">TPartitionTableScanner iLBA=%08x %08x", I64HIGH(iLBA), I64LOW(iLBA))); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
6038 |
OstTraceExt2( TRACE_INTERNALS, TPARTITIONTABLESCANNER_NEXTLBA1, "TPartitionTableScanner iLBA=%08x %08x", I64HIGH(iLBA), I64LOW(iLBA) ); |
0 | 6039 |
TInt r; |
6040 |
TUint8* b = iSectorBuffer; |
|
6041 |
TUint8* pS = b + 0x1be; |
|
6042 |
TUint8* pE = pS + 64; |
|
6043 |
TUint8* p = pS; |
|
6044 |
TInt orig_sp = iStackPointer; |
|
6045 |
TInt sp; |
|
6046 |
if (iLBA < 0) |
|
6047 |
{ |
|
6048 |
iLBA = 0; |
|
6049 |
goto end; |
|
6050 |
} |
|
6051 |
__KTRACE_OPT(KLOCDRV,DMEMDUMP(b, ESectorSize)); |
|
6052 |
if (b[ESectorSize-2]!=0x55 || b[ESectorSize-1]!=0xaa) |
|
6053 |
{ |
|
6054 |
__KTRACE_OPT(KLOCDRV, Kern::Printf("Bad signature")); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
6055 |
OstTrace0( TRACE_INTERNALS, TPARTITIONTABLESCANNER_NEXTLBA2, "Bad signature" ); |
0 | 6056 |
iLBA = KErrCorrupt; |
6057 |
goto end; |
|
6058 |
} |
|
6059 |
if (iLBA==0 && iNextEntry==iFirstEntry) |
|
6060 |
{ |
|
6061 |
// Look for bootable partition first |
|
6062 |
for (; p<pE; p+=16) |
|
6063 |
{ |
|
6064 |
SPart pt(p); |
|
6065 |
if (pt.iBootInd==0x80 && pt.iType && pt.iSectors>0) |
|
6066 |
{ |
|
6067 |
p[4] = 0; |
|
6068 |
r = MakeEntry(pt); |
|
6069 |
if (r!=KErrNone) |
|
6070 |
{ |
|
6071 |
iLBA = r; |
|
6072 |
goto end; |
|
6073 |
} |
|
6074 |
} |
|
6075 |
} |
|
6076 |
} |
|
6077 |
// Look for extended partitions |
|
6078 |
for (p=pE-16; p>=pS; p-=16) |
|
6079 |
{ |
|
6080 |
SPart pt(p); |
|
6081 |
if ((pt.iType==0x05 || pt.iType==0x0f) && pt.iSectors>0) |
|
6082 |
{ |
|
6083 |
// This one is an EBR |
|
6084 |
p[4] = 0; |
|
6085 |
if (iStackPointer == EMaxNest) |
|
6086 |
{ |
|
6087 |
if (iStackPointer == orig_sp) |
|
6088 |
continue; |
|
6089 |
--iStackPointer; |
|
6090 |
for(sp = orig_sp; sp<iStackPointer; ++sp) |
|
6091 |
iStack[sp] = iStack[sp+1]; |
|
6092 |
} |
|
6093 |
iStack[iStackPointer].iRSS = pt.iRSS; |
|
6094 |
iStack[iStackPointer].iSectors = pt.iSectors; |
|
6095 |
++iStackPointer; |
|
6096 |
#ifdef _DEBUG |
|
6097 |
for (sp=0; sp<iStackPointer; ++sp) |
|
6098 |
{ |
|
6099 |
const TInt64& rss = iStack[sp].iRSS; |
|
6100 |
const TInt64& size = iStack[sp].iSectors; |
|
6101 |
__KTRACE_OPT(KLOCDRV, Kern::Printf("Stack[%d] RSS %08x %08x SIZE %08x %08x", sp, |
|
6102 |
I64HIGH(rss), I64LOW(rss), I64HIGH(size), I64LOW(size) )); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
6103 |
OstTraceExt5(TRACE_INTERNALS, PARTITIONTABLESCANNER_NEXTLBA3, "Stack[%d] RSS 0x%x 0x%x SIZE 0x%08x 0x%08x", (TInt) sp, (TUint) I64HIGH(rss), (TUint) I64LOW(rss), (TUint) I64HIGH(size), (TUint) I64LOW(size)); |
0 | 6104 |
} |
6105 |
#endif |
|
6106 |
} |
|
6107 |
} |
|
6108 |
// Look for other data partitions |
|
6109 |
for (p=pS; p<pE; p+=16) |
|
6110 |
{ |
|
6111 |
SPart pt(p); |
|
6112 |
if (pt.iType && pt.iSectors>0) |
|
6113 |
{ |
|
6114 |
pt.iRSS += TUint32(iLBA); // data partitions are specified relative to the EBR they appear in |
|
6115 |
r = MakeEntry(pt); |
|
6116 |
if (r!=KErrNone) |
|
6117 |
{ |
|
6118 |
iLBA = r; |
|
6119 |
goto end; |
|
6120 |
} |
|
6121 |
} |
|
6122 |
} |
|
6123 |
// If any EBRs on stack, pop off the first and process it |
|
6124 |
if (iStackPointer) |
|
6125 |
{ |
|
6126 |
--iStackPointer; |
|
6127 |
iLBA = iFirstEBR + iStack[iStackPointer].iRSS; // LBA of second and subsequent EBR is specified relative to first EBR |
|
6128 |
if (!iFirstEBR) |
|
6129 |
iFirstEBR = iLBA; |
|
6130 |
} |
|
6131 |
else |
|
6132 |
iLBA = KErrEof; // finished |
|
6133 |
||
6134 |
end: |
|
6135 |
__KTRACE_OPT(KLOCDRV, Kern::Printf("<TPartitionTableScanner iLBA=%08x %08x", I64HIGH(iLBA), I64LOW(iLBA))); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
6136 |
OstTraceExt2( TRACE_INTERNALS, TPARTITIONTABLESCANNER_NEXTLBA3, "TPartitionTableScanner iLBA=0x%08x 0x%08x", I64HIGH(iLBA), I64LOW(iLBA) ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
6137 |
OstTraceFunctionExit0( TPARTITIONTABLESCANNER_NEXTLBA_EXIT ); |
0 | 6138 |
return iLBA; |
6139 |
} |
|
6140 |
||
6141 |
/** |
|
6142 |
* Returns Address and Length of next contiguous Physical memory fragment |
|
6143 |
* |
|
6144 |
* @param aAddr On success, populated with the Physical Address of the next fragment. |
|
6145 |
* @param aLen On success, populated with the length in bytes of the next fragment. |
|
6146 |
* |
|
6147 |
* @return KErrNone, if successful; |
|
6148 |
* KErrNoMemory, if no more memory fragments left. |
|
6149 |
* KErrNotSupported, if Physical Memory addressing is not supported by this Media. |
|
6150 |
*/ |
|
6151 |
EXPORT_C TInt TLocDrvRequest::GetNextPhysicalAddress(TPhysAddr& aAddr, TInt& aLen) |
|
6152 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
6153 |
OstTraceExt2(TRACE_FLOW, TLOCDRVREQUEST_GETNEXTPHYSICALADDRESS_ENTRY, "> TLocDrvRequest::GetNextPhysicalAddress;aAddr=%x;aLen=%d;", (TUint) &aAddr, aLen ); |
0 | 6154 |
if (Flags() & EPhysAddr) |
6155 |
{ |
|
6156 |
#ifdef __DEMAND_PAGING__ |
|
6157 |
if (DMediaPagingDevice::PagingRequest(*this)) |
|
6158 |
{ |
|
6159 |
return DDmaHelper::GetPhysicalAddress(*this, aAddr, aLen); |
|
6160 |
} |
|
6161 |
#endif |
|
6162 |
return Drive()->iDmaHelper->GetPhysicalAddress(aAddr, aLen); |
|
6163 |
} |
|
6164 |
else |
|
6165 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
6166 |
OstTraceFunctionExitExt( TLOCDRVREQUEST_GETNEXTPHYSICALADDRESS_EXIT, this, KErrNotSupported ); |
0 | 6167 |
return KErrNotSupported; |
6168 |
} |
|
6169 |
} |
|
6170 |
||
6171 |
||
6172 |
/****************************************************************************** |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6173 |
DMediaDriverExtension base class |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6174 |
******************************************************************************/ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6175 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6176 |
EXPORT_C DMediaDriverExtension::DMediaDriverExtension(TInt aMediaId) : |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6177 |
DMediaDriver(aMediaId) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6178 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6179 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6180 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6181 |
/** |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6182 |
*/ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6183 |
EXPORT_C DMediaDriverExtension::~DMediaDriverExtension() |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6184 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6185 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6186 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6187 |
/** |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6188 |
Closes the media driver. |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6189 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6190 |
This default implementation simply deletes this DMediaDriverExtension object. |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6191 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6192 |
Media drivers can provide their own implementation, which gives them |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6193 |
the opportunity to clean up resources before closure; for example, |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6194 |
cancelling a DFC. |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6195 |
Any replacement function must call this base class function as |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6196 |
the last instruction. |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6197 |
*/ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6198 |
EXPORT_C void DMediaDriverExtension::Close() |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6199 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6200 |
DMediaDriver::Close(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6201 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6202 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6203 |
/** |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6204 |
DoDrivePartitionInfo() |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6205 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6206 |
Fills out the passed TPartitionInfo object with information from the attached drives |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6207 |
*/ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6208 |
EXPORT_C TInt DMediaDriverExtension::DoDrivePartitionInfo(TPartitionInfo& aInfo) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6209 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6210 |
memclr(&aInfo, sizeof(aInfo)); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6211 |
aInfo.iPartitionCount = 0; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6212 |
aInfo.iMediaSizeInBytes = 0; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6213 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6214 |
TDriveIterator driveIter; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6215 |
for (TLocDrv* drv = driveIter.NextDrive(); drv != NULL; drv = driveIter.NextDrive()) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6216 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6217 |
if (drv && drv->iPrimaryMedia == iPrimaryMedia) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6218 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6219 |
TLocDrv* attachedDrive = drv->iNextDrive; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6220 |
__ASSERT_DEBUG(attachedDrive, LOCM_FAULT()); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6221 |
TLocDrvRequest m; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6222 |
memclr(&m, sizeof(m)); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6223 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6224 |
// Get the Caps from the device. NB for MMC/SD we may need to retry as there may have been an earlier |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6225 |
// EForceMediaChange request which can result in the cancellation of requests already in the queue |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6226 |
TBuf8<KMaxLocalDriveCapsLength> capsBuf; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6227 |
TInt i; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6228 |
const TInt KRetries = 5; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6229 |
TInt r = KErrNotReady; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6230 |
for (i=0; r == KErrNotReady && i < KRetries; i++) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6231 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6232 |
capsBuf.SetMax(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6233 |
capsBuf.FillZ(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6234 |
m.Drive() = attachedDrive; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6235 |
m.Id() = DLocalDrive::ECaps; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6236 |
m.RemoteDes() = (TAny*)capsBuf.Ptr(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6237 |
m.Length() = KMaxLocalDriveCapsLength; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6238 |
r = attachedDrive->iPrimaryMedia->Request(m); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6239 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6240 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6241 |
__KTRACE_OPT2(KBOOT,KLOCDPAGING, Kern::Printf("DMediaDriverExtension::PartitionInfo(ECaps: i %d: r %d ", driveIter.Index(), r)); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6242 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6243 |
// NB The ECaps call might legitimately fail if one of the attached drives is removable |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6244 |
// If this happens, just ignore & proceed to the next attached drive |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6245 |
if (r == KErrNone) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6246 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6247 |
aInfo.iEntry[aInfo.iPartitionCount] = *attachedDrive; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6248 |
// Set the media size to be that of the largest attached media |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6249 |
// This is only needed to ensure that the test in TLocDrvRequest::CheckAndAdjustForPartition() |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6250 |
// with the ELocDrvWholeMedia flag set succeeds: A further check on whether a request's |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6251 |
// position & length are outside the media will be made when its is delievered to the attached media.... |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6252 |
aInfo.iMediaSizeInBytes = Max( |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6253 |
aInfo.iMediaSizeInBytes, |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6254 |
((TLocalDriveCapsV4*) capsBuf.Ptr())->MediaSizeInBytes()); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6255 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6256 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6257 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6258 |
aInfo.iPartitionCount++; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6259 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6260 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6261 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6262 |
return KErrNone; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6263 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6264 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6265 |
/** |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6266 |
ForwardRequest() - |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6267 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6268 |
forwards the request onto the next attached drive in the chain |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6269 |
*/ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6270 |
EXPORT_C TInt DMediaDriverExtension::ForwardRequest(TLocDrvRequest& aRequest) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6271 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6272 |
TLocDrv* drive = aRequest.Drive(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6273 |
TLocDrv* attachedDrive = drive->iNextDrive; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6274 |
__ASSERT_DEBUG(attachedDrive, LOCM_FAULT()); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6275 |
aRequest.Drive() = attachedDrive; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6276 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6277 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6278 |
TInt r = attachedDrive->iPrimaryMedia->HandleMediaNotPresent(aRequest); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6279 |
if (r != KErrNone) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6280 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6281 |
return r; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6282 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6283 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6284 |
aRequest.Forward(&attachedDrive->iPrimaryMedia->iMsgQ, EFalse); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6285 |
return KErrNone; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6286 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6287 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6288 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6289 |
TInt DMediaDriverExtension::SendRequest(TInt aReqId, TBool aPagingRequest, TInt aDriveNumber, TInt64 aPos, TLinAddr aData, TUint aLen) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6290 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6291 |
__ASSERT_DEBUG(aLen > 0, LOCM_FAULT()); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6292 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6293 |
// Ensure this is a legitimate attached drive registered using LocDrv::RegisterMediaDevice() |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6294 |
if (!(iPrimaryMedia->iBody->iRegisteredDriveMask & (0x1 << aDriveNumber))) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6295 |
return KErrArgument; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6296 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6297 |
TLocDrv* drive = TDriveIterator::GetDrive(aDriveNumber, iPrimaryMedia); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6298 |
__ASSERT_DEBUG(drive, LOCM_FAULT()); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6299 |
TLocDrv* attachedDrive = drive->iNextDrive; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6300 |
__ASSERT_DEBUG(attachedDrive, LOCM_FAULT()); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6301 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6302 |
TLocDrvRequest request; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6303 |
memclr(&request, sizeof(request)); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6304 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6305 |
request.Drive() = attachedDrive; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6306 |
request.Id() = aReqId; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6307 |
request.Length() = aLen; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6308 |
request.RemoteDes() = (TAny*) aData; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6309 |
request.Pos() = aPos; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6310 |
request.Flags() = TLocDrvRequest::EKernelBuffer | TLocDrvRequest::EAdjusted; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6311 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6312 |
#ifdef __DEMAND_PAGING__ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6313 |
if (aPagingRequest) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6314 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6315 |
request.Flags()|= TLocDrvRequest::EPaging; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6316 |
// If the buffer is page aligned, use SendToMainQueueDfcAndBlock() as this |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6317 |
// is more efficient if the attached drive use DMA. |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6318 |
const TInt KPageSizeMask = 4096-1; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6319 |
if (aData & KPageSizeMask) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6320 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6321 |
return attachedDrive->iPrimaryMedia->SendReceive(request, aData); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6322 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6323 |
else |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6324 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6325 |
attachedDrive->iPrimaryMedia->iBody->iPagingDevice->SendToMainQueueDfcAndBlock(&request); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6326 |
return 0; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6327 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6328 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6329 |
#else |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6330 |
aPagingRequest; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6331 |
#endif |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6332 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6333 |
return attachedDrive->iPrimaryMedia->SendReceive(request, aData); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6334 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6335 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6336 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6337 |
/** |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6338 |
Read() - |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6339 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6340 |
reads data from the next attached drive in the chain |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6341 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6342 |
N.B. The position is assumed to be already adjusted i.e. relative to the start of the |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6343 |
media, not the partition |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6344 |
*/ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6345 |
EXPORT_C TInt DMediaDriverExtension::Read(TInt aDriveNumber, TInt64 aPos, TLinAddr aData, TUint aLen) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6346 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6347 |
return SendRequest(DLocalDrive::ERead, EFalse, aDriveNumber, aPos, aData, aLen); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6348 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6349 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6350 |
/** |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6351 |
Write() - |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6352 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6353 |
writes data to the next attached drive in the chain |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6354 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6355 |
N.B. The position is assumed to be already adjusted i.e. relative to the start of the |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6356 |
media, not the partition |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6357 |
*/ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6358 |
EXPORT_C TInt DMediaDriverExtension::Write(TInt aDriveNumber, TInt64 aPos, TLinAddr aData, TUint aLen) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6359 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6360 |
return SendRequest(DLocalDrive::EWrite, EFalse, aDriveNumber, aPos, aData, aLen); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6361 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6362 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6363 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6364 |
#ifdef __DEMAND_PAGING__ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6365 |
/** |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6366 |
ReadPaged() - |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6367 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6368 |
Sends a paging read request to the specified attached drive |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6369 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6370 |
N.B. The position is assumed to be already adjusted i.e. relative to the start of the |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6371 |
media, not the partition |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6372 |
*/ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6373 |
EXPORT_C TInt DMediaDriverExtension::ReadPaged(TInt aDriveNumber, TInt64 aPos, TLinAddr aData, TUint aLen) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6374 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6375 |
return SendRequest(DLocalDrive::ERead, ETrue, aDriveNumber, aPos, aData, aLen); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6376 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6377 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6378 |
/** |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6379 |
WritePaged() - |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6380 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6381 |
Send a paging write request to the specified attached drive |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6382 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6383 |
N.B. The position is assumed to be already adjusted i.e. relative to the start of the |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6384 |
media, not the partition |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6385 |
*/ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6386 |
EXPORT_C TInt DMediaDriverExtension::WritePaged(TInt aDriveNumber, TInt64 aPos, TLinAddr aData, TUint aLen) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6387 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6388 |
return SendRequest(DLocalDrive::EWrite, ETrue, aDriveNumber, aPos, aData, aLen); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6389 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6390 |
#endif // __DEMAND_PAGING__ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6391 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6392 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6393 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6394 |
/** |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6395 |
Caps() - |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6396 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6397 |
gets the caps from the next attached drive in the chain |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6398 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6399 |
N.B. The position is assumed to be already adjusted i.e. relative to the start of the |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6400 |
media, not the partition |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6401 |
*/ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6402 |
EXPORT_C TInt DMediaDriverExtension::Caps(TInt aDriveNumber, TDes8& aCaps) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6403 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6404 |
// Ensure this is a legitimate attached drive registered using LocDrv::RegisterMediaDevice() |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6405 |
if (!(iPrimaryMedia->iBody->iRegisteredDriveMask & (0x1 << aDriveNumber))) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6406 |
return KErrArgument; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6407 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6408 |
TLocDrv* drive = TDriveIterator::GetDrive(aDriveNumber, iPrimaryMedia); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6409 |
__ASSERT_DEBUG(drive, LOCM_FAULT()); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6410 |
TLocDrv* attachedDrive = drive->iNextDrive; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6411 |
__ASSERT_DEBUG(attachedDrive, LOCM_FAULT()); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6412 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6413 |
TLocDrvRequest request; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6414 |
memclr(&request, sizeof(request)); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6415 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6416 |
request.Drive() = attachedDrive; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6417 |
request.Id() = DLocalDrive::ECaps; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6418 |
request.Length() = aCaps.Length(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6419 |
request.RemoteDes() = (TAny*) aCaps.Ptr(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6420 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6421 |
return request.SendReceive(&attachedDrive->iPrimaryMedia->iMsgQ); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6422 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6423 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6424 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6425 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6426 |
EXPORT_C void DMediaDriverExtension::NotifyPowerDown() |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6427 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6428 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6429 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6430 |
EXPORT_C void DMediaDriverExtension::NotifyEmergencyPowerDown() |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6431 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6432 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6433 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6434 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6435 |
/** |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6436 |
Returns ETrue if this media - or any media which this TLocDrv is attached to - is busy |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6437 |
*/ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6438 |
EXPORT_C TBool DMediaDriverExtension::MediaBusy(TInt aDriveNumber) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6439 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6440 |
for (TLocDrv* drive = TDriveIterator::GetDrive(aDriveNumber, iPrimaryMedia); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6441 |
drive; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6442 |
drive = drive->iNextDrive) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6443 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6444 |
DPrimaryMediaBase* primaryMedia = drive->iPrimaryMedia; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6445 |
__ASSERT_DEBUG(primaryMedia, LOCM_FAULT()); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6446 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6447 |
if ((primaryMedia->iMsgQ.iMessage && primaryMedia->iMsgQ.iMessage->iState != TMessageBase::EFree) || |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6448 |
!primaryMedia->iMsgQ.iQ.IsEmpty() || |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6449 |
primaryMedia->iBody->iMediaChangeDfc.Queued() || |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6450 |
primaryMedia->iBody->iMediaPresentDfc.Queued()) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6451 |
return ETrue; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6452 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6453 |
#ifdef __DEMAND_PAGING__ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6454 |
DMediaPagingDevice* pagingDevice = iPrimaryMedia->iBody->iPagingDevice; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6455 |
if (pagingDevice) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6456 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6457 |
if ((pagingDevice->iMainQ.iMessage && pagingDevice->iMainQ.iMessage->iState != TMessageBase::EFree) || |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6458 |
!pagingDevice->iMainQ.iQ.IsEmpty()) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6459 |
return ETrue; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6460 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6461 |
#endif |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6462 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6463 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6464 |
return EFalse; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6465 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6466 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6467 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6468 |
TCallBackLink::TCallBackLink() |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6469 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6470 |
memclr(this, sizeof(this)); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6471 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6472 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6473 |
TCallBackLink::TCallBackLink(TInt (*aFunction)(TAny* aPtr, TInt aParam),TAny* aPtr, TObjectType aObjectType) : |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6474 |
iFunction(aFunction), iPtr(aPtr), iObjectType(aObjectType) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6475 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6476 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6477 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6478 |
TInt TCallBackLink::CallBack(TInt aParam) const |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6479 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6480 |
return (*iFunction)(iPtr, aParam); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6481 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6482 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6483 |
/****************************************************************************** |
0 | 6484 |
Entry point |
6485 |
******************************************************************************/ |
|
6486 |
DECLARE_STANDARD_EXTENSION() |
|
6487 |
{ |
|
6488 |
__KTRACE_OPT(KBOOT,Kern::Printf("Starting LOCMEDIA extension")); |
|
6489 |
||
6490 |
// install the HAL function |
|
6491 |
TInt r=Kern::AddHalEntry(EHalGroupMedia,MediaHalFunction,NULL); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6492 |
|
0 | 6493 |
#ifdef __DEMAND_PAGING__ |
6494 |
if (r==KErrNone) |
|
6495 |
{ |
|
6496 |
__KTRACE_OPT(KBOOT,Kern::Printf("Creating LocDrv device")); |
|
6497 |
DLocalDriveFactory* device = new DLocalDriveFactory; |
|
6498 |
if (device==NULL) |
|
6499 |
r=KErrNoMemory; |
|
6500 |
else |
|
6501 |
r=Kern::InstallLogicalDevice(device); |
|
6502 |
__KTRACE_OPT(KBOOT,Kern::Printf("Installing LocDrv device in kernel returned %d",r)); |
|
6503 |
} |
|
6504 |
#endif // __DEMAND_PAGING__ |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6505 |
|
0 | 6506 |
return r; |
6507 |
} |
|
6508 |
||
6509 |