author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 14 May 2010 17:13:29 +0300 | |
changeset 109 | b3a1d9898418 |
parent 90 | 947f0dc9f7a8 |
child 152 | 657f875b013e |
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 |
|
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
32 |
|
0 | 33 |
#if defined(_DEBUG) && defined(__DEMAND_PAGING__) |
34 |
//#define __DEBUG_DEMAND_PAGING__ |
|
35 |
#endif |
|
36 |
||
37 |
||
38 |
#if 0 |
|
39 |
#define CHECK_RET(r) if ((r)==KErrNotSupported && (KDebugNum(KSCRATCH))) {NKern::Lock(); *(TInt*)0xfaece5=0;} |
|
40 |
//#define CHECK_RET(r) |
|
41 |
#else |
|
42 |
#define CHECK_RET(r) |
|
43 |
#endif |
|
44 |
||
45 |
_LIT(KLddName,"LocDrv"); |
|
46 |
_LIT(KLitMediaDriverName, "Media.*"); |
|
47 |
_LIT(KLitLocMedia,"LocMedia"); |
|
48 |
||
49 |
#define LOCM_FAULT() Kern::Fault("LOCMEDIA",__LINE__) |
|
50 |
||
51 |
const TInt KMaxLocalDriveCapsLength=256; |
|
52 |
const TInt KMaxQueryDeviceLength=256; |
|
53 |
||
54 |
// The maximum amount of user-data which will be pinned. If a request is longer |
|
55 |
// than this value it will be split up into a number of requests |
|
56 |
// This value is a bit arbitrary - it needs to be sufficiently large so that transfer |
|
57 |
// rates don't suffer too much - but it can't be too big or we'd be "stealing" too much |
|
58 |
// memory from the demand paging pool and starving other processes |
|
59 |
const TInt KMaxPinData = 256*1024; |
|
60 |
||
61 |
// The number of locks available for pinning shared by all the drive threads in the system. |
|
62 |
// If all locks are in use then a single pre-allocated lock is used. |
|
63 |
const TInt KDynamicPagingLockCount = 8; |
|
64 |
||
65 |
TLocDrv* TheDrives[KMaxLocalDrives]; |
|
66 |
DMedia* TheMedia[KMaxLocalDrives]; |
|
67 |
HBuf* DriveNames[KMaxLocalDrives]; |
|
68 |
TInt UsedMedia=0; |
|
69 |
TPasswordStore* ThePasswordStore=NULL; |
|
70 |
||
71 |
class DPrimaryMediaBase::DBody : public DBase |
|
72 |
{ |
|
73 |
public: |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
74 |
DBody(DPrimaryMediaBase& aPrimaryMediaBase); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
75 |
public: |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
76 |
DPrimaryMediaBase& iPrimaryMediaBase; // ptr to parent |
0 | 77 |
TInt iPhysDevIndex; |
78 |
TInt iRequestCount; |
|
79 |
#ifdef __DEMAND_PAGING__ |
|
80 |
DMediaPagingDevice* iPagingDevice; |
|
81 |
TInt iPageSizeMsk; // Mask of page size (e.g. 4096-1 -> 4095) |
|
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); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
589 |
OstTraceDefExt4( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_READ, "ERead iDriveNumber=%d; length=0x%x; position=0x%x; TLocDrvRequest Object=0x%x", (TInt) iDrive->iDriveNumber, (TUint) m.Length(), (TUint) m.Pos(), (TUint) &m); |
0 | 590 |
r=iDrive->Request(m); |
591 |
__TRACE_TIMING(3); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
592 |
OstTraceDefExt4( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_READ_RETURN, "ERead Return iDriveNumber=%d; length=0x%x; position=0x%x; TLocDrvRequest Object=0x%x", (TInt) iDrive->iDriveNumber, (TUint) m.Length(), (TUint) m.Pos(), (TUint) &m ); |
0 | 593 |
} |
594 |
m.CloseRemoteThread(); |
|
595 |
break; |
|
596 |
} |
|
597 |
case RLocalDrive::EControlWrite: |
|
598 |
{ |
|
599 |
m.Id()=EWrite; |
|
600 |
r=m.ProcessMessageData(a1); |
|
601 |
if (r==KErrNone) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
602 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
603 |
OstTraceDefExt4( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_WRITE, "EWrite iDriveNumber=%d; length=0x%x; position=0x%x; TLocDrvRequest Object=0x%x", (TInt) iDrive->iDriveNumber, (TUint) m.Length(), (TUint) m.Pos(), (TUint) &m ); |
0 | 604 |
r=iDrive->Request(m); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
605 |
OstTraceDefExt4( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_WRITE_RETURN, "EWrite Return iDriveNumber=%d; length=0x%x; position=0x%x; TLocDrvRequest Object=0x%x", (TInt) iDrive->iDriveNumber, (TUint) m.Length(), (TUint) m.Pos(), (TUint) &m ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
606 |
} |
0 | 607 |
m.CloseRemoteThread(); |
608 |
break; |
|
609 |
} |
|
610 |
case RLocalDrive::EControlCaps: |
|
611 |
{ |
|
612 |
TBuf8<KMaxLocalDriveCapsLength> capsBuf; |
|
613 |
capsBuf.SetMax(); |
|
614 |
capsBuf.FillZ(); |
|
615 |
m.Id()=ECaps; |
|
616 |
m.RemoteDes()=(TAny*)capsBuf.Ptr(); // overload this |
|
617 |
m.Length()=KMaxLocalDriveCapsLength; // for pinning |
|
618 |
r=iDrive->Request(m); |
|
619 |
||
620 |
||
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
621 |
#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
|
622 |
const TLocalDriveCapsV5& caps=*(const TLocalDriveCapsV5*)capsBuf.Ptr(); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
623 |
#endif |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
624 |
|
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
625 |
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
|
626 |
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
|
627 |
|
0 | 628 |
#if defined(_DEBUG) |
629 |
__KTRACE_OPT(KLOCDRV,DebugDumpDriveCaps(iDrive,capsBuf.Ptr())); |
|
630 |
#endif |
|
631 |
Kern::InfoCopy(*(TDes8*)a1, capsBuf); |
|
632 |
break; |
|
633 |
} |
|
634 |
case RLocalDrive::EControlFormat: |
|
635 |
{ |
|
636 |
m.Id()=EFormat; |
|
637 |
r=m.ProcessMessageData(a1); |
|
638 |
if (r==KErrNone) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
639 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
640 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_FORMAT, "EFormat; TLocDrvRequest Object=0x%x", (TUint) &m); |
0 | 641 |
r=iDrive->Request(m); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
642 |
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
|
643 |
} |
0 | 644 |
break; |
645 |
} |
|
646 |
case RLocalDrive::EControlEnlarge: |
|
647 |
if ((TInt)a1<0) |
|
648 |
{ |
|
649 |
r=KErrArgument; |
|
650 |
break; |
|
651 |
} |
|
652 |
m.Length()=(TInt)a1; |
|
653 |
m.Id()=EEnlarge; |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
654 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_ENLARGE, "EEnlarge; TLocDrvRequest Object=0x%x", (TUint) &m); |
0 | 655 |
r=iDrive->Request(m); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
656 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_ENLARGE_RETURN, "EEnlarge Return; TLocDrvRequest Object=0x%x", (TUint) &m); |
0 | 657 |
break; |
658 |
case RLocalDrive::EControlReduce: |
|
659 |
{ |
|
660 |
if ((TInt)a1<0 || (TInt)a2<0) |
|
661 |
{ |
|
662 |
r=KErrArgument; |
|
663 |
break; |
|
664 |
} |
|
665 |
m.Pos()=(TInt)a1; |
|
666 |
m.Length()=(TInt)a2; |
|
667 |
m.Id()=EReduce; |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
668 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_REDUCE, "EReduce; TLocDrvRequest Object=0x%x", (TUint) &m); |
0 | 669 |
r=iDrive->Request(m); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
670 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_REDUCE_RETURN, "EReduce Return; TLocDrvRequest Object=0x%x", (TUint) &m); |
0 | 671 |
break; |
672 |
} |
|
673 |
case RLocalDrive::EControlForceMediaChange: |
|
674 |
m.Pos()=(TInt)a1; |
|
675 |
m.Id()=EForceMediaChange; |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
676 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_FORCEMEDIACHANGE, "EForceMediaChange; TLocDrvRequest Object=0x%x", (TUint) &m); |
0 | 677 |
r = iDrive->Request(m); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
678 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_FORCEMEDIACHANGE_RETURN, "EForceMediaChange Return; TLocDrvRequest Object=0x%x", (TUint) &m); |
0 | 679 |
break; |
680 |
case RLocalDrive::EControlMediaDevice: |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
681 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_CONTROLMEDIADEVICE, "EControlMediaDevice; TLocDrvRequest Object=0x%x", (TUint) &m); |
0 | 682 |
r=iDrive->iPrimaryMedia->iDevice; |
683 |
break; |
|
684 |
case RLocalDrive::EControlIsRemovable: |
|
685 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
686 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_CONTROLISREMOVABLE, "EControlIsRemovable; TLocDrvRequest Object=0x%x", (TUint) &m); |
0 | 687 |
TInt sockNum; |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
688 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
689 |
// Pass request on to last chained drive |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
690 |
TLocDrv* drv = TDriveIterator::GetPhysicalDrive(iDrive); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
691 |
r = drv->iPrimaryMedia->IsRemovableDevice(sockNum); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
692 |
|
0 | 693 |
if (r) |
694 |
kumemput32(a1,&sockNum,sizeof(TInt)); |
|
695 |
break; |
|
696 |
} |
|
697 |
case RLocalDrive::EControlControlIO: |
|
698 |
{ |
|
699 |
TLocalDriveControlIOData d; |
|
700 |
kumemget32(&d,a1,sizeof(d)); |
|
701 |
||
702 |
m.Id() = EControlIO; |
|
703 |
m.iArg[0] = (TAny*) d.iCommand; |
|
704 |
m.iArg[1] = d.iParam1; |
|
705 |
m.iArg[2] = d.iParam2; |
|
706 |
||
707 |
// if d.iHandle is == KLocalMessageHandle (-1), |
|
708 |
// d.aParam1 and d.aParam2 are TAny* pointers |
|
709 |
// |
|
710 |
// if d.iHandle is == 0, |
|
711 |
// d.aParam1 and d.aParam2 are TInts |
|
712 |
// |
|
713 |
// if d.iHandle is > 0, |
|
714 |
// d.aParam1 is a data pointer (TUint8*) |
|
715 |
// d.aParam2 is an optional extra paramater (TInt) |
|
716 |
// d.iHandle is a data length (TInt) |
|
717 |
m.iArg[3] = (TAny*) d.iHandle; |
|
718 |
||
719 |
//We're highjacking fields representing |
|
720 |
//length and position in a normal message, so |
|
721 |
//let's not have the dispatcher function attempt |
|
722 |
//to adjust for partition size. |
|
723 |
m.Flags() |= TLocDrvRequest::EAdjusted; |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
724 |
|
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
725 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_CONTROLCONTROLIO, "EControlControlIO; TLocDrvRequest Object=0x%x", (TUint) &m); |
0 | 726 |
r=iDrive->Request(m); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
727 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_CONTROLCONTROLIO_RETURN, "EControlControlIO Return; TLocDrvRequest Object=0x%x", (TUint) &m); |
0 | 728 |
break; |
729 |
} |
|
730 |
case RLocalDrive::EControlSetMountInfo: |
|
731 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
732 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_CONTROLSETMOUNTINFO, "EControlSetMountInfo; TLocDrvRequest Object=0x%x", (TUint) &m); |
0 | 733 |
m.Id()=ERead; |
734 |
r=m.ProcessMessageData(a1); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
735 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
736 |
// Pass request on to last chained drive |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
737 |
TLocDrv* drv = TDriveIterator::GetPhysicalDrive(iDrive); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
738 |
DPrimaryMediaBase* pM = drv->iPrimaryMedia; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
739 |
|
0 | 740 |
if(!pM || r!=KErrNone) |
741 |
break; |
|
742 |
||
743 |
if (pM->iMountInfo.iThread) |
|
744 |
{ |
|
745 |
NKern::ThreadEnterCS(); |
|
746 |
//Close original thread |
|
747 |
Kern::SafeClose((DObject*&) pM->iMountInfo.iThread,NULL); |
|
748 |
if (m.RemoteDes()!=NULL) |
|
749 |
{ |
|
750 |
//Set new mount info and leave setting thread open |
|
751 |
#ifdef __DEMAND_PAGING__ |
|
752 |
// lock the mount info if this is a data paging media - and keep it locked |
|
753 |
if ((DataPagingDfcQ(pM)) && ((r = LockMountInfo(*pM, m)) != KErrNone)) |
|
754 |
break; |
|
755 |
#endif |
|
756 |
pM->iMountInfo.iInfo=(TDesC8*)m.RemoteDes(); |
|
757 |
pM->iMountInfo.iThread=m.RemoteThread(); |
|
758 |
} |
|
759 |
else |
|
760 |
{ |
|
761 |
//Clear existing mount info and close setting thread |
|
762 |
||
763 |
#ifdef __DEMAND_PAGING__ |
|
764 |
// unlock the mount info if this is a data paging media |
|
765 |
UnlockMountInfo(*pM); |
|
766 |
#endif |
|
767 |
||
768 |
pM->iMountInfo.iInfo=NULL; |
|
769 |
pM->iMountInfo.iThread=NULL; |
|
770 |
m.CloseRemoteThread(); |
|
771 |
} |
|
772 |
NKern::ThreadLeaveCS(); |
|
773 |
r=KErrNone; |
|
774 |
} |
|
775 |
else |
|
776 |
{ |
|
777 |
//Setting mount info for the first time |
|
778 |
if (m.RemoteDes()==NULL) |
|
779 |
{ |
|
780 |
// if no mount info, close setting thread opened in ProcessMessageData() |
|
781 |
m.CloseRemoteThread(); |
|
782 |
break; |
|
783 |
} |
|
784 |
||
785 |
NKern::ThreadEnterCS(); |
|
786 |
#ifdef __DEMAND_PAGING__ |
|
787 |
// lock the mount info if this is a data paging media - and keep it locked |
|
788 |
if ((DataPagingDfcQ(pM)) && ((r = LockMountInfo(*pM, m)) != KErrNone)) |
|
789 |
break; |
|
790 |
#endif |
|
791 |
||
792 |
pM->iMountInfo.iInfo=(TDesC8*)m.RemoteDes(); |
|
793 |
pM->iMountInfo.iThread=m.RemoteThread(); |
|
794 |
NKern::ThreadLeaveCS(); |
|
795 |
r=KErrNone; |
|
796 |
} |
|
797 |
break; |
|
798 |
} |
|
799 |
case RLocalDrive::EControlPasswordLock: |
|
800 |
{ |
|
801 |
m.Id()=EPasswordLock; |
|
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
802 |
m.RemoteDes() = a1; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
803 |
|
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
804 |
TMediaPassword oldPasswd; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
805 |
TMediaPassword newPasswd; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
806 |
TLocalDrivePasswordData pswData; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
807 |
r = ReadPasswordData(m, pswData, oldPasswd, newPasswd); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
808 |
|
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
809 |
if (r == KErrNone) |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
810 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
811 |
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
|
812 |
r = iDrive->Request(m); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
813 |
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
|
814 |
} |
0 | 815 |
break; |
816 |
} |
|
817 |
case RLocalDrive::EControlPasswordUnlock: |
|
818 |
{ |
|
819 |
m.Id()=EPasswordUnlock; |
|
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
820 |
m.RemoteDes() = a1; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
821 |
|
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
822 |
TMediaPassword oldPasswd; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
823 |
TMediaPassword newPasswd; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
824 |
TLocalDrivePasswordData pswData; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
825 |
r = ReadPasswordData(m, pswData, oldPasswd, newPasswd); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
826 |
|
0 | 827 |
if(r == KErrNone) |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
828 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
829 |
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
|
830 |
r=iDrive->Request(m); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
831 |
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
|
832 |
} |
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
833 |
if (r == KErrNone) |
0 | 834 |
iDrive->iPrimaryMedia->iTotalPartitionsOpened = 0; |
835 |
break; |
|
836 |
} |
|
837 |
case RLocalDrive::EControlPasswordClear: |
|
838 |
{ |
|
839 |
m.Id()=EPasswordClear; |
|
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
840 |
m.RemoteDes() = a1; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
841 |
|
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
842 |
TMediaPassword oldPasswd; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
843 |
TMediaPassword newPasswd; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
844 |
TLocalDrivePasswordData pswData; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
845 |
r = ReadPasswordData(m, pswData, oldPasswd, newPasswd); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
846 |
|
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
847 |
if (r == KErrNone) |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
848 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
849 |
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
|
850 |
r = iDrive->Request(m); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
851 |
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
|
852 |
} |
0 | 853 |
break; |
854 |
} |
|
855 |
case RLocalDrive::EControlPasswordErase: |
|
856 |
{ |
|
857 |
m.Id()=EPasswordErase; |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
858 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_PASSWORDERASE, "EPasswordErase; TLocDrvRequest Object=0x%x", (TUint) &m); |
0 | 859 |
r=iDrive->Request(m); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
860 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_PASSWORDERASE_RETURN, "EPasswordErase Return; TLocDrvRequest Object=0x%x", (TUint) &m); |
0 | 861 |
if(r == KErrNone) |
862 |
iDrive->iPrimaryMedia->iTotalPartitionsOpened = 0; |
|
863 |
break; |
|
864 |
} |
|
865 |
case RLocalDrive::EControlNotifyChange: |
|
866 |
if (iCleanup.iThread != &Kern::CurrentThread()) |
|
867 |
Kern::PanicCurrentThread(KLitLocMedia,KErrAccessDenied); |
|
868 |
r=KErrNone; |
|
869 |
if (!iNotifyChangeRequest->StatusPtr()) |
|
870 |
r = iNotifyChangeRequest->SetStatus((TRequestStatus*) a1); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
871 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_CONTROLNOTIFYCHANGE, "EControlNotifyChange; TLocDrvRequest Object=0x%x", (TUint) &m); |
0 | 872 |
break; |
873 |
case RLocalDrive::EControlNotifyChangeCancel: |
|
874 |
if (iCleanup.iThread != &Kern::CurrentThread()) |
|
875 |
Kern::PanicCurrentThread(KLitLocMedia,KErrAccessDenied); |
|
876 |
Kern::QueueRequestComplete(iCleanup.iThread,iNotifyChangeRequest,KErrCancel); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
877 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_CONTROLNOTIFYCHANGECANCEL, "EControlNotifyChangeCancel; TLocDrvRequest Object=0x%x", (TUint) &m); |
0 | 878 |
break; |
879 |
case RLocalDrive::EControlReadPasswordStore: |
|
880 |
{ |
|
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
881 |
TUint8 passData[TPasswordStore::EMaxPasswordLength]; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
882 |
m.RemoteDes() = (TAny*) passData; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
883 |
m.Length() = sizeof(passData); |
0 | 884 |
m.Id()=EReadPasswordStore; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
885 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_READPASSWORDSTORE, "EReadPasswordStore; TLocDrvRequest Object=0x%x", (TUint) &m); |
0 | 886 |
r=iDrive->Request(m); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
887 |
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
|
888 |
if (r==KErrNone) |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
889 |
{ |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
890 |
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
|
891 |
m.RemoteDes()=(TDes8*)a1; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
892 |
r = m.WriteRemote(&pData,0); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
893 |
} |
0 | 894 |
break; |
895 |
} |
|
896 |
case RLocalDrive::EControlWritePasswordStore: |
|
897 |
{ |
|
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
898 |
TUint8 passData[TPasswordStore::EMaxPasswordLength]; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
899 |
TPtr8 pData(passData, TPasswordStore::EMaxPasswordLength); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
900 |
|
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
901 |
DThread* pT=m.RemoteThread(); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
902 |
if (!pT) |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
903 |
pT=m.Client(); |
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 |
m.RemoteDes() = (TDes8*)a1; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
906 |
r = Kern::ThreadGetDesLength(pT, m.RemoteDes()); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
907 |
if ( r > pData.MaxLength() ) |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
908 |
r = KErrOverflow; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
909 |
if ( r < KErrNone) |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
910 |
break; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
911 |
|
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
912 |
r = m.ReadRemote(&pData,0); |
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 |
|
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
917 |
m.RemoteDes() = (TAny*) pData.Ptr(); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
918 |
m.Length() = pData.Length(); |
0 | 919 |
m.Id()=EWritePasswordStore; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
920 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_WRITEPASSWORDSTORE, "EWritePasswordStore; TLocDrvRequest Object=0x%x", (TUint) &m); |
0 | 921 |
r=iDrive->Request(m); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
922 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_WRITEPASSWORDSTORE_RETURN, "EReadPasswordStore Return; TLocDrvRequest Object=0x%x", (TUint) &m); |
0 | 923 |
if(r == KErrNone) |
924 |
iDrive->iPrimaryMedia->iTotalPartitionsOpened = 0; |
|
925 |
break; |
|
926 |
} |
|
927 |
case RLocalDrive::EControlPasswordStoreLengthInBytes: |
|
928 |
{ |
|
929 |
m.Id()=EPasswordStoreLengthInBytes; |
|
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
930 |
TInt length; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
931 |
m.RemoteDes() = (TAny*) &length; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
932 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_PASSWORDSTORELENGTH, "EPasswordStoreLengthInBytes; TLocDrvRequest Object=0x%x", (TUint) &m); |
0 | 933 |
r=iDrive->Request(m); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
934 |
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
|
935 |
|
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
936 |
if (r == KErrNone) |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
937 |
{ |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
938 |
m.RemoteDes()=a1; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
939 |
r = m.WriteRemoteRaw(&length,sizeof(TInt)); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
940 |
} |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
941 |
|
0 | 942 |
break; |
943 |
} |
|
944 |
case RLocalDrive::EControlGetLastErrorInfo: |
|
945 |
{ |
|
946 |
m.Id()=EGetLastErrorInfo; |
|
947 |
m.iArg[0]=this; |
|
948 |
TErrorInfoBuf errorInfoBuf; |
|
949 |
errorInfoBuf.SetMax(); |
|
950 |
errorInfoBuf.FillZ(); |
|
951 |
m.RemoteDes()=(TAny*) errorInfoBuf.Ptr(); // overload this |
|
952 |
m.Length() = errorInfoBuf.MaxLength(); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
953 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_GETLASTERRORINFO, "EGetLastErrorInfo; TLocDrvRequest Object=0x%x", (TUint) &m); |
0 | 954 |
r=iDrive->Request(m); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
955 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_CONTROLGETLASTERRORINFO_RETURN, "EControlGetLastErrorInfo Return; TLocDrvRequest Object=0x%x", (TUint) &m); |
0 | 956 |
Kern::InfoCopy(*(TDes8*)a1, errorInfoBuf); |
957 |
break; |
|
958 |
} |
|
959 |
case RLocalDrive::EControlDeleteNotify: |
|
960 |
{ |
|
961 |
m.Id()=EDeleteNotify; |
|
962 |
r=m.ProcessMessageData(a1); |
|
963 |
if (r==KErrNone) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
964 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
965 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_DELETENOTIFY, "EDeleteNotify; TLocDrvRequest Object=0x%x", (TUint) &m); |
0 | 966 |
r=iDrive->Request(m); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
967 |
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
|
968 |
} |
0 | 969 |
break; |
970 |
} |
|
971 |
||
972 |
case RLocalDrive::EControlQueryDevice: |
|
973 |
{ |
|
974 |
TBuf8<KMaxQueryDeviceLength> queryBuf; |
|
975 |
queryBuf.SetMax(); |
|
976 |
queryBuf.FillZ(); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
977 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
978 |
DThread* pT = m.Client(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
979 |
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
|
980 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
981 |
queryBuf.SetMax(); |
0 | 982 |
m.Id() = EQueryDevice; |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
983 |
m.iArg[0] = a1; // RLocalDrive::TQueryDevice |
0 | 984 |
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
|
985 |
m.Length() = KMaxQueryDeviceLength; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
986 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_QUERYDEVICE, "EQueryDevice; TLocDrvRequest Object=0x%x", (TUint) &m); |
0 | 987 |
r=iDrive->Request(m); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
988 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DLOCALDRIVE_REQUEST_QUERYDEVICE_RETURN, "EQueryDevice Return; TLocDrvRequest Object=0x%x", (TUint) &m); |
0 | 989 |
Kern::InfoCopy(*(TDes8*)a2, queryBuf); |
990 |
break; |
|
991 |
} |
|
992 |
||
993 |
} |
|
994 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("<DLocalDrive::DoControl D:%d M:%08x ret %d",iDrive->iDriveNumber, iDrive->iMedia, r)); |
|
995 |
__TRACE_TIMING(4); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
996 |
OstTraceFunctionExitExt( DLOCALDRIVE_REQUEST_EXIT, this, r ); |
0 | 997 |
return r; |
998 |
} |
|
999 |
||
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1000 |
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
|
1001 |
{ |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1002 |
TLocalDrivePasswordData clientData; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1003 |
TInt r = aReq.ReadRemoteRaw(&clientData, sizeof(TLocalDrivePasswordData)); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1004 |
|
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1005 |
DThread* pT = aReq.RemoteThread(); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1006 |
if (!pT) |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1007 |
pT = aReq.Client(); |
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 |
if (r == KErrNone) |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1010 |
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
|
1011 |
if (r == KErrNone) |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1012 |
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
|
1013 |
|
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1014 |
aPswData.iStorePasswd = clientData.iStorePasswd; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1015 |
aPswData.iOldPasswd = &aOldPasswd; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1016 |
aPswData.iNewPasswd = &aNewPasswd; |
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 |
|
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1019 |
aReq.RemoteDes() = (TAny*) &aPswData; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1020 |
aReq.Flags()|= TLocDrvRequest::EKernelBuffer; |
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 |
return r; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1023 |
} |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1024 |
|
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1025 |
|
0 | 1026 |
#ifdef __DEMAND_PAGING__ |
1027 |
TInt DLocalDrive::LockMountInfo(DPrimaryMediaBase& aPrimaryMedia, TLocDrvRequest& aReq) |
|
1028 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1029 |
OstTraceExt2(TRACE_FLOW, DLOCALDRIVE_LOCKMOUNTINFO_ENTRY, "> aPrimaryMedia=%x;aReq=%x", (TUint) &aPrimaryMedia, (TUint) &aReq ); |
0 | 1030 |
DMediaPagingDevice* pagingDevice = aPrimaryMedia.iBody->iPagingDevice; |
1031 |
if (pagingDevice == NULL) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1032 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1033 |
OstTraceFunctionExitExt( DLOCALDRIVE_LOCKMOUNTINFO_EXIT1, this, KErrNone ); |
0 | 1034 |
return KErrNone; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1035 |
} |
0 | 1036 |
|
1037 |
__ASSERT_DEBUG(pagingDevice->iMountInfoDataLock == NULL, LOCM_FAULT()); |
|
1038 |
__ASSERT_DEBUG(pagingDevice->iMountInfoDescHdrLock == NULL, LOCM_FAULT()); |
|
1039 |
__ASSERT_DEBUG(pagingDevice->iMountInfoDescLenLock == NULL, LOCM_FAULT()); |
|
1040 |
||
1041 |
DThread* pT = aReq.RemoteThread(); |
|
1042 |
if (!pT) |
|
1043 |
pT = &Kern::CurrentThread(); // e.g. when using TBusLocalDrive directly |
|
1044 |
||
1045 |
TInt length = 0; |
|
1046 |
TInt maxLength = 0; |
|
1047 |
TUint8* desAddress = NULL; |
|
1048 |
TInt r = Kern::ThreadGetDesInfo(pT,aReq.RemoteDes(),length,maxLength,desAddress,EFalse); // get descriptor length, maxlength and desAddress |
|
1049 |
if (r != KErrNone) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1050 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1051 |
OstTraceFunctionExitExt( DLOCALDRIVE_LOCKMOUNTINFO_EXIT2, this, r ); |
0 | 1052 |
return r; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1053 |
} |
0 | 1054 |
if (length == 0) |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1055 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1056 |
OstTraceFunctionExitExt( DLOCALDRIVE_LOCKMOUNTINFO_EXIT3, this, KErrNone ); |
0 | 1057 |
return KErrNone; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1058 |
} |
0 | 1059 |
|
1060 |
||
1061 |
static const TUint8 LengthLookup[16]={4,8,12,8,12,0,0,0,0,0,0,0,0,0,0,0}; |
|
1062 |
TUint32 desHdr; |
|
1063 |
r = Kern::ThreadRawRead(pT, aReq.RemoteDes(), &desHdr, sizeof(desHdr)); |
|
1064 |
if(r!=KErrNone) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1065 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1066 |
OstTraceFunctionExitExt( DLOCALDRIVE_LOCKMOUNTINFO_EXIT4, this, r ); |
0 | 1067 |
return r; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1068 |
} |
0 | 1069 |
TInt desType = desHdr >>KShiftDesType8; |
1070 |
TInt desHdrLen = LengthLookup[desType]; |
|
1071 |
if(!desHdrLen) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1072 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1073 |
OstTraceFunctionExitExt( DLOCALDRIVE_LOCKMOUNTINFO_EXIT5, this, KErrBadDescriptor ); |
0 | 1074 |
return KErrBadDescriptor; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1075 |
} |
0 | 1076 |
|
1077 |
||
1078 |
pagingDevice->iMountInfoDataLock = ThePinObjectAllocator->AcquirePinObject(); |
|
1079 |
pagingDevice->iMountInfoDescHdrLock = ThePinObjectAllocator->AcquirePinObject(); |
|
1080 |
pagingDevice->iMountInfoDescLenLock = ThePinObjectAllocator->AcquirePinObject(); |
|
1081 |
||
1082 |
if (pagingDevice->iMountInfoDataLock == NULL || |
|
1083 |
pagingDevice->iMountInfoDescHdrLock == NULL || |
|
1084 |
pagingDevice->iMountInfoDescLenLock == NULL) |
|
1085 |
{ |
|
1086 |
UnlockMountInfo(aPrimaryMedia); // tidy up |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1087 |
OstTraceFunctionExitExt( DLOCALDRIVE_LOCKMOUNTINFO_EXIT6, this, KErrNoMemory ); |
0 | 1088 |
return KErrNoMemory; |
1089 |
} |
|
1090 |
||
1091 |
||
1092 |
// First pin the descriptor header |
|
1093 |
DPinObjectAllocator::SVirtualPinContainer* lock; |
|
1094 |
lock = (DPinObjectAllocator::SVirtualPinContainer*) pagingDevice->iMountInfoDescHdrLock; |
|
1095 |
r = Kern::PinVirtualMemory(lock->iObject, (TLinAddr) (TUint8*) aReq.RemoteDes(), desHdrLen, pT); |
|
1096 |
if (r != KErrNone) |
|
1097 |
{ |
|
1098 |
UnlockMountInfo(aPrimaryMedia); // tidy up |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1099 |
OstTraceFunctionExitExt( DLOCALDRIVE_LOCKMOUNTINFO_EXIT7, this, KErrNoMemory ); |
0 | 1100 |
return KErrNoMemory; |
1101 |
} |
|
1102 |
||
1103 |
||
1104 |
||
1105 |
// For EBufCPtr-type descriptors, need to pin the extra length before the buffer (!) |
|
1106 |
lock = (DPinObjectAllocator::SVirtualPinContainer*) pagingDevice->iMountInfoDescLenLock; |
|
1107 |
if (desType == EBufCPtr) |
|
1108 |
{ |
|
1109 |
TLinAddr extraLenAddr = TLinAddr(desAddress) - aReq.RemoteDesOffset() - sizeof(TUint32); |
|
1110 |
r = Kern::PinVirtualMemory(lock->iObject, (TLinAddr) (TUint8*) extraLenAddr, sizeof(TUint32), pT); |
|
1111 |
if (r != KErrNone) |
|
1112 |
{ |
|
1113 |
UnlockMountInfo(aPrimaryMedia); // tidy up |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1114 |
OstTraceFunctionExitExt( DLOCALDRIVE_LOCKMOUNTINFO_EXIT8, this, KErrNoMemory ); |
0 | 1115 |
return KErrNoMemory; |
1116 |
} |
|
1117 |
} |
|
1118 |
||
1119 |
||
1120 |
// Now pin the descriptor contents |
|
1121 |
lock = (DPinObjectAllocator::SVirtualPinContainer*) pagingDevice->iMountInfoDataLock; |
|
1122 |
r = Kern::PinVirtualMemory(lock->iObject, (TLinAddr) desAddress, length, pT); |
|
1123 |
if (r != KErrNone) |
|
1124 |
{ |
|
1125 |
UnlockMountInfo(aPrimaryMedia); // tidy up |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1126 |
OstTraceFunctionExitExt( DLOCALDRIVE_LOCKMOUNTINFO_EXIT9, this, KErrNoMemory ); |
0 | 1127 |
return KErrNoMemory; |
1128 |
} |
|
1129 |
||
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1130 |
OstTraceFunctionExitExt( DLOCALDRIVE_LOCKMOUNTINFO_EXIT10, this, KErrNone ); |
0 | 1131 |
return KErrNone; |
1132 |
} |
|
1133 |
||
1134 |
||
1135 |
void DLocalDrive::UnlockMountInfo(DPrimaryMediaBase& aPrimaryMedia) |
|
1136 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1137 |
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
|
1138 |
|
0 | 1139 |
DMediaPagingDevice* pagingDevice = aPrimaryMedia.iBody->iPagingDevice; |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1140 |
if (pagingDevice == NULL) |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1141 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1142 |
OstTraceFunctionExit1( DLOCALDRIVE_UNLOCKMOUNTINFO_EXIT1, this ); |
0 | 1143 |
return; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1144 |
} |
0 | 1145 |
|
1146 |
||
1147 |
if (pagingDevice->iMountInfoDataLock) |
|
1148 |
{ |
|
1149 |
Kern::UnpinVirtualMemory(((DPinObjectAllocator::SVirtualPinContainer*) pagingDevice->iMountInfoDataLock)->iObject); |
|
1150 |
ThePinObjectAllocator->ReleasePinObject((DPinObjectAllocator::SVirtualPinContainer*) pagingDevice->iMountInfoDataLock); |
|
1151 |
pagingDevice->iMountInfoDataLock = NULL; |
|
1152 |
} |
|
1153 |
||
1154 |
if (pagingDevice->iMountInfoDescHdrLock) |
|
1155 |
{ |
|
1156 |
Kern::UnpinVirtualMemory(((DPinObjectAllocator::SVirtualPinContainer*) pagingDevice->iMountInfoDescHdrLock)->iObject); |
|
1157 |
ThePinObjectAllocator->ReleasePinObject((DPinObjectAllocator::SVirtualPinContainer*) pagingDevice->iMountInfoDescHdrLock); |
|
1158 |
pagingDevice->iMountInfoDescHdrLock = NULL; |
|
1159 |
} |
|
1160 |
||
1161 |
if (pagingDevice->iMountInfoDescLenLock) |
|
1162 |
{ |
|
1163 |
Kern::UnpinVirtualMemory(((DPinObjectAllocator::SVirtualPinContainer*) pagingDevice->iMountInfoDescLenLock)->iObject); |
|
1164 |
ThePinObjectAllocator->ReleasePinObject((DPinObjectAllocator::SVirtualPinContainer*) pagingDevice->iMountInfoDescLenLock); |
|
1165 |
pagingDevice->iMountInfoDescLenLock = NULL; |
|
1166 |
} |
|
1167 |
||
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1168 |
OstTraceFunctionExit1( DLOCALDRIVE_UNLOCKMOUNTINFO_EXIT2, this ); |
0 | 1169 |
} |
1170 |
#endif // __DEMAND_PAGING__ |
|
1171 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1172 |
void DLocalDrive::NotifyChange() |
0 | 1173 |
{ |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1174 |
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
|
1175 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1176 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1177 |
// Complete any notification request on media change |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1178 |
DThread* pC=NULL; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1179 |
NKern::LockSystem(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1180 |
if (iCleanup.iThread) |
0 | 1181 |
{ |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1182 |
pC=iCleanup.iThread; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1183 |
pC->Open(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1184 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1185 |
NKern::UnlockSystem(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1186 |
if (pC) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1187 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1188 |
TBool b = ETrue; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1189 |
// 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
|
1190 |
if (iNotifyChangeRequest->IsReady()) |
0 | 1191 |
{ |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1192 |
*((TBool*) iNotifyChangeRequest->Buffer()) = b; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1193 |
Kern::QueueRequestComplete(pC,iNotifyChangeRequest,KErrNone); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1194 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1195 |
// 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
|
1196 |
// 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
|
1197 |
// N.B. Must NOT do this on data paging media |
0 | 1198 |
#ifdef __DEMAND_PAGING__ |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1199 |
else if (!DataPagingDfcQ(iDrive->iPrimaryMedia)) |
0 | 1200 |
#else |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1201 |
else |
0 | 1202 |
#endif |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1203 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1204 |
Kern::ThreadRawWrite(pC, iNotifyChangeRequest->DestPtr(), &b, sizeof(b), NULL); |
0 | 1205 |
} |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1206 |
pC->AsyncClose(); |
0 | 1207 |
} |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1208 |
OstTraceFunctionExit1( DLOCALDRIVE_NOTIFYCHANGE_EXIT, this ); |
0 | 1209 |
} |
1210 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1211 |
// 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
|
1212 |
TInt DLocalDrive::MediaChangeCallback(TAny* aLocalDrive, TInt /* aNotifyType*/) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1213 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1214 |
((DLocalDrive*) aLocalDrive)->NotifyChange(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1215 |
return KErrNone; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1216 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1217 |
|
0 | 1218 |
TLocalDriveCleanup::TLocalDriveCleanup() |
1219 |
{ |
|
1220 |
} |
|
1221 |
||
1222 |
// This will be called when the original client thread exits |
|
1223 |
// It is called in the context of the exiting thread with the system locked. |
|
1224 |
void TLocalDriveCleanup::Cleanup() |
|
1225 |
{ |
|
1226 |
DLocalDrive& d=LocalDrive(); |
|
1227 |
d.iNotifyChangeRequest=NULL; |
|
1228 |
DThread* pC=iThread; |
|
1229 |
Remove(); |
|
1230 |
iThread=NULL; |
|
1231 |
NKern::UnlockSystem(); |
|
1232 |
pC->Close(NULL); // balances Open() in DoCreate |
|
1233 |
NKern::LockSystem(); |
|
1234 |
} |
|
1235 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1236 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1237 |
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
|
1238 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1239 |
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
|
1240 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1241 |
return KErrPermissionDenied; |
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 |
|
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 |
if (aDriveNumber >= KMaxLocalDrives) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1246 |
return KErrArgument; |
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 |
TLocDrv* drive = TheDrives[aDriveNumber]; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1249 |
if (!drive) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1250 |
return KErrNotSupported; |
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 |
TLocDrvRequest request; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1253 |
memclr(&request, sizeof(request)); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1254 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1255 |
request.Drive() = drive; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1256 |
request.Id() = DLocalDrive::ECaps; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1257 |
request.Length() = aCaps.Length(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1258 |
request.RemoteDes() = (TAny*) aCaps.Ptr(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1259 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1260 |
return request.SendReceive(&drive->iPrimaryMedia->iMsgQ); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1261 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1262 |
|
0 | 1263 |
/******************************************** |
1264 |
* Local drive request class |
|
1265 |
********************************************/ |
|
1266 |
||
1267 |
/** |
|
1268 |
Reads data from the descriptor specified in the request, from the requesting |
|
1269 |
thread's process. |
|
1270 |
||
1271 |
This is used by the media driver to read data from a descriptor in the |
|
1272 |
requesting thread. The remote data is copied into the specified descriptor, |
|
1273 |
starting at the specified offset within that descriptor's data area. |
|
1274 |
||
1275 |
@param aDes The target descriptor into which data from the remote thread |
|
1276 |
is to be put. |
|
1277 |
@param anOffset The offset within the target descriptor data area, where data |
|
1278 |
from the remote thread is to be put. Note that this parameter |
|
1279 |
may be useful when write operations to the media must be broken |
|
1280 |
up into smaller chunks than the length requested. |
|
1281 |
||
1282 |
@return KErrNone,if successful, otherwise one of the other |
|
1283 |
system-wide error codes. |
|
1284 |
||
1285 |
@see Kern::ThreadDesRead() |
|
1286 |
*/ |
|
1287 |
EXPORT_C TInt TLocDrvRequest::ReadRemote(TDes8* aDes, TInt anOffset) |
|
1288 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1289 |
OstTraceFunctionEntry1( TLOCDRVREQUEST_READREMOTE_ENTRY, this ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1290 |
TInt r; |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1291 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1292 |
if (Flags() & TLocDrvRequest::EKernelBuffer) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1293 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1294 |
(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
|
1295 |
aDes->SetLength(aDes->MaxLength()); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1296 |
return KErrNone; |
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 |
|
0 | 1299 |
DThread* pT=RemoteThread(); |
1300 |
if (!pT) |
|
1301 |
pT=Client(); |
|
1302 |
||
1303 |
#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 |
|
1304 |
if (Flags() & ETClientBuffer) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1305 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1306 |
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
|
1307 |
OstTraceFunctionExitExt( TLOCDRVREQUEST_READREMOTE_EXIT1, this, r ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1308 |
return r; |
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 |
|
0 | 1311 |
__ASSERT_ALWAYS((Flags() & ETClientBuffer) == 0, LOCM_FAULT()); |
1312 |
#endif |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1313 |
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
|
1314 |
OstTraceFunctionExitExt( TLOCDRVREQUEST_READREMOTE_EXIT2, this, r ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1315 |
return r; |
0 | 1316 |
} |
1317 |
||
1318 |
||
1319 |
||
1320 |
||
1321 |
/** |
|
1322 |
Reads data from an arbitrary descriptor in the requesting thread's process. |
|
1323 |
||
1324 |
This is used by the media driver to read data from a descriptor in the |
|
1325 |
requesting thread. |
|
1326 |
||
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1327 |
NB This is NOT supported on datapaging media as there is no guarantee |
0 | 1328 |
that the remote descriptor won't be paged out. If this function is called and |
1329 |
data-paging is enabled the kernel will fault in debug mode and return |
|
1330 |
KErrNotSupported in release mode. |
|
1331 |
||
1332 |
@param aSrc A pointer to the source descriptor in the requesting thread's |
|
1333 |
address space. |
|
1334 |
@param aDes The target descriptor into which data from the remote thread |
|
1335 |
is to be put. |
|
1336 |
||
1337 |
@return KErrNone,if successful, |
|
1338 |
KErrNotSupported if data-paging is enabled |
|
1339 |
otherwise one of the other system-wide error codes. |
|
1340 |
||
1341 |
@see Kern::ThreadDesRead() |
|
1342 |
*/ |
|
1343 |
EXPORT_C TInt TLocDrvRequest::ReadRemote(const TAny* aSrc, TDes8* aDes) |
|
1344 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1345 |
OstTraceFunctionEntry1( TLOCDRVREQUEST_READ_REMOTE_ENTRY, this ); |
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1346 |
if (Flags() & TLocDrvRequest::EKernelBuffer) |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1347 |
{ |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1348 |
aDes->Copy(* (TDesC8*) aSrc); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1349 |
return KErrNone; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1350 |
} |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1351 |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1352 |
TInt r; |
0 | 1353 |
DThread* pT=RemoteThread(); |
1354 |
if (!pT) |
|
1355 |
pT=Client(); |
|
1356 |
||
1357 |
#ifdef __DEMAND_PAGING__ |
|
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1358 |
__ASSERT_DEBUG(!DataPagingDfcQ(Drive()->iPrimaryMedia), LOCM_FAULT()); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1359 |
|
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1360 |
if (DataPagingDfcQ(Drive()->iPrimaryMedia)) |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1361 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1362 |
OstTraceFunctionExitExt( TLOCDRVREQUEST_READ_REMOTE_EXIT1, this, KErrNotSupported ); |
0 | 1363 |
return KErrNotSupported; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1364 |
} |
0 | 1365 |
#endif |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1366 |
|
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1367 |
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
|
1368 |
OstTraceFunctionExitExt( TLOCDRVREQUEST_READ_REMOTE_EXIT2, this, r ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1369 |
return r; |
0 | 1370 |
} |
1371 |
||
1372 |
||
1373 |
||
1374 |
||
1375 |
/** |
|
1376 |
Reads raw data from the requesting thread's process. |
|
1377 |
||
1378 |
This is used by the media driver to read raw data from a location in requesting |
|
1379 |
thread's address space. The remote data is copied into the specified |
|
1380 |
buffer. |
|
1381 |
||
1382 |
@param aDest A pointer to the buffer where the data is to be written. |
|
1383 |
@param aSize The number of bytes to read. |
|
1384 |
||
1385 |
@return KErrNone,if successful, otherwise one of the other |
|
1386 |
system-wide error codes. |
|
1387 |
||
1388 |
@see Kern::ThreadRawRead() |
|
1389 |
*/ |
|
1390 |
EXPORT_C TInt TLocDrvRequest::ReadRemoteRaw(TAny* aDest, TInt aSize) |
|
1391 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1392 |
OstTraceFunctionEntry1( TLOCDRVREQUEST_READREMOTERAW_ENTRY, this ); |
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1393 |
if (Flags() & TLocDrvRequest::EKernelBuffer) |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1394 |
{ |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1395 |
(void)memcpy(aDest, (TAny*) RemoteDes(), aSize); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1396 |
return KErrNone; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1397 |
} |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1398 |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1399 |
TInt r; |
0 | 1400 |
DThread* pT=RemoteThread(); |
1401 |
if (!pT) |
|
1402 |
pT=Client(); |
|
1403 |
||
1404 |
#ifdef __DEMAND_PAGING__ |
|
1405 |
__ASSERT_ALWAYS((Flags() & ETClientBuffer) == 0, LOCM_FAULT()); |
|
1406 |
#endif |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1407 |
|
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1408 |
r = Kern::ThreadRawRead(pT,RemoteDes(),aDest,aSize); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1409 |
OstTraceFunctionExitExt( TLOCDRVREQUEST_READREMOTERAW_EXIT, this, r ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1410 |
return r; |
0 | 1411 |
} |
1412 |
||
1413 |
||
1414 |
/** |
|
1415 |
Writes data to a descriptor in the requesting thread's process. |
|
1416 |
||
1417 |
This is used by the media driver to write data to a descriptor in the requesting |
|
1418 |
thread. Data is copied from the specified descriptor, starting at the specified |
|
1419 |
offset within that descriptor's data area. |
|
1420 |
||
1421 |
@param aDes The source descriptor from which data is to be written to |
|
1422 |
the remote thread. |
|
1423 |
||
1424 |
@param anOffset The offset within the source descriptor data area, from where data |
|
1425 |
is to be written to the remote thread. Note that this parameter |
|
1426 |
may be useful when read operations from the media must be broken |
|
1427 |
up into smaller chunks than the length requested. |
|
1428 |
||
1429 |
@return KErrNone,if successful, otherwise one of the other |
|
1430 |
system-wide error codes. |
|
1431 |
||
1432 |
@see Kern::ThreadDesWrite() |
|
1433 |
*/ |
|
1434 |
EXPORT_C TInt TLocDrvRequest::WriteRemote(const TDesC8* aDes, TInt anOffset) |
|
1435 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1436 |
OstTraceFunctionEntry1( TLOCDRVREQUEST_WRITEREMOTE_ENTRY, this ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1437 |
TInt r; |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1438 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1439 |
if (Flags() & TLocDrvRequest::EKernelBuffer) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1440 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1441 |
(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
|
1442 |
OstTraceFunctionExitExt( TLOCDRVREQUEST_WRITEREMOTE_EXIT1, this, KErrNone ); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1443 |
return KErrNone; |
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 |
|
0 | 1446 |
DThread* pC=Client(); |
1447 |
DThread* pT=RemoteThread(); |
|
1448 |
if (!pT) |
|
1449 |
pT=pC; |
|
1450 |
||
1451 |
#ifdef __DEMAND_PAGING__ |
|
1452 |
if (Flags() & ETClientBuffer) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1453 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1454 |
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
|
1455 |
OstTraceFunctionExitExt( TLOCDRVREQUEST_WRITEREMOTE_EXIT2, this, r ); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1456 |
return r; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1457 |
} |
0 | 1458 |
#endif |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1459 |
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
|
1460 |
OstTraceFunctionExitExt( TLOCDRVREQUEST_WRITEREMOTE_EXIT3, this, r ); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1461 |
return r; |
0 | 1462 |
} |
1463 |
||
1464 |
||
1465 |
/** |
|
1466 |
Writes raw data to the requesting thread's process. |
|
1467 |
||
1468 |
This is used by the media driver to write raw data to a location in the |
|
1469 |
requesting thread's address space. |
|
1470 |
||
1471 |
@param aSrc The source addres from which data is to be written to |
|
1472 |
the remote thread. |
|
1473 |
||
1474 |
@param aSize The number of bytes to write. |
|
1475 |
||
1476 |
@return KErrNone,if successful, otherwise one of the other |
|
1477 |
system-wide error codes. |
|
1478 |
||
1479 |
@see Kern::ThreadRawWrite() |
|
1480 |
*/ |
|
1481 |
EXPORT_C TInt TLocDrvRequest::WriteRemoteRaw(const TAny* aSrc, TInt aSize) |
|
1482 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1483 |
OstTraceFunctionEntry1( TLOCDRVREQUEST_WRITEREMOTERAW_ENTRY, this ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1484 |
TInt r; |
0 | 1485 |
DThread* pC=Client(); |
1486 |
DThread* pT=RemoteThread(); |
|
1487 |
if (!pT) |
|
1488 |
pT=pC; |
|
1489 |
||
1490 |
#ifdef __DEMAND_PAGING__ |
|
1491 |
__ASSERT_ALWAYS((Flags() & ETClientBuffer) == 0, LOCM_FAULT()); |
|
1492 |
#endif |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1493 |
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
|
1494 |
OstTraceFunctionExitExt( TLOCDRVREQUEST_WRITEREMOTERAW_EXIT, this, r ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1495 |
return r; |
0 | 1496 |
} |
1497 |
||
1498 |
||
1499 |
TInt TLocDrvRequest::ProcessMessageData(TAny* aPtr) |
|
1500 |
// |
|
1501 |
// Get read/write parameters from client and open remote thread |
|
1502 |
// |
|
1503 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1504 |
OstTraceFunctionEntry1( TLOCDRVREQUEST_PROCESSMESSAGEDATA_ENTRY, this ); |
0 | 1505 |
RemoteThread()=NULL; |
1506 |
DThread& t=Kern::CurrentThread(); |
|
1507 |
TLocalDriveMessageData d; |
|
1508 |
kumemget32(&d,aPtr,sizeof(d)); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1509 |
OstTrace1( TRACE_INTERNALS, TLOCDRVREQUEST_PROCESSMESSAGEDATA, "Message handle=%d", d.iHandle ); |
0 | 1510 |
if (d.iHandle!=KLocalMessageHandle && Id()!=DLocalDrive::EFormat) |
1511 |
{ |
|
1512 |
NKern::LockSystem(); |
|
1513 |
DThread* pT = RMessageK::MessageK(d.iHandle)->iClient; |
|
1514 |
if (!pT || pT->Open()!=KErrNone) |
|
1515 |
{ |
|
1516 |
NKern::UnlockSystem(); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1517 |
OstTraceFunctionExitExt( TLOCDRVREQUEST_PROCESSMESSAGEDATA_EXIT1, this, KErrBadHandle ); |
0 | 1518 |
return KErrBadHandle; |
1519 |
} |
|
1520 |
t.iExtTempObj=pT; |
|
1521 |
RemoteThread()=pT; |
|
1522 |
NKern::UnlockSystem(); |
|
1523 |
} |
|
1524 |
Pos()=d.iPos; |
|
1525 |
Length()=d.iLength; |
|
1526 |
RemoteDes()=(TAny*)d.iPtr; |
|
1527 |
RemoteDesOffset()=d.iOffset; |
|
1528 |
DriverFlags()=d.iFlags; |
|
1529 |
if (Pos()<0 || Length()<0) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1530 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1531 |
OstTraceFunctionExitExt( TLOCDRVREQUEST_PROCESSMESSAGEDATA_EXIT2, this, KErrArgument ); |
0 | 1532 |
return KErrArgument; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1533 |
} |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1534 |
OstTraceFunctionExitExt( TLOCDRVREQUEST_PROCESSMESSAGEDATA_EXIT3, this, KErrNone ); |
0 | 1535 |
return KErrNone; |
1536 |
} |
|
1537 |
||
1538 |
void TLocDrvRequest::CloseRemoteThread() |
|
1539 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1540 |
OstTraceFunctionEntry1( TLOCDRVREQUEST_CLOSEREMOTETHREAD_ENTRY, this ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1541 |
|
0 | 1542 |
if (!RemoteThread()) |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1543 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1544 |
OstTraceFunctionExit1( TLOCDRVREQUEST_CLOSEREMOTETHREAD_EXIT1, this ); |
0 | 1545 |
return; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1546 |
} |
0 | 1547 |
NKern::ThreadEnterCS(); |
1548 |
DThread& t=Kern::CurrentThread(); |
|
1549 |
RemoteThread()=NULL; |
|
1550 |
Kern::SafeClose((DObject*&)t.iExtTempObj,NULL); |
|
1551 |
NKern::ThreadLeaveCS(); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1552 |
OstTraceFunctionExit1( TLOCDRVREQUEST_CLOSEREMOTETHREAD_EXIT2, this ); |
0 | 1553 |
} |
1554 |
||
1555 |
EXPORT_C TInt TLocDrvRequest::CheckAndAdjustForPartition() |
|
1556 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1557 |
OstTraceFunctionEntry1( TLOCDRVREQUEST_CHECKANDADJUSTFORPARTITION_ENTRY, this ); |
0 | 1558 |
TLocDrv& d=*Drive(); |
1559 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("CheckAndAdjustForPartition drive %d partition len %lx",d.iDriveNumber,d.iPartitionLen)); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1560 |
OstTraceExt2( TRACE_INTERNALS, TLOCDRVREQUEST_CHECKANDADJUSTFORPARTITION1, "iDriveNumber=%d; partition length=0x%lx", d.iDriveNumber, (TInt) d.iPartitionLen ); |
0 | 1561 |
Flags() |= EAdjusted; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1562 |
TInt r; |
0 | 1563 |
switch (Id()) |
1564 |
{ |
|
1565 |
case DLocalDrive::ECaps: |
|
1566 |
case DLocalDrive::EForceMediaChange: |
|
1567 |
case DLocalDrive::EPasswordLock: |
|
1568 |
case DLocalDrive::EPasswordUnlock: |
|
1569 |
case DLocalDrive::EPasswordClear: |
|
1570 |
case DLocalDrive::EPasswordErase: |
|
1571 |
case DLocalDrive::EReadPasswordStore: |
|
1572 |
case DLocalDrive::EWritePasswordStore: |
|
1573 |
case DLocalDrive::EPasswordStoreLengthInBytes: |
|
1574 |
case DLocalDrive::EQueryDevice: |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1575 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1576 |
r = KErrNone; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1577 |
break; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1578 |
} |
0 | 1579 |
case DLocalDrive::EEnlarge: |
1580 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("Enlarge request %lx",Length())); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1581 |
OstTrace1( TRACE_INTERNALS, TLOCDRVREQUEST_CHECKANDADJUSTFORPARTITION2, "Enlarge request=0x%lx", Length() ); |
0 | 1582 |
if (Length()>KMaxTInt) |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1583 |
r = KErrArgument; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1584 |
else |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1585 |
r = KErrNone; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1586 |
break; |
0 | 1587 |
case DLocalDrive::EReduce: |
1588 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("Reduce request %lx@%lx",Length(),Pos())); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1589 |
OstTraceExt2( TRACE_INTERNALS, TLOCDRVREQUEST_CHECKANDADJUSTFORPARTITION3, "Reduce request length=0x%lx; position=0x%lx", (TUint) Length(), (TUint) Pos() ); |
0 | 1590 |
if (Pos()+Length()>d.iPartitionLen) |
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::EFormat: |
1596 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("Format request %lx@%lx",Length(),Pos())); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1597 |
OstTraceExt2( TRACE_INTERNALS, TLOCDRVREQUEST_CHECKANDADJUSTFORPARTITION4, "Format request length=0x%lx; position=0x%lx", (TUint) Length(), (TUint) Pos() ); |
0 | 1598 |
if (!(DriverFlags() & RLocalDrive::ELocDrvWholeMedia)) |
1599 |
{ |
|
1600 |
if (Pos()>d.iPartitionLen) |
|
1601 |
{ |
|
1602 |
Length()=0; |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1603 |
r = KErrEof; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1604 |
break; |
0 | 1605 |
} |
1606 |
Int64 left=d.iPartitionLen-Pos(); |
|
1607 |
if (left<Length()) |
|
1608 |
Length()=left; |
|
1609 |
Pos()+=d.iPartitionBaseAddr; |
|
1610 |
if (Length()==0) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1611 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1612 |
r = KErrEof; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1613 |
break; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1614 |
} |
0 | 1615 |
} |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1616 |
r = KErrNone; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1617 |
break; |
0 | 1618 |
|
1619 |
#ifdef __DEMAND_PAGING__ |
|
1620 |
case DMediaPagingDevice::ERomPageInRequest: |
|
1621 |
// if the ROM was reported to LOCM then it will also need to be adjusted.... |
|
1622 |
// Otherwise the media driver adjust it internally |
|
1623 |
case DMediaPagingDevice::ECodePageInRequest: |
|
1624 |
__KTRACE_OPT(KLOCDPAGING,Kern::Printf("Adjusted Paging read request %lx@%lx",Length(),Pos())); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1625 |
OstTraceDefExt2(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, TLOCDRVREQUESTCHECKANDADJUSTFORPARTITION5, "Adjusted Paging read request length=0x%lx; position=0x%lx", (TUint) Length(), (TUint) Pos()); |
0 | 1626 |
if (Pos()+Length()>d.iPartitionLen) |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1627 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1628 |
r = KErrArgument; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1629 |
break; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1630 |
} |
0 | 1631 |
Pos()+=d.iPartitionBaseAddr; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1632 |
r = KErrNone; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1633 |
break; |
0 | 1634 |
#endif |
1635 |
||
1636 |
default: // read or write or fragment |
|
1637 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("R/W request %lx@%lx",Length(),Pos())); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1638 |
OstTraceExt2( TRACE_INTERNALS, TLOCDRVREQUEST_CHECKANDADJUSTFORPARTITION6, "Read/Write request length=0x%x; position=0x%x", (TUint) Length(), (TUint) Pos() ); |
0 | 1639 |
if (DriverFlags() & RLocalDrive::ELocDrvWholeMedia) |
1640 |
{ |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1641 |
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
|
1642 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1643 |
r = KErrArgument; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1644 |
break; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1645 |
} |
0 | 1646 |
} |
1647 |
else |
|
1648 |
{ |
|
1649 |
if (Pos()+Length() > d.iPartitionLen) |
|
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 |
Pos()+=d.iPartitionBaseAddr; |
1655 |
} |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1656 |
r = KErrNone; |
0 | 1657 |
} |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1658 |
OstTraceFunctionExitExt( TLOCDRVREQUEST_CHECKANDADJUSTFORPARTITION_EXIT, this, r ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1659 |
return r; |
0 | 1660 |
} |
1661 |
||
1662 |
/******************************************** |
|
1663 |
* Local drive class |
|
1664 |
********************************************/ |
|
1665 |
TLocDrv::TLocDrv(TInt aDriveNumber) |
|
1666 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1667 |
OstTraceFunctionEntryExt( TLOCDRV_TLOCDRV_ENTRY, this ); |
0 | 1668 |
memclr(this, sizeof(TLocDrv)); |
1669 |
iDriveNumber=aDriveNumber; |
|
1670 |
iPartitionNumber=-1; |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1671 |
iMediaChangeObserver.iFunction = MediaChangeCallback; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1672 |
iMediaChangeObserver.iPtr= this; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1673 |
iMediaChangeObserver.iObjectType = TCallBackLink::ETLocDrvObject; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1674 |
OstTraceFunctionExit1( TLOCDRV_TLOCDRV_EXIT, this ); |
0 | 1675 |
} |
1676 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1677 |
TInt TLocDrv::MediaChangeCallback(TAny* aLocDrv, TInt aNotifyType) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1678 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1679 |
__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
|
1680 |
if (aNotifyType == DPrimaryMediaBase::EMediaPresent) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1681 |
return ((TLocDrv*) aLocDrv)->iPrimaryMedia->iBody->iMediaPresentDfc.Enque(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1682 |
else |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1683 |
return ((TLocDrv*) aLocDrv)->iPrimaryMedia->iBody->iMediaChangeDfc.Enque(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1684 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1685 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1686 |
|
0 | 1687 |
/** |
1688 |
Initialises the DMedia entity with the media device number and ID. |
|
1689 |
||
1690 |
@param aDevice The unique ID for this device. This can take one of the |
|
1691 |
enumerated values defined in TMediaDevice enum. |
|
1692 |
||
1693 |
@param aMediaId The unique ID to associate with this media entity. |
|
1694 |
||
1695 |
@return KErrNone,if successful, otherwise one of the other |
|
1696 |
system-wide error codes. |
|
1697 |
||
1698 |
@see TMediaDevice |
|
1699 |
*/ |
|
1700 |
EXPORT_C TInt DMedia::Create(TMediaDevice aDevice, TInt aMediaId, TInt) |
|
1701 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1702 |
OstTraceFunctionEntry1( DMEDIA_CREATE_ENTRY, this ); |
0 | 1703 |
__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
|
1704 |
OstTraceExt2(TRACE_INTERNALS, DMEDIA_CREATE, "media=%d; device=%d", aMediaId, (TUint) aDevice); |
0 | 1705 |
iMediaId=aMediaId; |
1706 |
iDevice=aDevice; |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1707 |
OstTraceFunctionExitExt( DMEDIA_CREATE_EXIT, this, KErrNone ); |
0 | 1708 |
return KErrNone; |
1709 |
} |
|
1710 |
||
1711 |
/******************************************** |
|
1712 |
* Primary Media Class |
|
1713 |
********************************************/ |
|
1714 |
void asyncDfc(TAny* aPtr) |
|
1715 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1716 |
OstTraceFunctionEntry0( _ASYNCDFC_ENTRY ); |
0 | 1717 |
DPrimaryMediaBase* pM=(DPrimaryMediaBase*)aPtr; |
1718 |
if (pM->iState==DMedia::EOpening) |
|
1719 |
pM->DoOpenMediaDriverComplete(pM->iAsyncErrorCode); |
|
1720 |
else if (pM->iState==DMedia::EReadPartitionInfo) |
|
1721 |
pM->DoPartitionInfoComplete(pM->iAsyncErrorCode); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1722 |
OstTraceFunctionExit0( _ASYNCDFC_EXIT ); |
0 | 1723 |
} |
1724 |
||
1725 |
void handleMsg(TAny* aPtr) |
|
1726 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1727 |
OstTraceFunctionEntry0( _HANDLEMSG_ENTRY ); |
0 | 1728 |
DPrimaryMediaBase* primaryMedia=(DPrimaryMediaBase*)aPtr; |
1729 |
||
1730 |
for(TLocDrvRequest* m = (TLocDrvRequest*) primaryMedia->iMsgQ.iMessage; |
|
1731 |
m != NULL; |
|
1732 |
m = (TLocDrvRequest*) primaryMedia->iMsgQ.Poll()) |
|
1733 |
{ |
|
1734 |
#if defined(_DEBUG) |
|
1735 |
if (!primaryMedia->iMsgQ.iQ.IsEmpty()) |
|
1736 |
__KTRACE_OPT(KLOCDRV, Kern::Printf("TRACE: handleMsg, queue not empty %08X", m)); |
|
1737 |
#endif |
|
1738 |
primaryMedia->HandleMsg(*m); |
|
1739 |
||
1740 |
#ifdef __DEMAND_PAGING__ |
|
1741 |
// don't empty the queue if this media is paging as there |
|
1742 |
// may be a (higher-priority) paging DFC waiting to run... |
|
1743 |
if (primaryMedia->iPagingMedia) |
|
1744 |
break; |
|
1745 |
#endif |
|
1746 |
} |
|
1747 |
||
1748 |
||
1749 |
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
|
1750 |
OstTraceFunctionExit0( _HANDLEMSG_EXIT ); |
0 | 1751 |
} |
1752 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1753 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1754 |
void mediaChangeDfc(TAny* aPtr) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1755 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1756 |
DPrimaryMediaBase* pM = (DPrimaryMediaBase*)aPtr; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1757 |
pM->NotifyMediaChange(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1758 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1759 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1760 |
void mediaPresentDfc(TAny* aPtr) |
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 |
DPrimaryMediaBase* pM = (DPrimaryMediaBase*)aPtr; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1763 |
pM->NotifyMediaPresent(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1764 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1765 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1766 |
DPrimaryMediaBase::DBody::DBody(DPrimaryMediaBase& aPrimaryMediaBase) : |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1767 |
iPrimaryMediaBase(aPrimaryMediaBase), |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1768 |
iMediaChangeDfc(mediaChangeDfc, &aPrimaryMediaBase, KMaxDfcPriority), |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1769 |
iMediaPresentDfc(mediaPresentDfc, &aPrimaryMediaBase, KMaxDfcPriority) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1770 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1771 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1772 |
|
0 | 1773 |
EXPORT_C DPrimaryMediaBase::DPrimaryMediaBase() |
1774 |
: iMsgQ(handleMsg, this, NULL, 1), |
|
1775 |
iDeferred(NULL, NULL, NULL, 0), // callback never used |
|
1776 |
iWaitMedChg(NULL, NULL, NULL, 0), // callback never used |
|
1777 |
iAsyncDfc(asyncDfc, this, 1) |
|
1778 |
/** |
|
1779 |
Constructor of DPrimaryMediaBase class. |
|
1780 |
Initialises the media state as closed. |
|
1781 |
*/ |
|
1782 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1783 |
OstTraceFunctionEntry1( DPRIMARYMEDIABASE_DPRIMARYMEDIABASE_ENTRY, this ); |
0 | 1784 |
iState = EClosed; |
1785 |
} |
|
1786 |
||
1787 |
||
1788 |
||
1789 |
EXPORT_C TInt DPrimaryMediaBase::Create(TMediaDevice aDevice, TInt aMediaId, TInt aLastMediaId) |
|
1790 |
/** |
|
1791 |
Called from LocDrv::RegisterMediaDevice() function. |
|
1792 |
Calls DMedia::Create() |
|
1793 |
||
1794 |
@param aDevice Local media ID |
|
1795 |
@param aMediaId Media Id (unique for a media subsystem) |
|
1796 |
@param aLastMediaId This indicates number of used media ids+ number of DMedia objects to be associated with the media driver. |
|
1797 |
||
1798 |
@return KErrNone |
|
1799 |
@see TMediaDevice |
|
1800 |
||
1801 |
*/ |
|
1802 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1803 |
OstTraceFunctionEntry1( DPRIMARYMEDIABASE_CREATE_ENTRY, this ); |
0 | 1804 |
__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
|
1805 |
OstTraceExt3( TRACE_INTERNALS, DPRIMARYMEDIABASE_CREATE, "aMediaId=%d; aLastMediaId=%d; aDevice=%d ", aMediaId, aLastMediaId, (TUint) aDevice ); |
0 | 1806 |
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
|
1807 |
|
0 | 1808 |
if (r != KErrNone) |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1809 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1810 |
OstTraceFunctionExitExt( DPRIMARYMEDIABASE_CREATE_EXIT1, this, r ); |
0 | 1811 |
return r; |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1812 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1813 |
iBody = new DBody(*this); |
0 | 1814 |
if (iBody == NULL) |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1815 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1816 |
OstTraceFunctionExitExt( DPRIMARYMEDIABASE_CREATE_EXIT2, this, KErrNoMemory ); |
0 | 1817 |
return KErrNoMemory; |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1818 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1819 |
if (iDfcQ) |
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->iMediaChangeDfc.SetDfcQ(iDfcQ); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1822 |
iBody->iMediaPresentDfc.SetDfcQ(iDfcQ); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1823 |
} |
0 | 1824 |
|
1825 |
#ifdef __DEMAND_PAGING__ |
|
1826 |
TInt pageSize = Kern::RoundToPageSize(1); |
|
1827 |
iBody->iPageSizeMsk = pageSize-1; |
|
1828 |
#endif |
|
1829 |
||
1830 |
iLastMediaId=aLastMediaId; |
|
1831 |
if (r==KErrNone && iDfcQ) |
|
1832 |
{ |
|
1833 |
iMsgQ.SetDfcQ(iDfcQ); |
|
1834 |
iDeferred.SetDfcQ(iDfcQ); |
|
1835 |
iWaitMedChg.SetDfcQ(iDfcQ); |
|
1836 |
iAsyncDfc.SetDfcQ(iDfcQ); |
|
1837 |
} |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1838 |
OstTraceFunctionExitExt( DPRIMARYMEDIABASE_CREATE_EXIT3, this, KErrNone ); |
0 | 1839 |
return KErrNone; |
1840 |
} |
|
1841 |
||
1842 |
||
1843 |
EXPORT_C TInt DPrimaryMediaBase::Connect(DLocalDrive* aLocalDrive) |
|
1844 |
/** |
|
1845 |
Connects to a local drive |
|
1846 |
||
1847 |
@param aLocalDrive Local drive logical channel abstraction |
|
1848 |
||
1849 |
@pre Kernel must be unlocked |
|
1850 |
@pre Current thread in critical section |
|
1851 |
||
1852 |
@post Kernel must be unlocked |
|
1853 |
||
1854 |
@return KErrNone, if successful |
|
1855 |
KErrNotFound, If no PDD matches criteria while getting driver list |
|
1856 |
KErrNoMemory, If the array could not be expanded at some point while getting driver list or ran out of memory while opening media driver |
|
1857 |
KErrNotReady, If not ready when trying to open media driver |
|
1858 |
otherwise, one of the other system wide error codes. |
|
1859 |
||
1860 |
@see DLocalDrive |
|
1861 |
*/ |
|
1862 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1863 |
OstTraceFunctionEntryExt( DPRIMARYMEDIABASE_CONNECT_ENTRY, this ); |
0 | 1864 |
__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
|
1865 |
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
|
1866 |
|
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1867 |
TInt r=KErrNone; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1868 |
|
0 | 1869 |
if (iDfcQ) |
1870 |
{ |
|
1871 |
TThreadMessage& m=Kern::Message(); |
|
1872 |
m.iValue=EConnect; |
|
1873 |
m.iArg[0]=aLocalDrive; |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1874 |
r=m.SendReceive(&iMsgQ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1875 |
OstTraceFunctionExitExt( DPRIMARYMEDIABASE_CONNECT_EXIT1, this, r ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1876 |
return r; |
0 | 1877 |
} |
1878 |
||
1879 |
// If no DFC queue, must be a fixed media device |
|
1880 |
// If this is the first connection, open media driver now |
|
1881 |
// 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
|
1882 |
|
0 | 1883 |
NKern::LockSystem(); |
1884 |
TBool first=iConnectionQ.IsEmpty(); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1885 |
iConnectionQ.Add(&aLocalDrive->iMediaChangeObserver.iLink); |
0 | 1886 |
NKern::UnlockSystem(); |
1887 |
if (first) |
|
1888 |
{ |
|
1889 |
r=OpenMediaDriver(); |
|
1890 |
if (r!=KErrNone) |
|
1891 |
{ |
|
1892 |
NKern::LockSystem(); |
|
1893 |
aLocalDrive->Deque(); |
|
1894 |
NKern::UnlockSystem(); |
|
1895 |
} |
|
1896 |
} |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1897 |
|
0 | 1898 |
if (r==KErrNone) |
1899 |
aLocalDrive->iDrive->iMedia=this; |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1900 |
OstTraceFunctionExitExt( DPRIMARYMEDIABASE_CONNECT_EXIT2, this, r ); |
0 | 1901 |
return r; |
1902 |
} |
|
1903 |
||
1904 |
||
1905 |
||
1906 |
||
1907 |
EXPORT_C void DPrimaryMediaBase::Disconnect(DLocalDrive* aLocalDrive) |
|
1908 |
/** |
|
1909 |
Disconnects from a local drive |
|
1910 |
||
1911 |
@param aLocalDrive Local drive logical channel abstraction |
|
1912 |
||
1913 |
@pre Kernel must be unlocked |
|
1914 |
@pre Current thread in critical section |
|
1915 |
||
1916 |
@post Kernel must be unlocked |
|
1917 |
@see DLocalDrive |
|
1918 |
*/ |
|
1919 |
||
1920 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1921 |
OstTraceFunctionEntryExt( DPRIMARYMEDIABASE_DISCONNECT_ENTRY, this ); |
0 | 1922 |
__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
|
1923 |
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
|
1924 |
|
0 | 1925 |
if (iDfcQ) |
1926 |
{ |
|
1927 |
TThreadMessage& m=Kern::Message(); |
|
1928 |
m.iValue=EDisconnect; |
|
1929 |
m.iArg[0]=aLocalDrive; |
|
1930 |
m.SendReceive(&iMsgQ); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1931 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_DISCONNECT_EXIT1, this ); |
0 | 1932 |
return; |
1933 |
} |
|
1934 |
||
1935 |
// If no DFC queue, must be a fixed media device |
|
1936 |
// If this is the last connection, close media driver now |
|
1937 |
// Assume no non-primary media exist on this device |
|
1938 |
DMediaDriver* pD=NULL; |
|
1939 |
NKern::LockSystem(); |
|
1940 |
aLocalDrive->iDrive->iMedia=NULL; |
|
1941 |
aLocalDrive->Deque(); |
|
1942 |
if (iConnectionQ.IsEmpty()) |
|
1943 |
{ |
|
1944 |
pD=iDriver; |
|
1945 |
iDriver=NULL; |
|
1946 |
} |
|
1947 |
NKern::UnlockSystem(); |
|
1948 |
if (pD) |
|
1949 |
pD->Close(); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1950 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_DISCONNECT_EXIT2, this ); |
0 | 1951 |
} |
1952 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1953 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1954 |
/** |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1955 |
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
|
1956 |
*/ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1957 |
TInt DPrimaryMediaBase::Connect(TLocDrv* aLocDrv) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1958 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1959 |
TInt r = KErrNone; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1960 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1961 |
NKern::LockSystem(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1962 |
TBool first = iConnectionQ.IsEmpty(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1963 |
iConnectionQ.Add(&aLocDrv->iMediaChangeObserver.iLink); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1964 |
NKern::UnlockSystem(); |
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 |
if (first && !iDfcQ) |
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 |
r = OpenMediaDriver(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1969 |
if (r!=KErrNone) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1970 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1971 |
NKern::LockSystem(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1972 |
aLocDrv->iMediaChangeObserver.iLink.Deque(); |
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 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1976 |
return r; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1977 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1978 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1979 |
TInt DPrimaryMediaBase::HandleMediaNotPresent(TLocDrvRequest& aReq) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1980 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1981 |
TInt reqId = aReq.Id(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1982 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1983 |
if (reqId == DLocalDrive::ECaps) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1984 |
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
|
1985 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1986 |
TInt r = QuickCheckStatus(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1987 |
if (r != KErrNone && |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1988 |
reqId != DLocalDrive::EForceMediaChange && // EForceMediaChange, and |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1989 |
reqId != DLocalDrive::EReadPasswordStore && // Password store operations |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1990 |
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
|
1991 |
reqId != DLocalDrive::EPasswordStoreLengthInBytes) // to be ready.) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1992 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1993 |
return r; |
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 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1996 |
return KErrNone; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1997 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
1998 |
|
0 | 1999 |
EXPORT_C TInt DPrimaryMediaBase::Request(TLocDrvRequest& aReq) |
2000 |
/** |
|
2001 |
Issues a local drive request. It is called from TLocDrv::Request() function . |
|
2002 |
Each local drive request is encapsulated as a TLocDrvRequest- a class derived from TThreadMessage, the kernel message class. |
|
2003 |
TLocDrvRequest contains information pertaining to the request, including the ID and any associated parameters such as drive position, length and source/destination location. |
|
2004 |
Passes the request through to the media driver. |
|
2005 |
||
2006 |
@param m Encapsulates the request information received from the client |
|
2007 |
||
2008 |
@pre Enter with kernel unlocked |
|
2009 |
||
2010 |
@post Leave with Kernel unlocked |
|
2011 |
||
2012 |
@return KErrNone,if successful |
|
2013 |
KErrBadDescriptor, if request encapsulates a bad descriptor |
|
2014 |
Otherwise, one of the other system wide error codes. |
|
2015 |
||
2016 |
@see TLocDrvRequest |
|
2017 |
*/ |
|
2018 |
{ |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2019 |
OstTraceFunctionEntry1( DPRIMARYMEDIABASE_REQUEST_ENTRY, this ); |
0 | 2020 |
|
2021 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase(%d)::Request(%08x)",iMediaId,&aReq)); |
|
2022 |
__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())); |
|
2023 |
||
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2024 |
OstTraceDefExt4(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DPRIMARYMEDIABASE_REQUEST, "reqId=%d; length=0x%lx; position=0x%lx; remote thread=0x%x", (TInt) aReq.Id(), (TUint) aReq.Length(), (TUint) aReq.Pos(), (TUint) aReq.RemoteThread()); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2025 |
|
0 | 2026 |
TInt reqId = aReq.Id(); |
2027 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2028 |
TInt r = HandleMediaNotPresent(aReq); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2029 |
if (r != KErrNone) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2030 |
{ |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2031 |
OstTraceFunctionExitExt( DPRIMARYMEDIABASE_REQUEST_EXIT, this, r ); |
0 | 2032 |
return r; |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2033 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2034 |
|
0 | 2035 |
|
2036 |
||
2037 |
// for ERead & EWrite requests, get the linear address for pinning & DMA |
|
2038 |
TUint8* linAddress = NULL; |
|
2039 |
TClientBuffer clientBuffer; |
|
2040 |
DThread* pT = NULL; |
|
2041 |
||
2042 |
if (reqId == DLocalDrive::ERead || reqId == DLocalDrive::EWrite) |
|
2043 |
{ |
|
2044 |
pT = aReq.RemoteThread(); |
|
2045 |
if (!pT) |
|
2046 |
pT = &Kern::CurrentThread(); // e.g. when using TBusLocalDrive directly |
|
2047 |
||
2048 |
// for silly zero-length requests, return immediately, setting the client |
|
2049 |
// descriptor length to zero if it's a read request |
|
2050 |
if (aReq.Length() == 0) |
|
2051 |
{ |
|
2052 |
DThread* pC = &Kern::CurrentThread(); |
|
2053 |
r = KErrNone; |
|
2054 |
if (reqId == DLocalDrive::ERead) |
|
2055 |
{ |
|
2056 |
TPtrC8 ptr(NULL, 0); |
|
2057 |
r = Kern::ThreadDesWrite(pT, aReq.RemoteDes(), ptr, aReq.RemoteDesOffset(), KChunkShiftBy0,pC); |
|
2058 |
} |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2059 |
OstTraceFunctionExitExt( DPRIMARYMEDIABASE_REQUEST_EXIT2, this, r ); |
0 | 2060 |
return r; |
2061 |
} |
|
2062 |
||
2063 |
clientBuffer.SetFromDescriptor(aReq.RemoteDes(), pT); |
|
2064 |
||
2065 |
TInt length = 0; |
|
2066 |
TInt maxLength = 0; |
|
2067 |
TInt r = Kern::ThreadGetDesInfo(pT,aReq.RemoteDes(),length,maxLength,linAddress,EFalse); // get descriptor length, maxlength and linAddress |
|
2068 |
if (r != KErrNone) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2069 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2070 |
OstTraceFunctionExitExt( DPRIMARYMEDIABASE_REQUEST_EXIT3, this, r ); |
0 | 2071 |
return r; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2072 |
} |
0 | 2073 |
linAddress+= aReq.RemoteDesOffset(); |
2074 |
||
2075 |
#ifdef __DEMAND_PAGING__ |
|
2076 |
// NB change in behavior IF DATA PAGING IS ENABLED: TLocDrvRequest::RemoteDes() points |
|
2077 |
// to a TClientBuffer rather than the client's remote descriptor |
|
2078 |
if (DataPagingDeviceRegistered) |
|
2079 |
{ |
|
2080 |
aReq.RemoteDes() = &clientBuffer; |
|
2081 |
aReq.Flags() |= TLocDrvRequest::ETClientBuffer; |
|
2082 |
} |
|
2083 |
#endif |
|
2084 |
} |
|
2085 |
||
2086 |
if (iDfcQ) |
|
2087 |
{ |
|
2088 |
__TRACE_TIMING(0x10); |
|
2089 |
||
2090 |
||
2091 |
#ifdef __DEMAND_PAGING__ |
|
2092 |
// If this is a ROM/Code paging media, pin writes |
|
2093 |
// If there is a Data paging media registered, pin all requests with descriptors |
|
2094 |
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
|
2095 |
{ |
0 | 2096 |
r = PinSendReceive(aReq, (TLinAddr) linAddress); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2097 |
} |
0 | 2098 |
else |
2099 |
#endif // __DEMAND_PAGING__ |
|
2100 |
r = SendReceive(aReq, (TLinAddr) linAddress); |
|
2101 |
} |
|
2102 |
else |
|
2103 |
{ |
|
2104 |
// If no DFC queue, must be a fixed media device |
|
2105 |
// Media driver must already have been opened |
|
2106 |
// Assume no non-primary media exist on this device |
|
2107 |
// Just pass request straight through to media driver |
|
2108 |
r = aReq.CheckAndAdjustForPartition(); |
|
2109 |
if (r == KErrNone) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2110 |
r = iDriver->Request(aReq); |
0 | 2111 |
} |
2112 |
||
2113 |
#ifdef __DEMAND_PAGING__ |
|
2114 |
// NB change in behavior IF DATA PAGING IS ENABLED: TLocDrvRequest::RemoteDes() points |
|
2115 |
// to a TClientBuffer rather than the client's remote descriptor |
|
2116 |
if (reqId == DLocalDrive::ERead && DataPagingDeviceRegistered && r == KErrNone) |
|
2117 |
{ |
|
2118 |
r = clientBuffer.UpdateDescriptorLength(pT); |
|
2119 |
} |
|
2120 |
#endif |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2121 |
OstTraceFunctionExitExt( DPRIMARYMEDIABASE_REQUEST_EXIT4, this, r ); |
0 | 2122 |
return r; |
2123 |
} |
|
2124 |
||
2125 |
||
2126 |
#ifdef __DEMAND_PAGING__ |
|
2127 |
TInt DPrimaryMediaBase::PinSendReceive(TLocDrvRequest& aReq, TLinAddr aLinAddress) |
|
2128 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2129 |
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
|
2130 |
|
0 | 2131 |
__ASSERT_DEBUG(ThePinObjectAllocator, LOCM_FAULT()); |
2132 |
||
2133 |
||
2134 |
TInt msgId = aReq.Id(); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2135 |
TInt r; |
0 | 2136 |
|
2137 |
switch(msgId) |
|
2138 |
{ |
|
2139 |
case DLocalDrive::EControlIO: |
|
2140 |
{ |
|
2141 |
TInt controlIoType = aReq.Int3(); |
|
2142 |
switch(controlIoType) |
|
2143 |
{ |
|
2144 |
case KLocalMessageHandle: |
|
2145 |
// ControlIo is not supported if either of the two bare (TAny*) pointers are non-NULL |
|
2146 |
// as it's not possible to determine what the pointers are pointing at... |
|
2147 |
if (aReq.Int1() || aReq.Int2()) |
|
2148 |
{ |
|
2149 |
__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
|
2150 |
r = KErrNotSupported; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2151 |
break; |
0 | 2152 |
} |
2153 |
// fall into... |
|
2154 |
case 0: |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2155 |
r = SendReceive(aReq); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2156 |
break; |
0 | 2157 |
|
2158 |
default: |
|
2159 |
// if Int3() is > 0, Int1() is a data pointer, and Int3() is a length |
|
2160 |
if (controlIoType > (TInt) ThePinObjectAllocator->iFragmentGranularity) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2161 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2162 |
r = KErrTooBig; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2163 |
break; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2164 |
} |
0 | 2165 |
if (controlIoType < 0) |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2166 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2167 |
r = KErrArgument; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2168 |
break; |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2169 |
} |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2170 |
r = PinFragmentSendReceive(aReq, (TLinAddr) aReq.Ptr1(), controlIoType); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2171 |
break; |
0 | 2172 |
} |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2173 |
break; |
0 | 2174 |
} |
2175 |
||
2176 |
case DLocalDrive::ERead: |
|
2177 |
case DLocalDrive::EWrite: |
|
2178 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2179 |
r = PinFragmentSendReceive(aReq, aLinAddress, aReq.Length()); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2180 |
break; |
0 | 2181 |
} |
2182 |
||
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2183 |
// 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
|
2184 |
// 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
|
2185 |
case DLocalDrive::ECaps: |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2186 |
case DLocalDrive::EGetLastErrorInfo: |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2187 |
case DLocalDrive::EQueryDevice: |
0 | 2188 |
case DLocalDrive::EPasswordLock: |
2189 |
case DLocalDrive::EPasswordUnlock: |
|
2190 |
case DLocalDrive::EPasswordClear: |
|
2191 |
case DLocalDrive::EReadPasswordStore: |
|
2192 |
case DLocalDrive::EWritePasswordStore: |
|
2193 |
case DLocalDrive::EPasswordStoreLengthInBytes: |
|
2194 |
case DLocalDrive::EPasswordErase: |
|
2195 |
||
2196 |
default: |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2197 |
r = SendReceive(aReq); |
0 | 2198 |
} |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2199 |
OstTraceFunctionExitExt( DPRIMARYMEDIABASE_PINSENDRECEIVE_EXIT, this, r ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2200 |
return r; |
0 | 2201 |
} |
2202 |
||
2203 |
TInt DPrimaryMediaBase::PinFragmentSendReceive(TLocDrvRequest& aReq, TLinAddr aLinAddress, TInt aLength) |
|
2204 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2205 |
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
|
2206 |
|
0 | 2207 |
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) |
2208 |
TInt r = KErrNone; |
|
2209 |
||
2210 |
// Kern::Printf(">PFSR %02X aReq %08X aLinAddress %08X aLen %08X offset %08X", aReq.Id(), &aReq, aLinAddress, aLength, aReq.RemoteDesOffset()); |
|
2211 |
||
2212 |
DThread* pT = aReq.RemoteThread(); |
|
2213 |
if (!pT) |
|
2214 |
pT=&Kern::CurrentThread(); // e.g. when using TBusLocalDrive directly |
|
2215 |
||
2216 |
__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)); |
|
2217 |
__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
|
2218 |
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
|
2219 |
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
|
2220 |
|
0 | 2221 |
// don't want this thread to be terminated until last fragment is sent to MD and mem can be free'd up |
2222 |
NKern::ThreadEnterCS(); |
|
2223 |
||
2224 |
__ASSERT_DEBUG(ThePinObjectAllocator, LOCM_FAULT()); |
|
2225 |
||
2226 |
TUint fragmentGranularity = ThePinObjectAllocator->iFragmentGranularity; |
|
2227 |
TInt dataLockResult = 0; |
|
2228 |
// fragmentation only allowed for read/write requests |
|
2229 |
__ASSERT_DEBUG(aLength <= (TInt) fragmentGranularity || (aReq.Id() == DLocalDrive::EWrite || aReq.Id() == DLocalDrive::ERead), LOCM_FAULT()); |
|
2230 |
||
2231 |
// Pin the client buffer |
|
2232 |
TInt pinnedLen; |
|
2233 |
for (TInt pos = 0; pos < aLength; pos+= pinnedLen, aLinAddress+= pinnedLen) |
|
2234 |
{ |
|
2235 |
pinnedLen = 0; |
|
2236 |
||
2237 |
// pin memory |
|
2238 |
TInt remainingLen = aLength - pos; // remaining length |
|
2239 |
||
2240 |
// first attempt to pin memory with no pre-allocated buffers (which may fail) |
|
2241 |
DPinObjectAllocator::SVirtualPinContainer* pinDataObject = ThePinObjectAllocator->AcquirePinObject(); |
|
2242 |
||
2243 |
if (pinDataObject) |
|
2244 |
{ |
|
2245 |
TInt lenToPin = Min(KMaxPinData, remainingLen); |
|
2246 |
||
2247 |
TInt r = Kern::PinVirtualMemory(pinDataObject->iObject, aLinAddress, lenToPin, pT); |
|
2248 |
if (r == KErrNone) |
|
2249 |
{ |
|
2250 |
pinnedLen = lenToPin; |
|
2251 |
} |
|
2252 |
else |
|
2253 |
{ |
|
2254 |
#ifdef __DEBUG_DEMAND_PAGING__ |
|
2255 |
Kern::Printf("Kern::PinVirtualMemory() error %d", r); |
|
2256 |
#endif |
|
2257 |
// pin failed, so use preallocated buffer instead |
|
2258 |
ThePinObjectAllocator->ReleasePinObject(pinDataObject); |
|
2259 |
pinDataObject = NULL; |
|
2260 |
} |
|
2261 |
} |
|
2262 |
||
2263 |
if (!pinDataObject) |
|
2264 |
{ |
|
2265 |
ThePinObjectAllocator->PreAllocatedDataLock().LockFragmentation(); |
|
2266 |
||
2267 |
TLinAddr start = aLinAddress; |
|
2268 |
do |
|
2269 |
{ |
|
2270 |
TInt lenToPin = Min((TInt) fragmentGranularity, remainingLen - pinnedLen); |
|
2271 |
||
2272 |
#ifdef __DEBUG_DEMAND_PAGING__ |
|
2273 |
Kern::Printf(">SR PinS Id %d aLinAddress %08X lenToPin %08X offset %08X", aReq.Id(), aLinAddress, lenToPin); |
|
2274 |
#endif |
|
2275 |
||
2276 |
dataLockResult = ThePinObjectAllocator->PreAllocatedDataLock().Lock(pT, start, lenToPin); |
|
2277 |
||
2278 |
#ifdef __DEBUG_DEMAND_PAGING__ |
|
2279 |
Kern::Printf("<SR PinS Id %d aLinAddress %08X lenToPin %08X offset %08X r %d", aReq.Id(), aLinAddress, lenToPin, r); |
|
2280 |
#endif |
|
2281 |
||
2282 |
start+= lenToPin; |
|
2283 |
pinnedLen+= lenToPin; |
|
2284 |
} |
|
2285 |
while (dataLockResult == 0 && pinnedLen < remainingLen); |
|
2286 |
||
2287 |
// if nothing pinned (dataLockResult == 0) or error (dataLockResult <0), release the mutex, |
|
2288 |
// otherwise (dataLockResult > 0) release it after calling SendReceive() |
|
2289 |
if (dataLockResult <= 0) |
|
2290 |
ThePinObjectAllocator->PreAllocatedDataLock().UnlockFragmentation(); |
|
2291 |
||
2292 |
#ifdef __DEBUG_DEMAND_PAGING__ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2293 |
if (dataLockResult < 0) |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2294 |
Kern::Printf("DFragmentationPagingLock::Lock() %d", dataLockResult); |
0 | 2295 |
#endif |
2296 |
||
2297 |
if (dataLockResult < 0) // if lock returned an error then give up |
|
2298 |
{ |
|
2299 |
r = dataLockResult; |
|
2300 |
break; |
|
2301 |
} |
|
2302 |
} |
|
2303 |
||
2304 |
// fragment request Id defaults to same as original request |
|
2305 |
fragment.Id() = aReq.Id(); |
|
2306 |
fragment.Length() = Int64(pinnedLen); |
|
2307 |
fragment.RemoteDesOffset() = aReq.RemoteDesOffset() + pos; |
|
2308 |
fragment.Pos() = aReq.Pos() + pos; |
|
2309 |
fragment.Flags() = aReq.Flags(); |
|
2310 |
||
2311 |
__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())); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2312 |
OstTraceDefExt5(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DPRIMARYMEDIABASE_PINFRAGMENTSENDRECEIVE3, "Send fragment 0x%08x; type=%d; length=0x%x; offset within original req=0x%x; position in media=0x%lx", (TUint) &fragment, (TInt) fragment.Id(), (TUint) pinnedLen, (TUint) pos, (TUint) fragment.Pos()); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2313 |
|
0 | 2314 |
#ifdef BTRACE_PAGING_MEDIA |
2315 |
TInt buf[4]; |
|
2316 |
buf[0] = pinnedLen; // fragment length |
|
2317 |
buf[1] = pos; // offset within original request |
|
2318 |
buf[2] = fragment.Pos(); // offset in media |
|
2319 |
buf[3] = (TInt)&pT->iNThread; // thread that issued the original write req |
|
2320 |
BTraceContextN(BTrace::EPagingMedia,BTrace::EPagingMediaLocMedFragmentBegin,&fragment,fragment.Id(),buf,sizeof(buf)); |
|
2321 |
#endif |
|
2322 |
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
|
2323 |
|
0 | 2324 |
// unpin memory |
2325 |
if (pinDataObject) |
|
2326 |
{ |
|
2327 |
Kern::UnpinVirtualMemory(pinDataObject->iObject); |
|
2328 |
ThePinObjectAllocator->ReleasePinObject(pinDataObject); |
|
2329 |
} |
|
2330 |
else if (dataLockResult > 0) // pinDataObject = NULL |
|
2331 |
{ |
|
2332 |
__ASSERT_DEBUG(dataLockResult == 1, LOCM_FAULT()); |
|
2333 |
ThePinObjectAllocator->PreAllocatedDataLock().Unlock(); |
|
2334 |
ThePinObjectAllocator->PreAllocatedDataLock().UnlockFragmentation(); |
|
2335 |
} |
|
2336 |
||
2337 |
#ifdef BTRACE_PAGING_MEDIA |
|
2338 |
BTraceContext8(BTrace::EPagingMedia,BTrace::EPagingMediaLocMedFragmentEnd,&fragment,r); |
|
2339 |
#endif |
|
2340 |
||
2341 |
if (r != KErrNone) |
|
2342 |
break; |
|
2343 |
} |
|
2344 |
||
2345 |
NKern::ThreadLeaveCS(); |
|
2346 |
||
2347 |
// Kern::Printf("<PFSR %02X aReq %08X aLinAddress %08X aLen %08X offset %08X", aReq.Id(), &aReq, aLinAddress, aLength, aReq.RemoteDesOffset()); |
|
2348 |
||
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2349 |
OstTraceFunctionExitExt( DPRIMARYMEDIABASE_PINFRAGMENTSENDRECEIVE_EXIT, this, r ); |
0 | 2350 |
return r; |
2351 |
} |
|
2352 |
||
2353 |
#endif // __DEMAND_PAGING__ |
|
2354 |
||
2355 |
||
2356 |
TInt DPrimaryMediaBase::SendReceive(TLocDrvRequest& aReq, TLinAddr aLinAddress) |
|
2357 |
/** |
|
2358 |
* If a Physical memory helper object is present for given drive, |
|
2359 |
* then message is routed via helper; |
|
2360 |
* |
|
2361 |
* @return KErrNone, if successful; |
|
2362 |
* otherwise, one of the other system wide error codes. |
|
2363 |
* |
|
2364 |
* @see TLocDrvRequest::SendReceive() |
|
2365 |
* @see DDmaHelper::SendReceive() |
|
2366 |
*/ |
|
2367 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2368 |
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
|
2369 |
|
0 | 2370 |
DDmaHelper* dmaHelper = aReq.Drive()->iDmaHelper; |
2371 |
||
2372 |
#ifdef __DEMAND_PAGING__ |
|
2373 |
RequestCountInc(); |
|
2374 |
#endif |
|
2375 |
||
2376 |
TInt r; |
|
2377 |
||
2378 |
if (dmaHelper) |
|
2379 |
r = dmaHelper->SendReceive(aReq, aLinAddress); |
|
2380 |
else |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2381 |
{ |
0 | 2382 |
r = aReq.SendReceive(&iMsgQ); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2383 |
} |
0 | 2384 |
#ifdef __DEMAND_PAGING__ |
2385 |
RequestCountDec(); |
|
2386 |
#endif |
|
2387 |
||
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2388 |
OstTraceFunctionExitExt( DPRIMARYMEDIABASE_SENDRECEIVE_EXIT, this, r ); |
0 | 2389 |
return r; |
2390 |
} |
|
2391 |
||
2392 |
||
2393 |
||
2394 |
EXPORT_C TInt DPrimaryMediaBase::ForceMediaChange(TInt) |
|
2395 |
/** |
|
2396 |
Forces a media change.The method can be overridden in the derived classes. |
|
2397 |
@param mode Media change mode |
|
2398 |
||
2399 |
@return KErrNotSupported, in the default implementation |
|
2400 |
KErrNone, if successful |
|
2401 |
Otherwise, one of the other system wide error codes. |
|
2402 |
||
2403 |
*/ |
|
2404 |
{ |
|
2405 |
// default implementation |
|
2406 |
return KErrNotSupported; |
|
2407 |
} |
|
2408 |
||
2409 |
EXPORT_C TInt DPrimaryMediaBase::InitiatePowerUp() |
|
2410 |
/** |
|
2411 |
Initiates Power up sequence |
|
2412 |
@return KErrCompletion, operation is complete successfully or otherwise |
|
2413 |
KErrNone, if successful |
|
2414 |
Otherwise, one of the other system wide error codes. |
|
2415 |
||
2416 |
*/ |
|
2417 |
{ |
|
2418 |
// default implementation, this is the default implementation. |
|
2419 |
return KErrCompletion; |
|
2420 |
} |
|
2421 |
||
2422 |
EXPORT_C TInt DPrimaryMediaBase::QuickCheckStatus() |
|
2423 |
/** |
|
2424 |
Checks the status of the media device, whether the device is present,absent,not ready,etc. |
|
2425 |
The function can be overridden in the derived classes |
|
2426 |
||
2427 |
@return KErrNone, if successful |
|
2428 |
Otherwise, one of the other system wide error codes. |
|
2429 |
||
2430 |
*/ |
|
2431 |
{ |
|
2432 |
// default implementation |
|
2433 |
return KErrNone; |
|
2434 |
} |
|
2435 |
||
2436 |
EXPORT_C void DPrimaryMediaBase::DefaultDriveCaps(TLocalDriveCapsV2& aCaps) |
|
2437 |
/** |
|
2438 |
Fills in the default drive capabilities in TLocalDriveCapsV2 . |
|
2439 |
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. |
|
2440 |
||
2441 |
@param aCaps Media drive capability fields. Extension to Capabilities fields(i.e) in addition to TLocalDriveCaps mainly to support Nor flash |
|
2442 |
@see TLocalDriveCapsV2 |
|
2443 |
*/ |
|
2444 |
||
2445 |
{ |
|
2446 |
// default implementation |
|
2447 |
// aCaps is zeroed beforehand |
|
2448 |
aCaps.iType = EMediaUnknown; |
|
2449 |
} |
|
2450 |
||
2451 |
EXPORT_C TBool DPrimaryMediaBase::IsRemovableDevice(TInt& /*aSocketNum*/) |
|
2452 |
/** |
|
2453 |
Checks whether it is a removable device or not |
|
2454 |
@param aSocketNum Socket number |
|
2455 |
@return ETrue=Removable Device |
|
2456 |
EFalse=Non-Removable device, default implementation |
|
2457 |
||
2458 |
*/ |
|
2459 |
{ |
|
2460 |
// default implementation |
|
2461 |
return(EFalse); |
|
2462 |
} |
|
2463 |
||
2464 |
EXPORT_C void DPrimaryMediaBase::HandleMsg(TLocDrvRequest& m) |
|
2465 |
/** |
|
2466 |
It handles the drive request encapsulated in TLocDrvRequest depending on the message id. |
|
2467 |
||
2468 |
@param aRequest Encapsulates the request information received from the client |
|
2469 |
@see TLocDrvRequest |
|
2470 |
*/ |
|
2471 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2472 |
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
|
2473 |
|
0 | 2474 |
switch (m.iValue) |
2475 |
{ |
|
2476 |
case EConnect: |
|
2477 |
{ |
|
2478 |
DLocalDrive* pD=(DLocalDrive*)m.Ptr0(); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2479 |
iConnectionQ.Add(&pD->iMediaChangeObserver.iLink); |
0 | 2480 |
m.Complete(KErrNone, EFalse); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2481 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_HANDLEMSG_EXIT1, this ); |
0 | 2482 |
return; |
2483 |
} |
|
2484 |
case EDisconnect: |
|
2485 |
{ |
|
2486 |
DLocalDrive* pD=(DLocalDrive*)m.Ptr0(); |
|
2487 |
TLocDrv* pL=pD->iDrive; |
|
2488 |
DMedia* media=pL->iMedia; |
|
2489 |
if (iState==EReady && media && media->iDriver) |
|
2490 |
media->iDriver->Disconnect(pD,&m); |
|
2491 |
else |
|
2492 |
{ |
|
2493 |
pD->Deque(); |
|
2494 |
m.Complete(KErrNone, EFalse); |
|
2495 |
} |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2496 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_HANDLEMSG_EXIT2, this ); |
0 | 2497 |
return; |
2498 |
} |
|
2499 |
case DLocalDrive::EForceMediaChange: |
|
2500 |
{ |
|
2501 |
TUint flags = (TUint) m.Pos(); |
|
2502 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2503 |
#ifdef __DEMAND_PAGING__ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2504 |
// 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
|
2505 |
// 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
|
2506 |
// 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
|
2507 |
if (iBody->iPagingDevice) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2508 |
flags&= ~KMediaRemountForceMediaChange; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2509 |
#endif |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2510 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2511 |
// 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
|
2512 |
TLocDrv* drv = m.Drive(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2513 |
if (drv->iNextDrive) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2514 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2515 |
TLocDrvRequest request; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2516 |
request.Drive() = drv->iNextDrive; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2517 |
request.Id() = DLocalDrive::EForceMediaChange; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2518 |
request.Pos() = m.Pos(); // flags |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2519 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2520 |
request.SendReceive(&drv->iNextDrive->iPrimaryMedia->iMsgQ); |
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 |
CompleteRequest(m, request.iValue); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2523 |
return; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2524 |
} |
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 |
|
0 | 2527 |
// if KForceMediaChangeReOpenDriver specified wait for power up, |
2528 |
// and then re-open this drive's media driver |
|
2529 |
__KTRACE_OPT(KLOCDRV, Kern::Printf("EForceMediaChange, flags %08X\n", flags)); |
|
2530 |
if (flags == (TUint) KForceMediaChangeReOpenMediaDriver) |
|
2531 |
{ |
|
2532 |
TInt sock; |
|
2533 |
if (!IsRemovableDevice(sock)) |
|
2534 |
{ |
|
2535 |
CompleteRequest(m, KErrNotSupported); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2536 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_HANDLEMSG_EXIT3, this ); |
0 | 2537 |
return; |
2538 |
} |
|
2539 |
// wait for power up and then call DPrimaryMediaBase::DoRequest() |
|
2540 |
break; |
|
2541 |
} |
|
2542 |
||
2543 |
TInt r=ForceMediaChange(flags); |
|
2544 |
if (r==KErrNone) |
|
2545 |
{ |
|
2546 |
// wait for media change notification to complete message |
|
2547 |
m.Forward(&iWaitMedChg,EFalse); |
|
2548 |
} |
|
2549 |
else |
|
2550 |
{ |
|
2551 |
if (r==KErrNotSupported || r==KErrCompletion) |
|
2552 |
r=KErrNone; |
|
2553 |
CompleteRequest(m, r); |
|
2554 |
} |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2555 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_HANDLEMSG_EXIT4, this ); |
0 | 2556 |
return; |
2557 |
} |
|
2558 |
case DLocalDrive::ECaps: |
|
2559 |
if (iState==EPoweredDown) |
|
2560 |
{ |
|
2561 |
// The media is powered down, but the media driver still exists. |
|
2562 |
// - Issue the ECaps request without powering the media back up. |
|
2563 |
DoRequest(m); |
|
2564 |
__TRACE_TIMING(0x101); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2565 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_HANDLEMSG_EXIT5, this ); |
0 | 2566 |
return; |
2567 |
} |
|
2568 |
break; |
|
2569 |
||
2570 |
case DLocalDrive::ERead: |
|
2571 |
case DLocalDrive::EWrite: |
|
2572 |
case DLocalDrive::EFormat: |
|
2573 |
case DLocalDrive::EEnlarge: |
|
2574 |
case DLocalDrive::EReduce: |
|
2575 |
case DLocalDrive::EPasswordLock: |
|
2576 |
case DLocalDrive::EPasswordUnlock: |
|
2577 |
case DLocalDrive::EPasswordClear: |
|
2578 |
case DLocalDrive::EPasswordErase: |
|
2579 |
case DLocalDrive::EControlIO: |
|
2580 |
case DLocalDrive::EDeleteNotify: |
|
2581 |
case DLocalDrive::EQueryDevice: |
|
2582 |
||
2583 |
#ifdef __DEMAND_PAGING__ |
|
2584 |
case DMediaPagingDevice::ERomPageInRequest: |
|
2585 |
case DMediaPagingDevice::ECodePageInRequest: |
|
2586 |
#endif |
|
2587 |
break; |
|
2588 |
case DLocalDrive::EGetLastErrorInfo: |
|
2589 |
{ |
|
2590 |
DLocalDrive* pD=(DLocalDrive*)m.Ptr0(); |
|
2591 |
TLocDrv* pL=pD->iDrive; |
|
2592 |
*((TErrorInfo*) m.RemoteDes()) = pL->iLastErrorInfo; |
|
2593 |
CompleteRequest(m, KErrNone); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2594 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_HANDLEMSG_EXIT6, this ); |
0 | 2595 |
return; |
2596 |
} |
|
2597 |
case DLocalDrive::EReadPasswordStore: |
|
2598 |
{ |
|
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2599 |
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
|
2600 |
TInt r = ThePasswordStore->ReadPasswordData(pswData); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2601 |
m.Length() = pswData.Length(); |
0 | 2602 |
CompleteRequest(m, r); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2603 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_HANDLEMSG_EXIT7, this ); |
0 | 2604 |
return; |
2605 |
} |
|
2606 |
case DLocalDrive::EWritePasswordStore: |
|
2607 |
{ |
|
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2608 |
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
|
2609 |
TInt r = ThePasswordStore->WritePasswordData(pData); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2610 |
|
0 | 2611 |
if(r != KErrNone) |
2612 |
{ |
|
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_EXIT8, this ); |
0 | 2615 |
return; |
2616 |
} |
|
2617 |
||
2618 |
r = QuickCheckStatus(); |
|
2619 |
if(r != KErrNone) |
|
2620 |
{ |
|
2621 |
// Don't try to power up the device if it's not ready. |
|
2622 |
// - Note that this isn't an error that needs to be returned to the client. |
|
2623 |
CompleteRequest(m, KErrNone); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2624 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_HANDLEMSG_EXIT9, this ); |
0 | 2625 |
return; |
2626 |
} |
|
2627 |
||
2628 |
break; |
|
2629 |
} |
|
2630 |
case DLocalDrive::EPasswordStoreLengthInBytes: |
|
2631 |
{ |
|
2632 |
TInt length = ThePasswordStore->PasswordStoreLengthInBytes(); |
|
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2633 |
*(TInt*) m.RemoteDes() = length; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
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_EXIT10, this ); |
0 | 2636 |
return; |
2637 |
} |
|
2638 |
default: |
|
2639 |
CHECK_RET(KErrNotSupported); |
|
2640 |
CompleteRequest(m, KErrNotSupported); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2641 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_HANDLEMSG_EXIT11, this ); |
0 | 2642 |
return; |
2643 |
} |
|
2644 |
||
2645 |
__KTRACE_OPT(KFAIL,Kern::Printf("mdrq %d",m.Id())); |
|
2646 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase(%d)::HandleMsg state %d req %d",iMediaId,iState,m.Id())); |
|
2647 |
||
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2648 |
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
|
2649 |
|
0 | 2650 |
// if media driver already open, pass request through |
2651 |
if (iState==EReady) |
|
2652 |
{ |
|
2653 |
DoRequest(m); |
|
2654 |
__TRACE_TIMING(0x101); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2655 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_HANDLEMSG_EXIT12, this ); |
0 | 2656 |
return; |
2657 |
} |
|
2658 |
||
2659 |
// if open or close in progress, defer this message |
|
2660 |
if (iState!=EClosed && iState!=EPoweredDown) |
|
2661 |
{ |
|
2662 |
#ifdef __DEMAND_PAGING__ |
|
2663 |
if (DMediaPagingDevice::PagingRequest(m)) |
|
2664 |
{ |
|
2665 |
__ASSERT_ALWAYS(iPagingMedia,LOCM_FAULT()); |
|
2666 |
__ASSERT_DEBUG(iBody->iPagingDevice,LOCM_FAULT()); |
|
2667 |
__ASSERT_ALWAYS( ((m.Flags() & TLocDrvRequest::ECodePaging) == 0) || (m.Drive()->iPagingDrv), LOCM_FAULT()); |
|
2668 |
||
2669 |
__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
|
2670 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DPRIMARYMEDIABASE_HANDLEMSG3, "Deferring PageIn request 0x%08x because opening or closing", &m); |
0 | 2671 |
iBody->iPagingDevice->SendToDeferredQ(&m); |
2672 |
} |
|
2673 |
else |
|
2674 |
#endif |
|
2675 |
m.Forward(&iDeferred,EFalse); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2676 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_HANDLEMSG_EXIT13, this ); |
0 | 2677 |
return; |
2678 |
} |
|
2679 |
||
2680 |
// nothing is open, so try to open something |
|
2681 |
__ASSERT_ALWAYS(!iCurrentReq,LOCM_FAULT()); |
|
2682 |
||
2683 |
#ifdef __DEMAND_PAGING__ |
|
2684 |
||
2685 |
#ifdef BTRACE_PAGING_MEDIA |
|
2686 |
if (DMediaPagingDevice::PagingRequest(m)) |
|
2687 |
BTraceContext12(BTrace::EPagingMedia,BTrace::EPagingMediaLocMedPageInQuietlyDeferred,&m,iState,m.iValue); |
|
2688 |
#endif // BTRACE_PAGING_MEDIA |
|
2689 |
||
2690 |
#ifdef _DEBUG |
|
2691 |
__ASSERT_ALWAYS( ((m.Flags() & TLocDrvRequest::ECodePaging) == 0) || (m.Drive()->iPagingDrv), LOCM_FAULT()); |
|
2692 |
||
2693 |
if (DMediaPagingDevice::PagingRequest(m)) |
|
2694 |
{ |
|
2695 |
__ASSERT_DEBUG(iPagingMedia,LOCM_FAULT()); |
|
2696 |
__ASSERT_DEBUG(iBody->iPagingDevice,LOCM_FAULT()); |
|
2697 |
__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
|
2698 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DPRIMARYMEDIABASE_HANDLEMSG4, "Page request 0x%08x received; opening MD", &m); |
0 | 2699 |
} |
2700 |
#endif // _DEBUG |
|
2701 |
||
2702 |
#endif // __DEMAND_PAGING__ |
|
2703 |
||
2704 |
iCurrentReq=&m; |
|
2705 |
if(iState == EClosed) |
|
2706 |
{ |
|
2707 |
iState=EPoweringUp1; |
|
2708 |
} |
|
2709 |
else if (iState == EPoweredDown) |
|
2710 |
{ |
|
2711 |
iState=EPoweringUp2; |
|
2712 |
} |
|
2713 |
||
2714 |
TInt r=InitiatePowerUp(); |
|
2715 |
if (r==KErrNone || r==KErrServerBusy) |
|
2716 |
{ |
|
2717 |
// 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
|
2718 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_HANDLEMSG_EXIT14, this ); |
0 | 2719 |
return; |
2720 |
} |
|
2721 |
if (r==KErrCompletion) |
|
2722 |
r=KErrNone; // device already powered up |
|
2723 |
PowerUpComplete(r); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2724 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_HANDLEMSG_EXIT15, this ); |
0 | 2725 |
} |
2726 |
||
2727 |
EXPORT_C TInt DPrimaryMediaBase::DoRequest(TLocDrvRequest& m) |
|
2728 |
/** |
|
2729 |
If the media exists, it tries to get the partition information if not there. |
|
2730 |
It then passes on the request to the media driver by calling its Request( ) function. |
|
2731 |
Then it completes the kernel thread message and the reference count of the thread is closed asynchronously. |
|
2732 |
||
2733 |
@param aRequest Encapsulates the request information received from the client |
|
2734 |
||
2735 |
@return KErrNone, if successful |
|
2736 |
KErrNotReady, if missing partitions on removable media |
|
2737 |
KErrNotSupported, if missing partitions on fixed media |
|
2738 |
KErrArgument Out of range argument ,encapsulated in Local drive request , passed while checking and adjusting for partition |
|
2739 |
KErrEOF, Reached the end of file |
|
2740 |
KErrBadDescriptor, if request encapsulates a bad descriptor |
|
2741 |
Otherwise, one of the other system wide error codes. |
|
2742 |
||
2743 |
*/ |
|
2744 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2745 |
OstTraceFunctionEntry1( DPRIMARYMEDIABASE_DOREQUEST_ENTRY, this ); |
0 | 2746 |
__KTRACE_OPT2(KLOCDRV,KLOCDPAGING,Kern::Printf("DPrimaryMediaBase::DoRequest %d",m.Id())); |
2747 |
TLocDrv* pL=m.Drive(); |
|
2748 |
DMedia* media=pL->iMedia; |
|
2749 |
TInt r=KErrNone; |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2750 |
|
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2751 |
OstTraceDefExt3( OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DPRIMARYMEDIABASE_DOREQUEST, "req Id=%d; length=0x%x; position=0x%x", (TInt) m.Id(), (TInt) m.Length(), (TInt) m.Pos()); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2752 |
|
0 | 2753 |
// re-open this drive's media driver ? |
2754 |
if (m.iValue == DLocalDrive::EForceMediaChange) |
|
2755 |
{ |
|
2756 |
__ASSERT_DEBUG(((TUint) m.Pos()) == (TUint) KForceMediaChangeReOpenMediaDriver, LOCM_FAULT()); |
|
2757 |
iCurrentReq=NULL; |
|
2758 |
||
2759 |
TLocDrv* pL = m.Drive(); |
|
2760 |
DMedia* media = pL->iMedia; |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2761 |
|
0 | 2762 |
if (media && media->iDriver) |
2763 |
CloseMediaDrivers(media); |
|
2764 |
||
2765 |
iState=EOpening; |
|
2766 |
StartOpenMediaDrivers(); |
|
2767 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2768 |
NotifyClients(EMediaChange, pL); |
0 | 2769 |
CompleteRequest(m, r); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2770 |
OstTraceFunctionExitExt( DPRIMARYMEDIABASE_DOREQUEST_EXIT, this, r ); |
0 | 2771 |
return r; |
2772 |
} |
|
2773 |
||
2774 |
if (!media || !media->iDriver || iState == EClosed) |
|
2775 |
{ |
|
2776 |
// Return KErrNotReady for missing partitions on removable media |
|
2777 |
// as opposed to KErrNotSupported for missing partitions on fixed media |
|
2778 |
// since the latter don't exist whereas the former might exist at some time. |
|
2779 |
TInt sock; |
|
2780 |
r=IsRemovableDevice(sock) ? KErrNotReady : KErrNotSupported; |
|
2781 |
} |
|
2782 |
||
2783 |
iCurrentReq=&m; |
|
2784 |
if (r==KErrNone) |
|
2785 |
{ |
|
2786 |
if(iTotalPartitionsOpened == 0) |
|
2787 |
{ |
|
2788 |
UpdatePartitionInfo(); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2789 |
OstTraceFunctionExitExt( DPRIMARYMEDIABASE_DOREQUEST_EXIT2, this, KErrNone ); |
0 | 2790 |
return KErrNone; |
2791 |
} |
|
2792 |
if (!(m.Flags() & TLocDrvRequest::EAdjusted)) |
|
2793 |
{ |
|
2794 |
// 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
|
2795 |
if (TDriveIterator::GetPhysicalDrive(m.Drive())->iPrimaryMedia->iTotalPartitionsOpened > 1) |
0 | 2796 |
m.DriverFlags() &= ~RLocalDrive::ELocDrvWholeMedia; |
2797 |
r=m.CheckAndAdjustForPartition(); |
|
2798 |
} |
|
2799 |
if (r==KErrNone) |
|
2800 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2801 |
OstTraceDefExt2( OST_TRACE_CATEGORY_RND, TRACE_INTERNALS, DPRIMARYMEDIABASE_DOREQUEST_START, "req Id=%d; Remote Thread=0x%x", (TInt) m.Id(), (TUint) m.RemoteThread()); |
0 | 2802 |
r=media->iDriver->Request(m); |
2803 |
if (r>0) |
|
2804 |
{ |
|
2805 |
// defer request |
|
2806 |
#ifdef __DEMAND_PAGING__ |
|
2807 |
if (DMediaPagingDevice::PagingRequest(m)) |
|
2808 |
{ |
|
2809 |
__ASSERT_ALWAYS(iPagingMedia,LOCM_FAULT()); |
|
2810 |
__ASSERT_ALWAYS( ((m.Flags() & TLocDrvRequest::ECodePaging) == 0) || (m.Drive()->iPagingDrv), LOCM_FAULT()); |
|
2811 |
__ASSERT_DEBUG(iBody->iPagingDevice,LOCM_FAULT()); |
|
2812 |
__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
|
2813 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DPRIMARYMEDIABASE_DOREQUEST2, "Defer PageIn request 0x%08x", &m); |
0 | 2814 |
DMediaPagingDevice* pagingdevice=iBody->iPagingDevice; |
2815 |
||
2816 |
#ifdef __CONCURRENT_PAGING_INSTRUMENTATION__ |
|
2817 |
TInt id=m.iValue; |
|
2818 |
if (id==DMediaPagingDevice::ERomPageInRequest) |
|
2819 |
{ |
|
2820 |
NKern::FMWait(&pagingdevice->iInstrumentationLock); |
|
2821 |
if(pagingdevice->iEmptyingQ & DMediaPagingDevice::EDeferredQ) |
|
2822 |
pagingdevice->iROMStats.iTotalReDeferrals++; |
|
2823 |
else if(pagingdevice->iEmptyingQ & DMediaPagingDevice::EMainQ) |
|
2824 |
pagingdevice->iROMStats.iTotalSynchDeferredFromMainQ++; |
|
2825 |
NKern::FMSignal(&pagingdevice->iInstrumentationLock); |
|
2826 |
} |
|
2827 |
else if (m.Flags() & TLocDrvRequest::ECodePaging) |
|
2828 |
{ |
|
2829 |
NKern::FMWait(&pagingdevice->iInstrumentationLock); |
|
2830 |
if(pagingdevice->iEmptyingQ & DMediaPagingDevice::EDeferredQ) |
|
2831 |
pagingdevice->iCodeStats.iTotalReDeferrals++; |
|
2832 |
else if(pagingdevice->iEmptyingQ & DMediaPagingDevice::EMainQ) |
|
2833 |
pagingdevice->iCodeStats.iTotalSynchDeferredFromMainQ++; |
|
2834 |
NKern::FMSignal(&pagingdevice->iInstrumentationLock); |
|
2835 |
} |
|
2836 |
else if (m.Flags() & TLocDrvRequest::EDataPaging) |
|
2837 |
{ |
|
2838 |
NKern::FMWait(&pagingdevice->iInstrumentationLock); |
|
2839 |
if(pagingdevice->iEmptyingQ & DMediaPagingDevice::EDeferredQ) |
|
2840 |
pagingdevice->iDataStats.iTotalReDeferrals++; |
|
2841 |
else if(pagingdevice->iEmptyingQ & DMediaPagingDevice::EMainQ) |
|
2842 |
pagingdevice->iDataStats.iTotalSynchDeferredFromMainQ++; |
|
2843 |
NKern::FMSignal(&pagingdevice->iInstrumentationLock); |
|
2844 |
} |
|
2845 |
#endif |
|
2846 |
pagingdevice->SendToDeferredQ(&m); |
|
2847 |
} |
|
2848 |
else |
|
2849 |
#endif |
|
2850 |
m.Forward(&iDeferred,EFalse); |
|
2851 |
r=KErrNone; |
|
2852 |
} |
|
2853 |
#if defined(__DEMAND_PAGING__) && defined(_DEBUG) |
|
2854 |
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
|
2855 |
{ |
0 | 2856 |
__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
|
2857 |
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
|
2858 |
} |
0 | 2859 |
#endif |
2860 |
} |
|
2861 |
} |
|
2862 |
||
2863 |
if (r!=KErrNone && iCurrentReq) |
|
2864 |
{ |
|
2865 |
TInt s=(r==KErrCompletion)?KErrNone:r; |
|
2866 |
CHECK_RET(s); |
|
2867 |
||
2868 |
#ifdef __DEMAND_PAGING__ |
|
2869 |
// got here because media driver cannot service or defer this request or did service it synchronously |
|
2870 |
if (DMediaPagingDevice::PagingRequest(m)) |
|
2871 |
{ |
|
2872 |
__ASSERT_ALWAYS(iPagingMedia,LOCM_FAULT()); |
|
2873 |
__ASSERT_ALWAYS( ((m.Flags() & TLocDrvRequest::ECodePaging) == 0) || (m.Drive()->iPagingDrv), LOCM_FAULT()); |
|
2874 |
__ASSERT_DEBUG(iBody->iPagingDevice,LOCM_FAULT()); |
|
2875 |
__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
|
2876 |
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 | 2877 |
iBody->iPagingDevice->CompleteRequest(&m, s); |
2878 |
} |
|
2879 |
else |
|
2880 |
#endif |
|
2881 |
||
2882 |
CompleteRequest(m, s); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2883 |
OstTraceDefExt3( OST_TRACE_CATEGORY_RND, TRACE_INTERNALS, DPRIMARYMEDIABASE_DOREQUEST_RETURN, "Return req Id=%d; Remote Thread=0x%x; retval=%d", (TInt) m.Id(), (TUint) m.RemoteThread(), (TInt) s); |
0 | 2884 |
} |
2885 |
||
2886 |
iCurrentReq=NULL; |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2887 |
OstTraceFunctionExitExt( DPRIMARYMEDIABASE_DOREQUEST_EXIT3, this, r ); |
0 | 2888 |
return r; |
2889 |
} |
|
2890 |
||
2891 |
EXPORT_C void DPrimaryMediaBase::PowerUpComplete(TInt anError) |
|
2892 |
/** |
|
2893 |
Called after the device is powered up or there is some error while powering up the device. |
|
2894 |
If there is an error powering up the devices then it just completes the current running requests with an error |
|
2895 |
and also completes the outstanding requests on the iDeferred message queue by calling SetClosed( ). |
|
2896 |
If the device is powered up OK then it either opens the media drivers |
|
2897 |
and if they are already open then it handles the current/pending requests. |
|
2898 |
||
2899 |
@param anError Error code to be passed on while completing outstanding requests. |
|
2900 |
*/ |
|
2901 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2902 |
OstTraceFunctionEntry1( DPRIMARYMEDIABASE_POWERUPCOMPLETE_ENTRY, this ); |
0 | 2903 |
__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
|
2904 |
|
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2905 |
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
|
2906 |
|
0 | 2907 |
if (anError!=KErrNone) |
2908 |
{ |
|
2909 |
// error powering up device |
|
2910 |
if (iState==EPoweringUp1 || iState==EPoweringUp2) |
|
2911 |
SetClosed(anError); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2912 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_POWERUPCOMPLETE_EXIT, this ); |
0 | 2913 |
return; |
2914 |
} |
|
2915 |
||
2916 |
// Powered up OK - now open media drivers |
|
2917 |
if (iState==EPoweringUp1) |
|
2918 |
{ |
|
2919 |
iState=EOpening; |
|
2920 |
StartOpenMediaDrivers(); |
|
2921 |
} |
|
2922 |
else if (iState==EPoweringUp2) |
|
2923 |
{ |
|
2924 |
// media is powered up and ready, so handle the current/pending requests |
|
2925 |
MediaReadyHandleRequest(); |
|
2926 |
} |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2927 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_POWERUPCOMPLETE_EXIT2, this ); |
0 | 2928 |
} |
2929 |
||
2930 |
void DPrimaryMediaBase::CloseMediaDrivers(DMedia* aMedia) |
|
2931 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2932 |
OstTraceFunctionEntry1( DPRIMARYMEDIABASE_CLOSEMEDIADRIVERS_ENTRY, this ); |
0 | 2933 |
__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
|
2934 |
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
|
2935 |
|
0 | 2936 |
// we mustn't ever close the media driver if it's responsible for data paging as re-opening the drive |
2937 |
// would involve memory allocation which might cause deadlock if the kernel heap were to grow |
|
2938 |
#ifdef __DEMAND_PAGING__ |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2939 |
if (DataPagingMedia(this)) |
0 | 2940 |
{ |
2941 |
__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
|
2942 |
OstTrace1(TRACE_FLOW, DPRIMARYMEDIABASE_CLOSEMEDIADRIVERS_EXIT1, "CloseMediaDrivers aborting for data paging media 0x%08x", this); |
0 | 2943 |
return; |
2944 |
} |
|
2945 |
#endif |
|
2946 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2947 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2948 |
// 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
|
2949 |
// 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
|
2950 |
if (iBody->iMediaExtension) |
0 | 2951 |
{ |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2952 |
__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
|
2953 |
return; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2954 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2955 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2956 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2957 |
TDriveIterator driveIter; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2958 |
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
|
2959 |
{ |
0 | 2960 |
if (pL && pL->iPrimaryMedia==this) |
2961 |
{ |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2962 |
__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
|
2963 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_MEDIACHANGE, DPRIMARYMEDIABASE_CLOSEMEDIADRIVERS2, "Drive=%d", driveIter.Index()); |
0 | 2964 |
if (aMedia == NULL || pL->iMedia == aMedia) |
2965 |
{ |
|
2966 |
pL->iMedia=NULL; |
|
2967 |
} |
|
2968 |
} |
|
2969 |
} |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
2970 |
for (TInt i=iLastMediaId; i>=iMediaId; i--) |
0 | 2971 |
{ |
2972 |
DMedia* pM=TheMedia[i]; |
|
2973 |
if (aMedia == NULL || pM == aMedia) |
|
2974 |
{ |
|
2975 |
DMediaDriver* pD=pM->iDriver; |
|
2976 |
pM->iDriver=NULL; |
|
2977 |
__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
|
2978 |
OstTraceDefExt3( OST_TRACE_CATEGORY_RND, TRACE_MEDIACHANGE, DPRIMARYMEDIABASE_CLOSEMEDIADRIVERS3, "MediaId=%d; DMedia=0x%08x; MediaDriver=0x%08x", (TInt) i, (TUint) pM, (TUint) pD ); |
0 | 2979 |
if (pD) |
2980 |
pD->Close(); |
|
2981 |
} |
|
2982 |
} |
|
2983 |
__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
|
2984 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_CLOSEMEDIADRIVERS_EXIT2, this ); |
0 | 2985 |
} |
2986 |
||
2987 |
void DPrimaryMediaBase::StartOpenMediaDrivers() |
|
2988 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2989 |
OstTraceFunctionEntry1( DPRIMARYMEDIABASE_STARTOPENMEDIADRIVERS_ENTRY, this ); |
0 | 2990 |
__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
|
2991 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_MEDIACHANGE, DPRIMARYMEDIABASE_STARTOPENMEDIADRIVERS, "DPrimaryMediaBase iMediaId=%d ",iMediaId); |
0 | 2992 |
TVersion ver(KMediaDriverInterfaceMajorVersion,KMediaDriverInterfaceMinorVersion,KMediaDriverInterfaceBuildVersion); |
2993 |
||
2994 |
// Get a list of all currently loaded media drivers |
|
2995 |
// Most media drivers do not make use of the pointer iMountInfo.iInfo when |
|
2996 |
// their Validate() procedures are called from RPhysicalDeviceArray::GetDriverList(). |
|
2997 |
// However, a group of media drivers sharing the same id (passed in iDevice) may use |
|
2998 |
// the additional information pointed to by iMountInfo.iInfo to distinguish |
|
2999 |
// group members. This information is passed when the media driver is registered |
|
3000 |
// using LocDrv::RegisterMediaDevice(). |
|
3001 |
TInt r=iPhysDevArray.GetDriverList(KLitMediaDriverName,iDevice,iMountInfo.iInfo,ver); |
|
3002 |
if (r!=KErrNone) |
|
3003 |
{ |
|
3004 |
// out of memory or no driver exists |
|
3005 |
SetClosed(r); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3006 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_STARTOPENMEDIADRIVERS_EXIT1, this ); |
0 | 3007 |
return; |
3008 |
} |
|
3009 |
||
3010 |
// Go through them starting with highest priority |
|
3011 |
iNextMediaId=iMediaId; |
|
3012 |
iBody->iPhysDevIndex=iPhysDevArray.Count()-1; |
|
3013 |
iTotalPartitionsOpened=0; |
|
3014 |
iMediaDriversOpened=0; |
|
3015 |
iNextMediaDriver=NULL; |
|
3016 |
OpenNextMediaDriver(); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3017 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_STARTOPENMEDIADRIVERS_EXIT2, this ); |
0 | 3018 |
} |
3019 |
||
3020 |
void DPrimaryMediaBase::OpenNextMediaDriver() |
|
3021 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3022 |
OstTraceFunctionEntry1( DPRIMARYMEDIABASE_OPENNEXTMEDIADRIVER_ENTRY, this ); |
0 | 3023 |
__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
|
3024 |
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
|
3025 |
|
0 | 3026 |
TVersion ver(KMediaDriverInterfaceMajorVersion,KMediaDriverInterfaceMinorVersion,KMediaDriverInterfaceBuildVersion); |
3027 |
SPhysicalDeviceEntry& e=iPhysDevArray[iBody->iPhysDevIndex]; |
|
3028 |
DPhysicalDevice* pD=e.iPhysicalDevice; |
|
3029 |
||
3030 |
iState = EOpening; |
|
3031 |
||
3032 |
DMedia* pM=TheMedia[iNextMediaId]; |
|
3033 |
if (pM && pM->iDriver != NULL) |
|
3034 |
{ |
|
3035 |
iNextMediaDriver = pM->iDriver; |
|
3036 |
DoOpenMediaDriverComplete(KErrNone); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3037 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_OPENNEXTMEDIADRIVER_EXIT1, this ); |
0 | 3038 |
return; |
3039 |
} |
|
3040 |
||
3041 |
// this may be asynchronous |
|
3042 |
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
|
3043 |
|
0 | 3044 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("Media:Open-Opening %o(PRI:%d)-%d",pD,e.iPriority,s)); |
3045 |
if (s!=KErrNone) |
|
3046 |
{ |
|
3047 |
iAsyncErrorCode=s; |
|
3048 |
iAsyncDfc.Enque(); |
|
3049 |
} |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3050 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_OPENNEXTMEDIADRIVER_EXIT2, this ); |
0 | 3051 |
} |
3052 |
||
3053 |
// Called when a media driver has responded to the Open request |
|
3054 |
void DPrimaryMediaBase::DoOpenMediaDriverComplete(TInt anError) |
|
3055 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3056 |
OstTraceFunctionEntry1( DPRIMARYMEDIABASE_DOOPENMEDIADRIVERCOMPLETE_ENTRY, this ); |
0 | 3057 |
__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
|
3058 |
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
|
3059 |
|
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3060 |
|
0 | 3061 |
if (anError!=KErrNone) |
3062 |
{ |
|
3063 |
DMediaDriver* md = iNextMediaDriver; |
|
3064 |
iNextMediaDriver = NULL; |
|
3065 |
if (md) |
|
3066 |
md->Close(); |
|
3067 |
} |
|
3068 |
if (anError==KErrNotReady || anError==KErrNoMemory) |
|
3069 |
{ |
|
3070 |
// if it's not ready or we're out of memory, abort |
|
3071 |
CloseMediaDrivers(); |
|
3072 |
SetClosed(anError); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3073 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_DOOPENMEDIADRIVERCOMPLETE_EXIT1, this ); |
0 | 3074 |
return; |
3075 |
} |
|
3076 |
if (anError==KErrNone) |
|
3077 |
{ |
|
3078 |
DMedia* pM=TheMedia[iNextMediaId]; |
|
3079 |
pM->iDriver=iNextMediaDriver; |
|
3080 |
DPhysicalDevice*& pD=iPhysDevArray[iBody->iPhysDevIndex].iPhysicalDevice; |
|
3081 |
iNextMediaDriver->iPhysicalDevice=pD; |
|
3082 |
pD=NULL; // so it won't be closed when we tidy up |
|
3083 |
++iMediaDriversOpened; |
|
3084 |
} |
|
3085 |
||
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3086 |
|
0 | 3087 |
// if no error, read partition info on media |
3088 |
iState = EReadPartitionInfo; |
|
3089 |
||
3090 |
if (anError == KErrNone) |
|
3091 |
{ |
|
3092 |
DMedia* pM=TheMedia[iNextMediaId]; |
|
3093 |
TInt r = pM->iDriver->PartitionInfo(pM->iPartitionInfo); |
|
3094 |
if (r!=KErrNone) |
|
3095 |
{ |
|
3096 |
if (r==KErrCompletion) |
|
3097 |
r=KErrNone; |
|
3098 |
DoPartitionInfoComplete(r); |
|
3099 |
} |
|
3100 |
} |
|
3101 |
else |
|
3102 |
{ |
|
3103 |
DoPartitionInfoComplete(anError); |
|
3104 |
} |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3105 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_DOOPENMEDIADRIVERCOMPLETE_EXIT2, this ); |
0 | 3106 |
} |
3107 |
||
3108 |
void DPrimaryMediaBase::DoPartitionInfoComplete(TInt anError) |
|
3109 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3110 |
OstTraceFunctionEntry1( DPRIMARYMEDIABASE_DOPARTITIONINFOCOMPLETE_ENTRY, this ); |
0 | 3111 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase(%d)::DoPartitionInfoComplete error %d",iNextMediaId,anError)); |
3112 |
||
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3113 |
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
|
3114 |
|
0 | 3115 |
DMedia* pM=TheMedia[iNextMediaId]; |
3116 |
if (anError==KErrNone || anError == KErrLocked) |
|
3117 |
{ |
|
3118 |
// successfully read partition info |
|
3119 |
iTotalPartitionsOpened+=pM->PartitionCount(); |
|
3120 |
} |
|
3121 |
else |
|
3122 |
{ |
|
3123 |
// couldn't read partition info or driver failed to open |
|
3124 |
if (pM->iDriver) |
|
3125 |
{ |
|
3126 |
#ifdef __DEMAND_PAGING__ |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3127 |
if (DataPagingMedia(this)) |
0 | 3128 |
{ |
3129 |
__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
|
3130 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DPRIMARYMEDIABASE_DOPARTITIONINFOCOMPLETE2, "Close Media Driver for data paging media 0x%08x", this); |
0 | 3131 |
} |
3132 |
else |
|
3133 |
#endif |
|
3134 |
{ |
|
3135 |
pM->iDriver->Close(); |
|
3136 |
pM->iDriver=NULL; |
|
3137 |
} |
|
3138 |
} |
|
3139 |
if (anError==KErrNotReady || anError==KErrNoMemory) |
|
3140 |
{ |
|
3141 |
// if it's not ready or we're out of memory, or the drive is locked, abort |
|
3142 |
CloseMediaDrivers(); |
|
3143 |
SetClosed(anError); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3144 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_DOPARTITIONINFOCOMPLETE_EXIT, this ); |
0 | 3145 |
return; |
3146 |
} |
|
3147 |
} |
|
3148 |
||
3149 |
// Open next media driver, if there is one |
|
3150 |
TBool complete = EFalse; |
|
3151 |
if (++iNextMediaId>iLastMediaId) |
|
3152 |
complete=ETrue; |
|
3153 |
if (iBody->iPhysDevIndex==0) |
|
3154 |
complete=ETrue; |
|
3155 |
else |
|
3156 |
iBody->iPhysDevIndex--; |
|
3157 |
if (!complete) |
|
3158 |
{ |
|
3159 |
OpenNextMediaDriver(); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3160 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_DOPARTITIONINFOCOMPLETE_EXIT2, this ); |
0 | 3161 |
return; |
3162 |
} |
|
3163 |
||
3164 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase %d All media drivers open & partitions read",iMediaId)); |
|
3165 |
__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
|
3166 |
OstTrace1( TRACE_INTERNALS, DPRIMARYMEDIABASE_DOPARTITIONINFOCOMPLETE3, "iMediaDriversOpened=%d", iMediaDriversOpened ); |
0 | 3167 |
if (iMediaDriversOpened==0) |
3168 |
{ |
|
3169 |
SetClosed(KErrNotSupported); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3170 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_DOPARTITIONINFOCOMPLETE_EXIT3, this ); |
0 | 3171 |
return; |
3172 |
} |
|
3173 |
||
3174 |
// we are now finished with media driver list |
|
3175 |
iPhysDevArray.Close(); |
|
3176 |
||
3177 |
// Finished reading partition info |
|
3178 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase %d Read partition info complete",iMediaId)); |
|
3179 |
__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
|
3180 |
OstTraceExt2( TRACE_INTERNALS, DPRIMARYMEDIABASE_DOPARTITIONINFOCOMPLETE4, "Read partition info complete iMediaId=%d; iPartitionsOpened=%d", iMediaId, iTotalPartitionsOpened ); |
0 | 3181 |
if (iTotalPartitionsOpened==0) |
3182 |
{ |
|
3183 |
SetClosed(KErrNotSupported); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3184 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_DOPARTITIONINFOCOMPLETE_EXIT4, this ); |
0 | 3185 |
return; |
3186 |
} |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3187 |
|
0 | 3188 |
// work out mapping of drives to partitions/media |
3189 |
TInt totalPartitions=iTotalPartitionsOpened; |
|
3190 |
TInt id=iMediaId; // start with primary media |
|
3191 |
TInt partitionsOnThisMedia=PartitionCount(); |
|
3192 |
TInt partition=0; |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3193 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3194 |
TDriveIterator driveIter; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3195 |
for (TLocDrv* pD = driveIter.NextDrive(); pD != NULL; pD = driveIter.NextDrive()) |
0 | 3196 |
{ |
3197 |
if (pD && pD->iPrimaryMedia==this) |
|
3198 |
{ |
|
3199 |
if (totalPartitions==0) |
|
3200 |
{ |
|
3201 |
pD->iMedia=NULL; |
|
3202 |
continue; |
|
3203 |
} |
|
3204 |
if (partition==partitionsOnThisMedia) |
|
3205 |
{ |
|
3206 |
id++; |
|
3207 |
partition=0; |
|
3208 |
partitionsOnThisMedia=TheMedia[id]->PartitionCount(); |
|
3209 |
} |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3210 |
__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
|
3211 |
OstTraceExt3( TRACE_INTERNALS, DPRIMARYMEDIABASE_DOPARTITIONINFOCOMPLETE5, "Local Drive=%d; iMediaId=%d; partition=%d", driveIter.Index(), id, partition ); |
0 | 3212 |
pD->iMedia=TheMedia[id]; |
3213 |
pD->iPartitionNumber=partition; |
|
3214 |
memcpy(pD, pD->iMedia->iPartitionInfo.iEntry+partition, sizeof(TPartitionEntry)); |
|
3215 |
partition++; |
|
3216 |
totalPartitions--; |
|
3217 |
} |
|
3218 |
} |
|
3219 |
||
3220 |
// media is now ready - handle current or deferred requests |
|
3221 |
MediaReadyHandleRequest(); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3222 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_DOPARTITIONINFOCOMPLETE_EXIT5, this ); |
0 | 3223 |
} |
3224 |
||
3225 |
void DPrimaryMediaBase::MediaReadyHandleRequest() |
|
3226 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3227 |
OstTraceFunctionEntry1( DPRIMARYMEDIABASE_MEDIAREADYHANDLEREQUEST_ENTRY, this ); |
0 | 3228 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase::MediaReadyHandleRequest() this %x", this)); |
3229 |
iState = EReady; |
|
3230 |
||
3231 |
// now we can process the current request |
|
3232 |
// careful - thread may have exited while we were powering up |
|
3233 |
if (iCurrentReq) |
|
3234 |
{ |
|
3235 |
DoRequest(*iCurrentReq); // this sets iCurrentReq=NULL |
|
3236 |
} |
|
3237 |
||
3238 |
// see if we can process any other requests concurrently |
|
3239 |
RunDeferred(); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3240 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_MEDIAREADYHANDLEREQUEST_EXIT, this ); |
0 | 3241 |
} |
3242 |
||
3243 |
void DPrimaryMediaBase::UpdatePartitionInfo() |
|
3244 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3245 |
OstTraceFunctionEntry1( DPRIMARYMEDIABASE_UPDATEPARTITIONINFO_ENTRY, this ); |
0 | 3246 |
iState=EReadPartitionInfo; |
3247 |
iNextMediaId=iMediaId; |
|
3248 |
DMedia* pM=TheMedia[iNextMediaId]; |
|
3249 |
TInt r=pM->iDriver->PartitionInfo(pM->iPartitionInfo); |
|
3250 |
if (r!=KErrNone) |
|
3251 |
{ |
|
3252 |
if (r==KErrCompletion) |
|
3253 |
r=KErrNone; |
|
3254 |
DoPartitionInfoComplete(r); |
|
3255 |
} |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3256 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_UPDATEPARTITIONINFO_EXIT, this ); |
0 | 3257 |
} |
3258 |
||
3259 |
void DPrimaryMediaBase::CompleteCurrent(TInt anError) |
|
3260 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3261 |
OstTraceFunctionEntryExt( DPRIMARYMEDIABASE_COMPLETECURRENT_ENTRY, this ); |
0 | 3262 |
if (iCurrentReq) |
3263 |
{ |
|
3264 |
CHECK_RET(anError); |
|
3265 |
#ifdef __DEMAND_PAGING__ |
|
3266 |
// got here because it was powered down when powering up, or failed powering up or failed opening MD or got media change |
|
3267 |
if (DMediaPagingDevice::PagingRequest(*iCurrentReq)) |
|
3268 |
{ |
|
3269 |
__ASSERT_ALWAYS(iPagingMedia,LOCM_FAULT()); |
|
3270 |
__ASSERT_DEBUG(iBody->iPagingDevice,LOCM_FAULT()); |
|
3271 |
__ASSERT_ALWAYS( ((iCurrentReq->Flags() & TLocDrvRequest::ECodePaging) == 0) || (iCurrentReq->Drive()->iPagingDrv), LOCM_FAULT()); |
|
3272 |
||
3273 |
__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
|
3274 |
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 | 3275 |
iBody->iPagingDevice->CompleteRequest(iCurrentReq, anError); |
3276 |
} |
|
3277 |
else |
|
3278 |
#endif |
|
3279 |
CompleteRequest(*iCurrentReq, anError); |
|
3280 |
iCurrentReq=NULL; |
|
3281 |
} |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3282 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_COMPLETECURRENT_EXIT, this ); |
0 | 3283 |
} |
3284 |
||
3285 |
||
3286 |
void DPrimaryMediaBase::CompleteRequest(TLocDrvRequest& aMsg, TInt aResult) |
|
3287 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3288 |
OstTraceFunctionEntry1( DPRIMARYMEDIABASE_COMPLETEREQUEST_ENTRY, this ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3289 |
OstTraceDefExt2(OST_TRACE_CATEGORY_RND, TRACE_REQUEST, DPRIMARYMEDIABASE_COMPLETEREQUEST1, "TLocDrvRequest Object=0x%x; aResult=%d", (TUint) &aMsg, aResult); |
0 | 3290 |
aMsg.Complete(aResult,EFalse); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3291 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_COMPLETEREQUEST_EXIT, this ); |
0 | 3292 |
} |
3293 |
||
3294 |
EXPORT_C void DPrimaryMediaBase::RunDeferred() |
|
3295 |
/** |
|
3296 |
Runs deferred Requests. Initiated from DPrimaryMediaBase::PowerUpComplete() function |
|
3297 |
to see if any other requests can be processed concurrently. |
|
3298 |
Can also be called from DPrimaryMediaBase::NotifyPowerDown |
|
3299 |
or DPrimaryMediaBase::NotifyEmergencyPowerDown() function or DMediaDriver::Complete() |
|
3300 |
*/ |
|
3301 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3302 |
OstTraceFunctionEntry1( DPRIMARYMEDIABASE_RUNDEFERRED_ENTRY, this ); |
0 | 3303 |
// Do nothing if an open or close is in progress - this might be the case, for example, |
3304 |
// if a EForceMediaChange request (with the KForceMediaChangeReOpenMediaDriver flag) |
|
3305 |
// has recently been processed |
|
3306 |
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
|
3307 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3308 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_RUNDEFERRED_EXIT1, this ); |
0 | 3309 |
return; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3310 |
} |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3311 |
|
0 | 3312 |
// rerun deferred requests; |
3313 |
#ifdef __DEMAND_PAGING__ |
|
3314 |
#ifdef __CONCURRENT_PAGING_INSTRUMENTATION__ |
|
3315 |
TInt countROM=0; |
|
3316 |
TInt countCode=0; |
|
3317 |
#endif |
|
3318 |
||
3319 |
if(iPagingMedia) |
|
3320 |
{ |
|
3321 |
__ASSERT_DEBUG(iBody->iPagingDevice,LOCM_FAULT()); |
|
3322 |
if(iBody->iPagingDevice->iEmptyingQ & DMediaPagingDevice::EDeferredQ) // if already emptying deferred page in queue, don't reenter |
|
3323 |
{ |
|
3324 |
__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
|
3325 |
OstTrace0(TRACE_FLOW, DPRIMARYMEDIABASE_RUNDEFERRED_EXIT2, "< Already emptying deferred queue"); |
0 | 3326 |
return; |
3327 |
} |
|
3328 |
||
3329 |
DMediaPagingDevice* pagingdevice=iBody->iPagingDevice; |
|
3330 |
TLocDrvRequest* pL = (TLocDrvRequest*) pagingdevice->iDeferredQ.Last(); |
|
3331 |
if(pL) |
|
3332 |
{ |
|
3333 |
pagingdevice->iEmptyingQ|= DMediaPagingDevice::EDeferredQ; // prevent reentering when already emptying this queue |
|
3334 |
TLocDrvRequest* pM=NULL; |
|
3335 |
while (pM != pL && (pM = (TLocDrvRequest*) pagingdevice->iDeferredQ.Poll()) != NULL) // synchronously empty deferred queue but ignore re-deferrals |
|
3336 |
{ |
|
3337 |
__ASSERT_ALWAYS( DMediaPagingDevice::PagingRequest(*pL), LOCM_FAULT() ); |
|
3338 |
||
3339 |
#ifdef __CONCURRENT_PAGING_INSTRUMENTATION__ |
|
3340 |
(pM->iValue==DMediaPagingDevice::ERomPageInRequest)?(countROM++):(countCode++); |
|
3341 |
if(pM==pL) |
|
3342 |
{ |
|
3343 |
NKern::FMWait(&pagingdevice->iInstrumentationLock); |
|
3344 |
if(pM->iValue==DMediaPagingDevice::ERomPageInRequest && pagingdevice->iROMStats.iMaxReqsInDeferred<countROM) |
|
3345 |
pagingdevice->iROMStats.iMaxReqsInDeferred=countROM; |
|
3346 |
else if ((pM->Flags() & TLocDrvRequest::ECodePaging) && pagingdevice->iCodeStats.iMaxReqsInDeferred<countCode) |
|
3347 |
pagingdevice->iCodeStats.iMaxReqsInDeferred=countCode; |
|
3348 |
else if ((pM->Flags() & TLocDrvRequest::EDataPaging) && pagingdevice->iDataStats.iMaxReqsInDeferred<countCode) |
|
3349 |
pagingdevice->iDataStats.iMaxReqsInDeferred=countCode; |
|
3350 |
NKern::FMSignal(&pagingdevice->iInstrumentationLock); |
|
3351 |
} |
|
3352 |
#endif |
|
3353 |
__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
|
3354 |
OstTraceDefExt2(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DPRIMARYMEDIABASE_RUNDEFERRED2, "process req=0x%08x; last in deferred queue=0x%08x",(TUint) pM, (TUint) pL); |
0 | 3355 |
#ifdef BTRACE_PAGING_MEDIA |
3356 |
BTraceContext8(BTrace::EPagingMedia,BTrace::EPagingMediaLocMedPageInDeferredReposted,pM,pM->iValue); |
|
3357 |
#endif |
|
3358 |
// if Page In requests are synchronous this services them all in sequence, |
|
3359 |
// if they're asynch it re-defers them |
|
3360 |
DoRequest(*(TLocDrvRequest*)pM); |
|
3361 |
} |
|
3362 |
pagingdevice->iEmptyingQ&= ~DMediaPagingDevice::EDeferredQ; |
|
3363 |
} |
|
3364 |
||
3365 |
// the reason we now try an empty the main Page In queue is there is at least one type of Page In request |
|
3366 |
// serviced synchronously in which case when we empty the deferred Page In queue as above, received Page In |
|
3367 |
// requests are left in the main queue (not deferred) and we don't want to start processing deferred normal |
|
3368 |
// requests before these Page In requests. If all deferred normal requests are synchronous, the received Page |
|
3369 |
// In requests will have to wait until all are serviced. NB: requests may be deferred even if the MD services |
|
3370 |
// all requests synchronously, but runs background tasks that cannot be interrupted. In this last case the |
|
3371 |
// normal deferred queue may have some very long latency requests. |
|
3372 |
if(pagingdevice->iEmptyingQ & DMediaPagingDevice::EMainQ) // already emptying main Page In queue, skip (any Page In requests will be deferred) |
|
3373 |
{ |
|
3374 |
__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
|
3375 |
OstTrace0(TRACE_FLOW, DPRIMARYMEDIABASE_RUNDEFERRED_EXIT3, "< Already emptying main queue"); |
0 | 3376 |
return; |
3377 |
} |
|
3378 |
||
3379 |
TLocDrvRequest* pM=NULL; |
|
3380 |
if (!pagingdevice->iMainQ.iReady) // if it's ready, then queue is empty |
|
3381 |
{ |
|
3382 |
pM = (TLocDrvRequest*) pagingdevice->iMainQ.iMessage; |
|
3383 |
pagingdevice->iMainQ.iMessage = NULL; |
|
3384 |
if (pM == NULL) |
|
3385 |
pM = (TLocDrvRequest*) pagingdevice->iMainQ.Poll(); |
|
3386 |
} |
|
3387 |
||
3388 |
#ifdef __CONCURRENT_PAGING_INSTRUMENTATION__ |
|
3389 |
countROM = countCode=0; |
|
3390 |
#endif |
|
3391 |
if(pM) |
|
3392 |
{ |
|
3393 |
#ifdef __CONCURRENT_PAGING_INSTRUMENTATION__ |
|
3394 |
__e32_atomic_add_ord32(&pagingdevice->iROMStats.iTotalSynchEmptiedMainQ, 1); |
|
3395 |
#endif |
|
3396 |
pagingdevice->iEmptyingQ|=DMediaPagingDevice::EMainQ; |
|
3397 |
for ( ; pM != NULL; pM = (TLocDrvRequest*) pagingdevice->iMainQ.Poll()) |
|
3398 |
{ |
|
3399 |
__ASSERT_ALWAYS(DMediaPagingDevice::PagingRequest(*pM), LOCM_FAULT()); |
|
3400 |
||
3401 |
#ifdef __CONCURRENT_PAGING_INSTRUMENTATION__ |
|
3402 |
(pM->iValue==DMediaPagingDevice::ERomPageInRequest)?(countROM++):(countCode++); |
|
3403 |
#endif |
|
3404 |
||
3405 |
__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
|
3406 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DPRIMARYMEDIABASE_RUNDEFERRED4, "process req=0x%08x", pM); |
0 | 3407 |
DoRequest(*(TLocDrvRequest*)pM); // if Page In requests are synchronous this services them all in sequence, if they're asynch it defers them |
3408 |
} |
|
3409 |
||
3410 |
pagingdevice->iEmptyingQ&= ~DMediaPagingDevice::EMainQ; |
|
3411 |
||
3412 |
||
3413 |
#ifdef __CONCURRENT_PAGING_INSTRUMENTATION__ |
|
3414 |
NKern::FMWait(&pagingdevice->iInstrumentationLock); |
|
3415 |
pagingdevice->iROMStats.iTotalSynchServicedFromMainQ+=countROM; |
|
3416 |
if(pagingdevice->iROMStats.iMaxReqsInPending<countROM) |
|
3417 |
pagingdevice->iROMStats.iMaxReqsInPending=countROM; |
|
3418 |
pagingdevice->iCodeStats.iTotalSynchServicedFromMainQ+=countCode; |
|
3419 |
if(pagingdevice->iCodeStats.iMaxReqsInPending<countCode) |
|
3420 |
pagingdevice->iCodeStats.iMaxReqsInPending=countCode; |
|
3421 |
NKern::FMSignal(&pagingdevice->iInstrumentationLock); |
|
3422 |
#endif |
|
3423 |
} // if (pM) |
|
3424 |
} // if(iPagingMedia) |
|
3425 |
#endif |
|
3426 |
if (iRunningDeferred) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3427 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3428 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_RUNDEFERRED_EXIT4, this ); |
0 | 3429 |
return; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3430 |
} |
0 | 3431 |
TMessageBase* pL = iDeferred.Last(); |
3432 |
if (!pL) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3433 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3434 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_RUNDEFERRED_EXIT5, this ); |
0 | 3435 |
return; // no deferred requests |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3436 |
} |
0 | 3437 |
iRunningDeferred=1; |
3438 |
TMessageBase* pM=NULL; |
|
3439 |
||
3440 |
while( pM != pL && (pM=iDeferred.Poll()) != NULL) // stop after processing last one (requests may be re-deferred) |
|
3441 |
DoRequest(*(TLocDrvRequest*)pM); |
|
3442 |
iRunningDeferred=0; |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3443 |
|
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3444 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_RUNDEFERRED_EXIT6, this ); |
0 | 3445 |
} |
3446 |
||
3447 |
void DPrimaryMediaBase::SetClosed(TInt anError) |
|
3448 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3449 |
OstTraceFunctionEntry1( DPRIMARYMEDIABASE_SETCLOSED_ENTRY, this ); |
0 | 3450 |
__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
|
3451 |
OstTraceExt2( TRACE_MEDIACHANGE, DPRIMARYMEDIABASE_SETCLOSED, "iMediaId=%d; anError=%d", iMediaId, anError ); |
0 | 3452 |
CHECK_RET(anError); |
3453 |
||
3454 |
// cancel DMediaDriver::OpenMediaDriverComplete() / DMediaDriver::PartitionInfoComplete() DFC |
|
3455 |
iAsyncDfc.Cancel(); |
|
3456 |
||
3457 |
iDeferred.CompleteAll(anError); |
|
3458 |
||
3459 |
#ifdef __DEMAND_PAGING__ |
|
3460 |
if(iPagingMedia) |
|
3461 |
iBody->iPagingDevice->iDeferredQ.CompleteAll(anError); |
|
3462 |
#endif |
|
3463 |
||
3464 |
CompleteCurrent(anError); |
|
3465 |
||
3466 |
||
3467 |
||
3468 |
if (iState==EOpening) |
|
3469 |
iPhysDevArray.Close(); |
|
3470 |
||
3471 |
iState = EClosed; |
|
3472 |
||
3473 |
iWaitMedChg.CompleteAll(KErrNone); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3474 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_SETCLOSED_EXIT, this ); |
0 | 3475 |
} |
3476 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3477 |
void DPrimaryMediaBase::NotifyClients(TNotifyType aNotifyType, TLocDrv* aLocDrv) |
0 | 3478 |
|
3479 |
// |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3480 |
// Notify all clients of a media change or media present event |
0 | 3481 |
// |
3482 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3483 |
OstTraceFunctionEntryExt( DPRIMARYMEDIABASE_NOTIFYCLIENTS_ENTRY, this ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3484 |
|
0 | 3485 |
SDblQueLink* pL=iConnectionQ.iA.iNext; |
3486 |
while (pL!=&iConnectionQ.iA) |
|
3487 |
{ |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3488 |
// Get pointer to TCallBackLink |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3489 |
TCallBackLink* pCallBackLink = _LOFF(pL,TCallBackLink,iLink); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3490 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3491 |
// 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
|
3492 |
// 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
|
3493 |
__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
|
3494 |
TLocDrv* locDrv; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3495 |
if (pCallBackLink->iObjectType == TCallBackLink::EDLocalDriveObject) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3496 |
locDrv = ((DLocalDrive*) _LOFF(pCallBackLink,DLocalDrive, iMediaChangeObserver))->iDrive; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3497 |
else |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3498 |
locDrv = ((TLocDrv*) _LOFF(pCallBackLink,TLocDrv, iMediaChangeObserver))->iNextDrive; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3499 |
|
0 | 3500 |
// Issue the notification if the caller wants to notify all drives (aLocDrv == NULL) or |
3501 |
// the specified drive matches this one |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3502 |
if (aLocDrv == NULL || aLocDrv == locDrv) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3503 |
pCallBackLink->CallBack(aNotifyType); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3504 |
|
0 | 3505 |
pL=pL->iNext; |
3506 |
} |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3507 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_NOTIFYCLIENTS_EXIT, this ); |
0 | 3508 |
} |
3509 |
||
3510 |
EXPORT_C void DPrimaryMediaBase::NotifyMediaChange() |
|
3511 |
/** |
|
3512 |
Closes all media drivers on this device and notifies all connections that media change has occurred |
|
3513 |
and completes any outstanding requests with KErrNotReady. |
|
3514 |
This also completes any force media change requests with KErrNone. |
|
3515 |
*/ |
|
3516 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3517 |
OstTraceFunctionEntry1( DPRIMARYMEDIABASE_NOTIFYMEDIACHANGE_ENTRY, this ); |
0 | 3518 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("DPrimaryMediaBase(%d)::NotifyMediaChange state %d",iMediaId,iState)); |
3519 |
||
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3520 |
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
|
3521 |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3522 |
// 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
|
3523 |
__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
|
3524 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3525 |
MediaChange(); |
0 | 3526 |
|
3527 |
// 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
|
3528 |
NotifyClients(EMediaChange); |
0 | 3529 |
|
3530 |
// complete any force media change requests |
|
3531 |
iWaitMedChg.CompleteAll(KErrNone); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3532 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_NOTIFYMEDIACHANGE_EXIT, this ); |
0 | 3533 |
} |
3534 |
||
3535 |
||
3536 |
EXPORT_C void DPrimaryMediaBase::NotifyPowerDown() |
|
3537 |
/** |
|
3538 |
Called on machine power-down. Notifies all media drivers on this device. |
|
3539 |
If device is not ready then it completes current requests but leaves other outstanding requests |
|
3540 |
If ready, media driver should complete current request. |
|
3541 |
||
3542 |
*/ |
|
3543 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3544 |
OstTraceFunctionEntry1( DPRIMARYMEDIABASE_NOTIFYPOWERDOWN_ENTRY, this ); |
0 | 3545 |
__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
|
3546 |
|
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3547 |
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
|
3548 |
|
0 | 3549 |
TInt id; |
3550 |
TBool allPersistent = ETrue; |
|
3551 |
TBool allOpen = ETrue; |
|
3552 |
||
3553 |
// notify all media drivers on this device |
|
3554 |
for (id=iMediaId; id<=iLastMediaId; id++) |
|
3555 |
{ |
|
3556 |
DMedia* pM = TheMedia[id]; |
|
3557 |
DMediaDriver* pD = pM->iDriver; |
|
3558 |
||
3559 |
if ((pD) && (iState==EReady || iState==EReadPartitionInfo || iState==EOpening || iState==EPoweringUp2 || iState==ERecovering)) |
|
3560 |
pD->NotifyPowerDown(); |
|
3561 |
||
3562 |
if (pD == NULL || pD->iPhysicalDevice == NULL) |
|
3563 |
allOpen = EFalse; |
|
3564 |
else if (pD->iPhysicalDevice->Info(DPhysicalDevice::EMediaDriverPersistent, NULL) != KErrNone) |
|
3565 |
{ |
|
3566 |
// We must NOT destroy the media driver if this media is responsible for data paging as |
|
3567 |
// re-opening the media driver would involve memory allocation which might cause a deadlock |
|
3568 |
#ifdef __DEMAND_PAGING__ |
|
3569 |
__ASSERT_ALWAYS(!DataPagingDfcQ(this), LOCM_FAULT()); |
|
3570 |
#endif |
|
3571 |
allPersistent = EFalse; |
|
3572 |
} |
|
3573 |
} |
|
3574 |
||
3575 |
__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
|
3576 |
OstTraceExt2( TRACE_INTERNALS, DPRIMARYMEDIABASE_NOTIFYPOWERDOWN2, "allPersistent=%d; allOpen=%d", allPersistent, allOpen ); |
0 | 3577 |
|
3578 |
if (allPersistent && allOpen && iState == EReady) |
|
3579 |
{ |
|
3580 |
// |
|
3581 |
// The EPoweredDown state indicates that the media is powered down, but the media driver still exists. |
|
3582 |
// |
|
3583 |
// - This allows the media driver to still be accessed (ie - to determine driver capabilities) without |
|
3584 |
// the need to power up the device, which can be a lengthy operation. |
|
3585 |
// |
|
3586 |
// - NOTE : This will need re-visiting if we ever re-enable standby mode on a platform that is not capable |
|
3587 |
// of detecting door interrupts while in standby. In such a scenario, problems could occur as |
|
3588 |
// the device capabilities may change without the local media subsystem recognising. |
|
3589 |
// |
|
3590 |
iState=EPoweredDown; |
|
3591 |
} |
|
3592 |
else |
|
3593 |
{ |
|
3594 |
CloseMediaDrivers(); |
|
3595 |
SetClosed(KErrNotReady); |
|
3596 |
} |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3597 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_NOTIFYPOWERDOWN_EXIT, this ); |
0 | 3598 |
} |
3599 |
||
3600 |
||
3601 |
EXPORT_C void DPrimaryMediaBase::NotifyPsuFault(TInt anError) |
|
3602 |
/** |
|
3603 |
Closes all media drivers on this device and completes any outstanding requests with error code. |
|
3604 |
@param anError Error code to be passed on while closing media drivers and completing outstanding requests. |
|
3605 |
*/ |
|
3606 |
||
3607 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3608 |
OstTraceFunctionEntry1( DPRIMARYMEDIABASE_NOTIFYPSUFAULT_ENTRY, this ); |
0 | 3609 |
__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
|
3610 |
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
|
3611 |
|
0 | 3612 |
if (iState>=EOpening) |
3613 |
{ |
|
3614 |
CloseMediaDrivers(); |
|
3615 |
} |
|
3616 |
||
3617 |
// complete any outstanding requests with error |
|
3618 |
SetClosed(anError); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3619 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_NOTIFYPSUFAULT_EXIT, this ); |
0 | 3620 |
} |
3621 |
||
3622 |
EXPORT_C void DPrimaryMediaBase::NotifyEmergencyPowerDown() |
|
3623 |
/** |
|
3624 |
Called on emergency power down. Notifies all media drivers on this device. |
|
3625 |
If it is not in a ready state then it completes the current request but leaves other outstanding requests. |
|
3626 |
If it is ready then the media driver should complete the current request. |
|
3627 |
It closes all media drivers and notifies all clients of a power down event. |
|
3628 |
*/ |
|
3629 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3630 |
OstTraceFunctionEntry1( DPRIMARYMEDIABASE_NOTIFYEMERGENCYPOWERDOWN_ENTRY, this ); |
0 | 3631 |
__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
|
3632 |
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
|
3633 |
|
0 | 3634 |
TBool recover=EFalse; |
3635 |
if (iState==EReady && iCritical!=0) |
|
3636 |
{ |
|
3637 |
// check if emergency power recovery supported |
|
3638 |
; |
|
3639 |
} |
|
3640 |
if (recover) |
|
3641 |
{ |
|
3642 |
} |
|
3643 |
||
3644 |
// else just return KErrAbort |
|
3645 |
// notify all media drivers on this device |
|
3646 |
if (iState==EReady || iState==EOpening || iState==EPoweringUp2 || iState==ERecovering) |
|
3647 |
{ |
|
3648 |
TInt id; |
|
3649 |
for (id=iMediaId; id<=iLastMediaId; id++) |
|
3650 |
{ |
|
3651 |
DMedia* pM=TheMedia[id]; |
|
3652 |
DMediaDriver* pD=pM->iDriver; |
|
3653 |
if (pD) |
|
3654 |
pD->NotifyEmergencyPowerDown(); |
|
3655 |
} |
|
3656 |
} |
|
3657 |
||
3658 |
if (iState!=EReady) |
|
3659 |
{ |
|
3660 |
// complete current request but leave other outstanding requests |
|
3661 |
// if ready, media driver should complete current request |
|
3662 |
CompleteCurrent(KErrNotReady); |
|
3663 |
} |
|
3664 |
CloseMediaDrivers(); |
|
3665 |
SetClosed(KErrNotReady); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3666 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_NOTIFYEMERGENCYPOWERDOWN_EXIT, this ); |
0 | 3667 |
} |
3668 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3669 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3670 |
/** |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3671 |
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
|
3672 |
*/ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3673 |
void DPrimaryMediaBase::MediaChange() |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3674 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3675 |
// 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
|
3676 |
// 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
|
3677 |
TInt state = iState; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3678 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3679 |
__ASSERT_DEBUG(iBody, LOCM_FAULT()); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3680 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3681 |
#ifdef __DEMAND_PAGING__ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3682 |
iBody->iMediaChanges++; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3683 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3684 |
// 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
|
3685 |
// 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
|
3686 |
// DMediaDriver::NotifyPowerDown() should do this |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3687 |
if (DataPagingMedia(this)) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3688 |
NotifyPowerDown(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3689 |
#endif |
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 |
// complete any outstanding requests with KErrNotReady |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3692 |
// 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
|
3693 |
SetClosed(KErrNotReady); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3694 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3695 |
// close all media drivers on this device |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3696 |
if (state>=EOpening) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3697 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3698 |
CloseMediaDrivers(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3699 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3700 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3701 |
|
0 | 3702 |
EXPORT_C void DPrimaryMediaBase::NotifyMediaPresent() |
3703 |
/** |
|
3704 |
Notifies clients of a media change by calling NotifyClients ( ) function to indicate that media is present. |
|
3705 |
*/ |
|
3706 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3707 |
OstTraceFunctionEntry1( DPRIMARYMEDIABASE_NOTIFYMEDIAPRESENT_ENTRY, this ); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3708 |
__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
|
3709 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3710 |
// 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
|
3711 |
__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
|
3712 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3713 |
MediaChange(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3714 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3715 |
NotifyClients(EMediaPresent); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3716 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_NOTIFYMEDIAPRESENT_EXIT, this ); |
0 | 3717 |
} |
3718 |
||
3719 |
EXPORT_C TInt DPrimaryMediaBase::DoInCritical() |
|
3720 |
/** |
|
3721 |
Flags the media driver as entering a critical part of its processing. |
|
3722 |
||
3723 |
In this context, critical means that the driver must be allowed to complete |
|
3724 |
its current activity. |
|
3725 |
For example, a request to power down the device must be deferred until |
|
3726 |
the driver exits the critical part. |
|
3727 |
||
3728 |
@return KErrNone, if the driver has been successfully flagged as being in |
|
3729 |
a critical part; otherwise, one of the other system-wide error codes. |
|
3730 |
The default implementation just returns KErrNone and can be overridden in the derived class |
|
3731 |
@see DPrimaryMediaBase::DoEndInCritical() |
|
3732 |
*/ |
|
3733 |
||
3734 |
{ |
|
3735 |
return KErrNone; |
|
3736 |
} |
|
3737 |
||
3738 |
EXPORT_C void DPrimaryMediaBase::DoEndInCritical() |
|
3739 |
/** |
|
3740 |
Flags the media driver as leaving a critical part of its processing. |
|
3741 |
||
3742 |
Default implementation does nothing |
|
3743 |
@see DPrimaryMediaBase::DoEndInCritical() |
|
3744 |
*/ |
|
3745 |
{ |
|
3746 |
} |
|
3747 |
||
3748 |
TInt DPrimaryMediaBase::InCritical() |
|
3749 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3750 |
OstTraceFunctionEntry1( DPRIMARYMEDIABASE_INCRITICAL_ENTRY, this ); |
0 | 3751 |
if (iCritical==0) |
3752 |
{ |
|
3753 |
TInt r=DoInCritical(); |
|
3754 |
if (r!=KErrNone) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3755 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3756 |
OstTraceFunctionExitExt( DPRIMARYMEDIABASE_INCRITICAL_EXIT1, this, r ); |
0 | 3757 |
return r; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3758 |
} |
0 | 3759 |
} |
3760 |
++iCritical; |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3761 |
OstTraceFunctionExitExt( DPRIMARYMEDIABASE_INCRITICAL_EXIT2, this, KErrNone ); |
0 | 3762 |
return KErrNone; |
3763 |
} |
|
3764 |
||
3765 |
void DPrimaryMediaBase::EndInCritical() |
|
3766 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3767 |
OstTraceFunctionEntry1( DPRIMARYMEDIABASE_ENDINCRITICAL_ENTRY, this ); |
0 | 3768 |
if (--iCritical==0) |
3769 |
DoEndInCritical(); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3770 |
OstTraceFunctionExit1( DPRIMARYMEDIABASE_ENDINCRITICAL_EXIT, this ); |
0 | 3771 |
} |
3772 |
||
3773 |
EXPORT_C void DPrimaryMediaBase::DeltaCurrentConsumption(TInt /*aCurrent*/) |
|
3774 |
/** |
|
3775 |
Sets the incremental value of current consumption to aCurrent. |
|
3776 |
The default implementation does nothing . |
|
3777 |
||
3778 |
@param aCurrent Delta Current in Milliamps |
|
3779 |
*/ |
|
3780 |
{ |
|
3781 |
// default implementation |
|
3782 |
} |
|
3783 |
||
3784 |
TInt DPrimaryMediaBase::OpenMediaDriver() |
|
3785 |
// |
|
3786 |
// Synchronous open for devices with no DFC queue (e.g. IRAM) |
|
3787 |
// |
|
3788 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3789 |
OstTraceFunctionEntry1( DPRIMARYMEDIABASE_OPENMEDIADRIVER_ENTRY, this ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3790 |
|
0 | 3791 |
__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
|
3792 |
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
|
3793 |
|
0 | 3794 |
TVersion ver(KMediaDriverInterfaceMajorVersion,KMediaDriverInterfaceMinorVersion,KMediaDriverInterfaceBuildVersion); |
3795 |
||
3796 |
// Get a list of all currently loaded media drivers |
|
3797 |
// Most media drivers do not make use of the pointer iMountInfo.iInfo when |
|
3798 |
// their Validate() procedures are called from RPhysicalDeviceArray::GetDriverList(). |
|
3799 |
// However, a group of media drivers sharing the same id (passed in iDevice) may use |
|
3800 |
// the additional information pointed to by iMountInfo.iInfo to distinguish |
|
3801 |
// group members. This information is passed when the media driver is registered |
|
3802 |
// using LocDrv::RegisterMediaDevice(). |
|
3803 |
TInt r=iPhysDevArray.GetDriverList(KLitMediaDriverName,iDevice,iMountInfo.iInfo,ver); |
|
3804 |
if (r!=KErrNone) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3805 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3806 |
OstTraceFunctionExitExt( DPRIMARYMEDIABASE_OPENMEDIADRIVER_EXIT1, this, r ); |
0 | 3807 |
return r; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3808 |
} |
0 | 3809 |
// Go through them starting with highest priority |
3810 |
TInt totalPartitions=0; |
|
3811 |
TInt c=iPhysDevArray.Count(); // can't be zero |
|
3812 |
TInt i=c-1; |
|
3813 |
r=KErrNotSupported; |
|
3814 |
for (iNextMediaId=iMediaId; i>=0 && iNextMediaId<=iLastMediaId && r!=KErrNotReady; i--) |
|
3815 |
{ |
|
3816 |
DPhysicalDevice* pD=iPhysDevArray[i].iPhysicalDevice; |
|
3817 |
DMediaDriver *pM=NULL; |
|
3818 |
||
3819 |
// try to open media driver |
|
3820 |
TInt s=pD->Create( (DBase*&)pM, iMediaId, NULL, ver); |
|
3821 |
||
3822 |
__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
|
3823 |
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 | 3824 |
if (s!=KErrNone && pM) |
3825 |
{ |
|
3826 |
pM->Close(); |
|
3827 |
pM=NULL; |
|
3828 |
} |
|
3829 |
if (s==KErrNotReady) |
|
3830 |
{ |
|
3831 |
r=KErrNotReady; // If it isn't ready - nothing will open. |
|
3832 |
break; |
|
3833 |
} |
|
3834 |
if (s==KErrNoMemory) |
|
3835 |
{ |
|
3836 |
r=KErrNoMemory; // If we are out of memory, give up now |
|
3837 |
break; |
|
3838 |
} |
|
3839 |
if (s==KErrNone) |
|
3840 |
{ |
|
3841 |
// Found a media driver for this device - check for valid partitions. |
|
3842 |
DMedia* media=TheMedia[iNextMediaId]; |
|
3843 |
s=pM->PartitionInfo(media->iPartitionInfo); |
|
3844 |
if (s==KErrNone) |
|
3845 |
{ |
|
3846 |
r=KErrNone; |
|
3847 |
media->iDriver=pM; |
|
3848 |
pM->iPhysicalDevice=pD; |
|
3849 |
iPhysDevArray[i].iPhysicalDevice=NULL; // so it won't be closed when we tidy up |
|
3850 |
totalPartitions+=media->PartitionCount(); |
|
3851 |
} |
|
3852 |
else |
|
3853 |
pM->Close(); |
|
3854 |
} |
|
3855 |
} |
|
3856 |
||
3857 |
// we are now finished with media driver list |
|
3858 |
iPhysDevArray.Close(); |
|
3859 |
||
3860 |
// if driver opened OK, work out mapping of drives to partitions/media |
|
3861 |
if (r==KErrNone) |
|
3862 |
{ |
|
3863 |
TInt id=iMediaId; // start with primary media |
|
3864 |
TInt partitionsOnThisMedia=PartitionCount(); |
|
3865 |
TInt partition=0; |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3866 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3867 |
TDriveIterator driveIter; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
3868 |
for (TLocDrv* pD = driveIter.NextDrive(); pD != NULL; pD = driveIter.NextDrive()) |
0 | 3869 |
{ |
3870 |
if (pD && pD->iPrimaryMedia==this) |
|
3871 |
{ |
|
3872 |
if (totalPartitions==0) |
|
3873 |
{ |
|
3874 |
pD->iMedia=NULL; |
|
3875 |
continue; |
|
3876 |
} |
|
3877 |
if (partition==partitionsOnThisMedia) |
|
3878 |
{ |
|
3879 |
id++; |
|
3880 |
partition=0; |
|
3881 |
partitionsOnThisMedia=TheMedia[id]->PartitionCount(); |
|
3882 |
} |
|
3883 |
pD->iMedia=TheMedia[id]; |
|
3884 |
pD->iPartitionNumber=partition; |
|
3885 |
memcpy(pD, pD->iMedia->iPartitionInfo.iEntry+partition, sizeof(TPartitionEntry)); |
|
3886 |
partition++; |
|
3887 |
totalPartitions--; |
|
3888 |
} |
|
3889 |
} |
|
3890 |
} |
|
3891 |
||
3892 |
__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
|
3893 |
OstTraceFunctionExitExt( DPRIMARYMEDIABASE_OPENMEDIADRIVER_EXIT2, this, r ); |
0 | 3894 |
return r; |
3895 |
} |
|
3896 |
||
3897 |
#ifdef __DEMAND_PAGING__ |
|
3898 |
// RequestCountInc() |
|
3899 |
// |
|
3900 |
// Counts the number of outstanding requests |
|
3901 |
// For data-paging media, calls DPagingDevice::NotifyBusy() when count goes positive |
|
3902 |
// |
|
3903 |
void DPrimaryMediaBase::RequestCountInc() |
|
3904 |
{ |
|
3905 |
__ASSERT_DEBUG(iBody, LOCM_FAULT()); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
3906 |
if (iBody->iPagingDevice) |
0 | 3907 |
{ |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
3908 |
NFastMutex* lock = iBody->iPagingDevice->NotificationLock(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
3909 |
NKern::FMWait(lock); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
3910 |
TInt oldVal = iBody->iRequestCount++; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
3911 |
//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
|
3912 |
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
|
3913 |
if (oldVal == 0) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
3914 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
3915 |
//Kern::Printf("RCINC: NotifyBusy()"); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
3916 |
iBody->iPagingDevice->NotifyBusy(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
3917 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
3918 |
NKern::FMSignal(lock); |
0 | 3919 |
} |
3920 |
} |
|
3921 |
||
3922 |
// RequestCountDec() |
|
3923 |
// |
|
3924 |
// Counts the number of outstanding requests |
|
3925 |
// For data-paging media, calls DPagingDevice::NotifyIdle() when count reaches zero |
|
3926 |
// |
|
3927 |
void DPrimaryMediaBase::RequestCountDec() |
|
3928 |
{ |
|
3929 |
__ASSERT_DEBUG(iBody, LOCM_FAULT()); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
3930 |
if (iBody->iPagingDevice) |
0 | 3931 |
{ |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
3932 |
NFastMutex* lock = iBody->iPagingDevice->NotificationLock(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
3933 |
NKern::FMWait(lock); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
3934 |
TInt oldVal = iBody->iRequestCount--; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
3935 |
//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
|
3936 |
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
|
3937 |
if (oldVal == 1) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
3938 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
3939 |
//Kern::Printf("RCDEC: NotifyIdle()"); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
3940 |
iBody->iPagingDevice->NotifyIdle(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
3941 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
3942 |
NKern::FMSignal(lock); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
3943 |
__ASSERT_DEBUG(iBody->iRequestCount >= 0, LOCM_FAULT()); |
0 | 3944 |
} |
3945 |
} |
|
3946 |
#endif // __DEMAND_PAGING__ |
|
3947 |
||
3948 |
TPartitionInfo::TPartitionInfo() |
|
3949 |
// |
|
3950 |
// Constructor |
|
3951 |
// |
|
3952 |
{ |
|
3953 |
memclr(this, sizeof(TPartitionInfo)); |
|
3954 |
} |
|
3955 |
||
3956 |
#ifdef __DEMAND_PAGING__ |
|
3957 |
||
3958 |
void pageInDfc(TAny* aPtr) |
|
3959 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3960 |
OstTraceFunctionEntry0( _PAGEINDFC_ENTRY ); |
0 | 3961 |
__KTRACE_OPT2(KLOCDRV,KLOCDPAGING,Kern::Printf("pageInDfc")); |
3962 |
DPrimaryMediaBase* primaryMedia=(DPrimaryMediaBase*)aPtr; |
|
3963 |
__ASSERT_ALWAYS(primaryMedia && primaryMedia->iPagingMedia && primaryMedia->iBody->iPagingDevice,LOCM_FAULT()); |
|
3964 |
DMediaPagingDevice* pagingdevice=primaryMedia->iBody->iPagingDevice; |
|
3965 |
||
3966 |
TLocDrvRequest* m = (TLocDrvRequest*) pagingdevice->iMainQ.iMessage; |
|
3967 |
pagingdevice->iMainQ.iMessage = NULL; |
|
3968 |
||
3969 |
#ifdef __CONCURRENT_PAGING_INSTRUMENTATION__ |
|
3970 |
if (!m) |
|
3971 |
__e32_atomic_add_ord8(&pagingdevice->iROMStats.iTotalRunDry, 1); |
|
3972 |
#endif |
|
3973 |
||
3974 |
#ifdef __CONCURRENT_PAGING_INSTRUMENTATION__ |
|
3975 |
TInt countROM=0; |
|
3976 |
TInt countCode=0; |
|
3977 |
#endif |
|
3978 |
||
3979 |
for ( ; m != NULL; m = (TLocDrvRequest*) pagingdevice->iMainQ.Poll()) |
|
3980 |
{ |
|
3981 |
__ASSERT_ALWAYS(DMediaPagingDevice::PagingRequest(*m), LOCM_FAULT()); |
|
3982 |
||
3983 |
#ifdef __CONCURRENT_PAGING_INSTRUMENTATION__ |
|
3984 |
(m->iValue == DMediaPagingDevice::ERomPageInRequest)?(countROM++):(countCode++); |
|
3985 |
#endif |
|
3986 |
__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
|
3987 |
OstTraceDefExt2(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, PAGEINDFC2, "process request=0x%08x; last in queue=0x%08x",(TUint) m, (TUint) pagingdevice->iMainQ.Last()); |
0 | 3988 |
|
3989 |
primaryMedia->HandleMsg(*m); |
|
3990 |
} |
|
3991 |
||
3992 |
#ifdef __CONCURRENT_PAGING_INSTRUMENTATION__ |
|
3993 |
NKern::FMWait(&pagingdevice->iInstrumentationLock); |
|
3994 |
if (pagingdevice->iROMStats.iMaxReqsInPending<countROM) |
|
3995 |
pagingdevice->iROMStats.iMaxReqsInPending=countROM; |
|
3996 |
if (pagingdevice->iCodeStats.iMaxReqsInPending<countCode) |
|
3997 |
pagingdevice->iCodeStats.iMaxReqsInPending=countCode; |
|
3998 |
NKern::FMSignal(&pagingdevice->iInstrumentationLock); |
|
3999 |
#endif |
|
4000 |
||
4001 |
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
|
4002 |
OstTraceFunctionExit0( _PAGEINDFC_EXIT ); |
0 | 4003 |
} |
4004 |
||
4005 |
DMediaPagingDevice::DMediaPagingDevice(DPrimaryMediaBase* aPtr) |
|
4006 |
: iMainQ(pageInDfc, aPtr, NULL, KMaxDfcPriority), |
|
4007 |
iDeferredQ(NULL, NULL, NULL, 0), // callback never used |
|
4008 |
iEmptyingQ(NULL), |
|
4009 |
iInstrumentationLock() |
|
4010 |
#ifdef __CONCURRENT_PAGING_INSTRUMENTATION__ |
|
4011 |
,iServicingROM(NULL), iServicingCode(NULL) |
|
4012 |
#endif |
|
4013 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4014 |
OstTraceFunctionEntry1( DMEDIAPAGINGDEVICE_DMEDIAPAGINGDEVICE_CONSTRUCTOR_ENTRY, this ); |
0 | 4015 |
iPrimaryMedia = aPtr; |
4016 |
if (iPrimaryMedia->iDfcQ) // media driver has its own thread |
|
4017 |
{ |
|
4018 |
iMainQ.SetDfcQ(iPrimaryMedia->iDfcQ); |
|
4019 |
} |
|
4020 |
#ifdef __CONCURRENT_PAGING_INSTRUMENTATION__ |
|
4021 |
memclr((TAny*)&iROMStats,sizeof(SMediaROMPagingConcurrencyInfo)+sizeof(SMediaCodePagingConcurrencyInfo)); |
|
4022 |
#endif |
|
4023 |
#ifdef __DEMAND_PAGING_BENCHMARKS__ |
|
4024 |
iROMBenchmarkData.iCount=iROMBenchmarkData.iTotalTime=iROMBenchmarkData.iMaxTime=0; |
|
4025 |
iROMBenchmarkData.iMinTime = KMaxTInt; |
|
4026 |
iCodeBenchmarkData.iCount=iCodeBenchmarkData.iTotalTime=iCodeBenchmarkData.iMaxTime=0; |
|
4027 |
iCodeBenchmarkData.iMinTime = KMaxTInt; |
|
4028 |
iDataInBenchmarkData.iCount=iDataInBenchmarkData.iTotalTime=iDataInBenchmarkData.iMaxTime=0; |
|
4029 |
iDataInBenchmarkData.iMinTime = KMaxTInt; |
|
4030 |
iDataOutBenchmarkData.iCount=iDataOutBenchmarkData.iTotalTime=iDataOutBenchmarkData.iMaxTime=0; |
|
4031 |
iDataOutBenchmarkData.iMinTime = KMaxTInt; |
|
4032 |
#endif |
|
4033 |
||
4034 |
iMainQ.Receive(); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4035 |
OstTraceFunctionExit1( DMEDIAPAGINGDEVICE_DMEDIAPAGINGDEVICE_CONSTRUCTOR_EXIT, this ); |
0 | 4036 |
} |
4037 |
||
4038 |
DMediaPagingDevice::~DMediaPagingDevice() |
|
4039 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4040 |
OstTraceFunctionEntry1( DMEDIAPAGINGDEVICE_DMEDIAPAGINGDEVICE_DESTRUCTOR_ENTRY, this ); |
0 | 4041 |
|
4042 |
if (iMountInfoDataLock) |
|
4043 |
ThePinObjectAllocator->ReleasePinObject((DPinObjectAllocator::SVirtualPinContainer*) iMountInfoDataLock); |
|
4044 |
||
4045 |
if (iMountInfoDescHdrLock) |
|
4046 |
ThePinObjectAllocator->ReleasePinObject((DPinObjectAllocator::SVirtualPinContainer*) iMountInfoDescHdrLock); |
|
4047 |
||
4048 |
if (iMountInfoDescLenLock) |
|
4049 |
ThePinObjectAllocator->ReleasePinObject((DPinObjectAllocator::SVirtualPinContainer*) iMountInfoDescLenLock); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4050 |
OstTraceFunctionExit1( DMEDIAPAGINGDEVICE_DMEDIAPAGINGDEVICE_DESTRUCTOR_EXIT, this ); |
0 | 4051 |
} |
4052 |
||
4053 |
||
4054 |
void DMediaPagingDevice::SendToMainQueueDfcAndBlock(TThreadMessage* aMsg) |
|
4055 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4056 |
OstTraceFunctionEntryExt( DMEDIAPAGINGDEVICE_SENDTOMAINQUEUEDFCANDBLOCK_ENTRY, this ); |
0 | 4057 |
__KTRACE_OPT2(KLOCDRV,KLOCDPAGING,Kern::Printf("Send request 0x%08x to main queue",aMsg)); |
4058 |
__ASSERT_ALWAYS(aMsg->iState==TMessageBase::EFree,LOCM_FAULT()); // check that message was previously completed or never queued |
|
4059 |
||
4060 |
// if drive supports DMA, turn on Physical memory flag & sync memory |
|
4061 |
TLocDrvRequest& m=*(TLocDrvRequest*)(aMsg); |
|
4062 |
||
4063 |
TLinAddr addr = (TLinAddr) m.RemoteDes(); |
|
4064 |
TInt len = I64LOW(m.Length()); |
|
4065 |
||
4066 |
TBool needSyncAfterRead = EFalse; |
|
4067 |
if (m.Drive()->iDmaHelper) |
|
4068 |
{ |
|
4069 |
m.Flags() |= TLocDrvRequest::EPhysAddr; |
|
4070 |
if (m.Id() == DLocalDrive::EWrite) |
|
4071 |
{ |
|
4072 |
Cache::SyncMemoryBeforeDmaWrite(addr, len); |
|
4073 |
} |
|
4074 |
else |
|
4075 |
{ |
|
4076 |
Cache::SyncMemoryBeforeDmaRead(addr, len); |
|
4077 |
needSyncAfterRead = ETrue; |
|
4078 |
} |
|
4079 |
} |
|
4080 |
||
4081 |
// Count the number of outstanding requests if this is the data-paging media, so that |
|
4082 |
// we can call DPagingDevice::NotifyBusy() / DPagingDevice::NotifyIdle() |
|
4083 |
if ((m.Flags() & TLocDrvRequest::EBackgroundPaging) == 0) |
|
4084 |
iPrimaryMedia->RequestCountInc(); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4085 |
|
0 | 4086 |
aMsg->SendReceive(&iMainQ); |
4087 |
||
4088 |
#ifdef __DEMAND_PAGING__ |
|
4089 |
if ((m.Flags() & TLocDrvRequest::EBackgroundPaging) == 0) |
|
4090 |
iPrimaryMedia->RequestCountDec(); |
|
4091 |
#endif |
|
4092 |
||
4093 |
if (needSyncAfterRead) |
|
4094 |
{ |
|
4095 |
Cache::SyncMemoryAfterDmaRead(addr, len); |
|
4096 |
} |
|
4097 |
||
4098 |
||
4099 |
// come back here when request is completed |
|
4100 |
__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
|
4101 |
OstTraceFunctionExit1( DMEDIAPAGINGDEVICE_SENDTOMAINQUEUEDFCANDBLOCK_EXIT, this ); |
0 | 4102 |
} |
4103 |
||
4104 |
void DMediaPagingDevice::SendToDeferredQ(TThreadMessage* aMsg) |
|
4105 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4106 |
OstTraceFunctionEntryExt( DMEDIAPAGINGDEVICE_SENDTODEFERREDQ_ENTRY, this ); |
0 | 4107 |
// This queue is only accessed from MD thread |
4108 |
__ASSERT_ALWAYS(aMsg->iState==TMessageBase::EAccepted,LOCM_FAULT()); // check that message was previously dequeued |
|
4109 |
#ifdef BTRACE_PAGING_MEDIA |
|
4110 |
if(iEmptyingQ&DMediaPagingDevice::EDeferredQ) // already deferring |
|
4111 |
BTraceContext8(BTrace::EPagingMedia,BTrace::EPagingMediaLocMedPageInReDeferred,aMsg,aMsg->iValue); |
|
4112 |
else |
|
4113 |
BTraceContext8(BTrace::EPagingMedia,BTrace::EPagingMediaLocMedPageInDeferred,aMsg,aMsg->iValue); |
|
4114 |
#endif |
|
4115 |
||
4116 |
aMsg->Forward(&iDeferredQ, EFalse); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4117 |
OstTraceFunctionExit1( DMEDIAPAGINGDEVICE_SENDTODEFERREDQ_EXIT, this ); |
0 | 4118 |
} |
4119 |
||
4120 |
||
4121 |
void DMediaPagingDevice::CompleteRequest(TThreadMessage* aMsg, TInt aResult) |
|
4122 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4123 |
OstTraceFunctionEntryExt( DMEDIAPAGINGDEVICE_COMPLETEREQUEST_ENTRY, this ); |
0 | 4124 |
__KTRACE_OPT2(KLOCDRV,KLOCDPAGING,Kern::Printf("DMediaPagingDevice::CompleteRequest, request 0x%08x result %d", aMsg, aResult)); |
4125 |
__ASSERT_DEBUG(aMsg->iState==TMessageBase::EAccepted,LOCM_FAULT()); |
|
4126 |
||
4127 |
#ifdef BTRACE_PAGING_MEDIA |
|
4128 |
BTraceContext12(BTrace::EPagingMedia,BTrace::EPagingMediaLocMedPageInPagedIn,aMsg,aResult,aMsg->iValue); |
|
4129 |
#endif |
|
4130 |
||
4131 |
iPrimaryMedia->CompleteRequest(*((TLocDrvRequest*) aMsg), aResult); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4132 |
OstTraceFunctionExit1( DMEDIAPAGINGDEVICE_COMPLETEREQUEST_EXIT, this ); |
0 | 4133 |
} |
4134 |
||
4135 |
TInt DMediaPagingDevice::Read(TThreadMessage* aReq,TLinAddr aBuffer,TUint aOffset,TUint aSize,TInt aDrvNumber) |
|
4136 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4137 |
OstTraceFunctionEntry1( DMEDIAPAGINGDEVICE_READ_ENTRY, this ); |
0 | 4138 |
__ASSERT_ALWAYS(NKern::CurrentThread()!=iPrimaryMedia->iDfcQ->iThread,LOCM_FAULT()); // that would lock up the system, thus better die now |
4139 |
__ASSERT_ALWAYS(aReq,LOCM_FAULT()); |
|
4140 |
__ASSERT_CRITICAL |
|
4141 |
||
4142 |
#ifdef __DEMAND_PAGING_BENCHMARKS__ |
|
4143 |
TUint32 bmStart = NKern::FastCounter(); |
|
4144 |
#endif |
|
4145 |
||
4146 |
#ifdef __CONCURRENT_PAGING_INSTRUMENTATION__ |
|
4147 |
TUint8* servicingCount; |
|
4148 |
NKern::FMWait(&iInstrumentationLock); |
|
4149 |
if(aDrvNumber == EDriveRomPaging) // ROM paging |
|
4150 |
{ |
|
4151 |
servicingCount = &iServicingROM; |
|
4152 |
if(iServicingROM) |
|
4153 |
iROMStats.iTotalConcurrentReqs++; |
|
4154 |
if(!(++iServicingROM)) |
|
4155 |
{ |
|
4156 |
iServicingROM=1; // overflow... |
|
4157 |
iROMStats.iTotalConcurrentReqs=0; // ...reset this |
|
4158 |
} |
|
4159 |
TBool empty = iMainQ.iReady && iDeferredQ.iQ.IsEmpty(); |
|
4160 |
if(!empty) |
|
4161 |
iROMStats.iTotalReqIssuedNonEmptyQ++; |
|
4162 |
} |
|
4163 |
else if (aDrvNumber == EDriveDataPaging) // Data paging |
|
4164 |
{ |
|
4165 |
servicingCount = &iServicingDataIn; |
|
4166 |
if(iServicingDataIn) |
|
4167 |
iDataStats.iTotalConcurrentReqs++; |
|
4168 |
if(!(++iServicingDataIn)) |
|
4169 |
{ |
|
4170 |
iServicingDataIn=1; // overflow... |
|
4171 |
iDataStats.iTotalConcurrentReqs=0; // ...reset this |
|
4172 |
} |
|
4173 |
TBool empty = iMainQ.iReady && iDeferredQ.iQ.IsEmpty(); |
|
4174 |
if(!empty) |
|
4175 |
iDataStats.iTotalReqIssuedNonEmptyQ++; |
|
4176 |
} |
|
4177 |
else |
|
4178 |
{ |
|
4179 |
servicingCount = &iServicingCode; |
|
4180 |
if(iServicingCode) |
|
4181 |
iCodeStats.iTotalConcurrentReqs++; |
|
4182 |
if(!(++iServicingCode)) |
|
4183 |
{ |
|
4184 |
iServicingCode=1; // overflow... |
|
4185 |
iCodeStats.iTotalConcurrentReqs=0; // ...reset this |
|
4186 |
} |
|
4187 |
TBool empty = iMainQ.iReady && iDeferredQ.iQ.IsEmpty(); |
|
4188 |
if(!empty) |
|
4189 |
iCodeStats.iTotalReqIssuedNonEmptyQ++; |
|
4190 |
} |
|
4191 |
NKern::FMSignal(&iInstrumentationLock); |
|
4192 |
#endif |
|
4193 |
||
4194 |
TUint offset=aOffset<<iReadUnitShift; |
|
4195 |
TUint size=aSize<<iReadUnitShift; |
|
4196 |
||
4197 |
#ifdef BTRACE_PAGING_MEDIA |
|
4198 |
TInt buf[3]; |
|
4199 |
buf[0]=size; // page in request length |
|
4200 |
buf[1]=aDrvNumber; // local drive number (-1 if ROM) |
|
4201 |
buf[2]=(TInt)aReq; // address of request object |
|
4202 |
BTraceContextN(BTrace::EPagingMedia,BTrace::EPagingMediaLocMedPageInBegin,aBuffer,offset,buf,sizeof(buf)); |
|
4203 |
#endif |
|
4204 |
||
4205 |
__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
|
4206 |
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 | 4207 |
|
4208 |
// no DFCQ, media driver executes in the context of calling thread |
|
4209 |
if (!iPrimaryMedia->iDfcQ) |
|
4210 |
{ |
|
4211 |
LOCM_FAULT(); // don't allow paging |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4212 |
OstTraceFunctionExitExt( DMEDIAPAGINGDEVICE_READ_EXIT, this, KErrNone ); |
0 | 4213 |
return KErrNone; // keep compiler happy |
4214 |
} |
|
4215 |
||
4216 |
||
4217 |
TLocDrvRequest& m=*(TLocDrvRequest*)(aReq); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4218 |
|
0 | 4219 |
|
4220 |
#ifdef __DEMAND_PAGING_BENCHMARKS__ |
|
4221 |
SPagingBenchmarkInfo* info = NULL; |
|
4222 |
#endif |
|
4223 |
||
4224 |
||
4225 |
// Read from the media and allow for retries in the unlikely event of an error. |
|
4226 |
const TInt KPageInRetries = 5; |
|
4227 |
TInt retVal = KErrGeneral; |
|
4228 |
for (TInt i=0; retVal != KErrNone && i < KPageInRetries; i++) |
|
4229 |
{ |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4230 |
m.Flags() = TLocDrvRequest::EKernelBuffer | TLocDrvRequest::EPaging; |
0 | 4231 |
TLocDrv* pL=NULL; |
4232 |
if(aDrvNumber == EDriveRomPaging) // ROM paging |
|
4233 |
{ |
|
4234 |
m.Id() = DMediaPagingDevice::ERomPageInRequest; |
|
4235 |
if (iRomPagingDriveNumber == KErrNotFound) |
|
4236 |
{ |
|
4237 |
// ROM partition has not been reported by the media driver |
|
4238 |
// it is assumed that the media driver will adjust the request accordingly |
|
4239 |
m.Flags() |= TLocDrvRequest::EAdjusted; |
|
4240 |
// Use a media drive number so the request reaches the correct media... |
|
4241 |
m.Drive() = TheDrives[iFirstLocalDriveNumber]; |
|
4242 |
} |
|
4243 |
else |
|
4244 |
{ |
|
4245 |
//ROM partition has been reported |
|
4246 |
//Set drive for use with CheckAndAdjustForPartition |
|
4247 |
m.Drive() = TheDrives[iRomPagingDriveNumber]; |
|
4248 |
} |
|
4249 |
#ifdef __DEMAND_PAGING_BENCHMARKS__ |
|
4250 |
__e32_atomic_add_ord32(&iMediaPagingInfo.iRomPageInCount, (TUint) 1); |
|
4251 |
info = &iROMBenchmarkData; |
|
4252 |
#endif |
|
4253 |
} |
|
4254 |
else if(aDrvNumber == EDriveDataPaging) // Data paging |
|
4255 |
{ |
|
4256 |
m.Id() = DLocalDrive::ERead; |
|
4257 |
m.Flags() |= TLocDrvRequest::EDataPaging; |
|
4258 |
m.Drive() = TheDrives[iDataPagingDriveNumber]; |
|
4259 |
#ifdef __DEMAND_PAGING_BENCHMARKS__ |
|
4260 |
__e32_atomic_add_ord32(&iMediaPagingInfo.iDataPageInCount, (TUint) 1); |
|
4261 |
info = &iDataInBenchmarkData; |
|
4262 |
#endif |
|
4263 |
} |
|
4264 |
else if ((aDrvNumber >=0) && (aDrvNumber<KMaxLocalDrives)) // Code paging |
|
4265 |
{ |
|
4266 |
m.Id() = DMediaPagingDevice::ECodePageInRequest; |
|
4267 |
m.Flags() |= TLocDrvRequest::ECodePaging; |
|
4268 |
pL=TheDrives[aDrvNumber]; |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4269 |
__ASSERT_DEBUG(pL && TDriveIterator::GetDrive(aDrvNumber, iPrimaryMedia) ,LOCM_FAULT()); // valid drive number? |
0 | 4270 |
m.Drive()=pL; |
4271 |
#ifdef __DEMAND_PAGING_BENCHMARKS__ |
|
4272 |
__e32_atomic_add_ord32(&iMediaPagingInfo.iCodePageInCount, (TUint) 1); |
|
4273 |
info = &iCodeBenchmarkData; |
|
4274 |
#endif |
|
4275 |
} |
|
4276 |
else |
|
4277 |
LOCM_FAULT(); // invalid drive number |
|
4278 |
||
4279 |
m.RemoteThread()=NULL; |
|
4280 |
m.Pos()=offset; |
|
4281 |
m.Length()=Int64(size); |
|
4282 |
m.RemoteDes()=(TAny*)aBuffer; |
|
4283 |
m.RemoteDesOffset()=0; // pre-aligned |
|
4284 |
m.DriverFlags()=0; |
|
4285 |
__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())); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4286 |
OstTraceDefExt4(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DMEDIAPAGINGDEVICE_READ2, "reqId=%d; position=0x%lx; length=0x%x; remote Des=0x%x", (TInt) m.Id(), (TUint) m.Pos(), (TUint) m.Length(), (TUint) m.RemoteDes()); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4287 |
|
0 | 4288 |
__ASSERT_DEBUG(iPrimaryMedia->iBody, LOCM_FAULT()); |
4289 |
TInt mediaChanges = iPrimaryMedia->iBody->iMediaChanges; |
|
4290 |
||
4291 |
SendToMainQueueDfcAndBlock(&m); // queues request, sets and opens client thread, queues dfc and blocks thread until request is completed |
|
4292 |
retVal = m.iValue; |
|
4293 |
||
4294 |
#ifdef __DEBUG_DEMAND_PAGING__ |
|
4295 |
if (retVal != KErrNone) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4296 |
{ |
0 | 4297 |
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
|
4298 |
} |
0 | 4299 |
#endif |
4300 |
||
4301 |
// reset retry count if there's ben a media change |
|
4302 |
if (retVal != KErrNone && mediaChanges != iPrimaryMedia->iBody->iMediaChanges) |
|
4303 |
i = 0; |
|
4304 |
} // for () |
|
4305 |
||
4306 |
#ifdef __CONCURRENT_PAGING_INSTRUMENTATION__ |
|
4307 |
NKern::FMWait(&iInstrumentationLock); |
|
4308 |
if (*servicingCount) |
|
4309 |
(*servicingCount)--; |
|
4310 |
NKern::FMSignal(&iInstrumentationLock); |
|
4311 |
#endif |
|
4312 |
||
4313 |
#ifdef __DEMAND_PAGING_BENCHMARKS__ |
|
4314 |
TUint32 bmEnd = NKern::FastCounter(); |
|
4315 |
++info->iCount; |
|
4316 |
#if !defined(HIGHIGH_RES_TIMER) || defined(HIGH_RES_TIMER_COUNTS_UP) |
|
4317 |
TInt64 elapsed=bmEnd-bmStart; |
|
4318 |
#else |
|
4319 |
TInt64 elapsed=bmStart-bmEnd; |
|
4320 |
#endif |
|
4321 |
info->iTotalTime += elapsed; |
|
4322 |
if (elapsed > info->iMaxTime) |
|
4323 |
info->iMaxTime = elapsed; |
|
4324 |
if (elapsed < info->iMinTime) |
|
4325 |
info->iMinTime = elapsed; |
|
4326 |
#endif // __DEMAND_PAGING_BENCHMARKS__ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4327 |
OstTraceFunctionExitExt( DMEDIAPAGINGDEVICE_READ_EXIT2, this, retVal ); |
0 | 4328 |
return retVal; |
4329 |
} |
|
4330 |
||
4331 |
TInt DMediaPagingDevice::Write(TThreadMessage* aReq,TLinAddr aBuffer,TUint aOffset,TUint aSize,TBool aBackground) |
|
4332 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4333 |
OstTraceFunctionEntry1( DMEDIAPAGINGDEVICE_WRITE_ENTRY, this ); |
0 | 4334 |
__ASSERT_ALWAYS(NKern::CurrentThread()!=iPrimaryMedia->iDfcQ->iThread,LOCM_FAULT()); // that would lock up the system, thus better die now |
4335 |
__ASSERT_ALWAYS(aReq,LOCM_FAULT()); |
|
4336 |
__ASSERT_CRITICAL |
|
4337 |
||
4338 |
#ifdef __DEMAND_PAGING_BENCHMARKS__ |
|
4339 |
TUint32 bmStart = NKern::FastCounter(); |
|
4340 |
#endif |
|
4341 |
||
4342 |
#ifdef __CONCURRENT_PAGING_INSTRUMENTATION__ |
|
4343 |
NKern::FMWait(&iInstrumentationLock); |
|
4344 |
if(iServicingDataOut) |
|
4345 |
iDataStats.iTotalConcurrentReqs++; |
|
4346 |
if(!(++iServicingDataOut)) |
|
4347 |
{ |
|
4348 |
iServicingDataOut=1; // overflow... |
|
4349 |
iDataStats.iTotalConcurrentReqs=0; // ...reset this |
|
4350 |
} |
|
4351 |
TBool empty = iMainQ.iReady && iDeferredQ.iQ.IsEmpty(); |
|
4352 |
if(!empty) |
|
4353 |
iDataStats.iTotalReqIssuedNonEmptyQ++; |
|
4354 |
NKern::FMSignal(&iInstrumentationLock); |
|
4355 |
#endif |
|
4356 |
||
4357 |
TUint offset=aOffset<<iReadUnitShift; |
|
4358 |
TUint size=aSize<<iReadUnitShift; |
|
4359 |
||
4360 |
#ifdef BTRACE_PAGING_MEDIA |
|
4361 |
TInt buf[2]; |
|
4362 |
buf[0] = size; // page out request length |
|
4363 |
buf[1] = (TInt)aReq; // address of request object |
|
4364 |
BTraceContextN(BTrace::EPagingMedia,BTrace::EPagingMediaLocMedPageOutBegin,aBuffer,offset,buf,sizeof(buf)); |
|
4365 |
#endif |
|
4366 |
||
4367 |
__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
|
4368 |
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 | 4369 |
|
4370 |
// no DFCQ, media driver executes in the context of calling thread |
|
4371 |
if (!iPrimaryMedia->iDfcQ) |
|
4372 |
{ |
|
4373 |
LOCM_FAULT(); // don't allow paging |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4374 |
OstTraceFunctionExitExt( DMEDIAPAGINGDEVICE_WRITE_EXIT, this, KErrNone ); |
0 | 4375 |
return KErrNone; // keep compiler happy |
4376 |
} |
|
4377 |
||
4378 |
||
4379 |
TLocDrvRequest& m=*(TLocDrvRequest*)(aReq); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4380 |
|
0 | 4381 |
#ifdef __DEMAND_PAGING_BENCHMARKS__ |
4382 |
__e32_atomic_add_ord32(&iMediaPagingInfo.iDataPageOutCount, (TUint) 1); |
|
4383 |
if (aBackground) |
|
4384 |
__e32_atomic_add_ord32(&iMediaPagingInfo.iDataPageOutBackgroundCount, (TUint) 1); |
|
4385 |
#endif |
|
4386 |
||
4387 |
// Write to the media and allow for retries in the unlikely event of an error. |
|
4388 |
const TInt KPageOutRetries = 5; |
|
4389 |
TInt retVal = KErrGeneral; |
|
4390 |
for (TInt i=0; retVal != KErrNone && i < KPageOutRetries; i++) |
|
4391 |
{ |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4392 |
m.Flags() = TLocDrvRequest::EKernelBuffer | TLocDrvRequest::EPaging | TLocDrvRequest::EDataPaging | (aBackground ? TLocDrvRequest::EBackgroundPaging : 0); |
0 | 4393 |
|
4394 |
m.Id() = DLocalDrive::EWrite; |
|
4395 |
m.Drive() = TheDrives[iDataPagingDriveNumber]; |
|
4396 |
||
4397 |
m.RemoteThread()=NULL; |
|
4398 |
m.Pos()=offset; |
|
4399 |
m.Length()=Int64(size); |
|
4400 |
m.RemoteDes()=(TAny*)aBuffer; |
|
4401 |
m.RemoteDesOffset()=0; // pre-aligned |
|
4402 |
m.DriverFlags()=0; |
|
4403 |
__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())); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4404 |
OstTraceDefExt4(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DMEDIAPAGINGDEVICE_WRITE2, "reqId=%d; position=0x%lx; length=0x%lx; remote Des=0x%x", (TInt) m.Id(), (TUint) m.Pos(), (TUint) m.Length(), (TUint) m.RemoteDes()); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4405 |
|
0 | 4406 |
__ASSERT_DEBUG(iPrimaryMedia->iBody, LOCM_FAULT()); |
4407 |
TInt mediaChanges = iPrimaryMedia->iBody->iMediaChanges; |
|
4408 |
||
4409 |
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
|
4410 |
|
0 | 4411 |
retVal = m.iValue; |
4412 |
||
4413 |
#ifdef __DEBUG_DEMAND_PAGING__ |
|
4414 |
if (retVal != KErrNone) |
|
4415 |
Kern::Printf("Pagout Failure %d, retry %d", retVal, i); |
|
4416 |
#endif |
|
4417 |
// reset retry count if there's ben a media change |
|
4418 |
if (retVal != KErrNone && mediaChanges != iPrimaryMedia->iBody->iMediaChanges) |
|
4419 |
i = 0; |
|
4420 |
} // for () |
|
4421 |
||
4422 |
#ifdef __CONCURRENT_PAGING_INSTRUMENTATION__ |
|
4423 |
NKern::FMWait(&iInstrumentationLock); |
|
4424 |
if (iServicingDataOut) |
|
4425 |
iServicingDataOut--; |
|
4426 |
NKern::FMSignal(&iInstrumentationLock); |
|
4427 |
#endif |
|
4428 |
||
4429 |
#ifdef __DEMAND_PAGING_BENCHMARKS__ |
|
4430 |
SPagingBenchmarkInfo& info = iDataOutBenchmarkData; |
|
4431 |
TUint32 bmEnd = NKern::FastCounter(); |
|
4432 |
++info.iCount; |
|
4433 |
#if !defined(HIGHIGH_RES_TIMER) || defined(HIGH_RES_TIMER_COUNTS_UP) |
|
4434 |
TInt64 elapsed=bmEnd-bmStart; |
|
4435 |
#else |
|
4436 |
TInt64 elapsed=bmStart-bmEnd; |
|
4437 |
#endif |
|
4438 |
info.iTotalTime += elapsed; |
|
4439 |
if (elapsed > info.iMaxTime) |
|
4440 |
info.iMaxTime = elapsed; |
|
4441 |
if (elapsed < info.iMinTime) |
|
4442 |
info.iMinTime = elapsed; |
|
4443 |
#endif // __DEMAND_PAGING_BENCHMARKS__ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4444 |
|
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4445 |
OstTraceFunctionExitExt( DMEDIAPAGINGDEVICE_WRITE_EXIT2, this, retVal ); |
0 | 4446 |
return retVal; |
4447 |
} |
|
4448 |
||
4449 |
||
4450 |
TInt DMediaPagingDevice::DeleteNotify(TThreadMessage* aReq,TUint aOffset,TUint aSize) |
|
4451 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4452 |
OstTraceFunctionEntry1( DMEDIAPAGINGDEVICE_DELETENOTIFY_ENTRY, this ); |
0 | 4453 |
if (iDeleteNotifyNotSupported) |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4454 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4455 |
OstTraceFunctionExitExt( DMEDIAPAGINGDEVICE_DELETENOTIFY_EXIT1, this, KErrNotSupported ); |
0 | 4456 |
return KErrNotSupported; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4457 |
} |
0 | 4458 |
|
4459 |
__ASSERT_ALWAYS(NKern::CurrentThread()!=iPrimaryMedia->iDfcQ->iThread,LOCM_FAULT()); // that would lock up the system, thus better die now |
|
4460 |
__ASSERT_ALWAYS(aReq,LOCM_FAULT()); |
|
4461 |
__ASSERT_ALWAYS(DataPagingDfcQ(iPrimaryMedia),LOCM_FAULT()); |
|
4462 |
__ASSERT_CRITICAL |
|
4463 |
||
4464 |
TUint offset = aOffset<<iReadUnitShift; |
|
4465 |
TUint size = aSize<<iReadUnitShift; |
|
4466 |
||
4467 |
#ifdef BTRACE_PAGING_MEDIA |
|
4468 |
TInt buf[2]; |
|
4469 |
buf[0] = size; // delete notify length |
|
4470 |
buf[1] = (TInt)aReq; // address of request object |
|
4471 |
BTraceContextN(BTrace::EPagingMedia,BTrace::EPagingMediaLocMedDeleteNotifyBegin,NULL,offset,buf,sizeof(buf)); |
|
4472 |
#endif |
|
4473 |
||
4474 |
__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
|
4475 |
OstTraceDefExt3(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DMEDIAPAGINGDEVICE_DELETENOTIFY1 , "req=0x%08x; offset=%d; size=%d", (TUint) aReq, offset, size); |
0 | 4476 |
|
4477 |
// no DFCQ, media driver executes in the context of calling thread |
|
4478 |
if (!iPrimaryMedia->iDfcQ) |
|
4479 |
{ |
|
4480 |
LOCM_FAULT(); // don't allow paging |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4481 |
OstTraceFunctionExitExt( DMEDIAPAGINGDEVICE_DELETENOTIFY_EXIT2, this, KErrNone ); |
0 | 4482 |
return KErrNone; // keep compiler happy |
4483 |
} |
|
4484 |
||
4485 |
TLocDrvRequest& m=*(TLocDrvRequest*)(aReq); |
|
4486 |
||
4487 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4488 |
m.Flags() = TLocDrvRequest::EKernelBuffer | TLocDrvRequest::EPaging | TLocDrvRequest::EDataPaging; |
0 | 4489 |
m.Id() = DLocalDrive::EDeleteNotify; |
4490 |
m.Drive() = TheDrives[iDataPagingDriveNumber]; |
|
4491 |
||
4492 |
m.RemoteThread() = NULL; |
|
4493 |
m.Pos() = offset; |
|
4494 |
m.Length() = Int64(size); |
|
4495 |
m.RemoteDes() = NULL; |
|
4496 |
m.RemoteDesOffset() = 0; // pre-aligned |
|
4497 |
m.DriverFlags()=0; |
|
4498 |
__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())); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4499 |
OstTraceDefExt4(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DMEDIAPAGINGDEVICE_DELETENOTIFY2 , "reqId=%d; position=0x%lx; length=0x%lx; remote Des=0x%x", m.Id(), m.Pos(), m.Length(), (TUint) m.RemoteDes()); |
0 | 4500 |
|
4501 |
// send request aynchronously as we don't particularly care about the result |
|
4502 |
// and waiting would slow down the thread taking the page fault |
|
4503 |
iPrimaryMedia->RequestCountInc(); |
|
4504 |
||
4505 |
m.SendReceive(&iMainQ); // send request synchronously |
|
4506 |
||
4507 |
#ifdef __DEMAND_PAGING__ |
|
4508 |
iPrimaryMedia->RequestCountDec(); |
|
4509 |
#endif |
|
4510 |
||
4511 |
TInt retVal = m.iValue; |
|
4512 |
||
4513 |
if (retVal == KErrNotSupported) |
|
4514 |
iDeleteNotifyNotSupported = ETrue; |
|
4515 |
||
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4516 |
OstTraceFunctionExitExt( DMEDIAPAGINGDEVICE_DELETENOTIFY_EXIT3, this, retVal ); |
0 | 4517 |
return retVal; |
4518 |
} |
|
4519 |
||
4520 |
||
4521 |
EXPORT_C TInt TLocDrvRequest::WriteToPageHandler(const TAny* aSrc, TInt aSize, TInt anOffset) |
|
4522 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4523 |
OstTraceFunctionEntry1( TLOCDRVREQUEST_WRITETOPAGEHANDLER_ENTRY, this ); |
0 | 4524 |
#ifdef BTRACE_PAGING_MEDIA |
4525 |
TMediaDevice medDev=Drive()->iMedia->iDevice; |
|
4526 |
TInt buf[3]; |
|
4527 |
buf[0]=(TUint32)RemoteDes(); |
|
4528 |
buf[1]=anOffset; |
|
4529 |
buf[2]=aSize; |
|
4530 |
BTraceContextN(BTrace::EPagingMedia,BTrace::EPagingMediaMedDrvWriteBack,medDev,this,buf,sizeof(buf)); |
|
4531 |
#endif |
|
4532 |
__KTRACE_OPT2(KLOCDRV,KLOCDPAGING,Kern::Printf("TLocDrvRequest::WriteToPageHandler, memcpy((aTrg)%08x, (aSrc)%08x, (aLength)%08x)",(TUint32)RemoteDes()+anOffset,aSrc,aSize)); |
|
4533 |
(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
|
4534 |
OstTraceFunctionExitExt( TLOCDRVREQUEST_WRITETOPAGEHANDLER_EXIT, this, KErrNone ); |
0 | 4535 |
return KErrNone; |
4536 |
} |
|
4537 |
||
4538 |
EXPORT_C TInt TLocDrvRequest::ReadFromPageHandler(TAny* aDst, TInt aSize, TInt anOffset) |
|
4539 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4540 |
OstTraceFunctionEntry1( TLOCDRVREQUEST_READFROMPAGEHANDLER_ENTRY, this ); |
0 | 4541 |
#ifdef BTRACE_PAGING_MEDIA |
4542 |
TMediaDevice medDev=Drive()->iMedia->iDevice; |
|
4543 |
TInt buf[3]; |
|
4544 |
buf[0]=(TUint32)RemoteDes(); |
|
4545 |
buf[1]=anOffset; |
|
4546 |
buf[2]=aSize; |
|
4547 |
BTraceContextN(BTrace::EPagingMedia,BTrace::EPagingMediaMedDrvRead,medDev,this,buf,sizeof(buf)); |
|
4548 |
#endif |
|
4549 |
__KTRACE_OPT2(KLOCDRV,KLOCDPAGING,Kern::Printf("TLocDrvRequest::ReadFromPageHandler, memcpy((aDst)%08x, (aTrg)%08x, (aLength)%08x)",aDst,(TUint32)RemoteDes()+anOffset,aSize)); |
|
4550 |
(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
|
4551 |
OstTraceFunctionExitExt( TLOCDRVREQUEST_READFROMPAGEHANDLER_EXIT, this, KErrNone ); |
0 | 4552 |
return KErrNone; |
4553 |
} |
|
4554 |
||
4555 |
_LIT(KLitFragmentationMutexName, "FRAGMENTATION_MUTEX"); |
|
4556 |
||
4557 |
TInt DFragmentationPagingLock::Construct(TUint aNumPages) |
|
4558 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4559 |
OstTraceFunctionEntryExt( DFRAGMENTATIONPAGINGLOCK_CONSTRUCT_ENTRY, this ); |
0 | 4560 |
TInt r=KErrNone; |
4561 |
__KTRACE_OPT2(KBOOT,KLOCDPAGING,Kern::Printf("Fragmentation Lock: creating Mutex")); |
|
4562 |
r=Kern::MutexCreate(this->iFragmentationMutex, KLitFragmentationMutexName, KMutexOrdNone); |
|
4563 |
if (r!=KErrNone) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4564 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4565 |
OstTraceFunctionExitExt( DFRAGMENTATIONPAGINGLOCK_CONSTRUCT_EXIT1, this, r ); |
0 | 4566 |
return r; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4567 |
} |
0 | 4568 |
__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
|
4569 |
OstTraceDef0(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DFRAGMENTATIONPAGINGLOCK_CONSTRUCT1 , "Fragmentation Lock: Mutex created OK"); |
0 | 4570 |
|
4571 |
iFragmentGranularity = 0; |
|
4572 |
if (aNumPages == 0) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4573 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4574 |
OstTraceFunctionExitExt( DFRAGMENTATIONPAGINGLOCK_CONSTRUCT_EXIT2, this, KErrNone ); |
0 | 4575 |
return KErrNone; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4576 |
} |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4577 |
|
0 | 4578 |
// in CS |
4579 |
TInt pageSize=Kern::RoundToPageSize(1); |
|
4580 |
LockFragmentation(); |
|
4581 |
r=Alloc(pageSize*aNumPages); // alloc pages |
|
4582 |
UnlockFragmentation(); |
|
4583 |
||
4584 |
if(r==KErrNone) |
|
4585 |
{ |
|
4586 |
iFragmentGranularity = pageSize * aNumPages; |
|
4587 |
__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
|
4588 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DFRAGMENTATIONPAGINGLOCK_CONSTRUCT2, "Fragmentation granularity=0x%x", iFragmentGranularity); |
0 | 4589 |
} |
4590 |
||
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4591 |
OstTraceFunctionExitExt( DFRAGMENTATIONPAGINGLOCK_CONSTRUCT_EXIT3, this, r ); |
0 | 4592 |
return r; |
4593 |
} |
|
4594 |
||
4595 |
void DFragmentationPagingLock::Cleanup() |
|
4596 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4597 |
OstTraceFunctionEntry1( DFRAGMENTATIONPAGINGLOCK_CLEANUP_ENTRY, this ); |
0 | 4598 |
// in CS |
4599 |
if (iFragmentationMutex) |
|
4600 |
{ |
|
4601 |
LockFragmentation(); |
|
4602 |
Free(); // at last! |
|
4603 |
UnlockFragmentation(); |
|
4604 |
Kern::SafeClose((DObject*&)iFragmentationMutex,NULL); |
|
4605 |
} |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4606 |
OstTraceFunctionExit1( DFRAGMENTATIONPAGINGLOCK_CLEANUP_EXIT, this ); |
0 | 4607 |
} |
4608 |
||
4609 |
#else |
|
4610 |
#if !defined(__WINS__) |
|
4611 |
EXPORT_C TInt TLocDrvRequest::WriteToPageHandler(const TAny* , TInt , TInt) |
|
4612 |
{ |
|
4613 |
return KErrNone; // stub for def file |
|
4614 |
} |
|
4615 |
#endif // __WINS__ |
|
4616 |
#endif //__DEMAND_PAGING__ |
|
4617 |
/******************************************** |
|
4618 |
* Media driver base class |
|
4619 |
********************************************/ |
|
4620 |
||
4621 |
||
4622 |
||
4623 |
||
4624 |
/** |
|
4625 |
Constructor. |
|
4626 |
||
4627 |
This is called, typically, by a derived class constructor in its ctor list. |
|
4628 |
||
4629 |
@param aMediaId The value of the unique media ID assigned when the media |
|
4630 |
driver is registered. |
|
4631 |
||
4632 |
@see LocDrv::RegisterMediaDevice() |
|
4633 |
*/ |
|
4634 |
EXPORT_C DMediaDriver::DMediaDriver(TInt aMediaId) |
|
4635 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4636 |
OstTraceFunctionEntryExt( DMEDIADRIVER_DMEDIADRIVER_ENTRY, this ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4637 |
|
0 | 4638 |
// iPhysicalDevice=NULL; |
4639 |
// iTotalSizeInBytes=0; |
|
4640 |
// iCurrentConsumption=0; |
|
4641 |
// iPrimaryMedia=NULL; |
|
4642 |
// iCritical=EFalse; |
|
4643 |
iPrimaryMedia=(DPrimaryMediaBase*)TheMedia[aMediaId]; |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4644 |
OstTraceFunctionExit1( DMEDIADRIVER_DMEDIADRIVER_EXIT, this ); |
0 | 4645 |
} |
4646 |
||
4647 |
||
4648 |
||
4649 |
||
4650 |
/** |
|
4651 |
Destructor. |
|
4652 |
||
4653 |
Sets the device's current consumption to zero, and calls Close() on |
|
4654 |
the PDD factory object. |
|
4655 |
||
4656 |
@see DObject::Close() |
|
4657 |
*/ |
|
4658 |
EXPORT_C DMediaDriver::~DMediaDriver() |
|
4659 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4660 |
OstTraceFunctionEntry1( DMEDIADRIVER_DMEDIADRIVER_DESTRUCTOR_ENTRY, this ); |
0 | 4661 |
SetCurrentConsumption(0); |
4662 |
Kern::SafeClose((DObject*&)iPhysicalDevice,NULL); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4663 |
OstTraceFunctionExit1( DMEDIADRIVER_DMEDIADRIVER_DESTRUCTOR_EXIT, this ); |
0 | 4664 |
} |
4665 |
||
4666 |
||
4667 |
||
4668 |
||
4669 |
/** |
|
4670 |
Closes the media driver. |
|
4671 |
||
4672 |
This default implementation simply deletes this DMediaDriver object. |
|
4673 |
||
4674 |
Media drivers can provide their own implementation, which gives them |
|
4675 |
the opportunity to clean up resources before closure; for example, |
|
4676 |
cancelling a DFC. |
|
4677 |
Any replacement function must call this base class function as |
|
4678 |
the last instruction. |
|
4679 |
*/ |
|
4680 |
EXPORT_C void DMediaDriver::Close() |
|
4681 |
{ |
|
4682 |
delete this; |
|
4683 |
} |
|
4684 |
||
4685 |
||
4686 |
||
4687 |
||
4688 |
/** |
|
4689 |
Sets the total size of the media device. |
|
4690 |
||
4691 |
The function must be called by the media driver's implementation of PartitionInfo(). |
|
4692 |
||
4693 |
@param aTotalSizeInBytes The total size of the media, in bytes. |
|
4694 |
@param aLocDrv This is not used by media drivers; the class |
|
4695 |
definition provides a default value. |
|
4696 |
||
4697 |
@see DMediaDriver::PartitionInfo() |
|
4698 |
*/ |
|
4699 |
EXPORT_C void DMediaDriver::SetTotalSizeInBytes(Int64 aTotalSizeInBytes, TLocDrv* aLocDrv) |
|
4700 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4701 |
OstTraceFunctionEntry1( DMEDIADRIVER_SETTOTALSIZEINBYTES_ENTRY, this ); |
0 | 4702 |
iTotalSizeInBytes=aTotalSizeInBytes; |
4703 |
if (aLocDrv) |
|
4704 |
aLocDrv->iPartitionLen=aTotalSizeInBytes; |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4705 |
OstTraceFunctionExit1( DMEDIADRIVER_SETTOTALSIZEINBYTES_EXIT, this ); |
0 | 4706 |
} |
4707 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4708 |
/** |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4709 |
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
|
4710 |
set iSectorSizeInBytes, iNumberOfSectors & iNumPagesPerBlock appropriately to allow |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4711 |
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
|
4712 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4713 |
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
|
4714 |
*/ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4715 |
EXPORT_C void DMediaDriver::SetTotalSizeInBytes(TLocalDriveCapsV4& aCaps) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4716 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4717 |
if (aCaps.iNumOfBlocks == 0) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4718 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4719 |
aCaps.iSectorSizeInBytes = 512; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4720 |
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
|
4721 |
Int64 numberOfSectors = iTotalSizeInBytes >> 9; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4722 |
while (I64HIGH(numberOfSectors) > 0) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4723 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4724 |
aCaps.iNumPagesPerBlock<<= 1; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4725 |
numberOfSectors>>= 1; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4726 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4727 |
aCaps.iNumberOfSectors = I64LOW(numberOfSectors); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4728 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4729 |
} |
0 | 4730 |
|
4731 |
||
4732 |
||
4733 |
/** |
|
4734 |
Gets the total size of the media. |
|
4735 |
||
4736 |
@return The total size of the media, in bytes. |
|
4737 |
||
4738 |
@see DMediaDriver::SetTotalSizeInBytes() |
|
4739 |
*/ |
|
4740 |
EXPORT_C Int64 DMediaDriver::TotalSizeInBytes() |
|
4741 |
{ |
|
4742 |
return iTotalSizeInBytes; |
|
4743 |
} |
|
4744 |
||
4745 |
||
4746 |
||
4747 |
||
4748 |
/** |
|
4749 |
Flags the media driver as entering a critical part of its processing. |
|
4750 |
||
4751 |
In this context, critical means that the driver must be allowed to complete |
|
4752 |
its current activity. |
|
4753 |
For example, a request to power down the device must be deferred until |
|
4754 |
the driver exits the critical part. |
|
4755 |
||
4756 |
@return KErrNone, if the driver has been successfully flagged as being in |
|
4757 |
a critical part; otherwise, one of the other system-wide error codes. |
|
4758 |
||
4759 |
@see DMediaDriver::EndInCritical() |
|
4760 |
*/ |
|
4761 |
EXPORT_C TInt DMediaDriver::InCritical() |
|
4762 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4763 |
OstTraceFunctionEntry1( DMEDIADRIVER_INCRITICAL_ENTRY, this ); |
0 | 4764 |
if (!iCritical) |
4765 |
{ |
|
4766 |
TInt r=iPrimaryMedia->InCritical(); |
|
4767 |
if (r!=KErrNone) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4768 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4769 |
OstTraceFunctionExitExt( DMEDIADRIVER_INCRITICAL_EXIT, this, r ); |
0 | 4770 |
return r; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4771 |
} |
0 | 4772 |
iCritical=ETrue; |
4773 |
} |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4774 |
OstTraceFunctionExitExt( DMEDIADRIVER_INCRITICAL_EXIT2, this, KErrNone ); |
0 | 4775 |
return KErrNone; |
4776 |
} |
|
4777 |
||
4778 |
||
4779 |
||
4780 |
||
4781 |
/** |
|
4782 |
Flags the media driver as leaving a critical part of its processing. |
|
4783 |
||
4784 |
@see DMediaDriver::InCritical() |
|
4785 |
*/ |
|
4786 |
EXPORT_C void DMediaDriver::EndInCritical() |
|
4787 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4788 |
OstTraceFunctionEntry1( DMEDIADRIVER_ENDINCRITICAL_ENTRY, this ); |
0 | 4789 |
if (iCritical) |
4790 |
{ |
|
4791 |
iCritical=EFalse; |
|
4792 |
iPrimaryMedia->EndInCritical(); |
|
4793 |
} |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4794 |
OstTraceFunctionExit1( DMEDIADRIVER_ENDINCRITICAL_EXIT, this ); |
0 | 4795 |
} |
4796 |
||
4797 |
||
4798 |
||
4799 |
||
4800 |
/** |
|
4801 |
@internalComponent |
|
4802 |
*/ |
|
4803 |
EXPORT_C void DMediaDriver::SetCurrentConsumption(TInt aValue) |
|
4804 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4805 |
OstTraceFunctionEntryExt( DMEDIADRIVER_SETCURRENTCONSUMPTION_ENTRY, this ); |
0 | 4806 |
TInt old = (TInt)__e32_atomic_swp_ord32(&iCurrentConsumption, aValue); |
4807 |
TInt delta = aValue - old; |
|
4808 |
iPrimaryMedia->DeltaCurrentConsumption(delta); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4809 |
OstTraceFunctionExit1( DMEDIADRIVER_SETCURRENTCONSUMPTION_EXIT, this ); |
0 | 4810 |
} |
4811 |
||
4812 |
||
4813 |
||
4814 |
||
4815 |
/** |
|
4816 |
Informs the media driver subsystem that an asynchronous request is complete. |
|
4817 |
||
4818 |
@param m The request that this call is completing. |
|
4819 |
@param aResult The return code for the asynchronous request. Typically, this |
|
4820 |
is KErrNone to report success, or one of the other system-wide |
|
4821 |
error codes to report failure or other problems. |
|
4822 |
*/ |
|
4823 |
EXPORT_C void DMediaDriver::Complete(TLocDrvRequest& m, TInt aResult) |
|
4824 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4825 |
OstTraceExt2( TRACE_FLOW, DMEDIADRIVER_COMPLETE_ENTRY, "m=%x;aResult=%d", (TUint) &m, aResult ); |
0 | 4826 |
CHECK_RET(aResult); |
4827 |
#ifdef __DEMAND_PAGING__ |
|
4828 |
if (DMediaPagingDevice::PagingRequest(m)) |
|
4829 |
{ |
|
4830 |
__ASSERT_ALWAYS(iPrimaryMedia && iPrimaryMedia->iPagingMedia && iPrimaryMedia->iBody->iPagingDevice,LOCM_FAULT()); |
|
4831 |
__ASSERT_ALWAYS( ((m.Flags() & TLocDrvRequest::ECodePaging) == 0) || (m.Drive()->iPagingDrv), LOCM_FAULT()); |
|
4832 |
DMediaPagingDevice* pagingdevice = iPrimaryMedia->iBody->iPagingDevice; |
|
4833 |
pagingdevice->CompleteRequest(&m, aResult); |
|
4834 |
} |
|
4835 |
else |
|
4836 |
#endif |
|
4837 |
iPrimaryMedia->CompleteRequest(m, aResult); |
|
4838 |
||
4839 |
if (&m == iPrimaryMedia->iCurrentReq) // Complete() called on request serviced synchronously |
|
4840 |
iPrimaryMedia->iCurrentReq = NULL; |
|
4841 |
||
4842 |
iPrimaryMedia->RunDeferred(); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4843 |
OstTraceFunctionExit1( DMEDIADRIVER_COMPLETE_EXIT, this ); |
0 | 4844 |
} |
4845 |
||
4846 |
||
4847 |
||
4848 |
||
4849 |
/** |
|
4850 |
Informs the media driver subsystem that the media driver is open |
|
4851 |
and has been initialised. |
|
4852 |
||
4853 |
This can be called from the PDD factory function Create(), if opening and |
|
4854 |
initialising the media driver is synchronous, otherwise it should be called by |
|
4855 |
the asynchronous media driver function that is responsible for opening and |
|
4856 |
initialising the driver. |
|
4857 |
||
4858 |
@param anError KErrNone if successful, otherwise one of the other system wide |
|
4859 |
error codes. |
|
4860 |
*/ |
|
4861 |
EXPORT_C void DMediaDriver::OpenMediaDriverComplete(TInt anError) |
|
4862 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4863 |
OstTraceFunctionEntry1( DMEDIADRIVER_OPENMEDIADRIVERCOMPLETE_ENTRY, this ); |
0 | 4864 |
__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
|
4865 |
OstTraceDefExt3(OST_TRACE_CATEGORY_RND, TRACE_MEDIACHANGE, DMEDIADRIVER_OPENMEDIADRIVERCOMPLETE, "anError %d this 0x%x iPrimaryMedia 0x%x", anError, (TUint) this, (TUint) iPrimaryMedia); |
0 | 4866 |
DPrimaryMediaBase* pM=iPrimaryMedia; |
4867 |
pM->iAsyncErrorCode=anError; |
|
4868 |
pM->iAsyncDfc.Enque(); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4869 |
OstTraceFunctionExit1( DMEDIADRIVER_OPENMEDIADRIVERCOMPLETE_EXIT, this ); |
0 | 4870 |
} |
4871 |
||
4872 |
||
4873 |
||
4874 |
||
4875 |
/** |
|
4876 |
Informs the media driver subsystem that the media driver has completed |
|
4877 |
the provision of partition information. |
|
4878 |
||
4879 |
The media driver provides partition information in its implementation |
|
4880 |
of PartitionInfo(). |
|
4881 |
||
4882 |
@param anError KErrNone if successful, otherwise one of the other system wide |
|
4883 |
error codes. |
|
4884 |
||
4885 |
@see DMediaDriver::PartitionInfo() |
|
4886 |
*/ |
|
4887 |
EXPORT_C void DMediaDriver::PartitionInfoComplete(TInt anError) |
|
4888 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4889 |
OstTraceFunctionEntry1( DMEDIADRIVER_PARTITIONINFOCOMPLETE_ENTRY, this ); |
0 | 4890 |
__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
|
4891 |
OstTraceExt3( TRACE_INTERNALS, DMDEDIADRIVER_PARTITIONINFOCOMPLETE, "anError=%d; this=%x; iPrimaryMedia=%x", anError, (TUint) this, (TUint) iPrimaryMedia ); |
0 | 4892 |
DPrimaryMediaBase* pM=iPrimaryMedia; |
4893 |
pM->iAsyncErrorCode=anError; |
|
4894 |
pM->iAsyncDfc.Enque(); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4895 |
OstTraceFunctionExit1( DMEDIADRIVER_PARTITIONINFOCOMPLETE_EXIT, this ); |
0 | 4896 |
} |
4897 |
||
4898 |
||
4899 |
||
4900 |
||
4901 |
/** |
|
4902 |
@internalComponent |
|
4903 |
*/ |
|
4904 |
// Default implementation |
|
4905 |
EXPORT_C void DMediaDriver::Disconnect(DLocalDrive* aLocalDrive, TThreadMessage* aMsg) |
|
4906 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4907 |
OstTraceFunctionEntryExt( DMEDIADRIVER_DISCONNECT_ENTRY, this ); |
0 | 4908 |
// don't need to worry about DLocalDrive going away |
4909 |
aLocalDrive->Deque(); |
|
4910 |
||
4911 |
aMsg->Complete(KErrNone, EFalse); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4912 |
OstTraceFunctionExit1( DMEDIADRIVER_DISCONNECT_EXIT, this ); |
0 | 4913 |
} |
4914 |
||
4915 |
||
4916 |
||
4917 |
||
4918 |
/** |
|
4919 |
Registers a media driver with the Local Media Subsystem, and provides |
|
4920 |
information about the number of supported drives, partitions, |
|
4921 |
names and drive numbers. |
|
4922 |
||
4923 |
@param aDevice The unique Media ID for this device. |
|
4924 |
This can take one of the enumerated values defined |
|
4925 |
by the TMediaDevice enum. |
|
4926 |
@param aDriveCount Specifies the number of local drive objects to be assigned |
|
4927 |
to the media driver. Drives that support more than one |
|
4928 |
partition must specify a number greater than 1. |
|
4929 |
@param aDriveList A pointer to an array of TInt values, which define |
|
4930 |
the drive numbers that are to be allocated to each partition. |
|
4931 |
0 signifies Drive C, 1 signifies drive D, etc. For example, |
|
4932 |
to allocate drive letters J and K, specify an array |
|
4933 |
containing the values [7,8]. |
|
4934 |
Note that the size of this array must be the same as the value |
|
4935 |
specified by aDriveCount. |
|
4936 |
@param aPrimaryMedia A pointer to the primary DPrimaryMedia object to be |
|
4937 |
associated with the media. This object is responsible for |
|
4938 |
the overall state of the media, i.e. powering up, reading |
|
4939 |
partition information etc. It also has overall control over |
|
4940 |
all partitions as represented by the additional (aNumMedia-1) |
|
4941 |
DMedia objects. |
|
4942 |
@param aNumMedia Specifies the total number of DMedia objects to be |
|
4943 |
associated with the media driver. This number includes the |
|
4944 |
primary DPrimaryMedia object referred to by aPrimaryMedia, |
|
4945 |
plus all of the DMedia objects that are created for each |
|
4946 |
additional drive, and which hold basic information about |
|
4947 |
partitions. |
|
4948 |
@param aName The name of the media driver, for example: PCCard |
|
4949 |
||
4950 |
@return KErrNone, if successful; |
|
4951 |
KErrInUse, if a drive is already in use; |
|
4952 |
KErrNoMemory, if there is insufficient memory; |
|
4953 |
or one of the other system-wide error codes. |
|
4954 |
*/ |
|
4955 |
EXPORT_C TInt LocDrv::RegisterMediaDevice(TMediaDevice aDevice, TInt aDriveCount, const TInt* aDriveList, DPrimaryMediaBase* aPrimaryMedia, TInt aNumMedia, const TDesC& aName) |
|
4956 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4957 |
OstTraceFunctionEntry0( LOCDRV_REGISTERMEDIADEVICE_ENTRY ); |
0 | 4958 |
// Create TLocDrv / DMedia objects to handle a media device |
4959 |
__KTRACE_OPT(KBOOT,Kern::Printf("RegisterMediaDevice %lS 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
|
4960 |
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
|
4961 |
|
0 | 4962 |
if (UsedMedia+aNumMedia>KMaxLocalDrives) |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4963 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4964 |
OstTrace0(TRACE_FLOW, LOCDRV_REGISTERMEDIADEVICE_EXIT1, "< KErrInUse"); |
0 | 4965 |
return KErrInUse; |
4966 |
} |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4967 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4968 |
// make a local copy of the name |
0 | 4969 |
HBuf* pN=HBuf::New(aName); |
4970 |
if (!pN) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4971 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4972 |
OstTrace0(TRACE_FLOW, LOCDRV_REGISTERMEDIADEVICE_EXIT3, "< KErrNoMemory"); |
0 | 4973 |
return KErrNoMemory; |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4974 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4975 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4976 |
// 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
|
4977 |
TInt lastMedia = UsedMedia+aNumMedia-1; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4978 |
TInt i; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
4979 |
TInt r=0; |
0 | 4980 |
for (i=UsedMedia; i<=lastMedia; ++i) |
4981 |
{ |
|
4982 |
if (i==UsedMedia) |
|
4983 |
TheMedia[i]=aPrimaryMedia; |
|
4984 |
else |
|
4985 |
TheMedia[i]=new DMedia; |
|
4986 |
if (!TheMedia[i]) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4987 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4988 |
OstTrace0(TRACE_FLOW, LOCDRV_REGISTERMEDIADEVICE_EXIT4, "< KErrNoMemory"); |
0 | 4989 |
return KErrNoMemory; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4990 |
} |
0 | 4991 |
r=TheMedia[i]->Create(aDevice,i,lastMedia); |
4992 |
__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
|
4993 |
OstTraceExt2( TRACE_INTERNALS, LOCDRV_REGISTERMEDIADEVICE3, "Media=%d Create(); retval=%d", i, r ); |
0 | 4994 |
if (r!=KErrNone) |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4995 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4996 |
OstTrace1(TRACE_FLOW, LOCDRV_REGISTERMEDIADEVICE_EXIT5, "< retval=%d", r); |
0 | 4997 |
return r; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
4998 |
} |
0 | 4999 |
} |
5000 |
__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
|
5001 |
OstTraceExt2( TRACE_INTERNALS, LOCDRV_REGISTERMEDIADEVICE4, "FirstMedia=%d; LastMedia=%d", UsedMedia, lastMedia ); |
0 | 5002 |
UsedMedia+=aNumMedia; |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5003 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5004 |
if (__IS_EXTENSION(aDevice)) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5005 |
aPrimaryMedia->iBody->iMediaExtension = ETrue; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5006 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5007 |
// Register the drives |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5008 |
const TInt* p=aDriveList; |
0 | 5009 |
for (i=0; i<aDriveCount; ++i) |
5010 |
{ |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5011 |
TInt drv = *p++; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5012 |
// -1 means not used; this is to enable Dual-slot MMC support |
0 | 5013 |
if (drv == -1) |
5014 |
continue; |
|
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 |
__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
|
5017 |
if (!__IS_EXTENSION(aDevice) && TheDrives[drv]) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5018 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5019 |
__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
|
5020 |
return KErrInUse; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5021 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5022 |
else if (__IS_EXTENSION(aDevice) && !TheDrives[drv]) |
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 |
__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
|
5025 |
return KErrNotReady; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5026 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5027 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5028 |
TLocDrv* pNewDrive = new TLocDrv(drv); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5029 |
if (!pNewDrive) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5030 |
{ |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5031 |
OstTrace0(TRACE_FLOW, LOCDRV_REGISTERMEDIADEVICE_EXIT6, "< KErrNoMemory"); |
0 | 5032 |
return KErrNoMemory; |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5033 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5034 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5035 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5036 |
TLocDrv* pOldDrive = TheDrives[drv]; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5037 |
aPrimaryMedia->iBody->iRegisteredDriveMask|= (0x1 << drv); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5038 |
pNewDrive->iNextDrive = pOldDrive; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5039 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5040 |
TheDrives[drv] = pNewDrive; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5041 |
DriveNames[drv] = pN; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5042 |
pNewDrive->iPrimaryMedia = aPrimaryMedia; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5043 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5044 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5045 |
if (pOldDrive) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5046 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5047 |
TInt r = pOldDrive->iPrimaryMedia->Connect(pNewDrive); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5048 |
if (r != KErrNone) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5049 |
return r; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5050 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5051 |
#ifdef __DEMAND_PAGING__ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5052 |
// 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
|
5053 |
// 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
|
5054 |
// 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
|
5055 |
DMediaPagingDevice* oldPagingDevice = pOldDrive->iPrimaryMedia->iBody->iPagingDevice; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5056 |
if (oldPagingDevice && |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5057 |
(oldPagingDevice->iType & DPagingDevice::ERom) && |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5058 |
oldPagingDevice->iRomPagingDriveNumber == KErrNotFound && |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5059 |
oldPagingDevice->iFirstLocalDriveNumber == drv) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5060 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5061 |
__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
|
5062 |
TInt n; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5063 |
for (n=0; n<KMaxLocalDrives; ++n) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5064 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5065 |
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
|
5066 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5067 |
__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
|
5068 |
oldPagingDevice->iFirstLocalDriveNumber = n; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5069 |
break; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5070 |
} |
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 |
__ASSERT_ALWAYS(n < KMaxLocalDrives, LOCM_FAULT()); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5073 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5074 |
#endif |
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 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5077 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5078 |
__KTRACE_OPT(KBOOT,Kern::Printf("Drive %d: TLocDrv @ %08x",drv,pNewDrive)); |
0 | 5079 |
} |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5080 |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5081 |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5082 |
OstTraceFunctionExit0( LOCDRV_REGISTERMEDIADEVICE_EXIT7 ); |
0 | 5083 |
return KErrNone; |
5084 |
} |
|
5085 |
||
5086 |
||
5087 |
||
5088 |
||
5089 |
/** |
|
5090 |
A utility function that is used internally to register the specified |
|
5091 |
password store. |
|
5092 |
||
5093 |
The password store is used to save passwords for local media. |
|
5094 |
||
5095 |
@param aStore A pointer to the password store to be registered. |
|
5096 |
||
5097 |
@return KErrNone, if successful; |
|
5098 |
KErrAlreadyExists, if a password store has already been registered. |
|
5099 |
*/ |
|
5100 |
EXPORT_C TInt LocDrv::RegisterPasswordStore(TPasswordStore* aStore) |
|
5101 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5102 |
OstTraceFunctionEntry0( LOCDRV_REGISTERPASSWORDSTORE_ENTRY ); |
0 | 5103 |
// Create TLocDrv / DMedia objects to handle a media device |
5104 |
__KTRACE_OPT(KBOOT,Kern::Printf("RegisterPasswordStore")); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5105 |
|
0 | 5106 |
TInt r = KErrNone; |
5107 |
||
5108 |
if(ThePasswordStore == NULL) |
|
5109 |
ThePasswordStore = aStore; |
|
5110 |
else |
|
5111 |
r = KErrAlreadyExists; |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5112 |
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
|
5113 |
OstTraceFunctionExit0( LOCDRV_REGISTERPASSWORDSTORE_EXIT ); |
0 | 5114 |
return r; |
5115 |
} |
|
5116 |
||
5117 |
/** |
|
5118 |
Returns a pointer to the registered password store. |
|
5119 |
||
5120 |
The password store is used to save passwords for local media. |
|
5121 |
||
5122 |
@return A pointer to the registered password store. |
|
5123 |
*/ |
|
5124 |
EXPORT_C TPasswordStore* LocDrv::PasswordStore() |
|
5125 |
{ |
|
5126 |
return ThePasswordStore; |
|
5127 |
} |
|
5128 |
||
5129 |
#ifdef __DEMAND_PAGING__ |
|
5130 |
/** |
|
5131 |
Registers a paging device with the Local Media Subsystem, and provides |
|
5132 |
information about drive numbers used in Code Paging. |
|
5133 |
||
5134 |
@param aPrimaryMedia A pointer to the primary DPrimaryMedia object associated |
|
5135 |
with the media. |
|
5136 |
@param aPagingDriveList A pointer to an array of TInt values, which define |
|
5137 |
the drive numbers used as Code backup in Code Paging, which |
|
5138 |
are the target of Page In requests. For NAND these will |
|
5139 |
will be usually associated with ROFS and/or User Data drives. |
|
5140 |
In ROM pagigng systems no drive is specified, it is assumed |
|
5141 |
a fixed media for which no non-primary media exists, will be |
|
5142 |
used. |
|
5143 |
@param aDriveCount Specifies the number of local drives associated with this |
|
5144 |
media device which can be used for code paging. |
|
5145 |
@param aPagingType Identifies the type of Paging this media device is capable |
|
5146 |
of servicing. |
|
5147 |
@param aReadShift Log2 of the read unit size. A read unit is the number of bytes |
|
5148 |
which the device can optimally read from the underlying media. |
|
5149 |
E.g. for small block NAND, a read unit would be equal to the |
|
5150 |
page size, 512 bytes, therefore iReadShift would be set to 9. |
|
5151 |
@param aNumPages The number of pages to alloc for each drive associated with this |
|
5152 |
media driver. The pages are used in request fragmentation. |
|
5153 |
||
5154 |
@return KErrNone, if successful; |
|
5155 |
KErrNotFound, if at least one of the drive numbers |
|
5156 |
specified has not yet been mapped. |
|
5157 |
KErrArgument, if the passed in an invalid argument. |
|
5158 |
KErrNotSupported, if at least one of the drive numbers |
|
5159 |
specifed is not associated with this Primary Media. |
|
5160 |
KErrNoMemory, if there is insufficient memory; |
|
5161 |
or one of the other system-wide error codes. |
|
5162 |
*/ |
|
5163 |
EXPORT_C TInt LocDrv::RegisterPagingDevice(DPrimaryMediaBase* aPrimaryMedia, const TInt* aPagingDriveList, TInt aDriveCount, TUint aPagingType, TInt aReadShift, TUint aNumPages) |
|
5164 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5165 |
OstTraceFunctionEntry0( LOCDRV_REGISTERPAGINGDEVICE_ENTRY ); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5166 |
// SETDEBUGFLAG(KLOCDPAGING); |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5167 |
|
0 | 5168 |
__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
|
5169 |
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
|
5170 |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5171 |
TInt i = 0; |
0 | 5172 |
|
5173 |
if(!aPagingType || (aPagingType&~(DPagingDevice::ERom | DPagingDevice::ECode | DPagingDevice::EData))) |
|
5174 |
{ |
|
5175 |
__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
|
5176 |
OstTrace0(TRACE_FLOW, LOVDRV_REGISTERPAGINGDEVICE_EXIT1, "< Unsupported paging type; KErrArgument"); |
0 | 5177 |
return KErrArgument; |
5178 |
} |
|
5179 |
||
5180 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5181 |
// Check for duplicate drives |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5182 |
if (!aPrimaryMedia->iBody->iMediaExtension) |
0 | 5183 |
{ |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5184 |
for(i=0; i<KMaxLocalDrives; i++) |
0 | 5185 |
{ |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5186 |
if (ThePagingDevices[i] == NULL) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5187 |
continue; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5188 |
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
|
5189 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5190 |
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
|
5191 |
__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
|
5192 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5193 |
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
|
5194 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5195 |
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
|
5196 |
__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
|
5197 |
} |
0 | 5198 |
} |
5199 |
} |
|
5200 |
||
5201 |
||
5202 |
if (aPagingType == 0) |
|
5203 |
{ |
|
5204 |
// there's already a ROM or Data paging device & this doesn't support code paging so quietly exit without further addo |
|
5205 |
__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
|
5206 |
OstTrace1(TRACE_FLOW, LOVDRV_REGISTERPAGINGDEVICE_EXIT2, "< Nothing left to register on locdrv no %d; KErrNone",i); |
0 | 5207 |
return KErrNone; |
5208 |
} |
|
5209 |
||
5210 |
const TInt* p=aPagingDriveList; |
|
5211 |
if(aPagingType&DPagingDevice::ECode) // supports code paging, do argument check |
|
5212 |
{ |
|
5213 |
if(!aDriveCount || (aDriveCount>=KMaxLocalDrives)) |
|
5214 |
{ |
|
5215 |
__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
|
5216 |
OstTrace1(TRACE_FLOW, LOVDRV_REGISTERPAGINGDEVICE_EXIT3, "< Invalid code paging drive count=%d; KErrArgument", aDriveCount); |
0 | 5217 |
return KErrArgument; |
5218 |
} |
|
5219 |
||
5220 |
TInt drvCount=0; |
|
5221 |
for(i=0; i<KMaxLocalDrives; i++) |
|
5222 |
if(TheDrives[i] && TheDrives[i]->iPrimaryMedia==aPrimaryMedia) |
|
5223 |
drvCount++; |
|
5224 |
if(aDriveCount>drvCount) // can't exceed number of drives registered by this device |
|
5225 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5226 |
__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
|
5227 |
OstTraceExt2(TRACE_FLOW, LOVDRV_REGISTERPAGINGDEVICE_EXIT4, "< Invalid code paging drive count=%d; total=%d; KErrArgument", aDriveCount, drvCount); |
0 | 5228 |
return KErrArgument; |
5229 |
} |
|
5230 |
||
5231 |
for (i=0; i<aDriveCount; ++i) |
|
5232 |
{ |
|
5233 |
__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
|
5234 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, LOCDRV_REGISTERPAGINGDEVICE2, "Registering Drive=%d", *p ); |
0 | 5235 |
TInt drv=*p++; |
5236 |
if(drv>=KMaxLocalDrives) |
|
5237 |
{ |
|
5238 |
__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
|
5239 |
OstTrace1(TRACE_FLOW, LOVDRV_REGISTERPAGINGDEVICE_EXIT5, "< Invalid code paging drive number=%d; KErrArgument", drv); |
0 | 5240 |
return KErrArgument; |
5241 |
} |
|
5242 |
TLocDrv* pD=TheDrives[drv]; |
|
5243 |
if (!pD) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5244 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5245 |
OstTrace0(TRACE_FLOW, LOCRV_REGISTERPAGINGDEVICE_EXIT6, "< KErrNotFound"); |
0 | 5246 |
return KErrNotFound; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5247 |
} |
0 | 5248 |
if (pD->iPrimaryMedia!=aPrimaryMedia) |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5249 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5250 |
OstTrace0(TRACE_FLOW, LOCRV_REGISTERPAGINGDEVICE_EXIT7, "< KErrNotSupported"); |
0 | 5251 |
return KErrNotSupported; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5252 |
} |
0 | 5253 |
} |
5254 |
} |
|
5255 |
||
5256 |
||
5257 |
TInt firstLocalDriveNumber = KErrNotFound; |
|
5258 |
TInt romPagingDriveNumber = KErrNotFound; |
|
5259 |
||
5260 |
TInt dataPagingDriveNumber = KErrNotFound; |
|
5261 |
TInt swapSize = 0; |
|
5262 |
||
5263 |
// find the local drive assocated with the primary media |
|
5264 |
for (i=0; i<KMaxLocalDrives; ++i) |
|
5265 |
{ |
|
5266 |
if(TheDrives[i] && TheDrives[i]->iPrimaryMedia == aPrimaryMedia) |
|
5267 |
{ |
|
5268 |
firstLocalDriveNumber = i; |
|
5269 |
break; |
|
5270 |
} |
|
5271 |
} |
|
5272 |
__ASSERT_ALWAYS(i < KMaxLocalDrives, LOCM_FAULT()); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5273 |
__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
|
5274 |
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
|
5275 |
|
0 | 5276 |
// Send an ECaps message to wake up the media driver & ensure all partitions are |
5277 |
// 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
|
5278 |
// 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
|
5279 |
// 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
|
5280 |
// 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
|
5281 |
// @see DMediaPagingDevice::Read() |
0 | 5282 |
if ((aPagingType & DPagingDevice::EData) || |
5283 |
(aPagingType & DPagingDevice::ERom && aPrimaryMedia->iDfcQ && aPrimaryMedia->iMsgQ.iReady)) |
|
5284 |
{ |
|
5285 |
// 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
|
5286 |
// 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
|
5287 |
if (!aPrimaryMedia->iDfcQ || !aPrimaryMedia->iMsgQ.iReady) |
0 | 5288 |
{ |
5289 |
__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
|
5290 |
OstTrace0(TRACE_FLOW, LOVDRV_REGISTERPAGINGDEVICE_EXIT8, "< RegisterPagingDevice: Message queue not started; KErrNotReady"); |
0 | 5291 |
return KErrNotReady; |
5292 |
} |
|
5293 |
||
5294 |
||
5295 |
TLocDrvRequest m; |
|
5296 |
memclr(&m, sizeof(m)); |
|
5297 |
||
5298 |
||
5299 |
// Get the Caps from the device. NB for MMC/SD we may need to retry as some PSLs start up |
|
5300 |
// in "door open" or "media not present" state which can result in the cancellation of requests |
|
5301 |
TInt i; |
|
5302 |
const TInt KRetries = 5; |
|
5303 |
TInt r = KErrNotReady; |
|
5304 |
for (i=0; r == KErrNotReady && i < KRetries; i++) |
|
5305 |
{ |
|
5306 |
TBuf8<KMaxLocalDriveCapsLength> capsBuf; |
|
5307 |
capsBuf.SetMax(); |
|
5308 |
capsBuf.FillZ(); |
|
5309 |
m.Drive() = TheDrives[firstLocalDriveNumber]; |
|
5310 |
m.Id() = DLocalDrive::ECaps; |
|
5311 |
m.RemoteDes() = (TAny*)capsBuf.Ptr(); // overload this |
|
5312 |
m.Length() = KMaxLocalDriveCapsLength; // for pinning |
|
5313 |
r = aPrimaryMedia->Request(m); |
|
5314 |
||
5315 |
//Kern::Printf("EQueryPageDeviceInfo: i %d: r %d ", i, r); |
|
5316 |
__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
|
5317 |
OstTraceDefExt2( OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, LOCDRV_REGISTERPAGINGDEVICE4, "Paging device ECaps: i %d retval=%d", i, r); |
0 | 5318 |
} |
5319 |
||
5320 |
if (r != KErrNone) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5321 |
{ |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5322 |
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
|
5323 |
// 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
|
5324 |
// 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
|
5325 |
return KErrNotSupported; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5326 |
} |
0 | 5327 |
|
5328 |
TLocDrv* drive; |
|
5329 |
for (i=0; i<KMaxLocalDrives; ++i) |
|
5330 |
{ |
|
5331 |
drive = TheDrives[i]; |
|
5332 |
if(drive && drive->iPrimaryMedia == aPrimaryMedia) |
|
5333 |
{ |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5334 |
__KTRACE_OPT2(KBOOT,KLOCDPAGING, Kern::Printf("RegisterPagingDevice: local drive %d, partition type %x base %lx size %lx name %lS", i, drive->iPartitionType, drive->iPartitionBaseAddr, drive->iPartitionLen, DriveNames[i] ? DriveNames[i] : &KNullDesC8)); |
0 | 5335 |
// ROM partition ? |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5336 |
if ((romPagingDriveNumber == KErrNotFound) && |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5337 |
(drive->iPartitionType == KPartitionTypeROM) && |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5338 |
(aPagingType & DPagingDevice::ERom)) |
0 | 5339 |
{ |
5340 |
__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
|
5341 |
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 | 5342 |
romPagingDriveNumber = i; |
5343 |
} |
|
5344 |
// swap partition ? |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5345 |
else if ((dataPagingDriveNumber == KErrNotFound) && |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5346 |
(drive->iPartitionType == KPartitionTypePagedData) && |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5347 |
(aPagingType & DPagingDevice::EData)) |
0 | 5348 |
{ |
5349 |
__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
|
5350 |
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 | 5351 |
dataPagingDriveNumber = i; |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5352 |
TheDataPagingDrive = drive; |
0 | 5353 |
swapSize = drive->iPartitionLen >> aReadShift; |
5354 |
} |
|
5355 |
} |
|
5356 |
} |
|
5357 |
||
5358 |
if (swapSize == 0) |
|
5359 |
{ |
|
5360 |
__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
|
5361 |
OstTraceDef0(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, LOCDRV_REGISTERPAGINGDEVICE7, "Disabling data paging"); |
0 | 5362 |
aPagingType &= ~DPagingDevice::EData; |
5363 |
} |
|
5364 |
||
5365 |
} |
|
5366 |
||
5367 |
||
5368 |
// create and set up a DPagingDevice to allow PageIn request servicing |
|
5369 |
DMediaPagingDevice* pagingDevice = new DMediaPagingDevice(aPrimaryMedia); |
|
5370 |
if(!pagingDevice) |
|
5371 |
{ |
|
5372 |
__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
|
5373 |
OstTrace0(TRACE_FLOW, LOVDRV_REGISTERPAGINGDEVICE_EXIT_EXIT10, "< RegisterPagingDevice: could not create paging device; KErrNoMemory"); |
0 | 5374 |
return KErrNoMemory; |
5375 |
} |
|
5376 |
||
5377 |
pagingDevice->iType = aPagingType; |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5378 |
if (aPrimaryMedia->iBody->iMediaExtension) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5379 |
pagingDevice->iType|= DPagingDevice::EMediaExtension; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5380 |
|
0 | 5381 |
pagingDevice->iReadUnitShift = aReadShift; |
5382 |
||
5383 |
pagingDevice->iFirstLocalDriveNumber = firstLocalDriveNumber; |
|
5384 |
pagingDevice->iRomPagingDriveNumber = romPagingDriveNumber; |
|
5385 |
||
5386 |
pagingDevice->iDataPagingDriveNumber = dataPagingDriveNumber; |
|
5387 |
pagingDevice->iSwapSize = swapSize; |
|
5388 |
||
5389 |
#ifdef __DEBUG_DEMAND_PAGING__ |
|
5390 |
Kern::Printf("PagingDevice :"); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5391 |
Kern::Printf("Name %lS", firstLocalDriveNumber >= 0 && DriveNames[firstLocalDriveNumber] ? DriveNames[firstLocalDriveNumber] : &KNullDesC8); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5392 |
Kern::Printf("iType 0x%x", pagingDevice->iType); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5393 |
Kern::Printf("iReadUnitShift 0x%x", pagingDevice->iReadUnitShift); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5394 |
Kern::Printf("iFirstLocalDriveNumber 0x%x", pagingDevice->iFirstLocalDriveNumber); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5395 |
Kern::Printf("iRomPagingDriveNumber 0x%x", pagingDevice->iRomPagingDriveNumber); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5396 |
Kern::Printf("iDataPagingDriveNumber 0x%x", pagingDevice->iDataPagingDriveNumber); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5397 |
Kern::Printf("iSwapSize 0x%x", pagingDevice->iSwapSize); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
5398 |
#endif |
0 | 5399 |
|
5400 |
||
5401 |
// This table is indexed by DPagingDevice::TType |
|
5402 |
const char* DeviceName[] = |
|
5403 |
{ |
|
5404 |
"Error", |
|
5405 |
"RomPagingDevice", |
|
5406 |
"CodePagingDevice", |
|
5407 |
"RomAndCodePagingDevice", |
|
5408 |
"DataPagingDevice", |
|
5409 |
"RomAndDataPagingDevice", |
|
5410 |
"CodeAndDataPagingDevice", |
|
5411 |
"RomAndCodeAndDataPagingDevice" |
|
5412 |
}; |
|
5413 |
||
5414 |
||
5415 |
if(aPagingType & DPagingDevice::ECode) |
|
5416 |
{ |
|
5417 |
for (i=0; i<aDriveCount; ++i) |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5418 |
pagingDevice->iDrivesSupported |= (0x1<<aPagingDriveList[i]); |
0 | 5419 |
} |
5420 |
pagingDevice->iName = DeviceName[aPagingType]; |
|
5421 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5422 |
// 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
|
5423 |
// delete it & then re-create it |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5424 |
__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
|
5425 |
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
|
5426 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5427 |
__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
|
5428 |
delete ThePinObjectAllocator; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5429 |
ThePinObjectAllocator = NULL; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5430 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5431 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5432 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5433 |
TInt r; |
0 | 5434 |
if (ThePinObjectAllocator == NULL) |
5435 |
{ |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5436 |
ThePinObjectAllocator = new DPinObjectAllocator(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5437 |
if(!ThePinObjectAllocator) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5438 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5439 |
__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
|
5440 |
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
|
5441 |
return KErrNoMemory; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5442 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5443 |
r = ThePinObjectAllocator->Construct(KDynamicPagingLockCount, aNumPages); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5444 |
if (r != KErrNone) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5445 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5446 |
__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
|
5447 |
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
|
5448 |
return r; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5449 |
} |
0 | 5450 |
} |
5451 |
||
5452 |
||
5453 |
// Register our DPagingDevice with the Kernel |
|
5454 |
r=Kern::InstallPagingDevice(pagingDevice); |
|
5455 |
||
5456 |
#ifdef __DEBUG_DEMAND_PAGING__ |
|
5457 |
Kern::Printf("Kern::InstallPagingDevice() r %d", r); |
|
5458 |
#endif |
|
5459 |
||
5460 |
if (r!=KErrNone) |
|
5461 |
{ |
|
5462 |
__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
|
5463 |
OstTrace1(TRACE_FLOW, LOVDRV_REGISTERPAGINGDEVICE_EXIT13, "< RegisterPagingDevice: could not install paging device; retval=%d", r); |
0 | 5464 |
delete pagingDevice; |
5465 |
return r; |
|
5466 |
} |
|
5467 |
||
5468 |
// all hunky dory, save paging device and mark our media as pageable |
|
5469 |
ThePagingDevices[aPrimaryMedia->iMediaId] = pagingDevice; // association created between PrimaryMedia and PagingDevice via iMediaId |
|
5470 |
aPrimaryMedia->iPagingMedia = 1; |
|
5471 |
||
5472 |
// mark our drives as pageable |
|
5473 |
p=aPagingDriveList; |
|
5474 |
if (aPagingType&DPagingDevice::ECode) |
|
5475 |
{ |
|
5476 |
for (i=0; i<aDriveCount; ++i) |
|
5477 |
{ |
|
5478 |
TLocDrv* pD=TheDrives[*p++]; |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5479 |
pD->iPagingDrv = 1; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5480 |
// 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
|
5481 |
// 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
|
5482 |
while (pD->iNextDrive) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5483 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5484 |
pD->iNextDrive->iPagingDrv = 1; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5485 |
pD = pD->iNextDrive; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5486 |
} |
0 | 5487 |
} |
5488 |
} |
|
5489 |
||
5490 |
// Flags to indicate that a paging device is registered and pinning of user requests may be required |
|
5491 |
aPrimaryMedia->iPagingMedia = 1; |
|
5492 |
||
5493 |
// point the primary media to the paging device |
|
5494 |
aPrimaryMedia->iBody->iPagingDevice = pagingDevice; |
|
5495 |
||
5496 |
if (aPagingType & DPagingDevice::ERom) |
|
5497 |
{ |
|
5498 |
aPrimaryMedia->iRomPagingMedia = 1; |
|
5499 |
TheRomPagingMedia = aPrimaryMedia; |
|
5500 |
} |
|
5501 |
||
5502 |
// Is data paging enabled in this ROM ? |
|
5503 |
TInt memModelAttributes = Kern::HalFunction(EHalGroupKernel, EKernelHalMemModelInfo, NULL, NULL); |
|
5504 |
TBool dataPagingSupported = memModelAttributes & EMemModelAttrDataPaging; |
|
5505 |
#ifdef __DEBUG_DEMAND_PAGING__ |
|
5506 |
Kern::Printf("memModelAttributes %08X", memModelAttributes); |
|
5507 |
Kern::Printf("DataPagingSupported %d", dataPagingSupported); |
|
5508 |
#endif |
|
5509 |
if (!dataPagingSupported) |
|
5510 |
{ |
|
5511 |
#ifdef __DEBUG_DEMAND_PAGING__ |
|
5512 |
if (aPagingType & DPagingDevice::EData) |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5513 |
{ |
0 | 5514 |
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
|
5515 |
} |
0 | 5516 |
#endif |
5517 |
aPagingType&= ~DPagingDevice::EData; |
|
5518 |
} |
|
5519 |
||
5520 |
||
5521 |
if (aPagingType & DPagingDevice::EData) |
|
5522 |
{ |
|
5523 |
DataPagingDeviceRegistered = ETrue; |
|
5524 |
aPrimaryMedia->iDataPagingMedia = 1; |
|
5525 |
TheDataPagingMedia = aPrimaryMedia; |
|
5526 |
} |
|
5527 |
||
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5528 |
__KTRACE_OPT2(KBOOT,KLOCDPAGING,Kern::Printf("< RegisterPagingDevice")); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5529 |
OstTraceFunctionExit0( LOCDRV_REGISTERPAGINGDEVICE_EXIT14 ); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5530 |
// CLRDEBUGFLAG(KLOCDPAGING); |
0 | 5531 |
return KErrNone; |
5532 |
} |
|
5533 |
||
5534 |
#else //__DEMAND_PAGING__ |
|
5535 |
||
5536 |
#if !defined(__WINS__) |
|
5537 |
EXPORT_C TInt LocDrv::RegisterPagingDevice(DPrimaryMediaBase* , const TInt* , TInt , TUint , TInt , TUint ) |
|
5538 |
{ |
|
5539 |
return KErrNotSupported; |
|
5540 |
} // stub for def file |
|
5541 |
#endif // __WINS__ |
|
5542 |
||
5543 |
#endif //__DEMAND_PAGING__ |
|
5544 |
||
5545 |
||
5546 |
/** |
|
5547 |
Registers a media device with physical memory addressing capabilities with the |
|
5548 |
Local Media Subsystem. |
|
5549 |
||
5550 |
@param aPrimaryMedia A pointer to the primary DPrimaryMedia object associated |
|
5551 |
with the media device. |
|
5552 |
@param aMediaBlockSize The Minimum transfer size (bytes) for the media device. |
|
5553 |
@param aDmaMaxAddressable The Maximum Addressing Range for the media device's DMA controller, 0 if None. |
|
5554 |
@param aDmaAlignment The required memory alignment for the media device's DMA controller. |
|
5555 |
||
5556 |
@return KErrNone, Always; |
|
5557 |
*/ |
|
5558 |
EXPORT_C TInt LocDrv::RegisterDmaDevice(DPrimaryMediaBase* aPrimaryMedia, |
|
5559 |
TInt aMediaBlockSize, // Minimum transfer size (bytes) for the media |
|
5560 |
TInt aDmaMaxAddressable, // Max Addressing Range for DMA controller, 0 if None. |
|
5561 |
TInt aDmaAlignment) // DMA Alignment e.g. word alignment required = 2 |
|
5562 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5563 |
OstTraceFunctionEntry0( LOCDRV_REGISTERDMADEVICE_ENTRY ); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5564 |
|
0 | 5565 |
__KTRACE_OPT(KBOOT ,Kern::Printf("RegisterPhysicalAddrDevice: PM=0x%x BS=%d MaxAddr=%d DMA=%d", |
5566 |
aPrimaryMedia, aMediaBlockSize, aDmaMaxAddressable, aDmaAlignment)); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5567 |
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
|
5568 |
|
0 | 5569 |
for (TInt i=0; i<KMaxLocalDrives; ++i) |
5570 |
{ |
|
5571 |
TLocDrv* pL=TheDrives[i]; |
|
5572 |
if (pL && pL->iPrimaryMedia == aPrimaryMedia && pL->iDmaHelper == NULL) |
|
5573 |
{ |
|
5574 |
pL->iDmaHelper = new DDmaHelper; |
|
5575 |
__ASSERT_ALWAYS(pL != NULL, LOCM_FAULT()); |
|
5576 |
||
5577 |
// if no limit stated on addressing range use 1MB |
|
5578 |
TInt MaxAddress = aDmaMaxAddressable ? (1024*1024) : aDmaMaxAddressable; |
|
5579 |
||
5580 |
TInt r = pL->iDmaHelper->Construct(MaxAddress, aMediaBlockSize, aDmaAlignment); |
|
5581 |
__ASSERT_ALWAYS(r == KErrNone, LOCM_FAULT()); |
|
5582 |
} |
|
5583 |
} |
|
5584 |
||
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5585 |
OstTraceFunctionExit0( LOCDRV_REGISTERDMADEVICE_EXIT ); |
0 | 5586 |
return KErrNone; |
5587 |
} |
|
5588 |
||
5589 |
void GetDriveInfo(TDriveInfoV1& info) |
|
5590 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5591 |
OstTraceFunctionEntry1( GETDRIVEINFO_ENTRY, ( TUint )&( info ) ); |
0 | 5592 |
TInt i; |
5593 |
TInt drives=0; |
|
5594 |
TUint32 sock_mask=0; |
|
5595 |
TInt sockets=0; |
|
5596 |
||
5597 |
info.iRegisteredDriveBitmask = 0; |
|
5598 |
||
5599 |
for (i=0; i<KMaxPBusSockets; ++i) |
|
5600 |
info.iSocketName[i].Zero(); |
|
5601 |
for (i=0; i<KMaxLocalDrives; ++i) |
|
5602 |
{ |
|
5603 |
TLocDrv* pL=TheDrives[i]; |
|
5604 |
if (pL) |
|
5605 |
{ |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5606 |
pL = TDriveIterator::GetPhysicalDrive(TheDrives[i]); |
0 | 5607 |
++drives; |
5608 |
TInt sockNum; |
|
5609 |
DPrimaryMediaBase* pM=pL->iPrimaryMedia; |
|
5610 |
if (pM->IsRemovableDevice(sockNum)) |
|
5611 |
{ |
|
5612 |
if (!(sock_mask & (1<<sockNum))) |
|
5613 |
{ |
|
5614 |
info.iSocketName[sockNum]=*DriveNames[i]; |
|
5615 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("Socket %d device %d name %lS", sockNum, pM->iDevice, DriveNames[i])); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5616 |
OstTraceExt2( TRACE_INTERNALS, GETDRIVEINFO1, "Socket=%d; device=%d", sockNum, (TUint) pM->iDevice ); |
0 | 5617 |
if ( (sockNum + 1) > sockets ) |
5618 |
sockets = sockNum + 1; |
|
5619 |
} |
|
5620 |
sock_mask |= (1<<sockNum); |
|
5621 |
} |
|
5622 |
info.iDriveName[i]=*DriveNames[i]; |
|
5623 |
__KTRACE_OPT(KLOCDRV,Kern::Printf("Drive %d device %d name %lS",i,pM->iDevice,DriveNames[i])); |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5624 |
OstTraceExt2( TRACE_INTERNALS, GETDRIVEINFO2, "Drive=%d; device=%d", i, (TUint) pM->iDevice ); |
0 | 5625 |
|
5626 |
info.iRegisteredDriveBitmask |= (0x01 << i); |
|
5627 |
} |
|
5628 |
} |
|
5629 |
info.iTotalSupportedDrives=drives; |
|
5630 |
info.iTotalSockets=sockets; |
|
5631 |
info.iRuggedFileSystem=ETrue; |
|
5632 |
__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
|
5633 |
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
|
5634 |
OstTraceFunctionExit0( GETDRIVEINFO_EXIT ); |
0 | 5635 |
} |
5636 |
||
5637 |
#if defined(__DEMAND_PAGING__) && defined(__CONCURRENT_PAGING_INSTRUMENTATION__) |
|
5638 |
void ResetConcurrencyStats(DMediaPagingDevice* aDevice, TMediaPagingStats aStats) |
|
5639 |
{ |
|
5640 |
NKern::FMWait(&aDevice->iInstrumentationLock); |
|
5641 |
switch(aStats) |
|
5642 |
{ |
|
5643 |
case EMediaPagingStatsRom: |
|
5644 |
aDevice->iServicingROM=0; |
|
5645 |
memclr(&aDevice->iROMStats,sizeof(SMediaROMPagingConcurrencyInfo)); |
|
5646 |
break; |
|
5647 |
case EMediaPagingStatsCode: |
|
5648 |
aDevice->iServicingCode=0; |
|
5649 |
memclr(&aDevice->iCodeStats,sizeof(SMediaCodePagingConcurrencyInfo)); |
|
5650 |
break; |
|
5651 |
case EMediaPagingStatsDataIn: |
|
5652 |
aDevice->iServicingDataIn=0; |
|
5653 |
memclr(&aDevice->iDataStats,sizeof(SMediaDataPagingConcurrencyInfo)); |
|
5654 |
break; |
|
5655 |
case EMediaPagingStatsDataOut: |
|
5656 |
aDevice->iServicingDataOut=0; |
|
5657 |
memclr(&aDevice->iDataStats,sizeof(SMediaDataPagingConcurrencyInfo)); |
|
5658 |
break; |
|
5659 |
case EMediaPagingStatsAll: |
|
5660 |
aDevice->iServicingROM=0; |
|
5661 |
aDevice->iServicingCode=0; |
|
5662 |
aDevice->iServicingDataIn=0; |
|
5663 |
aDevice->iServicingDataOut=0; |
|
5664 |
memclr(&aDevice->iROMStats,sizeof(SMediaROMPagingConcurrencyInfo)); |
|
5665 |
memclr(&aDevice->iCodeStats,sizeof(SMediaCodePagingConcurrencyInfo)); |
|
5666 |
memclr(&aDevice->iDataStats,sizeof(SMediaDataPagingConcurrencyInfo)); |
|
5667 |
break; |
|
5668 |
} |
|
5669 |
NKern::FMSignal(&aDevice->iInstrumentationLock); |
|
5670 |
} |
|
5671 |
#endif |
|
5672 |
#if defined(__DEMAND_PAGING__) && defined(__DEMAND_PAGING_BENCHMARKS__) |
|
5673 |
void ResetBenchmarkStats(DMediaPagingDevice* aDevice, TMediaPagingStats aStats) |
|
5674 |
{ |
|
5675 |
NKern::FMWait(&aDevice->iInstrumentationLock); |
|
5676 |
switch(aStats) |
|
5677 |
{ |
|
5678 |
case EMediaPagingStatsRom: |
|
5679 |
aDevice->iROMBenchmarkData.iCount = 0; |
|
5680 |
aDevice->iROMBenchmarkData.iTotalTime = 0; |
|
5681 |
aDevice->iROMBenchmarkData.iMaxTime = 0; |
|
5682 |
aDevice->iROMBenchmarkData.iMinTime = KMaxTInt; |
|
5683 |
break; |
|
5684 |
case EMediaPagingStatsCode: |
|
5685 |
aDevice->iCodeBenchmarkData.iCount = 0; |
|
5686 |
aDevice->iCodeBenchmarkData.iTotalTime = 0; |
|
5687 |
aDevice->iCodeBenchmarkData.iMaxTime = 0; |
|
5688 |
aDevice->iCodeBenchmarkData.iMinTime = KMaxTInt; |
|
5689 |
break; |
|
5690 |
case EMediaPagingStatsDataIn: |
|
5691 |
aDevice->iDataInBenchmarkData.iCount = 0; |
|
5692 |
aDevice->iDataInBenchmarkData.iTotalTime = 0; |
|
5693 |
aDevice->iDataInBenchmarkData.iMaxTime = 0; |
|
5694 |
aDevice->iDataInBenchmarkData.iMinTime = KMaxTInt; |
|
5695 |
break; |
|
5696 |
case EMediaPagingStatsDataOut: |
|
5697 |
aDevice->iDataOutBenchmarkData.iCount = 0; |
|
5698 |
aDevice->iDataOutBenchmarkData.iTotalTime = 0; |
|
5699 |
aDevice->iDataOutBenchmarkData.iMaxTime = 0; |
|
5700 |
aDevice->iDataOutBenchmarkData.iMinTime = KMaxTInt; |
|
5701 |
break; |
|
5702 |
case EMediaPagingStatsAll: |
|
5703 |
aDevice->iDataInBenchmarkData.iCount = 0; |
|
5704 |
aDevice->iDataInBenchmarkData.iTotalTime = 0; |
|
5705 |
aDevice->iDataInBenchmarkData.iMaxTime = 0; |
|
5706 |
aDevice->iDataInBenchmarkData.iMinTime = KMaxTInt; |
|
5707 |
||
5708 |
aDevice->iDataOutBenchmarkData.iCount = 0; |
|
5709 |
aDevice->iDataOutBenchmarkData.iTotalTime = 0; |
|
5710 |
aDevice->iDataOutBenchmarkData.iMaxTime = 0; |
|
5711 |
aDevice->iDataOutBenchmarkData.iMinTime = KMaxTInt; |
|
5712 |
||
5713 |
aDevice->iROMBenchmarkData.iCount = 0; |
|
5714 |
aDevice->iROMBenchmarkData.iTotalTime = 0; |
|
5715 |
aDevice->iROMBenchmarkData.iMaxTime = 0; |
|
5716 |
aDevice->iROMBenchmarkData.iMinTime = KMaxTInt; |
|
5717 |
||
5718 |
aDevice->iCodeBenchmarkData.iCount = 0; |
|
5719 |
aDevice->iCodeBenchmarkData.iTotalTime = 0; |
|
5720 |
aDevice->iCodeBenchmarkData.iMaxTime = 0; |
|
5721 |
aDevice->iCodeBenchmarkData.iMinTime = KMaxTInt; |
|
5722 |
break; |
|
5723 |
} |
|
5724 |
NKern::FMSignal(&aDevice->iInstrumentationLock); |
|
5725 |
} |
|
5726 |
#endif |
|
5727 |
||
5728 |
TInt MediaHalFunction(TAny*, TInt aFunction, TAny* a1, TAny* a2) |
|
5729 |
{ |
|
5730 |
TInt r=KErrNotSupported; |
|
5731 |
switch (aFunction) |
|
5732 |
{ |
|
5733 |
case EMediaHalDriveInfo: |
|
5734 |
{ |
|
5735 |
(void) a2; |
|
5736 |
TDriveInfoV1Buf infoBuf; |
|
5737 |
TDriveInfoV1& info=infoBuf(); |
|
5738 |
GetDriveInfo(info); |
|
5739 |
Kern::InfoCopy(*(TDes8*)a1,infoBuf); |
|
5740 |
r=KErrNone; |
|
5741 |
break; |
|
5742 |
} |
|
5743 |
#if defined(__DEMAND_PAGING__) && defined(__CONCURRENT_PAGING_INSTRUMENTATION__) |
|
5744 |
case EMediaHalGetROMConcurrencyInfo: |
|
5745 |
{ |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5746 |
DMediaPagingDevice* device = TDriveIterator::PagingDevice((TInt)a1, DPagingDevice::ERom); |
0 | 5747 |
if(!device) |
5748 |
break; |
|
5749 |
NKern::FMWait(&device->iInstrumentationLock); |
|
5750 |
SMediaROMPagingConcurrencyInfo info=device->iROMStats; |
|
5751 |
NKern::FMSignal(&device->iInstrumentationLock); |
|
5752 |
kumemput32(a2,&info,sizeof(info)); |
|
5753 |
r=KErrNone; |
|
5754 |
break; |
|
5755 |
} |
|
5756 |
case EMediaHalGetCodeConcurrencyInfo: |
|
5757 |
{ |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5758 |
DMediaPagingDevice* device = TDriveIterator::PagingDevice((TInt)a1, DPagingDevice::ECode); |
0 | 5759 |
if(!device) |
5760 |
break; |
|
5761 |
NKern::FMWait(&device->iInstrumentationLock); |
|
5762 |
SMediaCodePagingConcurrencyInfo info=device->iCodeStats; |
|
5763 |
NKern::FMSignal(&device->iInstrumentationLock); |
|
5764 |
kumemput32(a2,&info,sizeof(info)); |
|
5765 |
r=KErrNone; |
|
5766 |
break; |
|
5767 |
} |
|
5768 |
case EMediaHalGetDataConcurrencyInfo: |
|
5769 |
{ |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5770 |
DMediaPagingDevice* device = TDriveIterator::PagingDevice((TInt)a1, DPagingDevice::EData); |
0 | 5771 |
if(!device) |
5772 |
break; |
|
5773 |
NKern::FMWait(&device->iInstrumentationLock); |
|
5774 |
SMediaDataPagingConcurrencyInfo info=device->iDataStats; |
|
5775 |
NKern::FMSignal(&device->iInstrumentationLock); |
|
5776 |
kumemput32(a2,&info,sizeof(info)); |
|
5777 |
r=KErrNone; |
|
5778 |
break; |
|
5779 |
} |
|
5780 |
case EMediaHalResetConcurrencyInfo: |
|
5781 |
{ |
|
5782 |
TUint index=(TInt)a2; |
|
5783 |
if(index>EMediaPagingStatsCode) |
|
5784 |
break; |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5785 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5786 |
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
|
5787 |
if (device) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5788 |
ResetConcurrencyStats(device, (TMediaPagingStats)index); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5789 |
device = TDriveIterator::PagingDevice((TInt)a1, DPagingDevice::ECode); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5790 |
if (device) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5791 |
ResetConcurrencyStats(device, (TMediaPagingStats)index); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5792 |
device = TDriveIterator::PagingDevice((TInt)a1, DPagingDevice::EData); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5793 |
if (device) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5794 |
ResetConcurrencyStats(device, (TMediaPagingStats)index); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5795 |
|
0 | 5796 |
r=KErrNone; |
5797 |
break; |
|
5798 |
} |
|
5799 |
#endif |
|
5800 |
#if defined(__DEMAND_PAGING__) && defined(__DEMAND_PAGING_BENCHMARKS__) |
|
5801 |
case EMediaHalGetROMPagingBenchmark: |
|
5802 |
{ |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5803 |
DMediaPagingDevice* device = TDriveIterator::PagingDevice((TInt)a1, DPagingDevice::ERom); |
0 | 5804 |
if(!device) |
5805 |
break; |
|
5806 |
NKern::FMWait(&device->iInstrumentationLock); |
|
5807 |
SPagingBenchmarkInfo info = device->iROMBenchmarkData; |
|
5808 |
NKern::FMSignal(&device->iInstrumentationLock); |
|
5809 |
kumemput32(a2,&info,sizeof(info)); |
|
5810 |
r=KErrNone; |
|
5811 |
break; |
|
5812 |
} |
|
5813 |
case EMediaHalGetCodePagingBenchmark: |
|
5814 |
{ |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5815 |
DMediaPagingDevice* device = TDriveIterator::PagingDevice((TInt)a1, DPagingDevice::ECode); |
0 | 5816 |
if(!device) |
5817 |
break; |
|
5818 |
NKern::FMWait(&device->iInstrumentationLock); |
|
5819 |
SPagingBenchmarkInfo info = device->iCodeBenchmarkData; |
|
5820 |
NKern::FMSignal(&device->iInstrumentationLock); |
|
5821 |
kumemput32(a2,&info,sizeof(info)); |
|
5822 |
r=KErrNone; |
|
5823 |
break; |
|
5824 |
} |
|
5825 |
case EMediaHalGetDataInPagingBenchmark: |
|
5826 |
{ |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5827 |
DMediaPagingDevice* device = TDriveIterator::PagingDevice((TInt)a1, DPagingDevice::EData); |
0 | 5828 |
if(!device) |
5829 |
break; |
|
5830 |
NKern::FMWait(&device->iInstrumentationLock); |
|
5831 |
SPagingBenchmarkInfo info = device->iDataInBenchmarkData; |
|
5832 |
NKern::FMSignal(&device->iInstrumentationLock); |
|
5833 |
kumemput32(a2,&info,sizeof(info)); |
|
5834 |
r=KErrNone; |
|
5835 |
break; |
|
5836 |
} |
|
5837 |
case EMediaHalGetDataOutPagingBenchmark: |
|
5838 |
{ |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5839 |
DMediaPagingDevice* device = TDriveIterator::PagingDevice((TInt)a1, DPagingDevice::EData); |
0 | 5840 |
if(!device) |
5841 |
break; |
|
5842 |
NKern::FMWait(&device->iInstrumentationLock); |
|
5843 |
SPagingBenchmarkInfo info = device->iDataOutBenchmarkData; |
|
5844 |
NKern::FMSignal(&device->iInstrumentationLock); |
|
5845 |
kumemput32(a2,&info,sizeof(info)); |
|
5846 |
r=KErrNone; |
|
5847 |
break; |
|
5848 |
} |
|
5849 |
case EMediaHalResetPagingBenchmark: |
|
5850 |
{ |
|
5851 |
TUint index=(TInt)a2; |
|
5852 |
if(index>EMediaPagingStatsCode) |
|
5853 |
break; |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5854 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5855 |
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
|
5856 |
if (device) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5857 |
ResetBenchmarkStats(device, (TMediaPagingStats)index); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5858 |
device = TDriveIterator::PagingDevice((TInt)a1, DPagingDevice::ECode); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5859 |
if (device) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5860 |
ResetBenchmarkStats(device, (TMediaPagingStats)index); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5861 |
device = TDriveIterator::PagingDevice((TInt)a1, DPagingDevice::EData); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5862 |
if (device) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5863 |
ResetBenchmarkStats(device, (TMediaPagingStats)index); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5864 |
|
0 | 5865 |
r=KErrNone; |
5866 |
break; |
|
5867 |
} |
|
5868 |
case EMediaHalGetPagingInfo: |
|
5869 |
{ |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
5870 |
DMediaPagingDevice* device = TDriveIterator::PagingDevice((TInt)a1, (DPagingDevice::TType) 0xFF); |
0 | 5871 |
if(!device) |
5872 |
break; |
|
5873 |
NKern::FMWait(&device->iInstrumentationLock); |
|
5874 |
SMediaPagingInfo info = device->iMediaPagingInfo; |
|
5875 |
NKern::FMSignal(&device->iInstrumentationLock); |
|
5876 |
kumemput32(a2,&info,sizeof(info)); |
|
5877 |
r=KErrNone; |
|
5878 |
break; |
|
5879 |
} |
|
5880 |
#endif |
|
5881 |
default: |
|
5882 |
break; |
|
5883 |
} |
|
5884 |
return r; |
|
5885 |
} |
|
5886 |
||
5887 |
||
5888 |
/****************************************************************************** |
|
5889 |
Partition table scanner |
|
5890 |
******************************************************************************/ |
|
5891 |
||
5892 |
#ifdef _DEBUG |
|
5893 |
#define DMEMDUMP(base,size) DbgMemDump((TLinAddr)base,size) |
|
5894 |
void DbgMemDump(TLinAddr aBase, TInt aSize) |
|
5895 |
{ |
|
5896 |
TInt off; |
|
5897 |
const TUint8* p=(const TUint8*)aBase; |
|
5898 |
NKern::Lock(); |
|
5899 |
for (off=0; off<aSize; off+=16, p+=16) |
|
5900 |
{ |
|
5901 |
Kern::Printf("%04x: %02x %02x %02x %02x %02x %02x %02x %02x | %02x %02x %02x %02x %02x %02x %02x %02x", |
|
5902 |
off, p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], |
|
5903 |
p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]); |
|
5904 |
} |
|
5905 |
NKern::Unlock(); |
|
5906 |
} |
|
5907 |
#else |
|
5908 |
#define DMEMDUMP(base,size) |
|
5909 |
#endif |
|
5910 |
||
5911 |
EXPORT_C void TPartitionTableScanner::Set(TUint8* aSectorBuffer, TPartitionEntry* aEntry, TInt aMaxPartitions, TInt64 aMediaSize) |
|
5912 |
{ |
|
5913 |
__KTRACE_OPT(KLOCDRV, Kern::Printf("TPartitionTableScanner @ %08x : buf %08x entry %08x max %d sz %08x %08x", |
|
5914 |
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
|
5915 |
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 | 5916 |
__ASSERT_ALWAYS(aMaxPartitions>0, LOCM_FAULT()); |
5917 |
memclr(this, sizeof(TPartitionTableScanner)); |
|
5918 |
iLBA = -1; |
|
5919 |
iSectorBuffer = aSectorBuffer; |
|
5920 |
iFirstEntry = aEntry; |
|
5921 |
iNextEntry = aEntry; |
|
5922 |
iLimit = aEntry + aMaxPartitions; |
|
5923 |
iMediaSize = aMediaSize; |
|
5924 |
} |
|
5925 |
||
5926 |
EXPORT_C TInt TPartitionTableScanner::NumberOfPartitionsFound() const |
|
5927 |
{ |
|
5928 |
TInt n = iNextEntry - iFirstEntry; |
|
5929 |
__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
|
5930 |
OstTrace1( TRACE_INTERNALS, TPARTITIONTABLESCANNER_NUMBERPARTITIONS, "Number of partitions=%d", n ); |
0 | 5931 |
return n; |
5932 |
} |
|
5933 |
||
5934 |
TPartitionTableScanner::SPart::SPart(const TUint8* a) |
|
5935 |
{ |
|
5936 |
iBootInd = a[0]; |
|
5937 |
iType = a[4]; |
|
5938 |
iRSS = a[8]|(a[9]<<8)|(a[10]<<16)|(a[11]<<24); |
|
5939 |
iSectors = a[12]|(a[13]<<8)|(a[14]<<16)|(a[15]<<24); |
|
5940 |
__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
|
5941 |
OstTraceExt4(TRACE_INTERNALS, TPARTITIONTABLESCANNER_SPART_SPART, "SPart: iBootInd=%02x; iType=%02x; iRSS=%08x; iSectors=%08x", (TUint) iBootInd, (TUint) iType, (TUint) iRSS, (TUint) iSectors); |
0 | 5942 |
} |
5943 |
||
5944 |
TInt TPartitionTableScanner::MakeEntry(const SPart& a) |
|
5945 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5946 |
OstTraceFunctionEntry1( TPARTITIONTABLESCANNER_MAKEENTRY_ENTRY, this ); |
0 | 5947 |
if (iNextEntry == iLimit) |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5948 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5949 |
OstTraceFunctionExitExt( TPARTITIONTABLESCANNER_MAKEENTRY_EXIT1, this, KErrOverflow ); |
0 | 5950 |
return KErrOverflow; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5951 |
} |
0 | 5952 |
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
|
5953 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5954 |
OstTraceFunctionExitExt( TPARTITIONTABLESCANNER_MAKEENTRY_EXIT2, this, KErrCorrupt ); |
0 | 5955 |
return KErrCorrupt; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5956 |
} |
0 | 5957 |
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
|
5958 |
{ |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5959 |
OstTraceFunctionExitExt( TPARTITIONTABLESCANNER_MAKEENTRY_EXIT3, this, KErrCorrupt ); |
0 | 5960 |
return KErrCorrupt; |
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5961 |
} |
0 | 5962 |
iNextEntry->iBootIndicator = a.iBootInd; |
5963 |
iNextEntry->iPartitionType = a.iType; |
|
5964 |
iNextEntry->iPartitionBaseAddr = TInt64(a.iRSS)<<ESectorShift; |
|
5965 |
iNextEntry->iPartitionLen = TInt64(a.iSectors)<<ESectorShift; |
|
5966 |
++iNextEntry; |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5967 |
OstTraceFunctionExitExt( TPARTITIONTABLESCANNER_MAKEENTRY_EXIT4, this, KErrNone ); |
0 | 5968 |
return KErrNone; |
5969 |
} |
|
5970 |
||
5971 |
EXPORT_C TInt64 TPartitionTableScanner::NextLBA() |
|
5972 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
5973 |
OstTraceFunctionEntry0( TPARTITIONTABLESCANNER_NEXTLBA_ENTRY ); |
0 | 5974 |
__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
|
5975 |
OstTraceExt2( TRACE_INTERNALS, TPARTITIONTABLESCANNER_NEXTLBA1, "TPartitionTableScanner iLBA=%08x %08x", I64HIGH(iLBA), I64LOW(iLBA) ); |
0 | 5976 |
TInt r; |
5977 |
TUint8* b = iSectorBuffer; |
|
5978 |
TUint8* pS = b + 0x1be; |
|
5979 |
TUint8* pE = pS + 64; |
|
5980 |
TUint8* p = pS; |
|
5981 |
TInt orig_sp = iStackPointer; |
|
5982 |
TInt sp; |
|
5983 |
if (iLBA < 0) |
|
5984 |
{ |
|
5985 |
iLBA = 0; |
|
5986 |
goto end; |
|
5987 |
} |
|
5988 |
__KTRACE_OPT(KLOCDRV,DMEMDUMP(b, ESectorSize)); |
|
5989 |
if (b[ESectorSize-2]!=0x55 || b[ESectorSize-1]!=0xaa) |
|
5990 |
{ |
|
5991 |
__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
|
5992 |
OstTrace0( TRACE_INTERNALS, TPARTITIONTABLESCANNER_NEXTLBA2, "Bad signature" ); |
0 | 5993 |
iLBA = KErrCorrupt; |
5994 |
goto end; |
|
5995 |
} |
|
5996 |
if (iLBA==0 && iNextEntry==iFirstEntry) |
|
5997 |
{ |
|
5998 |
// Look for bootable partition first |
|
5999 |
for (; p<pE; p+=16) |
|
6000 |
{ |
|
6001 |
SPart pt(p); |
|
6002 |
if (pt.iBootInd==0x80 && pt.iType && pt.iSectors>0) |
|
6003 |
{ |
|
6004 |
p[4] = 0; |
|
6005 |
r = MakeEntry(pt); |
|
6006 |
if (r!=KErrNone) |
|
6007 |
{ |
|
6008 |
iLBA = r; |
|
6009 |
goto end; |
|
6010 |
} |
|
6011 |
} |
|
6012 |
} |
|
6013 |
} |
|
6014 |
// Look for extended partitions |
|
6015 |
for (p=pE-16; p>=pS; p-=16) |
|
6016 |
{ |
|
6017 |
SPart pt(p); |
|
6018 |
if ((pt.iType==0x05 || pt.iType==0x0f) && pt.iSectors>0) |
|
6019 |
{ |
|
6020 |
// This one is an EBR |
|
6021 |
p[4] = 0; |
|
6022 |
if (iStackPointer == EMaxNest) |
|
6023 |
{ |
|
6024 |
if (iStackPointer == orig_sp) |
|
6025 |
continue; |
|
6026 |
--iStackPointer; |
|
6027 |
for(sp = orig_sp; sp<iStackPointer; ++sp) |
|
6028 |
iStack[sp] = iStack[sp+1]; |
|
6029 |
} |
|
6030 |
iStack[iStackPointer].iRSS = pt.iRSS; |
|
6031 |
iStack[iStackPointer].iSectors = pt.iSectors; |
|
6032 |
++iStackPointer; |
|
6033 |
#ifdef _DEBUG |
|
6034 |
for (sp=0; sp<iStackPointer; ++sp) |
|
6035 |
{ |
|
6036 |
const TInt64& rss = iStack[sp].iRSS; |
|
6037 |
const TInt64& size = iStack[sp].iSectors; |
|
6038 |
__KTRACE_OPT(KLOCDRV, Kern::Printf("Stack[%d] RSS %08x %08x SIZE %08x %08x", sp, |
|
6039 |
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
|
6040 |
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 | 6041 |
} |
6042 |
#endif |
|
6043 |
} |
|
6044 |
} |
|
6045 |
// Look for other data partitions |
|
6046 |
for (p=pS; p<pE; p+=16) |
|
6047 |
{ |
|
6048 |
SPart pt(p); |
|
6049 |
if (pt.iType && pt.iSectors>0) |
|
6050 |
{ |
|
6051 |
pt.iRSS += TUint32(iLBA); // data partitions are specified relative to the EBR they appear in |
|
6052 |
r = MakeEntry(pt); |
|
6053 |
if (r!=KErrNone) |
|
6054 |
{ |
|
6055 |
iLBA = r; |
|
6056 |
goto end; |
|
6057 |
} |
|
6058 |
} |
|
6059 |
} |
|
6060 |
// If any EBRs on stack, pop off the first and process it |
|
6061 |
if (iStackPointer) |
|
6062 |
{ |
|
6063 |
--iStackPointer; |
|
6064 |
iLBA = iFirstEBR + iStack[iStackPointer].iRSS; // LBA of second and subsequent EBR is specified relative to first EBR |
|
6065 |
if (!iFirstEBR) |
|
6066 |
iFirstEBR = iLBA; |
|
6067 |
} |
|
6068 |
else |
|
6069 |
iLBA = KErrEof; // finished |
|
6070 |
||
6071 |
end: |
|
6072 |
__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
|
6073 |
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
|
6074 |
OstTraceFunctionExit0( TPARTITIONTABLESCANNER_NEXTLBA_EXIT ); |
0 | 6075 |
return iLBA; |
6076 |
} |
|
6077 |
||
6078 |
/** |
|
6079 |
* Returns Address and Length of next contiguous Physical memory fragment |
|
6080 |
* |
|
6081 |
* @param aAddr On success, populated with the Physical Address of the next fragment. |
|
6082 |
* @param aLen On success, populated with the length in bytes of the next fragment. |
|
6083 |
* |
|
6084 |
* @return KErrNone, if successful; |
|
6085 |
* KErrNoMemory, if no more memory fragments left. |
|
6086 |
* KErrNotSupported, if Physical Memory addressing is not supported by this Media. |
|
6087 |
*/ |
|
6088 |
EXPORT_C TInt TLocDrvRequest::GetNextPhysicalAddress(TPhysAddr& aAddr, TInt& aLen) |
|
6089 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
6090 |
OstTraceExt2(TRACE_FLOW, TLOCDRVREQUEST_GETNEXTPHYSICALADDRESS_ENTRY, "> TLocDrvRequest::GetNextPhysicalAddress;aAddr=%x;aLen=%d;", (TUint) &aAddr, aLen ); |
0 | 6091 |
if (Flags() & EPhysAddr) |
6092 |
{ |
|
6093 |
#ifdef __DEMAND_PAGING__ |
|
6094 |
if (DMediaPagingDevice::PagingRequest(*this)) |
|
6095 |
{ |
|
6096 |
return DDmaHelper::GetPhysicalAddress(*this, aAddr, aLen); |
|
6097 |
} |
|
6098 |
#endif |
|
6099 |
return Drive()->iDmaHelper->GetPhysicalAddress(aAddr, aLen); |
|
6100 |
} |
|
6101 |
else |
|
6102 |
{ |
|
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
6103 |
OstTraceFunctionExitExt( TLOCDRVREQUEST_GETNEXTPHYSICALADDRESS_EXIT, this, KErrNotSupported ); |
0 | 6104 |
return KErrNotSupported; |
6105 |
} |
|
6106 |
} |
|
6107 |
||
6108 |
||
6109 |
/****************************************************************************** |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6110 |
DMediaDriverExtension base class |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6111 |
******************************************************************************/ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6112 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6113 |
EXPORT_C DMediaDriverExtension::DMediaDriverExtension(TInt aMediaId) : |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6114 |
DMediaDriver(aMediaId) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6115 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6116 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6117 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6118 |
/** |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6119 |
*/ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6120 |
EXPORT_C DMediaDriverExtension::~DMediaDriverExtension() |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6121 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6122 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6123 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6124 |
/** |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6125 |
Closes the media driver. |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6126 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6127 |
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
|
6128 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6129 |
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
|
6130 |
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
|
6131 |
cancelling a DFC. |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6132 |
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
|
6133 |
the last instruction. |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6134 |
*/ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6135 |
EXPORT_C void DMediaDriverExtension::Close() |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6136 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6137 |
DMediaDriver::Close(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6138 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6139 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6140 |
/** |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6141 |
DoDrivePartitionInfo() |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6142 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6143 |
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
|
6144 |
*/ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6145 |
EXPORT_C TInt DMediaDriverExtension::DoDrivePartitionInfo(TPartitionInfo& aInfo) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6146 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6147 |
memclr(&aInfo, sizeof(aInfo)); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6148 |
aInfo.iPartitionCount = 0; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6149 |
aInfo.iMediaSizeInBytes = 0; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6150 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6151 |
TDriveIterator driveIter; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6152 |
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
|
6153 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6154 |
if (drv && drv->iPrimaryMedia == iPrimaryMedia) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6155 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6156 |
TLocDrv* attachedDrive = drv->iNextDrive; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6157 |
__ASSERT_DEBUG(attachedDrive, LOCM_FAULT()); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6158 |
TLocDrvRequest m; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6159 |
memclr(&m, sizeof(m)); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6160 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6161 |
// 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
|
6162 |
// 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
|
6163 |
TBuf8<KMaxLocalDriveCapsLength> capsBuf; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6164 |
TInt i; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6165 |
const TInt KRetries = 5; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6166 |
TInt r = KErrNotReady; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6167 |
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
|
6168 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6169 |
capsBuf.SetMax(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6170 |
capsBuf.FillZ(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6171 |
m.Drive() = attachedDrive; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6172 |
m.Id() = DLocalDrive::ECaps; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6173 |
m.RemoteDes() = (TAny*)capsBuf.Ptr(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6174 |
m.Length() = KMaxLocalDriveCapsLength; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6175 |
r = attachedDrive->iPrimaryMedia->Request(m); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6176 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6177 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6178 |
__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
|
6179 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6180 |
// 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
|
6181 |
// 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
|
6182 |
if (r == KErrNone) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6183 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6184 |
aInfo.iEntry[aInfo.iPartitionCount] = *attachedDrive; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6185 |
// 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
|
6186 |
// 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
|
6187 |
// 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
|
6188 |
// 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
|
6189 |
aInfo.iMediaSizeInBytes = Max( |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6190 |
aInfo.iMediaSizeInBytes, |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6191 |
((TLocalDriveCapsV4*) capsBuf.Ptr())->MediaSizeInBytes()); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6192 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6193 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6194 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6195 |
aInfo.iPartitionCount++; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6196 |
} |
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 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6199 |
return KErrNone; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6200 |
} |
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 |
ForwardRequest() - |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6204 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6205 |
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
|
6206 |
*/ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6207 |
EXPORT_C TInt DMediaDriverExtension::ForwardRequest(TLocDrvRequest& aRequest) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6208 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6209 |
TLocDrv* drive = aRequest.Drive(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6210 |
TLocDrv* attachedDrive = drive->iNextDrive; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6211 |
__ASSERT_DEBUG(attachedDrive, LOCM_FAULT()); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6212 |
aRequest.Drive() = attachedDrive; |
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 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6215 |
TInt r = attachedDrive->iPrimaryMedia->HandleMediaNotPresent(aRequest); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6216 |
if (r != KErrNone) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6217 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6218 |
return r; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6219 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6220 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6221 |
aRequest.Forward(&attachedDrive->iPrimaryMedia->iMsgQ, EFalse); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6222 |
return KErrNone; |
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 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6225 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6226 |
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
|
6227 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6228 |
__ASSERT_DEBUG(aLen > 0, LOCM_FAULT()); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6229 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6230 |
// 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
|
6231 |
if (!(iPrimaryMedia->iBody->iRegisteredDriveMask & (0x1 << aDriveNumber))) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6232 |
return KErrArgument; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6233 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6234 |
TLocDrv* drive = TDriveIterator::GetDrive(aDriveNumber, iPrimaryMedia); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6235 |
__ASSERT_DEBUG(drive, LOCM_FAULT()); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6236 |
TLocDrv* attachedDrive = drive->iNextDrive; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6237 |
__ASSERT_DEBUG(attachedDrive, LOCM_FAULT()); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6238 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6239 |
TLocDrvRequest request; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6240 |
memclr(&request, sizeof(request)); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6241 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6242 |
request.Drive() = attachedDrive; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6243 |
request.Id() = aReqId; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6244 |
request.Length() = aLen; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6245 |
request.RemoteDes() = (TAny*) aData; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6246 |
request.Pos() = aPos; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6247 |
request.Flags() = TLocDrvRequest::EKernelBuffer | TLocDrvRequest::EAdjusted; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6248 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6249 |
#ifdef __DEMAND_PAGING__ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6250 |
if (aPagingRequest) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6251 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6252 |
request.Flags()|= TLocDrvRequest::EPaging; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6253 |
// 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
|
6254 |
// 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
|
6255 |
const TInt KPageSizeMask = 4096-1; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6256 |
if (aData & KPageSizeMask) |
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 |
return attachedDrive->iPrimaryMedia->SendReceive(request, aData); |
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 |
else |
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 |
attachedDrive->iPrimaryMedia->iBody->iPagingDevice->SendToMainQueueDfcAndBlock(&request); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6263 |
return 0; |
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 |
#else |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6267 |
aPagingRequest; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6268 |
#endif |
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 |
return attachedDrive->iPrimaryMedia->SendReceive(request, aData); |
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 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6273 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6274 |
/** |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6275 |
Read() - |
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 |
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
|
6278 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6279 |
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
|
6280 |
media, not the partition |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6281 |
*/ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6282 |
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
|
6283 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6284 |
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
|
6285 |
} |
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 |
Write() - |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6289 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6290 |
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
|
6291 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6292 |
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
|
6293 |
media, not the partition |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6294 |
*/ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6295 |
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
|
6296 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6297 |
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
|
6298 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6299 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6300 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6301 |
#ifdef __DEMAND_PAGING__ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6302 |
/** |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6303 |
ReadPaged() - |
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 |
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
|
6306 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6307 |
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
|
6308 |
media, not the partition |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6309 |
*/ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6310 |
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
|
6311 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6312 |
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
|
6313 |
} |
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 |
/** |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6316 |
WritePaged() - |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6317 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6318 |
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
|
6319 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6320 |
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
|
6321 |
media, not the partition |
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 |
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
|
6324 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6325 |
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
|
6326 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6327 |
#endif // __DEMAND_PAGING__ |
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 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6330 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6331 |
/** |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6332 |
Caps() - |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6333 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6334 |
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
|
6335 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6336 |
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
|
6337 |
media, not the partition |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6338 |
*/ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6339 |
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
|
6340 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6341 |
// 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
|
6342 |
if (!(iPrimaryMedia->iBody->iRegisteredDriveMask & (0x1 << aDriveNumber))) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6343 |
return KErrArgument; |
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 |
TLocDrv* drive = TDriveIterator::GetDrive(aDriveNumber, iPrimaryMedia); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6346 |
__ASSERT_DEBUG(drive, LOCM_FAULT()); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6347 |
TLocDrv* attachedDrive = drive->iNextDrive; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6348 |
__ASSERT_DEBUG(attachedDrive, LOCM_FAULT()); |
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 |
TLocDrvRequest request; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6351 |
memclr(&request, sizeof(request)); |
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 |
request.Drive() = attachedDrive; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6354 |
request.Id() = DLocalDrive::ECaps; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6355 |
request.Length() = aCaps.Length(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6356 |
request.RemoteDes() = (TAny*) aCaps.Ptr(); |
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 |
return request.SendReceive(&attachedDrive->iPrimaryMedia->iMsgQ); |
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 |
|
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 |
EXPORT_C void DMediaDriverExtension::NotifyPowerDown() |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6364 |
{ |
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 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6367 |
EXPORT_C void DMediaDriverExtension::NotifyEmergencyPowerDown() |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6368 |
{ |
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 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6371 |
|
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 |
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
|
6374 |
*/ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6375 |
EXPORT_C TBool DMediaDriverExtension::MediaBusy(TInt aDriveNumber) |
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 |
for (TLocDrv* drive = TDriveIterator::GetDrive(aDriveNumber, iPrimaryMedia); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6378 |
drive; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6379 |
drive = drive->iNextDrive) |
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 |
DPrimaryMediaBase* primaryMedia = drive->iPrimaryMedia; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6382 |
__ASSERT_DEBUG(primaryMedia, LOCM_FAULT()); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6383 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6384 |
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
|
6385 |
!primaryMedia->iMsgQ.iQ.IsEmpty() || |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6386 |
primaryMedia->iBody->iMediaChangeDfc.Queued() || |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6387 |
primaryMedia->iBody->iMediaPresentDfc.Queued()) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6388 |
return ETrue; |
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 |
#ifdef __DEMAND_PAGING__ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6391 |
DMediaPagingDevice* pagingDevice = iPrimaryMedia->iBody->iPagingDevice; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6392 |
if (pagingDevice) |
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 |
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
|
6395 |
!pagingDevice->iMainQ.iQ.IsEmpty()) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6396 |
return ETrue; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6397 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6398 |
#endif |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6399 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6400 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6401 |
return EFalse; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6402 |
} |
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 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6405 |
TCallBackLink::TCallBackLink() |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6406 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6407 |
memclr(this, sizeof(this)); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6408 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6409 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6410 |
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
|
6411 |
iFunction(aFunction), iPtr(aPtr), iObjectType(aObjectType) |
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 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6414 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6415 |
TInt TCallBackLink::CallBack(TInt aParam) const |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6416 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6417 |
return (*iFunction)(iPtr, aParam); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6418 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6419 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6420 |
/****************************************************************************** |
0 | 6421 |
Entry point |
6422 |
******************************************************************************/ |
|
6423 |
DECLARE_STANDARD_EXTENSION() |
|
6424 |
{ |
|
6425 |
__KTRACE_OPT(KBOOT,Kern::Printf("Starting LOCMEDIA extension")); |
|
6426 |
||
6427 |
// install the HAL function |
|
6428 |
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
|
6429 |
|
0 | 6430 |
#ifdef __DEMAND_PAGING__ |
6431 |
if (r==KErrNone) |
|
6432 |
{ |
|
6433 |
__KTRACE_OPT(KBOOT,Kern::Printf("Creating LocDrv device")); |
|
6434 |
DLocalDriveFactory* device = new DLocalDriveFactory; |
|
6435 |
if (device==NULL) |
|
6436 |
r=KErrNoMemory; |
|
6437 |
else |
|
6438 |
r=Kern::InstallLogicalDevice(device); |
|
6439 |
__KTRACE_OPT(KBOOT,Kern::Printf("Installing LocDrv device in kernel returned %d",r)); |
|
6440 |
} |
|
6441 |
#endif // __DEMAND_PAGING__ |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
6442 |
|
0 | 6443 |
return r; |
6444 |
} |
|
6445 |
||
6446 |