1 /* 2 * linux/include/asm-arm/proc-armo/pgtable.h 3 * 4 * Copyright (C) 1995-2001 Russell King 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License version 2 as 8 * published by the Free Software Foundation. 9 * 10 * 18-Oct-1997 RMK Now two-level (32x32) 11 */ 12 #ifndef __ASM_PROC_PGTABLE_H 13 #define __ASM_PROC_PGTABLE_H 14 15 /* 16 * entries per page directory level: they are two-level, so 17 * we don't really have any PMD directory. 18 */ 19 #define PTRS_PER_PTE 32 20 #define PTRS_PER_PMD 1 21 #define PTRS_PER_PGD 32 22 23 /* 24 * The vmalloc() routines leaves a hole of 4kB between each vmalloced 25 * area for the same reason. ;) 26 */ 27 #define VMALLOC_START 0x01a00000 28 #define VMALLOC_VMADDR(x) ((unsigned long)(x)) 29 #define VMALLOC_END 0x01c00000 30 31 #define _PAGE_TABLE (0x01) 32 33 #define pmd_bad(pmd) ((pmd_val(pmd) & 0xfc000002)) 34 #define set_pmd(pmdp,pmd) ((*(pmdp)) = (pmd)) 35 __mk_pmd(pte_t * ptep,unsigned long prot)36static inline pmd_t __mk_pmd(pte_t *ptep, unsigned long prot) 37 { 38 unsigned long pte_ptr = (unsigned long)ptep; 39 pmd_t pmd; 40 41 pmd_val(pmd) = __virt_to_phys(pte_ptr) | prot; 42 43 return pmd; 44 } 45 pmd_page(pmd_t pmd)46static inline unsigned long pmd_page(pmd_t pmd) 47 { 48 return __phys_to_virt(pmd_val(pmd) & ~_PAGE_TABLE); 49 } 50 51 #define set_pte(pteptr, pteval) ((*(pteptr)) = (pteval)) 52 53 #define _PAGE_PRESENT 0x01 54 #define _PAGE_READONLY 0x02 55 #define _PAGE_NOT_USER 0x04 56 #define _PAGE_OLD 0x08 57 #define _PAGE_CLEAN 0x10 58 59 /* -- present -- -- !dirty -- --- !write --- ---- !user --- */ 60 #define PAGE_NONE __pgprot(_PAGE_PRESENT | _PAGE_CLEAN | _PAGE_READONLY | _PAGE_NOT_USER) 61 #define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_CLEAN ) 62 #define PAGE_COPY __pgprot(_PAGE_PRESENT | _PAGE_CLEAN | _PAGE_READONLY ) 63 #define PAGE_READONLY __pgprot(_PAGE_PRESENT | _PAGE_CLEAN | _PAGE_READONLY ) 64 #define PAGE_KERNEL __pgprot(_PAGE_PRESENT | _PAGE_NOT_USER) 65 66 #define _PAGE_CHG_MASK (PAGE_MASK | _PAGE_OLD | _PAGE_CLEAN) 67 68 69 /* 70 * The following only work if pte_present() is true. 71 * Undefined behaviour if not.. 72 */ 73 #define pte_present(pte) (pte_val(pte) & _PAGE_PRESENT) 74 #define pte_read(pte) (!(pte_val(pte) & _PAGE_NOT_USER)) 75 #define pte_write(pte) (!(pte_val(pte) & _PAGE_READONLY)) 76 #define pte_exec(pte) (!(pte_val(pte) & _PAGE_NOT_USER)) 77 #define pte_dirty(pte) (!(pte_val(pte) & _PAGE_CLEAN)) 78 #define pte_young(pte) (!(pte_val(pte) & _PAGE_OLD)) 79 pte_wrprotect(pte_t pte)80static inline pte_t pte_wrprotect(pte_t pte) { pte_val(pte) |= _PAGE_READONLY; return pte; } pte_rdprotect(pte_t pte)81static inline pte_t pte_rdprotect(pte_t pte) { pte_val(pte) |= _PAGE_NOT_USER; return pte; } pte_exprotect(pte_t pte)82static inline pte_t pte_exprotect(pte_t pte) { pte_val(pte) |= _PAGE_NOT_USER; return pte; } pte_mkclean(pte_t pte)83static inline pte_t pte_mkclean(pte_t pte) { pte_val(pte) |= _PAGE_CLEAN; return pte; } pte_mkold(pte_t pte)84static inline pte_t pte_mkold(pte_t pte) { pte_val(pte) |= _PAGE_OLD; return pte; } 85 pte_mkwrite(pte_t pte)86static inline pte_t pte_mkwrite(pte_t pte) { pte_val(pte) &= ~_PAGE_READONLY; return pte; } pte_mkread(pte_t pte)87static inline pte_t pte_mkread(pte_t pte) { pte_val(pte) &= ~_PAGE_NOT_USER; return pte; } pte_mkexec(pte_t pte)88static inline pte_t pte_mkexec(pte_t pte) { pte_val(pte) &= ~_PAGE_NOT_USER; return pte; } pte_mkdirty(pte_t pte)89static inline pte_t pte_mkdirty(pte_t pte) { pte_val(pte) &= ~_PAGE_CLEAN; return pte; } pte_mkyoung(pte_t pte)90static inline pte_t pte_mkyoung(pte_t pte) { pte_val(pte) &= ~_PAGE_OLD; return pte; } 91 92 #define pte_alloc_kernel pte_alloc 93 94 /* 95 * We don't store cache state bits in the page table here. 96 */ 97 #define pgprot_noncached(prot) (prot) 98 99 #endif /* __ASM_PROC_PGTABLE_H */ 100