OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [arch/] [ppc/] [kernel/] [support.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1624 jcastillo
/*
2
 * Miscellaneous support routines
3
 */
4
 
5
#include <asm/bitops.h>
6
 
7
/*extern __inline__*/ int find_first_zero_bit(void *add, int len)
8
{
9
        int     mask, nr, i;
10
        BITFIELD *addr = add;
11
        nr = 0;
12
        while (len)
13
        {
14
                if (~*addr != 0)
15
                { /* Contains at least one zero */
16
                        for (i = 0;  i < 32;  i++, nr++)
17
                        {
18
                                mask = BIT(nr);
19
                                if ((mask & *addr) == 0)
20
                                {
21
                                        return (nr);
22
                                }
23
                        }
24
                }
25
                len -= 32;
26
                addr++;
27
                nr += 32;
28
        }
29
        return (0);  /* Shouldn't happen */
30
}
31
 
32
/*extern __inline__*/ int find_next_zero_bit(void *add, int last_bit, int nr)
33
{
34
        int     mask, i;
35
        BITFIELD *addr = add;
36
#if 0   
37
printk("Find next (%x, %x)", addr, nr);
38
#endif
39
        addr += nr >> 5;
40
#if 0   
41
printk(" - Pat: %x(%08X)\n", addr, *addr);
42
#endif
43
        if ((nr & 0x1F) != 0)
44
        {
45
                if (*addr != 0xFFFFFFFF)
46
                { /* At least one more bit available in this longword */
47
                        for (i = (nr&0x1F);  i < 32;  i++, nr++)
48
                        {
49
                                mask = BIT(nr);
50
                                if ((mask & *addr) == 0)
51
                                {
52
#if 0                                   
53
printk("(1)Bit: %x(%d), Pat: %x(%08x)\n", nr, nr&0x1F, addr, *addr);
54
#endif
55
                                        return (nr);
56
                                }
57
                        }
58
                }
59
                addr++;
60
                nr = (nr + 0x1F) & ~0x1F;
61
        }
62
        while (nr < last_bit)
63
        {
64
                if (*addr != 0xFFFFFFFF)
65
                { /* Contains at least one zero */
66
                        for (i = 0;  i < 32;  i++, nr++)
67
                        {
68
                                mask = BIT(nr);
69
                                if ((mask & *addr) == 0)
70
                                {
71
#if 0                                   
72
printk("(2)Bit: %x(%d), Pat: %x(%08x)\n", nr, nr&0x1F, addr, *addr);
73
#endif
74
                                        return (nr);
75
                                }
76
                        }
77
                }
78
                addr++;
79
                nr += 32;
80
        }
81
        return (nr);  /* Shouldn't happen */
82
}
83
 
84
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.