[ALSA] ice1724 - Add support of M-Audio Revolution 5.1
[linux-2.6/x86.git] / include / asm-powerpc / page_64.h
blob6642c012500177fc5e6f90a6ddf84e0cfa2e5ec5
1 #ifndef _ASM_POWERPC_PAGE_64_H
2 #define _ASM_POWERPC_PAGE_64_H
4 /*
5 * Copyright (C) 2001 PPC64 Team, IBM Corp
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.
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.
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))
23 * PAGE_FACTOR is the number of bits factor between PAGE_SHIFT and
24 * HW_PAGE_SHIFT, that is 4K pages.
26 #define PAGE_FACTOR (PAGE_SHIFT - HW_PAGE_SHIFT)
28 #define REGION_SIZE 4UL
29 #define REGION_SHIFT 60UL
30 #define REGION_MASK (((1UL<<REGION_SIZE)-1UL)<<REGION_SHIFT)
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)
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)
44 #ifndef __ASSEMBLY__
45 #include <asm/cache.h>
47 typedef unsigned long pte_basic_t;
49 static __inline__ void clear_page(void *addr)
51 unsigned long lines, line_size;
53 line_size = ppc64_caches.dline_size;
54 lines = ppc64_caches.dlines_per_page;
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");
66 extern void copy_4K_page(void *to, void *from);
68 #ifdef CONFIG_PPC_64K_PAGES
69 static inline void copy_page(void *to, void *from)
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;
78 #else /* CONFIG_PPC_64K_PAGES */
79 static inline void copy_page(void *to, void *from)
81 copy_4K_page(to, from);
83 #endif /* CONFIG_PPC_64K_PAGES */
85 /* Log 2 of page table size */
86 extern u64 ppc64_pft_size;
88 /* Large pages size */
89 #ifdef CONFIG_HUGETLB_PAGE
90 extern unsigned int HPAGE_SHIFT;
91 #else
92 #define HPAGE_SHIFT PAGE_SHIFT
93 #endif
94 #define HPAGE_SIZE ((1UL) << HPAGE_SHIFT)
95 #define HPAGE_MASK (~(HPAGE_SIZE - 1))
96 #define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)
98 #endif /* __ASSEMBLY__ */
100 #ifdef CONFIG_HUGETLB_PAGE
102 #define HTLB_AREA_SHIFT 40
103 #define HTLB_AREA_SIZE (1UL << HTLB_AREA_SHIFT)
104 #define GET_HTLB_AREA(x) ((x) >> HTLB_AREA_SHIFT)
106 #define LOW_ESID_MASK(addr, len) \
107 (((1U << (GET_ESID(min((addr)+(len)-1, 0x100000000UL))+1)) \
108 - (1U << GET_ESID(min((addr), 0x100000000UL)))) & 0xffff)
109 #define HTLB_AREA_MASK(addr, len) (((1U << (GET_HTLB_AREA(addr+len-1)+1)) \
110 - (1U << GET_HTLB_AREA(addr))) & 0xffff)
112 #define ARCH_HAS_HUGEPAGE_ONLY_RANGE
113 #define ARCH_HAS_PREPARE_HUGEPAGE_RANGE
114 #define ARCH_HAS_SETCLEAR_HUGE_PTE
116 #define touches_hugepage_low_range(mm, addr, len) \
117 (((addr) < 0x100000000UL) \
118 && (LOW_ESID_MASK((addr), (len)) & (mm)->context.low_htlb_areas))
119 #define touches_hugepage_high_range(mm, addr, len) \
120 ((((addr) + (len)) > 0x100000000UL) \
121 && (HTLB_AREA_MASK((addr), (len)) & (mm)->context.high_htlb_areas))
123 #define __within_hugepage_low_range(addr, len, segmask) \
124 ( (((addr)+(len)) <= 0x100000000UL) \
125 && ((LOW_ESID_MASK((addr), (len)) | (segmask)) == (segmask)))
126 #define within_hugepage_low_range(addr, len) \
127 __within_hugepage_low_range((addr), (len), \
128 current->mm->context.low_htlb_areas)
129 #define __within_hugepage_high_range(addr, len, zonemask) \
130 ( ((addr) >= 0x100000000UL) \
131 && ((HTLB_AREA_MASK((addr), (len)) | (zonemask)) == (zonemask)))
132 #define within_hugepage_high_range(addr, len) \
133 __within_hugepage_high_range((addr), (len), \
134 current->mm->context.high_htlb_areas)
136 #define is_hugepage_only_range(mm, addr, len) \
137 (touches_hugepage_high_range((mm), (addr), (len)) || \
138 touches_hugepage_low_range((mm), (addr), (len)))
139 #define HAVE_ARCH_HUGETLB_UNMAPPED_AREA
141 #define in_hugepage_area(context, addr) \
142 (cpu_has_feature(CPU_FTR_16M_PAGE) && \
143 ( ( (addr) >= 0x100000000UL) \
144 ? ((1 << GET_HTLB_AREA(addr)) & (context).high_htlb_areas) \
145 : ((1 << GET_ESID(addr)) & (context).low_htlb_areas) ) )
147 #else /* !CONFIG_HUGETLB_PAGE */
149 #define in_hugepage_area(mm, addr) 0
151 #endif /* !CONFIG_HUGETLB_PAGE */
153 #ifdef MODULE
154 #define __page_aligned __attribute__((__aligned__(PAGE_SIZE)))
155 #else
156 #define __page_aligned \
157 __attribute__((__aligned__(PAGE_SIZE), \
158 __section__(".data.page_aligned")))
159 #endif
161 #define VM_DATA_DEFAULT_FLAGS \
162 (test_thread_flag(TIF_32BIT) ? \
163 VM_DATA_DEFAULT_FLAGS32 : VM_DATA_DEFAULT_FLAGS64)
166 * This is the default if a program doesn't have a PT_GNU_STACK
167 * program header entry. The PPC64 ELF ABI has a non executable stack
168 * stack by default, so in the absense of a PT_GNU_STACK program header
169 * we turn execute permission off.
171 #define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
172 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
174 #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
175 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
177 #define VM_STACK_DEFAULT_FLAGS \
178 (test_thread_flag(TIF_32BIT) ? \
179 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
181 #include <asm-generic/page.h>
183 #endif /* _ASM_POWERPC_PAGE_64_H */