aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-um/pgtable.h
diff options
context:
space:
mode:
authorJeff Dike <jdike@addtoit.com>2005-09-03 18:57:41 -0400
committerLinus Torvalds <torvalds@evo.osdl.org>2005-09-05 03:06:22 -0400
commit08964c565b2fe49e338ffbe4907adcc19647ef16 (patch)
treedd37fefc7f654c8662154dd92efd0258e81a0ff4 /include/asm-um/pgtable.h
parentc56004901fa5dcf55f92318f192ab3c0e87db2d1 (diff)
[PATCH] uml: merge duplicated page table code
There is a lot of code which is duplicated between the 2 and 3 level implementation, with the only difference that the 3-level implementation is a bit more generalized (instead of accessing directly pte_t.pte, it uses the appropriate access macros). So this code is joined together. As obvious, a "core code nice cleanup" is not a "stability-friendly patch" so usual care applies. Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Signed-off-by: Jeff Dike <jdike@addtoit.com> Cc: Paolo Giarrusso <blaisorblade@yahoo.it> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include/asm-um/pgtable.h')
-rw-r--r--include/asm-um/pgtable.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/include/asm-um/pgtable.h b/include/asm-um/pgtable.h
index e9336f616f9c..b48e0966ecd7 100644
--- a/include/asm-um/pgtable.h
+++ b/include/asm-um/pgtable.h
@@ -153,10 +153,24 @@ extern unsigned long pg0[1024];
153 153
154#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)
155 155
156#define pte_page(x) pfn_to_page(pte_pfn(x))
156#define pte_address(x) (__va(pte_val(x) & PAGE_MASK)) 157#define pte_address(x) (__va(pte_val(x) & PAGE_MASK))
157#define mk_phys(a, r) ((a) + (((unsigned long) r) << REGION_SHIFT)) 158#define mk_phys(a, r) ((a) + (((unsigned long) r) << REGION_SHIFT))
158#define phys_addr(p) ((p) & ~REGION_MASK) 159#define phys_addr(p) ((p) & ~REGION_MASK)
159 160
161#define pte_present(x) pte_get_bits(x, (_PAGE_PRESENT | _PAGE_PROTNONE))
162
163/*
164 * =================================
165 * Flags checking section.
166 * =================================
167 */
168
169static inline int pte_none(pte_t pte)
170{
171 return pte_is_zero(pte);
172}
173
160/* 174/*
161 * The following only work if pte_present() is true. 175 * The following only work if pte_present() is true.
162 * Undefined behaviour if not.. 176 * Undefined behaviour if not..
@@ -212,6 +226,18 @@ static inline int pte_newprot(pte_t pte)
212 return(pte_present(pte) && (pte_get_bits(pte, _PAGE_NEWPROT))); 226 return(pte_present(pte) && (pte_get_bits(pte, _PAGE_NEWPROT)));
213} 227}
214 228
229/*
230 * =================================
231 * Flags setting section.
232 * =================================
233 */
234
235static inline pte_t pte_mknewprot(pte_t pte)
236{
237 pte_set_bits(pte, _PAGE_NEWPROT);
238 return(pte);
239}
240
215static inline pte_t pte_rdprotect(pte_t pte) 241static inline pte_t pte_rdprotect(pte_t pte)
216{ 242{
217 pte_clear_bits(pte, _PAGE_USER); 243 pte_clear_bits(pte, _PAGE_USER);
@@ -280,6 +306,26 @@ static inline pte_t pte_mkuptodate(pte_t pte)
280 return(pte); 306 return(pte);
281} 307}
282 308
309static inline pte_t pte_mknewpage(pte_t pte)
310{
311 pte_set_bits(pte, _PAGE_NEWPAGE);
312 return(pte);
313}
314
315static 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
283extern phys_t page_to_phys(struct page *page); 329extern phys_t page_to_phys(struct page *page);
284 330
285/* 331/*