]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - 6/sys/alpha/alpha/atomic.s
merge fix for boot-time hang on centos' xen
[FreeBSD/FreeBSD.git] / 6 / sys / alpha / alpha / atomic.s
1 /*-
2  * Copyright (c) 1998 Doug Rabson
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  *
26  * $FreeBSD$
27  */
28
29 #include <machine/asm.h>
30
31         .text
32
33 LEAF(atomic_set_8, 2)
34         bic     a0, 7, t1
35 0:      ldq_l   t2, 0(t1)
36         extbl   t2, a0, t0
37         bis     t0, a1, t0
38         insbl   t0, a0, t0
39         mskbl   t2, a0, t2
40         or      t2, t0, t0
41         stq_c   t0, 0(t1)
42         beq     t0, 1f
43         RET
44 1:      br      0b
45         END(atomic_set_8)
46
47 LEAF(atomic_clear_8, 2)
48         bic     a0, 7, t1
49 0:      ldq_l   t2, 0(t1)
50         extbl   t2, a0, t0
51         bic     t0, a1, t0
52         insbl   t0, a0, t0
53         mskbl   t2, a0, t2
54         or      t2, t0, t0
55         stq_c   t0, 0(t1)
56         beq     t0, 1f
57         RET
58 1:      br      0b
59         END(atomic_clear_8)
60         
61 LEAF(atomic_add_8, 2)
62         bic     a0, 7, t1
63 0:      ldq_l   t2, 0(t1)
64         extbl   t2, a0, t0
65         addl    t0, a1, t0
66         insbl   t0, a0, t0
67         mskbl   t2, a0, t2
68         or      t2, t0, t0
69         stq_c   t0, 0(t1)
70         beq     t0, 1f
71         RET
72 1:      br      0b
73         END(atomic_add_8)
74
75 LEAF(atomic_subtract_8, 2)
76         bic     a0, 7, t1
77 0:      ldq_l   t2, 0(t1)
78         extbl   t2, a0, t0
79         subl    t0, a1, t0
80         insbl   t0, a0, t0
81         mskbl   t2, a0, t2
82         or      t2, t0, t0
83         stq_c   t0, 0(t1)
84         beq     t0, 1f
85         RET
86 1:      br      0b
87         END(atomic_subtract_8)
88         
89 LEAF(atomic_set_16, 2)
90         bic     a0, 7, t1
91 0:      ldq_l   t2, 0(t1)
92         extwl   t2, a0, t0
93         bis     t0, a1, t0
94         inswl   t0, a0, t0
95         mskwl   t2, a0, t2
96         or      t2, t0, t0
97         stq_c   t0, 0(t1)
98         beq     t0, 1f
99         RET
100 1:      br      0b
101         END(atomic_set_16)
102
103 LEAF(atomic_clear_16, 2)
104         bic     a0, 7, t1
105 0:      ldq_l   t2, 0(t1)
106         extwl   t2, a0, t0
107         bic     t0, a1, t0
108         inswl   t0, a0, t0
109         mskwl   t2, a0, t2
110         or      t2, t0, t0
111         stq_c   t0, 0(t1)
112         beq     t0, 1f
113         RET
114 1:      br      0b
115         END(atomic_clear_16)
116         
117 LEAF(atomic_add_16, 2)
118         bic     a0, 7, t1
119 0:      ldq_l   t2, 0(t1)
120         extwl   t2, a0, t0
121         addl    t0, a1, t0
122         inswl   t0, a0, t0
123         mskwl   t2, a0, t2
124         or      t2, t0, t0
125         stq_c   t0, 0(t1)
126         beq     t0, 1f
127         RET
128 1:      br      0b
129         END(atomic_add_16)
130
131 LEAF(atomic_subtract_16, 2)
132         bic     a0, 7, t1
133 0:      ldq_l   t2, 0(t1)
134         extwl   t2, a0, t0
135         subl    t0, a1, t0
136         inswl   t0, a0, t0
137         mskwl   t2, a0, t2
138         or      t2, t0, t0
139         stq_c   t0, 0(t1)
140         beq     t0, 1f
141         RET
142 1:      br      0b
143         END(atomic_subtract_16)