Subversion Repositories shark

Rev

Rev 141 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
141 trimarchi 1
/*
2
 * Some of this code has been taken from bitops.h
3
 * Copyright 1992, Linus Torvalds.
4
 *
5
 * Others functions has been added by
6
 * Miguel Masmano Tello <mmasmano@disca.upv.es>
7
 * Copyright (C) Feb, 2003 OCERA Consortium
8
 * Release under the terms of the GNU General Public License Version 2
9
 */
10
 
11
#define ADDR (*(volatile long *) addr)
12
 
13
/**
14
 * ffs - find first bit set
15
 * @x: the word to search
16
 *
17
 * This is defined the same way as
18
 * the libc and compiler builtin ffs routines, therefore
19
 * differs in spirit from the above ffz (man ffs).
20
 */
21
 
22
 
23
static __inline__ int DIDMA_ffs(int x)
24
{
25
        int r;
26
 
27
        __asm__("bsfl %1,%0\n\t"
28
                "jnz 1f\n\t"
29
                "movl $-1,%0\n"
30
                "1:" : "=r" (r) : "g" (x));
31
        return r;
32
}
33
 
34
 
35
/**
36
 * fls - find last bit set
37
 * @x: the word to search
38
 *
39
 * This is defined the same way as
40
 * the libc and compiler builtin ffs routines, therefore
41
 * differs in spirit from the above ffz (man ffs).
42
 */
43
static __inline__ int DIDMA_fls(int x)
44
{
45
        int r;
46
 
47
        __asm__("bsrl %1,%0\n\t"
48
                "jnz 1f\n\t"
49
                "movl $-1,%0\n"
50
                "1:" : "=r" (r) : "g" (x));
51
        return r;
52
}
53
 
54
/**
55
 * __set_bit - Set a bit in memory
56
 * @nr: the bit to set
57
 * @addr: the address to start counting from
58
 *
59
 * Unlike set_bit(), this function is non-atomic and may be reordered.
60
 * If it's called on the same region of memory simultaneously, the effect
61
 * may be that only one operation succeeds.
62
 */
63
/*
64
static __inline__ void __set_bit(int nr, volatile void * addr)
65
{
66
        __asm__(
67
                "btsl %1,%0"
68
                :"=m" (ADDR)
69
                :"Ir" (nr));
70
}
71
*/
72
/**
73
 * __clear_bit - Clears a bit in memory
74
 * @nr: Bit to clear
75
 * @addr: Address to start counting from
76
 *
77
 * clear_bit() is non-atomic and may be reordered.  However, it does
78
 * not contain a memory barrier, so if it is used for locking purposes,
79
 * you should call smp_mb__before_clear_bit() and/or smp_mb__after_clear_bit()
80
 * in order to ensure changes are visible on other processors.
81
 */
82
static __inline__ void __clear_bit(int nr, volatile void * addr)
83
{
84
        __asm__ __volatile__(
85
                "btrl %1,%0"
86
                :"=m" (ADDR)
87
                :"Ir" (nr));
88
}
89
 
90
 
91
 
92