1 /* SPDX-License-Identifier: GPL-2.0 */
2 #include <asm/assembler.h>
3 #include <asm/unwind.h>
5 #if __LINUX_ARM_ARCH__ >= 6
6 .macro bitop
, name
, instr
10 strbne r1
, [ip
] @
assert word
-aligned
12 and r3
, r0
, #31 @ Get bit offset
14 add r1
, r1
, r0
, lsl
#2 @ Get word offset
15 #if __LINUX_ARM_ARCH__ >= 7 && defined(CONFIG_SMP)
31 .macro testop
, name
, instr
, store
35 strbne r1
, [ip
] @
assert word
-aligned
37 and r3
, r0
, #31 @ Get bit offset
39 add r1
, r1
, r0
, lsl
#2 @ Get word offset
40 mov r3
, r2
, lsl r3 @ create mask
42 #if __LINUX_ARM_ARCH__ >= 7 && defined(CONFIG_SMP)
48 ands r0
, r2
, r3 @ save old value of bit
49 \instr r2
, r2
, r3 @ toggle bit
61 .macro bitop
, name
, instr
65 strbne r1
, [ip
] @
assert word
-aligned
70 save_and_disable_irqs ip
71 ldr r2
, [r1
, r0
, lsl
#2]
73 str r2
, [r1
, r0
, lsl
#2]
81 * testop - implement a test_and_xxx_bit operation.
82 * @instr: operational instruction
83 * @store: store instruction
85 * Note: we can trivially conditionalise the store instruction
86 * to avoid dirtying the data cache.
88 .macro testop
, name
, instr
, store
92 strbne r1
, [ip
] @
assert word
-aligned
95 save_and_disable_irqs ip
96 ldr r2
, [r1
, r0
, lsl
#2]!
99 \instr r2
, r2
, r0
, lsl r3