initial commit with v2.6.9
[linux-2.6.9-moxart.git] / include / asm-ia64 / page.h
blob0936ebcc22e1609a199adf178eb725bcf38408ef
1 #ifndef _ASM_IA64_PAGE_H
2 #define _ASM_IA64_PAGE_H
3 /*
4 * Pagetable related stuff.
6 * Copyright (C) 1998, 1999, 2002 Hewlett-Packard Co
7 * David Mosberger-Tang <davidm@hpl.hp.com>
8 */
10 #include <linux/config.h>
12 #include <asm/intrinsics.h>
13 #include <asm/types.h>
16 * PAGE_SHIFT determines the actual kernel page size.
18 #if defined(CONFIG_IA64_PAGE_SIZE_4KB)
19 # define PAGE_SHIFT 12
20 #elif defined(CONFIG_IA64_PAGE_SIZE_8KB)
21 # define PAGE_SHIFT 13
22 #elif defined(CONFIG_IA64_PAGE_SIZE_16KB)
23 # define PAGE_SHIFT 14
24 #elif defined(CONFIG_IA64_PAGE_SIZE_64KB)
25 # define PAGE_SHIFT 16
26 #else
27 # error Unsupported page size!
28 #endif
30 #define PAGE_SIZE (__IA64_UL_CONST(1) << PAGE_SHIFT)
31 #define PAGE_MASK (~(PAGE_SIZE - 1))
32 #define PAGE_ALIGN(addr) (((addr) + PAGE_SIZE - 1) & PAGE_MASK)
34 #define PERCPU_PAGE_SHIFT 16 /* log2() of max. size of per-CPU area */
35 #define PERCPU_PAGE_SIZE (__IA64_UL_CONST(1) << PERCPU_PAGE_SHIFT)
37 #define RGN_MAP_LIMIT ((1UL << (4*PAGE_SHIFT - 12)) - PAGE_SIZE) /* per region addr limit */
39 #ifdef CONFIG_HUGETLB_PAGE
40 # define REGION_HPAGE (4UL) /* note: this is hardcoded in reload_context()!*/
41 # define REGION_SHIFT 61
42 # define HPAGE_REGION_BASE (REGION_HPAGE << REGION_SHIFT)
43 # define HPAGE_SHIFT hpage_shift
44 # define HPAGE_SHIFT_DEFAULT 28 /* check ia64 SDM for architecture supported size */
45 # define HPAGE_SIZE (__IA64_UL_CONST(1) << HPAGE_SHIFT)
46 # define HPAGE_MASK (~(HPAGE_SIZE - 1))
48 # define HAVE_ARCH_HUGETLB_UNMAPPED_AREA
49 # define ARCH_HAS_HUGEPAGE_ONLY_RANGE
50 #endif /* CONFIG_HUGETLB_PAGE */
52 #ifdef __ASSEMBLY__
53 # define __pa(x) ((x) - PAGE_OFFSET)
54 # define __va(x) ((x) + PAGE_OFFSET)
55 #else /* !__ASSEMBLY */
56 # ifdef __KERNEL__
57 # define STRICT_MM_TYPECHECKS
59 extern void clear_page (void *page);
60 extern void copy_page (void *to, void *from);
63 * clear_user_page() and copy_user_page() can't be inline functions because
64 * flush_dcache_page() can't be defined until later...
66 #define clear_user_page(addr, vaddr, page) \
67 do { \
68 clear_page(addr); \
69 flush_dcache_page(page); \
70 } while (0)
72 #define copy_user_page(to, from, vaddr, page) \
73 do { \
74 copy_page((to), (from)); \
75 flush_dcache_page(page); \
76 } while (0)
78 #define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
80 #ifdef CONFIG_VIRTUAL_MEM_MAP
81 extern int ia64_pfn_valid (unsigned long pfn);
82 #else
83 # define ia64_pfn_valid(pfn) 1
84 #endif
86 #ifndef CONFIG_DISCONTIGMEM
87 # define pfn_valid(pfn) (((pfn) < max_mapnr) && ia64_pfn_valid(pfn))
88 # define page_to_pfn(page) ((unsigned long) (page - mem_map))
89 # define pfn_to_page(pfn) (mem_map + (pfn))
90 #else
91 extern struct page *vmem_map;
92 extern unsigned long max_low_pfn;
93 # define pfn_valid(pfn) (((pfn) < max_low_pfn) && ia64_pfn_valid(pfn))
94 # define page_to_pfn(page) ((unsigned long) (page - vmem_map))
95 # define pfn_to_page(pfn) (vmem_map + (pfn))
96 #endif
98 #define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT)
99 #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
101 typedef union ia64_va {
102 struct {
103 unsigned long off : 61; /* intra-region offset */
104 unsigned long reg : 3; /* region number */
105 } f;
106 unsigned long l;
107 void *p;
108 } ia64_va;
111 * Note: These macros depend on the fact that PAGE_OFFSET has all
112 * region bits set to 1 and all other bits set to zero. They are
113 * expressed in this way to ensure they result in a single "dep"
114 * instruction.
116 #define __pa(x) ({ia64_va _v; _v.l = (long) (x); _v.f.reg = 0; _v.l;})
117 #define __va(x) ({ia64_va _v; _v.l = (long) (x); _v.f.reg = -1; _v.p;})
119 #define REGION_NUMBER(x) ({ia64_va _v; _v.l = (long) (x); _v.f.reg;})
120 #define REGION_OFFSET(x) ({ia64_va _v; _v.l = (long) (x); _v.f.off;})
122 #define REGION_SIZE REGION_NUMBER(1)
123 #define REGION_KERNEL 7
125 #ifdef CONFIG_HUGETLB_PAGE
126 # define htlbpage_to_page(x) (((unsigned long) REGION_NUMBER(x) << 61) \
127 | (REGION_OFFSET(x) >> (HPAGE_SHIFT-PAGE_SHIFT)))
128 # define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)
129 # define is_hugepage_only_range(addr, len) \
130 (REGION_NUMBER(addr) == REGION_HPAGE && \
131 REGION_NUMBER((addr)+(len)) == REGION_HPAGE)
132 extern unsigned int hpage_shift;
133 #endif
135 static __inline__ int
136 get_order (unsigned long size)
138 long double d = size - 1;
139 long order;
141 order = ia64_getf_exp(d);
142 order = order - PAGE_SHIFT - 0xffff + 1;
143 if (order < 0)
144 order = 0;
145 return order;
148 # endif /* __KERNEL__ */
149 #endif /* !__ASSEMBLY__ */
151 #ifdef STRICT_MM_TYPECHECKS
153 * These are used to make use of C type-checking..
155 typedef struct { unsigned long pte; } pte_t;
156 typedef struct { unsigned long pmd; } pmd_t;
157 typedef struct { unsigned long pgd; } pgd_t;
158 typedef struct { unsigned long pgprot; } pgprot_t;
160 # define pte_val(x) ((x).pte)
161 # define pmd_val(x) ((x).pmd)
162 # define pgd_val(x) ((x).pgd)
163 # define pgprot_val(x) ((x).pgprot)
165 # define __pte(x) ((pte_t) { (x) } )
166 # define __pgprot(x) ((pgprot_t) { (x) } )
168 #else /* !STRICT_MM_TYPECHECKS */
170 * .. while these make it easier on the compiler
172 # ifndef __ASSEMBLY__
173 typedef unsigned long pte_t;
174 typedef unsigned long pmd_t;
175 typedef unsigned long pgd_t;
176 typedef unsigned long pgprot_t;
177 # endif
179 # define pte_val(x) (x)
180 # define pmd_val(x) (x)
181 # define pgd_val(x) (x)
182 # define pgprot_val(x) (x)
184 # define __pte(x) (x)
185 # define __pgd(x) (x)
186 # define __pgprot(x) (x)
187 #endif /* !STRICT_MM_TYPECHECKS */
189 #define PAGE_OFFSET __IA64_UL_CONST(0xe000000000000000)
191 #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | \
192 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC | \
193 (((current->personality & READ_IMPLIES_EXEC) != 0) \
194 ? VM_EXEC : 0))
196 #endif /* _ASM_IA64_PAGE_H */