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

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [rc203soc/] [sw/] [uClinux/] [arch/] [armnommu/] [lib/] [bitops.S] - Blame information for rev 1765

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

Line No. Rev Author Line
1 1622 jcastillo
/*
2
 * linux/arch/arm/lib/bitops.S
3
 *
4
 * Copyright (C) 1995, 1996 Russell King
5
 */
6
 
7
#include 
8
                .text
9
 
10
@ Purpose  : Function to set a bit
11
@ Prototype: int set_bit(int bit,int *addr)
12
 
13
                .globl  _set_bit,set_bit
14
set_bit:
15
_set_bit:       add     r1, r1, r0, lsr #3      @ Get byte offset
16
                and     r3, r0, #7              @ Get bit offset
17
                mov     r0, #1
18
                SAVEIRQS(ip)
19
                DISABLEIRQS(ip)
20
                ldrb    r2, [r1]
21
                tst     r2, r0, lsl r3
22
                orr     r2, r2, r0, lsl r3
23
                moveq   r0, #0
24
                strb    r2, [r1]
25
                RESTOREIRQS(ip)
26
                RETINSTR(mov,pc,lr)
27
 
28
@ Purpose  : Function to clear a bit
29
@ Prototype: int clear_bit(int bit,int *addr)
30
 
31
                .globl  _clear_bit,clear_bit
32
clear_bit:
33
_clear_bit:     add     r1, r1, r0, lsr #3      @ Get byte offset
34
                and     r3, r0, #7      @ Get bit offset
35
                mov     r0, #1
36
                SAVEIRQS(ip)
37
                DISABLEIRQS(ip)
38
                ldrb    r2, [r1]
39
                tst     r2, r0, lsl r3
40
                bic     r2, r2, r0, lsl r3
41
                moveq   r0, #0
42
                strb    r2, [r1]
43
                RESTOREIRQS(ip)
44
                RETINSTR(mov,pc,lr)
45
 
46
/* Purpose  : Function to change a bit
47
 * Prototype: int change_bit(int bit,int *addr)
48
 */
49
                .globl  _change_bit,change_bit
50
change_bit:
51
_change_bit:    add     r1, r1, r0, lsr #3
52
                and     r3, r0, #7
53
                mov     r0, #1
54
                SAVEIRQS(ip)
55
                DISABLEIRQS(ip)
56
                ldrb    r2, [r1]
57
                tst     r2, r0, lsl r3
58
                eor     r2, r2, r0, lsl r3
59
                moveq   r0, #0
60
                strb    r2, [r1]
61
                RESTOREIRQS(ip)
62
                RETINSTR(mov,pc,lr)
63
 
64
@ Purpose  : Find a 'zero' bit
65
@ Prototype: int find_first_zero_bit(char *addr,int maxbit);
66
 
67
                .globl  _find_first_zero_bit,find_first_zero_bit
68
find_first_zero_bit:
69
_find_first_zero_bit:
70
                mov     r2, #0                  @ Initialise bit position
71
Lfindzbit1lp:   ldrb    r3, [r0, r2, lsr #3]    @ Check byte, if 0xFF, then all bits set
72
                teq     r3, #0xFF
73
                bne     Lfoundzbit
74
                add     r2, r2, #8
75
                cmp     r2, r1                  @ Check to see if we have come to the end
76
                bcc     Lfindzbit1lp
77
                add     r0, r1, #1              @ Make sure that we flag an error
78
                RETINSTR(mov,pc,lr)
79
Lfoundzbit:     tst     r3, #1                  @ Check individual bits
80
                moveq   r0, r2
81
                RETINSTR(moveq,pc,lr)
82
                tst     r3, #2
83
                addeq   r0, r2, #1
84
                RETINSTR(moveq,pc,lr)
85
                tst     r3, #4
86
                addeq   r0, r2, #2
87
                RETINSTR(moveq,pc,lr)
88
                tst     r3, #8
89
                addeq   r0, r2, #3
90
                RETINSTR(moveq,pc,lr)
91
                tst     r3, #16
92
                addeq   r0, r2, #4
93
                RETINSTR(moveq,pc,lr)
94
                tst     r3, #32
95
                addeq   r0, r2, #5
96
                RETINSTR(moveq,pc,lr)
97
                tst     r3, #64
98
                addeq   r0, r2, #6
99
                RETINSTR(moveq,pc,lr)
100
                add     r0, r2, #7
101
                RETINSTR(mov,pc,lr)
102
 
103
@ Purpose  : Find next 'zero' bit
104
@ Prototype: int find_next_zero_bit(char *addr,int maxbit,int offset)
105
 
106
                .globl  _find_next_zero_bit,find_next_zero_bit
107
find_next_zero_bit:
108
_find_next_zero_bit:
109
                tst     r2, #7
110
                beq     Lfindzbit1lp            @ If new byte, goto old routine
111
                ldrb    r3, [r0, r2, lsr#3]
112
                orr     r3, r3, #0xFF00         @ Set top bits so we wont get confused
113
                stmfd   sp!, {r4}
114
                and     r4, r2, #7
115
                mov     r3, r3, lsr r4          @ Shift right by no. of bits
116
                ldmfd   sp!, {r4}
117
                and     r3, r3, #0xFF
118
                teq     r3, #0xFF
119
                orreq   r2, r2, #7
120
                addeq   r2, r2, #1
121
                beq     Lfindzbit1lp            @ If all bits are set, goto old routine
122
                b       Lfoundzbit

powered by: WebSVN 2.1.0

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