blob: 2e787d40d59992c96bb6d546c2d31cc7a485c251 [file] [log] [blame]
Russell King3c4ee4e2005-08-10 14:41:45 +01001
Russell King4a5f79e2005-11-03 15:48:21 +00002#if __LINUX_ARM_ARCH__ >= 6 && defined(CONFIG_CPU_32v6K)
Russell King54ea06f2005-07-16 15:21:51 +01003 .macro bitop, instr
4 mov r2, #1
5 and r3, r0, #7 @ Get bit offset
6 add r1, r1, r0, lsr #3 @ Get byte offset
7 mov r3, r2, lsl r3
81: ldrexb r2, [r1]
9 \instr r2, r2, r3
10 strexb r0, r2, [r1]
Russell Kinge7ec0292005-07-28 20:36:26 +010011 cmp r0, #0
Russell King54ea06f2005-07-16 15:21:51 +010012 bne 1b
13 mov pc, lr
14 .endm
15
16 .macro testop, instr, store
17 and r3, r0, #7 @ Get bit offset
18 mov r2, #1
19 add r1, r1, r0, lsr #3 @ Get byte offset
20 mov r3, r2, lsl r3 @ create mask
211: ldrexb r2, [r1]
22 ands r0, r2, r3 @ save old value of bit
Russell King614d73e2005-07-27 23:00:05 +010023 \instr r2, r2, r3 @ toggle bit
24 strexb ip, r2, [r1]
25 cmp ip, #0
Russell King54ea06f2005-07-16 15:21:51 +010026 bne 1b
27 cmp r0, #0
28 movne r0, #1
292: mov pc, lr
30 .endm
31#else
Russell King7a55fd02005-04-18 22:50:01 +010032 .macro bitop, instr
33 and r2, r0, #7
34 mov r3, #1
35 mov r3, r3, lsl r2
Russell King59d1ff32005-11-09 15:04:22 +000036 save_and_disable_irqs ip
Russell King7a55fd02005-04-18 22:50:01 +010037 ldrb r2, [r1, r0, lsr #3]
38 \instr r2, r2, r3
39 strb r2, [r1, r0, lsr #3]
40 restore_irqs ip
41 mov pc, lr
42 .endm
43
44/**
45 * testop - implement a test_and_xxx_bit operation.
46 * @instr: operational instruction
47 * @store: store instruction
48 *
49 * Note: we can trivially conditionalise the store instruction
Simon Arlott6cbdc8c2007-05-11 20:40:30 +010050 * to avoid dirtying the data cache.
Russell King7a55fd02005-04-18 22:50:01 +010051 */
52 .macro testop, instr, store
53 add r1, r1, r0, lsr #3
54 and r3, r0, #7
55 mov r0, #1
Russell King59d1ff32005-11-09 15:04:22 +000056 save_and_disable_irqs ip
Russell King7a55fd02005-04-18 22:50:01 +010057 ldrb r2, [r1]
58 tst r2, r0, lsl r3
59 \instr r2, r2, r0, lsl r3
60 \store r2, [r1]
61 restore_irqs ip
62 moveq r0, #0
63 mov pc, lr
64 .endm
Russell King54ea06f2005-07-16 15:21:51 +010065#endif