1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kernel/eka/include/memmodel/epoc/multiple/memmodel.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,554 @@
1.4 +// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// e32\include\memmodel\epoc\multiple\memmodel.h
1.18 +//
1.19 +// WARNING: This file contains some APIs which are internal and are subject
1.20 +// to change without notice. Such APIs should therefore not be used
1.21 +// outside the Kernel and Hardware Services package.
1.22 +//
1.23 +
1.24 +#ifndef __MEMMODEL_H__
1.25 +#define __MEMMODEL_H__
1.26 +#include <memmodel/epoc/mmubase/mmubase.h>
1.27 +
1.28 +#ifdef __SMP__
1.29 +// SubScheduler fields for each processor
1.30 +#define i_AliasLinAddr iExtras[0]
1.31 +#define i_AliasPdePtr iExtras[1]
1.32 +#endif
1.33 +
1.34 +/********************************************
1.35 + * Dynamic Branch Predictor Support
1.36 + ********************************************/
1.37 +
1.38 +/**
1.39 +@internalComponent
1.40 +*/
1.41 +#ifdef __SMP__
1.42 +//#define LastUserSelfMod ((DProcess*&)SubScheduler().iExtras[0])
1.43 +#else
1.44 +#define LastUserSelfMod ((DProcess*&)TheScheduler.iExtras[0])
1.45 +#endif
1.46 +
1.47 +/********************************************
1.48 + * RAM Defrag Page Table Moving Support
1.49 + ********************************************/
1.50 +
1.51 +/**
1.52 +@internalComponent
1.53 +*/
1.54 +#define AliasRemapOld ((TPhysAddr&)TheScheduler.iExtras[1])
1.55 +
1.56 +/**
1.57 +@internalComponent
1.58 +*/
1.59 +#define AliasRemapNew ((TPhysAddr&)TheScheduler.iExtras[2])
1.60 +
1.61 +/********************************************
1.62 + * Thread Control Block
1.63 + ********************************************/
1.64 +
1.65 +class DMemModelProcess;
1.66 +
1.67 +/**
1.68 +@internalComponent
1.69 +*/
1.70 +class DMemModelThread : public DThread
1.71 + {
1.72 +public:
1.73 + TInt Alias(TLinAddr aAddr, DMemModelProcess* aProcess, TInt aSize, TInt aPerm, TLinAddr& aAliasAddr, TInt& aAliasSize);
1.74 + void RemoveAlias();
1.75 + virtual void DoExit1();
1.76 + static void RestoreAddressSpace();
1.77 +public:
1.78 + TLinAddr iAliasLinAddr; // linear address to access aliased memory (0 means no alias is present).
1.79 + TPde* iAliasPdePtr; // Address of PDE which has been modified to make aliased memory accessible.
1.80 + TPde iAliasPde; // PDE to store at iAliasPdePtr.
1.81 + TInt iAliasOsAsid; // asid for the process whoes memory is aliased.
1.82 + SDblQueLink iAliasLink; // link to make TheMmu.iAliasList.
1.83 + TLinAddr iAliasTarget; // linear address of the memory which has been aliased
1.84 +#ifdef __SMP__
1.85 + TInt iCpuRestoreCookie;
1.86 +#endif
1.87 + };
1.88 +
1.89 +
1.90 +/********************************************
1.91 + * Process Control Block
1.92 + ********************************************/
1.93 +
1.94 +class DMemModelChunk;
1.95 +class DMemModelCodeSegMemory;
1.96 +
1.97 +/**
1.98 +@internalComponent
1.99 +*/
1.100 +class DMemModelProcess : public DEpocProcess
1.101 + {
1.102 +public:
1.103 + void Destruct();
1.104 +public:
1.105 + virtual TInt DoCreate(TBool aKernelProcess, TProcessCreateInfo& aInfo);
1.106 + virtual TInt NewChunk(DChunk*& aChunk, SChunkCreateInfo& aInfo, TLinAddr& aRunAddr);
1.107 + virtual TInt AddChunk(DChunk* aChunk,TBool isReadOnly);
1.108 + virtual TInt NewShPool(DShPool*& aPool, TShPoolCreateInfo& aInfo);
1.109 + virtual TInt CreateDataBssStackArea(TProcessCreateInfo& aInfo);
1.110 + virtual TInt MapCodeSeg(DCodeSeg* aCodeSeg);
1.111 + virtual void UnmapCodeSeg(DCodeSeg* aCodeSeg);
1.112 + virtual void RemoveDllData();
1.113 + virtual void FinalRelease();
1.114 +public:
1.115 + virtual TInt GetNewChunk(DMemModelChunk*& aChunk, SChunkCreateInfo& aInfo)=0;
1.116 +public:
1.117 + TInt AddChunk(DMemModelChunk* aChunk, TLinAddr& aDataSectionBase, TBool isReadOnly);
1.118 + TInt AllocateDataSectionBase(DMemModelChunk& aChunk, TUint& aBase);
1.119 + TUint8* DataSectionBase(DMemModelChunk* aChunk);
1.120 + void RemoveChunk(DMemModelChunk *aChunk);
1.121 + void DoRemoveChunk(TInt aIndex);
1.122 + TInt ChunkIndex(DMemModelChunk* aChunk,TInt& aPos);
1.123 + TInt CreateCodeChunk();
1.124 + void FreeCodeChunk();
1.125 + TInt CreateDllDataChunk();
1.126 + void FreeDllDataChunk();
1.127 + TInt CommitDllData(TLinAddr aBase, TInt aSize);
1.128 + void DecommitDllData(TLinAddr aBase, TInt aSize);
1.129 + TInt MapUserRamCode(DMemModelCodeSegMemory* aMemory, TBool aLoading);
1.130 + void UnmapUserRamCode(DMemModelCodeSegMemory* aMemory, TBool aLoading);
1.131 +public:
1.132 + enum TMemModelProcessAttributes
1.133 + {
1.134 + ESeparateGlobalSpace=0x40000000,
1.135 + EMMProcessAttributesMask = ESeparateGlobalSpace,
1.136 + };
1.137 +
1.138 + struct SChunkInfo
1.139 + {
1.140 + DMemModelChunk* iChunk;
1.141 + TInt16 iAccessCount;
1.142 + TInt16 isReadOnly;
1.143 + };
1.144 +
1.145 + TInt iChunkCount;
1.146 + TInt iChunkAlloc;
1.147 + SChunkInfo* iChunks;
1.148 + TLinearSection* iLocalSection;
1.149 + TInt iOsAsid;
1.150 + TPhysAddr iLocalPageDir;
1.151 + TPhysAddr iGlobalPageDir;
1.152 + TUint32 iAddressCheckMaskR;
1.153 + TUint32 iAddressCheckMaskW;
1.154 + DMemModelChunk* iCodeChunk;
1.155 + DMemModelChunk* iDllDataChunk;
1.156 + TInt iSelfModChunks;
1.157 +public:
1.158 + friend class Monitor;
1.159 + };
1.160 +
1.161 +
1.162 +/********************************************
1.163 + * Chunk Control Block
1.164 + ********************************************/
1.165 +
1.166 +/**
1.167 +@internalComponent
1.168 +*/
1.169 +class DMemModelChunk : public DChunk
1.170 + {
1.171 +public:
1.172 + /**
1.173 + @see DChunk::TChunkAttributes for generic attribute flags
1.174 + */
1.175 + enum TMemModelChunkAttributes
1.176 + {
1.177 + EPrivate =0x80000000,
1.178 + ECode =0x40000000,
1.179 + EAddressAllocDown =0x20000000,
1.180 +
1.181 + EAddressRangeMask =0x0f000000,
1.182 + EAddressRangeShift =24,
1.183 + EAddressLocal =0x00000000,
1.184 + EAddressShared =0x01000000,
1.185 + EAddressUserGlobal =0x02000000,
1.186 + EAddressKernel =0x03000000,
1.187 + EAddressFixed =0x04000000,
1.188 +
1.189 + EMapTypeMask =0x00c00000,
1.190 + EMapTypeLocal =0x00000000,
1.191 + EMapTypeGlobal =0x00400000,
1.192 + EMapTypeShared =0x00800000,
1.193 +
1.194 + EMMChunkAttributesMask = EPrivate|ECode|EAddressAllocDown|EAddressRangeMask|EMapTypeMask,
1.195 + };
1.196 +
1.197 +public:
1.198 + DMemModelChunk();
1.199 + void Destruct();
1.200 +public:
1.201 + virtual TInt Close(TAny* aPtr);
1.202 + virtual TInt DoCreate(SChunkCreateInfo& aInfo);
1.203 + virtual TInt Adjust(TInt aNewSize);
1.204 + virtual TInt AdjustDoubleEnded(TInt aBottom, TInt aTop);
1.205 + virtual TInt CheckAccess();
1.206 + virtual TInt Commit(TInt aOffset, TInt aSize, TCommitType aCommitType=DChunk::ECommitDiscontiguous, TUint32* aExtraArg=0);
1.207 + virtual TInt Allocate(TInt aSize, TInt aGuard=0, TInt aAlign=0);
1.208 + virtual TInt Decommit(TInt aOffset, TInt aSize);
1.209 + virtual TInt Lock(TInt anOffset, TInt aSize);
1.210 + virtual TInt Unlock(TInt anOffset, TInt aSize);
1.211 + virtual TInt Address(TInt aOffset, TInt aSize, TLinAddr& aKernelAddress);
1.212 + virtual TInt PhysicalAddress(TInt aOffset, TInt aSize, TLinAddr& aKernelAddress, TUint32& aPhysicalAddress, TUint32* aPhysicalPageList=NULL);
1.213 + virtual void BTracePrime(TInt aCategory);
1.214 + virtual void Substitute(TInt aOffset, TPhysAddr aOldAddr, TPhysAddr aNewAddr);
1.215 + virtual TUint8* Base(DProcess* aProcess);
1.216 + inline TUint8* Base() const { return DChunk::Base(); }
1.217 +public:
1.218 + TInt Decommit(TInt aOffset, TInt aSize, TDecommitType aDecommitType);
1.219 + void ClaimInitialPages();
1.220 + void SetFixedAddress(TLinAddr aAddr, TInt aInitialSize);
1.221 + TInt Reserve(TInt aInitialSize);
1.222 + TInt DoCommit(TInt aOffset, TInt aSize, TCommitType aCommitType=DChunk::ECommitDiscontiguous, TUint32* aExtraArg=0);
1.223 + void DoDecommit(TInt aOffset, TInt aSize, TDecommitType aDecommitType=EDecommitNormal);
1.224 + TInt AllocateAddress();
1.225 + void ApplyPermissions(TInt aOffset, TInt aSize, TPte aPtePerm);
1.226 + TLinearSection* LinearSection();
1.227 + TZonePageType GetPageType();
1.228 +
1.229 +public:
1.230 + virtual TInt SetupPermissions()=0;
1.231 +
1.232 +public:
1.233 + TBitMapAllocator* iOsAsids; // NULL for local or fully global else list of OS ASIDs
1.234 + TPte iPtePermissions;
1.235 + TPde iPdePermissions;
1.236 + TUint16* iPageTables;
1.237 + TBitMapAllocator* iPageBitMap; // NULL if not disconnected chunk
1.238 + TBitMapAllocator* iPermanentPageBitMap;
1.239 + DMemModelChunk* iKernelMirror;
1.240 +public:
1.241 + friend class Monitor;
1.242 + };
1.243 +
1.244 +
1.245 +/********************************************
1.246 + * Code segment
1.247 + ********************************************/
1.248 +
1.249 +/**
1.250 +@internalComponent
1.251 +*/
1.252 +class DMemModelCodeSegMemory : public DMmuCodeSegMemory
1.253 + {
1.254 +public:
1.255 + DMemModelCodeSegMemory(DEpocCodeSeg* aCodeSeg);
1.256 + ~DMemModelCodeSegMemory();
1.257 + TInt Create(TCodeSegCreateInfo& aInfo);
1.258 + TInt Loaded(TCodeSegCreateInfo& aInfo);
1.259 + void Substitute(TInt aOffset, TPhysAddr aOld, TPhysAddr aNew);
1.260 + void Destroy();
1.261 +public:
1.262 + DMemModelProcess* iCreator; // process loading this code segment
1.263 +
1.264 + TPhysAddr* iPages; // list of physical pages (iPageCount+iDataPageCount)
1.265 +
1.266 + /**
1.267 + List of OS ASIDs this code segment is mapped into.
1.268 + Protected by RamAllocMutex and System Lock.
1.269 + */
1.270 + TBitMapAllocator* iOsAsids;
1.271 +
1.272 + TLinAddr* iCopyOfExportDir; // kernel side copy of export directory or NULL
1.273 + };
1.274 +
1.275 +/**
1.276 +@internalComponent
1.277 +*/
1.278 +class DMemModelCodeSeg: public DEpocCodeSeg
1.279 + {
1.280 +public:
1.281 + DMemModelCodeSeg();
1.282 + virtual ~DMemModelCodeSeg();
1.283 + virtual TInt DoCreateRam(TCodeSegCreateInfo& aInfo, DProcess* aProcess);
1.284 + virtual TInt DoCreateXIP(DProcess* aProcess);
1.285 + virtual TInt Loaded(TCodeSegCreateInfo& aInfo);
1.286 + virtual void ReadExportDir(TUint32* aDest);
1.287 + virtual TBool FindCheck(DProcess* aProcess);
1.288 + virtual TBool OpenCheck(DProcess* aProcess);
1.289 + virtual void BTracePrime(TInt aCategory);
1.290 + inline DMemModelCodeSegMemory* Memory()
1.291 + { return (DMemModelCodeSegMemory*)iMemory; }
1.292 + inline TPhysAddr* Pages()
1.293 + { return iMemory!=0 ? Memory()->iPages : (TPhysAddr*)0; }
1.294 +public:
1.295 + TInt iCodeAllocBase;
1.296 + TInt iDataAllocBase;
1.297 + TAny* iKernelData; // only for kernel modules
1.298 + };
1.299 +
1.300 +
1.301 +/********************************************
1.302 + * MMU stuff
1.303 + ********************************************/
1.304 +
1.305 +/**
1.306 +@internalComponent
1.307 +Indicates that corresponding linear address applies to unknown address space.
1.308 +Common for EMemTypeShared types of chunks with no owning process.
1.309 +*/
1.310 +#define UNKNOWN_MAPPING ((TInt)-2)
1.311 +
1.312 +/**
1.313 +@internalComponent
1.314 +Indicates that corresponding linear address applies to global address space.
1.315 +*/
1.316 +#define GLOBAL_MAPPING ((const TAny*)-1)
1.317 +
1.318 + /**
1.319 +@internalComponent
1.320 +Indicates that corresponding linear address applies to kernel process (either global or Kernel's local space).
1.321 +*/
1.322 +#define KERNEL_MAPPING ((TInt)0)
1.323 +
1.324 +
1.325 +/**
1.326 +@internalComponent
1.327 +*/
1.328 +class Mmu : public MmuBase
1.329 + {
1.330 +public:
1.331 + enum TFlushFlags {
1.332 + EFlushDTLB=0x01,
1.333 + EFlushDCache=0x02,
1.334 + EFlushITLB=0x04,
1.335 + EFlushICache=0x08,
1.336 + EFlushDDecommit=0x80000000,
1.337 + EFlushDPermChg=0x20000000,
1.338 + EFlushDMove=0x40000000,
1.339 + EFlushIPermChg=0x04000000,
1.340 + EFlushIMove=0x10000000,
1.341 + EFlushInheritMask=EFlushDPermChg|EFlushDMove|EFlushIPermChg|EFlushIMove,
1.342 + };
1.343 +
1.344 + enum TPanic
1.345 + {
1.346 + ELocalPageDirBadAsid,
1.347 + EGlobalPageDirBadAsid,
1.348 + EPDEBadAsid,
1.349 + EFreeOsAsidBadAsid,
1.350 + EOsAsidAllocCreateFailed,
1.351 + EBadInitialPageAddr,
1.352 + EAssignPageTableInvalidUsage,
1.353 + EUserCodeAllocatorCreateFailed,
1.354 + EDllDataAllocatorCreateFailed,
1.355 + ERomUserDataAddressInvalid,
1.356 + ERomUserDataSizeInvalid,
1.357 + ECreateSharedSectionFailed,
1.358 + ECreateUserGlobalSectionFailed,
1.359 + ERemapPageFailed,
1.360 + ERemapPageTableFailed,
1.361 + EFixupXPTFailed,
1.362 + ETempMappingFailed,
1.363 + EDefragDisablePageFailed,
1.364 + EDefragFaultWhilstFMHeld,
1.365 + };
1.366 +
1.367 +public:
1.368 + TPde* LocalPageDir(TInt aOsAsid);
1.369 + TPde* GlobalPageDir(TInt aOsAsid);
1.370 + TPde& PDE(TLinAddr aAddr, TInt aOsAsid);
1.371 + TInt NewOsAsid(TBool aSeparateGlobal);
1.372 + void FreeOsAsid(TInt aOsAsid);
1.373 + void CreateUserGlobalSection(TLinAddr aBase, TLinAddr aEnd);
1.374 + TInt CreateGlobalCodeChunk();
1.375 +
1.376 + // virtual - inherited/overridden from MmuBase
1.377 + virtual void Init1();
1.378 +// virtual void Init2();
1.379 + virtual void DoInit2();
1.380 +// virtual TBool PteIsPresent(TPte aPte)=0;
1.381 +// virtual TPhysAddr PtePhysAddr(TPte aPte, TInt aPteIndex)=0;
1.382 +// virtual TPhysAddr PdePhysAddr(TLinAddr aAddr)=0;
1.383 + virtual void SetupInitialPageInfo(SPageInfo* aPageInfo, TLinAddr aChunkAddr, TInt aPdeIndex);
1.384 + virtual void SetupInitialPageTableInfo(TInt aId, TLinAddr aChunkAddr, TInt aNumPtes);
1.385 + virtual void AssignPageTable(TInt aId, TInt aUsage, TAny* aObject, TLinAddr aAddr, TPde aPdePerm);
1.386 + virtual TInt UnassignPageTable(TLinAddr aAddr);
1.387 +// virtual void BootstrapPageTable(TInt aXptId, TPhysAddr aXptPhys, TInt aId, TPhysAddr aPhysAddr)=0;
1.388 + virtual TInt PageTableId(TLinAddr aAddr);
1.389 +// virtual TInt BootPageTableId(TLinAddr aAddr, TPhysAddr& aPtPhys)=0;
1.390 +// virtual void ClearPageTable(TInt aId, TInt aFirstIndex=0)=0;
1.391 + virtual TPhysAddr LinearToPhysical(TLinAddr aAddr);
1.392 + virtual TInt LinearToPhysical(TLinAddr aAddr, TInt aSize, TPhysAddr& aPhysicalAddress, TPhysAddr* aPhysicalPageList=NULL);
1.393 +// virtual void MapRamPages(TInt aId, SPageInfo::TType aType, TAny* aPtr, TUint32 aOffset, const TPhysAddr* aPageList, TInt aNumPages, TPte aPtePerm)=0;
1.394 +// virtual void MapPhysicalPages(TInt aId, SPageInfo::TType aType, TAny* aPtr, TUint32 aOffset, TPhysAddr aPhysAddr, TInt aNumPages, TPte aPtePerm)=0;
1.395 +// virtual TInt UnmapPages(TInt aId, TUint32 aAddr, TInt aNumPages, TPhysAddr* aPageList, TBool aSetPagesFree, TInt& aNumPtes, TInt& aNumFree, DProcess* aProcess)=0;
1.396 +// virtual void ClearRamDrive(TLinAddr aStart)=0;
1.397 +// virtual TInt PdePtePermissions(TUint& aMapAttr, TPde& aPde, TPte& aPte)=0;
1.398 +// virtual void Map(TLinAddr aLinAddr, TPhysAddr aPhysAddr, TInt aSize, TPde aPdePerm, TPte aPtePerm, TInt aMapShift)=0;
1.399 +// virtual void Unmap(TLinAddr aLinAddr, TInt aSize)=0;
1.400 +// virtual void InitShadowPageTable(TInt aId, TLinAddr aRomAddr, TPhysAddr aOrigPhys)=0;
1.401 +// virtual void InitShadowPage(TPhysAddr aShadowPhys, TLinAddr aRomAddr)=0;
1.402 +// virtual void DoUnmapShadowPage(TInt aId, TLinAddr aRomAddr, TPhysAddr aOrigPhys)=0;
1.403 +// virtual TInt UnassignShadowPageTable(TLinAddr aRomAddr, TPhysAddr aOrigPhys)=0;
1.404 +// virtual void DoFreezeShadowPage(TInt aId, TLinAddr aRomAddr)=0;
1.405 +// virtual void FlushShadow(TLinAddr aRomAddr)=0;
1.406 +// virtual void AssignShadowPageTable(TInt aId, TLinAddr aRomAddr)=0;
1.407 +// virtual void ClearPages(TInt aNumPages, TPhysAddr* aPageList)=0;
1.408 + virtual TPte PtePermissions(TChunkType aChunkType)=0;
1.409 + virtual TInt MoveKernelPage(DChunk* aChunk, TUint32 aOffset, TPhysAddr aOld, TPhysAddr& aNew, TUint aBlockZoneId, TBool aBlockRest);
1.410 + virtual TInt MoveCodeSegMemoryPage(DMemModelCodeSegMemory* aCodeSegMemory, TUint32 aOffset, TPhysAddr aOld, TPhysAddr& aNew, TUint aBlockZoneId, TBool aBlockRest);
1.411 + virtual TInt MoveCodeChunkPage(DChunk* aChunk, TUint32 aOffset, TPhysAddr aOld, TPhysAddr& aNew, TUint aBlockZoneId, TBool aBlockRest);
1.412 + virtual TInt MoveDataChunkPage(DChunk* aChunk, TUint32 aOffset, TPhysAddr aOld, TPhysAddr& aNew, TUint aBlockZoneId, TBool aBlockRest);
1.413 +
1.414 + // pure virtual - new in Mmu
1.415 + virtual TInt NewPageDirectory(TInt aOsAsid, TBool aSeparateGlobal, TPhysAddr& aPhysAddr, TInt& aNumPages)=0;
1.416 + virtual void InitPageDirectory(TInt aOsAsid, TBool aGlobal)=0;
1.417 + virtual TInt PageTableId(TLinAddr aAddr, TInt aOsAsid)=0;
1.418 + virtual TPhysAddr LinearToPhysical(TLinAddr aAddr, TInt aOsAsid)=0;
1.419 + virtual TInt LinearToPhysical(TLinAddr aAddr, TInt aSize, TPhysAddr& aPhysicalAddress, TPhysAddr* aPhysicalPageList, TInt aOsAsid)=0;
1.420 + virtual TInt PreparePagesForDMA(TLinAddr aAddr, TInt aSize, TInt aOsAsid, TPhysAddr* aPhysicalPageList)=0;
1.421 + virtual TInt ReleasePagesFromDMA(TPhysAddr* aPhysicalPageList, TInt aPageCount)=0;
1.422 + virtual void DoAssignPageTable(TInt aId, TLinAddr aAddr, TPde aPdePerm, const TAny* aOsAsids)=0;
1.423 + virtual void RemapPageTableSingle(TPhysAddr aOld, TPhysAddr aNew, TLinAddr aAddr, TInt aOsAsid)=0;
1.424 + virtual void RemapPageTableMultiple(TPhysAddr aOld, TPhysAddr aNew, TLinAddr aAddr, const TAny* aOsAsids)=0;
1.425 + virtual void RemapPageTableGlobal(TPhysAddr aOld, TPhysAddr aNew, TLinAddr aAddr)=0;
1.426 + virtual void RemapPageTableAliases(TPhysAddr aOld, TPhysAddr aNew)=0;
1.427 + virtual void DoUnassignPageTable(TLinAddr aAddr, const TAny* aOsAsids)=0;
1.428 + virtual TPde PdePermissions(TChunkType aChunkType, TBool aRO)=0;
1.429 + virtual void ApplyTopLevelPermissions(TLinAddr aAddr, TInt aOsAsid, TInt aNumPdes, TPde aPdePerm)=0;
1.430 + virtual void ApplyPagePermissions(TInt aId, TInt aPageOffset, TInt aNumPages, TPte aPtePerm)=0;
1.431 + virtual void GenericFlush(TUint32 aMask)=0;
1.432 + virtual TLinAddr MapTemp(TPhysAddr aPage,TLinAddr aLinAddr, TInt aPages=1)=0;
1.433 + virtual TLinAddr MapTemp(TPhysAddr aPage,TLinAddr aLinAddr,TInt aPages, TMemoryType aMemType)=0;
1.434 + virtual TLinAddr MapSecondTemp(TPhysAddr aPage,TLinAddr aLinAddr, TInt aPages=1)=0;
1.435 + virtual void UnmapTemp()=0;
1.436 + virtual void UnmapSecondTemp()=0;
1.437 + virtual TBool ValidateLocalIpcAddress(TLinAddr aAddr,TInt aSize,TBool aWrite)=0;
1.438 + virtual TInt UnlockRamCachePages(TLinAddr aLinAddr, TInt aNumPages, DProcess* aProcess)=0;
1.439 + virtual TInt LockRamCachePages(TLinAddr aLinAddr, TInt aNumPages, DProcess* aProcess)=0;
1.440 + virtual void MapVirtual(TInt aId, TInt aNumPages)=0;
1.441 + virtual TInt UnmapUnownedPages(TInt aId, TUint32 aAddr, TInt aNumPages, TPhysAddr* aPageList, TLinAddr* aLAPageList, TInt& aNumPtes, TInt& aNumFree, DProcess* aProcess)=0;
1.442 + virtual TInt UnmapVirtual(TInt aId, TUint32 aAddr, TInt aNumPages, TPhysAddr* aPageList, TBool aSetPagesFree, TInt& aNumPtes, TInt& aNumFree, DProcess* aProcess)=0;
1.443 + virtual TInt UnmapUnownedVirtual(TInt aId, TUint32 aAddr, TInt aNumPages, TPhysAddr* aPageList, TLinAddr* aLAPageList, TInt& aNumPtes, TInt& aNumFree, DProcess* aProcess)=0;
1.444 + virtual void RemapPageByAsid(TBitMapAllocator* aOsAsids, TLinAddr aLinAddr, TPhysAddr aOldAddr, TPhysAddr aNewAddr, TPte aPtePerm)=0;
1.445 + virtual void CacheMaintenanceOnDecommit(const TPhysAddr* aPhysAddr, TInt aPageCount)=0;
1.446 + virtual void CacheMaintenanceOnDecommit(const TPhysAddr aPhysAddr)=0; // Maintains physical (VIPT & PIPT) cache for pages to be reused.
1.447 + virtual void CacheMaintenanceOnPreserve(const TPhysAddr* aPhysAddr, TInt aPageCount, TUint iMapAttr)=0;
1.448 + virtual void CacheMaintenanceOnPreserve(const TPhysAddr aPhysAddr, TUint iMapAttr)=0;
1.449 + virtual void CacheMaintenanceOnPreserve(TPhysAddr aPhysAddr, TInt aSize, TLinAddr aLinAddr, TUint iMapAttr)=0;
1.450 +
1.451 +public:
1.452 + inline static Mmu& Get()
1.453 + {return *(Mmu*)TheMmu;}
1.454 + static void Panic(TPanic aPanic);
1.455 +public:
1.456 + TInt iNumOsAsids;
1.457 + TInt iNumGlobalPageDirs;
1.458 + TBitMapAllocator* iOsAsidAllocator;
1.459 + TInt iGlobalPdSize;
1.460 + TInt iGlobalPdShift;
1.461 + TInt iLocalPdSize;
1.462 + TInt iLocalPdShift;
1.463 + TInt iAsidGroupSize; // number of global page directories mapped by a page table
1.464 + TInt iAsidGroupMask; // number of global page directories mapped by a page table - 1
1.465 + TInt iAsidGroupShift; // log2(number of global page directories mapped by a page table)
1.466 + TInt iAliasSize; // minimum allowed spacing between synonyms of any physical address
1.467 + TInt iAliasMask;
1.468 + TInt iAliasShift;
1.469 + TLinAddr iUserLocalBase; // lowest local data address
1.470 + TLinAddr iUserLocalEnd; // 1+highest local data address (lowest DLL data address)
1.471 + TLinAddr iUserSharedBase; // lowest shared data address (1+highest DLL data address)
1.472 + TLinAddr iUserSharedEnd; // 1+highest shared data address (=local PD size)
1.473 + TLinAddr iDllDataBase;
1.474 + TInt iMaxDllDataSize;
1.475 + TLinAddr iUserCodeBase;
1.476 + TInt iMaxUserCodeSize;
1.477 + TUint32* iAsidInfo;
1.478 + TLinAddr iPdeBase;
1.479 + TPte iPdPtePerm;
1.480 + TPde iPdPdePerm;
1.481 + TPte iUserCodeLoadPtePerm;
1.482 + TPte iKernelCodePtePerm;
1.483 + TPte iGlobalCodePtePerm;
1.484 + TUint32 iRamDriveMask;
1.485 + TLinearSection* iSharedSection;
1.486 + TLinearSection* iUserGlobalSection;
1.487 + DMemModelChunk* iGlobalCode;
1.488 + SDblQue iAliasList;
1.489 + TInt iTempMapCount;
1.490 + TInt iSecondTempMapCount;
1.491 + TPte* iSecondTempPte; // second PTE used for temporary mappings
1.492 + TLinAddr iSecondTempAddr; // address corresponding to iSecondTempPte
1.493 + TInt iCacheMaintenanceTempMapAttr; // holds SP_PTE's attr. entry for cache maintenance
1.494 + // temporary mapping.
1.495 +public:
1.496 + friend class Monitor;
1.497 + friend TPte& PageTableEntry(TLinAddr aLinAddr);
1.498 + };
1.499 +
1.500 +
1.501 +/********************************************
1.502 + * Functions/Data defined in memory model
1.503 + ********************************************/
1.504 +
1.505 +/**
1.506 +@internalComponent
1.507 +*/
1.508 +class MM
1.509 + {
1.510 +public:
1.511 + enum TMemModelPanic
1.512 + {
1.513 + EChunkTransferBadOwner=0,
1.514 + EChunkDecommitNoPageTable=1,
1.515 + EChunkTransferAllocAddrFailed=2,
1.516 + EFsRegisterThread=3,
1.517 + EClaimInitialPagesBadPageTable=4,
1.518 + EChunkNotDisconnected1=5,
1.519 + EChunkNotDisconnected2=6,
1.520 + EChunkCommitNoPageTable=7,
1.521 + EProcessDestructChunksRemaining=8,
1.522 + ECommitInvalidDllDataAddress=9,
1.523 + EDecommitInvalidDllDataAddress=10,
1.524 + EChunkApplyPermissions1=11,
1.525 + EChunkApplyPermissions2=12,
1.526 + ECodeSegLoadedNotCreator=13,
1.527 + EChunkBadAddressRange=14,
1.528 + EPdeAlreadyInUse=15,
1.529 + EPteAlreadyInUse=16,
1.530 + EMmuMapNoPageTable=17,
1.531 + EUnmapBadAlignment=18,
1.532 + EBootstrapPageTableBadAddr=19,
1.533 + ETempMappingAlreadyInUse=20,
1.534 + EDecommitFailed=21,
1.535 + EPageTableNotFound=22,
1.536 + EUnexpectedPageType=23,
1.537 + EOperationNotSupported=24,
1.538 + EChunkRemapNoPageTable=25,
1.539 + EChunkRemapUnsupported=26,
1.540 + ECodeSegRemapWrongPage=27,
1.541 + EChunkRemapWrongPageTable=28,
1.542 + ETempMappingNoRoom=29,
1.543 + };
1.544 +
1.545 + static void Panic(TMemModelPanic aPanic);
1.546 +public:
1.547 + static void Init1();
1.548 + static void StartCrashDebugger();
1.549 +public:
1.550 + static TInt MaxPagesInOneGo;
1.551 + static DMemModelChunk* SvStackChunk;
1.552 + static DMemModelChunk* TheRamDriveChunk;
1.553 + static TBitMapAllocator* UserCodeAllocator;
1.554 + static TBitMapAllocator* DllDataAllocator;
1.555 + };
1.556 +
1.557 +#endif