2 * linux/arch/arm/mm/proc-arm6,7.S
4 * Copyright (C) 1997-2000 Russell King
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.
10 * These are the low level assembler for performing cache and TLB
11 * functions on the ARM610 & ARM710.
13 #include <linux/linkage.h>
14 #include <linux/init.h>
15 #include <asm/assembler.h>
16 #include <asm/constants.h>
17 #include <asm/pgtable.h>
18 #include <asm/procinfo.h>
19 #include <asm/ptrace.h>
21 ENTRY(cpu_arm6_dcache_clean_area)
22 ENTRY(cpu_arm7_dcache_clean_area)
26 * Function: arm6_7_data_abort ()
28 * Params : r2 = address of aborted instruction
29 * : sp = pointer to registers
31 * Purpose : obtain information about current aborted instruction
33 * Returns : r0 = address of abort
37 ENTRY(cpu_arm7_data_abort)
38 mrc p15, 0, r1, c5, c0, 0 @ get FSR
39 mrc p15, 0, r0, c6, c0, 0 @ get FAR
40 ldr r8, [r0] @ read arm instruction
41 tst r8, #1 << 20 @ L = 0 -> write?
42 orreq r1, r1, #1 << 11 @ yes.
44 add pc, pc, r7, lsr #22 @ Now branch to the relevant processing routine
47 /* 0 */ b .data_unknown
48 /* 1 */ mov pc, lr @ swp
49 /* 2 */ b .data_unknown
50 /* 3 */ b .data_unknown
51 /* 4 */ b .data_arm_lateldrpostconst @ ldr rd, [rn], #m
52 /* 5 */ b .data_arm_lateldrpreconst @ ldr rd, [rn, #m]
53 /* 6 */ b .data_arm_lateldrpostreg @ ldr rd, [rn], rm
54 /* 7 */ b .data_arm_lateldrprereg @ ldr rd, [rn, rm]
55 /* 8 */ b .data_arm_ldmstm @ ldm*a rn, <rlist>
56 /* 9 */ b .data_arm_ldmstm @ ldm*b rn, <rlist>
57 /* a */ b .data_unknown
58 /* b */ b .data_unknown
59 /* c */ mov pc, lr @ ldc rd, [rn], #m @ Same as ldr rd, [rn], #m
60 /* d */ mov pc, lr @ ldc rd, [rn, #m]
61 /* e */ b .data_unknown
63 .data_unknown: @ Part of jumptable
70 ENTRY(cpu_arm6_data_abort)
71 mrc p15, 0, r1, c5, c0, 0 @ get FSR
72 mrc p15, 0, r0, c6, c0, 0 @ get FAR
73 ldr r8, [r2] @ read arm instruction
74 tst r8, #1 << 20 @ L = 0 -> write?
75 orreq r1, r1, #1 << 11 @ yes.
77 teq r7, #8 << 24 @ was it ldm/stm
81 tst r8, #1 << 21 @ check writeback bit
82 moveq pc, lr @ no writeback -> no fixup
86 and r2, r8, r7, lsl #1
87 add r6, r6, r2, lsr #1
88 and r2, r8, r7, lsl #2
89 add r6, r6, r2, lsr #2
90 and r2, r8, r7, lsl #3
91 add r6, r6, r2, lsr #3
92 add r6, r6, r6, lsr #8
93 add r6, r6, r6, lsr #4
94 and r6, r6, #15 @ r6 = no. of registers to transfer.
95 and r5, r8, #15 << 16 @ Extract 'n' from instruction
96 ldr r7, [sp, r5, lsr #14] @ Get register 'Rn'
97 tst r8, #1 << 23 @ Check U bit
98 subne r7, r7, r6, lsl #2 @ Undo increment
99 addeq r7, r7, r6, lsl #2 @ Undo decrement
100 str r7, [sp, r5, lsr #14] @ Put register 'Rn'
103 .data_arm_apply_r6_and_rn:
104 and r5, r8, #15 << 16 @ Extract 'n' from instruction
105 ldr r7, [sp, r5, lsr #14] @ Get register 'Rn'
106 tst r8, #1 << 23 @ Check U bit
107 subne r7, r7, r6 @ Undo incrmenet
108 addeq r7, r7, r6 @ Undo decrement
109 str r7, [sp, r5, lsr #14] @ Put register 'Rn'
112 .data_arm_lateldrpreconst:
113 tst r8, #1 << 21 @ check writeback bit
114 moveq pc, lr @ no writeback -> no fixup
115 .data_arm_lateldrpostconst:
116 movs r2, r8, lsl #20 @ Get offset
117 moveq pc, lr @ zero -> no fixup
118 and r5, r8, #15 << 16 @ Extract 'n' from instruction
119 ldr r7, [sp, r5, lsr #14] @ Get register 'Rn'
120 tst r8, #1 << 23 @ Check U bit
121 subne r7, r7, r2, lsr #20 @ Undo increment
122 addeq r7, r7, r2, lsr #20 @ Undo decrement
123 str r7, [sp, r5, lsr #14] @ Put register 'Rn'
126 .data_arm_lateldrprereg:
127 tst r8, #1 << 21 @ check writeback bit
128 moveq pc, lr @ no writeback -> no fixup
129 .data_arm_lateldrpostreg:
130 and r7, r8, #15 @ Extract 'm' from instruction
131 ldr r6, [sp, r7, lsl #2] @ Get register 'Rm'
132 mov r5, r8, lsr #7 @ get shift count
134 and r7, r8, #0x70 @ get shift type
135 orreq r7, r7, #8 @ shift count = 0
139 mov r6, r6, lsl r5 @ 0: LSL #!0
140 b .data_arm_apply_r6_and_rn
141 b .data_arm_apply_r6_and_rn @ 1: LSL #0
143 b .data_unknown @ 2: MUL?
145 b .data_unknown @ 3: MUL?
147 mov r6, r6, lsr r5 @ 4: LSR #!0
148 b .data_arm_apply_r6_and_rn
149 mov r6, r6, lsr #32 @ 5: LSR #32
150 b .data_arm_apply_r6_and_rn
151 b .data_unknown @ 6: MUL?
153 b .data_unknown @ 7: MUL?
155 mov r6, r6, asr r5 @ 8: ASR #!0
156 b .data_arm_apply_r6_and_rn
157 mov r6, r6, asr #32 @ 9: ASR #32
158 b .data_arm_apply_r6_and_rn
159 b .data_unknown @ A: MUL?
161 b .data_unknown @ B: MUL?
163 mov r6, r6, ror r5 @ C: ROR #!0
164 b .data_arm_apply_r6_and_rn
165 mov r6, r6, rrx @ D: RRX
166 b .data_arm_apply_r6_and_rn
167 b .data_unknown @ E: MUL?
169 b .data_unknown @ F: MUL?
172 * Function: arm6_7_proc_init (void)
173 * : arm6_7_proc_fin (void)
175 * Notes : This processor does not require these
177 ENTRY(cpu_arm6_proc_init)
178 ENTRY(cpu_arm7_proc_init)
181 ENTRY(cpu_arm6_proc_fin)
182 ENTRY(cpu_arm7_proc_fin)
183 mov r0, #PSR_F_BIT | PSR_I_BIT | SVC_MODE
185 mov r0, #0x31 @ ....S..DP...M
186 mcr p15, 0, r0, c1, c0, 0 @ disable caches
189 ENTRY(cpu_arm6_do_idle)
190 ENTRY(cpu_arm7_do_idle)
194 * Function: arm6_7_switch_mm(unsigned long pgd_phys)
195 * Params : pgd_phys Physical address of page table
196 * Purpose : Perform a task switch, saving the old processes state, and restoring
199 ENTRY(cpu_arm6_switch_mm)
200 ENTRY(cpu_arm7_switch_mm)
202 mcr p15, 0, r1, c7, c0, 0 @ flush cache
203 mcr p15, 0, r0, c2, c0, 0 @ update page table ptr
204 mcr p15, 0, r1, c5, c0, 0 @ flush TLBs
208 * Function: arm6_7_set_pte(pte_t *ptep, pte_t pte)
209 * Params : r0 = Address to set
210 * : r1 = value to set
211 * Purpose : Set a PTE and flush it out of any WB cache
214 ENTRY(cpu_arm6_set_pte)
215 ENTRY(cpu_arm7_set_pte)
216 str r1, [r0], #-2048 @ linux version
218 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
220 bic r2, r1, #PTE_SMALL_AP_MASK
221 bic r2, r2, #PTE_TYPE_MASK
222 orr r2, r2, #PTE_TYPE_SMALL
224 tst r1, #L_PTE_USER @ User?
225 orrne r2, r2, #PTE_SMALL_AP_URO_SRW
227 tst r1, #L_PTE_WRITE | L_PTE_DIRTY @ Write and Dirty?
228 orreq r2, r2, #PTE_SMALL_AP_UNO_SRW
230 tst r1, #L_PTE_PRESENT | L_PTE_YOUNG @ Present and Young
233 str r2, [r0] @ hardware version
237 * Function: _arm6_7_reset
238 * Params : r0 = address to jump to
239 * Notes : This sets up everything for a reset
241 ENTRY(cpu_arm6_reset)
242 ENTRY(cpu_arm7_reset)
244 mcr p15, 0, r1, c7, c0, 0 @ flush cache
245 mcr p15, 0, r1, c5, c0, 0 @ flush TLB
247 mcr p15, 0, r1, c1, c0, 0 @ turn off MMU etc
252 .type __arm6_setup, #function
253 __arm6_setup: mov r0, #0
254 mcr p15, 0, r0, c7, c0 @ flush caches on v3
255 mcr p15, 0, r0, c5, c0 @ flush TLBs on v3
256 mov r0, #0x3d @ . ..RS BLDP WCAM
257 orr r0, r0, #0x100 @ . ..01 0011 1101
259 .size __arm6_setup, . - __arm6_setup
261 .type __arm7_setup, #function
262 __arm7_setup: mov r0, #0
263 mcr p15, 0, r0, c7, c0 @ flush caches on v3
264 mcr p15, 0, r0, c5, c0 @ flush TLBs on v3
265 mcr p15, 0, r0, c3, c0 @ load domain access register
266 mov r0, #0x7d @ . ..RS BLDP WCAM
267 orr r0, r0, #0x100 @ . ..01 0111 1101
269 .size __arm7_setup, . - __arm7_setup
274 * Purpose : Function pointers used to access above functions - all calls
277 .type arm6_processor_functions, #object
278 ENTRY(arm6_processor_functions)
279 .word cpu_arm6_data_abort
280 .word cpu_arm6_proc_init
281 .word cpu_arm6_proc_fin
283 .word cpu_arm6_do_idle
284 .word cpu_arm6_dcache_clean_area
285 .word cpu_arm6_switch_mm
286 .word cpu_arm6_set_pte
287 .size arm6_processor_functions, . - arm6_processor_functions
290 * Purpose : Function pointers used to access above functions - all calls
293 .type arm7_processor_functions, #object
294 ENTRY(arm7_processor_functions)
295 .word cpu_arm7_data_abort
296 .word cpu_arm7_proc_init
297 .word cpu_arm7_proc_fin
299 .word cpu_arm7_do_idle
300 .word cpu_arm7_dcache_clean_area
301 .word cpu_arm7_switch_mm
302 .word cpu_arm7_set_pte
303 .size arm7_processor_functions, . - arm7_processor_functions
307 .type cpu_arch_name, #object
308 cpu_arch_name: .asciz "armv3"
309 .size cpu_arch_name, . - cpu_arch_name
311 .type cpu_elf_name, #object
312 cpu_elf_name: .asciz "v3"
313 .size cpu_elf_name, . - cpu_elf_name
315 .type cpu_arm6_name, #object
316 cpu_arm6_name: .asciz "ARM6"
317 .size cpu_arm6_name, . - cpu_arm6_name
319 .type cpu_arm610_name, #object
322 .size cpu_arm610_name, . - cpu_arm610_name
324 .type cpu_arm7_name, #object
325 cpu_arm7_name: .asciz "ARM7"
326 .size cpu_arm7_name, . - cpu_arm7_name
328 .type cpu_arm710_name, #object
331 .size cpu_arm710_name, . - cpu_arm710_name
335 .section ".proc.info", #alloc, #execinstr
337 .type __arm6_proc_info, #object
345 .long HWCAP_SWP | HWCAP_26BIT
347 .long arm6_processor_functions
351 .size __arm6_proc_info, . - __arm6_proc_info
353 .type __arm610_proc_info, #object
361 .long HWCAP_SWP | HWCAP_26BIT
362 .long cpu_arm610_name
363 .long arm6_processor_functions
367 .size __arm610_proc_info, . - __arm610_proc_info
369 .type __arm7_proc_info, #object
377 .long HWCAP_SWP | HWCAP_26BIT
379 .long arm7_processor_functions
383 .size __arm7_proc_info, . - __arm7_proc_info
385 .type __arm710_proc_info, #object
389 .long PMD_TYPE_SECT | \
390 PMD_SECT_BUFFERABLE | \
391 PMD_SECT_CACHEABLE | \
393 PMD_SECT_AP_WRITE | \
398 .long HWCAP_SWP | HWCAP_26BIT
399 .long cpu_arm710_name
400 .long arm7_processor_functions
404 .size __arm710_proc_info, . - __arm710_proc_info