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 = 1 -> write?
42 orreq r1, r1, #1 << 8 @ 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 = 1 -> write?
75 orreq r1, r1, #1 << 8 @ 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 mcr p15, 0, r4, c2, c0 @ load page table pointer
257 mov r0, #0x1f @ Domains 0, 1 = client
258 mcr p15, 0, r0, c3, c0 @ load domain access register
259 mov r0, #0x3d @ . ..RS BLDP WCAM
260 orr r0, r0, #0x100 @ . ..01 0011 1101
262 .size __arm6_setup, . - __arm6_setup
264 .type __arm7_setup, #function
265 __arm7_setup: mov r0, #0
266 mcr p15, 0, r0, c7, c0 @ flush caches on v3
267 mcr p15, 0, r0, c5, c0 @ flush TLBs on v3
268 mcr p15, 0, r4, c2, c0 @ load page table pointer
269 mov r0, #0x1f @ Domains 0, 1 = client
270 mcr p15, 0, r0, c3, c0 @ load domain access register
271 mov r0, #0x7d @ . ..RS BLDP WCAM
272 orr r0, r0, #0x100 @ . ..01 0111 1101
274 .size __arm7_setup, . - __arm7_setup
279 * Purpose : Function pointers used to access above functions - all calls
282 .type arm6_processor_functions, #object
283 ENTRY(arm6_processor_functions)
284 .word cpu_arm6_data_abort
285 .word cpu_arm6_proc_init
286 .word cpu_arm6_proc_fin
288 .word cpu_arm6_do_idle
289 .word cpu_arm6_dcache_clean_area
290 .word cpu_arm6_switch_mm
291 .word cpu_arm6_set_pte
292 .size arm6_processor_functions, . - arm6_processor_functions
295 * Purpose : Function pointers used to access above functions - all calls
298 .type arm7_processor_functions, #object
299 ENTRY(arm7_processor_functions)
300 .word cpu_arm7_data_abort
301 .word cpu_arm7_proc_init
302 .word cpu_arm7_proc_fin
304 .word cpu_arm7_do_idle
305 .word cpu_arm7_dcache_clean_area
306 .word cpu_arm7_switch_mm
307 .word cpu_arm7_set_pte
308 .size arm7_processor_functions, . - arm7_processor_functions
312 .type cpu_arch_name, #object
313 cpu_arch_name: .asciz "armv3"
314 .size cpu_arch_name, . - cpu_arch_name
316 .type cpu_elf_name, #object
317 cpu_elf_name: .asciz "v3"
318 .size cpu_elf_name, . - cpu_elf_name
320 .type cpu_arm6_name, #object
321 cpu_arm6_name: .asciz "ARM6"
322 .size cpu_arm6_name, . - cpu_arm6_name
324 .type cpu_arm610_name, #object
327 .size cpu_arm610_name, . - cpu_arm610_name
329 .type cpu_arm7_name, #object
330 cpu_arm7_name: .asciz "ARM7"
331 .size cpu_arm7_name, . - cpu_arm7_name
333 .type cpu_arm710_name, #object
336 .size cpu_arm710_name, . - cpu_arm710_name
340 .section ".proc.info", #alloc, #execinstr
342 .type __arm6_proc_info, #object
350 .long HWCAP_SWP | HWCAP_26BIT
352 .long arm6_processor_functions
356 .size __arm6_proc_info, . - __arm6_proc_info
358 .type __arm610_proc_info, #object
366 .long HWCAP_SWP | HWCAP_26BIT
367 .long cpu_arm610_name
368 .long arm6_processor_functions
372 .size __arm610_proc_info, . - __arm610_proc_info
374 .type __arm7_proc_info, #object
382 .long HWCAP_SWP | HWCAP_26BIT
384 .long arm7_processor_functions
388 .size __arm7_proc_info, . - __arm7_proc_info
390 .type __arm710_proc_info, #object
398 .long HWCAP_SWP | HWCAP_26BIT
399 .long cpu_arm710_name
400 .long arm7_processor_functions
404 .size __arm710_proc_info, . - __arm710_proc_info