diff options
author | Ralf Baechle <ralf@linux-mips.org> | 1997-01-07 02:33:00 +0000 |
---|---|---|
committer | <ralf@linux-mips.org> | 1997-01-07 02:33:00 +0000 |
commit | beb116954b9b7f3bb56412b2494b562f02b864b1 (patch) | |
tree | 120e997879884e1b9d93b265221b939d2ef1ade1 /arch/ppc/kernel/support.c | |
parent | 908d4681a1dc3792ecafbe64265783a86c4cccb6 (diff) |
Import of Linux/MIPS 2.1.14
Diffstat (limited to 'arch/ppc/kernel/support.c')
-rw-r--r-- | arch/ppc/kernel/support.c | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/arch/ppc/kernel/support.c b/arch/ppc/kernel/support.c new file mode 100644 index 000000000..cd2b58b8a --- /dev/null +++ b/arch/ppc/kernel/support.c @@ -0,0 +1,84 @@ +/* + * Miscellaneous support routines + */ + +#include <asm/bitops.h> + +/*extern __inline__*/ int find_first_zero_bit(void *add, int len) +{ + int mask, nr, i; + BITFIELD *addr = add; + nr = 0; + while (len) + { + if (~*addr != 0) + { /* Contains at least one zero */ + for (i = 0; i < 32; i++, nr++) + { + mask = BIT(nr); + if ((mask & *addr) == 0) + { + return (nr); + } + } + } + len -= 32; + addr++; + nr += 32; + } + return (0); /* Shouldn't happen */ +} + +/*extern __inline__*/ int find_next_zero_bit(void *add, int last_bit, int nr) +{ + int mask, i; + BITFIELD *addr = add; +#if 0 +printk("Find next (%x, %x)", addr, nr); +#endif + addr += nr >> 5; +#if 0 +printk(" - Pat: %x(%08X)\n", addr, *addr); +#endif + if ((nr & 0x1F) != 0) + { + if (*addr != 0xFFFFFFFF) + { /* At least one more bit available in this longword */ + for (i = (nr&0x1F); i < 32; i++, nr++) + { + mask = BIT(nr); + if ((mask & *addr) == 0) + { +#if 0 +printk("(1)Bit: %x(%d), Pat: %x(%08x)\n", nr, nr&0x1F, addr, *addr); +#endif + return (nr); + } + } + } + addr++; + nr = (nr + 0x1F) & ~0x1F; + } + while (nr < last_bit) + { + if (*addr != 0xFFFFFFFF) + { /* Contains at least one zero */ + for (i = 0; i < 32; i++, nr++) + { + mask = BIT(nr); + if ((mask & *addr) == 0) + { +#if 0 +printk("(2)Bit: %x(%d), Pat: %x(%08x)\n", nr, nr&0x1F, addr, *addr); +#endif + return (nr); + } + } + } + addr++; + nr += 32; + } + return (nr); /* Shouldn't happen */ +} + + |