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