• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/linux/linux-2.6.36/arch/avr32/lib/
1/*
2 * Copyright (C) 2006 Atmel Corporation
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8#include <linux/linkage.h>
9
10	.text
11	/*
12	 * unsigned long find_first_zero_bit(const unsigned long *addr,
13	 *				     unsigned long size)
14	 */
15ENTRY(find_first_zero_bit)
16	cp.w	r11, 0
17	reteq	r11
18	mov	r9, r11
191:	ld.w	r8, r12[0]
20	com	r8
21	brne	.L_found
22	sub	r12, -4
23	sub	r9, 32
24	brgt	1b
25	retal	r11
26
27	/*
28	 * unsigned long find_next_zero_bit(const unsigned long *addr,
29	 *				    unsigned long size,
30	 *				    unsigned long offset)
31	 */
32ENTRY(find_next_zero_bit)
33	lsr	r8, r10, 5
34	sub	r9, r11, r10
35	retle	r11
36
37	lsl	r8, 2
38	add	r12, r8
39	andl	r10, 31, COH
40	breq	1f
41
42	/* offset is not word-aligned. Handle the first (32 - r10) bits */
43	ld.w	r8, r12[0]
44	com	r8
45	sub	r12, -4
46	lsr	r8, r8, r10
47	brne	.L_found
48
49	/* r9 = r9 - (32 - r10) = r9 + r10 - 32 */
50	add	r9, r10
51	sub	r9, 32
52	retle	r11
53
54	/* Main loop. offset must be word-aligned */
551:	ld.w	r8, r12[0]
56	com	r8
57	brne	.L_found
58	sub	r12, -4
59	sub	r9, 32
60	brgt	1b
61	retal	r11
62
63	/* Common return path for when a bit is actually found. */
64.L_found:
65	brev	r8
66	clz	r10, r8
67	rsub	r9, r11
68	add	r10, r9
69
70	min	r12, r11, r10
71	retal	r12
72
73	/*
74	 * unsigned long find_first_bit(const unsigned long *addr,
75	 *				unsigned long size)
76	 */
77ENTRY(find_first_bit)
78	cp.w	r11, 0
79	reteq	r11
80	mov	r9, r11
811:	ld.w	r8, r12[0]
82	cp.w	r8, 0
83	brne	.L_found
84	sub	r12, -4
85	sub	r9, 32
86	brgt	1b
87	retal	r11
88
89	/*
90	 * unsigned long find_next_bit(const unsigned long *addr,
91	 *			       unsigned long size,
92	 *			       unsigned long offset)
93	 */
94ENTRY(find_next_bit)
95	lsr	r8, r10, 5
96	sub	r9, r11, r10
97	retle	r11
98
99	lsl	r8, 2
100	add	r12, r8
101	andl	r10, 31, COH
102	breq	1f
103
104	/* offset is not word-aligned. Handle the first (32 - r10) bits */
105	ld.w	r8, r12[0]
106	sub	r12, -4
107	lsr	r8, r8, r10
108	brne	.L_found
109
110	/* r9 = r9 - (32 - r10) = r9 + r10 - 32 */
111	add	r9, r10
112	sub	r9, 32
113	retle	r11
114
115	/* Main loop. offset must be word-aligned */
1161:	ld.w	r8, r12[0]
117	cp.w	r8, 0
118	brne	.L_found
119	sub	r12, -4
120	sub	r9, 32
121	brgt	1b
122	retal	r11
123
124ENTRY(generic_find_next_le_bit)
125	lsr	r8, r10, 5
126	sub	r9, r11, r10
127	retle	r11
128
129	lsl	r8, 2
130	add	r12, r8
131	andl	r10, 31, COH
132	breq	1f
133
134	/* offset is not word-aligned. Handle the first (32 - r10) bits */
135	ldswp.w	r8, r12[0]
136	sub	r12, -4
137	lsr	r8, r8, r10
138	brne	.L_found
139
140	/* r9 = r9 - (32 - r10) = r9 + r10 - 32 */
141	add	r9, r10
142	sub	r9, 32
143	retle	r11
144
145	/* Main loop. offset must be word-aligned */
1461:	ldswp.w	r8, r12[0]
147	cp.w	r8, 0
148	brne	.L_found
149	sub	r12, -4
150	sub	r9, 32
151	brgt	1b
152	retal	r11
153
154ENTRY(generic_find_next_zero_le_bit)
155	lsr	r8, r10, 5
156	sub	r9, r11, r10
157	retle	r11
158
159	lsl	r8, 2
160	add	r12, r8
161	andl	r10, 31, COH
162	breq	1f
163
164	/* offset is not word-aligned. Handle the first (32 - r10) bits */
165	ldswp.w	r8, r12[0]
166	sub	r12, -4
167	com	r8
168	lsr	r8, r8, r10
169	brne	.L_found
170
171	/* r9 = r9 - (32 - r10) = r9 + r10 - 32 */
172	add	r9, r10
173	sub	r9, 32
174	retle	r11
175
176	/* Main loop. offset must be word-aligned */
1771:	ldswp.w	r8, r12[0]
178	com	r8
179	brne	.L_found
180	sub	r12, -4
181	sub	r9, 32
182	brgt	1b
183	retal	r11
184