2 * Based on arch/arm/include/asm/assembler.h
4 * Copyright (C) 1996-2000 Russell King
5 * Copyright (C) 2012 ARM Ltd.
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 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #error "Only include this from assembly code"
23 #ifndef __ASM_ASSEMBLER_H
24 #define __ASM_ASSEMBLER_H
26 #include <asm/ptrace.h>
27 #include <asm/thread_info.h>
30 * Stack pushing/popping (register pairs only). Equivalent to store decrement
31 * before, load increment after.
33 .macro push
, xreg1
, xreg2
34 stp \xreg1
, \xreg2
, [sp
, #-16]!
37 .macro pop
, xreg1
, xreg2
38 ldp \xreg1
, \xreg2
, [sp
], #16
42 * Enable and disable interrupts.
53 * Save/disable and restore interrupts.
55 .macro save_and_disable_irqs
, olddaif
60 .macro restore_irqs
, olddaif
65 * Enable and disable debug exceptions.
75 .macro disable_step_tsk
, flgs
, tmp
76 tbz
\flgs
, #TIF_SINGLESTEP, 9990f
80 isb
// Synchronise with enable_dbg
84 .macro enable_step_tsk
, flgs
, tmp
85 tbz
\flgs
, #TIF_SINGLESTEP, 9990f
94 * Enable both debug exceptions and interrupts. This is likely to be
95 * faster than two daifclr operations, since writes to this register
96 * are self-synchronising.
98 .macro enable_dbg_and_irq
103 * SMP data memory barrier
111 #define USER(l, x...) \
113 .section __ex_table,"a"; \
121 lr
.req x30
// link register
132 * Select code when configured for BE.
134 #ifdef CONFIG_CPU_BIG_ENDIAN
135 #define CPU_BE(code...) code
137 #define CPU_BE(code...)
141 * Select code when configured for LE.
143 #ifdef CONFIG_CPU_BIG_ENDIAN
144 #define CPU_LE(code...)
146 #define CPU_LE(code...) code
150 * Define a macro that constructs a 64-bit value by concatenating two
151 * 32-bit registers. Note that on big endian systems the order of the
152 * registers is swapped.
154 #ifndef CONFIG_CPU_BIG_ENDIAN
155 .macro regs_to_64
, rd
, lbits
, hbits
157 .macro regs_to_64
, rd
, hbits
, lbits
159 orr
\rd
, \lbits
, \hbits
, lsl
#32
163 * Pseudo-ops for PC-relative adr/ldr/str <reg>, <symbol> where
164 * <symbol> is within the range +/- 4 GB of the PC.
167 * @dst: destination register (64 bit wide)
168 * @sym: name of the symbol
169 * @tmp: optional scratch register to be used if <dst> == sp, which
170 * is not allowed in an adrp instruction
172 .macro adr_l
, dst
, sym
, tmp
=
175 add \dst
, \dst
, :lo12
:\sym
178 add \dst
, \tmp
, :lo12
:\sym
183 * @dst: destination register (32 or 64 bit wide)
184 * @sym: name of the symbol
185 * @tmp: optional 64-bit scratch register to be used if <dst> is a
186 * 32-bit wide register, in which case it cannot be used to hold
189 .macro ldr_l
, dst
, sym
, tmp
=
192 ldr \dst
, [\dst
, :lo12
:\sym
]
195 ldr \dst
, [\tmp
, :lo12
:\sym
]
200 * @src: source register (32 or 64 bit wide)
201 * @sym: name of the symbol
202 * @tmp: mandatory 64-bit scratch register to calculate the address
203 * while <src> needs to be preserved.
205 .macro str_l
, src
, sym
, tmp
207 str \src
, [\tmp
, :lo12
:\sym
]
210 #endif /* __ASM_ASSEMBLER_H */