aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-mips/pgtable-64.h
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2005-02-10 07:19:59 -0500
committerRalf Baechle <ralf@linux-mips.org>2005-10-29 14:30:31 -0400
commitc6e8b587718c486b55c2ebecc6de231a30beba35 (patch)
tree7c6162d449c69fb6425bd27ba341e2d874fb0a1b /include/asm-mips/pgtable-64.h
parent57f0060b8a2bb2a70a4cce1a37d5e0158cea92a6 (diff)
Update MIPS to use the 4-level pagetable code thereby getting rid of
the compacrapability headers. Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'include/asm-mips/pgtable-64.h')
-rw-r--r--include/asm-mips/pgtable-64.h55
1 files changed, 32 insertions, 23 deletions
diff --git a/include/asm-mips/pgtable-64.h b/include/asm-mips/pgtable-64.h
index 1011e0635f56..ac5517fa1ee4 100644
--- a/include/asm-mips/pgtable-64.h
+++ b/include/asm-mips/pgtable-64.h
@@ -16,13 +16,15 @@
16#include <asm/page.h> 16#include <asm/page.h>
17#include <asm/cachectl.h> 17#include <asm/cachectl.h>
18 18
19#include <asm-generic/pgtable-nopud.h>
20
19/* 21/*
20 * Each address space has 2 4K pages as its page directory, giving 1024 22 * Each address space has 2 4K pages as its page directory, giving 1024
21 * (== PTRS_PER_PGD) 8 byte pointers to pmd tables. Each pmd table is a 23 * (== PTRS_PER_PGD) 8 byte pointers to pmd tables. Each pmd table is a
22 * pair of 4K pages, giving 1024 (== PTRS_PER_PMD) 8 byte pointers to 24 * single 4K page, giving 512 (== PTRS_PER_PMD) 8 byte pointers to page
23 * page tables. Each page table is a single 4K page, giving 512 (== 25 * tables. Each page table is also a single 4K page, giving 512 (==
24 * PTRS_PER_PTE) 8 byte ptes. Each pgde is initialized to point to 26 * PTRS_PER_PTE) 8 byte ptes. Each pud entry is initialized to point to
25 * invalid_pmd_table, each pmde is initialized to point to 27 * invalid_pmd_table, each pmd entry is initialized to point to
26 * invalid_pte_table, each pte is initialized to 0. When memory is low, 28 * invalid_pte_table, each pte is initialized to 0. When memory is low,
27 * and a pmd table or a page table allocation fails, empty_bad_pmd_table 29 * and a pmd table or a page table allocation fails, empty_bad_pmd_table
28 * and empty_bad_page_table is returned back to higher layer code, so 30 * and empty_bad_page_table is returned back to higher layer code, so
@@ -36,17 +38,17 @@
36 */ 38 */
37 39
38/* PMD_SHIFT determines the size of the area a second-level page table can map */ 40/* PMD_SHIFT determines the size of the area a second-level page table can map */
39#define PMD_SHIFT (PAGE_SHIFT + (PAGE_SHIFT - 3)) 41#define PMD_SHIFT (PAGE_SHIFT + (PAGE_SHIFT + PTE_ORDER - 3))
40#define PMD_SIZE (1UL << PMD_SHIFT) 42#define PMD_SIZE (1UL << PMD_SHIFT)
41#define PMD_MASK (~(PMD_SIZE-1)) 43#define PMD_MASK (~(PMD_SIZE-1))
42 44
43/* PGDIR_SHIFT determines what a third-level page table entry can map */ 45/* PGDIR_SHIFT determines what a third-level page table entry can map */
44#define PGDIR_SHIFT (PMD_SHIFT + (PAGE_SHIFT + 1 - 3)) 46#define PGDIR_SHIFT (PMD_SHIFT + (PAGE_SHIFT + PMD_ORDER - 3))
45#define PGDIR_SIZE (1UL << PGDIR_SHIFT) 47#define PGDIR_SIZE (1UL << PGDIR_SHIFT)
46#define PGDIR_MASK (~(PGDIR_SIZE-1)) 48#define PGDIR_MASK (~(PGDIR_SIZE-1))
47 49
48/* 50/*
49 * For 4kB page size we use a 3 level page tree and a 8kB pmd and pgds which 51 * For 4kB page size we use a 3 level page tree and an 8kB pud, which
50 * permits us mapping 40 bits of virtual address space. 52 * permits us mapping 40 bits of virtual address space.
51 * 53 *
52 * We used to implement 41 bits by having an order 1 pmd level but that seemed 54 * We used to implement 41 bits by having an order 1 pmd level but that seemed
@@ -65,21 +67,25 @@
65 */ 67 */
66#ifdef CONFIG_PAGE_SIZE_4KB 68#ifdef CONFIG_PAGE_SIZE_4KB
67#define PGD_ORDER 1 69#define PGD_ORDER 1
70#define PUD_ORDER aieeee_attempt_to_allocate_pud
68#define PMD_ORDER 0 71#define PMD_ORDER 0
69#define PTE_ORDER 0 72#define PTE_ORDER 0
70#endif 73#endif
71#ifdef CONFIG_PAGE_SIZE_8KB 74#ifdef CONFIG_PAGE_SIZE_8KB
72#define PGD_ORDER 0 75#define PGD_ORDER 0
76#define PUD_ORDER aieeee_attempt_to_allocate_pud
73#define PMD_ORDER 0 77#define PMD_ORDER 0
74#define PTE_ORDER 0 78#define PTE_ORDER 0
75#endif 79#endif
76#ifdef CONFIG_PAGE_SIZE_16KB 80#ifdef CONFIG_PAGE_SIZE_16KB
77#define PGD_ORDER 0 81#define PGD_ORDER 0
82#define PUD_ORDER aieeee_attempt_to_allocate_pud
78#define PMD_ORDER 0 83#define PMD_ORDER 0
79#define PTE_ORDER 0 84#define PTE_ORDER 0
80#endif 85#endif
81#ifdef CONFIG_PAGE_SIZE_64KB 86#ifdef CONFIG_PAGE_SIZE_64KB
82#define PGD_ORDER 0 87#define PGD_ORDER 0
88#define PUD_ORDER aieeee_attempt_to_allocate_pud
83#define PMD_ORDER 0 89#define PMD_ORDER 0
84#define PTE_ORDER 0 90#define PTE_ORDER 0
85#endif 91#endif
@@ -102,10 +108,10 @@
102#define pgd_ERROR(e) \ 108#define pgd_ERROR(e) \
103 printk("%s:%d: bad pgd %016lx.\n", __FILE__, __LINE__, pgd_val(e)) 109 printk("%s:%d: bad pgd %016lx.\n", __FILE__, __LINE__, pgd_val(e))
104 110
105extern pte_t invalid_pte_table[PAGE_SIZE/sizeof(pte_t)]; 111extern pte_t invalid_pte_table[PTRS_PER_PTE];
106extern pte_t empty_bad_page_table[PAGE_SIZE/sizeof(pte_t)]; 112extern pte_t empty_bad_page_table[PTRS_PER_PTE];
107extern pmd_t invalid_pmd_table[2*PAGE_SIZE/sizeof(pmd_t)]; 113extern pmd_t invalid_pmd_table[PTRS_PER_PMD];
108extern pmd_t empty_bad_pmd_table[2*PAGE_SIZE/sizeof(pmd_t)]; 114extern pmd_t empty_bad_pmd_table[PTRS_PER_PMD];
109 115
110/* 116/*
111 * Empty pmd entries point to the invalid_pte_table. 117 * Empty pmd entries point to the invalid_pte_table.
@@ -130,21 +136,24 @@ static inline void pmd_clear(pmd_t *pmdp)
130/* 136/*
131 * Empty pgd entries point to the invalid_pmd_table. 137 * Empty pgd entries point to the invalid_pmd_table.
132 */ 138 */
133static inline int pgd_none(pgd_t pgd) 139static inline int pud_none(pud_t pud)
134{ 140{
135 return pgd_val(pgd) == (unsigned long) invalid_pmd_table; 141 return pud_val(pud) == (unsigned long) invalid_pmd_table;
136} 142}
137 143
138#define pgd_bad(pgd) (pgd_val(pgd) &~ PAGE_MASK) 144static inline int pud_bad(pud_t pud)
145{
146 return pud_val(pud) & ~PAGE_MASK;
147}
139 148
140static inline int pgd_present(pgd_t pgd) 149static inline int pud_present(pud_t pud)
141{ 150{
142 return pgd_val(pgd) != (unsigned long) invalid_pmd_table; 151 return pud_val(pud) != (unsigned long) invalid_pmd_table;
143} 152}
144 153
145static inline void pgd_clear(pgd_t *pgdp) 154static inline void pud_clear(pud_t *pudp)
146{ 155{
147 pgd_val(*pgdp) = ((unsigned long) invalid_pmd_table); 156 pud_val(*pudp) = ((unsigned long) invalid_pmd_table);
148} 157}
149 158
150#define pte_page(x) pfn_to_page((unsigned long)((pte_val(x) >> PAGE_SHIFT))) 159#define pte_page(x) pfn_to_page((unsigned long)((pte_val(x) >> PAGE_SHIFT)))
@@ -162,20 +171,20 @@ static inline void pgd_clear(pgd_t *pgdp)
162/* to find an entry in a kernel page-table-directory */ 171/* to find an entry in a kernel page-table-directory */
163#define pgd_offset_k(address) pgd_offset(&init_mm, 0) 172#define pgd_offset_k(address) pgd_offset(&init_mm, 0)
164 173
165#define pgd_index(address) ((address) >> PGDIR_SHIFT) 174#define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
166 175
167/* to find an entry in a page-table-directory */ 176/* to find an entry in a page-table-directory */
168#define pgd_offset(mm,addr) ((mm)->pgd + pgd_index(addr)) 177#define pgd_offset(mm,addr) ((mm)->pgd + pgd_index(addr))
169 178
170static inline unsigned long pgd_page(pgd_t pgd) 179static inline unsigned long pud_page(pud_t pud)
171{ 180{
172 return pgd_val(pgd); 181 return pud_val(pud);
173} 182}
174 183
175/* Find an entry in the second-level page table.. */ 184/* Find an entry in the second-level page table.. */
176static inline pmd_t *pmd_offset(pgd_t * dir, unsigned long address) 185static inline pmd_t *pmd_offset(pud_t * pud, unsigned long address)
177{ 186{
178 return (pmd_t *) pgd_page(*dir) + 187 return (pmd_t *) pud_page(*pud) +
179 ((address >> PMD_SHIFT) & (PTRS_PER_PMD - 1)); 188 ((address >> PMD_SHIFT) & (PTRS_PER_PMD - 1));
180} 189}
181 190