diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/asm-ppc64/page.h |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'include/asm-ppc64/page.h')
-rw-r--r-- | include/asm-ppc64/page.h | 261 |
1 files changed, 261 insertions, 0 deletions
diff --git a/include/asm-ppc64/page.h b/include/asm-ppc64/page.h new file mode 100644 index 000000000000..20e0f19324e8 --- /dev/null +++ b/include/asm-ppc64/page.h | |||
@@ -0,0 +1,261 @@ | |||
1 | #ifndef _PPC64_PAGE_H | ||
2 | #define _PPC64_PAGE_H | ||
3 | |||
4 | /* | ||
5 | * Copyright (C) 2001 PPC64 Team, IBM Corp | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * as published by the Free Software Foundation; either version | ||
10 | * 2 of the License, or (at your option) any later version. | ||
11 | */ | ||
12 | |||
13 | #include <linux/config.h> | ||
14 | |||
15 | #ifdef __ASSEMBLY__ | ||
16 | #define ASM_CONST(x) x | ||
17 | #else | ||
18 | #define __ASM_CONST(x) x##UL | ||
19 | #define ASM_CONST(x) __ASM_CONST(x) | ||
20 | #endif | ||
21 | |||
22 | /* PAGE_SHIFT determines the page size */ | ||
23 | #define PAGE_SHIFT 12 | ||
24 | #define PAGE_SIZE (ASM_CONST(1) << PAGE_SHIFT) | ||
25 | #define PAGE_MASK (~(PAGE_SIZE-1)) | ||
26 | #define PAGE_OFFSET_MASK (PAGE_SIZE-1) | ||
27 | |||
28 | #define SID_SHIFT 28 | ||
29 | #define SID_MASK 0xfffffffffUL | ||
30 | #define ESID_MASK 0xfffffffff0000000UL | ||
31 | #define GET_ESID(x) (((x) >> SID_SHIFT) & SID_MASK) | ||
32 | |||
33 | #define HPAGE_SHIFT 24 | ||
34 | #define HPAGE_SIZE ((1UL) << HPAGE_SHIFT) | ||
35 | #define HPAGE_MASK (~(HPAGE_SIZE - 1)) | ||
36 | |||
37 | #ifdef CONFIG_HUGETLB_PAGE | ||
38 | |||
39 | #define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT) | ||
40 | |||
41 | /* For 64-bit processes the hugepage range is 1T-1.5T */ | ||
42 | #define TASK_HPAGE_BASE ASM_CONST(0x0000010000000000) | ||
43 | #define TASK_HPAGE_END ASM_CONST(0x0000018000000000) | ||
44 | |||
45 | #define LOW_ESID_MASK(addr, len) (((1U << (GET_ESID(addr+len-1)+1)) \ | ||
46 | - (1U << GET_ESID(addr))) & 0xffff) | ||
47 | |||
48 | #define ARCH_HAS_HUGEPAGE_ONLY_RANGE | ||
49 | #define ARCH_HAS_PREPARE_HUGEPAGE_RANGE | ||
50 | |||
51 | #define touches_hugepage_low_range(mm, addr, len) \ | ||
52 | (LOW_ESID_MASK((addr), (len)) & mm->context.htlb_segs) | ||
53 | #define touches_hugepage_high_range(addr, len) \ | ||
54 | (((addr) > (TASK_HPAGE_BASE-(len))) && ((addr) < TASK_HPAGE_END)) | ||
55 | |||
56 | #define __within_hugepage_low_range(addr, len, segmask) \ | ||
57 | ((LOW_ESID_MASK((addr), (len)) | (segmask)) == (segmask)) | ||
58 | #define within_hugepage_low_range(addr, len) \ | ||
59 | __within_hugepage_low_range((addr), (len), \ | ||
60 | current->mm->context.htlb_segs) | ||
61 | #define within_hugepage_high_range(addr, len) (((addr) >= TASK_HPAGE_BASE) \ | ||
62 | && ((addr)+(len) <= TASK_HPAGE_END) && ((addr)+(len) >= (addr))) | ||
63 | |||
64 | #define is_hugepage_only_range(mm, addr, len) \ | ||
65 | (touches_hugepage_high_range((addr), (len)) || \ | ||
66 | touches_hugepage_low_range((mm), (addr), (len))) | ||
67 | #define HAVE_ARCH_HUGETLB_UNMAPPED_AREA | ||
68 | |||
69 | #define in_hugepage_area(context, addr) \ | ||
70 | (cpu_has_feature(CPU_FTR_16M_PAGE) && \ | ||
71 | ( (((addr) >= TASK_HPAGE_BASE) && ((addr) < TASK_HPAGE_END)) || \ | ||
72 | ( ((addr) < 0x100000000L) && \ | ||
73 | ((1 << GET_ESID(addr)) & (context).htlb_segs) ) ) ) | ||
74 | |||
75 | #else /* !CONFIG_HUGETLB_PAGE */ | ||
76 | |||
77 | #define in_hugepage_area(mm, addr) 0 | ||
78 | |||
79 | #endif /* !CONFIG_HUGETLB_PAGE */ | ||
80 | |||
81 | /* align addr on a size boundary - adjust address up/down if needed */ | ||
82 | #define _ALIGN_UP(addr,size) (((addr)+((size)-1))&(~((size)-1))) | ||
83 | #define _ALIGN_DOWN(addr,size) ((addr)&(~((size)-1))) | ||
84 | |||
85 | /* align addr on a size boundary - adjust address up if needed */ | ||
86 | #define _ALIGN(addr,size) _ALIGN_UP(addr,size) | ||
87 | |||
88 | /* to align the pointer to the (next) double word boundary */ | ||
89 | #define DOUBLEWORD_ALIGN(addr) _ALIGN(addr,sizeof(unsigned long)) | ||
90 | |||
91 | /* to align the pointer to the (next) page boundary */ | ||
92 | #define PAGE_ALIGN(addr) _ALIGN(addr, PAGE_SIZE) | ||
93 | |||
94 | #ifdef __KERNEL__ | ||
95 | #ifndef __ASSEMBLY__ | ||
96 | #include <asm/cache.h> | ||
97 | |||
98 | #undef STRICT_MM_TYPECHECKS | ||
99 | |||
100 | #define REGION_SIZE 4UL | ||
101 | #define REGION_SHIFT 60UL | ||
102 | #define REGION_MASK (((1UL<<REGION_SIZE)-1UL)<<REGION_SHIFT) | ||
103 | #define REGION_STRIDE (1UL << REGION_SHIFT) | ||
104 | |||
105 | static __inline__ void clear_page(void *addr) | ||
106 | { | ||
107 | unsigned long lines, line_size; | ||
108 | |||
109 | line_size = ppc64_caches.dline_size; | ||
110 | lines = ppc64_caches.dlines_per_page; | ||
111 | |||
112 | __asm__ __volatile__( | ||
113 | "mtctr %1 # clear_page\n\ | ||
114 | 1: dcbz 0,%0\n\ | ||
115 | add %0,%0,%3\n\ | ||
116 | bdnz+ 1b" | ||
117 | : "=r" (addr) | ||
118 | : "r" (lines), "0" (addr), "r" (line_size) | ||
119 | : "ctr", "memory"); | ||
120 | } | ||
121 | |||
122 | extern void copy_page(void *to, void *from); | ||
123 | struct page; | ||
124 | extern void clear_user_page(void *page, unsigned long vaddr, struct page *pg); | ||
125 | extern void copy_user_page(void *to, void *from, unsigned long vaddr, struct page *p); | ||
126 | |||
127 | #ifdef STRICT_MM_TYPECHECKS | ||
128 | /* | ||
129 | * These are used to make use of C type-checking. | ||
130 | * Entries in the pte table are 64b, while entries in the pgd & pmd are 32b. | ||
131 | */ | ||
132 | typedef struct { unsigned long pte; } pte_t; | ||
133 | typedef struct { unsigned int pmd; } pmd_t; | ||
134 | typedef struct { unsigned int pgd; } pgd_t; | ||
135 | typedef struct { unsigned long pgprot; } pgprot_t; | ||
136 | |||
137 | #define pte_val(x) ((x).pte) | ||
138 | #define pmd_val(x) ((x).pmd) | ||
139 | #define pgd_val(x) ((x).pgd) | ||
140 | #define pgprot_val(x) ((x).pgprot) | ||
141 | |||
142 | #define __pte(x) ((pte_t) { (x) } ) | ||
143 | #define __pmd(x) ((pmd_t) { (x) } ) | ||
144 | #define __pgd(x) ((pgd_t) { (x) } ) | ||
145 | #define __pgprot(x) ((pgprot_t) { (x) } ) | ||
146 | |||
147 | #else | ||
148 | /* | ||
149 | * .. while these make it easier on the compiler | ||
150 | */ | ||
151 | typedef unsigned long pte_t; | ||
152 | typedef unsigned int pmd_t; | ||
153 | typedef unsigned int pgd_t; | ||
154 | typedef unsigned long pgprot_t; | ||
155 | |||
156 | #define pte_val(x) (x) | ||
157 | #define pmd_val(x) (x) | ||
158 | #define pgd_val(x) (x) | ||
159 | #define pgprot_val(x) (x) | ||
160 | |||
161 | #define __pte(x) (x) | ||
162 | #define __pmd(x) (x) | ||
163 | #define __pgd(x) (x) | ||
164 | #define __pgprot(x) (x) | ||
165 | |||
166 | #endif | ||
167 | |||
168 | /* Pure 2^n version of get_order */ | ||
169 | static inline int get_order(unsigned long size) | ||
170 | { | ||
171 | int order; | ||
172 | |||
173 | size = (size-1) >> (PAGE_SHIFT-1); | ||
174 | order = -1; | ||
175 | do { | ||
176 | size >>= 1; | ||
177 | order++; | ||
178 | } while (size); | ||
179 | return order; | ||
180 | } | ||
181 | |||
182 | #define __pa(x) ((unsigned long)(x)-PAGE_OFFSET) | ||
183 | |||
184 | extern int page_is_ram(unsigned long pfn); | ||
185 | |||
186 | extern u64 ppc64_pft_size; /* Log 2 of page table size */ | ||
187 | |||
188 | /* We do define AT_SYSINFO_EHDR but don't use the gate mecanism */ | ||
189 | #define __HAVE_ARCH_GATE_AREA 1 | ||
190 | |||
191 | #endif /* __ASSEMBLY__ */ | ||
192 | |||
193 | #ifdef MODULE | ||
194 | #define __page_aligned __attribute__((__aligned__(PAGE_SIZE))) | ||
195 | #else | ||
196 | #define __page_aligned \ | ||
197 | __attribute__((__aligned__(PAGE_SIZE), \ | ||
198 | __section__(".data.page_aligned"))) | ||
199 | #endif | ||
200 | |||
201 | |||
202 | /* This must match the -Ttext linker address */ | ||
203 | /* Note: tophys & tovirt make assumptions about how */ | ||
204 | /* KERNELBASE is defined for performance reasons. */ | ||
205 | /* When KERNELBASE moves, those macros may have */ | ||
206 | /* to change! */ | ||
207 | #define PAGE_OFFSET ASM_CONST(0xC000000000000000) | ||
208 | #define KERNELBASE PAGE_OFFSET | ||
209 | #define VMALLOCBASE ASM_CONST(0xD000000000000000) | ||
210 | #define IOREGIONBASE ASM_CONST(0xE000000000000000) | ||
211 | |||
212 | #define IO_REGION_ID (IOREGIONBASE>>REGION_SHIFT) | ||
213 | #define VMALLOC_REGION_ID (VMALLOCBASE>>REGION_SHIFT) | ||
214 | #define KERNEL_REGION_ID (KERNELBASE>>REGION_SHIFT) | ||
215 | #define USER_REGION_ID (0UL) | ||
216 | #define REGION_ID(X) (((unsigned long)(X))>>REGION_SHIFT) | ||
217 | |||
218 | #define __bpn_to_ba(x) ((((unsigned long)(x))<<PAGE_SHIFT) + KERNELBASE) | ||
219 | #define __ba_to_bpn(x) ((((unsigned long)(x)) & ~REGION_MASK) >> PAGE_SHIFT) | ||
220 | |||
221 | #define __va(x) ((void *)((unsigned long)(x) + KERNELBASE)) | ||
222 | |||
223 | #ifdef CONFIG_DISCONTIGMEM | ||
224 | #define page_to_pfn(page) discontigmem_page_to_pfn(page) | ||
225 | #define pfn_to_page(pfn) discontigmem_pfn_to_page(pfn) | ||
226 | #define pfn_valid(pfn) discontigmem_pfn_valid(pfn) | ||
227 | #else | ||
228 | #define pfn_to_page(pfn) (mem_map + (pfn)) | ||
229 | #define page_to_pfn(page) ((unsigned long)((page) - mem_map)) | ||
230 | #define pfn_valid(pfn) ((pfn) < max_mapnr) | ||
231 | #endif | ||
232 | |||
233 | #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT) | ||
234 | #define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT) | ||
235 | |||
236 | #define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT) | ||
237 | |||
238 | /* | ||
239 | * Unfortunately the PLT is in the BSS in the PPC32 ELF ABI, | ||
240 | * and needs to be executable. This means the whole heap ends | ||
241 | * up being executable. | ||
242 | */ | ||
243 | #define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \ | ||
244 | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) | ||
245 | |||
246 | #define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \ | ||
247 | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) | ||
248 | |||
249 | #define VM_DATA_DEFAULT_FLAGS \ | ||
250 | (test_thread_flag(TIF_32BIT) ? \ | ||
251 | VM_DATA_DEFAULT_FLAGS32 : VM_DATA_DEFAULT_FLAGS64) | ||
252 | |||
253 | /* | ||
254 | * This is the default if a program doesn't have a PT_GNU_STACK | ||
255 | * program header entry. | ||
256 | */ | ||
257 | #define VM_STACK_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \ | ||
258 | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) | ||
259 | |||
260 | #endif /* __KERNEL__ */ | ||
261 | #endif /* _PPC64_PAGE_H */ | ||