sl@0: // Copyright (c) 2007-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: // sl@0: // Support for mapping memory with section mappings and large pages. sl@0: // sl@0: // This adds the following new classes: sl@0: // sl@0: // DLargeMappedMemory - a subclass of DCoarseMemory that holds information about which areas of sl@0: // memory are contiguous, and contains the page tables to use to map the sl@0: // memory. sl@0: // sl@0: // DLargeMapping - a subclass of DCoarseMapping used to map areas of a DLargeMappedMemory sl@0: // object. sl@0: // sl@0: // todo: currently only section mappings are supported. sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @internalComponent sl@0: */ sl@0: sl@0: #ifndef MLAGEMAPPINGS_H sl@0: #define MLAGEMAPPINGS_H sl@0: sl@0: #include "mobject.h" sl@0: #include "mmapping.h" sl@0: sl@0: // todo: Think of a better name than DLargeMappedMemory for a coarse memory object that supports sl@0: // large mappings sl@0: sl@0: /** sl@0: A coarse memory object that supports mappings larger than 4K pages. sl@0: sl@0: All the contraints of coarse memory objects also apply to large memory objects. sl@0: sl@0: Fine memory mappings (DFineMapping) may also be attached to this memory object but these will be sl@0: mapped using 4K pages and won't benefit from page table sharing. sl@0: */ sl@0: class DLargeMappedMemory : public DCoarseMemory sl@0: { sl@0: public: sl@0: /** sl@0: Create a new DLargeMappedMemory object. sl@0: sl@0: @param aManager The manager object for this memory. sl@0: @param aSizeInPages Size of the memory object, in number of pages. (Must represent an exact sl@0: 'chunk' size.) sl@0: @param aAttributes Bitmask of values from enum #TMemoryAttributes. sl@0: @param aCreateFlags Bitmask of option flags from enum #TMemoryCreateFlags. sl@0: sl@0: @return The newly created DLargeMemory or the null pointer if there was insufficient memory. sl@0: */ sl@0: static DLargeMappedMemory* New(DMemoryManager* aManager, TUint aSizeInPages, TMemoryAttributes aAttributes, TMemoryCreateFlags aCreateFlags); sl@0: sl@0: private: sl@0: DLargeMappedMemory(DMemoryManager* aManager, TUint aSizeInPages, TMemoryAttributes aAttributes, TMemoryCreateFlags aCreateFlags); sl@0: sl@0: public: sl@0: // from DMemoryObject... sl@0: virtual ~DLargeMappedMemory(); sl@0: virtual TInt ClaimInitialPages(TLinAddr aBase, TUint aSize, TMappingPermissions aPermissions, TBool aAllowGaps, TBool aAllowNonRamPages); sl@0: virtual TInt MapPages(RPageArray::TIter aPages); sl@0: virtual void RemapPage(TPhysAddr& aPageArray, TUint aIndex, TBool aInvalidateTLB); sl@0: virtual void UnmapPages(RPageArray::TIter aPages, TBool aDecommitting); sl@0: virtual void RestrictPages(RPageArray::TIter aPages, TRestrictPagesType aRestriction); sl@0: virtual DMemoryMapping* CreateMapping(TUint aIndex, TUint aCount); sl@0: sl@0: public: sl@0: TBool IsChunkContiguous(TInt aChunkIndex); sl@0: private: sl@0: void SetChunkContiguous(TInt aChunkIndex, TBool aIsContiguous); sl@0: sl@0: TUint32 iContiguousState[1]; sl@0: }; sl@0: sl@0: sl@0: /** sl@0: A memory mapping to map a 'chunk' aligned region of a DLargeMappedMemory object into an address sl@0: space, which allows use of mappings larger than a single page. sl@0: sl@0: Currently this only supports section mapping, and only then when the memory is initially mapped in sl@0: sections by the bootstrap. sl@0: */ sl@0: class DLargeMapping: public DCoarseMapping sl@0: { sl@0: public: sl@0: DLargeMapping(); sl@0: sl@0: private: sl@0: // from DMemoryMappingBase... sl@0: virtual TInt DoMap(); sl@0: virtual void RemapPage(TPhysAddr& aPageArray, TUint aIndex, TUint aMapInstanceCount, TBool aInvalidateTLB); sl@0: virtual TInt PageIn(RPageArray::TIter aPages, TPinArgs& aPinArgs, TUint aMapInstanceCount); sl@0: virtual TBool MovingPageIn(TPhysAddr& aPageArrayPtr, TUint aIndex); sl@0: sl@0: // from DMemoryMapping... sl@0: virtual TPte* FindPageTable(TLinAddr aLinAddr, TUint aMemoryIndex); sl@0: }; sl@0: sl@0: sl@0: #endif