2 * linux/arch/arm/lib/findbit.S
4 * Copyright (C) 1995-2000 Russell King
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 #include <linux/linkage.h>
11 #include <asm/assembler.h>
15 * Purpose : Find a 'zero' bit
16 * Prototype: int find_first_zero_bit(void *addr, int maxbit);
18 ENTRY(find_first_zero_bit)
20 .bytelp: ldrb r3, [r0, r2, lsr #3]
21 eors r3, r3, #0xff @ invert bits
22 bne .found @ any now set - found zero bit
23 add r2, r2, #8 @ next bit pointer
24 cmp r2, r1 @ any more?
26 add r0, r1, #1 @ no free bits
30 * Purpose : Find next 'zero' bit
31 * Prototype: int find_next_zero_bit(void *addr, int maxbit, int offset)
33 ENTRY(find_next_zero_bit)
35 beq .bytelp @ If new byte, goto old routine
36 ldrb r3, [r0, r2, lsr#3]
37 eor r3, r3, #0xff @ now looking for a 1 bit
38 movs r3, r3, lsr ip @ shift off unused bits
39 orreq r2, r2, #7 @ if zero, then no bits here
40 addeq r2, r2, #1 @ align bit pointer
41 beq .bytelp @ loop for next bit
44 * One or more bits in the LSB of r3 are assumed to be set.