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

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [rc203soc/] [sw/] [uClinux/] [include/] [asm-armnommu/] [bitops.h] - Blame information for rev 1765

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1633 jcastillo
#ifndef __ASM_ARM_BITOPS_H
2
#define __ASM_ARM_BITOPS_H
3
 
4
/*
5
 * Copyright 1995, Russell King.
6
 * Various bits and pieces copyrights include:
7
 *  Linus Torvalds (test_bit).
8
 */
9
 
10
/*
11
 * These should be done with inline assembly.
12
 * All bit operations return 0 if the bit
13
 * was cleared before the operation and != 0 if it was not.
14
 *
15
 * bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1).
16
 */
17
 
18
extern int set_bit(int nr, void * addr);
19
extern int clear_bit(int nr, void * addr);
20
extern int change_bit(int nr, void * addr);
21
 
22
/*
23
 * This routine doesn't need to be atomic.
24
 */
25
extern __inline__ int test_bit(int nr, const void * addr)
26
{
27
    return ((unsigned char *) addr)[nr >> 3] & (1U << (nr & 7));
28
}
29
 
30
/*
31
 * Find-bit routines..
32
 */
33
extern int find_first_zero_bit(void * addr, unsigned size);
34
extern int find_next_zero_bit (void * addr, int size, int offset);
35
 
36
/*
37
 * ffz = Find First Zero in word. Undefined if no zero exists.
38
 */
39
extern __inline__ unsigned long ffz(unsigned long word)
40
{
41
        int k;
42
 
43
        word = ~word;
44
        k = 31;
45
        if (word & 0x0000ffff) { k -= 16; word <<= 16; }
46
        if (word & 0x00ff0000) { k -= 8;  word <<= 8;  }
47
        if (word & 0x0f000000) { k -= 4;  word <<= 4;  }
48
        if (word & 0x30000000) { k -= 2;  word <<= 2;  }
49
        if (word & 0x40000000) { k -= 1; }
50
        return k;
51
}
52
 
53
extern __inline__ int __ext2_set_bit(int nr,void * addr) { return set_bit(nr, addr); }
54
extern __inline__ int __ext2_clear_bit(int nr, void * addr) { return clear_bit(nr, addr); }
55
extern __inline__ int __ext2_test_bit(int nr, const void * addr) { return test_bit(nr, addr); }
56
extern __inline__ unsigned long __ext2_find_next_zero_bit(void *addr, unsigned long size, unsigned long offset)
57
{
58
        return find_next_zero_bit(addr, size, offset);
59
}
60
 
61
extern __inline__ unsigned long __ext2_find_first_zero_bit(void *addr, unsigned long size)
62
{
63
        return find_first_zero_bit(addr, size);
64
}
65
 
66
 
67
#endif /* _ARM_BITOPS_H */

powered by: WebSVN 2.1.0

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