Russell King | 3c4ee4e | 2005-08-10 14:41:45 +0100 | [diff] [blame] | 1 | #include <linux/config.h> |
| 2 | |
Russell King | 4a5f79e | 2005-11-03 15:48:21 +0000 | [diff] [blame^] | 3 | #if __LINUX_ARM_ARCH__ >= 6 && defined(CONFIG_CPU_32v6K) |
Russell King | 54ea06f | 2005-07-16 15:21:51 +0100 | [diff] [blame] | 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 |
| 9 | 1: ldrexb r2, [r1] |
| 10 | \instr r2, r2, r3 |
| 11 | strexb r0, r2, [r1] |
Russell King | e7ec029 | 2005-07-28 20:36:26 +0100 | [diff] [blame] | 12 | cmp r0, #0 |
Russell King | 54ea06f | 2005-07-16 15:21:51 +0100 | [diff] [blame] | 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 |
| 22 | 1: ldrexb r2, [r1] |
| 23 | ands r0, r2, r3 @ save old value of bit |
Russell King | 614d73e | 2005-07-27 23:00:05 +0100 | [diff] [blame] | 24 | \instr r2, r2, r3 @ toggle bit |
| 25 | strexb ip, r2, [r1] |
| 26 | cmp ip, #0 |
Russell King | 54ea06f | 2005-07-16 15:21:51 +0100 | [diff] [blame] | 27 | bne 1b |
| 28 | cmp r0, #0 |
| 29 | movne r0, #1 |
| 30 | 2: mov pc, lr |
| 31 | .endm |
| 32 | #else |
Russell King | 7a55fd0 | 2005-04-18 22:50:01 +0100 | [diff] [blame] | 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 |
Russell King | 54ea06f | 2005-07-16 15:21:51 +0100 | [diff] [blame] | 66 | #endif |