diff options
Diffstat (limited to 'arch/arm/mm/proc-v7.S')
-rw-r--r-- | arch/arm/mm/proc-v7.S | 190 |
1 files changed, 33 insertions, 157 deletions
diff --git a/arch/arm/mm/proc-v7.S b/arch/arm/mm/proc-v7.S index e70a73731eaa..7e9b5bf910c1 100644 --- a/arch/arm/mm/proc-v7.S +++ b/arch/arm/mm/proc-v7.S | |||
@@ -19,24 +19,11 @@ | |||
19 | 19 | ||
20 | #include "proc-macros.S" | 20 | #include "proc-macros.S" |
21 | 21 | ||
22 | #define TTB_S (1 << 1) | 22 | #ifdef CONFIG_ARM_LPAE |
23 | #define TTB_RGN_NC (0 << 3) | 23 | #include "proc-v7-3level.S" |
24 | #define TTB_RGN_OC_WBWA (1 << 3) | 24 | #else |
25 | #define TTB_RGN_OC_WT (2 << 3) | 25 | #include "proc-v7-2level.S" |
26 | #define TTB_RGN_OC_WB (3 << 3) | 26 | #endif |
27 | #define TTB_NOS (1 << 5) | ||
28 | #define TTB_IRGN_NC ((0 << 0) | (0 << 6)) | ||
29 | #define TTB_IRGN_WBWA ((0 << 0) | (1 << 6)) | ||
30 | #define TTB_IRGN_WT ((1 << 0) | (0 << 6)) | ||
31 | #define TTB_IRGN_WB ((1 << 0) | (1 << 6)) | ||
32 | |||
33 | /* PTWs cacheable, inner WB not shareable, outer WB not shareable */ | ||
34 | #define TTB_FLAGS_UP TTB_IRGN_WB|TTB_RGN_OC_WB | ||
35 | #define PMD_FLAGS_UP PMD_SECT_WB | ||
36 | |||
37 | /* PTWs cacheable, inner WBWA shareable, outer WBWA not shareable */ | ||
38 | #define TTB_FLAGS_SMP TTB_IRGN_WBWA|TTB_S|TTB_NOS|TTB_RGN_OC_WBWA | ||
39 | #define PMD_FLAGS_SMP PMD_SECT_WBWA|PMD_SECT_S | ||
40 | 27 | ||
41 | ENTRY(cpu_v7_proc_init) | 28 | ENTRY(cpu_v7_proc_init) |
42 | mov pc, lr | 29 | mov pc, lr |
@@ -63,6 +50,7 @@ ENDPROC(cpu_v7_proc_fin) | |||
63 | * caches disabled. | 50 | * caches disabled. |
64 | */ | 51 | */ |
65 | .align 5 | 52 | .align 5 |
53 | .pushsection .idmap.text, "ax" | ||
66 | ENTRY(cpu_v7_reset) | 54 | ENTRY(cpu_v7_reset) |
67 | mrc p15, 0, r1, c1, c0, 0 @ ctrl register | 55 | mrc p15, 0, r1, c1, c0, 0 @ ctrl register |
68 | bic r1, r1, #0x1 @ ...............m | 56 | bic r1, r1, #0x1 @ ...............m |
@@ -71,6 +59,7 @@ ENTRY(cpu_v7_reset) | |||
71 | isb | 59 | isb |
72 | mov pc, r0 | 60 | mov pc, r0 |
73 | ENDPROC(cpu_v7_reset) | 61 | ENDPROC(cpu_v7_reset) |
62 | .popsection | ||
74 | 63 | ||
75 | /* | 64 | /* |
76 | * cpu_v7_do_idle() | 65 | * cpu_v7_do_idle() |
@@ -97,127 +86,12 @@ ENTRY(cpu_v7_dcache_clean_area) | |||
97 | mov pc, lr | 86 | mov pc, lr |
98 | ENDPROC(cpu_v7_dcache_clean_area) | 87 | ENDPROC(cpu_v7_dcache_clean_area) |
99 | 88 | ||
100 | /* | ||
101 | * cpu_v7_switch_mm(pgd_phys, tsk) | ||
102 | * | ||
103 | * Set the translation table base pointer to be pgd_phys | ||
104 | * | ||
105 | * - pgd_phys - physical address of new TTB | ||
106 | * | ||
107 | * It is assumed that: | ||
108 | * - we are not using split page tables | ||
109 | */ | ||
110 | ENTRY(cpu_v7_switch_mm) | ||
111 | #ifdef CONFIG_MMU | ||
112 | mov r2, #0 | ||
113 | ldr r1, [r1, #MM_CONTEXT_ID] @ get mm->context.id | ||
114 | ALT_SMP(orr r0, r0, #TTB_FLAGS_SMP) | ||
115 | ALT_UP(orr r0, r0, #TTB_FLAGS_UP) | ||
116 | #ifdef CONFIG_ARM_ERRATA_430973 | ||
117 | mcr p15, 0, r2, c7, c5, 6 @ flush BTAC/BTB | ||
118 | #endif | ||
119 | #ifdef CONFIG_ARM_ERRATA_754322 | ||
120 | dsb | ||
121 | #endif | ||
122 | mcr p15, 0, r2, c13, c0, 1 @ set reserved context ID | ||
123 | isb | ||
124 | 1: mcr p15, 0, r0, c2, c0, 0 @ set TTB 0 | ||
125 | isb | ||
126 | #ifdef CONFIG_ARM_ERRATA_754322 | ||
127 | dsb | ||
128 | #endif | ||
129 | mcr p15, 0, r1, c13, c0, 1 @ set context ID | ||
130 | isb | ||
131 | #endif | ||
132 | mov pc, lr | ||
133 | ENDPROC(cpu_v7_switch_mm) | ||
134 | |||
135 | /* | ||
136 | * cpu_v7_set_pte_ext(ptep, pte) | ||
137 | * | ||
138 | * Set a level 2 translation table entry. | ||
139 | * | ||
140 | * - ptep - pointer to level 2 translation table entry | ||
141 | * (hardware version is stored at +2048 bytes) | ||
142 | * - pte - PTE value to store | ||
143 | * - ext - value for extended PTE bits | ||
144 | */ | ||
145 | ENTRY(cpu_v7_set_pte_ext) | ||
146 | #ifdef CONFIG_MMU | ||
147 | str r1, [r0] @ linux version | ||
148 | |||
149 | bic r3, r1, #0x000003f0 | ||
150 | bic r3, r3, #PTE_TYPE_MASK | ||
151 | orr r3, r3, r2 | ||
152 | orr r3, r3, #PTE_EXT_AP0 | 2 | ||
153 | |||
154 | tst r1, #1 << 4 | ||
155 | orrne r3, r3, #PTE_EXT_TEX(1) | ||
156 | |||
157 | eor r1, r1, #L_PTE_DIRTY | ||
158 | tst r1, #L_PTE_RDONLY | L_PTE_DIRTY | ||
159 | orrne r3, r3, #PTE_EXT_APX | ||
160 | |||
161 | tst r1, #L_PTE_USER | ||
162 | orrne r3, r3, #PTE_EXT_AP1 | ||
163 | #ifdef CONFIG_CPU_USE_DOMAINS | ||
164 | @ allow kernel read/write access to read-only user pages | ||
165 | tstne r3, #PTE_EXT_APX | ||
166 | bicne r3, r3, #PTE_EXT_APX | PTE_EXT_AP0 | ||
167 | #endif | ||
168 | |||
169 | tst r1, #L_PTE_XN | ||
170 | orrne r3, r3, #PTE_EXT_XN | ||
171 | |||
172 | tst r1, #L_PTE_YOUNG | ||
173 | tstne r1, #L_PTE_PRESENT | ||
174 | moveq r3, #0 | ||
175 | |||
176 | ARM( str r3, [r0, #2048]! ) | ||
177 | THUMB( add r0, r0, #2048 ) | ||
178 | THUMB( str r3, [r0] ) | ||
179 | mcr p15, 0, r0, c7, c10, 1 @ flush_pte | ||
180 | #endif | ||
181 | mov pc, lr | ||
182 | ENDPROC(cpu_v7_set_pte_ext) | ||
183 | |||
184 | string cpu_v7_name, "ARMv7 Processor" | 89 | string cpu_v7_name, "ARMv7 Processor" |
185 | .align | 90 | .align |
186 | 91 | ||
187 | /* | ||
188 | * Memory region attributes with SCTLR.TRE=1 | ||
189 | * | ||
190 | * n = TEX[0],C,B | ||
191 | * TR = PRRR[2n+1:2n] - memory type | ||
192 | * IR = NMRR[2n+1:2n] - inner cacheable property | ||
193 | * OR = NMRR[2n+17:2n+16] - outer cacheable property | ||
194 | * | ||
195 | * n TR IR OR | ||
196 | * UNCACHED 000 00 | ||
197 | * BUFFERABLE 001 10 00 00 | ||
198 | * WRITETHROUGH 010 10 10 10 | ||
199 | * WRITEBACK 011 10 11 11 | ||
200 | * reserved 110 | ||
201 | * WRITEALLOC 111 10 01 01 | ||
202 | * DEV_SHARED 100 01 | ||
203 | * DEV_NONSHARED 100 01 | ||
204 | * DEV_WC 001 10 | ||
205 | * DEV_CACHED 011 10 | ||
206 | * | ||
207 | * Other attributes: | ||
208 | * | ||
209 | * DS0 = PRRR[16] = 0 - device shareable property | ||
210 | * DS1 = PRRR[17] = 1 - device shareable property | ||
211 | * NS0 = PRRR[18] = 0 - normal shareable property | ||
212 | * NS1 = PRRR[19] = 1 - normal shareable property | ||
213 | * NOS = PRRR[24+n] = 1 - not outer shareable | ||
214 | */ | ||
215 | .equ PRRR, 0xff0a81a8 | ||
216 | .equ NMRR, 0x40e040e0 | ||
217 | |||
218 | /* Suspend/resume support: derived from arch/arm/mach-s5pv210/sleep.S */ | 92 | /* Suspend/resume support: derived from arch/arm/mach-s5pv210/sleep.S */ |
219 | .globl cpu_v7_suspend_size | 93 | .globl cpu_v7_suspend_size |
220 | .equ cpu_v7_suspend_size, 4 * 7 | 94 | .equ cpu_v7_suspend_size, 4 * 8 |
221 | #ifdef CONFIG_ARM_CPU_SUSPEND | 95 | #ifdef CONFIG_ARM_CPU_SUSPEND |
222 | ENTRY(cpu_v7_do_suspend) | 96 | ENTRY(cpu_v7_do_suspend) |
223 | stmfd sp!, {r4 - r10, lr} | 97 | stmfd sp!, {r4 - r10, lr} |
@@ -226,10 +100,11 @@ ENTRY(cpu_v7_do_suspend) | |||
226 | stmia r0!, {r4 - r5} | 100 | stmia r0!, {r4 - r5} |
227 | mrc p15, 0, r6, c3, c0, 0 @ Domain ID | 101 | mrc p15, 0, r6, c3, c0, 0 @ Domain ID |
228 | mrc p15, 0, r7, c2, c0, 1 @ TTB 1 | 102 | mrc p15, 0, r7, c2, c0, 1 @ TTB 1 |
103 | mrc p15, 0, r11, c2, c0, 2 @ TTB control register | ||
229 | mrc p15, 0, r8, c1, c0, 0 @ Control register | 104 | mrc p15, 0, r8, c1, c0, 0 @ Control register |
230 | mrc p15, 0, r9, c1, c0, 1 @ Auxiliary control register | 105 | mrc p15, 0, r9, c1, c0, 1 @ Auxiliary control register |
231 | mrc p15, 0, r10, c1, c0, 2 @ Co-processor access control | 106 | mrc p15, 0, r10, c1, c0, 2 @ Co-processor access control |
232 | stmia r0, {r6 - r10} | 107 | stmia r0, {r6 - r11} |
233 | ldmfd sp!, {r4 - r10, pc} | 108 | ldmfd sp!, {r4 - r10, pc} |
234 | ENDPROC(cpu_v7_do_suspend) | 109 | ENDPROC(cpu_v7_do_suspend) |
235 | 110 | ||
@@ -241,13 +116,15 @@ ENTRY(cpu_v7_do_resume) | |||
241 | ldmia r0!, {r4 - r5} | 116 | ldmia r0!, {r4 - r5} |
242 | mcr p15, 0, r4, c13, c0, 0 @ FCSE/PID | 117 | mcr p15, 0, r4, c13, c0, 0 @ FCSE/PID |
243 | mcr p15, 0, r5, c13, c0, 3 @ User r/o thread ID | 118 | mcr p15, 0, r5, c13, c0, 3 @ User r/o thread ID |
244 | ldmia r0, {r6 - r10} | 119 | ldmia r0, {r6 - r11} |
245 | mcr p15, 0, r6, c3, c0, 0 @ Domain ID | 120 | mcr p15, 0, r6, c3, c0, 0 @ Domain ID |
121 | #ifndef CONFIG_ARM_LPAE | ||
246 | ALT_SMP(orr r1, r1, #TTB_FLAGS_SMP) | 122 | ALT_SMP(orr r1, r1, #TTB_FLAGS_SMP) |
247 | ALT_UP(orr r1, r1, #TTB_FLAGS_UP) | 123 | ALT_UP(orr r1, r1, #TTB_FLAGS_UP) |
124 | #endif | ||
248 | mcr p15, 0, r1, c2, c0, 0 @ TTB 0 | 125 | mcr p15, 0, r1, c2, c0, 0 @ TTB 0 |
249 | mcr p15, 0, r7, c2, c0, 1 @ TTB 1 | 126 | mcr p15, 0, r7, c2, c0, 1 @ TTB 1 |
250 | mcr p15, 0, ip, c2, c0, 2 @ TTB control register | 127 | mcr p15, 0, r11, c2, c0, 2 @ TTB control register |
251 | mrc p15, 0, r4, c1, c0, 1 @ Read Auxiliary control register | 128 | mrc p15, 0, r4, c1, c0, 1 @ Read Auxiliary control register |
252 | teq r4, r9 @ Is it already set? | 129 | teq r4, r9 @ Is it already set? |
253 | mcrne p15, 0, r9, c1, c0, 1 @ No, so write it | 130 | mcrne p15, 0, r9, c1, c0, 1 @ No, so write it |
@@ -284,6 +161,7 @@ __v7_ca5mp_setup: | |||
284 | __v7_ca9mp_setup: | 161 | __v7_ca9mp_setup: |
285 | mov r10, #(1 << 0) @ TLB ops broadcasting | 162 | mov r10, #(1 << 0) @ TLB ops broadcasting |
286 | b 1f | 163 | b 1f |
164 | __v7_ca7mp_setup: | ||
287 | __v7_ca15mp_setup: | 165 | __v7_ca15mp_setup: |
288 | mov r10, #0 | 166 | mov r10, #0 |
289 | 1: | 167 | 1: |
@@ -379,12 +257,7 @@ __v7_setup: | |||
379 | dsb | 257 | dsb |
380 | #ifdef CONFIG_MMU | 258 | #ifdef CONFIG_MMU |
381 | mcr p15, 0, r10, c8, c7, 0 @ invalidate I + D TLBs | 259 | mcr p15, 0, r10, c8, c7, 0 @ invalidate I + D TLBs |
382 | mcr p15, 0, r10, c2, c0, 2 @ TTB control register | 260 | v7_ttb_setup r10, r4, r8, r5 @ TTBCR, TTBRx setup |
383 | ALT_SMP(orr r4, r4, #TTB_FLAGS_SMP) | ||
384 | ALT_UP(orr r4, r4, #TTB_FLAGS_UP) | ||
385 | ALT_SMP(orr r8, r8, #TTB_FLAGS_SMP) | ||
386 | ALT_UP(orr r8, r8, #TTB_FLAGS_UP) | ||
387 | mcr p15, 0, r8, c2, c0, 1 @ load TTB1 | ||
388 | ldr r5, =PRRR @ PRRR | 261 | ldr r5, =PRRR @ PRRR |
389 | ldr r6, =NMRR @ NMRR | 262 | ldr r6, =NMRR @ NMRR |
390 | mcr p15, 0, r5, c10, c2, 0 @ write PRRR | 263 | mcr p15, 0, r5, c10, c2, 0 @ write PRRR |
@@ -406,16 +279,7 @@ __v7_setup: | |||
406 | mov pc, lr @ return to head.S:__ret | 279 | mov pc, lr @ return to head.S:__ret |
407 | ENDPROC(__v7_setup) | 280 | ENDPROC(__v7_setup) |
408 | 281 | ||
409 | /* AT | 282 | .align 2 |
410 | * TFR EV X F I D LR S | ||
411 | * .EEE ..EE PUI. .T.T 4RVI ZWRS BLDP WCAM | ||
412 | * rxxx rrxx xxx0 0101 xxxx xxxx x111 xxxx < forced | ||
413 | * 1 0 110 0011 1100 .111 1101 < we want | ||
414 | */ | ||
415 | .type v7_crval, #object | ||
416 | v7_crval: | ||
417 | crval clear=0x0120c302, mmuset=0x10c03c7d, ucset=0x00c01c7c | ||
418 | |||
419 | __v7_setup_stack: | 283 | __v7_setup_stack: |
420 | .space 4 * 11 @ 11 registers | 284 | .space 4 * 11 @ 11 registers |
421 | 285 | ||
@@ -437,11 +301,11 @@ __v7_setup_stack: | |||
437 | */ | 301 | */ |
438 | .macro __v7_proc initfunc, mm_mmuflags = 0, io_mmuflags = 0, hwcaps = 0 | 302 | .macro __v7_proc initfunc, mm_mmuflags = 0, io_mmuflags = 0, hwcaps = 0 |
439 | ALT_SMP(.long PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_AP_READ | \ | 303 | ALT_SMP(.long PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_AP_READ | \ |
440 | PMD_FLAGS_SMP | \mm_mmuflags) | 304 | PMD_SECT_AF | PMD_FLAGS_SMP | \mm_mmuflags) |
441 | ALT_UP(.long PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_AP_READ | \ | 305 | ALT_UP(.long PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_AP_READ | \ |
442 | PMD_FLAGS_UP | \mm_mmuflags) | 306 | PMD_SECT_AF | PMD_FLAGS_UP | \mm_mmuflags) |
443 | .long PMD_TYPE_SECT | PMD_SECT_XN | PMD_SECT_AP_WRITE | \ | 307 | .long PMD_TYPE_SECT | PMD_SECT_AP_WRITE | \ |
444 | PMD_SECT_AP_READ | \io_mmuflags | 308 | PMD_SECT_AP_READ | PMD_SECT_AF | \io_mmuflags |
445 | W(b) \initfunc | 309 | W(b) \initfunc |
446 | .long cpu_arch_name | 310 | .long cpu_arch_name |
447 | .long cpu_elf_name | 311 | .long cpu_elf_name |
@@ -454,6 +318,7 @@ __v7_setup_stack: | |||
454 | .long v7_cache_fns | 318 | .long v7_cache_fns |
455 | .endm | 319 | .endm |
456 | 320 | ||
321 | #ifndef CONFIG_ARM_LPAE | ||
457 | /* | 322 | /* |
458 | * ARM Ltd. Cortex A5 processor. | 323 | * ARM Ltd. Cortex A5 processor. |
459 | */ | 324 | */ |
@@ -465,6 +330,16 @@ __v7_ca5mp_proc_info: | |||
465 | .size __v7_ca5mp_proc_info, . - __v7_ca5mp_proc_info | 330 | .size __v7_ca5mp_proc_info, . - __v7_ca5mp_proc_info |
466 | 331 | ||
467 | /* | 332 | /* |
333 | * ARM Ltd. Cortex A7 processor. | ||
334 | */ | ||
335 | .type __v7_ca7mp_proc_info, #object | ||
336 | __v7_ca7mp_proc_info: | ||
337 | .long 0x410fc070 | ||
338 | .long 0xff0ffff0 | ||
339 | __v7_proc __v7_ca7mp_setup, hwcaps = HWCAP_IDIV | ||
340 | .size __v7_ca7mp_proc_info, . - __v7_ca7mp_proc_info | ||
341 | |||
342 | /* | ||
468 | * ARM Ltd. Cortex A9 processor. | 343 | * ARM Ltd. Cortex A9 processor. |
469 | */ | 344 | */ |
470 | .type __v7_ca9mp_proc_info, #object | 345 | .type __v7_ca9mp_proc_info, #object |
@@ -473,6 +348,7 @@ __v7_ca9mp_proc_info: | |||
473 | .long 0xff0ffff0 | 348 | .long 0xff0ffff0 |
474 | __v7_proc __v7_ca9mp_setup | 349 | __v7_proc __v7_ca9mp_setup |
475 | .size __v7_ca9mp_proc_info, . - __v7_ca9mp_proc_info | 350 | .size __v7_ca9mp_proc_info, . - __v7_ca9mp_proc_info |
351 | #endif /* CONFIG_ARM_LPAE */ | ||
476 | 352 | ||
477 | /* | 353 | /* |
478 | * ARM Ltd. Cortex A15 processor. | 354 | * ARM Ltd. Cortex A15 processor. |