[ARM SMP] Add configuration option for ARMv6K processors
[deliverable/linux.git] / arch / arm / lib / bitops.h
CommitLineData
3c4ee4e2
RK
1#include <linux/config.h>
2
4a5f79e7 3#if __LINUX_ARM_ARCH__ >= 6 && defined(CONFIG_CPU_32v6K)
54ea06f6
RK
4 .macro bitop, instr
5 mov r2, #1
6 and r3, r0, #7 @ Get bit offset
7 add r1, r1, r0, lsr #3 @ Get byte offset
8 mov r3, r2, lsl r3
91: ldrexb r2, [r1]
10 \instr r2, r2, r3
11 strexb r0, r2, [r1]
e7ec0293 12 cmp r0, #0
54ea06f6
RK
13 bne 1b
14 mov pc, lr
15 .endm
16
17 .macro testop, instr, store
18 and r3, r0, #7 @ Get bit offset
19 mov r2, #1
20 add r1, r1, r0, lsr #3 @ Get byte offset
21 mov r3, r2, lsl r3 @ create mask
221: ldrexb r2, [r1]
23 ands r0, r2, r3 @ save old value of bit
614d73ed
RK
24 \instr r2, r2, r3 @ toggle bit
25 strexb ip, r2, [r1]
26 cmp ip, #0
54ea06f6
RK
27 bne 1b
28 cmp r0, #0
29 movne r0, #1
302: mov pc, lr
31 .endm
32#else
7a55fd0b
RK
33 .macro bitop, instr
34 and r2, r0, #7
35 mov r3, #1
36 mov r3, r3, lsl r2
37 save_and_disable_irqs ip, r2
38 ldrb r2, [r1, r0, lsr #3]
39 \instr r2, r2, r3
40 strb r2, [r1, r0, lsr #3]
41 restore_irqs ip
42 mov pc, lr
43 .endm
44
45/**
46 * testop - implement a test_and_xxx_bit operation.
47 * @instr: operational instruction
48 * @store: store instruction
49 *
50 * Note: we can trivially conditionalise the store instruction
51 * to avoid dirting the data cache.
52 */
53 .macro testop, instr, store
54 add r1, r1, r0, lsr #3
55 and r3, r0, #7
56 mov r0, #1
57 save_and_disable_irqs ip, r2
58 ldrb r2, [r1]
59 tst r2, r0, lsl r3
60 \instr r2, r2, r0, lsl r3
61 \store r2, [r1]
62 restore_irqs ip
63 moveq r0, #0
64 mov pc, lr
65 .endm
54ea06f6 66#endif
This page took 0.08005 seconds and 5 git commands to generate.