kernel/eka/memmodel/epoc/flexible/mmu/mmu.h
branchRCL_3
changeset 110 c734af59ce98
parent 87 2f92ad2dc5db
child 117 5b5d147c7838
equal deleted inserted replaced
97:41f0cfe18c80 110:c734af59ce98
    19 */
    19 */
    20 
    20 
    21 #ifndef __MMU_H__
    21 #ifndef __MMU_H__
    22 #define __MMU_H__
    22 #define __MMU_H__
    23 
    23 
    24 #define _USE_OLDEST_LISTS
       
    25 
       
    26 #include "mm.h"
    24 #include "mm.h"
    27 #include "mmboot.h"
    25 #include "mmboot.h"
    28 #include <mmtypes.h>
    26 #include <mmtypes.h>
    29 #include <kern_priv.h>
    27 #include <kern_priv.h>
    30 
    28 
   144 	State for the page when being used to contain demand paged content.
   142 	State for the page when being used to contain demand paged content.
   145 	*/
   143 	*/
   146 	enum TPagedState
   144 	enum TPagedState
   147 		{
   145 		{
   148 		/**
   146 		/**
   149 		Page is not being managed for demand paging purposes, is has been transiently
   147 		Page is not being managed for demand paging purposes, or has been transiently
   150 		removed from the demand paging live list.
   148 		removed from the demand paging live list.
   151 		*/
   149 		*/
   152 		EUnpaged 			= 0x0,
   150 		EUnpaged 			= 0x0,
   153 
   151 
   154 		/**
   152 		/**
   170 		Page has been removed from live list to prevent contents being paged-out.
   168 		Page has been removed from live list to prevent contents being paged-out.
   171 		*/
   169 		*/
   172 		// NOTE - This must be the same value as EStatePagedLocked as defined in mmubase.h
   170 		// NOTE - This must be the same value as EStatePagedLocked as defined in mmubase.h
   173 		EPagedPinned 		= 0x4,
   171 		EPagedPinned 		= 0x4,
   174 
   172 
   175 #ifdef _USE_OLDEST_LISTS
       
   176 		/**
   173 		/**
   177 		Page is in the live list as one of oldest pages that is clean.
   174 		Page is in the live list as one of oldest pages that is clean.
   178 		*/
   175 		*/
   179 		EPagedOldestClean	= 0x5,
   176 		EPagedOldestClean	= 0x5,
   180 
   177 
   181 		/**
   178 		/**
   182 		Page is in the live list as one of oldest pages that is dirty.
   179 		Page is in the live list as one of oldest pages that is dirty.
   183 		*/
   180 		*/
   184 		EPagedOldestDirty 	= 0x6
   181 		EPagedOldestDirty 	= 0x6	
   185 #endif
       
   186 		};
   182 		};
   187 
   183 
   188 
   184 
   189 	/**
   185 	/**
   190 	Additional flags, stored in #iFlags2.
   186 	Additional flags, stored in #iFlags2.
   676 		return iFlags&EWritable;
   672 		return iFlags&EWritable;
   677 		}
   673 		}
   678 
   674 
   679 	/**
   675 	/**
   680 	Flag this page as 'dirty', indicating that its contents may no longer match those saved
   676 	Flag this page as 'dirty', indicating that its contents may no longer match those saved
   681 	to a backing store. This sets the flag #EWritable.
   677 	to a backing store. This sets the flag #EDirty.
   682 
   678 
   683 	This is used in the management of demand paged memory.
   679 	This is used in the management of demand paged memory.
   684 
   680 
   685 	@pre #MmuLock held.
   681 	@pre #MmuLock held.
   686 	*/
   682 	*/
   687 	FORCE_INLINE void SetDirty()
   683 	FORCE_INLINE void SetDirty()
   688 		{
   684 		{
   689 		CheckAccess("SetDirty");
   685 		CheckAccess("SetDirty");
       
   686 		__NK_ASSERT_DEBUG(IsWritable());
   690 		iFlags |= EDirty;
   687 		iFlags |= EDirty;
   691 		}
   688 		}
   692 
   689 
   693 	/**
   690 	/**
   694 	Flag this page as 'clean', indicating that its contents now match those saved
   691 	Flag this page as 'clean', indicating that its contents now match those saved
   695 	to a backing store. This clears the flag #EWritable.
   692 	to a backing store. This clears the flag #EDirty.
   696 
   693 
   697 	This is used in the management of demand paged memory.
   694 	This is used in the management of demand paged memory.
   698 
   695 
   699 	@pre #MmuLock held.
   696 	@pre #MmuLock held.
   700 	*/
   697 	*/
   701 	FORCE_INLINE void SetClean()
   698 	FORCE_INLINE void SetClean()
   702 		{
   699 		{
   703 		CheckAccess("SetClean");
   700 		CheckAccess("SetClean");
       
   701 		__NK_ASSERT_DEBUG(!IsWritable());
   704 		iFlags &= ~EDirty;
   702 		iFlags &= ~EDirty;
   705 		}
   703 		}
   706 
   704 
   707 	/**
   705 	/**
   708 	Return the  #EDirty flag. See #SetDirty and #SetClean.
   706 	Return the  #EDirty flag. See #SetDirty and #SetClean.
  1749 		if(UnlockGuardNest)
  1747 		if(UnlockGuardNest)
  1750 			UnlockGuardFail = ETrue;
  1748 			UnlockGuardFail = ETrue;
  1751 #endif
  1749 #endif
  1752 		}
  1750 		}
  1753 
  1751 
  1754 private:
  1752 public:
  1755 	/** The lock */
  1753 	/** The lock */
  1756 	static NFastMutex iLock;
  1754 	static NFastMutex iLock;
  1757 
  1755 
  1758 #ifdef _DEBUG
  1756 #ifdef _DEBUG
       
  1757 private:
  1759 	static TUint UnlockGuardNest;
  1758 	static TUint UnlockGuardNest;
  1760 	static TUint UnlockGuardFail;
  1759 	static TUint UnlockGuardFail;
  1761 #endif
  1760 #endif
  1762 	};
  1761 	};
  1763 
  1762 
  1961 	TUint FreeRamInPages();
  1960 	TUint FreeRamInPages();
  1962 	TUint TotalPhysicalRamPages();
  1961 	TUint TotalPhysicalRamPages();
  1963 
  1962 
  1964 	TInt AllocRam(	TPhysAddr* aPages, TUint aCount, TRamAllocFlags aFlags, TZonePageType aZonePageType, 
  1963 	TInt AllocRam(	TPhysAddr* aPages, TUint aCount, TRamAllocFlags aFlags, TZonePageType aZonePageType, 
  1965 					TUint aBlockZoneId=KRamZoneInvalidId, TBool aBlockRest=EFalse);
  1964 					TUint aBlockZoneId=KRamZoneInvalidId, TBool aBlockRest=EFalse);
       
  1965 	void MarkPageAllocated(TPhysAddr aPhysAddr, TZonePageType aZonePageType);
  1966 	void FreeRam(TPhysAddr* aPages, TUint aCount, TZonePageType aZonePageType);
  1966 	void FreeRam(TPhysAddr* aPages, TUint aCount, TZonePageType aZonePageType);
  1967 	TInt AllocContiguousRam(TPhysAddr& aPhysAddr, TUint aCount, TUint aAlign, TRamAllocFlags aFlags);
  1967 	TInt AllocContiguousRam(TPhysAddr& aPhysAddr, TUint aCount, TUint aAlign, TRamAllocFlags aFlags);
  1968 	void FreeContiguousRam(TPhysAddr aPhysAddr, TUint aCount);
  1968 	void FreeContiguousRam(TPhysAddr aPhysAddr, TUint aCount);
  1969 
  1969 
  1970 	const SRamZone* RamZoneConfig(TRamZoneCallback& aCallback) const;
  1970 	const SRamZone* RamZoneConfig(TRamZoneCallback& aCallback) const;