author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Mon, 21 Jun 2010 17:12:14 +0300 | |
branch | RCL_3 |
changeset 198 | 2bb754abd467 |
parent 80 | 597aaf25e343 |
child 291 | 206a6eaaeb71 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 1997-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 |
// e32test\mmu\d_shadow.cpp |
|
15 |
// LDD for testing ROM shadowing |
|
16 |
// |
|
17 |
// |
|
18 |
||
19 |
#include <kernel/kern_priv.h> |
|
20 |
#include "platform.h" |
|
21 |
#include <kernel/cache.h> |
|
22 |
#include "d_shadow.h" |
|
23 |
||
24 |
const TInt KMajorVersionNumber=0; |
|
25 |
const TInt KMinorVersionNumber=1; |
|
26 |
const TInt KBuildVersionNumber=1; |
|
27 |
||
28 |
_LIT(KLddName,"Shadow"); |
|
29 |
||
80
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
30 |
#ifdef __CPU_X86 |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
31 |
const TUint KPageDirectorySize = 1024; |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
32 |
const TUint KMaxNumberOfPageDirectories = 1024; |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
33 |
const TUint KPsudoX86TTBCR = 512; |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
34 |
#else |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
35 |
const TUint KPageDirectorySize = 4096; // Full size (ttbr0+ttbr1) |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
36 |
const TUint KMaxNumberOfPageDirectories = 256; |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
37 |
#endif |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
38 |
|
0 | 39 |
class DShadow; |
40 |
||
41 |
class DShadowFactory : public DLogicalDevice |
|
42 |
// |
|
43 |
// Shadow ROM LDD factory |
|
44 |
// |
|
45 |
{ |
|
46 |
public: |
|
47 |
DShadowFactory(); |
|
48 |
virtual TInt Install(); //overriding pure virtual |
|
49 |
virtual void GetCaps(TDes8& aDes) const; //overriding pure virtual |
|
50 |
virtual TInt Create(DLogicalChannelBase*& aChannel); //overriding pure virtual |
|
51 |
}; |
|
52 |
||
53 |
class DShadow : public DLogicalChannelBase |
|
54 |
// |
|
55 |
// Shadow ROM logical channel |
|
56 |
// |
|
57 |
{ |
|
58 |
public: |
|
59 |
DShadow(); |
|
60 |
~DShadow(); |
|
61 |
protected: |
|
62 |
virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer); |
|
63 |
virtual TInt Request(TInt aFunction, TAny* a1, TAny* a2); |
|
80
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
64 |
|
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
65 |
// Memory model specific values will be initialised when the channel is created. |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
66 |
TUint iPageDirectoryBase; |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
67 |
TUint iPageTableBase; |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
68 |
TMemModel iMemoryModel; |
0 | 69 |
}; |
70 |
||
71 |
DECLARE_STANDARD_LDD() |
|
72 |
{ |
|
73 |
return new DShadowFactory; |
|
74 |
} |
|
75 |
||
76 |
DShadowFactory::DShadowFactory() |
|
77 |
// |
|
78 |
// Constructor |
|
79 |
// |
|
80 |
{ |
|
81 |
iVersion=TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber); |
|
82 |
//iParseMask=0;//No units, no info, no PDD |
|
83 |
//iUnitsMask=0;//Only one thing |
|
84 |
} |
|
85 |
||
86 |
TInt DShadowFactory::Create(DLogicalChannelBase*& aChannel) |
|
87 |
// |
|
88 |
// Create a new DShadow on this logical device |
|
89 |
// |
|
90 |
{ |
|
91 |
aChannel=new DShadow; |
|
92 |
return aChannel?KErrNone:KErrNoMemory; |
|
93 |
} |
|
94 |
||
95 |
TInt DShadowFactory::Install() |
|
96 |
// |
|
97 |
// Install the LDD - overriding pure virtual |
|
98 |
// |
|
99 |
{ |
|
100 |
return SetName(&KLddName); |
|
101 |
} |
|
102 |
||
103 |
void DShadowFactory::GetCaps(TDes8& aDes) const |
|
104 |
// |
|
105 |
// Get capabilities - overriding pure virtual |
|
106 |
// |
|
107 |
{ |
|
108 |
TCapsShadowV01 b; |
|
109 |
b.iVersion=TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber); |
|
110 |
Kern::InfoCopy(aDes,(TUint8*)&b,sizeof(b)); |
|
111 |
} |
|
112 |
||
113 |
DShadow::DShadow() |
|
114 |
// |
|
115 |
// Constructor |
|
116 |
// |
|
117 |
{ |
|
118 |
} |
|
119 |
||
120 |
TInt DShadow::DoCreate(TInt /*aUnit*/, const TDesC8* /*anInfo*/, const TVersion& aVer) |
|
121 |
// |
|
122 |
// Create channel |
|
123 |
// |
|
124 |
{ |
|
125 |
||
126 |
if (!Kern::QueryVersionSupported(TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber),aVer)) |
|
127 |
return KErrNotSupported; |
|
80
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
128 |
// Set memory model specific values. |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
129 |
TUint32 memoryModelAttrib = (TUint32)Kern::HalFunction(EHalGroupKernel,EKernelHalMemModelInfo,0,0); |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
130 |
switch (memoryModelAttrib & EMemModelTypeMask) |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
131 |
{ |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
132 |
case EMemModelTypeMoving: |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
133 |
iPageDirectoryBase = 0x61000000; |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
134 |
iPageTableBase = 0x62000000; |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
135 |
iMemoryModel = EMemModelMoving; |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
136 |
break; |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
137 |
case EMemModelTypeMultiple: |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
138 |
iPageDirectoryBase = 0xC1000000; |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
139 |
iPageTableBase = 0xC2000000; |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
140 |
iMemoryModel = EMemModelMultiple; |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
141 |
break; |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
142 |
case EMemModelTypeFlexible: |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
143 |
iPageDirectoryBase = 0xF4000000u; |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
144 |
iPageTableBase = 0xF8000000u; |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
145 |
iMemoryModel = EMemModelFlexible; |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
146 |
break; |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
147 |
default: |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
148 |
iPageDirectoryBase = 0x00000000; |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
149 |
iPageTableBase = 0x00000000; |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
150 |
iMemoryModel = EMemModelOther; |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
151 |
} |
0 | 152 |
return KErrNone; |
153 |
} |
|
154 |
||
155 |
DShadow::~DShadow() |
|
156 |
// |
|
157 |
// Destructor |
|
158 |
// |
|
159 |
{ |
|
160 |
} |
|
161 |
||
162 |
#ifdef __MARM__ |
|
163 |
extern TInt DoRead(TAny*); |
|
164 |
extern TInt GetMmuId(); |
|
165 |
extern TInt GetCacheType(); |
|
166 |
extern TUint GetTTBCR(); |
|
167 |
extern TUint GetControlRegister(); |
|
168 |
#endif |
|
169 |
||
170 |
LOCAL_C TInt KernStackSize() |
|
171 |
{ |
|
172 |
TRomEntry* pE=(TRomEntry*)Kern::SuperPage().iPrimaryEntry; |
|
173 |
TRomImageHeader* pI=(TRomImageHeader*)pE->iAddressLin; |
|
174 |
return pI->iStackSize; |
|
175 |
} |
|
176 |
||
177 |
LOCAL_C TInt MeasureKernStackUse() |
|
178 |
{ |
|
179 |
TLinAddr kstack=Kern::RoundToPageSize(Epoc::RomHeader().iKernDataAddress + Epoc::RomHeader().iTotalSvDataSize); |
|
180 |
TLinAddr kstackEnd=kstack+KernStackSize(); |
|
181 |
TUint32 *pS=(TUint32*)kstack; |
|
182 |
while(*pS==0xffffffff) pS++; |
|
183 |
TUint used=kstackEnd-TLinAddr(pS); |
|
184 |
return (TInt)used; |
|
185 |
} |
|
186 |
||
187 |
#if !defined(__WINS__) |
|
188 |
TInt DShadow::Request(TInt aFunction, TAny* a1, TAny* a2) |
|
189 |
{ |
|
190 |
TInt pageSize=Kern::RoundToPageSize(1); |
|
191 |
TInt r=KErrNone; |
|
192 |
switch (aFunction) |
|
193 |
{ |
|
194 |
case RShadow::EControlAllocShadow: |
|
195 |
NKern::ThreadEnterCS(); |
|
196 |
r=Epoc::AllocShadowPage(TLinAddr(a1)); |
|
197 |
NKern::ThreadLeaveCS(); |
|
198 |
break; |
|
199 |
case RShadow::EControlFreeShadow: |
|
200 |
NKern::ThreadEnterCS(); |
|
201 |
r=Epoc::FreeShadowPage(TLinAddr(a1)); |
|
202 |
NKern::ThreadLeaveCS(); |
|
203 |
break; |
|
204 |
||
205 |
case RShadow::EControlWriteShadow: //copy 4KB(page size) data to shadow page |
|
206 |
{ |
|
207 |
NKern::ThreadEnterCS(); |
|
208 |
void* alloc = Kern::Alloc(pageSize); //CopyToShadowMemory assumes Kernel adress space. Copy here first |
|
209 |
if (alloc) |
|
210 |
{ |
|
211 |
kumemget(alloc,a2,pageSize);//From user space to kernel heap |
|
212 |
for (TInt i=0;i<pageSize;i+=32) |
|
213 |
Epoc::CopyToShadowMemory((TLinAddr)((TInt)a1+i),(TLinAddr)((TInt)alloc+i),32); |
|
214 |
Cache::IMB_Range((TLinAddr)a1,pageSize); |
|
215 |
Kern::Free(alloc); |
|
216 |
} |
|
217 |
else |
|
218 |
r = KErrNoMemory; |
|
219 |
||
220 |
NKern::ThreadLeaveCS(); |
|
221 |
} |
|
222 |
break; |
|
223 |
case RShadow::EControlFreezeShadow: |
|
224 |
NKern::ThreadEnterCS(); |
|
225 |
r=Epoc::FreezeShadowPage(TLinAddr(a1)); |
|
226 |
NKern::ThreadLeaveCS(); |
|
227 |
break; |
|
228 |
case RShadow::EControlSetPriority: |
|
229 |
{ |
|
230 |
TInt h=(TInt)a1; |
|
231 |
TInt p=(TInt)a2; |
|
232 |
NKern::LockSystem(); |
|
233 |
DThread *pT=(DThread*)Kern::CurrentThread().ObjectFromHandle(h); |
|
234 |
pT->SetThreadPriority(p); |
|
235 |
NKern::UnlockSystem(); |
|
236 |
break; |
|
237 |
} |
|
238 |
#ifdef __MARM__ |
|
239 |
case RShadow::EControlRead: |
|
240 |
r=DoRead(a1); |
|
241 |
break; |
|
242 |
case RShadow::EControlMmuId: |
|
243 |
r=GetMmuId(); |
|
244 |
break; |
|
245 |
case RShadow::EControlCacheType: |
|
246 |
r=GetCacheType(); |
|
247 |
break; |
|
248 |
#endif |
|
249 |
case RShadow::EControlMeasureKernStackUse: |
|
250 |
r=MeasureKernStackUse(); |
|
251 |
break; |
|
252 |
case RShadow::EControlMeasureKernHeapFree: |
|
253 |
r=KErrNotSupported; |
|
254 |
break; |
|
255 |
case RShadow::EControlCallFunction: |
|
256 |
{ |
|
257 |
TThreadFunction f=(TThreadFunction)a1; |
|
258 |
r=(*f)(a2); |
|
259 |
break; |
|
260 |
} |
|
261 |
case RShadow::EControlAllocPhys: |
|
262 |
{ |
|
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
263 |
|
0 | 264 |
TInt size=(TInt)a1; |
265 |
TInt align=(TInt)a2; |
|
266 |
TPhysAddr pa; |
|
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
267 |
|
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
268 |
NKern::ThreadEnterCS(); |
0 | 269 |
r=Epoc::AllocPhysicalRam(size,pa,align); |
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
270 |
NKern::ThreadLeaveCS(); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
271 |
|
0 | 272 |
if (r==KErrNone) |
273 |
{ |
|
274 |
if (pa&0x0f) |
|
275 |
r=KErrCorrupt; |
|
276 |
else |
|
277 |
r=pa>>4; |
|
278 |
} |
|
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
279 |
|
0 | 280 |
break; |
281 |
} |
|
282 |
case RShadow::EControlFreePhys: |
|
283 |
{ |
|
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
284 |
|
0 | 285 |
TPhysAddr pa=(TPhysAddr)a1; |
286 |
TInt size=(TInt)a2; |
|
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
287 |
NKern::ThreadEnterCS(); |
0 | 288 |
r=Epoc::FreePhysicalRam(pa,size); |
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
289 |
NKern::ThreadLeaveCS(); |
0 | 290 |
break; |
291 |
} |
|
292 |
case RShadow::EControlClaimPhys: |
|
293 |
{ |
|
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
294 |
|
0 | 295 |
TPhysAddr pa=(TPhysAddr)a1; |
296 |
TInt size=(TInt)a2; |
|
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
297 |
NKern::ThreadEnterCS(); |
0 | 298 |
r=Epoc::ClaimPhysicalRam(pa,size); |
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
299 |
NKern::ThreadLeaveCS(); |
0 | 300 |
break; |
301 |
} |
|
302 |
||
303 |
// GetMemoryArchitecture |
|
304 |
case RShadow::EControlGetMemoryArchitecture: |
|
305 |
{ |
|
306 |
TCpu* cpu = (TCpu*) a1; |
|
307 |
TUint* flags = (TUint*) a2; |
|
308 |
||
309 |
#if defined(__CPU_ARM) |
|
310 |
*cpu=ECpuArm; |
|
311 |
*flags = GetControlRegister(); |
|
312 |
#elif defined(__CPU_X86) |
|
313 |
*cpu=ECpuX86; |
|
314 |
*flags =0; |
|
315 |
#else |
|
316 |
*cpu=ECpuUnknown; |
|
317 |
*flags =0; |
|
318 |
#endif |
|
319 |
||
320 |
break; |
|
321 |
} |
|
322 |
||
323 |
||
324 |
// GetMemModelInfo |
|
325 |
case RShadow::EControlGetMemModelInfo: |
|
326 |
{ |
|
327 |
TUint pageTable; |
|
328 |
TUint numPds; |
|
329 |
||
330 |
#ifdef __EPOC32__ |
|
331 |
||
80
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
332 |
if (iMemoryModel == EMemModelFlexible || iMemoryModel == EMemModelMultiple) |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
333 |
numPds = KMaxNumberOfPageDirectories; |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
334 |
else |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
335 |
numPds = 0; |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
336 |
r = iMemoryModel; |
0 | 337 |
#endif |
80
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
338 |
pageTable = iPageTableBase; |
0 | 339 |
|
340 |
kumemput(a1, &pageTable, sizeof(TUint)); |
|
341 |
kumemput(a2, &numPds, sizeof(TUint)); |
|
342 |
break; |
|
343 |
} |
|
344 |
||
345 |
||
346 |
// GetPdInfo |
|
347 |
case RShadow::EControlGetPdInfo: |
|
348 |
{ |
|
349 |
TUint pd; |
|
350 |
kumemget(&pd, a1, sizeof(TUint)); |
|
351 |
||
352 |
TUint pdSize; |
|
353 |
TUint pdBase; |
|
354 |
||
355 |
r=KErrNoPageTable; |
|
356 |
||
80
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
357 |
if (iMemoryModel == EMemModelMoving) |
0 | 358 |
{ |
80
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
359 |
if (pd==KGlobalPageDirectory) |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
360 |
{ |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
361 |
pdSize=KPageDirectorySize; |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
362 |
pdBase=iPageDirectoryBase; |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
363 |
r = KErrNone; |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
364 |
} |
0 | 365 |
} |
80
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
366 |
else if(iMemoryModel == EMemModelFlexible || iMemoryModel == EMemModelMultiple) |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
367 |
{ |
0 | 368 |
#ifdef __CPU_X86 |
80
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
369 |
TUint ttbcr = KPsudoX86TTBCR; |
0 | 370 |
#else |
80
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
371 |
TUint ttbcr = KPageDirectorySize >> GetTTBCR(); |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
372 |
#endif // __CPU_X86 |
0 | 373 |
|
80
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
374 |
if (pd==KGlobalPageDirectory) |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
375 |
{ |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
376 |
pdSize=KPageDirectorySize - ttbcr; |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
377 |
pdBase=iPageDirectoryBase + ttbcr*4; |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
378 |
r = ttbcr & KPageOffsetMask; |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
379 |
} |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
380 |
else |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
381 |
{ |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
382 |
pdSize = ttbcr; |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
383 |
pdBase=iPageDirectoryBase + pd * KPageDirectorySize * 4; |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
384 |
|
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
385 |
TPhysAddr phys=Epoc::LinearToPhysical((TLinAddr)pdBase); |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
386 |
r = (phys==KPhysAddrInvalid) ? KErrNoPageTable : KErrNone; |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
387 |
} |
0 | 388 |
} |
389 |
||
390 |
if ((r & KErrNoPageTable) == 0) |
|
391 |
{ |
|
392 |
kumemput(a1, &pdSize, sizeof(TUint)); |
|
393 |
kumemput(a2, &pdBase, sizeof(TUint)); |
|
394 |
} |
|
395 |
||
396 |
break; |
|
397 |
} |
|
398 |
||
399 |
default: |
|
400 |
r=KErrNotSupported; |
|
401 |
break; |
|
402 |
} |
|
403 |
return r; |
|
404 |
} |
|
405 |
#else |
|
406 |
TInt DShadow::Request(TInt /*aFunction*/, TAny* /*a1*/, TAny* /*a2*/) |
|
407 |
{ |
|
408 |
||
409 |
return KErrNotSupported; |
|
410 |
} |
|
411 |
#endif |
|
412 |