2 * arch/arm/include/asm/assembler.h
4 * Copyright (C) 1996-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 * This file contains arm architecture specific defines
11 * for the different processors.
13 * Do not include any C declarations in this file - it is included by
17 #error "Only include this from assembly code"
20 #include <asm/ptrace.h>
23 * Endian independent macros for shifting bytes within registers.
28 #define get_byte_0 lsl #0
29 #define get_byte_1 lsr #8
30 #define get_byte_2 lsr #16
31 #define get_byte_3 lsr #24
32 #define put_byte_0 lsl #0
33 #define put_byte_1 lsl #8
34 #define put_byte_2 lsl #16
35 #define put_byte_3 lsl #24
39 #define get_byte_0 lsr #24
40 #define get_byte_1 lsr #16
41 #define get_byte_2 lsr #8
42 #define get_byte_3 lsl #0
43 #define put_byte_0 lsl #24
44 #define put_byte_1 lsl #16
45 #define put_byte_2 lsl #8
46 #define put_byte_3 lsl #0
50 * Data preload for architectures that support it
52 #if __LINUX_ARM_ARCH__ >= 5
53 #define PLD(code...) code
59 * This can be used to enable code to cacheline align the destination
60 * pointer when bulk writing to memory. Experiments on StrongARM and
61 * XScale didn't show this a worthwhile thing to do when the cache is not
62 * set to write-allocate (this would need further testing on XScale when WA
65 * On Feroceon there is much to gain however, regardless of cache mode.
67 #ifdef CONFIG_CPU_FEROCEON
68 #define CALGN(code...) code
70 #define CALGN(code...)
74 * Enable and disable interrupts
76 #if __LINUX_ARM_ARCH__ >= 6
77 .macro disable_irq_notrace
81 .macro enable_irq_notrace
85 .macro disable_irq_notrace
86 msr cpsr_c
, #PSR_I_BIT | SVC_MODE
89 .macro enable_irq_notrace
94 .macro asm_trace_hardirqs_off
95 #if defined(CONFIG_TRACE_IRQFLAGS)
96 stmdb sp
!, {r0
-r3
, ip
, lr
}
98 ldmia sp
!, {r0
-r3
, ip
, lr
}
102 .macro asm_trace_hardirqs_on_cond
, cond
103 #if defined(CONFIG_TRACE_IRQFLAGS)
105 * actually the registers should be pushed and pop'd conditionally, but
106 * after bl the flags are certainly clobbered
108 stmdb sp
!, {r0
-r3
, ip
, lr
}
109 bl\cond trace_hardirqs_on
110 ldmia sp
!, {r0
-r3
, ip
, lr
}
114 .macro asm_trace_hardirqs_on
115 asm_trace_hardirqs_on_cond al
120 asm_trace_hardirqs_off
124 asm_trace_hardirqs_on
128 * Save the current IRQ state and disable IRQs. Note that this macro
129 * assumes FIQs are enabled, and that the processor is in SVC mode.
131 .macro save_and_disable_irqs
, oldcpsr
136 .macro save_and_disable_irqs_notrace
, oldcpsr
142 * Restore interrupt state previously stored in a register. We don't
143 * guarantee that this will preserve the flags.
145 .macro restore_irqs_notrace
, oldcpsr
149 .macro restore_irqs
, oldcpsr
150 tst \oldcpsr
, #PSR_I_BIT
151 asm_trace_hardirqs_on_cond eq
152 restore_irqs_notrace \oldcpsr
157 .section __ex_table,"a"; \
163 * SMP data memory barrier
167 #if __LINUX_ARM_ARCH__ >= 7
169 #elif __LINUX_ARM_ARCH__ == 6
170 mcr p15
, 0, r0
, c7
, c10
, 5 @ dmb
175 #ifdef CONFIG_THUMB2_KERNEL
176 .macro setmode
, mode
, reg
181 .macro setmode
, mode
, reg
187 * STRT/LDRT access macros with ARM and Thumb-2 variants
189 #ifdef CONFIG_THUMB2_KERNEL
191 .macro usraccoff
, instr
, reg
, ptr
, inc
, off
, cond
, abort
194 \instr\cond\
()bt
\reg
, [\ptr
, #\off]
196 \instr\cond\
()t
\reg
, [\ptr
, #\off]
198 .error
"Unsupported inc macro argument"
201 .section __ex_table
,"a"
207 .macro usracc
, instr
, reg
, ptr
, inc
, cond
, rept
, abort
208 @
explicit IT instruction needed because of the label
209 @ introduced by the USER macro
216 .error
"Unsupported rept macro argument"
220 @ Slightly optimised to avoid incrementing the pointer twice
221 usraccoff \instr
, \reg
, \ptr
, \inc
, 0, \cond
, \abort
223 usraccoff \instr
, \reg
, \ptr
, \inc
, \inc
, \cond
, \abort
226 add\cond \ptr
, #\rept * \inc
229 #else /* !CONFIG_THUMB2_KERNEL */
231 .macro usracc
, instr
, reg
, ptr
, inc
, cond
, rept
, abort
235 \instr\cond\
()bt
\reg
, [\ptr
], #\inc
237 \instr\cond\
()t
\reg
, [\ptr
], #\inc
239 .error
"Unsupported inc macro argument"
242 .section __ex_table
,"a"
249 #endif /* CONFIG_THUMB2_KERNEL */
251 .macro strusr
, reg
, ptr
, inc
, cond
=al
, rept
=1, abort
=9001f
252 usracc str
, \reg
, \ptr
, \inc
, \cond
, \rept
, \abort
255 .macro ldrusr
, reg
, ptr
, inc
, cond
=al
, rept
=1, abort
=9001f
256 usracc ldr
, \reg
, \ptr
, \inc
, \cond
, \rept
, \abort