84 |
84 |
85 /** |
85 /** |
86 Page is in an indeterminate state. |
86 Page is in an indeterminate state. |
87 |
87 |
88 A page is placed into this state by Mmu::PagesAllocated when it is |
88 A page is placed into this state by Mmu::PagesAllocated when it is |
89 allocated (ceases to be #EUnused). Once the page |
89 allocated (ceases to be #EUnused). Once the page has been assigned to |
|
90 its new use its type will be updated. |
90 */ |
91 */ |
91 EUnknown, |
92 EUnknown, |
92 |
93 |
93 /** |
94 /** |
94 Page was allocated with Mmu::AllocPhysicalRam, Mmu::ClaimPhysicalRam |
95 Page was allocated with Mmu::AllocPhysicalRam, Mmu::ClaimPhysicalRam |
572 iPagedState = aPagedState; |
573 iPagedState = aPagedState; |
573 iModifier = 0; |
574 iModifier = 0; |
574 } |
575 } |
575 |
576 |
576 /** |
577 /** |
577 The the pages #iModifier value. |
578 Set the page's #iModifier value. |
578 |
579 |
579 #iModifier is cleared to zero whenever the usage or paging state of the page |
580 #iModifier is cleared to zero whenever the usage or paging state of the page |
580 changes. So if a thread sets this to a suitable unique value (e.g. the address |
581 changes. So if a thread sets this to a suitable unique value (e.g. the address |
581 of a local variable) then it may perform a long running operation on the page |
582 of a local variable) then it may perform a long running operation on the page |
582 and later check with #CheckModified that no other thread has changed the page |
583 and later check with #CheckModified that no other thread has changed the page |
1433 Return a pointer to a SPageTableInfo by conversion from the address |
1434 Return a pointer to a SPageTableInfo by conversion from the address |
1434 of its embedded link as returned by #FreeLink. |
1435 of its embedded link as returned by #FreeLink. |
1435 */ |
1436 */ |
1436 FORCE_INLINE static SPageTableInfo* FromFreeLink(SDblQueLink* aLink) |
1437 FORCE_INLINE static SPageTableInfo* FromFreeLink(SDblQueLink* aLink) |
1437 { |
1438 { |
1438 return (SPageTableInfo*)((TInt)aLink-_FOFF(SPageTableInfo,iUnused)); |
1439 return _LOFF(aLink, SPageTableInfo, iUnused); |
1439 } |
1440 } |
1440 |
1441 |
1441 /** |
1442 /** |
1442 Return the SPageTableInfo for the first page table in the same |
1443 Return the SPageTableInfo for the first page table in the same |
1443 physical ram page as the page table for this SPageTableInfo. |
1444 physical ram page as the page table for this SPageTableInfo. |
1710 __UNLOCK_GUARD_END(MmuLock); // fault if MmuLock released by SomeCode or SomeMoreCode |
1711 __UNLOCK_GUARD_END(MmuLock); // fault if MmuLock released by SomeCode or SomeMoreCode |
1711 @endcode |
1712 @endcode |
1712 */ |
1713 */ |
1713 static FORCE_INLINE void UnlockGuardStart() |
1714 static FORCE_INLINE void UnlockGuardStart() |
1714 { |
1715 { |
1715 #ifdef _DEBUG |
1716 #ifdef _DEBUG |
1716 ++UnlockGuardNest; |
1717 ++UnlockGuardNest; |
1717 #endif |
1718 #endif |
1718 } |
1719 } |
1719 |
1720 |
1720 /** |
1721 /** |
1721 End a debug check testing that the MmuLock is not unlocked unexpectedly. |
1722 End a debug check testing that the MmuLock is not unlocked unexpectedly. |
1722 This is usually used via the #__UNLOCK_GUARD_END which faults if true is returned. |
1723 This is usually used via the #__UNLOCK_GUARD_END which faults if true is returned. |
1723 |
1724 |
1724 @see UnlockGuardStart |
1725 @see UnlockGuardStart |
1725 |
1726 |
1726 @return True if the MmuLock was released between a previous #UnlockGuardStart |
1727 @return EFalse if the MmuLock was released between a previous #UnlockGuardStart |
1727 and the call this function. |
1728 and the call this function. |
1728 */ |
1729 */ |
1729 static FORCE_INLINE TBool UnlockGuardEnd() |
1730 static FORCE_INLINE TBool UnlockGuardEnd() |
1730 { |
1731 { |
1731 #ifdef _DEBUG |
1732 #ifdef _DEBUG |
1732 __NK_ASSERT_DEBUG(UnlockGuardNest); |
1733 __NK_ASSERT_DEBUG(UnlockGuardNest); |
1733 --UnlockGuardNest; |
1734 --UnlockGuardNest; |
1734 return UnlockGuardFail==0; |
1735 return UnlockGuardFail==0; |
1735 #else |
1736 #else |
1736 return true; |
1737 return ETrue; |
1737 #endif |
1738 #endif |
1738 } |
1739 } |
1739 |
1740 |
1740 private: |
1741 private: |
1741 /** |
1742 /** |
1742 Exectued whenever the lock is released to check that |
1743 Exectued whenever the lock is released to check that |
1743 #UnlockGuardStart and #UnlockGuardEnd are balanced. |
1744 #UnlockGuardStart and #UnlockGuardEnd are balanced. |
1744 */ |
1745 */ |
1745 static FORCE_INLINE void UnlockGuardCheck() |
1746 static FORCE_INLINE void UnlockGuardCheck() |
1746 { |
1747 { |
1747 #ifdef _DEBUG |
1748 #ifdef _DEBUG |
1748 if(UnlockGuardNest) |
1749 if(UnlockGuardNest) |
1749 UnlockGuardFail = true; |
1750 UnlockGuardFail = ETrue; |
1750 #endif |
1751 #endif |
1751 } |
1752 } |
1752 |
1753 |
1753 private: |
1754 private: |
1754 /** The lock */ |
1755 /** The lock */ |
1755 static NFastMutex iLock; |
1756 static NFastMutex iLock; |
1949 void Init2Common(); |
1950 void Init2Common(); |
1950 void Init2Final(); |
1951 void Init2Final(); |
1951 void Init2FinalCommon(); |
1952 void Init2FinalCommon(); |
1952 void Init3(); |
1953 void Init3(); |
1953 |
1954 |
|
1955 void BTracePrime(TUint aCategory); |
|
1956 |
1954 static void Panic(TPanic aPanic); |
1957 static void Panic(TPanic aPanic); |
1955 |
1958 |
1956 static TInt HandlePageFault(TLinAddr aPc, TLinAddr aFaultAddress, TUint aAccessPermissions, TAny* aExceptionInfo); |
1959 static TInt HandlePageFault(TLinAddr aPc, TLinAddr aFaultAddress, TUint aAccessPermissions, TAny* aExceptionInfo); |
1957 |
1960 |
1958 TUint FreeRamInPages(); |
1961 TUint FreeRamInPages(); |
1977 void FreePhysicalRam(TPhysAddr* aPages, TUint aCount); |
1980 void FreePhysicalRam(TPhysAddr* aPages, TUint aCount); |
1978 TInt AllocPhysicalRam(TPhysAddr& aPhysAddr, TUint aCount, TUint aAlign, TRamAllocFlags aFlags); |
1981 TInt AllocPhysicalRam(TPhysAddr& aPhysAddr, TUint aCount, TUint aAlign, TRamAllocFlags aFlags); |
1979 void FreePhysicalRam(TPhysAddr aPhysAddr, TUint aCount); |
1982 void FreePhysicalRam(TPhysAddr aPhysAddr, TUint aCount); |
1980 TInt ClaimPhysicalRam(TPhysAddr aPhysAddr, TUint aCount, TRamAllocFlags aFlags); |
1983 TInt ClaimPhysicalRam(TPhysAddr aPhysAddr, TUint aCount, TRamAllocFlags aFlags); |
1981 void AllocatedPhysicalRam(TPhysAddr aPhysAddr, TUint aCount, TRamAllocFlags aFlags); |
1984 void AllocatedPhysicalRam(TPhysAddr aPhysAddr, TUint aCount, TRamAllocFlags aFlags); |
1982 |
1985 private: |
|
1986 void SetAllocPhysRam(TPhysAddr aPhysAddr, TUint aCount); |
|
1987 void SetAllocPhysRam(TPhysAddr* aPageList, TUint aNumPages); |
|
1988 |
|
1989 public: |
1983 TLinAddr MapTemp(TPhysAddr aPage, TUint aColour, TUint aSlot=0); |
1990 TLinAddr MapTemp(TPhysAddr aPage, TUint aColour, TUint aSlot=0); |
1984 void UnmapTemp(TUint aSlot=0); |
1991 void UnmapTemp(TUint aSlot=0); |
1985 void RemoveAliasesForPageTable(TPhysAddr aPageTable); |
1992 void RemoveAliasesForPageTable(TPhysAddr aPageTable); |
1986 |
1993 |
1987 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); |