Linux Audio

Check our new training course

Loading...
v3.5.6
 
 1#include <asm/unwind.h>
 2
 3#if __LINUX_ARM_ARCH__ >= 6
 4	.macro	bitop, name, instr
 5ENTRY(	\name		)
 6UNWIND(	.fnstart	)
 7	ands	ip, r1, #3
 8	strneb	r1, [ip]		@ assert word-aligned
 9	mov	r2, #1
10	and	r3, r0, #31		@ Get bit offset
11	mov	r0, r0, lsr #5
12	add	r1, r1, r0, lsl #2	@ Get word offset
 
 
 
 
 
13	mov	r3, r2, lsl r3
141:	ldrex	r2, [r1]
15	\instr	r2, r2, r3
16	strex	r0, r2, [r1]
17	cmp	r0, #0
18	bne	1b
19	bx	lr
20UNWIND(	.fnend		)
21ENDPROC(\name		)
22	.endm
23
24	.macro	testop, name, instr, store
25ENTRY(	\name		)
26UNWIND(	.fnstart	)
27	ands	ip, r1, #3
28	strneb	r1, [ip]		@ assert word-aligned
29	mov	r2, #1
30	and	r3, r0, #31		@ Get bit offset
31	mov	r0, r0, lsr #5
32	add	r1, r1, r0, lsl #2	@ Get word offset
33	mov	r3, r2, lsl r3		@ create mask
34	smp_dmb
 
 
 
 
 
351:	ldrex	r2, [r1]
36	ands	r0, r2, r3		@ save old value of bit
37	\instr	r2, r2, r3		@ toggle bit
38	strex	ip, r2, [r1]
39	cmp	ip, #0
40	bne	1b
41	smp_dmb
42	cmp	r0, #0
43	movne	r0, #1
442:	bx	lr
45UNWIND(	.fnend		)
46ENDPROC(\name		)
47	.endm
48#else
49	.macro	bitop, name, instr
50ENTRY(	\name		)
51UNWIND(	.fnstart	)
52	ands	ip, r1, #3
53	strneb	r1, [ip]		@ assert word-aligned
54	and	r2, r0, #31
55	mov	r0, r0, lsr #5
56	mov	r3, #1
57	mov	r3, r3, lsl r2
58	save_and_disable_irqs ip
59	ldr	r2, [r1, r0, lsl #2]
60	\instr	r2, r2, r3
61	str	r2, [r1, r0, lsl #2]
62	restore_irqs ip
63	mov	pc, lr
64UNWIND(	.fnend		)
65ENDPROC(\name		)
66	.endm
67
68/**
69 * testop - implement a test_and_xxx_bit operation.
70 * @instr: operational instruction
71 * @store: store instruction
72 *
73 * Note: we can trivially conditionalise the store instruction
74 * to avoid dirtying the data cache.
75 */
76	.macro	testop, name, instr, store
77ENTRY(	\name		)
78UNWIND(	.fnstart	)
79	ands	ip, r1, #3
80	strneb	r1, [ip]		@ assert word-aligned
81	and	r3, r0, #31
82	mov	r0, r0, lsr #5
83	save_and_disable_irqs ip
84	ldr	r2, [r1, r0, lsl #2]!
85	mov	r0, #1
86	tst	r2, r0, lsl r3
87	\instr	r2, r2, r0, lsl r3
88	\store	r2, [r1]
89	moveq	r0, #0
90	restore_irqs ip
91	mov	pc, lr
92UNWIND(	.fnend		)
93ENDPROC(\name		)
94	.endm
95#endif
v4.6
  1#include <asm/assembler.h>
  2#include <asm/unwind.h>
  3
  4#if __LINUX_ARM_ARCH__ >= 6
  5	.macro	bitop, name, instr
  6ENTRY(	\name		)
  7UNWIND(	.fnstart	)
  8	ands	ip, r1, #3
  9	strneb	r1, [ip]		@ assert word-aligned
 10	mov	r2, #1
 11	and	r3, r0, #31		@ Get bit offset
 12	mov	r0, r0, lsr #5
 13	add	r1, r1, r0, lsl #2	@ Get word offset
 14#if __LINUX_ARM_ARCH__ >= 7 && defined(CONFIG_SMP)
 15	.arch_extension	mp
 16	ALT_SMP(W(pldw)	[r1])
 17	ALT_UP(W(nop))
 18#endif
 19	mov	r3, r2, lsl r3
 201:	ldrex	r2, [r1]
 21	\instr	r2, r2, r3
 22	strex	r0, r2, [r1]
 23	cmp	r0, #0
 24	bne	1b
 25	bx	lr
 26UNWIND(	.fnend		)
 27ENDPROC(\name		)
 28	.endm
 29
 30	.macro	testop, name, instr, store
 31ENTRY(	\name		)
 32UNWIND(	.fnstart	)
 33	ands	ip, r1, #3
 34	strneb	r1, [ip]		@ assert word-aligned
 35	mov	r2, #1
 36	and	r3, r0, #31		@ Get bit offset
 37	mov	r0, r0, lsr #5
 38	add	r1, r1, r0, lsl #2	@ Get word offset
 39	mov	r3, r2, lsl r3		@ create mask
 40	smp_dmb
 41#if __LINUX_ARM_ARCH__ >= 7 && defined(CONFIG_SMP)
 42	.arch_extension	mp
 43	ALT_SMP(W(pldw)	[r1])
 44	ALT_UP(W(nop))
 45#endif
 461:	ldrex	r2, [r1]
 47	ands	r0, r2, r3		@ save old value of bit
 48	\instr	r2, r2, r3		@ toggle bit
 49	strex	ip, r2, [r1]
 50	cmp	ip, #0
 51	bne	1b
 52	smp_dmb
 53	cmp	r0, #0
 54	movne	r0, #1
 552:	bx	lr
 56UNWIND(	.fnend		)
 57ENDPROC(\name		)
 58	.endm
 59#else
 60	.macro	bitop, name, instr
 61ENTRY(	\name		)
 62UNWIND(	.fnstart	)
 63	ands	ip, r1, #3
 64	strneb	r1, [ip]		@ assert word-aligned
 65	and	r2, r0, #31
 66	mov	r0, r0, lsr #5
 67	mov	r3, #1
 68	mov	r3, r3, lsl r2
 69	save_and_disable_irqs ip
 70	ldr	r2, [r1, r0, lsl #2]
 71	\instr	r2, r2, r3
 72	str	r2, [r1, r0, lsl #2]
 73	restore_irqs ip
 74	ret	lr
 75UNWIND(	.fnend		)
 76ENDPROC(\name		)
 77	.endm
 78
 79/**
 80 * testop - implement a test_and_xxx_bit operation.
 81 * @instr: operational instruction
 82 * @store: store instruction
 83 *
 84 * Note: we can trivially conditionalise the store instruction
 85 * to avoid dirtying the data cache.
 86 */
 87	.macro	testop, name, instr, store
 88ENTRY(	\name		)
 89UNWIND(	.fnstart	)
 90	ands	ip, r1, #3
 91	strneb	r1, [ip]		@ assert word-aligned
 92	and	r3, r0, #31
 93	mov	r0, r0, lsr #5
 94	save_and_disable_irqs ip
 95	ldr	r2, [r1, r0, lsl #2]!
 96	mov	r0, #1
 97	tst	r2, r0, lsl r3
 98	\instr	r2, r2, r0, lsl r3
 99	\store	r2, [r1]
100	moveq	r0, #0
101	restore_irqs ip
102	ret	lr
103UNWIND(	.fnend		)
104ENDPROC(\name		)
105	.endm
106#endif