diff options
Diffstat (limited to 'include/asm-mips/pgtable.h')
-rw-r--r-- | include/asm-mips/pgtable.h | 88 |
1 files changed, 49 insertions, 39 deletions
diff --git a/include/asm-mips/pgtable.h b/include/asm-mips/pgtable.h index 69cebbd9f3e0..f80fe75c7800 100644 --- a/include/asm-mips/pgtable.h +++ b/include/asm-mips/pgtable.h | |||
@@ -90,10 +90,11 @@ extern void paging_init(void); | |||
90 | #define pmd_page(pmd) (pfn_to_page(pmd_phys(pmd) >> PAGE_SHIFT)) | 90 | #define pmd_page(pmd) (pfn_to_page(pmd_phys(pmd) >> PAGE_SHIFT)) |
91 | #define pmd_page_kernel(pmd) pmd_val(pmd) | 91 | #define pmd_page_kernel(pmd) pmd_val(pmd) |
92 | 92 | ||
93 | #define pte_none(pte) (!(pte_val(pte) & ~_PAGE_GLOBAL)) | ||
94 | #define pte_present(pte) (pte_val(pte) & _PAGE_PRESENT) | ||
95 | |||
96 | #if defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32_R1) | 93 | #if defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32_R1) |
94 | |||
95 | #define pte_none(pte) (!(((pte).pte_low | (pte).pte_high) & ~_PAGE_GLOBAL)) | ||
96 | #define pte_present(pte) ((pte).pte_low & _PAGE_PRESENT) | ||
97 | |||
97 | static inline void set_pte(pte_t *ptep, pte_t pte) | 98 | static inline void set_pte(pte_t *ptep, pte_t pte) |
98 | { | 99 | { |
99 | ptep->pte_high = pte.pte_high; | 100 | ptep->pte_high = pte.pte_high; |
@@ -101,27 +102,35 @@ static inline void set_pte(pte_t *ptep, pte_t pte) | |||
101 | ptep->pte_low = pte.pte_low; | 102 | ptep->pte_low = pte.pte_low; |
102 | //printk("pte_high %x pte_low %x\n", ptep->pte_high, ptep->pte_low); | 103 | //printk("pte_high %x pte_low %x\n", ptep->pte_high, ptep->pte_low); |
103 | 104 | ||
104 | if (pte_val(pte) & _PAGE_GLOBAL) { | 105 | if (pte.pte_low & _PAGE_GLOBAL) { |
105 | pte_t *buddy = ptep_buddy(ptep); | 106 | pte_t *buddy = ptep_buddy(ptep); |
106 | /* | 107 | /* |
107 | * Make sure the buddy is global too (if it's !none, | 108 | * Make sure the buddy is global too (if it's !none, |
108 | * it better already be global) | 109 | * it better already be global) |
109 | */ | 110 | */ |
110 | if (pte_none(*buddy)) | 111 | if (pte_none(*buddy)) { |
111 | buddy->pte_low |= _PAGE_GLOBAL; | 112 | buddy->pte_low |= _PAGE_GLOBAL; |
113 | buddy->pte_high |= _PAGE_GLOBAL; | ||
114 | } | ||
112 | } | 115 | } |
113 | } | 116 | } |
114 | #define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval) | 117 | #define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval) |
115 | 118 | ||
116 | static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep) | 119 | static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep) |
117 | { | 120 | { |
121 | pte_t null = __pte(0); | ||
122 | |||
118 | /* Preserve global status for the pair */ | 123 | /* Preserve global status for the pair */ |
119 | if (pte_val(*ptep_buddy(ptep)) & _PAGE_GLOBAL) | 124 | if (ptep_buddy(ptep)->pte_low & _PAGE_GLOBAL) |
120 | set_pte_at(mm, addr, ptep, __pte(_PAGE_GLOBAL)); | 125 | null.pte_low = null.pte_high = _PAGE_GLOBAL; |
121 | else | 126 | |
122 | set_pte_at(mm, addr, ptep, __pte(0)); | 127 | set_pte_at(mm, addr, ptep, null); |
123 | } | 128 | } |
124 | #else | 129 | #else |
130 | |||
131 | #define pte_none(pte) (!(pte_val(pte) & ~_PAGE_GLOBAL)) | ||
132 | #define pte_present(pte) (pte_val(pte) & _PAGE_PRESENT) | ||
133 | |||
125 | /* | 134 | /* |
126 | * Certain architectures need to do special things when pte's | 135 | * Certain architectures need to do special things when pte's |
127 | * within a page table are directly modified. Thus, the following | 136 | * within a page table are directly modified. Thus, the following |
@@ -182,75 +191,76 @@ extern pgd_t swapper_pg_dir[PTRS_PER_PGD]; | |||
182 | */ | 191 | */ |
183 | static inline int pte_user(pte_t pte) { BUG(); return 0; } | 192 | static inline int pte_user(pte_t pte) { BUG(); return 0; } |
184 | #if defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32_R1) | 193 | #if defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32_R1) |
185 | static inline int pte_read(pte_t pte) { return (pte).pte_low & _PAGE_READ; } | 194 | static inline int pte_read(pte_t pte) { return pte.pte_low & _PAGE_READ; } |
186 | static inline int pte_write(pte_t pte) { return (pte).pte_low & _PAGE_WRITE; } | 195 | static inline int pte_write(pte_t pte) { return pte.pte_low & _PAGE_WRITE; } |
187 | static inline int pte_dirty(pte_t pte) { return (pte).pte_low & _PAGE_MODIFIED; } | 196 | static inline int pte_dirty(pte_t pte) { return pte.pte_low & _PAGE_MODIFIED; } |
188 | static inline int pte_young(pte_t pte) { return (pte).pte_low & _PAGE_ACCESSED; } | 197 | static inline int pte_young(pte_t pte) { return pte.pte_low & _PAGE_ACCESSED; } |
189 | static inline int pte_file(pte_t pte) { return (pte).pte_low & _PAGE_FILE; } | 198 | static inline int pte_file(pte_t pte) { return pte.pte_low & _PAGE_FILE; } |
199 | |||
190 | static inline pte_t pte_wrprotect(pte_t pte) | 200 | static inline pte_t pte_wrprotect(pte_t pte) |
191 | { | 201 | { |
192 | (pte).pte_low &= ~(_PAGE_WRITE | _PAGE_SILENT_WRITE); | 202 | pte.pte_low &= ~(_PAGE_WRITE | _PAGE_SILENT_WRITE); |
193 | (pte).pte_high &= ~_PAGE_SILENT_WRITE; | 203 | pte.pte_high &= ~_PAGE_SILENT_WRITE; |
194 | return pte; | 204 | return pte; |
195 | } | 205 | } |
196 | 206 | ||
197 | static inline pte_t pte_rdprotect(pte_t pte) | 207 | static inline pte_t pte_rdprotect(pte_t pte) |
198 | { | 208 | { |
199 | (pte).pte_low &= ~(_PAGE_READ | _PAGE_SILENT_READ); | 209 | pte.pte_low &= ~(_PAGE_READ | _PAGE_SILENT_READ); |
200 | (pte).pte_high &= ~_PAGE_SILENT_READ; | 210 | pte.pte_high &= ~_PAGE_SILENT_READ; |
201 | return pte; | 211 | return pte; |
202 | } | 212 | } |
203 | 213 | ||
204 | static inline pte_t pte_mkclean(pte_t pte) | 214 | static inline pte_t pte_mkclean(pte_t pte) |
205 | { | 215 | { |
206 | (pte).pte_low &= ~(_PAGE_MODIFIED|_PAGE_SILENT_WRITE); | 216 | pte.pte_low &= ~(_PAGE_MODIFIED | _PAGE_SILENT_WRITE); |
207 | (pte).pte_high &= ~_PAGE_SILENT_WRITE; | 217 | pte.pte_high &= ~_PAGE_SILENT_WRITE; |
208 | return pte; | 218 | return pte; |
209 | } | 219 | } |
210 | 220 | ||
211 | static inline pte_t pte_mkold(pte_t pte) | 221 | static inline pte_t pte_mkold(pte_t pte) |
212 | { | 222 | { |
213 | (pte).pte_low &= ~(_PAGE_ACCESSED|_PAGE_SILENT_READ); | 223 | pte.pte_low &= ~(_PAGE_ACCESSED | _PAGE_SILENT_READ); |
214 | (pte).pte_high &= ~_PAGE_SILENT_READ; | 224 | pte.pte_high &= ~_PAGE_SILENT_READ; |
215 | return pte; | 225 | return pte; |
216 | } | 226 | } |
217 | 227 | ||
218 | static inline pte_t pte_mkwrite(pte_t pte) | 228 | static inline pte_t pte_mkwrite(pte_t pte) |
219 | { | 229 | { |
220 | (pte).pte_low |= _PAGE_WRITE; | 230 | pte.pte_low |= _PAGE_WRITE; |
221 | if ((pte).pte_low & _PAGE_MODIFIED) { | 231 | if (pte.pte_low & _PAGE_MODIFIED) { |
222 | (pte).pte_low |= _PAGE_SILENT_WRITE; | 232 | pte.pte_low |= _PAGE_SILENT_WRITE; |
223 | (pte).pte_high |= _PAGE_SILENT_WRITE; | 233 | pte.pte_high |= _PAGE_SILENT_WRITE; |
224 | } | 234 | } |
225 | return pte; | 235 | return pte; |
226 | } | 236 | } |
227 | 237 | ||
228 | static inline pte_t pte_mkread(pte_t pte) | 238 | static inline pte_t pte_mkread(pte_t pte) |
229 | { | 239 | { |
230 | (pte).pte_low |= _PAGE_READ; | 240 | pte.pte_low |= _PAGE_READ; |
231 | if ((pte).pte_low & _PAGE_ACCESSED) { | 241 | if (pte.pte_low & _PAGE_ACCESSED) { |
232 | (pte).pte_low |= _PAGE_SILENT_READ; | 242 | pte.pte_low |= _PAGE_SILENT_READ; |
233 | (pte).pte_high |= _PAGE_SILENT_READ; | 243 | pte.pte_high |= _PAGE_SILENT_READ; |
234 | } | 244 | } |
235 | return pte; | 245 | return pte; |
236 | } | 246 | } |
237 | 247 | ||
238 | static inline pte_t pte_mkdirty(pte_t pte) | 248 | static inline pte_t pte_mkdirty(pte_t pte) |
239 | { | 249 | { |
240 | (pte).pte_low |= _PAGE_MODIFIED; | 250 | pte.pte_low |= _PAGE_MODIFIED; |
241 | if ((pte).pte_low & _PAGE_WRITE) { | 251 | if (pte.pte_low & _PAGE_WRITE) { |
242 | (pte).pte_low |= _PAGE_SILENT_WRITE; | 252 | pte.pte_low |= _PAGE_SILENT_WRITE; |
243 | (pte).pte_high |= _PAGE_SILENT_WRITE; | 253 | pte.pte_high |= _PAGE_SILENT_WRITE; |
244 | } | 254 | } |
245 | return pte; | 255 | return pte; |
246 | } | 256 | } |
247 | 257 | ||
248 | static inline pte_t pte_mkyoung(pte_t pte) | 258 | static inline pte_t pte_mkyoung(pte_t pte) |
249 | { | 259 | { |
250 | (pte).pte_low |= _PAGE_ACCESSED; | 260 | pte.pte_low |= _PAGE_ACCESSED; |
251 | if ((pte).pte_low & _PAGE_READ) | 261 | if (pte.pte_low & _PAGE_READ) |
252 | (pte).pte_low |= _PAGE_SILENT_READ; | 262 | pte.pte_low |= _PAGE_SILENT_READ; |
253 | (pte).pte_high |= _PAGE_SILENT_READ; | 263 | pte.pte_high |= _PAGE_SILENT_READ; |
254 | return pte; | 264 | return pte; |
255 | } | 265 | } |
256 | #else | 266 | #else |