aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/include/asm/pgtable.h
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2010-11-26 15:35:25 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2010-11-26 15:45:44 -0500
commitb510b049b549500816280f7ceaa087cfefdec581 (patch)
tree73e62d34ce385353944a7960a97d2152bac1eb55 /arch/arm/include/asm/pgtable.h
parent4eec4b1396ac6a6a602b4521d40e9cf596ab776d (diff)
ARM: pgtable: group pte functions together
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/include/asm/pgtable.h')
-rw-r--r--arch/arm/include/asm/pgtable.h110
1 files changed, 51 insertions, 59 deletions
diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
index 8ee9dce10b83..0ebe1165ba0a 100644
--- a/arch/arm/include/asm/pgtable.h
+++ b/arch/arm/include/asm/pgtable.h
@@ -299,26 +299,66 @@ extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
299#define set_pgd(pgd,pgdp) do { } while (0) 299#define set_pgd(pgd,pgdp) do { } while (0)
300 300
301 301
302#define pte_pfn(pte) (pte_val(pte) >> PAGE_SHIFT) 302/* Find an entry in the second-level page table.. */
303#define pfn_pte(pfn,prot) (__pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot))) 303#define pmd_offset(dir, addr) ((pmd_t *)(dir))
304 304
305#define pte_none(pte) (!pte_val(pte)) 305#define pmd_none(pmd) (!pmd_val(pmd))
306#define pte_clear(mm,addr,ptep) set_pte_ext(ptep, __pte(0), 0) 306#define pmd_present(pmd) (pmd_val(pmd))
307#define pte_page(pte) (pfn_to_page(pte_pfn(pte))) 307#define pmd_bad(pmd) (pmd_val(pmd) & 2)
308#define pte_offset_kernel(dir,addr) (pmd_page_vaddr(*(dir)) + __pte_index(addr)) 308
309#define copy_pmd(pmdpd,pmdps) \
310 do { \
311 pmdpd[0] = pmdps[0]; \
312 pmdpd[1] = pmdps[1]; \
313 flush_pmd_entry(pmdpd); \
314 } while (0)
315
316#define pmd_clear(pmdp) \
317 do { \
318 pmdp[0] = __pmd(0); \
319 pmdp[1] = __pmd(0); \
320 clean_pmd_entry(pmdp); \
321 } while (0)
322
323static inline pte_t *pmd_page_vaddr(pmd_t pmd)
324{
325 unsigned long ptr;
326
327 ptr = pmd_val(pmd) & ~(PTRS_PER_PTE * sizeof(void *) - 1);
328 ptr += PTRS_PER_PTE * sizeof(void *);
329
330 return __va(ptr);
331}
332
333#define pmd_page(pmd) pfn_to_page(__phys_to_pfn(pmd_val(pmd)))
334
335/* we don't need complex calculations here as the pmd is folded into the pgd */
336#define pmd_addr_end(addr,end) (end)
309 337
310#define pte_offset_map(dir,addr) (__pte_map(dir) + __pte_index(addr))
311#define pte_unmap(pte) __pte_unmap(pte)
312 338
313#ifndef CONFIG_HIGHPTE 339#ifndef CONFIG_HIGHPTE
314#define __pte_map(dir) pmd_page_vaddr(*(dir)) 340#define __pte_map(pmd) pmd_page_vaddr(*(pmd))
315#define __pte_unmap(pte) do { } while (0) 341#define __pte_unmap(pte) do { } while (0)
316#else 342#else
317#define __pte_map(dir) ((pte_t *)kmap_atomic(pmd_page(*(dir))) + PTRS_PER_PTE) 343#define __pte_map(pmd) ((pte_t *)kmap_atomic(pmd_page(*(pmd))) + PTRS_PER_PTE)
318#define __pte_unmap(pte) kunmap_atomic((pte - PTRS_PER_PTE)) 344#define __pte_unmap(pte) kunmap_atomic((pte - PTRS_PER_PTE))
319#endif 345#endif
320 346
347#define pte_index(addr) (((addr) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
348
349#define pte_offset_kernel(pmd,addr) (pmd_page_vaddr(*(pmd)) + pte_index(addr))
350
351#define pte_offset_map(pmd,addr) (__pte_map(pmd) + pte_index(addr))
352#define pte_unmap(pte) __pte_unmap(pte)
353
354#define pte_pfn(pte) (pte_val(pte) >> PAGE_SHIFT)
355#define pfn_pte(pfn,prot) __pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
356
357#define pte_page(pte) pfn_to_page(pte_pfn(pte))
358#define mk_pte(page,prot) pfn_pte(page_to_pfn(page), prot)
359
321#define set_pte_ext(ptep,pte,ext) cpu_set_pte_ext(ptep,pte,ext) 360#define set_pte_ext(ptep,pte,ext) cpu_set_pte_ext(ptep,pte,ext)
361#define pte_clear(mm,addr,ptep) set_pte_ext(ptep, __pte(0), 0)
322 362
323#if __LINUX_ARM_ARCH__ < 6 363#if __LINUX_ARM_ARCH__ < 6
324static inline void __sync_icache_dcache(pte_t pteval) 364static inline void __sync_icache_dcache(pte_t pteval)
@@ -339,10 +379,7 @@ static inline void set_pte_at(struct mm_struct *mm, unsigned long addr,
339 } 379 }
340} 380}
341 381
342/* 382#define pte_none(pte) (!pte_val(pte))
343 * The following only work if pte_present() is true.
344 * Undefined behaviour if not..
345 */
346#define pte_present(pte) (pte_val(pte) & L_PTE_PRESENT) 383#define pte_present(pte) (pte_val(pte) & L_PTE_PRESENT)
347#define pte_write(pte) (pte_val(pte) & L_PTE_WRITE) 384#define pte_write(pte) (pte_val(pte) & L_PTE_WRITE)
348#define pte_dirty(pte) (pte_val(pte) & L_PTE_DIRTY) 385#define pte_dirty(pte) (pte_val(pte) & L_PTE_DIRTY)
@@ -366,51 +403,6 @@ PTE_BIT_FUNC(mkyoung, |= L_PTE_YOUNG);
366 403
367static inline pte_t pte_mkspecial(pte_t pte) { return pte; } 404static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
368 405
369#define pmd_none(pmd) (!pmd_val(pmd))
370#define pmd_present(pmd) (pmd_val(pmd))
371#define pmd_bad(pmd) (pmd_val(pmd) & 2)
372
373#define copy_pmd(pmdpd,pmdps) \
374 do { \
375 pmdpd[0] = pmdps[0]; \
376 pmdpd[1] = pmdps[1]; \
377 flush_pmd_entry(pmdpd); \
378 } while (0)
379
380#define pmd_clear(pmdp) \
381 do { \
382 pmdp[0] = __pmd(0); \
383 pmdp[1] = __pmd(0); \
384 clean_pmd_entry(pmdp); \
385 } while (0)
386
387static inline pte_t *pmd_page_vaddr(pmd_t pmd)
388{
389 unsigned long ptr;
390
391 ptr = pmd_val(pmd) & ~(PTRS_PER_PTE * sizeof(void *) - 1);
392 ptr += PTRS_PER_PTE * sizeof(void *);
393
394 return __va(ptr);
395}
396
397#define pmd_page(pmd) pfn_to_page(__phys_to_pfn(pmd_val(pmd)))
398
399/* we don't need complex calculations here as the pmd is folded into the pgd */
400#define pmd_addr_end(addr,end) (end)
401
402/*
403 * Conversion functions: convert a page and protection to a page entry,
404 * and a page entry and page directory to the page they refer to.
405 */
406#define mk_pte(page,prot) pfn_pte(page_to_pfn(page),prot)
407
408/* Find an entry in the second-level page table.. */
409#define pmd_offset(dir, addr) ((pmd_t *)(dir))
410
411/* Find an entry in the third-level page table.. */
412#define __pte_index(addr) (((addr) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
413
414static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) 406static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
415{ 407{
416 const unsigned long mask = L_PTE_EXEC | L_PTE_WRITE | L_PTE_USER; 408 const unsigned long mask = L_PTE_EXEC | L_PTE_WRITE | L_PTE_USER;