os/kernelhwsrv/kernel/eka/memmodel/epoc/flexible/mmu/mlargemappings.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200 (2012-06-15)
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
//   Support for mapping memory with section mappings and large pages.
sl@0
    16
//
sl@0
    17
//   This adds the following new classes:
sl@0
    18
//   
sl@0
    19
//     DLargeMappedMemory - a subclass of DCoarseMemory that holds information about which areas of
sl@0
    20
//                          memory are contiguous, and contains the page tables to use to map the
sl@0
    21
//                          memory.
sl@0
    22
//
sl@0
    23
//     DLargeMapping	  - a subclass of DCoarseMapping used to map areas of a DLargeMappedMemory
sl@0
    24
//     						object.
sl@0
    25
//
sl@0
    26
//   todo: currently only section mappings are supported.
sl@0
    27
//
sl@0
    28
sl@0
    29
/**
sl@0
    30
 @file
sl@0
    31
 @internalComponent
sl@0
    32
*/
sl@0
    33
sl@0
    34
#ifndef MLAGEMAPPINGS_H
sl@0
    35
#define MLAGEMAPPINGS_H
sl@0
    36
sl@0
    37
#include "mobject.h"
sl@0
    38
#include "mmapping.h"
sl@0
    39
sl@0
    40
// todo: Think of a better name than DLargeMappedMemory for a coarse memory object that supports
sl@0
    41
// large mappings
sl@0
    42
sl@0
    43
/**
sl@0
    44
A coarse memory object that supports mappings larger than 4K pages.
sl@0
    45
sl@0
    46
All the contraints of coarse memory objects also apply to large memory objects.
sl@0
    47
sl@0
    48
Fine memory mappings (DFineMapping) may also be attached to this memory object but these will be
sl@0
    49
mapped using 4K pages and won't benefit from page table sharing.
sl@0
    50
*/
sl@0
    51
class DLargeMappedMemory : public DCoarseMemory
sl@0
    52
	{
sl@0
    53
public:
sl@0
    54
	/**
sl@0
    55
	Create a new DLargeMappedMemory object.
sl@0
    56
sl@0
    57
	@param aManager		The manager object for this memory.
sl@0
    58
	@param aSizeInPages Size of the memory object, in number of pages.  (Must represent an exact
sl@0
    59
						'chunk' size.)
sl@0
    60
	@param aAttributes	Bitmask of values from enum #TMemoryAttributes.
sl@0
    61
	@param aCreateFlags	Bitmask of option flags from enum #TMemoryCreateFlags.
sl@0
    62
sl@0
    63
	@return The newly created DLargeMemory or the null pointer if there was insufficient memory.
sl@0
    64
	*/
sl@0
    65
	static DLargeMappedMemory* New(DMemoryManager* aManager, TUint aSizeInPages, TMemoryAttributes aAttributes, TMemoryCreateFlags aCreateFlags);
sl@0
    66
	
sl@0
    67
private:
sl@0
    68
	DLargeMappedMemory(DMemoryManager* aManager, TUint aSizeInPages, TMemoryAttributes aAttributes, TMemoryCreateFlags aCreateFlags);
sl@0
    69
	
sl@0
    70
public:
sl@0
    71
	// from DMemoryObject...
sl@0
    72
	virtual ~DLargeMappedMemory();
sl@0
    73
	virtual TInt ClaimInitialPages(TLinAddr aBase, TUint aSize, TMappingPermissions aPermissions, TBool aAllowGaps, TBool aAllowNonRamPages);
sl@0
    74
	virtual TInt MapPages(RPageArray::TIter aPages);
sl@0
    75
	virtual void RemapPage(TPhysAddr& aPageArray, TUint aIndex, TBool aInvalidateTLB);
sl@0
    76
	virtual void UnmapPages(RPageArray::TIter aPages, TBool aDecommitting);
sl@0
    77
	virtual void RestrictPages(RPageArray::TIter aPages, TRestrictPagesType aRestriction);
sl@0
    78
	virtual DMemoryMapping* CreateMapping(TUint aIndex, TUint aCount);
sl@0
    79
	
sl@0
    80
public:
sl@0
    81
	TBool IsChunkContiguous(TInt aChunkIndex);
sl@0
    82
private:
sl@0
    83
	void SetChunkContiguous(TInt aChunkIndex, TBool aIsContiguous);
sl@0
    84
sl@0
    85
	TUint32 iContiguousState[1];
sl@0
    86
	};
sl@0
    87
sl@0
    88
sl@0
    89
/**
sl@0
    90
A memory mapping to map a 'chunk' aligned region of a DLargeMappedMemory object into an address
sl@0
    91
space, which allows use of mappings larger than a single page.
sl@0
    92
sl@0
    93
Currently this only supports section mapping, and only then when the memory is initially mapped in
sl@0
    94
sections by the bootstrap.
sl@0
    95
*/
sl@0
    96
class DLargeMapping: public DCoarseMapping
sl@0
    97
	{
sl@0
    98
public:
sl@0
    99
	DLargeMapping();
sl@0
   100
	
sl@0
   101
private:
sl@0
   102
	// from DMemoryMappingBase...
sl@0
   103
	virtual TInt DoMap();
sl@0
   104
	virtual void RemapPage(TPhysAddr& aPageArray, TUint aIndex, TUint aMapInstanceCount, TBool aInvalidateTLB);
sl@0
   105
	virtual TInt PageIn(RPageArray::TIter aPages, TPinArgs& aPinArgs, TUint aMapInstanceCount);
sl@0
   106
	virtual TBool MovingPageIn(TPhysAddr& aPageArrayPtr, TUint aIndex);
sl@0
   107
	
sl@0
   108
	// from DMemoryMapping...
sl@0
   109
	virtual TPte* FindPageTable(TLinAddr aLinAddr, TUint aMemoryIndex);
sl@0
   110
	};
sl@0
   111
sl@0
   112
sl@0
   113
#endif