Merge remote-tracking branch 'remotes/powerpc/topic/xive' into kvm-ppc-next
[linux/fpc-iii.git] / arch / um / include / asm / page.h
blobf878bec23576c54c619b633ce0c81508519ddb56
1 /*
2 * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
3 * Copyright 2003 PathScale, Inc.
4 * Licensed under the GPL
5 */
7 #ifndef __UM_PAGE_H
8 #define __UM_PAGE_H
10 #include <linux/const.h>
12 /* PAGE_SHIFT determines the page size */
13 #define PAGE_SHIFT 12
14 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
15 #define PAGE_MASK (~(PAGE_SIZE-1))
17 #ifndef __ASSEMBLY__
19 struct page;
21 #include <linux/pfn.h>
22 #include <linux/types.h>
23 #include <asm/vm-flags.h>
26 * These are used to make use of C type-checking..
29 #define clear_page(page) memset((void *)(page), 0, PAGE_SIZE)
30 #define copy_page(to,from) memcpy((void *)(to), (void *)(from), PAGE_SIZE)
32 #define clear_user_page(page, vaddr, pg) clear_page(page)
33 #define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
35 #if defined(CONFIG_3_LEVEL_PGTABLES) && !defined(CONFIG_64BIT)
37 typedef struct { unsigned long pte; } pte_t;
38 typedef struct { unsigned long pmd; } pmd_t;
39 typedef struct { unsigned long pgd; } pgd_t;
40 #define pte_val(p) ((p).pte)
42 #define pte_get_bits(p, bits) ((p).pte & (bits))
43 #define pte_set_bits(p, bits) ((p).pte |= (bits))
44 #define pte_clear_bits(p, bits) ((p).pte &= ~(bits))
45 #define pte_copy(to, from) ({ (to).pte = (from).pte; })
46 #define pte_is_zero(p) (!((p).pte & ~_PAGE_NEWPAGE))
47 #define pte_set_val(p, phys, prot) \
48 ({ (p).pte = (phys) | pgprot_val(prot); })
50 #define pmd_val(x) ((x).pmd)
51 #define __pmd(x) ((pmd_t) { (x) } )
53 typedef unsigned long long phys_t;
55 #else
57 typedef struct { unsigned long pte; } pte_t;
58 typedef struct { unsigned long pgd; } pgd_t;
60 #ifdef CONFIG_3_LEVEL_PGTABLES
61 typedef struct { unsigned long pmd; } pmd_t;
62 #define pmd_val(x) ((x).pmd)
63 #define __pmd(x) ((pmd_t) { (x) } )
64 #endif
66 #define pte_val(x) ((x).pte)
69 #define pte_get_bits(p, bits) ((p).pte & (bits))
70 #define pte_set_bits(p, bits) ((p).pte |= (bits))
71 #define pte_clear_bits(p, bits) ((p).pte &= ~(bits))
72 #define pte_copy(to, from) ((to).pte = (from).pte)
73 #define pte_is_zero(p) (!((p).pte & ~_PAGE_NEWPAGE))
74 #define pte_set_val(p, phys, prot) (p).pte = (phys | pgprot_val(prot))
76 typedef unsigned long phys_t;
78 #endif
80 typedef struct { unsigned long pgprot; } pgprot_t;
82 typedef struct page *pgtable_t;
84 #define pgd_val(x) ((x).pgd)
85 #define pgprot_val(x) ((x).pgprot)
87 #define __pte(x) ((pte_t) { (x) } )
88 #define __pgd(x) ((pgd_t) { (x) } )
89 #define __pgprot(x) ((pgprot_t) { (x) } )
91 extern unsigned long uml_physmem;
93 #define PAGE_OFFSET (uml_physmem)
94 #define KERNELBASE PAGE_OFFSET
96 #define __va_space (8*1024*1024)
98 #include <mem.h>
100 /* Cast to unsigned long before casting to void * to avoid a warning from
101 * mmap_kmem about cutting a long long down to a void *. Not sure that
102 * casting is the right thing, but 32-bit UML can't have 64-bit virtual
103 * addresses
105 #define __pa(virt) to_phys((void *) (unsigned long) (virt))
106 #define __va(phys) to_virt((unsigned long) (phys))
108 #define phys_to_pfn(p) ((p) >> PAGE_SHIFT)
109 #define pfn_to_phys(pfn) PFN_PHYS(pfn)
111 #define pfn_valid(pfn) ((pfn) < max_mapnr)
112 #define virt_addr_valid(v) pfn_valid(phys_to_pfn(__pa(v)))
114 #include <asm-generic/memory_model.h>
115 #include <asm-generic/getorder.h>
117 #endif /* __ASSEMBLY__ */
119 #ifdef CONFIG_X86_32
120 #define __HAVE_ARCH_GATE_AREA 1
121 #endif
123 #endif /* __UM_PAGE_H */