0001
0002
0003
0004
0005
0006
0007 #ifndef __UM_PGTABLE_3LEVEL_H
0008 #define __UM_PGTABLE_3LEVEL_H
0009
0010 #include <asm-generic/pgtable-nopud.h>
0011
0012
0013
0014 #ifdef CONFIG_64BIT
0015 #define PGDIR_SHIFT 30
0016 #else
0017 #define PGDIR_SHIFT 31
0018 #endif
0019 #define PGDIR_SIZE (1UL << PGDIR_SHIFT)
0020 #define PGDIR_MASK (~(PGDIR_SIZE-1))
0021
0022
0023
0024
0025
0026 #define PMD_SHIFT 21
0027 #define PMD_SIZE (1UL << PMD_SHIFT)
0028 #define PMD_MASK (~(PMD_SIZE-1))
0029
0030
0031
0032
0033
0034 #define PTRS_PER_PTE 512
0035 #ifdef CONFIG_64BIT
0036 #define PTRS_PER_PMD 512
0037 #define PTRS_PER_PGD 512
0038 #else
0039 #define PTRS_PER_PMD 1024
0040 #define PTRS_PER_PGD 1024
0041 #endif
0042
0043 #define USER_PTRS_PER_PGD ((TASK_SIZE + (PGDIR_SIZE - 1)) / PGDIR_SIZE)
0044
0045 #define pte_ERROR(e) \
0046 printk("%s:%d: bad pte %p(%016lx).\n", __FILE__, __LINE__, &(e), \
0047 pte_val(e))
0048 #define pmd_ERROR(e) \
0049 printk("%s:%d: bad pmd %p(%016lx).\n", __FILE__, __LINE__, &(e), \
0050 pmd_val(e))
0051 #define pgd_ERROR(e) \
0052 printk("%s:%d: bad pgd %p(%016lx).\n", __FILE__, __LINE__, &(e), \
0053 pgd_val(e))
0054
0055 #define pud_none(x) (!(pud_val(x) & ~_PAGE_NEWPAGE))
0056 #define pud_bad(x) ((pud_val(x) & (~PAGE_MASK & ~_PAGE_USER)) != _KERNPG_TABLE)
0057 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
0058 #define pud_populate(mm, pud, pmd) \
0059 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
0060
0061 #ifdef CONFIG_64BIT
0062 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
0063 #else
0064 #define set_pud(pudptr, pudval) (*(pudptr) = (pudval))
0065 #endif
0066
0067 static inline int pgd_newpage(pgd_t pgd)
0068 {
0069 return(pgd_val(pgd) & _PAGE_NEWPAGE);
0070 }
0071
0072 static inline void pgd_mkuptodate(pgd_t pgd) { pgd_val(pgd) &= ~_PAGE_NEWPAGE; }
0073
0074 #ifdef CONFIG_64BIT
0075 #define set_pmd(pmdptr, pmdval) set_64bit((u64 *) (pmdptr), pmd_val(pmdval))
0076 #else
0077 #define set_pmd(pmdptr, pmdval) (*(pmdptr) = (pmdval))
0078 #endif
0079
0080 static inline void pud_clear (pud_t *pud)
0081 {
0082 set_pud(pud, __pud(_PAGE_NEWPAGE));
0083 }
0084
0085 #define pud_page(pud) phys_to_page(pud_val(pud) & PAGE_MASK)
0086 #define pud_pgtable(pud) ((pmd_t *) __va(pud_val(pud) & PAGE_MASK))
0087
0088 static inline unsigned long pte_pfn(pte_t pte)
0089 {
0090 return phys_to_pfn(pte_val(pte));
0091 }
0092
0093 static inline pte_t pfn_pte(unsigned long page_nr, pgprot_t pgprot)
0094 {
0095 pte_t pte;
0096 phys_t phys = pfn_to_phys(page_nr);
0097
0098 pte_set_val(pte, phys, pgprot);
0099 return pte;
0100 }
0101
0102 static inline pmd_t pfn_pmd(unsigned long page_nr, pgprot_t pgprot)
0103 {
0104 return __pmd((page_nr << PAGE_SHIFT) | pgprot_val(pgprot));
0105 }
0106
0107 #endif
0108