os/kernelhwsrv/kernel/eka/include/memmodel/epoc/direct/memmodel.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kernel/eka/include/memmodel/epoc/direct/memmodel.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,175 @@
     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\direct\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 <plat_priv.h>
    1.27 +
    1.28 +/********************************************
    1.29 + * Process Control Block
    1.30 + ********************************************/
    1.31 +
    1.32 +class DMemModelChunk;
    1.33 +
    1.34 +/**
    1.35 +@internalComponent
    1.36 +*/
    1.37 +class DMemModelProcess : public DEpocProcess
    1.38 +	{
    1.39 +public:
    1.40 +	void Destruct();
    1.41 +public:
    1.42 +	virtual TInt DoCreate(TBool aKernelProcess, TProcessCreateInfo& aInfo);
    1.43 +	virtual TInt NewChunk(DChunk*& aChunk, SChunkCreateInfo& anInfo, TLinAddr& aRunAddr);
    1.44 +	virtual TInt AddChunk(DChunk* aChunk,TBool isReadOnly);
    1.45 +	virtual TInt NewShPool(DShPool*& aPool, TShPoolCreateInfo& aInfo);
    1.46 +	virtual TInt CreateDataBssStackArea(TProcessCreateInfo& aInfo);
    1.47 +	virtual TInt MapCodeSeg(DCodeSeg* aCodeSeg);
    1.48 +	virtual void UnmapCodeSeg(DCodeSeg* aCodeSeg);
    1.49 +	virtual void RemoveDllData();
    1.50 +	virtual void FinalRelease();
    1.51 +public:
    1.52 +	friend class Monitor;
    1.53 +	};
    1.54 +
    1.55 +/********************************************
    1.56 + * Chunk Control Block
    1.57 + ********************************************/
    1.58 +
    1.59 +/**
    1.60 +@internalComponent
    1.61 +*/
    1.62 +class DMemModelChunk : public DChunk
    1.63 +	{
    1.64 +public:
    1.65 +	enum TMemModelChunkAttributes
    1.66 +		{
    1.67 +		EPrivate=0x10000000,
    1.68 +	
    1.69 +		EMMChunkAttributesMask = EPrivate,
    1.70 +		};
    1.71 +
    1.72 +public:
    1.73 +	~DMemModelChunk();
    1.74 +public:
    1.75 +//	virtual TInt Close(TAny* aPtr);
    1.76 +	virtual TInt DoCreate(SChunkCreateInfo& anInfo);
    1.77 +	virtual TInt Adjust(TInt aNewSize);
    1.78 +	virtual TInt AdjustDoubleEnded(TInt aBottom, TInt aTop);
    1.79 +	virtual TInt CheckAccess();
    1.80 +	virtual TInt Commit(TInt anOffset, TInt aSize, TCommitType aCommitType=DChunk::ECommitDiscontiguous, TUint32* aExtraArg=0);
    1.81 +	virtual TInt Allocate(TInt aSize, TInt aGuard=0, TInt aAlign=0);
    1.82 +	virtual TInt Decommit(TInt anOffset, TInt aSize);
    1.83 +	virtual TInt Lock(TInt anOffset, TInt aSize);
    1.84 +	virtual TInt Unlock(TInt anOffset, TInt aSize);
    1.85 +	virtual TInt Address(TInt aOffset, TInt aSize, TLinAddr& aKernelAddress);
    1.86 +	virtual TInt PhysicalAddress(TInt aOffset, TInt aSize, TLinAddr& aKernelAddress, TUint32& aPhysicalAddress, TUint32* aPhysicalPageList=NULL);
    1.87 +	virtual void BTracePrime(TInt aCategory);
    1.88 +	virtual void Substitute(TInt aOffset, TPhysAddr aOldAddr, TPhysAddr aNewAddr);
    1.89 +	virtual TUint8* Base(DProcess* aProcess);
    1.90 +	inline TUint8* Base() const { return DChunk::Base(); }
    1.91 +public:
    1.92 +	void SetFixedAddress(TLinAddr anAddr, TInt aSize);
    1.93 +public:
    1.94 +	TLinAddr iRegionBase;
    1.95 +	TInt iRegionSize;
    1.96 +public:
    1.97 +	friend class Monitor;
    1.98 +	};
    1.99 +
   1.100 +/********************************************
   1.101 + * Code segment
   1.102 + ********************************************/
   1.103 +
   1.104 +/**
   1.105 +@internalComponent
   1.106 +*/
   1.107 +class DMemModelCodeSegMemory : public DEpocCodeSegMemory
   1.108 +	{
   1.109 +public:
   1.110 +	DMemModelCodeSegMemory(DEpocCodeSeg* aCodeSeg);
   1.111 +	};
   1.112 +
   1.113 +/**
   1.114 +@internalComponent
   1.115 +*/
   1.116 +class DMemModelCodeSeg: public DEpocCodeSeg
   1.117 +	{
   1.118 +public:
   1.119 +	DMemModelCodeSeg();
   1.120 +	virtual ~DMemModelCodeSeg();
   1.121 +	virtual TInt DoCreateRam(TCodeSegCreateInfo& aInfo, DProcess* aProcess);
   1.122 +	virtual TInt DoCreateXIP(DProcess* aProcess);
   1.123 +	virtual TInt Loaded(TCodeSegCreateInfo& aInfo);
   1.124 +	virtual void ReadExportDir(TUint32* aDest);
   1.125 +	virtual TBool FindCheck(DProcess* aProcess);
   1.126 +	virtual TBool OpenCheck(DProcess* aProcess);
   1.127 +public:
   1.128 +	TLinAddr iDataAlloc;
   1.129 +	TAny* iKernelData;			// only for kernel modules
   1.130 +	};
   1.131 +
   1.132 +/********************************************
   1.133 + * Functions/Data defined in memory model
   1.134 + ********************************************/
   1.135 +
   1.136 +/**
   1.137 +@internalComponent
   1.138 +*/
   1.139 +class MM
   1.140 +	{
   1.141 +public:
   1.142 +	enum TMemModelPanic
   1.143 +		{
   1.144 +		ERamAllocCreateFailed=0,
   1.145 +		ERamAllocMutexCreateFailed=1,
   1.146 +		EFreeInvalidRegion=2,
   1.147 +		ECodeSegCheckInconsistent=3,
   1.148 +		ESecAllocCreateFailed=4,
   1.149 +		EUnsupportedOperation=5,
   1.150 +		};
   1.151 +
   1.152 +	static void Panic(TMemModelPanic aPanic);
   1.153 +public:
   1.154 +	static void Init1();
   1.155 +	static void StartCrashDebugger();
   1.156 +	static void WaitRamAlloc();
   1.157 +	static void SignalRamAlloc();
   1.158 +	static TUint32 RoundToBlockSize(TUint32 aSize);
   1.159 +	static void FreeRegion(TLinAddr aBase, TInt aSize);
   1.160 +	static TInt AllocRegion(TLinAddr& aBase, TInt aSize, TInt aAlign=0);
   1.161 +	static TInt ClaimRegion(TLinAddr aBase, TInt aSize);
   1.162 +	static TInt AllocContiguousRegion(TLinAddr& aBase, TInt aSize, TInt aAlign=0);
   1.163 +	static TInt BlockNumber(TPhysAddr aAddr);
   1.164 +public:
   1.165 +	static TLinAddr UserDataSectionBase;
   1.166 +	static TLinAddr UserRomDataSectionEnd;
   1.167 +	static TLinAddr UserDataSectionEnd;
   1.168 +	static TLinAddr RomLinearBase;
   1.169 +	static DMutex* RamAllocatorMutex;
   1.170 +	static TBitMapAllocator* RamAllocator;
   1.171 +	static TBitMapAllocator* SecondaryAllocator;
   1.172 +	static TInt RamBlockSize;
   1.173 +	static TInt RamBlockShift;
   1.174 +	static TInt InitialFreeMemory;
   1.175 +	static TBool AllocFailed;
   1.176 +	};
   1.177 +
   1.178 +#endif