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