author | mikek |
Tue, 15 Jun 2010 12:46:12 +0100 | |
branch | GCC_SURGE |
changeset 150 | 9b2dbb18d44b |
parent 90 | 947f0dc9f7a8 |
child 257 | 3e88ff8f41d5 |
child 286 | 48e57fb1237e |
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\include\memmodel\epoc\multiple\memmodel.h |
|
15 |
// |
|
16 |
// WARNING: This file contains some APIs which are internal and are subject |
|
17 |
// to change without notice. Such APIs should therefore not be used |
|
18 |
// outside the Kernel and Hardware Services package. |
|
19 |
// |
|
20 |
||
21 |
#ifndef __MEMMODEL_H__ |
|
22 |
#define __MEMMODEL_H__ |
|
23 |
#include <memmodel/epoc/mmubase/mmubase.h> |
|
24 |
||
25 |
#ifdef __SMP__ |
|
26 |
// SubScheduler fields for each processor |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
27 |
#define i_AliasLinAddr iSubSchedScratch[0] |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
28 |
#define i_AliasPdePtr iSubSchedScratch[1] |
0 | 29 |
#endif |
30 |
||
31 |
/******************************************** |
|
32 |
* Dynamic Branch Predictor Support |
|
33 |
********************************************/ |
|
34 |
||
35 |
/** |
|
36 |
@internalComponent |
|
37 |
*/ |
|
38 |
#ifdef __SMP__ |
|
39 |
//#define LastUserSelfMod ((DProcess*&)SubScheduler().iExtras[0]) |
|
40 |
#else |
|
41 |
#define LastUserSelfMod ((DProcess*&)TheScheduler.iExtras[0]) |
|
42 |
#endif |
|
43 |
||
44 |
/******************************************** |
|
45 |
* RAM Defrag Page Table Moving Support |
|
46 |
********************************************/ |
|
47 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
48 |
#ifdef __SMP__ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
49 |
/** |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
50 |
@internalComponent |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
51 |
*/ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
52 |
#define AliasRemapOld ((TPhysAddr&)TheScheduler.iSchedScratch[1]) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
53 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
54 |
/** |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
55 |
@internalComponent |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
56 |
*/ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
57 |
#define AliasRemapNew ((TPhysAddr&)TheScheduler.iSchedScratch[2]) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
58 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
59 |
#else |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
60 |
|
0 | 61 |
/** |
62 |
@internalComponent |
|
63 |
*/ |
|
64 |
#define AliasRemapOld ((TPhysAddr&)TheScheduler.iExtras[1]) |
|
65 |
||
66 |
/** |
|
67 |
@internalComponent |
|
68 |
*/ |
|
69 |
#define AliasRemapNew ((TPhysAddr&)TheScheduler.iExtras[2]) |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
70 |
#endif |
0 | 71 |
|
72 |
/******************************************** |
|
73 |
* Thread Control Block |
|
74 |
********************************************/ |
|
75 |
||
76 |
class DMemModelProcess; |
|
77 |
||
78 |
/** |
|
79 |
@internalComponent |
|
80 |
*/ |
|
81 |
class DMemModelThread : public DThread |
|
82 |
{ |
|
83 |
public: |
|
84 |
TInt Alias(TLinAddr aAddr, DMemModelProcess* aProcess, TInt aSize, TInt aPerm, TLinAddr& aAliasAddr, TInt& aAliasSize); |
|
85 |
void RemoveAlias(); |
|
86 |
virtual void DoExit1(); |
|
87 |
static void RestoreAddressSpace(); |
|
88 |
public: |
|
89 |
TLinAddr iAliasLinAddr; // linear address to access aliased memory (0 means no alias is present). |
|
90 |
TPde* iAliasPdePtr; // Address of PDE which has been modified to make aliased memory accessible. |
|
91 |
TPde iAliasPde; // PDE to store at iAliasPdePtr. |
|
92 |
TInt iAliasOsAsid; // asid for the process whoes memory is aliased. |
|
93 |
SDblQueLink iAliasLink; // link to make TheMmu.iAliasList. |
|
94 |
TLinAddr iAliasTarget; // linear address of the memory which has been aliased |
|
95 |
#ifdef __SMP__ |
|
96 |
TInt iCpuRestoreCookie; |
|
97 |
#endif |
|
98 |
}; |
|
99 |
||
100 |
||
101 |
/******************************************** |
|
102 |
* Process Control Block |
|
103 |
********************************************/ |
|
104 |
||
105 |
class DMemModelChunk; |
|
106 |
class DMemModelCodeSegMemory; |
|
107 |
||
108 |
/** |
|
109 |
@internalComponent |
|
110 |
*/ |
|
111 |
class DMemModelProcess : public DEpocProcess |
|
112 |
{ |
|
113 |
public: |
|
114 |
void Destruct(); |
|
115 |
public: |
|
116 |
virtual TInt DoCreate(TBool aKernelProcess, TProcessCreateInfo& aInfo); |
|
117 |
virtual TInt NewChunk(DChunk*& aChunk, SChunkCreateInfo& aInfo, TLinAddr& aRunAddr); |
|
118 |
virtual TInt AddChunk(DChunk* aChunk,TBool isReadOnly); |
|
119 |
virtual TInt NewShPool(DShPool*& aPool, TShPoolCreateInfo& aInfo); |
|
120 |
virtual TInt CreateDataBssStackArea(TProcessCreateInfo& aInfo); |
|
121 |
virtual TInt MapCodeSeg(DCodeSeg* aCodeSeg); |
|
122 |
virtual void UnmapCodeSeg(DCodeSeg* aCodeSeg); |
|
123 |
virtual void RemoveDllData(); |
|
124 |
virtual void FinalRelease(); |
|
125 |
public: |
|
126 |
virtual TInt GetNewChunk(DMemModelChunk*& aChunk, SChunkCreateInfo& aInfo)=0; |
|
127 |
public: |
|
128 |
TInt AddChunk(DMemModelChunk* aChunk, TLinAddr& aDataSectionBase, TBool isReadOnly); |
|
129 |
TInt AllocateDataSectionBase(DMemModelChunk& aChunk, TUint& aBase); |
|
130 |
TUint8* DataSectionBase(DMemModelChunk* aChunk); |
|
131 |
void RemoveChunk(DMemModelChunk *aChunk); |
|
132 |
void DoRemoveChunk(TInt aIndex); |
|
133 |
TInt ChunkIndex(DMemModelChunk* aChunk,TInt& aPos); |
|
134 |
TInt CreateCodeChunk(); |
|
135 |
void FreeCodeChunk(); |
|
136 |
TInt CreateDllDataChunk(); |
|
137 |
void FreeDllDataChunk(); |
|
138 |
TInt CommitDllData(TLinAddr aBase, TInt aSize); |
|
139 |
void DecommitDllData(TLinAddr aBase, TInt aSize); |
|
140 |
TInt MapUserRamCode(DMemModelCodeSegMemory* aMemory, TBool aLoading); |
|
141 |
void UnmapUserRamCode(DMemModelCodeSegMemory* aMemory, TBool aLoading); |
|
142 |
public: |
|
143 |
enum TMemModelProcessAttributes |
|
144 |
{ |
|
145 |
ESeparateGlobalSpace=0x40000000, |
|
146 |
EMMProcessAttributesMask = ESeparateGlobalSpace, |
|
147 |
}; |
|
148 |
||
149 |
struct SChunkInfo |
|
150 |
{ |
|
151 |
DMemModelChunk* iChunk; |
|
152 |
TInt16 iAccessCount; |
|
153 |
TInt16 isReadOnly; |
|
154 |
}; |
|
155 |
||
156 |
TInt iChunkCount; |
|
157 |
TInt iChunkAlloc; |
|
158 |
SChunkInfo* iChunks; |
|
159 |
TLinearSection* iLocalSection; |
|
160 |
TInt iOsAsid; |
|
161 |
TPhysAddr iLocalPageDir; |
|
162 |
TPhysAddr iGlobalPageDir; |
|
163 |
TUint32 iAddressCheckMaskR; |
|
164 |
TUint32 iAddressCheckMaskW; |
|
165 |
DMemModelChunk* iCodeChunk; |
|
166 |
DMemModelChunk* iDllDataChunk; |
|
167 |
TInt iSelfModChunks; |
|
168 |
public: |
|
169 |
friend class Monitor; |
|
170 |
}; |
|
171 |
||
172 |
||
173 |
/******************************************** |
|
174 |
* Chunk Control Block |
|
175 |
********************************************/ |
|
176 |
||
177 |
/** |
|
178 |
@internalComponent |
|
179 |
*/ |
|
180 |
class DMemModelChunk : public DChunk |
|
181 |
{ |
|
182 |
public: |
|
183 |
/** |
|
184 |
@see DChunk::TChunkAttributes for generic attribute flags |
|
185 |
*/ |
|
186 |
enum TMemModelChunkAttributes |
|
187 |
{ |
|
188 |
EPrivate =0x80000000, |
|
189 |
ECode =0x40000000, |
|
190 |
EAddressAllocDown =0x20000000, |
|
191 |
||
192 |
EAddressRangeMask =0x0f000000, |
|
193 |
EAddressRangeShift =24, |
|
194 |
EAddressLocal =0x00000000, |
|
195 |
EAddressShared =0x01000000, |
|
196 |
EAddressUserGlobal =0x02000000, |
|
197 |
EAddressKernel =0x03000000, |
|
198 |
EAddressFixed =0x04000000, |
|
199 |
||
200 |
EMapTypeMask =0x00c00000, |
|
201 |
EMapTypeLocal =0x00000000, |
|
202 |
EMapTypeGlobal =0x00400000, |
|
203 |
EMapTypeShared =0x00800000, |
|
204 |
||
205 |
EMMChunkAttributesMask = EPrivate|ECode|EAddressAllocDown|EAddressRangeMask|EMapTypeMask, |
|
206 |
}; |
|
207 |
||
208 |
public: |
|
209 |
DMemModelChunk(); |
|
210 |
void Destruct(); |
|
211 |
public: |
|
212 |
virtual TInt Close(TAny* aPtr); |
|
213 |
virtual TInt DoCreate(SChunkCreateInfo& aInfo); |
|
214 |
virtual TInt Adjust(TInt aNewSize); |
|
215 |
virtual TInt AdjustDoubleEnded(TInt aBottom, TInt aTop); |
|
216 |
virtual TInt CheckAccess(); |
|
217 |
virtual TInt Commit(TInt aOffset, TInt aSize, TCommitType aCommitType=DChunk::ECommitDiscontiguous, TUint32* aExtraArg=0); |
|
218 |
virtual TInt Allocate(TInt aSize, TInt aGuard=0, TInt aAlign=0); |
|
219 |
virtual TInt Decommit(TInt aOffset, TInt aSize); |
|
220 |
virtual TInt Lock(TInt anOffset, TInt aSize); |
|
221 |
virtual TInt Unlock(TInt anOffset, TInt aSize); |
|
222 |
virtual TInt Address(TInt aOffset, TInt aSize, TLinAddr& aKernelAddress); |
|
223 |
virtual TInt PhysicalAddress(TInt aOffset, TInt aSize, TLinAddr& aKernelAddress, TUint32& aPhysicalAddress, TUint32* aPhysicalPageList=NULL); |
|
224 |
virtual void BTracePrime(TInt aCategory); |
|
225 |
virtual void Substitute(TInt aOffset, TPhysAddr aOldAddr, TPhysAddr aNewAddr); |
|
226 |
virtual TUint8* Base(DProcess* aProcess); |
|
227 |
inline TUint8* Base() const { return DChunk::Base(); } |
|
228 |
public: |
|
229 |
TInt Decommit(TInt aOffset, TInt aSize, TDecommitType aDecommitType); |
|
230 |
void ClaimInitialPages(); |
|
231 |
void SetFixedAddress(TLinAddr aAddr, TInt aInitialSize); |
|
232 |
TInt Reserve(TInt aInitialSize); |
|
233 |
TInt DoCommit(TInt aOffset, TInt aSize, TCommitType aCommitType=DChunk::ECommitDiscontiguous, TUint32* aExtraArg=0); |
|
234 |
void DoDecommit(TInt aOffset, TInt aSize, TDecommitType aDecommitType=EDecommitNormal); |
|
235 |
TInt AllocateAddress(); |
|
236 |
void ApplyPermissions(TInt aOffset, TInt aSize, TPte aPtePerm); |
|
237 |
TLinearSection* LinearSection(); |
|
238 |
TZonePageType GetPageType(); |
|
239 |
||
240 |
public: |
|
241 |
virtual TInt SetupPermissions()=0; |
|
242 |
||
243 |
public: |
|
244 |
TBitMapAllocator* iOsAsids; // NULL for local or fully global else list of OS ASIDs |
|
245 |
TPte iPtePermissions; |
|
246 |
TPde iPdePermissions; |
|
247 |
TUint16* iPageTables; |
|
248 |
TBitMapAllocator* iPageBitMap; // NULL if not disconnected chunk |
|
249 |
TBitMapAllocator* iPermanentPageBitMap; |
|
250 |
DMemModelChunk* iKernelMirror; |
|
251 |
public: |
|
252 |
friend class Monitor; |
|
253 |
}; |
|
254 |
||
255 |
||
256 |
/******************************************** |
|
257 |
* Code segment |
|
258 |
********************************************/ |
|
259 |
||
260 |
/** |
|
261 |
@internalComponent |
|
262 |
*/ |
|
263 |
class DMemModelCodeSegMemory : public DMmuCodeSegMemory |
|
264 |
{ |
|
265 |
public: |
|
266 |
DMemModelCodeSegMemory(DEpocCodeSeg* aCodeSeg); |
|
267 |
~DMemModelCodeSegMemory(); |
|
268 |
TInt Create(TCodeSegCreateInfo& aInfo); |
|
269 |
TInt Loaded(TCodeSegCreateInfo& aInfo); |
|
270 |
void Substitute(TInt aOffset, TPhysAddr aOld, TPhysAddr aNew); |
|
271 |
void Destroy(); |
|
272 |
public: |
|
273 |
DMemModelProcess* iCreator; // process loading this code segment |
|
274 |
||
275 |
TPhysAddr* iPages; // list of physical pages (iPageCount+iDataPageCount) |
|
276 |
||
277 |
/** |
|
278 |
List of OS ASIDs this code segment is mapped into. |
|
279 |
Protected by RamAllocMutex and System Lock. |
|
280 |
*/ |
|
281 |
TBitMapAllocator* iOsAsids; |
|
282 |
||
283 |
TLinAddr* iCopyOfExportDir; // kernel side copy of export directory or NULL |
|
284 |
}; |
|
285 |
||
286 |
/** |
|
287 |
@internalComponent |
|
288 |
*/ |
|
289 |
class DMemModelCodeSeg: public DEpocCodeSeg |
|
290 |
{ |
|
291 |
public: |
|
292 |
DMemModelCodeSeg(); |
|
293 |
virtual ~DMemModelCodeSeg(); |
|
294 |
virtual TInt DoCreateRam(TCodeSegCreateInfo& aInfo, DProcess* aProcess); |
|
295 |
virtual TInt DoCreateXIP(DProcess* aProcess); |
|
296 |
virtual TInt Loaded(TCodeSegCreateInfo& aInfo); |
|
297 |
virtual void ReadExportDir(TUint32* aDest); |
|
298 |
virtual TBool FindCheck(DProcess* aProcess); |
|
299 |
virtual TBool OpenCheck(DProcess* aProcess); |
|
300 |
virtual void BTracePrime(TInt aCategory); |
|
301 |
inline DMemModelCodeSegMemory* Memory() |
|
302 |
{ return (DMemModelCodeSegMemory*)iMemory; } |
|
303 |
inline TPhysAddr* Pages() |
|
304 |
{ return iMemory!=0 ? Memory()->iPages : (TPhysAddr*)0; } |
|
305 |
public: |
|
306 |
TInt iCodeAllocBase; |
|
307 |
TInt iDataAllocBase; |
|
308 |
TAny* iKernelData; // only for kernel modules |
|
309 |
}; |
|
310 |
||
311 |
||
312 |
/******************************************** |
|
313 |
* MMU stuff |
|
314 |
********************************************/ |
|
315 |
||
316 |
/** |
|
317 |
@internalComponent |
|
318 |
Indicates that corresponding linear address applies to unknown address space. |
|
319 |
Common for EMemTypeShared types of chunks with no owning process. |
|
320 |
*/ |
|
321 |
#define UNKNOWN_MAPPING ((TInt)-2) |
|
322 |
||
323 |
/** |
|
324 |
@internalComponent |
|
325 |
Indicates that corresponding linear address applies to global address space. |
|
326 |
*/ |
|
327 |
#define GLOBAL_MAPPING ((const TAny*)-1) |
|
328 |
||
329 |
/** |
|
330 |
@internalComponent |
|
331 |
Indicates that corresponding linear address applies to kernel process (either global or Kernel's local space). |
|
332 |
*/ |
|
333 |
#define KERNEL_MAPPING ((TInt)0) |
|
334 |
||
335 |
||
336 |
/** |
|
337 |
@internalComponent |
|
338 |
*/ |
|
339 |
class Mmu : public MmuBase |
|
340 |
{ |
|
341 |
public: |
|
342 |
enum TFlushFlags { |
|
343 |
EFlushDTLB=0x01, |
|
344 |
EFlushDCache=0x02, |
|
345 |
EFlushITLB=0x04, |
|
346 |
EFlushICache=0x08, |
|
347 |
EFlushDDecommit=0x80000000, |
|
348 |
EFlushDPermChg=0x20000000, |
|
349 |
EFlushDMove=0x40000000, |
|
350 |
EFlushIPermChg=0x04000000, |
|
351 |
EFlushIMove=0x10000000, |
|
352 |
EFlushInheritMask=EFlushDPermChg|EFlushDMove|EFlushIPermChg|EFlushIMove, |
|
353 |
}; |
|
354 |
||
355 |
enum TPanic |
|
356 |
{ |
|
357 |
ELocalPageDirBadAsid, |
|
358 |
EGlobalPageDirBadAsid, |
|
359 |
EPDEBadAsid, |
|
360 |
EFreeOsAsidBadAsid, |
|
361 |
EOsAsidAllocCreateFailed, |
|
362 |
EBadInitialPageAddr, |
|
363 |
EAssignPageTableInvalidUsage, |
|
364 |
EUserCodeAllocatorCreateFailed, |
|
365 |
EDllDataAllocatorCreateFailed, |
|
366 |
ERomUserDataAddressInvalid, |
|
367 |
ERomUserDataSizeInvalid, |
|
368 |
ECreateSharedSectionFailed, |
|
369 |
ECreateUserGlobalSectionFailed, |
|
370 |
ERemapPageFailed, |
|
371 |
ERemapPageTableFailed, |
|
372 |
EFixupXPTFailed, |
|
373 |
ETempMappingFailed, |
|
374 |
EDefragDisablePageFailed, |
|
375 |
EDefragFaultWhilstFMHeld, |
|
376 |
}; |
|
377 |
||
378 |
public: |
|
379 |
TPde* LocalPageDir(TInt aOsAsid); |
|
380 |
TPde* GlobalPageDir(TInt aOsAsid); |
|
381 |
TPde& PDE(TLinAddr aAddr, TInt aOsAsid); |
|
382 |
TInt NewOsAsid(TBool aSeparateGlobal); |
|
383 |
void FreeOsAsid(TInt aOsAsid); |
|
384 |
void CreateUserGlobalSection(TLinAddr aBase, TLinAddr aEnd); |
|
385 |
TInt CreateGlobalCodeChunk(); |
|
386 |
||
387 |
// virtual - inherited/overridden from MmuBase |
|
388 |
virtual void Init1(); |
|
389 |
// virtual void Init2(); |
|
390 |
virtual void DoInit2(); |
|
391 |
// virtual TBool PteIsPresent(TPte aPte)=0; |
|
392 |
// virtual TPhysAddr PtePhysAddr(TPte aPte, TInt aPteIndex)=0; |
|
393 |
// virtual TPhysAddr PdePhysAddr(TLinAddr aAddr)=0; |
|
394 |
virtual void SetupInitialPageInfo(SPageInfo* aPageInfo, TLinAddr aChunkAddr, TInt aPdeIndex); |
|
395 |
virtual void SetupInitialPageTableInfo(TInt aId, TLinAddr aChunkAddr, TInt aNumPtes); |
|
396 |
virtual void AssignPageTable(TInt aId, TInt aUsage, TAny* aObject, TLinAddr aAddr, TPde aPdePerm); |
|
397 |
virtual TInt UnassignPageTable(TLinAddr aAddr); |
|
398 |
// virtual void BootstrapPageTable(TInt aXptId, TPhysAddr aXptPhys, TInt aId, TPhysAddr aPhysAddr)=0; |
|
399 |
virtual TInt PageTableId(TLinAddr aAddr); |
|
400 |
// virtual TInt BootPageTableId(TLinAddr aAddr, TPhysAddr& aPtPhys)=0; |
|
401 |
// virtual void ClearPageTable(TInt aId, TInt aFirstIndex=0)=0; |
|
402 |
virtual TPhysAddr LinearToPhysical(TLinAddr aAddr); |
|
403 |
virtual TInt LinearToPhysical(TLinAddr aAddr, TInt aSize, TPhysAddr& aPhysicalAddress, TPhysAddr* aPhysicalPageList=NULL); |
|
404 |
// virtual void MapRamPages(TInt aId, SPageInfo::TType aType, TAny* aPtr, TUint32 aOffset, const TPhysAddr* aPageList, TInt aNumPages, TPte aPtePerm)=0; |
|
405 |
// virtual void MapPhysicalPages(TInt aId, SPageInfo::TType aType, TAny* aPtr, TUint32 aOffset, TPhysAddr aPhysAddr, TInt aNumPages, TPte aPtePerm)=0; |
|
406 |
// virtual TInt UnmapPages(TInt aId, TUint32 aAddr, TInt aNumPages, TPhysAddr* aPageList, TBool aSetPagesFree, TInt& aNumPtes, TInt& aNumFree, DProcess* aProcess)=0; |
|
407 |
// virtual void ClearRamDrive(TLinAddr aStart)=0; |
|
408 |
// virtual TInt PdePtePermissions(TUint& aMapAttr, TPde& aPde, TPte& aPte)=0; |
|
409 |
// virtual void Map(TLinAddr aLinAddr, TPhysAddr aPhysAddr, TInt aSize, TPde aPdePerm, TPte aPtePerm, TInt aMapShift)=0; |
|
410 |
// virtual void Unmap(TLinAddr aLinAddr, TInt aSize)=0; |
|
411 |
// virtual void InitShadowPageTable(TInt aId, TLinAddr aRomAddr, TPhysAddr aOrigPhys)=0; |
|
412 |
// virtual void InitShadowPage(TPhysAddr aShadowPhys, TLinAddr aRomAddr)=0; |
|
413 |
// virtual void DoUnmapShadowPage(TInt aId, TLinAddr aRomAddr, TPhysAddr aOrigPhys)=0; |
|
414 |
// virtual TInt UnassignShadowPageTable(TLinAddr aRomAddr, TPhysAddr aOrigPhys)=0; |
|
415 |
// virtual void DoFreezeShadowPage(TInt aId, TLinAddr aRomAddr)=0; |
|
416 |
// virtual void FlushShadow(TLinAddr aRomAddr)=0; |
|
417 |
// virtual void AssignShadowPageTable(TInt aId, TLinAddr aRomAddr)=0; |
|
418 |
// virtual void ClearPages(TInt aNumPages, TPhysAddr* aPageList)=0; |
|
419 |
virtual TPte PtePermissions(TChunkType aChunkType)=0; |
|
420 |
virtual TInt MoveKernelPage(DChunk* aChunk, TUint32 aOffset, TPhysAddr aOld, TPhysAddr& aNew, TUint aBlockZoneId, TBool aBlockRest); |
|
421 |
virtual TInt MoveCodeSegMemoryPage(DMemModelCodeSegMemory* aCodeSegMemory, TUint32 aOffset, TPhysAddr aOld, TPhysAddr& aNew, TUint aBlockZoneId, TBool aBlockRest); |
|
422 |
virtual TInt MoveCodeChunkPage(DChunk* aChunk, TUint32 aOffset, TPhysAddr aOld, TPhysAddr& aNew, TUint aBlockZoneId, TBool aBlockRest); |
|
423 |
virtual TInt MoveDataChunkPage(DChunk* aChunk, TUint32 aOffset, TPhysAddr aOld, TPhysAddr& aNew, TUint aBlockZoneId, TBool aBlockRest); |
|
424 |
||
425 |
// pure virtual - new in Mmu |
|
426 |
virtual TInt NewPageDirectory(TInt aOsAsid, TBool aSeparateGlobal, TPhysAddr& aPhysAddr, TInt& aNumPages)=0; |
|
427 |
virtual void InitPageDirectory(TInt aOsAsid, TBool aGlobal)=0; |
|
428 |
virtual TInt PageTableId(TLinAddr aAddr, TInt aOsAsid)=0; |
|
429 |
virtual TPhysAddr LinearToPhysical(TLinAddr aAddr, TInt aOsAsid)=0; |
|
430 |
virtual TInt LinearToPhysical(TLinAddr aAddr, TInt aSize, TPhysAddr& aPhysicalAddress, TPhysAddr* aPhysicalPageList, TInt aOsAsid)=0; |
|
431 |
virtual TInt PreparePagesForDMA(TLinAddr aAddr, TInt aSize, TInt aOsAsid, TPhysAddr* aPhysicalPageList)=0; |
|
432 |
virtual TInt ReleasePagesFromDMA(TPhysAddr* aPhysicalPageList, TInt aPageCount)=0; |
|
433 |
virtual void DoAssignPageTable(TInt aId, TLinAddr aAddr, TPde aPdePerm, const TAny* aOsAsids)=0; |
|
434 |
virtual void RemapPageTableSingle(TPhysAddr aOld, TPhysAddr aNew, TLinAddr aAddr, TInt aOsAsid)=0; |
|
435 |
virtual void RemapPageTableMultiple(TPhysAddr aOld, TPhysAddr aNew, TLinAddr aAddr, const TAny* aOsAsids)=0; |
|
436 |
virtual void RemapPageTableGlobal(TPhysAddr aOld, TPhysAddr aNew, TLinAddr aAddr)=0; |
|
437 |
virtual void RemapPageTableAliases(TPhysAddr aOld, TPhysAddr aNew)=0; |
|
438 |
virtual void DoUnassignPageTable(TLinAddr aAddr, const TAny* aOsAsids)=0; |
|
439 |
virtual TPde PdePermissions(TChunkType aChunkType, TBool aRO)=0; |
|
440 |
virtual void ApplyTopLevelPermissions(TLinAddr aAddr, TInt aOsAsid, TInt aNumPdes, TPde aPdePerm)=0; |
|
441 |
virtual void ApplyPagePermissions(TInt aId, TInt aPageOffset, TInt aNumPages, TPte aPtePerm)=0; |
|
442 |
virtual void GenericFlush(TUint32 aMask)=0; |
|
443 |
virtual TLinAddr MapTemp(TPhysAddr aPage,TLinAddr aLinAddr, TInt aPages=1)=0; |
|
444 |
virtual TLinAddr MapTemp(TPhysAddr aPage,TLinAddr aLinAddr,TInt aPages, TMemoryType aMemType)=0; |
|
445 |
virtual TLinAddr MapSecondTemp(TPhysAddr aPage,TLinAddr aLinAddr, TInt aPages=1)=0; |
|
446 |
virtual void UnmapTemp()=0; |
|
447 |
virtual void UnmapSecondTemp()=0; |
|
448 |
virtual TBool ValidateLocalIpcAddress(TLinAddr aAddr,TInt aSize,TBool aWrite)=0; |
|
449 |
virtual TInt UnlockRamCachePages(TLinAddr aLinAddr, TInt aNumPages, DProcess* aProcess)=0; |
|
450 |
virtual TInt LockRamCachePages(TLinAddr aLinAddr, TInt aNumPages, DProcess* aProcess)=0; |
|
451 |
virtual void MapVirtual(TInt aId, TInt aNumPages)=0; |
|
452 |
virtual TInt UnmapUnownedPages(TInt aId, TUint32 aAddr, TInt aNumPages, TPhysAddr* aPageList, TLinAddr* aLAPageList, TInt& aNumPtes, TInt& aNumFree, DProcess* aProcess)=0; |
|
453 |
virtual TInt UnmapVirtual(TInt aId, TUint32 aAddr, TInt aNumPages, TPhysAddr* aPageList, TBool aSetPagesFree, TInt& aNumPtes, TInt& aNumFree, DProcess* aProcess)=0; |
|
454 |
virtual TInt UnmapUnownedVirtual(TInt aId, TUint32 aAddr, TInt aNumPages, TPhysAddr* aPageList, TLinAddr* aLAPageList, TInt& aNumPtes, TInt& aNumFree, DProcess* aProcess)=0; |
|
455 |
virtual void RemapPageByAsid(TBitMapAllocator* aOsAsids, TLinAddr aLinAddr, TPhysAddr aOldAddr, TPhysAddr aNewAddr, TPte aPtePerm)=0; |
|
456 |
virtual void CacheMaintenanceOnDecommit(const TPhysAddr* aPhysAddr, TInt aPageCount)=0; |
|
457 |
virtual void CacheMaintenanceOnDecommit(const TPhysAddr aPhysAddr)=0; // Maintains physical (VIPT & PIPT) cache for pages to be reused. |
|
458 |
virtual void CacheMaintenanceOnPreserve(const TPhysAddr* aPhysAddr, TInt aPageCount, TUint iMapAttr)=0; |
|
459 |
virtual void CacheMaintenanceOnPreserve(const TPhysAddr aPhysAddr, TUint iMapAttr)=0; |
|
460 |
virtual void CacheMaintenanceOnPreserve(TPhysAddr aPhysAddr, TInt aSize, TLinAddr aLinAddr, TUint iMapAttr)=0; |
|
461 |
||
462 |
public: |
|
463 |
inline static Mmu& Get() |
|
464 |
{return *(Mmu*)TheMmu;} |
|
465 |
static void Panic(TPanic aPanic); |
|
466 |
public: |
|
467 |
TInt iNumOsAsids; |
|
468 |
TInt iNumGlobalPageDirs; |
|
469 |
TBitMapAllocator* iOsAsidAllocator; |
|
470 |
TInt iGlobalPdSize; |
|
471 |
TInt iGlobalPdShift; |
|
472 |
TInt iLocalPdSize; |
|
473 |
TInt iLocalPdShift; |
|
474 |
TInt iAsidGroupSize; // number of global page directories mapped by a page table |
|
475 |
TInt iAsidGroupMask; // number of global page directories mapped by a page table - 1 |
|
476 |
TInt iAsidGroupShift; // log2(number of global page directories mapped by a page table) |
|
477 |
TInt iAliasSize; // minimum allowed spacing between synonyms of any physical address |
|
478 |
TInt iAliasMask; |
|
479 |
TInt iAliasShift; |
|
480 |
TLinAddr iUserLocalBase; // lowest local data address |
|
481 |
TLinAddr iUserLocalEnd; // 1+highest local data address (lowest DLL data address) |
|
482 |
TLinAddr iUserSharedBase; // lowest shared data address (1+highest DLL data address) |
|
483 |
TLinAddr iUserSharedEnd; // 1+highest shared data address (=local PD size) |
|
484 |
TLinAddr iDllDataBase; |
|
485 |
TInt iMaxDllDataSize; |
|
486 |
TLinAddr iUserCodeBase; |
|
487 |
TInt iMaxUserCodeSize; |
|
488 |
TUint32* iAsidInfo; |
|
489 |
TLinAddr iPdeBase; |
|
490 |
TPte iPdPtePerm; |
|
491 |
TPde iPdPdePerm; |
|
492 |
TPte iUserCodeLoadPtePerm; |
|
493 |
TPte iKernelCodePtePerm; |
|
494 |
TPte iGlobalCodePtePerm; |
|
495 |
TUint32 iRamDriveMask; |
|
496 |
TLinearSection* iSharedSection; |
|
497 |
TLinearSection* iUserGlobalSection; |
|
498 |
DMemModelChunk* iGlobalCode; |
|
499 |
SDblQue iAliasList; |
|
500 |
TInt iTempMapCount; |
|
501 |
TInt iSecondTempMapCount; |
|
502 |
TPte* iSecondTempPte; // second PTE used for temporary mappings |
|
503 |
TLinAddr iSecondTempAddr; // address corresponding to iSecondTempPte |
|
504 |
TInt iCacheMaintenanceTempMapAttr; // holds SP_PTE's attr. entry for cache maintenance |
|
505 |
// temporary mapping. |
|
506 |
public: |
|
507 |
friend class Monitor; |
|
508 |
friend TPte& PageTableEntry(TLinAddr aLinAddr); |
|
509 |
}; |
|
510 |
||
511 |
||
512 |
/******************************************** |
|
513 |
* Functions/Data defined in memory model |
|
514 |
********************************************/ |
|
515 |
||
516 |
/** |
|
517 |
@internalComponent |
|
518 |
*/ |
|
519 |
class MM |
|
520 |
{ |
|
521 |
public: |
|
522 |
enum TMemModelPanic |
|
523 |
{ |
|
524 |
EChunkTransferBadOwner=0, |
|
525 |
EChunkDecommitNoPageTable=1, |
|
526 |
EChunkTransferAllocAddrFailed=2, |
|
527 |
EFsRegisterThread=3, |
|
528 |
EClaimInitialPagesBadPageTable=4, |
|
529 |
EChunkNotDisconnected1=5, |
|
530 |
EChunkNotDisconnected2=6, |
|
531 |
EChunkCommitNoPageTable=7, |
|
532 |
EProcessDestructChunksRemaining=8, |
|
533 |
ECommitInvalidDllDataAddress=9, |
|
534 |
EDecommitInvalidDllDataAddress=10, |
|
535 |
EChunkApplyPermissions1=11, |
|
536 |
EChunkApplyPermissions2=12, |
|
537 |
ECodeSegLoadedNotCreator=13, |
|
538 |
EChunkBadAddressRange=14, |
|
539 |
EPdeAlreadyInUse=15, |
|
540 |
EPteAlreadyInUse=16, |
|
541 |
EMmuMapNoPageTable=17, |
|
542 |
EUnmapBadAlignment=18, |
|
543 |
EBootstrapPageTableBadAddr=19, |
|
544 |
ETempMappingAlreadyInUse=20, |
|
545 |
EDecommitFailed=21, |
|
546 |
EPageTableNotFound=22, |
|
547 |
EUnexpectedPageType=23, |
|
548 |
EOperationNotSupported=24, |
|
549 |
EChunkRemapNoPageTable=25, |
|
550 |
EChunkRemapUnsupported=26, |
|
551 |
ECodeSegRemapWrongPage=27, |
|
552 |
EChunkRemapWrongPageTable=28, |
|
553 |
ETempMappingNoRoom=29, |
|
554 |
}; |
|
555 |
||
556 |
static void Panic(TMemModelPanic aPanic); |
|
557 |
public: |
|
558 |
static void Init1(); |
|
559 |
static void StartCrashDebugger(); |
|
560 |
public: |
|
561 |
static TInt MaxPagesInOneGo; |
|
562 |
static DMemModelChunk* SvStackChunk; |
|
563 |
static DMemModelChunk* TheRamDriveChunk; |
|
564 |
static TBitMapAllocator* UserCodeAllocator; |
|
565 |
static TBitMapAllocator* DllDataAllocator; |
|
566 |
}; |
|
567 |
||
568 |
#endif |