blob: 4fbeb5b8e6c246dcb8c3b647bbe36f8558f53f14 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/arch/arm/mm/proc-arm6,7.S
3 *
4 * Copyright (C) 1997-2000 Russell King
Hyok S. Choid090ddd2006-06-28 14:10:01 +01005 * hacked for non-paged-MM by Hyok S. Choi, 2003.
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 *
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.
10 *
11 * These are the low level assembler for performing cache and TLB
12 * functions on the ARM610 & ARM710.
13 */
14#include <linux/linkage.h>
15#include <linux/init.h>
16#include <asm/assembler.h>
Sam Ravnborge6ae7442005-09-09 21:08:59 +020017#include <asm/asm-offsets.h>
Russell King5ec94072008-09-07 19:15:31 +010018#include <asm/hwcap.h>
Russell King74945c82006-03-16 14:44:36 +000019#include <asm/pgtable-hwdef.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020#include <asm/pgtable.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include <asm/ptrace.h>
22
Russell Kingda091652008-09-06 17:19:08 +010023#include "proc-macros.S"
24
Linus Torvalds1da177e2005-04-16 15:20:36 -070025ENTRY(cpu_arm6_dcache_clean_area)
26ENTRY(cpu_arm7_dcache_clean_area)
27 mov pc, lr
28
29/*
30 * Function: arm6_7_data_abort ()
31 *
Russell Kingda740472011-06-26 16:01:26 +010032 * Params : r2 = pt_regs
33 * : r4 = aborted context pc
Russell King3e287be2011-06-26 14:35:07 +010034 * : r5 = aborted context psr
Linus Torvalds1da177e2005-04-16 15:20:36 -070035 *
36 * Purpose : obtain information about current aborted instruction
37 *
Russell King40f0b902011-06-27 12:27:47 +010038 * Returns : r4-r5, r10-r11, r13 preserved
Linus Torvalds1da177e2005-04-16 15:20:36 -070039 */
40
41ENTRY(cpu_arm7_data_abort)
42 mrc p15, 0, r1, c5, c0, 0 @ get FSR
43 mrc p15, 0, r0, c6, c0, 0 @ get FAR
Russell King3e287be2011-06-26 14:35:07 +010044 ldr r8, [r4] @ read arm instruction
Timothy Baldwinca6ca912005-09-04 10:13:48 +010045 tst r8, #1 << 20 @ L = 0 -> write?
46 orreq r1, r1, #1 << 11 @ yes.
Linus Torvalds1da177e2005-04-16 15:20:36 -070047 and r7, r8, #15 << 24
48 add pc, pc, r7, lsr #22 @ Now branch to the relevant processing routine
49 nop
50
51/* 0 */ b .data_unknown
Russell Kingda740472011-06-26 16:01:26 +010052/* 1 */ b do_DataAbort @ swp
Linus Torvalds1da177e2005-04-16 15:20:36 -070053/* 2 */ b .data_unknown
54/* 3 */ b .data_unknown
55/* 4 */ b .data_arm_lateldrpostconst @ ldr rd, [rn], #m
56/* 5 */ b .data_arm_lateldrpreconst @ ldr rd, [rn, #m]
57/* 6 */ b .data_arm_lateldrpostreg @ ldr rd, [rn], rm
58/* 7 */ b .data_arm_lateldrprereg @ ldr rd, [rn, rm]
59/* 8 */ b .data_arm_ldmstm @ ldm*a rn, <rlist>
60/* 9 */ b .data_arm_ldmstm @ ldm*b rn, <rlist>
61/* a */ b .data_unknown
62/* b */ b .data_unknown
Russell Kingda740472011-06-26 16:01:26 +010063/* c */ b do_DataAbort @ ldc rd, [rn], #m @ Same as ldr rd, [rn], #m
64/* d */ b do_DataAbort @ ldc rd, [rn, #m]
Linus Torvalds1da177e2005-04-16 15:20:36 -070065/* e */ b .data_unknown
66/* f */
67.data_unknown: @ Part of jumptable
Russell King3e287be2011-06-26 14:35:07 +010068 mov r0, r4
Linus Torvalds1da177e2005-04-16 15:20:36 -070069 mov r1, r8
Russell Kingda740472011-06-26 16:01:26 +010070 b baddataabort
Linus Torvalds1da177e2005-04-16 15:20:36 -070071
72ENTRY(cpu_arm6_data_abort)
73 mrc p15, 0, r1, c5, c0, 0 @ get FSR
74 mrc p15, 0, r0, c6, c0, 0 @ get FAR
Russell King3e287be2011-06-26 14:35:07 +010075 ldr r8, [r4] @ read arm instruction
Timothy Baldwinca6ca912005-09-04 10:13:48 +010076 tst r8, #1 << 20 @ L = 0 -> write?
77 orreq r1, r1, #1 << 11 @ yes.
Linus Torvalds1da177e2005-04-16 15:20:36 -070078 and r7, r8, #14 << 24
79 teq r7, #8 << 24 @ was it ldm/stm
Russell Kingda740472011-06-26 16:01:26 +010080 bne do_DataAbort
Linus Torvalds1da177e2005-04-16 15:20:36 -070081
82.data_arm_ldmstm:
83 tst r8, #1 << 21 @ check writeback bit
Russell Kingda740472011-06-26 16:01:26 +010084 beq do_DataAbort @ no writeback -> no fixup
Linus Torvalds1da177e2005-04-16 15:20:36 -070085 mov r7, #0x11
86 orr r7, r7, #0x1100
87 and r6, r8, r7
Russell King0d147db2011-06-26 14:42:02 +010088 and r9, r8, r7, lsl #1
89 add r6, r6, r9, lsr #1
90 and r9, r8, r7, lsl #2
91 add r6, r6, r9, lsr #2
92 and r9, r8, r7, lsl #3
93 add r6, r6, r9, lsr #3
Linus Torvalds1da177e2005-04-16 15:20:36 -070094 add r6, r6, r6, lsr #8
95 add r6, r6, r6, lsr #4
96 and r6, r6, #15 @ r6 = no. of registers to transfer.
Russell King40f0b902011-06-27 12:27:47 +010097 and r9, r8, #15 << 16 @ Extract 'n' from instruction
98 ldr r7, [r2, r9, lsr #14] @ Get register 'Rn'
Linus Torvalds1da177e2005-04-16 15:20:36 -070099 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
Russell King40f0b902011-06-27 12:27:47 +0100102 str r7, [r2, r9, lsr #14] @ Put register 'Rn'
Russell Kingda740472011-06-26 16:01:26 +0100103 b do_DataAbort
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104
105.data_arm_apply_r6_and_rn:
Russell King40f0b902011-06-27 12:27:47 +0100106 and r9, r8, #15 << 16 @ Extract 'n' from instruction
107 ldr r7, [r2, r9, lsr #14] @ Get register 'Rn'
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108 tst r8, #1 << 23 @ Check U bit
109 subne r7, r7, r6 @ Undo incrmenet
110 addeq r7, r7, r6 @ Undo decrement
Russell King40f0b902011-06-27 12:27:47 +0100111 str r7, [r2, r9, lsr #14] @ Put register 'Rn'
Russell Kingda740472011-06-26 16:01:26 +0100112 b do_DataAbort
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113
114.data_arm_lateldrpreconst:
115 tst r8, #1 << 21 @ check writeback bit
Russell Kingda740472011-06-26 16:01:26 +0100116 beq do_DataAbort @ no writeback -> no fixup
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117.data_arm_lateldrpostconst:
Russell King108f6af2011-06-27 12:23:11 +0100118 movs r6, r8, lsl #20 @ Get offset
Russell Kingda740472011-06-26 16:01:26 +0100119 beq do_DataAbort @ zero -> no fixup
Russell King40f0b902011-06-27 12:27:47 +0100120 and r9, r8, #15 << 16 @ Extract 'n' from instruction
121 ldr r7, [r2, r9, lsr #14] @ Get register 'Rn'
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122 tst r8, #1 << 23 @ Check U bit
Russell King108f6af2011-06-27 12:23:11 +0100123 subne r7, r7, r6, lsr #20 @ Undo increment
124 addeq r7, r7, r6, lsr #20 @ Undo decrement
Russell King40f0b902011-06-27 12:27:47 +0100125 str r7, [r2, r9, lsr #14] @ Put register 'Rn'
Russell Kingda740472011-06-26 16:01:26 +0100126 b do_DataAbort
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127
128.data_arm_lateldrprereg:
129 tst r8, #1 << 21 @ check writeback bit
Russell Kingda740472011-06-26 16:01:26 +0100130 beq do_DataAbort @ no writeback -> no fixup
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131.data_arm_lateldrpostreg:
132 and r7, r8, #15 @ Extract 'm' from instruction
Russell Kinge22c12f2011-06-27 09:52:54 +0100133 ldr r6, [r2, r7, lsl #2] @ Get register 'Rm'
Russell King40f0b902011-06-27 12:27:47 +0100134 mov r9, r8, lsr #7 @ get shift count
135 ands r9, r9, #31
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136 and r7, r8, #0x70 @ get shift type
137 orreq r7, r7, #8 @ shift count = 0
138 add pc, pc, r7
139 nop
140
Russell King40f0b902011-06-27 12:27:47 +0100141 mov r6, r6, lsl r9 @ 0: LSL #!0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142 b .data_arm_apply_r6_and_rn
143 b .data_arm_apply_r6_and_rn @ 1: LSL #0
144 nop
145 b .data_unknown @ 2: MUL?
146 nop
147 b .data_unknown @ 3: MUL?
148 nop
Russell King40f0b902011-06-27 12:27:47 +0100149 mov r6, r6, lsr r9 @ 4: LSR #!0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150 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?
154 nop
155 b .data_unknown @ 7: MUL?
156 nop
Russell King40f0b902011-06-27 12:27:47 +0100157 mov r6, r6, asr r9 @ 8: ASR #!0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158 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?
162 nop
163 b .data_unknown @ B: MUL?
164 nop
Russell King40f0b902011-06-27 12:27:47 +0100165 mov r6, r6, ror r9 @ C: ROR #!0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166 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?
170 nop
171 b .data_unknown @ F: MUL?
172
173/*
174 * Function: arm6_7_proc_init (void)
175 * : arm6_7_proc_fin (void)
176 *
177 * Notes : This processor does not require these
178 */
179ENTRY(cpu_arm6_proc_init)
180ENTRY(cpu_arm7_proc_init)
181 mov pc, lr
182
183ENTRY(cpu_arm6_proc_fin)
184ENTRY(cpu_arm7_proc_fin)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185 mov r0, #0x31 @ ....S..DP...M
186 mcr p15, 0, r0, c1, c0, 0 @ disable caches
187 mov pc, lr
188
189ENTRY(cpu_arm6_do_idle)
190ENTRY(cpu_arm7_do_idle)
191 mov pc, lr
192
193/*
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
197 * the new.
198 */
199ENTRY(cpu_arm6_switch_mm)
200ENTRY(cpu_arm7_switch_mm)
Hyok S. Choid090ddd2006-06-28 14:10:01 +0100201#ifdef CONFIG_MMU
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202 mov r1, #0
203 mcr p15, 0, r1, c7, c0, 0 @ flush cache
204 mcr p15, 0, r0, c2, c0, 0 @ update page table ptr
205 mcr p15, 0, r1, c5, c0, 0 @ flush TLBs
Hyok S. Choid090ddd2006-06-28 14:10:01 +0100206#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207 mov pc, lr
208
209/*
Russell Kingad1ae2f2006-12-13 14:34:43 +0000210 * Function: arm6_7_set_pte_ext(pte_t *ptep, pte_t pte, unsigned int ext)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211 * Params : r0 = Address to set
212 * : r1 = value to set
213 * Purpose : Set a PTE and flush it out of any WB cache
214 */
Russell Kingda091652008-09-06 17:19:08 +0100215 .align 5
Russell Kingad1ae2f2006-12-13 14:34:43 +0000216ENTRY(cpu_arm6_set_pte_ext)
217ENTRY(cpu_arm7_set_pte_ext)
Hyok S. Choid090ddd2006-06-28 14:10:01 +0100218#ifdef CONFIG_MMU
Russell Kingda091652008-09-06 17:19:08 +0100219 armv3_set_pte_ext wc_disable=0
Hyok S. Choid090ddd2006-06-28 14:10:01 +0100220#endif /* CONFIG_MMU */
Russell Kingda091652008-09-06 17:19:08 +0100221 mov pc, lr
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222
223/*
224 * Function: _arm6_7_reset
225 * Params : r0 = address to jump to
226 * Notes : This sets up everything for a reset
227 */
Will Deacon1a4baaf2011-11-15 13:25:04 +0000228 .pushsection .idmap.text, "ax"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229ENTRY(cpu_arm6_reset)
230ENTRY(cpu_arm7_reset)
231 mov r1, #0
232 mcr p15, 0, r1, c7, c0, 0 @ flush cache
Hyok S. Choid090ddd2006-06-28 14:10:01 +0100233#ifdef CONFIG_MMU
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234 mcr p15, 0, r1, c5, c0, 0 @ flush TLB
Hyok S. Choid090ddd2006-06-28 14:10:01 +0100235#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236 mov r1, #0x30
237 mcr p15, 0, r1, c1, c0, 0 @ turn off MMU etc
238 mov pc, r0
Will Deacon1a4baaf2011-11-15 13:25:04 +0000239ENDPROC(cpu_arm6_reset)
240ENDPROC(cpu_arm7_reset)
241 .popsection
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242
Russell King5085f3f2010-10-01 15:37:05 +0100243 __CPUINIT
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244
245 .type __arm6_setup, #function
246__arm6_setup: mov r0, #0
247 mcr p15, 0, r0, c7, c0 @ flush caches on v3
Hyok S. Choid090ddd2006-06-28 14:10:01 +0100248#ifdef CONFIG_MMU
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249 mcr p15, 0, r0, c5, c0 @ flush TLBs on v3
250 mov r0, #0x3d @ . ..RS BLDP WCAM
251 orr r0, r0, #0x100 @ . ..01 0011 1101
Hyok S. Choid090ddd2006-06-28 14:10:01 +0100252#else
253 mov r0, #0x3c @ . ..RS BLDP WCA.
254#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255 mov pc, lr
256 .size __arm6_setup, . - __arm6_setup
257
258 .type __arm7_setup, #function
259__arm7_setup: mov r0, #0
260 mcr p15, 0, r0, c7, c0 @ flush caches on v3
Hyok S. Choid090ddd2006-06-28 14:10:01 +0100261#ifdef CONFIG_MMU
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262 mcr p15, 0, r0, c5, c0 @ flush TLBs on v3
263 mcr p15, 0, r0, c3, c0 @ load domain access register
264 mov r0, #0x7d @ . ..RS BLDP WCAM
265 orr r0, r0, #0x100 @ . ..01 0111 1101
Hyok S. Choid090ddd2006-06-28 14:10:01 +0100266#else
267 mov r0, #0x7c @ . ..RS BLDP WCA.
268#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269 mov pc, lr
270 .size __arm7_setup, . - __arm7_setup
271
272 __INITDATA
273
Dave Martinc3be06e2011-06-23 17:18:31 +0100274 @ define struct processor (see <asm/proc-fns.h> and proc-macros.S)
275 define_processor_functions arm6, dabort=cpu_arm6_data_abort, pabort=legacy_pabort
276 define_processor_functions arm7, dabort=cpu_arm7_data_abort, pabort=legacy_pabort
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277
278 .section ".rodata"
279
Dave Martinc3be06e2011-06-23 17:18:31 +0100280 string cpu_arch_name, "armv3"
281 string cpu_elf_name, "v3"
282 string cpu_arm6_name, "ARM6"
283 string cpu_arm610_name, "ARM610"
284 string cpu_arm7_name, "ARM7"
285 string cpu_arm710_name, "ARM710"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286
287 .align
288
Ben Dooks02b7dd12005-09-20 16:35:03 +0100289 .section ".proc.info.init", #alloc, #execinstr
Linus Torvalds1da177e2005-04-16 15:20:36 -0700290
Dave Martinc3be06e2011-06-23 17:18:31 +0100291.macro arm67_proc_info name:req, cpu_val:req, cpu_mask:req, cpu_name:req, \
292 cpu_mm_mmu_flags:req, cpu_flush:req, cpu_proc_funcs:req
293 .type __\name\()_proc_info, #object
294__\name\()_proc_info:
295 .long \cpu_val
296 .long \cpu_mask
297 .long \cpu_mm_mmu_flags
Russell King8799ee92006-06-29 18:24:21 +0100298 .long PMD_TYPE_SECT | \
299 PMD_BIT4 | \
300 PMD_SECT_AP_WRITE | \
301 PMD_SECT_AP_READ
Dave Martinc3be06e2011-06-23 17:18:31 +0100302 b \cpu_flush
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303 .long cpu_arch_name
304 .long cpu_elf_name
305 .long HWCAP_SWP | HWCAP_26BIT
Dave Martinc3be06e2011-06-23 17:18:31 +0100306 .long \cpu_name
307 .long \cpu_proc_funcs
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308 .long v3_tlb_fns
309 .long v3_user_fns
310 .long v3_cache_fns
Dave Martinc3be06e2011-06-23 17:18:31 +0100311 .size __\name\()_proc_info, . - __\name\()_proc_info
312.endm
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313
Dave Martinc3be06e2011-06-23 17:18:31 +0100314 arm67_proc_info arm6, 0x41560600, 0xfffffff0, cpu_arm6_name, \
315 0x00000c1e, __arm6_setup, arm6_processor_functions
316 arm67_proc_info arm610, 0x41560610, 0xfffffff0, cpu_arm610_name, \
317 0x00000c1e, __arm6_setup, arm6_processor_functions
318 arm67_proc_info arm7, 0x41007000, 0xffffff00, cpu_arm7_name, \
319 0x00000c1e, __arm7_setup, arm7_processor_functions
320 arm67_proc_info arm710, 0x41007100, 0xfff8ff00, cpu_arm710_name, \
321 PMD_TYPE_SECT | \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322 PMD_SECT_BUFFERABLE | \
323 PMD_SECT_CACHEABLE | \
324 PMD_BIT4 | \
325 PMD_SECT_AP_WRITE | \
Dave Martinc3be06e2011-06-23 17:18:31 +0100326 PMD_SECT_AP_READ, \
327 __arm7_setup, arm7_processor_functions