os/kernelhwsrv/kernel/eka/include/memmodel/epoc/flexible/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/flexible/memmodel.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,541 @@
     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/flexible/memmodel.h
    1.18 +// Flexible Memory Model header file
    1.19 +
    1.20 +/**
    1.21 + @file
    1.22 + @internalComponent
    1.23 +*/
    1.24 +
    1.25 +
    1.26 +#ifndef __MEMMODEL_H__
    1.27 +#define __MEMMODEL_H__
    1.28 +
    1.29 +#include <plat_priv.h>
    1.30 +#include <memmodel/epoc/mmubase/kblockmap.h>
    1.31 +#include <mmtypes.h>
    1.32 +#include <mmboot.h>
    1.33 +
    1.34 +#ifdef __SMP__
    1.35 +// SubScheduler fields for each processor
    1.36 +#define	i_AliasLinAddr			iExtras[0]
    1.37 +#define	i_AliasPdePtr			iExtras[1]
    1.38 +#endif
    1.39 +
    1.40 +/********************************************
    1.41 + * Deterministic Scheduler Implementation
    1.42 + ********************************************/
    1.43 +
    1.44 +/**
    1.45 +@internalComponent
    1.46 +*/
    1.47 +#define TheCurrentAddressSpace			((DMemModelProcess*&)TheScheduler.iAddressSpace)
    1.48 +
    1.49 +class DMemoryObject;
    1.50 +class DMemoryMapping;
    1.51 +
    1.52 +/********************************************
    1.53 + * Thread Control Block
    1.54 + ********************************************/
    1.55 +
    1.56 +class DMemModelProcess;
    1.57 +
    1.58 +/**
    1.59 +@internalComponent
    1.60 +*/
    1.61 +class DMemModelThread : public DThread
    1.62 +	{
    1.63 +public:
    1.64 +	TInt Alias(TLinAddr aAddr, DMemModelProcess* aProcess, TInt aSize, TLinAddr& aAliasAddr, TUint& aAliasSize);
    1.65 +	void RemoveAlias();
    1.66 +	void RefreshAlias();
    1.67 +	virtual void DoExit1();
    1.68 +	static void RestoreAddressSpace();
    1.69 + 	virtual void BTracePrime(TInt aCategory);
    1.70 +protected:
    1.71 +	virtual void SetPaging(TUint& aCreateFlags);
    1.72 +private:
    1.73 +	void DoRemoveAlias(TLinAddr aAddr);
    1.74 +public:
    1.75 +	TLinAddr iAliasLinAddr;	// linear address to access aliased memory (0 means no alias is present).
    1.76 +	TPde* iAliasPdePtr;		// Address of PDE which has been modified to make aliased memory accessible.
    1.77 +	TPde iAliasPde;			// PDE to store at iAliasPdePtr.
    1.78 +	DMemModelProcess* iAliasProcess;		// The process whose memory is aliased.
    1.79 +	SDblQueLink iAliasLink;	// link to make TheMmu.iAliasList.
    1.80 +	TLinAddr iAliasTarget;	// linear address of the memory which has been aliased
    1.81 +	DMemoryMapping* iKernelStackMapping;
    1.82 +	DMemoryMapping* iUserStackMapping;
    1.83 +#ifdef __SMP__
    1.84 +	TInt iCpuRestoreCookie;
    1.85 +#endif
    1.86 +	};
    1.87 +
    1.88 +
    1.89 +/********************************************
    1.90 + * Process Control Block
    1.91 + ********************************************/
    1.92 +
    1.93 +class DMemModelChunk;
    1.94 +class DMemModelCodeSegMemory;
    1.95 +class RAddressedContainer;
    1.96 +
    1.97 +#ifdef INCLUDED_FROM_ASM
    1.98 +#define PRIVATE_EXCEPT_ASM public
    1.99 +#else
   1.100 +#define PRIVATE_EXCEPT_ASM private
   1.101 +#endif
   1.102 +
   1.103 +
   1.104 +/**
   1.105 +@internalComponent
   1.106 +*/
   1.107 +class DMemModelProcess : public DEpocProcess
   1.108 +	{
   1.109 +public:
   1.110 +	~DMemModelProcess();
   1.111 +private:
   1.112 +	void Destruct();
   1.113 +protected:
   1.114 +	virtual TInt AttachExistingCodeSeg(TProcessCreateInfo& aInfo);
   1.115 +	virtual TInt SetPaging(const TProcessCreateInfo& aInfo);
   1.116 +public:
   1.117 +	virtual TInt DoCreate(TBool aKernelProcess, TProcessCreateInfo& aInfo);
   1.118 +	virtual TInt NewChunk(DChunk*& aChunk, SChunkCreateInfo& aInfo, TLinAddr& aRunAddr);
   1.119 +	virtual TInt AddChunk(DChunk* aChunk,TBool aIsReadOnly);
   1.120 +	virtual TInt NewShPool(DShPool*& aPool, TShPoolCreateInfo& aInfo);
   1.121 +	virtual TInt CreateDataBssStackArea(TProcessCreateInfo& aInfo);
   1.122 +	virtual TInt MapCodeSeg(DCodeSeg* aCodeSeg);
   1.123 +	virtual void UnmapCodeSeg(DCodeSeg* aCodeSeg);
   1.124 +	virtual void RemoveDllData();
   1.125 +	virtual void FinalRelease();
   1.126 +	virtual void BTracePrime(TInt aCategory);
   1.127 +public:
   1.128 +	TInt DoAddChunk(DMemModelChunk* aChunk, TBool aIsReadOnly);
   1.129 +	TInt AllocateDataSectionBase(DMemModelChunk& aChunk, TUint& aBase);
   1.130 +	TUint8* DataSectionBase(DMemModelChunk* aChunk);
   1.131 +	void RemoveChunk(DMemModelChunk *aChunk);
   1.132 +	void DoRemoveChunk(TInt aIndex);
   1.133 +	TInt ChunkIndex(DMemModelChunk* aChunk);
   1.134 +	TUint ChunkInsertIndex(DMemModelChunk* aChunk);
   1.135 +	TInt CommitDllData(TLinAddr aBase, TInt aSize, DCodeSeg* aCodeSeg);
   1.136 +	void DecommitDllData(TLinAddr aBase, TInt aSize);
   1.137 +	TInt MapUserRamCode(DMemModelCodeSegMemory* aMemory);
   1.138 +	void UnmapUserRamCode(DMemModelCodeSegMemory* aMemory);
   1.139 +	inline TInt OsAsid()
   1.140 +		{__NK_ASSERT_DEBUG(	TheCurrentThread->iOwningProcess == this || // current thread's process so asid can't be freed.
   1.141 +							iOsAsid == (TInt)KKernelOsAsid ||	// kernel process so asid can't be freed.
   1.142 +							iContainerID != EProcess ||	// process not fully created yet so asid can't be freed.
   1.143 +							iOsAsidRefCount > 1);		// if none of the others are true then should have a reference 
   1.144 +														// to prevent asid being freed (this check isn't very 
   1.145 +														// robust but best we can do).
   1.146 +		return iOsAsid;
   1.147 +		};
   1.148 +
   1.149 +	TInt TryOpenOsAsid();
   1.150 +	void CloseOsAsid();
   1.151 +	void AsyncCloseOsAsid();
   1.152 +public:
   1.153 +	struct SChunkInfo
   1.154 +		{
   1.155 +		DMemModelChunk* iChunk;
   1.156 +		DMemoryMapping* iMapping;
   1.157 +		TInt16 iAccessCount;
   1.158 +		TInt16 iIsReadOnly;
   1.159 +		};
   1.160 +
   1.161 +	TInt iChunkCount;
   1.162 +	TInt iChunkAlloc;
   1.163 +	SChunkInfo* iChunks;
   1.164 +	RAddressedContainer* iSharedChunks;
   1.165 +	TPhysAddr iPageDir;
   1.166 +	DMemoryMapping* iDataBssMapping;
   1.167 +	/**
   1.168 +	Size of virtual memory allocated in process for EXE code, but which hasn't yet been been
   1.169 +	adopted by the codeseg memory mapping.
   1.170 +	*/
   1.171 +	TUint iCodeVirtualAllocSize;
   1.172 +	/**
   1.173 +	Address of virtual memory allocated in process for EXE code.
   1.174 +	*/
   1.175 +	TLinAddr iCodeVirtualAllocAddress;
   1.176 +
   1.177 +PRIVATE_EXCEPT_ASM:
   1.178 +	TInt iOsAsid;		// This should only be accessed directly by the scheduler, 
   1.179 +						// in all other cases use either OsAsid() or TryOpenOsAsid().
   1.180 +private:
   1.181 +	TUint iOsAsidRefCount;
   1.182 +public:
   1.183 +	friend class Monitor;
   1.184 +	};
   1.185 +
   1.186 +
   1.187 +/********************************************
   1.188 + * Chunk Control Block
   1.189 + ********************************************/
   1.190 +
   1.191 +/**
   1.192 +@internalComponent
   1.193 +*/
   1.194 +class DMemModelChunk : public DChunk
   1.195 +	{
   1.196 +public:
   1.197 +	/**
   1.198 +	@see DChunk::TChunkAttributes for generic attribute flags
   1.199 +	*/
   1.200 +	enum TMemModelChunkAttributes
   1.201 +		{
   1.202 +		EPrivate			=0x00000000, // need to be iOwningProcess in order to map or change chunk
   1.203 +		EPublic				=0x80000000, // not EPrivate
   1.204 +		ECode				=0x40000000, // contents are executable
   1.205 +		EMMChunkAttributesMask = EPrivate | EPublic | ECode,
   1.206 +		};
   1.207 +	
   1.208 +public:
   1.209 +	DMemModelChunk();
   1.210 +	~DMemModelChunk();
   1.211 +public:
   1.212 +	virtual TInt Close(TAny* aPtr);
   1.213 +	virtual TInt DoCreate(SChunkCreateInfo& aInfo);
   1.214 +	virtual TInt Adjust(TInt aNewSize);
   1.215 +	virtual TInt AdjustDoubleEnded(TInt aBottom, TInt aTop);
   1.216 +	virtual TInt CheckAccess();
   1.217 +	virtual TInt Commit(TInt aOffset, TInt aSize, TCommitType aCommitType=DChunk::ECommitDiscontiguous, TUint32* aExtraArg=0);
   1.218 +	virtual TInt Allocate(TInt aSize, TInt aGuard=0, TInt aAlign=0);
   1.219 +	virtual TInt Decommit(TInt aOffset, TInt aSize);
   1.220 +	virtual TInt Lock(TInt aOffset, TInt aSize);
   1.221 +	virtual TInt Unlock(TInt aOffset, TInt aSize);
   1.222 +	virtual TInt Address(TInt aOffset, TInt aSize, TLinAddr& aKernelAddress);
   1.223 +	virtual TInt PhysicalAddress(TInt aOffset, TInt aSize, TLinAddr& aKernelAddress, TUint32& aPhysicalAddress, TUint32* aPhysicalPageList=NULL);
   1.224 +	virtual void BTracePrime(TInt aCategory);
   1.225 +	virtual void Substitute(TInt aOffset, TPhysAddr aOldAddr, TPhysAddr aNewAddr);
   1.226 +	virtual TUint8* Base(DProcess* aProcess);
   1.227 +protected:
   1.228 +	virtual void SetPaging(TUint aCreateAtt);
   1.229 +public:
   1.230 +	void SetFixedAddress(TLinAddr aAddr, TInt aInitialSize);
   1.231 +	TInt SetAttributes(SChunkCreateInfo& aInfo);
   1.232 +	TInt DoCommit(TInt aOffset, TInt aSize, TCommitType aCommitType=DChunk::ECommitDiscontiguous, TUint32* aExtraArg=0);
   1.233 +	void DoDecommit(TInt aOffset, TInt aSize);
   1.234 +	TInt CheckRegion(TInt& aOffset, TInt& aSize);
   1.235 +public:
   1.236 +	TBitMapAllocator* iPageBitMap;		// NULL if not disconnected chunk
   1.237 +	TBitMapAllocator* iPermanentPageBitMap;
   1.238 +
   1.239 +	/**
   1.240 +	The memory object containing this chunk's memory.
   1.241 +	*/
   1.242 +	DMemoryObject* iMemoryObject;
   1.243 +
   1.244 +	/**
   1.245 +	For shared chunks and shared i/o buffers this is the mapping
   1.246 +	which maps #iMemoryObject into the kernel's address space.
   1.247 +	*/
   1.248 +	DMemoryMapping* iKernelMapping;
   1.249 +public:
   1.250 +	friend class Monitor;
   1.251 +	};
   1.252 +
   1.253 +
   1.254 +/**
   1.255 +@internalComponent
   1.256 +*/
   1.257 +class DMemModelChunkHw : public DPlatChunkHw
   1.258 +	{
   1.259 +public:
   1.260 +	virtual TInt Close(TAny* aPtr);
   1.261 +public:
   1.262 +	DMemoryObject* iMemoryObject;
   1.263 +	DMemoryMapping* iKernelMapping;
   1.264 +	};
   1.265 +
   1.266 +
   1.267 +	
   1.268 +/********************************************
   1.269 + * Code segment
   1.270 + ********************************************/
   1.271 +
   1.272 +class TPagedCodeInfo;
   1.273 +
   1.274 +/**
   1.275 +@internalComponent
   1.276 +*/
   1.277 +class DMemModelCodeSegMemory : public DEpocCodeSegMemory
   1.278 +	{
   1.279 +public:
   1.280 +	DMemModelCodeSegMemory(DEpocCodeSeg* aCodeSeg);
   1.281 +	~DMemModelCodeSegMemory();
   1.282 +	TInt Create(TCodeSegCreateInfo& aInfo, DMemModelProcess* aProcess);
   1.283 +	TInt Loaded(TCodeSegCreateInfo& aInfo);
   1.284 +	void Destroy();
   1.285 +public:
   1.286 +	/**
   1.287 +	The process loading this code segment.
   1.288 +	*/
   1.289 +	DMemModelProcess* iCreator;
   1.290 +
   1.291 +	/**
   1.292 +	Kernel side copy of the codeseg's export directory or NULL.
   1.293 +	*/
   1.294 +	TLinAddr* iCopyOfExportDir;
   1.295 +
   1.296 +	/**
   1.297 +	For demand paged codeseg's, pointer to saved copy of the data section.
   1.298 +	*/
   1.299 +	TAny* iDataSectionMemory;
   1.300 +
   1.301 +	/**
   1.302 +	The memory object containing the memory for the codeseg.
   1.303 +	*/
   1.304 +	DMemoryObject* iCodeMemoryObject;
   1.305 +
   1.306 +	/**
   1.307 +	A writable mapping which maps #iCodeMemoryObject into the loader
   1.308 +	process's memory so it can be accessed by the loader.
   1.309 +
   1.310 +	This mapping is destroyed once #Loaded is called.
   1.311 +	*/
   1.312 +	DMemoryMapping* iCodeLoadMapping;
   1.313 +
   1.314 +	/**
   1.315 +	For demand paged codeseg's, this is a writable mapping added to the
   1.316 +	loader process's address space which maps a memory object used to
   1.317 +	hold the initial contents of the codeseg's data section.
   1.318 +
   1.319 +	This mapping, and it's memory object, is destroyed once #Loaded is called.
   1.320 +	*/
   1.321 +	DMemoryMapping* iDataLoadMapping;
   1.322 +
   1.323 +	/**
   1.324 +	Size of any shared virtual memory allocated for the code.
   1.325 +	*/
   1.326 +	TUint iVirtualAllocCommonSize;
   1.327 +
   1.328 +	/**
   1.329 +	For demand paged codeseg's, a pointer to the #TPagedCodeInfo
   1.330 +	used with #iCodeMemoryObject.
   1.331 +	*/
   1.332 +	TPagedCodeInfo* iPagedCodeInfo;
   1.333 +	};
   1.334 +
   1.335 +
   1.336 +/**
   1.337 +@internalComponent
   1.338 +*/
   1.339 +class DMemModelCodeSeg: public DEpocCodeSeg
   1.340 +	{
   1.341 +public:
   1.342 +	DMemModelCodeSeg();
   1.343 +	virtual ~DMemModelCodeSeg();
   1.344 +	virtual TInt DoCreateRam(TCodeSegCreateInfo& aInfo, DProcess* aProcess);
   1.345 +	virtual TInt DoCreateXIP(DProcess* aProcess);
   1.346 +	virtual TInt Loaded(TCodeSegCreateInfo& aInfo);
   1.347 +	virtual void ReadExportDir(TUint32* aDest);
   1.348 +	virtual TBool FindCheck(DProcess* aProcess);
   1.349 +	virtual TBool OpenCheck(DProcess* aProcess);
   1.350 +	inline DMemModelCodeSegMemory* Memory()
   1.351 +		{ return (DMemModelCodeSegMemory*)iMemory; }
   1.352 +	virtual void BTracePrime(TInt aCategory);
   1.353 +public:
   1.354 +	/**
   1.355 +	For kernel codesegs, the address of the memory allocated for its static data.
   1.356 +	*/
   1.357 +	TAny* iKernelData;
   1.358 +
   1.359 +	/**
   1.360 +	The memory object containing the memory for this codeseg.
   1.361 +	*/
   1.362 +	DMemoryObject* iCodeMemoryObject;
   1.363 +
   1.364 +	/**
   1.365 +	A writable mapping which maps #iCodeMemoryObject into the loader
   1.366 +	process's memory so it can be accessed by the loader.
   1.367 +
   1.368 +	This mapping is destroyed once #Loaded is called.
   1.369 +	*/
   1.370 +	DMemoryMapping* iCodeLoadMapping;
   1.371 +
   1.372 +	/**
   1.373 +	The read=only mapping used for kernel and global codesegs to map
   1.374 +	#iCodeMemoryObject into the global address region.
   1.375 +	*/
   1.376 +	DMemoryMapping* iCodeGlobalMapping;
   1.377 +
   1.378 +	/**
   1.379 +	Base address of virtual memory allocated for the codeseg's static data.
   1.380 +	*/
   1.381 +	TLinAddr iDataAllocBase;	
   1.382 +
   1.383 +	/**
   1.384 +	Size of virtual memory allocated for the codeseg's static data.
   1.385 +	*/
   1.386 +	TUint iDataAllocSize;
   1.387 +	};
   1.388 +
   1.389 +
   1.390 +/********************************************
   1.391 + * Shared buffers and pools
   1.392 + ********************************************/
   1.393 +
   1.394 +#include <kernel/sshbuf.h>
   1.395 +
   1.396 +class DShBufMapping;
   1.397 +
   1.398 +
   1.399 +class DMemModelNonAlignedShBuf : public DShBuf
   1.400 +	{
   1.401 +public:
   1.402 +	DMemModelNonAlignedShBuf(DShPool* aPool, TLinAddr aRelAddr);
   1.403 +	~DMemModelNonAlignedShBuf();
   1.404 +
   1.405 +	TInt Close(TAny*);
   1.406 +	TInt AddToProcess(DProcess* aProcess, TUint aAttr);
   1.407 +
   1.408 +protected:
   1.409 +	virtual TInt Pin(TPhysicalPinObject* aPinObject, TBool aReadOnly, TPhysAddr& aAddress, TPhysAddr* aPages, TUint32& aMapAttr, TUint& aColour);
   1.410 +	virtual TInt Map(TUint, DProcess*, TLinAddr&);
   1.411 +	virtual TInt UnMap(DProcess*);
   1.412 +	virtual TUint8* Base(DProcess* aProcess);
   1.413 +	virtual TUint8* Base();
   1.414 +	};
   1.415 +
   1.416 +
   1.417 +class DMemModelAlignedShBuf : public DShBuf
   1.418 +	{
   1.419 +public:
   1.420 +	DMemModelAlignedShBuf(DShPool* aPool);
   1.421 +	virtual ~DMemModelAlignedShBuf();
   1.422 +
   1.423 +	TInt Create();
   1.424 +	virtual TInt Construct();
   1.425 +
   1.426 +	TInt Close(TAny*);
   1.427 +	TInt AddToProcess(DProcess* aProcess, TUint aAttr);
   1.428 +
   1.429 +protected:
   1.430 +	TUint8* Base(DProcess* aProcess);
   1.431 +	TUint8* Base();
   1.432 +	TInt Map(TUint, DProcess*, TLinAddr&);
   1.433 +	TInt UnMap(DProcess*);
   1.434 +	TInt Pin(TPhysicalPinObject* aPinObject, TBool aReadOnly, TPhysAddr& Address, TPhysAddr* aPages, TUint32& aMapAttr, TUint& aColour);
   1.435 +
   1.436 +private:
   1.437 +	TInt FindMapping(DShBufMapping*&, DMemModelProcess*);
   1.438 +	DMemoryObject* iMemoryObject;
   1.439 +	DMemoryMapping* iKernelMapping;
   1.440 +	SDblQue iMappings;
   1.441 +	friend class DMemModelAlignedShPool;
   1.442 +	};
   1.443 +
   1.444 +class DMemModelShPool : public DShPool
   1.445 +	{
   1.446 +public:
   1.447 +	DMemModelShPool();
   1.448 +	virtual ~DMemModelShPool();
   1.449 +protected:
   1.450 +	void DestroyClientResources(DProcess* aProcess);
   1.451 +	virtual TInt DestroyAllMappingsAndReservedHandles(DProcess* aProcess) = 0;
   1.452 +	};
   1.453 +
   1.454 +class DMemModelAlignedShPoolClient : public DShPoolClient
   1.455 +	{
   1.456 +public:
   1.457 +	SDblQue iMappingFreeList;
   1.458 +	TInt iWindowSize;
   1.459 +	};
   1.460 +
   1.461 +class DMemModelNonAlignedShPoolClient : public DShPoolClient
   1.462 +	{
   1.463 +public:
   1.464 +	DMemoryMapping* iMapping;
   1.465 +	};
   1.466 +
   1.467 +class DShBufMapping;
   1.468 +
   1.469 +class DMemModelAlignedShPool : public DMemModelShPool
   1.470 +	{
   1.471 +public:
   1.472 +	DMemModelAlignedShPool();
   1.473 +	virtual ~DMemModelAlignedShPool();
   1.474 +
   1.475 +	TInt Close(TAny* aPtr);
   1.476 +	TInt CreateInitialBuffers();
   1.477 +	TInt SetBufferWindow(DProcess* aProcess, TInt aWindowSize);
   1.478 +	TInt AddToProcess(DProcess* aProcess, TUint aAttr);
   1.479 +	TInt Alloc(DShBuf*&);
   1.480 +
   1.481 +private:
   1.482 +	TInt DoCreate(TShPoolCreateInfo& aInfo);
   1.483 +	TInt GrowPool();
   1.484 +	TInt ShrinkPool();
   1.485 +	TInt MappingNew(DShBufMapping*& aMapping, DMemModelProcess* aProcess);
   1.486 +	TInt GetFreeMapping(DShBufMapping*& aMapping, DMemModelAlignedShPoolClient* aClient);
   1.487 +	TInt ReleaseMapping(DShBufMapping*& aMapping, DMemModelAlignedShPoolClient* aClient);
   1.488 +	TInt UpdateMappingsAndReservedHandles(TInt aNoOfBuffers);
   1.489 +	TInt UpdateFreeList();
   1.490 +	void Free(DShBuf* aBuf);
   1.491 +	TInt CreateMappings(DMemModelAlignedShPoolClient* aClient, TInt aNoOfMappings, DMemModelProcess* aProcess);
   1.492 +	TInt DestroyAllMappingsAndReservedHandles(DProcess* aProcess);
   1.493 +	TInt DestroyMappings(DMemModelAlignedShPoolClient* aClient, TInt aNoOfMappings);
   1.494 +
   1.495 +	TInt DeleteInitialBuffers();
   1.496 +
   1.497 +	SDblQue iPendingList;
   1.498 +	DMemModelAlignedShBuf* iInitialBuffersArray;
   1.499 +
   1.500 +	friend class DMemModelAlignedShBuf;
   1.501 +	};
   1.502 +
   1.503 +class DMemModelNonAlignedShPool : public DMemModelShPool
   1.504 +	{
   1.505 +public:
   1.506 +	DMemModelNonAlignedShPool();
   1.507 +	virtual ~DMemModelNonAlignedShPool();
   1.508 +
   1.509 +	TInt Close(TAny* aPtr);
   1.510 +
   1.511 +	TInt DoInitFreeList();
   1.512 +	TUint8* Base(DProcess* aProcess);
   1.513 +
   1.514 +	inline TUint8* Base()
   1.515 +		{
   1.516 +		return reinterpret_cast<TUint8*>(iBaseAddress);
   1.517 +		};
   1.518 +	TInt AddToProcess(DProcess* aProcess, TUint aAttr);
   1.519 +	TInt CreateInitialBuffers();
   1.520 +
   1.521 +	TInt Alloc(DShBuf*&);
   1.522 +
   1.523 +private:
   1.524 +	void Free(DShBuf* aBuf);
   1.525 +	TInt UpdateFreeList();
   1.526 +
   1.527 +	TInt DoCreate(TShPoolCreateInfo& aInfo);
   1.528 +	void FreeBufferPages(TUint aOffset);
   1.529 +	TInt GrowPool();
   1.530 +	TInt ShrinkPool();
   1.531 +	TInt DeleteInitialBuffers();
   1.532 +	TInt DestroyAllMappingsAndReservedHandles(DProcess* aProcess);
   1.533 +
   1.534 +private:
   1.535 +	TLinAddr iBaseAddress;
   1.536 +	DMemoryObject* iMemoryObject;		// the 'real' memory pool (in the kernel)
   1.537 +	DMemModelNonAlignedShBuf* iInitialBuffersArray;
   1.538 +	TBitMapAllocator* iBufMap;
   1.539 +	TBitMapAllocator* iPagesMap;
   1.540 +
   1.541 +	friend class DMemModelNonAlignedShBuf;
   1.542 +	};
   1.543 +
   1.544 +#endif