sl@0: // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32\include\memmodel\epoc\direct\memmodel.h sl@0: // sl@0: // WARNING: This file contains some APIs which are internal and are subject sl@0: // to change without notice. Such APIs should therefore not be used sl@0: // outside the Kernel and Hardware Services package. sl@0: // sl@0: sl@0: #ifndef __MEMMODEL_H__ sl@0: #define __MEMMODEL_H__ sl@0: #include sl@0: sl@0: /******************************************** sl@0: * Process Control Block sl@0: ********************************************/ sl@0: sl@0: class DMemModelChunk; sl@0: sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: class DMemModelProcess : public DEpocProcess sl@0: { sl@0: public: sl@0: void Destruct(); sl@0: public: sl@0: virtual TInt DoCreate(TBool aKernelProcess, TProcessCreateInfo& aInfo); sl@0: virtual TInt NewChunk(DChunk*& aChunk, SChunkCreateInfo& anInfo, TLinAddr& aRunAddr); sl@0: virtual TInt AddChunk(DChunk* aChunk,TBool isReadOnly); sl@0: virtual TInt NewShPool(DShPool*& aPool, TShPoolCreateInfo& aInfo); sl@0: virtual TInt CreateDataBssStackArea(TProcessCreateInfo& aInfo); sl@0: virtual TInt MapCodeSeg(DCodeSeg* aCodeSeg); sl@0: virtual void UnmapCodeSeg(DCodeSeg* aCodeSeg); sl@0: virtual void RemoveDllData(); sl@0: virtual void FinalRelease(); sl@0: public: sl@0: friend class Monitor; sl@0: }; sl@0: sl@0: /******************************************** sl@0: * Chunk Control Block sl@0: ********************************************/ sl@0: sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: class DMemModelChunk : public DChunk sl@0: { sl@0: public: sl@0: enum TMemModelChunkAttributes sl@0: { sl@0: EPrivate=0x10000000, sl@0: sl@0: EMMChunkAttributesMask = EPrivate, sl@0: }; sl@0: sl@0: public: sl@0: ~DMemModelChunk(); sl@0: public: sl@0: // virtual TInt Close(TAny* aPtr); sl@0: virtual TInt DoCreate(SChunkCreateInfo& anInfo); sl@0: virtual TInt Adjust(TInt aNewSize); sl@0: virtual TInt AdjustDoubleEnded(TInt aBottom, TInt aTop); sl@0: virtual TInt CheckAccess(); sl@0: virtual TInt Commit(TInt anOffset, TInt aSize, TCommitType aCommitType=DChunk::ECommitDiscontiguous, TUint32* aExtraArg=0); sl@0: virtual TInt Allocate(TInt aSize, TInt aGuard=0, TInt aAlign=0); sl@0: virtual TInt Decommit(TInt anOffset, TInt aSize); sl@0: virtual TInt Lock(TInt anOffset, TInt aSize); sl@0: virtual TInt Unlock(TInt anOffset, TInt aSize); sl@0: virtual TInt Address(TInt aOffset, TInt aSize, TLinAddr& aKernelAddress); sl@0: virtual TInt PhysicalAddress(TInt aOffset, TInt aSize, TLinAddr& aKernelAddress, TUint32& aPhysicalAddress, TUint32* aPhysicalPageList=NULL); sl@0: virtual void BTracePrime(TInt aCategory); sl@0: virtual void Substitute(TInt aOffset, TPhysAddr aOldAddr, TPhysAddr aNewAddr); sl@0: virtual TUint8* Base(DProcess* aProcess); sl@0: inline TUint8* Base() const { return DChunk::Base(); } sl@0: public: sl@0: void SetFixedAddress(TLinAddr anAddr, TInt aSize); sl@0: public: sl@0: TLinAddr iRegionBase; sl@0: TInt iRegionSize; sl@0: public: sl@0: friend class Monitor; sl@0: }; sl@0: sl@0: /******************************************** sl@0: * Code segment sl@0: ********************************************/ sl@0: sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: class DMemModelCodeSegMemory : public DEpocCodeSegMemory sl@0: { sl@0: public: sl@0: DMemModelCodeSegMemory(DEpocCodeSeg* aCodeSeg); sl@0: }; sl@0: sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: class DMemModelCodeSeg: public DEpocCodeSeg sl@0: { sl@0: public: sl@0: DMemModelCodeSeg(); sl@0: virtual ~DMemModelCodeSeg(); sl@0: virtual TInt DoCreateRam(TCodeSegCreateInfo& aInfo, DProcess* aProcess); sl@0: virtual TInt DoCreateXIP(DProcess* aProcess); sl@0: virtual TInt Loaded(TCodeSegCreateInfo& aInfo); sl@0: virtual void ReadExportDir(TUint32* aDest); sl@0: virtual TBool FindCheck(DProcess* aProcess); sl@0: virtual TBool OpenCheck(DProcess* aProcess); sl@0: public: sl@0: TLinAddr iDataAlloc; sl@0: TAny* iKernelData; // only for kernel modules sl@0: }; sl@0: sl@0: /******************************************** sl@0: * Functions/Data defined in memory model sl@0: ********************************************/ sl@0: sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: class MM sl@0: { sl@0: public: sl@0: enum TMemModelPanic sl@0: { sl@0: ERamAllocCreateFailed=0, sl@0: ERamAllocMutexCreateFailed=1, sl@0: EFreeInvalidRegion=2, sl@0: ECodeSegCheckInconsistent=3, sl@0: ESecAllocCreateFailed=4, sl@0: EUnsupportedOperation=5, sl@0: }; sl@0: sl@0: static void Panic(TMemModelPanic aPanic); sl@0: public: sl@0: static void Init1(); sl@0: static void StartCrashDebugger(); sl@0: static void WaitRamAlloc(); sl@0: static void SignalRamAlloc(); sl@0: static TUint32 RoundToBlockSize(TUint32 aSize); sl@0: static void FreeRegion(TLinAddr aBase, TInt aSize); sl@0: static TInt AllocRegion(TLinAddr& aBase, TInt aSize, TInt aAlign=0); sl@0: static TInt ClaimRegion(TLinAddr aBase, TInt aSize); sl@0: static TInt AllocContiguousRegion(TLinAddr& aBase, TInt aSize, TInt aAlign=0); sl@0: static TInt BlockNumber(TPhysAddr aAddr); sl@0: public: sl@0: static TLinAddr UserDataSectionBase; sl@0: static TLinAddr UserRomDataSectionEnd; sl@0: static TLinAddr UserDataSectionEnd; sl@0: static TLinAddr RomLinearBase; sl@0: static DMutex* RamAllocatorMutex; sl@0: static TBitMapAllocator* RamAllocator; sl@0: static TBitMapAllocator* SecondaryAllocator; sl@0: static TInt RamBlockSize; sl@0: static TInt RamBlockShift; sl@0: static TInt InitialFreeMemory; sl@0: static TBool AllocFailed; sl@0: }; sl@0: sl@0: #endif