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 * Enable and disable debug exceptions.
63 .macro disable_step_tsk
, flgs
, tmp
64 tbz
\flgs
, #TIF_SINGLESTEP, 9990f
68 isb
// Synchronise with enable_dbg
72 .macro enable_step_tsk
, flgs
, tmp
73 tbz
\flgs
, #TIF_SINGLESTEP, 9990f
82 * Enable both debug exceptions and interrupts. This is likely to be
83 * faster than two daifclr operations, since writes to this register
84 * are self-synchronising.
86 .macro enable_dbg_and_irq
91 * SMP data memory barrier
97 #define USER(l, x...) \
99 .section __ex_table,"a"; \
107 lr
.req x30
// link register
118 * Select code when configured for BE.
120 #ifdef CONFIG_CPU_BIG_ENDIAN
121 #define CPU_BE(code...) code
123 #define CPU_BE(code...)
127 * Select code when configured for LE.
129 #ifdef CONFIG_CPU_BIG_ENDIAN
130 #define CPU_LE(code...)
132 #define CPU_LE(code...) code
136 * Define a macro that constructs a 64-bit value by concatenating two
137 * 32-bit registers. Note that on big endian systems the order of the
138 * registers is swapped.
140 #ifndef CONFIG_CPU_BIG_ENDIAN
141 .macro regs_to_64
, rd
, lbits
, hbits
143 .macro regs_to_64
, rd
, hbits
, lbits
145 orr
\rd
, \lbits
, \hbits
, lsl
#32
149 * Pseudo-ops for PC-relative adr/ldr/str <reg>, <symbol> where
150 * <symbol> is within the range +/- 4 GB of the PC.
153 * @dst: destination register (64 bit wide)
154 * @sym: name of the symbol
155 * @tmp: optional scratch register to be used if <dst> == sp, which
156 * is not allowed in an adrp instruction
158 .macro adr_l
, dst
, sym
, tmp
=
161 add \dst
, \dst
, :lo12
:\sym
164 add \dst
, \tmp
, :lo12
:\sym
169 * @dst: destination register (32 or 64 bit wide)
170 * @sym: name of the symbol
171 * @tmp: optional 64-bit scratch register to be used if <dst> is a
172 * 32-bit wide register, in which case it cannot be used to hold
175 .macro ldr_l
, dst
, sym
, tmp
=
178 ldr \dst
, [\dst
, :lo12
:\sym
]
181 ldr \dst
, [\tmp
, :lo12
:\sym
]
186 * @src: source register (32 or 64 bit wide)
187 * @sym: name of the symbol
188 * @tmp: mandatory 64-bit scratch register to calculate the address
189 * while <src> needs to be preserved.
191 .macro str_l
, src
, sym
, tmp
193 str \src
, [\tmp
, :lo12
:\sym
]
197 * Annotate a function as position independent, i.e., safe to be called before
198 * the kernel virtual mapping is activated.
200 #define ENDPIPROC(x) \
202 .type __pi_##x, %function; \
204 .size __pi_##x, . - x; \
207 #endif /* __ASM_ASSEMBLER_H */