mm: introduce get_user_pages_fast
[linux/fpc-iii.git] / include / asm-sh / page.h
blob5dc01d2fcc4cd5a7a2e1f9666b4b07a005703941
1 #ifndef __ASM_SH_PAGE_H
2 #define __ASM_SH_PAGE_H
4 /*
5 * Copyright (C) 1999 Niibe Yutaka
6 */
8 #include <linux/const.h>
10 /* PAGE_SHIFT determines the page size */
11 #if defined(CONFIG_PAGE_SIZE_4KB)
12 # define PAGE_SHIFT 12
13 #elif defined(CONFIG_PAGE_SIZE_8KB)
14 # define PAGE_SHIFT 13
15 #elif defined(CONFIG_PAGE_SIZE_64KB)
16 # define PAGE_SHIFT 16
17 #else
18 # error "Bogus kernel page size?"
19 #endif
21 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
22 #define PAGE_MASK (~(PAGE_SIZE-1))
23 #define PTE_MASK PAGE_MASK
25 #if defined(CONFIG_HUGETLB_PAGE_SIZE_64K)
26 #define HPAGE_SHIFT 16
27 #elif defined(CONFIG_HUGETLB_PAGE_SIZE_256K)
28 #define HPAGE_SHIFT 18
29 #elif defined(CONFIG_HUGETLB_PAGE_SIZE_1MB)
30 #define HPAGE_SHIFT 20
31 #elif defined(CONFIG_HUGETLB_PAGE_SIZE_4MB)
32 #define HPAGE_SHIFT 22
33 #elif defined(CONFIG_HUGETLB_PAGE_SIZE_64MB)
34 #define HPAGE_SHIFT 26
35 #elif defined(CONFIG_HUGETLB_PAGE_SIZE_512MB)
36 #define HPAGE_SHIFT 29
37 #endif
39 #ifdef CONFIG_HUGETLB_PAGE
40 #define HPAGE_SIZE (1UL << HPAGE_SHIFT)
41 #define HPAGE_MASK (~(HPAGE_SIZE-1))
42 #define HUGETLB_PAGE_ORDER (HPAGE_SHIFT-PAGE_SHIFT)
43 #endif
45 #ifndef __ASSEMBLY__
47 extern unsigned long shm_align_mask;
48 extern unsigned long max_low_pfn, min_low_pfn;
49 extern unsigned long memory_start, memory_end;
51 extern void clear_page(void *to);
52 extern void copy_page(void *to, void *from);
54 #if !defined(CONFIG_CACHE_OFF) && defined(CONFIG_MMU) && \
55 (defined(CONFIG_CPU_SH5) || defined(CONFIG_CPU_SH4) || \
56 defined(CONFIG_SH7705_CACHE_32KB))
57 struct page;
58 struct vm_area_struct;
59 extern void clear_user_page(void *to, unsigned long address, struct page *page);
60 extern void copy_user_page(void *to, void *from, unsigned long address,
61 struct page *page);
62 #if defined(CONFIG_CPU_SH4)
63 extern void copy_user_highpage(struct page *to, struct page *from,
64 unsigned long vaddr, struct vm_area_struct *vma);
65 #define __HAVE_ARCH_COPY_USER_HIGHPAGE
66 #endif
67 #else
68 #define clear_user_page(page, vaddr, pg) clear_page(page)
69 #define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
70 #endif
73 * These are used to make use of C type-checking..
75 #ifdef CONFIG_X2TLB
76 typedef struct { unsigned long pte_low, pte_high; } pte_t;
77 typedef struct { unsigned long long pgprot; } pgprot_t;
78 typedef struct { unsigned long long pgd; } pgd_t;
79 #define pte_val(x) \
80 ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
81 #define __pte(x) \
82 ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
83 #elif defined(CONFIG_SUPERH32)
84 typedef struct { unsigned long pte_low; } pte_t;
85 typedef struct { unsigned long pgprot; } pgprot_t;
86 typedef struct { unsigned long pgd; } pgd_t;
87 #define pte_val(x) ((x).pte_low)
88 #define __pte(x) ((pte_t) { (x) } )
89 #else
90 typedef struct { unsigned long long pte_low; } pte_t;
91 typedef struct { unsigned long pgprot; } pgprot_t;
92 typedef struct { unsigned long pgd; } pgd_t;
93 #define pte_val(x) ((x).pte_low)
94 #define __pte(x) ((pte_t) { (x) } )
95 #endif
97 #define pgd_val(x) ((x).pgd)
98 #define pgprot_val(x) ((x).pgprot)
100 #define __pgd(x) ((pgd_t) { (x) } )
101 #define __pgprot(x) ((pgprot_t) { (x) } )
103 typedef struct page *pgtable_t;
105 #endif /* !__ASSEMBLY__ */
108 * __MEMORY_START and SIZE are the physical addresses and size of RAM.
110 #define __MEMORY_START CONFIG_MEMORY_START
111 #define __MEMORY_SIZE CONFIG_MEMORY_SIZE
114 * PAGE_OFFSET is the virtual address of the start of kernel address
115 * space.
117 #define PAGE_OFFSET CONFIG_PAGE_OFFSET
120 * Virtual to physical RAM address translation.
122 * In 29 bit mode, the physical offset of RAM from address 0 is visible in
123 * the kernel virtual address space, and thus we don't have to take
124 * this into account when translating. However in 32 bit mode this offset
125 * is not visible (it is part of the PMB mapping) and so needs to be
126 * added or subtracted as required.
128 #ifdef CONFIG_32BIT
129 #define __pa(x) ((unsigned long)(x)-PAGE_OFFSET+__MEMORY_START)
130 #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET-__MEMORY_START))
131 #else
132 #define __pa(x) ((unsigned long)(x)-PAGE_OFFSET)
133 #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
134 #endif
136 #define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
137 #define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT)
140 * PFN = physical frame number (ie PFN 0 == physical address 0)
141 * PFN_START is the PFN of the first page of RAM. By defining this we
142 * don't have struct page entries for the portion of address space
143 * between physical address 0 and the start of RAM.
145 #define PFN_START (__MEMORY_START >> PAGE_SHIFT)
146 #define ARCH_PFN_OFFSET (PFN_START)
147 #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
148 #ifdef CONFIG_FLATMEM
149 #define pfn_valid(pfn) ((pfn) >= min_low_pfn && (pfn) < max_low_pfn)
150 #endif
151 #define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
153 #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
154 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
156 #include <asm-generic/memory_model.h>
157 #include <asm-generic/page.h>
159 /* vDSO support */
160 #ifdef CONFIG_VSYSCALL
161 #define __HAVE_ARCH_GATE_AREA
162 #endif
165 * Some drivers need to perform DMA into kmalloc'ed buffers
166 * and so we have to increase the kmalloc minalign for this.
168 #define ARCH_KMALLOC_MINALIGN L1_CACHE_BYTES
170 #ifdef CONFIG_SUPERH64
172 * While BYTES_PER_WORD == 4 on the current sh64 ABI, GCC will still
173 * happily generate {ld/st}.q pairs, requiring us to have 8-byte
174 * alignment to avoid traps. The kmalloc alignment is gauranteed by
175 * virtue of L1_CACHE_BYTES, requiring this to only be special cased
176 * for slab caches.
178 #define ARCH_SLAB_MINALIGN 8
179 #endif
181 #endif /* __ASM_SH_PAGE_H */