]>
Commit | Line | Data |
---|---|---|
bbe88886 CM |
1 | /* |
2 | * linux/arch/arm/mm/proc-v7.S | |
3 | * | |
4 | * Copyright (C) 2001 Deep Blue Solutions Ltd. | |
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 | * This is the "shell" of the ARMv7 processor support. | |
11 | */ | |
12 | #include <linux/linkage.h> | |
13 | #include <asm/assembler.h> | |
14 | #include <asm/asm-offsets.h> | |
15 | #include <asm/elf.h> | |
16 | #include <asm/pgtable-hwdef.h> | |
17 | #include <asm/pgtable.h> | |
18 | ||
19 | #include "proc-macros.S" | |
20 | ||
21 | #define TTB_C (1 << 0) | |
22 | #define TTB_S (1 << 1) | |
23 | #define TTB_RGN_OC_WT (2 << 3) | |
24 | #define TTB_RGN_OC_WB (3 << 3) | |
25 | ||
26 | ENTRY(cpu_v7_proc_init) | |
27 | mov pc, lr | |
28 | ||
29 | ENTRY(cpu_v7_proc_fin) | |
30 | mov pc, lr | |
31 | ||
32 | /* | |
33 | * cpu_v7_reset(loc) | |
34 | * | |
35 | * Perform a soft reset of the system. Put the CPU into the | |
36 | * same state as it would be if it had been reset, and branch | |
37 | * to what would be the reset vector. | |
38 | * | |
39 | * - loc - location to jump to for soft reset | |
40 | * | |
41 | * It is assumed that: | |
42 | */ | |
43 | .align 5 | |
44 | ENTRY(cpu_v7_reset) | |
45 | mov pc, r0 | |
46 | ||
47 | /* | |
48 | * cpu_v7_do_idle() | |
49 | * | |
50 | * Idle the processor (eg, wait for interrupt). | |
51 | * | |
52 | * IRQs are already disabled. | |
53 | */ | |
54 | ENTRY(cpu_v7_do_idle) | |
55 | .long 0xe320f003 @ ARM V7 WFI instruction | |
56 | mov pc, lr | |
57 | ||
58 | ENTRY(cpu_v7_dcache_clean_area) | |
59 | #ifndef TLB_CAN_READ_FROM_L1_CACHE | |
60 | dcache_line_size r2, r3 | |
61 | 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry | |
62 | add r0, r0, r2 | |
63 | subs r1, r1, r2 | |
64 | bhi 1b | |
65 | dsb | |
66 | #endif | |
67 | mov pc, lr | |
68 | ||
69 | /* | |
70 | * cpu_v7_switch_mm(pgd_phys, tsk) | |
71 | * | |
72 | * Set the translation table base pointer to be pgd_phys | |
73 | * | |
74 | * - pgd_phys - physical address of new TTB | |
75 | * | |
76 | * It is assumed that: | |
77 | * - we are not using split page tables | |
78 | */ | |
79 | ENTRY(cpu_v7_switch_mm) | |
2eb8c82b | 80 | #ifdef CONFIG_MMU |
bbe88886 CM |
81 | mov r2, #0 |
82 | ldr r1, [r1, #MM_CONTEXT_ID] @ get mm->context.id | |
83 | orr r0, r0, #TTB_RGN_OC_WB @ mark PTWs outer cacheable, WB | |
84 | mcr p15, 0, r2, c13, c0, 1 @ set reserved context ID | |
85 | isb | |
86 | 1: mcr p15, 0, r0, c2, c0, 0 @ set TTB 0 | |
87 | isb | |
88 | mcr p15, 0, r1, c13, c0, 1 @ set context ID | |
89 | isb | |
2eb8c82b | 90 | #endif |
bbe88886 CM |
91 | mov pc, lr |
92 | ||
93 | /* | |
94 | * cpu_v7_set_pte_ext(ptep, pte) | |
95 | * | |
96 | * Set a level 2 translation table entry. | |
97 | * | |
98 | * - ptep - pointer to level 2 translation table entry | |
99 | * (hardware version is stored at -1024 bytes) | |
100 | * - pte - PTE value to store | |
101 | * - ext - value for extended PTE bits | |
bbe88886 CM |
102 | */ |
103 | ENTRY(cpu_v7_set_pte_ext) | |
2eb8c82b | 104 | #ifdef CONFIG_MMU |
3f69c0c1 RK |
105 | str r1, [r0], #-2048 @ linux version |
106 | ||
107 | bic r3, r1, #0x000003f0 | |
108 | bic r3, r3, #PTE_TYPE_MASK | |
109 | orr r3, r3, r2 | |
110 | orr r3, r3, #PTE_EXT_AP0 | 2 | |
111 | ||
112 | tst r2, #1 << 4 | |
113 | orrne r3, r3, #PTE_EXT_TEX(1) | |
114 | ||
115 | tst r1, #L_PTE_WRITE | |
116 | tstne r1, #L_PTE_DIRTY | |
117 | orreq r3, r3, #PTE_EXT_APX | |
118 | ||
119 | tst r1, #L_PTE_USER | |
120 | orrne r3, r3, #PTE_EXT_AP1 | |
121 | tstne r3, #PTE_EXT_APX | |
122 | bicne r3, r3, #PTE_EXT_APX | PTE_EXT_AP0 | |
123 | ||
124 | tst r1, #L_PTE_EXEC | |
125 | orreq r3, r3, #PTE_EXT_XN | |
126 | ||
127 | tst r1, #L_PTE_YOUNG | |
128 | tstne r1, #L_PTE_PRESENT | |
129 | moveq r3, #0 | |
130 | ||
131 | str r3, [r0] | |
132 | mcr p15, 0, r0, c7, c10, 1 @ flush_pte | |
2eb8c82b | 133 | #endif |
bbe88886 CM |
134 | mov pc, lr |
135 | ||
136 | cpu_v7_name: | |
137 | .ascii "ARMv7 Processor" | |
138 | .align | |
139 | ||
140 | .section ".text.init", #alloc, #execinstr | |
141 | ||
142 | /* | |
143 | * __v7_setup | |
144 | * | |
145 | * Initialise TLB, Caches, and MMU state ready to switch the MMU | |
146 | * on. Return in r0 the new CP15 C1 control register setting. | |
147 | * | |
148 | * We automatically detect if we have a Harvard cache, and use the | |
149 | * Harvard cache control instructions insead of the unified cache | |
150 | * control instructions. | |
151 | * | |
152 | * This should be able to cover all ARMv7 cores. | |
153 | * | |
154 | * It is assumed that: | |
155 | * - cache type register is implemented | |
156 | */ | |
157 | __v7_setup: | |
158 | adr r12, __v7_setup_stack @ the local stack | |
159 | stmia r12, {r0-r5, r7, r9, r11, lr} | |
160 | bl v7_flush_dcache_all | |
161 | ldmia r12, {r0-r5, r7, r9, r11, lr} | |
162 | mov r10, #0 | |
163 | #ifdef HARVARD_CACHE | |
164 | mcr p15, 0, r10, c7, c5, 0 @ I+BTB cache invalidate | |
165 | #endif | |
166 | dsb | |
2eb8c82b | 167 | #ifdef CONFIG_MMU |
bbe88886 CM |
168 | mcr p15, 0, r10, c8, c7, 0 @ invalidate I + D TLBs |
169 | mcr p15, 0, r10, c2, c0, 2 @ TTB control register | |
170 | orr r4, r4, #TTB_RGN_OC_WB @ mark PTWs outer cacheable, WB | |
171 | mcr p15, 0, r4, c2, c0, 0 @ load TTB0 | |
172 | mcr p15, 0, r4, c2, c0, 1 @ load TTB1 | |
173 | mov r10, #0x1f @ domains 0, 1 = manager | |
174 | mcr p15, 0, r10, c3, c0, 0 @ load domain access register | |
2eb8c82b | 175 | #endif |
3f69c0c1 RK |
176 | ldr r5, =0x40e040e0 |
177 | ldr r6, =0xff0aa1a8 | |
178 | mcr p15, 0, r5, c10, c2, 0 @ write PRRR | |
179 | mcr p15, 0, r6, c10, c2, 1 @ write NMRR | |
2eb8c82b CM |
180 | adr r5, v7_crval |
181 | ldmia r5, {r5, r6} | |
182 | mrc p15, 0, r0, c1, c0, 0 @ read control register | |
183 | bic r0, r0, r5 @ clear bits them | |
184 | orr r0, r0, r6 @ set them | |
bbe88886 CM |
185 | mov pc, lr @ return to head.S:__ret |
186 | ||
187 | /* | |
188 | * V X F I D LR | |
189 | * .... ...E PUI. .T.T 4RVI ZFRS BLDP WCAM | |
190 | * rrrr rrrx xxx0 0101 xxxx xxxx x111 xxxx < forced | |
191 | * 0 110 0011 1.00 .111 1101 < we want | |
192 | */ | |
2eb8c82b CM |
193 | .type v7_crval, #object |
194 | v7_crval: | |
3f69c0c1 | 195 | crval clear=0x0120c302, mmuset=0x10c0387d, ucset=0x00c0187c |
bbe88886 CM |
196 | |
197 | __v7_setup_stack: | |
198 | .space 4 * 11 @ 11 registers | |
199 | ||
200 | .type v7_processor_functions, #object | |
201 | ENTRY(v7_processor_functions) | |
202 | .word v7_early_abort | |
4a1fd556 | 203 | .word pabort_ifar |
bbe88886 CM |
204 | .word cpu_v7_proc_init |
205 | .word cpu_v7_proc_fin | |
206 | .word cpu_v7_reset | |
207 | .word cpu_v7_do_idle | |
208 | .word cpu_v7_dcache_clean_area | |
209 | .word cpu_v7_switch_mm | |
210 | .word cpu_v7_set_pte_ext | |
211 | .size v7_processor_functions, . - v7_processor_functions | |
212 | ||
213 | .type cpu_arch_name, #object | |
214 | cpu_arch_name: | |
215 | .asciz "armv7" | |
216 | .size cpu_arch_name, . - cpu_arch_name | |
217 | ||
218 | .type cpu_elf_name, #object | |
219 | cpu_elf_name: | |
220 | .asciz "v7" | |
221 | .size cpu_elf_name, . - cpu_elf_name | |
222 | .align | |
223 | ||
224 | .section ".proc.info.init", #alloc, #execinstr | |
225 | ||
226 | /* | |
227 | * Match any ARMv7 processor core. | |
228 | */ | |
229 | .type __v7_proc_info, #object | |
230 | __v7_proc_info: | |
231 | .long 0x000f0000 @ Required ID value | |
232 | .long 0x000f0000 @ Mask for ID | |
233 | .long PMD_TYPE_SECT | \ | |
234 | PMD_SECT_BUFFERABLE | \ | |
235 | PMD_SECT_CACHEABLE | \ | |
236 | PMD_SECT_AP_WRITE | \ | |
237 | PMD_SECT_AP_READ | |
238 | .long PMD_TYPE_SECT | \ | |
239 | PMD_SECT_XN | \ | |
240 | PMD_SECT_AP_WRITE | \ | |
241 | PMD_SECT_AP_READ | |
242 | b __v7_setup | |
243 | .long cpu_arch_name | |
244 | .long cpu_elf_name | |
245 | .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP | |
246 | .long cpu_v7_name | |
247 | .long v7_processor_functions | |
2ccdd1e7 | 248 | .long v7wbi_tlb_fns |
bbe88886 CM |
249 | .long v6_user_fns |
250 | .long v7_cache_fns | |
251 | .size __v7_proc_info, . - __v7_proc_info |