568 iPagedState = aPagedState; |
569 iPagedState = aPagedState; |
569 iModifier = 0; |
570 iModifier = 0; |
570 } |
571 } |
571 |
572 |
572 /** |
573 /** |
573 The the pages #iModifier value. |
574 Set the page's #iModifier value. |
574 |
575 |
575 #iModifier is cleared to zero whenever the usage or paging state of the page |
576 #iModifier is cleared to zero whenever the usage or paging state of the page |
576 changes. So if a thread sets this to a suitable unique value (e.g. the address |
577 changes. So if a thread sets this to a suitable unique value (e.g. the address |
577 of a local variable) then it may perform a long running operation on the page |
578 of a local variable) then it may perform a long running operation on the page |
578 and later check with #CheckModified that no other thread has changed the page |
579 and later check with #CheckModified that no other thread has changed the page |
1431 Return a pointer to a SPageTableInfo by conversion from the address |
1432 Return a pointer to a SPageTableInfo by conversion from the address |
1432 of its embedded link as returned by #FreeLink. |
1433 of its embedded link as returned by #FreeLink. |
1433 */ |
1434 */ |
1434 FORCE_INLINE static SPageTableInfo* FromFreeLink(SDblQueLink* aLink) |
1435 FORCE_INLINE static SPageTableInfo* FromFreeLink(SDblQueLink* aLink) |
1435 { |
1436 { |
1436 return (SPageTableInfo*)((TInt)aLink-_FOFF(SPageTableInfo,iUnused)); |
1437 return _LOFF(aLink, SPageTableInfo, iUnused); |
1437 } |
1438 } |
1438 |
1439 |
1439 /** |
1440 /** |
1440 Return the SPageTableInfo for the first page table in the same |
1441 Return the SPageTableInfo for the first page table in the same |
1441 physical ram page as the page table for this SPageTableInfo. |
1442 physical ram page as the page table for this SPageTableInfo. |
1708 __UNLOCK_GUARD_END(MmuLock); // fault if MmuLock released by SomeCode or SomeMoreCode |
1709 __UNLOCK_GUARD_END(MmuLock); // fault if MmuLock released by SomeCode or SomeMoreCode |
1709 @endcode |
1710 @endcode |
1710 */ |
1711 */ |
1711 static FORCE_INLINE void UnlockGuardStart() |
1712 static FORCE_INLINE void UnlockGuardStart() |
1712 { |
1713 { |
1713 #ifdef _DEBUG |
1714 #ifdef _DEBUG |
1714 ++UnlockGuardNest; |
1715 ++UnlockGuardNest; |
1715 #endif |
1716 #endif |
1716 } |
1717 } |
1717 |
1718 |
1718 /** |
1719 /** |
1719 End a debug check testing that the MmuLock is not unlocked unexpectedly. |
1720 End a debug check testing that the MmuLock is not unlocked unexpectedly. |
1720 This is usually used via the #__UNLOCK_GUARD_END which faults if true is returned. |
1721 This is usually used via the #__UNLOCK_GUARD_END which faults if true is returned. |
1721 |
1722 |
1722 @see UnlockGuardStart |
1723 @see UnlockGuardStart |
1723 |
1724 |
1724 @return True if the MmuLock was released between a previous #UnlockGuardStart |
1725 @return EFalse if the MmuLock was released between a previous #UnlockGuardStart |
1725 and the call this function. |
1726 and the call this function. |
1726 */ |
1727 */ |
1727 static FORCE_INLINE TBool UnlockGuardEnd() |
1728 static FORCE_INLINE TBool UnlockGuardEnd() |
1728 { |
1729 { |
1729 #ifdef _DEBUG |
1730 #ifdef _DEBUG |
1730 __NK_ASSERT_DEBUG(UnlockGuardNest); |
1731 __NK_ASSERT_DEBUG(UnlockGuardNest); |
1731 --UnlockGuardNest; |
1732 --UnlockGuardNest; |
1732 return UnlockGuardFail==0; |
1733 return UnlockGuardFail==0; |
1733 #else |
1734 #else |
1734 return true; |
1735 return ETrue; |
1735 #endif |
1736 #endif |
1736 } |
1737 } |
1737 |
1738 |
1738 private: |
1739 private: |
1739 /** |
1740 /** |
1740 Exectued whenever the lock is released to check that |
1741 Exectued whenever the lock is released to check that |
1741 #UnlockGuardStart and #UnlockGuardEnd are balanced. |
1742 #UnlockGuardStart and #UnlockGuardEnd are balanced. |
1742 */ |
1743 */ |
1743 static FORCE_INLINE void UnlockGuardCheck() |
1744 static FORCE_INLINE void UnlockGuardCheck() |
1744 { |
1745 { |
1745 #ifdef _DEBUG |
1746 #ifdef _DEBUG |
1746 if(UnlockGuardNest) |
1747 if(UnlockGuardNest) |
1747 UnlockGuardFail = true; |
1748 UnlockGuardFail = ETrue; |
1748 #endif |
1749 #endif |
1749 } |
1750 } |
1750 |
1751 |
1751 public: |
1752 public: |
1752 /** The lock */ |
1753 /** The lock */ |
1753 static NFastMutex iLock; |
1754 static NFastMutex iLock; |
1969 TInt GetRamZonePageCount(TUint aId, SRamZonePageCount& aPageData); |
1972 TInt GetRamZonePageCount(TUint aId, SRamZonePageCount& aPageData); |
1970 TInt ZoneAllocPhysicalRam(TUint* aZoneIdList, TUint aZoneIdCount, TInt aBytes, TPhysAddr& aPhysAddr, TInt aAlign); |
1973 TInt ZoneAllocPhysicalRam(TUint* aZoneIdList, TUint aZoneIdCount, TInt aBytes, TPhysAddr& aPhysAddr, TInt aAlign); |
1971 TInt ZoneAllocPhysicalRam(TUint* aZoneIdList, TUint aZoneIdCount, TInt aNumPages, TPhysAddr* aPageList); |
1974 TInt ZoneAllocPhysicalRam(TUint* aZoneIdList, TUint aZoneIdCount, TInt aNumPages, TPhysAddr* aPageList); |
1972 TInt RamHalFunction(TInt aFunction, TAny* a1, TAny* a2); |
1975 TInt RamHalFunction(TInt aFunction, TAny* a1, TAny* a2); |
1973 void ChangePageType(SPageInfo* aPageInfo, TZonePageType aOldPageType, TZonePageType aNewPageType); |
1976 void ChangePageType(SPageInfo* aPageInfo, TZonePageType aOldPageType, TZonePageType aNewPageType); |
|
1977 TInt FreeRamZone(TUint aZoneId); |
1974 |
1978 |
1975 TInt AllocPhysicalRam(TPhysAddr* aPages, TUint aCount, TRamAllocFlags aFlags); |
1979 TInt AllocPhysicalRam(TPhysAddr* aPages, TUint aCount, TRamAllocFlags aFlags); |
1976 void FreePhysicalRam(TPhysAddr* aPages, TUint aCount); |
1980 void FreePhysicalRam(TPhysAddr* aPages, TUint aCount); |
1977 TInt AllocPhysicalRam(TPhysAddr& aPhysAddr, TUint aCount, TUint aAlign, TRamAllocFlags aFlags); |
1981 TInt AllocPhysicalRam(TPhysAddr& aPhysAddr, TUint aCount, TUint aAlign, TRamAllocFlags aFlags); |
1978 void FreePhysicalRam(TPhysAddr aPhysAddr, TUint aCount); |
1982 void FreePhysicalRam(TPhysAddr aPhysAddr, TUint aCount); |
1979 TInt ClaimPhysicalRam(TPhysAddr aPhysAddr, TUint aCount, TRamAllocFlags aFlags); |
1983 TInt ClaimPhysicalRam(TPhysAddr aPhysAddr, TUint aCount, TRamAllocFlags aFlags); |
1980 void AllocatedPhysicalRam(TPhysAddr aPhysAddr, TUint aCount, TRamAllocFlags aFlags); |
1984 void AllocatedPhysicalRam(TPhysAddr aPhysAddr, TUint aCount, TRamAllocFlags aFlags); |
1981 |
1985 private: |
|
1986 void SetAllocPhysRam(TPhysAddr aPhysAddr, TUint aCount); |
|
1987 void SetAllocPhysRam(TPhysAddr* aPageList, TUint aNumPages); |
|
1988 |
|
1989 public: |
1982 TLinAddr MapTemp(TPhysAddr aPage, TUint aColour, TUint aSlot=0); |
1990 TLinAddr MapTemp(TPhysAddr aPage, TUint aColour, TUint aSlot=0); |
1983 void UnmapTemp(TUint aSlot=0); |
1991 void UnmapTemp(TUint aSlot=0); |
1984 void RemoveAliasesForPageTable(TPhysAddr aPageTable); |
1992 void RemoveAliasesForPageTable(TPhysAddr aPageTable); |
1985 |
1993 |
1986 static TBool MapPages(TPte* const aPtePtr, const TUint aCount, TPhysAddr* aPages, TPte aBlankPte); |
1994 static TBool MapPages(TPte* const aPtePtr, const TUint aCount, TPhysAddr* aPages, TPte aBlankPte); |