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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // This will make sure that the changes in page tables are visible by H/W Page-Table Walk.
15 // Call this function when two and more consecutive entries in page table are changed.
20 FORCE_INLINE macro in GCC works differently from in VC and armcc.
23 #define REALLY_INLINE __forceinline
27 #define REALLY_INLINE inline
29 #define REALLY_INLINE inline __attribute__ ((always_inline))
32 #define REALLY_INLINE inline
37 This will make sure that the change in page directory is visible by H/W Page-Table Walk.
38 Call this function when a single entry in page directory is changed.
40 extern void SinglePdeUpdated(TPde* aPde);
43 extern void __fastcall DoInvalidateTLBForPage(TLinAddr aLinAddrAndAsid);
44 extern void DoInvalidateTLB();
48 Invalidate a single I+D TLB entry on this CPU core only.
49 @param aLinAddrAndAsid Virtual address of a page of memory ORed with the ASID value.
51 REALLY_INLINE void __fastcall LocalInvalidateTLBForPage(TLinAddr aLinAddrAndAsid)
53 DoInvalidateTLBForPage(aLinAddrAndAsid);
60 Invalidate a single I+D TLB entry
61 @param aLinAddrAndAsid Virtual address of a page of memory ORed with the ASID value.
63 REALLY_INLINE void __fastcall InvalidateTLBForPage(TLinAddr aLinAddrAndAsid)
65 DoInvalidateTLBForPage(aLinAddrAndAsid);
72 REALLY_INLINE void InvalidateTLB()
81 #define COARSE_GRAINED_TLB_MAINTENANCE
84 Invalidate a single I+D TLB entry.
85 @param aLinAddrAndAsid Virtual address of a page of memory ORed with the ASID value.
87 extern void InvalidateTLBForPage(TLinAddr aLinAddrAndAsid);
93 extern void InvalidateTLB();
100 Invalidate all TLB entries which match the given ASID value
102 extern void InvalidateTLBForAsid(TUint aAsid);
105 FORCE_INLINE TPde* Mmu::PageDirectory(TInt aOsAsid)
107 return (TPde*)(KPageDirectoryBase+(aOsAsid<<KPageDirectoryShift));
111 FORCE_INLINE TPde* Mmu::PageDirectoryEntry(TInt aOsAsid, TLinAddr aAddress)
113 return PageDirectory(aOsAsid) + (aAddress>>KChunkShift);
117 FORCE_INLINE TPhysAddr Mmu::PdePhysAddr(TPde aPde)
119 if ((aPde&(KPdePtePresent|KPdeLargePage)) == (KPdePtePresent|KPdeLargePage))
120 return aPde & KPdeLargePagePhysAddrMask;
121 return KPhysAddrInvalid;
125 FORCE_INLINE TPte Mmu::MakePteInaccessible(TPte aPte, TBool aReadOnly)
128 return aPte&~KPdePteWrite;
130 return aPte&~KPdePtePresent;
134 FORCE_INLINE TPte Mmu::MakePteAccessible(TPte aPte, TBool aWrite)
136 if((aPte&KPdePtePresent)==0)
138 aPte |= KPdePtePresent;
139 aPte &= ~KPdePteWrite;
142 aPte |= KPdePteWrite;
147 FORCE_INLINE TBool Mmu::IsPteReadOnly(TPte aPte)
149 __NK_ASSERT_DEBUG(aPte&KPdePtePresent); // read-only state is ambiguous if pte not present
150 return !(aPte&KPdePteWrite);
154 FORCE_INLINE TBool Mmu::IsPteInaccessible(TPte aPte)
156 return !(aPte&KPdePtePresent);
160 FORCE_INLINE TBool Mmu::IsPteMoreAccessible(TPte aNewPte, TPte aOldPte)
162 if(aNewPte&aOldPte&KPdePtePresent) // if ptes both present
163 return (aNewPte&~aOldPte)&KPdePteWrite; // check for more writable
165 return aNewPte&KPdePtePresent; // check for new pte being present
177 EPteTypeUserAccess = EUser,
178 EPteTypeWritable = EReadWrite,
179 EPteTypeGlobal = 1<<2,
183 __ASSERT_COMPILE(EPteTypeUserAccess==(1<<0));
184 __ASSERT_COMPILE(EPteTypeWritable==(1<<1));
187 FORCE_INLINE TUint Mmu::PdeType(TMemoryAttributes /*aAttributes*/)
193 FORCE_INLINE TUint Mmu::PteType(TMappingPermissions aPermissions, TBool aGlobal)
195 __NK_ASSERT_DEBUG(aPermissions&EUser || aGlobal); // can't have supervisor local memory
197 TUint pteType = (aPermissions&(EUser|EReadWrite));
199 pteType |= EPteTypeGlobal;
201 __NK_ASSERT_DEBUG(pteType<ENumPteTypes);
207 FORCE_INLINE TBool Mmu::CheckPteTypePermissions(TUint aPteType, TUint aAccessPermissions)
209 aAccessPermissions &= EUser|EReadWrite;
210 return (aPteType&aAccessPermissions)==aAccessPermissions;
214 FORCE_INLINE TMappingPermissions Mmu::PermissionsFromPteType(TUint aPteType)
216 return (TMappingPermissions)(aPteType&(EPteTypeUserAccess|EPteTypeWritable));
219 extern void __fastcall UserWriteFault(TLinAddr aAddr);
220 extern void __fastcall UserReadFault(TLinAddr aAddr);
224 Indicate whether a PDE entry maps a page table.
226 @param aPde The PDE entry in question.
228 FORCE_INLINE TBool Mmu::PdeMapsPageTable(TPde aPde)
230 return (aPde & KPdeLargePage) == 0;
235 Indicate whether a PDE entry maps a section.
237 @param aPde The PDE entry in question.
239 FORCE_INLINE TBool Mmu::PdeMapsSection(TPde aPde)
241 return (aPde & KPdeLargePage) != 0;