1
2
3
4
5
6
7
8#include <asm/asm-offsets.h>
9#include <asm/thread_info.h>
10
11#ifdef CONFIG_CPU_V7M
12#include <asm/v7m.h>
13#endif
14
15
16
17
18 .macro vma_vm_mm, rd, rn
19 ldr \rd, [\rn,
20 .endm
21
22
23
24
25 .macro vma_vm_flags, rd, rn
26 ldr \rd, [\rn,
27 .endm
28
29
30
31
32 .macro act_mm, rd
33 bic \rd, sp,
34 bic \rd, \rd,
35 ldr \rd, [\rd,
36 .if (TSK_ACTIVE_MM > IMM12_MASK)
37 add \rd, \rd,
38 .endif
39 ldr \rd, [\rd,
40 .endm
41
42
43
44
45
46 .macro mmid, rd, rn
47#ifdef __ARMEB__
48 ldr \rd, [\rn,
49#else
50 ldr \rd, [\rn,
51#endif
52 .endm
53
54
55
56
57 .macro asid, rd, rn
58 and \rd, \rn,
59 .endm
60
61 .macro crval, clear, mmuset, ucset
62#ifdef CONFIG_MMU
63 .word \clear
64 .word \mmuset
65#else
66 .word \clear
67 .word \ucset
68#endif
69 .endm
70
71
72
73
74
75 .macro dcache_line_size, reg, tmp
76#ifdef CONFIG_CPU_V7M
77 movw \tmp,
78 movt \tmp,
79 ldr \tmp, [\tmp]
80#else
81 mrc p15, 0, \tmp, c0, c0, 1 @ read ctr
82#endif
83 lsr \tmp, \tmp,
84 and \tmp, \tmp,
85 mov \reg,
86 mov \reg, \reg, lsl \tmp @ actual cache line size
87 .endm
88
89
90
91
92
93 .macro icache_line_size, reg, tmp
94#ifdef CONFIG_CPU_V7M
95 movw \tmp,
96 movt \tmp,
97 ldr \tmp, [\tmp]
98#else
99 mrc p15, 0, \tmp, c0, c0, 1 @ read ctr
100#endif
101 and \tmp, \tmp,
102 mov \reg,
103 mov \reg, \reg, lsl \tmp @ actual cache line size
104 .endm
105
106
107
108
109
110#ifdef CONFIG_MMU
111
112
113#endif
114
115 (L_PTE_XN+L_PTE_USER+L_PTE_RDONLY+L_PTE_DIRTY+L_PTE_YOUNG+\
116 L_PTE_PRESENT) > L_PTE_SHARED
117
118#endif
119#endif
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134 .macro armv6_mt_table pfx
135\pfx\()_mt_table:
136 .long 0x00 @ L_PTE_MT_UNCACHED
137 .long PTE_EXT_TEX(1) @ L_PTE_MT_BUFFERABLE
138 .long PTE_CACHEABLE @ L_PTE_MT_WRITETHROUGH
139 .long PTE_CACHEABLE | PTE_BUFFERABLE @ L_PTE_MT_WRITEBACK
140 .long PTE_BUFFERABLE @ L_PTE_MT_DEV_SHARED
141 .long 0x00 @ unused
142 .long 0x00 @ L_PTE_MT_MINICACHE (not present)
143 .long PTE_EXT_TEX(1) | PTE_CACHEABLE | PTE_BUFFERABLE @ L_PTE_MT_WRITEALLOC
144 .long 0x00 @ unused
145 .long PTE_EXT_TEX(1) @ L_PTE_MT_DEV_WC
146 .long 0x00 @ unused
147 .long PTE_CACHEABLE | PTE_BUFFERABLE @ L_PTE_MT_DEV_CACHED
148 .long PTE_EXT_TEX(2) @ L_PTE_MT_DEV_NONSHARED
149 .long 0x00 @ unused
150 .long 0x00 @ unused
151 .long PTE_CACHEABLE | PTE_BUFFERABLE | PTE_EXT_APX @ L_PTE_MT_VECTORS
152 .endm
153
154 .macro armv6_set_pte_ext pfx
155 str r1, [r0],
156
157 bic r3, r1,
158 bic r3, r3,
159 orr r3, r3, r2
160 orr r3, r3,
161
162 adr ip, \pfx\()_mt_table
163 and r2, r1,
164 ldr r2, [ip, r2]
165
166 eor r1, r1,
167 tst r1,
168 orrne r3, r3,
169
170 tst r1,
171 orrne r3, r3,
172 tstne r3,
173
174 @ user read-only -> kernel read-only
175 bicne r3, r3,
176
177 tst r1,
178 orrne r3, r3,
179
180 eor r3, r3, r2
181
182 tst r1,
183 tstne r1,
184 moveq r3,
185 tstne r1,
186 movne r3,
187
188 str r3, [r0]
189 mcr p15, 0, r0, c7, c10, 1 @ flush_pte
190 .endm
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207 .macro armv3_set_pte_ext wc_disable=1
208 str r1, [r0],
209
210 eor r3, r1,
211
212 bic r2, r1,
213 bic r2, r2,
214 orr r2, r2,
215
216 tst r3,
217 orrne r2, r2,
218
219 tst r3,
220 orreq r2, r2,
221
222 tst r3,
223 movne r2,
224
225 .if \wc_disable
226#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
227 tst r2,
228 bicne r2, r2,
229#endif
230 .endif
231 str r2, [r0] @ hardware version
232 .endm
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250 .macro xscale_set_pte_ext_prologue
251 str r1, [r0] @ linux version
252
253 eor r3, r1,
254
255 bic r2, r1,
256 orr r2, r2,
257
258 tst r3,
259 orrne r2, r2,
260
261 tst r3,
262 orreq r2, r2,
263 @ combined with user -> user r/w
264 .endm
265
266 .macro xscale_set_pte_ext_epilogue
267 tst r3,
268 movne r2,
269
270 str r2, [r0,
271 mov ip,
272 mcr p15, 0, r0, c7, c10, 1 @ clean L1 D line
273 mcr p15, 0, ip, c7, c10, 4 @ data write barrier
274 .endm
275
276.macro define_processor_functions name:req, dabort:req, pabort:req, nommu=0, suspend=0
277 .type \name\()_processor_functions,
278 .align 2
279ENTRY(\name\()_processor_functions)
280 .word \dabort
281 .word \pabort
282 .word cpu_\name\()_proc_init
283 .word cpu_\name\()_proc_fin
284 .word cpu_\name\()_reset
285 .word cpu_\name\()_do_idle
286 .word cpu_\name\()_dcache_clean_area
287 .word cpu_\name\()_switch_mm
288
289 .if \nommu
290 .word 0
291 .else
292 .word cpu_\name\()_set_pte_ext
293 .endif
294
295 .if \suspend
296 .word cpu_\name\()_suspend_size
297#ifdef CONFIG_ARM_CPU_SUSPEND
298 .word cpu_\name\()_do_suspend
299 .word cpu_\name\()_do_resume
300#else
301 .word 0
302 .word 0
303#endif
304 .else
305 .word 0
306 .word 0
307 .word 0
308 .endif
309
310 .size \name\()_processor_functions, . - \name\()_processor_functions
311.endm
312
313.macro define_cache_functions name:req
314 .align 2
315 .type \name\()_cache_fns,
316ENTRY(\name\()_cache_fns)
317 .long \name\()_flush_icache_all
318 .long \name\()_flush_kern_cache_all
319 .long \name\()_flush_kern_cache_louis
320 .long \name\()_flush_user_cache_all
321 .long \name\()_flush_user_cache_range
322 .long \name\()_coherent_kern_range
323 .long \name\()_coherent_user_range
324 .long \name\()_flush_kern_dcache_area
325 .long \name\()_dma_map_area
326 .long \name\()_dma_unmap_area
327 .long \name\()_dma_flush_range
328 .size \name\()_cache_fns, . - \name\()_cache_fns
329.endm
330
331.macro define_tlb_functions name:req, flags_up:req, flags_smp
332 .type \name\()_tlb_fns,
333ENTRY(\name\()_tlb_fns)
334 .long \name\()_flush_user_tlb_range
335 .long \name\()_flush_kern_tlb_range
336 .ifnb \flags_smp
337 ALT_SMP(.long \flags_smp )
338 ALT_UP(.long \flags_up )
339 .else
340 .long \flags_up
341 .endif
342 .size \name\()_tlb_fns, . - \name\()_tlb_fns
343.endm
344
345.macro globl_equ x, y
346 .globl \x
347 .equ \x, \y
348.endm
349
350.macro initfn, func, base
351 .long \func - \base
352.endm
353
354
355
356
357
358
359.macro pr_sz, rd, size, tmp
360 mov \tmp, \size, lsr
361 mov \rd,
3621: movs \tmp, \tmp, lsr
363 addne \rd, \rd,
364 bne 1b
365.endm
366
367
368
369
370
371
372.macro pr_val, dest, addr, size, enable
373 pr_sz \dest, \size, \size @ calculate log2(size) - 1
374 orr \dest, \addr, \dest, lsl
375 orr \dest, \dest, \enable
376.endm
377