diff options
author | Michael Ellerman <michael@ellerman.id.au> | 2005-11-10 22:25:24 -0500 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2005-11-14 00:33:05 -0500 |
commit | 5cd16ee934eafca74a6bb790328950cec68a8b78 (patch) | |
tree | 2f4335c9559f5d1d199ea6e0b20185ceede4a2b5 /include/asm-powerpc/page_64.h | |
parent | ee90f62b3e69d0cd9f8edc6b95f07b1a8c38aaf4 (diff) |
[PATCH] powerpc: Merge page.h
Merge asm-ppc/page.h and asm-ppc64/page.h into asm-powerpc/page.h,
asm-powerpc/page_32.h and asm-powerpc/page_64.h
Built for PPC (common_defconfig), with ARCH=powerpc, mostly built with
ARCH=ppc (other things break the build). Built and booted on P5 LPAR
for PPC64 with ARCH=ppc/powerpc (pseries_defconfig). Mostly built for
iSeries powerpc.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'include/asm-powerpc/page_64.h')
-rw-r--r-- | include/asm-powerpc/page_64.h | 174 |
1 files changed, 174 insertions, 0 deletions
diff --git a/include/asm-powerpc/page_64.h b/include/asm-powerpc/page_64.h new file mode 100644 index 000000000000..c16f106b5373 --- /dev/null +++ b/include/asm-powerpc/page_64.h | |||
@@ -0,0 +1,174 @@ | |||
1 | #ifndef _ASM_POWERPC_PAGE_64_H | ||
2 | #define _ASM_POWERPC_PAGE_64_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 | /* | ||
14 | * We always define HW_PAGE_SHIFT to 12 as use of 64K pages remains Linux | ||
15 | * specific, every notion of page number shared with the firmware, TCEs, | ||
16 | * iommu, etc... still uses a page size of 4K. | ||
17 | */ | ||
18 | #define HW_PAGE_SHIFT 12 | ||
19 | #define HW_PAGE_SIZE (ASM_CONST(1) << HW_PAGE_SHIFT) | ||
20 | #define HW_PAGE_MASK (~(HW_PAGE_SIZE-1)) | ||
21 | |||
22 | /* | ||
23 | * PAGE_FACTOR is the number of bits factor between PAGE_SHIFT and | ||
24 | * HW_PAGE_SHIFT, that is 4K pages. | ||
25 | */ | ||
26 | #define PAGE_FACTOR (PAGE_SHIFT - HW_PAGE_SHIFT) | ||
27 | |||
28 | #define REGION_SIZE 4UL | ||
29 | #define REGION_SHIFT 60UL | ||
30 | #define REGION_MASK (((1UL<<REGION_SIZE)-1UL)<<REGION_SHIFT) | ||
31 | |||
32 | #define VMALLOCBASE ASM_CONST(0xD000000000000000) | ||
33 | #define VMALLOC_REGION_ID (VMALLOCBASE >> REGION_SHIFT) | ||
34 | #define KERNEL_REGION_ID (KERNELBASE >> REGION_SHIFT) | ||
35 | #define USER_REGION_ID (0UL) | ||
36 | #define REGION_ID(ea) (((unsigned long)(ea)) >> REGION_SHIFT) | ||
37 | |||
38 | /* Segment size */ | ||
39 | #define SID_SHIFT 28 | ||
40 | #define SID_MASK 0xfffffffffUL | ||
41 | #define ESID_MASK 0xfffffffff0000000UL | ||
42 | #define GET_ESID(x) (((x) >> SID_SHIFT) & SID_MASK) | ||
43 | |||
44 | #ifndef __ASSEMBLY__ | ||
45 | #include <asm/cache.h> | ||
46 | |||
47 | typedef unsigned long pte_basic_t; | ||
48 | |||
49 | static __inline__ void clear_page(void *addr) | ||
50 | { | ||
51 | unsigned long lines, line_size; | ||
52 | |||
53 | line_size = ppc64_caches.dline_size; | ||
54 | lines = ppc64_caches.dlines_per_page; | ||
55 | |||
56 | __asm__ __volatile__( | ||
57 | "mtctr %1 # clear_page\n\ | ||
58 | 1: dcbz 0,%0\n\ | ||
59 | add %0,%0,%3\n\ | ||
60 | bdnz+ 1b" | ||
61 | : "=r" (addr) | ||
62 | : "r" (lines), "0" (addr), "r" (line_size) | ||
63 | : "ctr", "memory"); | ||
64 | } | ||
65 | |||
66 | extern void copy_4K_page(void *to, void *from); | ||
67 | |||
68 | #ifdef CONFIG_PPC_64K_PAGES | ||
69 | static inline void copy_page(void *to, void *from) | ||
70 | { | ||
71 | unsigned int i; | ||
72 | for (i=0; i < (1 << (PAGE_SHIFT - 12)); i++) { | ||
73 | copy_4K_page(to, from); | ||
74 | to += 4096; | ||
75 | from += 4096; | ||
76 | } | ||
77 | } | ||
78 | #else /* CONFIG_PPC_64K_PAGES */ | ||
79 | static inline void copy_page(void *to, void *from) | ||
80 | { | ||
81 | copy_4K_page(to, from); | ||
82 | } | ||
83 | #endif /* CONFIG_PPC_64K_PAGES */ | ||
84 | |||
85 | /* Log 2 of page table size */ | ||
86 | extern u64 ppc64_pft_size; | ||
87 | |||
88 | /* Large pages size */ | ||
89 | extern unsigned int HPAGE_SHIFT; | ||
90 | #define HPAGE_SIZE ((1UL) << HPAGE_SHIFT) | ||
91 | #define HPAGE_MASK (~(HPAGE_SIZE - 1)) | ||
92 | #define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT) | ||
93 | |||
94 | #endif /* __ASSEMBLY__ */ | ||
95 | |||
96 | #ifdef CONFIG_HUGETLB_PAGE | ||
97 | |||
98 | #define HTLB_AREA_SHIFT 40 | ||
99 | #define HTLB_AREA_SIZE (1UL << HTLB_AREA_SHIFT) | ||
100 | #define GET_HTLB_AREA(x) ((x) >> HTLB_AREA_SHIFT) | ||
101 | |||
102 | #define LOW_ESID_MASK(addr, len) (((1U << (GET_ESID(addr+len-1)+1)) \ | ||
103 | - (1U << GET_ESID(addr))) & 0xffff) | ||
104 | #define HTLB_AREA_MASK(addr, len) (((1U << (GET_HTLB_AREA(addr+len-1)+1)) \ | ||
105 | - (1U << GET_HTLB_AREA(addr))) & 0xffff) | ||
106 | |||
107 | #define ARCH_HAS_HUGEPAGE_ONLY_RANGE | ||
108 | #define ARCH_HAS_PREPARE_HUGEPAGE_RANGE | ||
109 | #define ARCH_HAS_SETCLEAR_HUGE_PTE | ||
110 | |||
111 | #define touches_hugepage_low_range(mm, addr, len) \ | ||
112 | (LOW_ESID_MASK((addr), (len)) & (mm)->context.low_htlb_areas) | ||
113 | #define touches_hugepage_high_range(mm, addr, len) \ | ||
114 | (HTLB_AREA_MASK((addr), (len)) & (mm)->context.high_htlb_areas) | ||
115 | |||
116 | #define __within_hugepage_low_range(addr, len, segmask) \ | ||
117 | ((LOW_ESID_MASK((addr), (len)) | (segmask)) == (segmask)) | ||
118 | #define within_hugepage_low_range(addr, len) \ | ||
119 | __within_hugepage_low_range((addr), (len), \ | ||
120 | current->mm->context.low_htlb_areas) | ||
121 | #define __within_hugepage_high_range(addr, len, zonemask) \ | ||
122 | ((HTLB_AREA_MASK((addr), (len)) | (zonemask)) == (zonemask)) | ||
123 | #define within_hugepage_high_range(addr, len) \ | ||
124 | __within_hugepage_high_range((addr), (len), \ | ||
125 | current->mm->context.high_htlb_areas) | ||
126 | |||
127 | #define is_hugepage_only_range(mm, addr, len) \ | ||
128 | (touches_hugepage_high_range((mm), (addr), (len)) || \ | ||
129 | touches_hugepage_low_range((mm), (addr), (len))) | ||
130 | #define HAVE_ARCH_HUGETLB_UNMAPPED_AREA | ||
131 | |||
132 | #define in_hugepage_area(context, addr) \ | ||
133 | (cpu_has_feature(CPU_FTR_16M_PAGE) && \ | ||
134 | ( ((1 << GET_HTLB_AREA(addr)) & (context).high_htlb_areas) || \ | ||
135 | ( ((addr) < 0x100000000L) && \ | ||
136 | ((1 << GET_ESID(addr)) & (context).low_htlb_areas) ) ) ) | ||
137 | |||
138 | #else /* !CONFIG_HUGETLB_PAGE */ | ||
139 | |||
140 | #define in_hugepage_area(mm, addr) 0 | ||
141 | |||
142 | #endif /* !CONFIG_HUGETLB_PAGE */ | ||
143 | |||
144 | #ifdef MODULE | ||
145 | #define __page_aligned __attribute__((__aligned__(PAGE_SIZE))) | ||
146 | #else | ||
147 | #define __page_aligned \ | ||
148 | __attribute__((__aligned__(PAGE_SIZE), \ | ||
149 | __section__(".data.page_aligned"))) | ||
150 | #endif | ||
151 | |||
152 | #define VM_DATA_DEFAULT_FLAGS \ | ||
153 | (test_thread_flag(TIF_32BIT) ? \ | ||
154 | VM_DATA_DEFAULT_FLAGS32 : VM_DATA_DEFAULT_FLAGS64) | ||
155 | |||
156 | /* | ||
157 | * This is the default if a program doesn't have a PT_GNU_STACK | ||
158 | * program header entry. The PPC64 ELF ABI has a non executable stack | ||
159 | * stack by default, so in the absense of a PT_GNU_STACK program header | ||
160 | * we turn execute permission off. | ||
161 | */ | ||
162 | #define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \ | ||
163 | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) | ||
164 | |||
165 | #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \ | ||
166 | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) | ||
167 | |||
168 | #define VM_STACK_DEFAULT_FLAGS \ | ||
169 | (test_thread_flag(TIF_32BIT) ? \ | ||
170 | VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64) | ||
171 | |||
172 | #include <asm-generic/page.h> | ||
173 | |||
174 | #endif /* _ASM_POWERPC_PAGE_64_H */ | ||