| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: atomic.S,v 1.14 2008/12/19 11:21:24 ad Exp $ */ | | 1 | /* $NetBSD: atomic.S,v 1.15 2009/01/04 18:21:38 pooka Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Jason R. Thorpe, and by Andrew Doran. | | 8 | * by Jason R. Thorpe, and by Andrew Doran. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -21,27 +21,31 @@ | | | @@ -21,27 +21,31 @@ |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | * POSSIBILITY OF SUCH DAMAGE. | | 29 | * POSSIBILITY OF SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | #include <machine/asm.h> | | 32 | #include <machine/asm.h> |
33 | | | 33 | |
34 | #ifdef _KERNEL | | 34 | #if defined(_KERNEL) && !defined(_RUMPKERNEL) |
| | | 35 | #define _HARDKERNEL |
| | | 36 | #endif |
| | | 37 | |
| | | 38 | #ifdef _HARDKERNEL |
35 | #define LOCK(n) .Lpatch/**/n: lock | | 39 | #define LOCK(n) .Lpatch/**/n: lock |
36 | #define ALIAS(f, t) STRONG_ALIAS(f,t) | | 40 | #define ALIAS(f, t) STRONG_ALIAS(f,t) |
37 | #define ENDLABEL(a) _ALIGN_TEXT; LABEL(a) | | 41 | #define ENDLABEL(a) _ALIGN_TEXT; LABEL(a) |
38 | #else | | 42 | #else |
39 | #define LOCK(n) lock | | 43 | #define LOCK(n) lock |
40 | #define ALIAS(f, t) WEAK_ALIAS(f,t) | | 44 | #define ALIAS(f, t) WEAK_ALIAS(f,t) |
41 | #define ENDLABEL(a) /* nothing */ | | 45 | #define ENDLABEL(a) /* nothing */ |
42 | #endif | | 46 | #endif |
43 | | | 47 | |
44 | .text | | 48 | .text |
45 | | | 49 | |
46 | ENTRY(_atomic_add_32) | | 50 | ENTRY(_atomic_add_32) |
47 | movl 4(%esp), %edx | | 51 | movl 4(%esp), %edx |
| @@ -160,27 +164,27 @@ ENDLABEL(membar_consumer_end) | | | @@ -160,27 +164,27 @@ ENDLABEL(membar_consumer_end) |
160 | | | 164 | |
161 | ENTRY(_membar_producer) | | 165 | ENTRY(_membar_producer) |
162 | /* A store is enough */ | | 166 | /* A store is enough */ |
163 | movl $0, -4(%esp) | | 167 | movl $0, -4(%esp) |
164 | ret | | 168 | ret |
165 | ENDLABEL(membar_producer_end) | | 169 | ENDLABEL(membar_producer_end) |
166 | | | 170 | |
167 | ENTRY(_membar_sync) | | 171 | ENTRY(_membar_sync) |
168 | LOCK(14) | | 172 | LOCK(14) |
169 | addl $0, -4(%esp) | | 173 | addl $0, -4(%esp) |
170 | ret | | 174 | ret |
171 | ENDLABEL(membar_sync_end) | | 175 | ENDLABEL(membar_sync_end) |
172 | | | 176 | |
173 | #ifdef _KERNEL | | 177 | #ifdef _HARDKERNEL |
174 | ENTRY(_atomic_cas_64) | | 178 | ENTRY(_atomic_cas_64) |
175 | pushf | | 179 | pushf |
176 | cli | | 180 | cli |
177 | pushl %edi | | 181 | pushl %edi |
178 | pushl %ebx | | 182 | pushl %ebx |
179 | movl 12(%esp), %edi | | 183 | movl 12(%esp), %edi |
180 | movl 16(%esp), %eax | | 184 | movl 16(%esp), %eax |
181 | movl 20(%esp), %edx | | 185 | movl 20(%esp), %edx |
182 | movl 24(%esp), %ebx | | 186 | movl 24(%esp), %ebx |
183 | movl 28(%esp), %ecx | | 187 | movl 28(%esp), %ecx |
184 | cmpl 0(%edi), %eax | | 188 | cmpl 0(%edi), %eax |
185 | jne 2f | | 189 | jne 2f |
186 | cmpl 4(%edi), %edx | | 190 | cmpl 4(%edi), %edx |
| @@ -233,27 +237,27 @@ atomic_lockpatch: | | | @@ -233,27 +237,27 @@ atomic_lockpatch: |
233 | ENTRY(_atomic_cas_64) | | 237 | ENTRY(_atomic_cas_64) |
234 | pushl %edi | | 238 | pushl %edi |
235 | pushl %ebx | | 239 | pushl %ebx |
236 | movl 12(%esp), %edi | | 240 | movl 12(%esp), %edi |
237 | movl 16(%esp), %eax | | 241 | movl 16(%esp), %eax |
238 | movl 20(%esp), %edx | | 242 | movl 20(%esp), %edx |
239 | movl 24(%esp), %ebx | | 243 | movl 24(%esp), %ebx |
240 | movl 28(%esp), %ecx | | 244 | movl 28(%esp), %ecx |
241 | lock | | 245 | lock |
242 | cmpxchg8b (%edi) | | 246 | cmpxchg8b (%edi) |
243 | popl %ebx | | 247 | popl %ebx |
244 | popl %edi | | 248 | popl %edi |
245 | ret | | 249 | ret |
246 | #endif /* _KERNEL */ | | 250 | #endif /* _HARDKERNEL */ |
247 | | | 251 | |
248 | ALIAS(atomic_add_32,_atomic_add_32) | | 252 | ALIAS(atomic_add_32,_atomic_add_32) |
249 | ALIAS(atomic_add_int,_atomic_add_32) | | 253 | ALIAS(atomic_add_int,_atomic_add_32) |
250 | ALIAS(atomic_add_long,_atomic_add_32) | | 254 | ALIAS(atomic_add_long,_atomic_add_32) |
251 | ALIAS(atomic_add_ptr,_atomic_add_32) | | 255 | ALIAS(atomic_add_ptr,_atomic_add_32) |
252 | | | 256 | |
253 | ALIAS(atomic_add_32_nv,_atomic_add_32_nv) | | 257 | ALIAS(atomic_add_32_nv,_atomic_add_32_nv) |
254 | ALIAS(atomic_add_int_nv,_atomic_add_32_nv) | | 258 | ALIAS(atomic_add_int_nv,_atomic_add_32_nv) |
255 | ALIAS(atomic_add_long_nv,_atomic_add_32_nv) | | 259 | ALIAS(atomic_add_long_nv,_atomic_add_32_nv) |
256 | ALIAS(atomic_add_ptr_nv,_atomic_add_32_nv) | | 260 | ALIAS(atomic_add_ptr_nv,_atomic_add_32_nv) |
257 | | | 261 | |
258 | ALIAS(atomic_and_32,_atomic_and_32) | | 262 | ALIAS(atomic_and_32,_atomic_and_32) |
259 | ALIAS(atomic_and_uint,_atomic_and_32) | | 263 | ALIAS(atomic_and_uint,_atomic_and_32) |