2 * linux/arch/arm/mm/proc-arm6,7.S
4 * Copyright (C) 1997-2000 Russell King
5 * hacked for non-paged-MM by Hyok S. Choi, 2003.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * These are the low level assembler for performing cache and TLB
12 * functions on the ARM610 & ARM710.
14 #include <linux/linkage.h>
15 #include <linux/init.h>
16 #include <asm/assembler.h>
17 #include <asm/asm-offsets.h>
19 #include <asm/pgtable-hwdef.h>
20 #include <asm/pgtable.h>
21 #include <asm/ptrace.h>
23 ENTRY(cpu_arm6_dcache_clean_area)
24 ENTRY(cpu_arm7_dcache_clean_area)
28 * Function: arm6_7_data_abort ()
30 * Params : r2 = address of aborted instruction
31 * : sp = pointer to registers
33 * Purpose : obtain information about current aborted instruction
35 * Returns : r0 = address of abort
39 ENTRY(cpu_arm7_data_abort)
40 mrc p15, 0, r1, c5, c0, 0 @ get FSR
41 mrc p15, 0, r0, c6, c0, 0 @ get FAR
42 ldr r8, [r0] @ read arm instruction
43 tst r8, #1 << 20 @ L = 0 -> write?
44 orreq r1, r1, #1 << 11 @ yes.
46 add pc, pc, r7, lsr #22 @ Now branch to the relevant processing routine
49 /* 0 */ b .data_unknown
50 /* 1 */ mov pc, lr @ swp
51 /* 2 */ b .data_unknown
52 /* 3 */ b .data_unknown
53 /* 4 */ b .data_arm_lateldrpostconst @ ldr rd, [rn], #m
54 /* 5 */ b .data_arm_lateldrpreconst @ ldr rd, [rn, #m]
55 /* 6 */ b .data_arm_lateldrpostreg @ ldr rd, [rn], rm
56 /* 7 */ b .data_arm_lateldrprereg @ ldr rd, [rn, rm]
57 /* 8 */ b .data_arm_ldmstm @ ldm*a rn, <rlist>
58 /* 9 */ b .data_arm_ldmstm @ ldm*b rn, <rlist>
59 /* a */ b .data_unknown
60 /* b */ b .data_unknown
61 /* c */ mov pc, lr @ ldc rd, [rn], #m @ Same as ldr rd, [rn], #m
62 /* d */ mov pc, lr @ ldc rd, [rn, #m]
63 /* e */ b .data_unknown
65 .data_unknown: @ Part of jumptable
72 ENTRY(cpu_arm6_data_abort)
73 mrc p15, 0, r1, c5, c0, 0 @ get FSR
74 mrc p15, 0, r0, c6, c0, 0 @ get FAR
75 ldr r8, [r2] @ read arm instruction
76 tst r8, #1 << 20 @ L = 0 -> write?
77 orreq r1, r1, #1 << 11 @ yes.
79 teq r7, #8 << 24 @ was it ldm/stm
83 tst r8, #1 << 21 @ check writeback bit
84 moveq pc, lr @ no writeback -> no fixup
88 and r2, r8, r7, lsl #1
89 add r6, r6, r2, lsr #1
90 and r2, r8, r7, lsl #2
91 add r6, r6, r2, lsr #2
92 and r2, r8, r7, lsl #3
93 add r6, r6, r2, lsr #3
94 add r6, r6, r6, lsr #8
95 add r6, r6, r6, lsr #4
96 and r6, r6, #15 @ r6 = no. of registers to transfer.
97 and r5, r8, #15 << 16 @ Extract 'n' from instruction
98 ldr r7, [sp, r5, lsr #14] @ Get register 'Rn'
99 tst r8, #1 << 23 @ Check U bit
100 subne r7, r7, r6, lsl #2 @ Undo increment
101 addeq r7, r7, r6, lsl #2 @ Undo decrement
102 str r7, [sp, r5, lsr #14] @ Put register 'Rn'
105 .data_arm_apply_r6_and_rn:
106 and r5, r8, #15 << 16 @ Extract 'n' from instruction
107 ldr r7, [sp, r5, lsr #14] @ Get register 'Rn'
108 tst r8, #1 << 23 @ Check U bit
109 subne r7, r7, r6 @ Undo incrmenet
110 addeq r7, r7, r6 @ Undo decrement
111 str r7, [sp, r5, lsr #14] @ Put register 'Rn'
114 .data_arm_lateldrpreconst:
115 tst r8, #1 << 21 @ check writeback bit
116 moveq pc, lr @ no writeback -> no fixup
117 .data_arm_lateldrpostconst:
118 movs r2, r8, lsl #20 @ Get offset
119 moveq pc, lr @ zero -> no fixup
120 and r5, r8, #15 << 16 @ Extract 'n' from instruction
121 ldr r7, [sp, r5, lsr #14] @ Get register 'Rn'
122 tst r8, #1 << 23 @ Check U bit
123 subne r7, r7, r2, lsr #20 @ Undo increment
124 addeq r7, r7, r2, lsr #20 @ Undo decrement
125 str r7, [sp, r5, lsr #14] @ Put register 'Rn'
128 .data_arm_lateldrprereg:
129 tst r8, #1 << 21 @ check writeback bit
130 moveq pc, lr @ no writeback -> no fixup
131 .data_arm_lateldrpostreg:
132 and r7, r8, #15 @ Extract 'm' from instruction
133 ldr r6, [sp, r7, lsl #2] @ Get register 'Rm'
134 mov r5, r8, lsr #7 @ get shift count
136 and r7, r8, #0x70 @ get shift type
137 orreq r7, r7, #8 @ shift count = 0
141 mov r6, r6, lsl r5 @ 0: LSL #!0
142 b .data_arm_apply_r6_and_rn
143 b .data_arm_apply_r6_and_rn @ 1: LSL #0
145 b .data_unknown @ 2: MUL?
147 b .data_unknown @ 3: MUL?
149 mov r6, r6, lsr r5 @ 4: LSR #!0
150 b .data_arm_apply_r6_and_rn
151 mov r6, r6, lsr #32 @ 5: LSR #32
152 b .data_arm_apply_r6_and_rn
153 b .data_unknown @ 6: MUL?
155 b .data_unknown @ 7: MUL?
157 mov r6, r6, asr r5 @ 8: ASR #!0
158 b .data_arm_apply_r6_and_rn
159 mov r6, r6, asr #32 @ 9: ASR #32
160 b .data_arm_apply_r6_and_rn
161 b .data_unknown @ A: MUL?
163 b .data_unknown @ B: MUL?
165 mov r6, r6, ror r5 @ C: ROR #!0
166 b .data_arm_apply_r6_and_rn
167 mov r6, r6, rrx @ D: RRX
168 b .data_arm_apply_r6_and_rn
169 b .data_unknown @ E: MUL?
171 b .data_unknown @ F: MUL?
174 * Function: arm6_7_proc_init (void)
175 * : arm6_7_proc_fin (void)
177 * Notes : This processor does not require these
179 ENTRY(cpu_arm6_proc_init)
180 ENTRY(cpu_arm7_proc_init)
183 ENTRY(cpu_arm6_proc_fin)
184 ENTRY(cpu_arm7_proc_fin)
185 mov r0, #PSR_F_BIT | PSR_I_BIT | SVC_MODE
187 mov r0, #0x31 @ ....S..DP...M
188 mcr p15, 0, r0, c1, c0, 0 @ disable caches
191 ENTRY(cpu_arm6_do_idle)
192 ENTRY(cpu_arm7_do_idle)
196 * Function: arm6_7_switch_mm(unsigned long pgd_phys)
197 * Params : pgd_phys Physical address of page table
198 * Purpose : Perform a task switch, saving the old processes state, and restoring
201 ENTRY(cpu_arm6_switch_mm)
202 ENTRY(cpu_arm7_switch_mm)
205 mcr p15, 0, r1, c7, c0, 0 @ flush cache
206 mcr p15, 0, r0, c2, c0, 0 @ update page table ptr
207 mcr p15, 0, r1, c5, c0, 0 @ flush TLBs
212 * Function: arm6_7_set_pte_ext(pte_t *ptep, pte_t pte, unsigned int ext)
213 * Params : r0 = Address to set
214 * : r1 = value to set
215 * Purpose : Set a PTE and flush it out of any WB cache
218 ENTRY(cpu_arm6_set_pte_ext)
219 ENTRY(cpu_arm7_set_pte_ext)
221 str r1, [r0], #-2048 @ linux version
223 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
225 bic r2, r1, #PTE_SMALL_AP_MASK
226 bic r2, r2, #PTE_TYPE_MASK
227 orr r2, r2, #PTE_TYPE_SMALL
229 tst r1, #L_PTE_USER @ User?
230 orrne r2, r2, #PTE_SMALL_AP_URO_SRW
232 tst r1, #L_PTE_WRITE | L_PTE_DIRTY @ Write and Dirty?
233 orreq r2, r2, #PTE_SMALL_AP_UNO_SRW
235 tst r1, #L_PTE_PRESENT | L_PTE_YOUNG @ Present and Young
238 str r2, [r0] @ hardware version
239 #endif /* CONFIG_MMU */
243 * Function: _arm6_7_reset
244 * Params : r0 = address to jump to
245 * Notes : This sets up everything for a reset
247 ENTRY(cpu_arm6_reset)
248 ENTRY(cpu_arm7_reset)
250 mcr p15, 0, r1, c7, c0, 0 @ flush cache
252 mcr p15, 0, r1, c5, c0, 0 @ flush TLB
255 mcr p15, 0, r1, c1, c0, 0 @ turn off MMU etc
260 .type __arm6_setup, #function
261 __arm6_setup: mov r0, #0
262 mcr p15, 0, r0, c7, c0 @ flush caches on v3
264 mcr p15, 0, r0, c5, c0 @ flush TLBs on v3
265 mov r0, #0x3d @ . ..RS BLDP WCAM
266 orr r0, r0, #0x100 @ . ..01 0011 1101
268 mov r0, #0x3c @ . ..RS BLDP WCA.
271 .size __arm6_setup, . - __arm6_setup
273 .type __arm7_setup, #function
274 __arm7_setup: mov r0, #0
275 mcr p15, 0, r0, c7, c0 @ flush caches on v3
277 mcr p15, 0, r0, c5, c0 @ flush TLBs on v3
278 mcr p15, 0, r0, c3, c0 @ load domain access register
279 mov r0, #0x7d @ . ..RS BLDP WCAM
280 orr r0, r0, #0x100 @ . ..01 0111 1101
282 mov r0, #0x7c @ . ..RS BLDP WCA.
285 .size __arm7_setup, . - __arm7_setup
290 * Purpose : Function pointers used to access above functions - all calls
293 .type arm6_processor_functions, #object
294 ENTRY(arm6_processor_functions)
295 .word cpu_arm6_data_abort
296 .word cpu_arm6_proc_init
297 .word cpu_arm6_proc_fin
299 .word cpu_arm6_do_idle
300 .word cpu_arm6_dcache_clean_area
301 .word cpu_arm6_switch_mm
302 .word cpu_arm6_set_pte_ext
304 .size arm6_processor_functions, . - arm6_processor_functions
307 * Purpose : Function pointers used to access above functions - all calls
310 .type arm7_processor_functions, #object
311 ENTRY(arm7_processor_functions)
312 .word cpu_arm7_data_abort
313 .word cpu_arm7_proc_init
314 .word cpu_arm7_proc_fin
316 .word cpu_arm7_do_idle
317 .word cpu_arm7_dcache_clean_area
318 .word cpu_arm7_switch_mm
319 .word cpu_arm7_set_pte_ext
321 .size arm7_processor_functions, . - arm7_processor_functions
325 .type cpu_arch_name, #object
326 cpu_arch_name: .asciz "armv3"
327 .size cpu_arch_name, . - cpu_arch_name
329 .type cpu_elf_name, #object
330 cpu_elf_name: .asciz "v3"
331 .size cpu_elf_name, . - cpu_elf_name
333 .type cpu_arm6_name, #object
334 cpu_arm6_name: .asciz "ARM6"
335 .size cpu_arm6_name, . - cpu_arm6_name
337 .type cpu_arm610_name, #object
340 .size cpu_arm610_name, . - cpu_arm610_name
342 .type cpu_arm7_name, #object
343 cpu_arm7_name: .asciz "ARM7"
344 .size cpu_arm7_name, . - cpu_arm7_name
346 .type cpu_arm710_name, #object
349 .size cpu_arm710_name, . - cpu_arm710_name
353 .section ".proc.info.init", #alloc, #execinstr
355 .type __arm6_proc_info, #object
360 .long PMD_TYPE_SECT | \
362 PMD_SECT_AP_WRITE | \
367 .long HWCAP_SWP | HWCAP_26BIT
369 .long arm6_processor_functions
373 .size __arm6_proc_info, . - __arm6_proc_info
375 .type __arm610_proc_info, #object
380 .long PMD_TYPE_SECT | \
382 PMD_SECT_AP_WRITE | \
387 .long HWCAP_SWP | HWCAP_26BIT
388 .long cpu_arm610_name
389 .long arm6_processor_functions
393 .size __arm610_proc_info, . - __arm610_proc_info
395 .type __arm7_proc_info, #object
400 .long PMD_TYPE_SECT | \
402 PMD_SECT_AP_WRITE | \
407 .long HWCAP_SWP | HWCAP_26BIT
409 .long arm7_processor_functions
413 .size __arm7_proc_info, . - __arm7_proc_info
415 .type __arm710_proc_info, #object
419 .long PMD_TYPE_SECT | \
420 PMD_SECT_BUFFERABLE | \
421 PMD_SECT_CACHEABLE | \
423 PMD_SECT_AP_WRITE | \
425 .long PMD_TYPE_SECT | \
427 PMD_SECT_AP_WRITE | \
432 .long HWCAP_SWP | HWCAP_26BIT
433 .long cpu_arm710_name
434 .long arm7_processor_functions
438 .size __arm710_proc_info, . - __arm710_proc_info