1 #ifndef _ASM_IA64_PAGE_H
2 #define _ASM_IA64_PAGE_H
4 * Pagetable related stuff.
6 * Copyright (C) 1998, 1999, 2002 Hewlett-Packard Co
7 * David Mosberger-Tang <davidm@hpl.hp.com>
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
27 # error Unsupported page size!
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 */
53 # define __pa(x) ((x) - PAGE_OFFSET)
54 # define __va(x) ((x) + PAGE_OFFSET)
55 #else /* !__ASSEMBLY */
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) \
69 flush_dcache_page(page); \
72 #define copy_user_page(to, from, vaddr, page) \
74 copy_page((to), (from)); \
75 flush_dcache_page(page); \
79 #define alloc_zeroed_user_highpage(vma, vaddr) \
81 struct page *page = alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO, vma, vaddr); \
83 flush_dcache_page(page); \
87 #define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE
89 #define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
91 #ifdef CONFIG_VIRTUAL_MEM_MAP
92 extern int ia64_pfn_valid (unsigned long pfn
);
94 # define ia64_pfn_valid(pfn) 1
97 #ifndef CONFIG_DISCONTIGMEM
98 # define pfn_valid(pfn) (((pfn) < max_mapnr) && ia64_pfn_valid(pfn))
99 # define page_to_pfn(page) ((unsigned long) (page - mem_map))
100 # define pfn_to_page(pfn) (mem_map + (pfn))
102 extern struct page
*vmem_map
;
103 extern unsigned long max_low_pfn
;
104 # define pfn_valid(pfn) (((pfn) < max_low_pfn) && ia64_pfn_valid(pfn))
105 # define page_to_pfn(page) ((unsigned long) (page - vmem_map))
106 # define pfn_to_page(pfn) (vmem_map + (pfn))
109 #define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT)
110 #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
112 typedef union ia64_va
{
114 unsigned long off
: 61; /* intra-region offset */
115 unsigned long reg
: 3; /* region number */
122 * Note: These macros depend on the fact that PAGE_OFFSET has all
123 * region bits set to 1 and all other bits set to zero. They are
124 * expressed in this way to ensure they result in a single "dep"
127 #define __pa(x) ({ia64_va _v; _v.l = (long) (x); _v.f.reg = 0; _v.l;})
128 #define __va(x) ({ia64_va _v; _v.l = (long) (x); _v.f.reg = -1; _v.p;})
130 #define REGION_NUMBER(x) ({ia64_va _v; _v.l = (long) (x); _v.f.reg;})
131 #define REGION_OFFSET(x) ({ia64_va _v; _v.l = (long) (x); _v.f.off;})
133 #define REGION_SIZE REGION_NUMBER(1)
134 #define REGION_KERNEL 7
136 #ifdef CONFIG_HUGETLB_PAGE
137 # define htlbpage_to_page(x) (((unsigned long) REGION_NUMBER(x) << 61) \
138 | (REGION_OFFSET(x) >> (HPAGE_SHIFT-PAGE_SHIFT)))
139 # define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)
140 # define is_hugepage_only_range(mm, addr, len) \
141 (REGION_NUMBER(addr) == REGION_HPAGE && \
142 REGION_NUMBER((addr)+(len)-1) == REGION_HPAGE)
143 extern unsigned int hpage_shift
;
146 static __inline__
int
147 get_order (unsigned long size
)
149 long double d
= size
- 1;
152 order
= ia64_getf_exp(d
);
153 order
= order
- PAGE_SHIFT
- 0xffff + 1;
159 # endif /* __KERNEL__ */
160 #endif /* !__ASSEMBLY__ */
162 #ifdef STRICT_MM_TYPECHECKS
164 * These are used to make use of C type-checking..
166 typedef struct { unsigned long pte
; } pte_t
;
167 typedef struct { unsigned long pmd
; } pmd_t
;
168 typedef struct { unsigned long pgd
; } pgd_t
;
169 typedef struct { unsigned long pgprot
; } pgprot_t
;
171 # define pte_val(x) ((x).pte)
172 # define pmd_val(x) ((x).pmd)
173 # define pgd_val(x) ((x).pgd)
174 # define pgprot_val(x) ((x).pgprot)
176 # define __pte(x) ((pte_t) { (x) } )
177 # define __pgprot(x) ((pgprot_t) { (x) } )
179 #else /* !STRICT_MM_TYPECHECKS */
181 * .. while these make it easier on the compiler
183 # ifndef __ASSEMBLY__
184 typedef unsigned long pte_t
;
185 typedef unsigned long pmd_t
;
186 typedef unsigned long pgd_t
;
187 typedef unsigned long pgprot_t
;
190 # define pte_val(x) (x)
191 # define pmd_val(x) (x)
192 # define pgd_val(x) (x)
193 # define pgprot_val(x) (x)
195 # define __pte(x) (x)
196 # define __pgd(x) (x)
197 # define __pgprot(x) (x)
198 #endif /* !STRICT_MM_TYPECHECKS */
200 #define PAGE_OFFSET __IA64_UL_CONST(0xe000000000000000)
202 #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | \
203 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC | \
204 (((current->personality & READ_IMPLIES_EXEC) != 0) \
207 #endif /* _ASM_IA64_PAGE_H */