xref: /openbmc/linux/arch/arm/include/asm/page.h (revision 81d67439)
1 /*
2  *  arch/arm/include/asm/page.h
3  *
4  *  Copyright (C) 1995-2003 Russell King
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  */
10 #ifndef _ASMARM_PAGE_H
11 #define _ASMARM_PAGE_H
12 
13 /* PAGE_SHIFT determines the page size */
14 #define PAGE_SHIFT		12
15 #define PAGE_SIZE		(_AC(1,UL) << PAGE_SHIFT)
16 #define PAGE_MASK		(~(PAGE_SIZE-1))
17 
18 #ifndef __ASSEMBLY__
19 
20 #ifndef CONFIG_MMU
21 
22 #include "page-nommu.h"
23 
24 #else
25 
26 #include <asm/glue.h>
27 
28 /*
29  *	User Space Model
30  *	================
31  *
32  *	This section selects the correct set of functions for dealing with
33  *	page-based copying and clearing for user space for the particular
34  *	processor(s) we're building for.
35  *
36  *	We have the following to choose from:
37  *	  v3		- ARMv3
38  *	  v4wt		- ARMv4 with writethrough cache, without minicache
39  *	  v4wb		- ARMv4 with writeback cache, without minicache
40  *	  v4_mc		- ARMv4 with minicache
41  *	  xscale	- Xscale
42  *	  xsc3		- XScalev3
43  */
44 #undef _USER
45 #undef MULTI_USER
46 
47 #ifdef CONFIG_CPU_COPY_V3
48 # ifdef _USER
49 #  define MULTI_USER 1
50 # else
51 #  define _USER v3
52 # endif
53 #endif
54 
55 #ifdef CONFIG_CPU_COPY_V4WT
56 # ifdef _USER
57 #  define MULTI_USER 1
58 # else
59 #  define _USER v4wt
60 # endif
61 #endif
62 
63 #ifdef CONFIG_CPU_COPY_V4WB
64 # ifdef _USER
65 #  define MULTI_USER 1
66 # else
67 #  define _USER v4wb
68 # endif
69 #endif
70 
71 #ifdef CONFIG_CPU_COPY_FEROCEON
72 # ifdef _USER
73 #  define MULTI_USER 1
74 # else
75 #  define _USER feroceon
76 # endif
77 #endif
78 
79 #ifdef CONFIG_CPU_COPY_FA
80 # ifdef _USER
81 #  define MULTI_USER 1
82 # else
83 #  define _USER fa
84 # endif
85 #endif
86 
87 #ifdef CONFIG_CPU_SA1100
88 # ifdef _USER
89 #  define MULTI_USER 1
90 # else
91 #  define _USER v4_mc
92 # endif
93 #endif
94 
95 #ifdef CONFIG_CPU_XSCALE
96 # ifdef _USER
97 #  define MULTI_USER 1
98 # else
99 #  define _USER xscale_mc
100 # endif
101 #endif
102 
103 #ifdef CONFIG_CPU_XSC3
104 # ifdef _USER
105 #  define MULTI_USER 1
106 # else
107 #  define _USER xsc3_mc
108 # endif
109 #endif
110 
111 #ifdef CONFIG_CPU_COPY_V6
112 # define MULTI_USER 1
113 #endif
114 
115 #if !defined(_USER) && !defined(MULTI_USER)
116 #error Unknown user operations model
117 #endif
118 
119 struct page;
120 struct vm_area_struct;
121 
122 struct cpu_user_fns {
123 	void (*cpu_clear_user_highpage)(struct page *page, unsigned long vaddr);
124 	void (*cpu_copy_user_highpage)(struct page *to, struct page *from,
125 			unsigned long vaddr, struct vm_area_struct *vma);
126 };
127 
128 #ifdef MULTI_USER
129 extern struct cpu_user_fns cpu_user;
130 
131 #define __cpu_clear_user_highpage	cpu_user.cpu_clear_user_highpage
132 #define __cpu_copy_user_highpage	cpu_user.cpu_copy_user_highpage
133 
134 #else
135 
136 #define __cpu_clear_user_highpage	__glue(_USER,_clear_user_highpage)
137 #define __cpu_copy_user_highpage	__glue(_USER,_copy_user_highpage)
138 
139 extern void __cpu_clear_user_highpage(struct page *page, unsigned long vaddr);
140 extern void __cpu_copy_user_highpage(struct page *to, struct page *from,
141 			unsigned long vaddr, struct vm_area_struct *vma);
142 #endif
143 
144 #define clear_user_highpage(page,vaddr)		\
145 	 __cpu_clear_user_highpage(page, vaddr)
146 
147 #define __HAVE_ARCH_COPY_USER_HIGHPAGE
148 #define copy_user_highpage(to,from,vaddr,vma)	\
149 	__cpu_copy_user_highpage(to, from, vaddr, vma)
150 
151 #define clear_page(page)	memset((void *)(page), 0, PAGE_SIZE)
152 extern void copy_page(void *to, const void *from);
153 
154 typedef unsigned long pteval_t;
155 
156 #undef STRICT_MM_TYPECHECKS
157 
158 #ifdef STRICT_MM_TYPECHECKS
159 /*
160  * These are used to make use of C type-checking..
161  */
162 typedef struct { pteval_t pte; } pte_t;
163 typedef struct { unsigned long pmd; } pmd_t;
164 typedef struct { unsigned long pgd[2]; } pgd_t;
165 typedef struct { unsigned long pgprot; } pgprot_t;
166 
167 #define pte_val(x)      ((x).pte)
168 #define pmd_val(x)      ((x).pmd)
169 #define pgd_val(x)	((x).pgd[0])
170 #define pgprot_val(x)   ((x).pgprot)
171 
172 #define __pte(x)        ((pte_t) { (x) } )
173 #define __pmd(x)        ((pmd_t) { (x) } )
174 #define __pgprot(x)     ((pgprot_t) { (x) } )
175 
176 #else
177 /*
178  * .. while these make it easier on the compiler
179  */
180 typedef pteval_t pte_t;
181 typedef unsigned long pmd_t;
182 typedef unsigned long pgd_t[2];
183 typedef unsigned long pgprot_t;
184 
185 #define pte_val(x)      (x)
186 #define pmd_val(x)      (x)
187 #define pgd_val(x)	((x)[0])
188 #define pgprot_val(x)   (x)
189 
190 #define __pte(x)        (x)
191 #define __pmd(x)        (x)
192 #define __pgprot(x)     (x)
193 
194 #endif /* STRICT_MM_TYPECHECKS */
195 
196 #endif /* CONFIG_MMU */
197 
198 typedef struct page *pgtable_t;
199 
200 #ifdef CONFIG_HAVE_ARCH_PFN_VALID
201 extern int pfn_valid(unsigned long);
202 #endif
203 
204 #include <asm/memory.h>
205 
206 #endif /* !__ASSEMBLY__ */
207 
208 #define VM_DATA_DEFAULT_FLAGS \
209 	(((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
210 	 VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
211 
212 #include <asm-generic/getorder.h>
213 
214 #endif
215