diff options
Diffstat (limited to 'include/asm-um/pgtable.h')
-rw-r--r-- | include/asm-um/pgtable.h | 54 |
1 files changed, 51 insertions, 3 deletions
diff --git a/include/asm-um/pgtable.h b/include/asm-um/pgtable.h index a88040920311..b48e0966ecd7 100644 --- a/include/asm-um/pgtable.h +++ b/include/asm-um/pgtable.h | |||
@@ -16,13 +16,15 @@ | |||
16 | 16 | ||
17 | #define _PAGE_PRESENT 0x001 | 17 | #define _PAGE_PRESENT 0x001 |
18 | #define _PAGE_NEWPAGE 0x002 | 18 | #define _PAGE_NEWPAGE 0x002 |
19 | #define _PAGE_NEWPROT 0x004 | 19 | #define _PAGE_NEWPROT 0x004 |
20 | #define _PAGE_FILE 0x008 /* set:pagecache unset:swap */ | ||
21 | #define _PAGE_PROTNONE 0x010 /* If not present */ | ||
22 | #define _PAGE_RW 0x020 | 20 | #define _PAGE_RW 0x020 |
23 | #define _PAGE_USER 0x040 | 21 | #define _PAGE_USER 0x040 |
24 | #define _PAGE_ACCESSED 0x080 | 22 | #define _PAGE_ACCESSED 0x080 |
25 | #define _PAGE_DIRTY 0x100 | 23 | #define _PAGE_DIRTY 0x100 |
24 | /* If _PAGE_PRESENT is clear, we use these: */ | ||
25 | #define _PAGE_FILE 0x008 /* nonlinear file mapping, saved PTE; unset:swap */ | ||
26 | #define _PAGE_PROTNONE 0x010 /* if the user mapped it with PROT_NONE; | ||
27 | pte_present gives true */ | ||
26 | 28 | ||
27 | #ifdef CONFIG_3_LEVEL_PGTABLES | 29 | #ifdef CONFIG_3_LEVEL_PGTABLES |
28 | #include "asm/pgtable-3level.h" | 30 | #include "asm/pgtable-3level.h" |
@@ -151,10 +153,24 @@ extern unsigned long pg0[1024]; | |||
151 | 153 | ||
152 | #define pmd_page(pmd) phys_to_page(pmd_val(pmd) & PAGE_MASK) | 154 | #define pmd_page(pmd) phys_to_page(pmd_val(pmd) & PAGE_MASK) |
153 | 155 | ||
156 | #define pte_page(x) pfn_to_page(pte_pfn(x)) | ||
154 | #define pte_address(x) (__va(pte_val(x) & PAGE_MASK)) | 157 | #define pte_address(x) (__va(pte_val(x) & PAGE_MASK)) |
155 | #define mk_phys(a, r) ((a) + (((unsigned long) r) << REGION_SHIFT)) | 158 | #define mk_phys(a, r) ((a) + (((unsigned long) r) << REGION_SHIFT)) |
156 | #define phys_addr(p) ((p) & ~REGION_MASK) | 159 | #define phys_addr(p) ((p) & ~REGION_MASK) |
157 | 160 | ||
161 | #define pte_present(x) pte_get_bits(x, (_PAGE_PRESENT | _PAGE_PROTNONE)) | ||
162 | |||
163 | /* | ||
164 | * ================================= | ||
165 | * Flags checking section. | ||
166 | * ================================= | ||
167 | */ | ||
168 | |||
169 | static inline int pte_none(pte_t pte) | ||
170 | { | ||
171 | return pte_is_zero(pte); | ||
172 | } | ||
173 | |||
158 | /* | 174 | /* |
159 | * The following only work if pte_present() is true. | 175 | * The following only work if pte_present() is true. |
160 | * Undefined behaviour if not.. | 176 | * Undefined behaviour if not.. |
@@ -210,6 +226,18 @@ static inline int pte_newprot(pte_t pte) | |||
210 | return(pte_present(pte) && (pte_get_bits(pte, _PAGE_NEWPROT))); | 226 | return(pte_present(pte) && (pte_get_bits(pte, _PAGE_NEWPROT))); |
211 | } | 227 | } |
212 | 228 | ||
229 | /* | ||
230 | * ================================= | ||
231 | * Flags setting section. | ||
232 | * ================================= | ||
233 | */ | ||
234 | |||
235 | static inline pte_t pte_mknewprot(pte_t pte) | ||
236 | { | ||
237 | pte_set_bits(pte, _PAGE_NEWPROT); | ||
238 | return(pte); | ||
239 | } | ||
240 | |||
213 | static inline pte_t pte_rdprotect(pte_t pte) | 241 | static inline pte_t pte_rdprotect(pte_t pte) |
214 | { | 242 | { |
215 | pte_clear_bits(pte, _PAGE_USER); | 243 | pte_clear_bits(pte, _PAGE_USER); |
@@ -278,6 +306,26 @@ static inline pte_t pte_mkuptodate(pte_t pte) | |||
278 | return(pte); | 306 | return(pte); |
279 | } | 307 | } |
280 | 308 | ||
309 | static inline pte_t pte_mknewpage(pte_t pte) | ||
310 | { | ||
311 | pte_set_bits(pte, _PAGE_NEWPAGE); | ||
312 | return(pte); | ||
313 | } | ||
314 | |||
315 | static inline void set_pte(pte_t *pteptr, pte_t pteval) | ||
316 | { | ||
317 | pte_copy(*pteptr, pteval); | ||
318 | |||
319 | /* If it's a swap entry, it needs to be marked _PAGE_NEWPAGE so | ||
320 | * fix_range knows to unmap it. _PAGE_NEWPROT is specific to | ||
321 | * mapped pages. | ||
322 | */ | ||
323 | |||
324 | *pteptr = pte_mknewpage(*pteptr); | ||
325 | if(pte_present(*pteptr)) *pteptr = pte_mknewprot(*pteptr); | ||
326 | } | ||
327 | #define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval) | ||
328 | |||
281 | extern phys_t page_to_phys(struct page *page); | 329 | extern phys_t page_to_phys(struct page *page); |
282 | 330 | ||
283 | /* | 331 | /* |