| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: atomic_nand_16.S,v 1.1.28.1 2021/07/06 04:13:50 martin Exp $ */ | | 1 | /* $NetBSD: atomic_nand_16.S,v 1.1.28.2 2021/07/08 11:22:01 martin Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2014 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2014 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 Matt Thomas of 3am Software Foundry. | | 8 | * by Matt Thomas of 3am Software Foundry. |
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. |
| @@ -28,44 +28,44 @@ | | | @@ -28,44 +28,44 @@ |
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 "atomic_op_asm.h" | | 32 | #include "atomic_op_asm.h" |
33 | | | 33 | |
34 | /* | | 34 | /* |
35 | * { tmp = *ptr; *ptr = ~(tmp & value); return tmp; } // nand | | 35 | * { tmp = *ptr; *ptr = ~(tmp & value); return tmp; } // nand |
36 | */ | | 36 | */ |
37 | ENTRY_NP(_atomic_nand_16) | | 37 | ENTRY_NP(_atomic_nand_16) |
38 | mov x4, x0 | | 38 | mov x4, x0 |
39 | 1: ldxrh w0, [x4] /* load old value (*ptr) */ | | 39 | 1: ldxrh w0, [x4] /* load old value (*ptr) */ |
40 | and w3, w0, w1 /* w3 = (*ptr & value) */ | | 40 | and w3, w0, w1 /* w3 = (*ptr & value) */ |
41 | mvn w3, w3 /* w3 = ~(*pte & value) */ | | 41 | mvn w3, w3 /* w3 = ~(*ptr & value) */ |
42 | stxrh w2, w3, [x4] /* try to store */ | | 42 | stxrh w2, w3, [x4] /* try to store */ |
43 | cbnz w2, 1b /* succeed? no, try again */ | | 43 | cbnz w2, 1b /* succeed? no, try again */ |
44 | dmb st | | 44 | dmb st |
45 | ret /* return old value */ | | 45 | ret /* return old value */ |
46 | END(_atomic_nand_16) | | 46 | END(_atomic_nand_16) |
47 | | | 47 | |
48 | ATOMIC_OP_ALIAS(atomic_nand_16,_atomic_nand_16) | | 48 | ATOMIC_OP_ALIAS(atomic_nand_16,_atomic_nand_16) |
49 | ATOMIC_OP_ALIAS(atomic_nand_ushort,_atomic_nand_16) | | 49 | ATOMIC_OP_ALIAS(atomic_nand_ushort,_atomic_nand_16) |
50 | STRONG_ALIAS(__sync_fetch_and_nand_2,_atomic_nand_16) | | 50 | STRONG_ALIAS(__sync_fetch_and_nand_2,_atomic_nand_16) |
51 | STRONG_ALIAS(_atomic_nand_ushort,_atomic_nand_16) | | 51 | STRONG_ALIAS(_atomic_nand_ushort,_atomic_nand_16) |
52 | | | 52 | |
53 | | | 53 | |
54 | /* | | 54 | /* |
55 | * { tmp = ~(*ptr & value); *ptr = tmp; return *ptr; } // nand | | 55 | * { tmp = ~(*ptr & value); *ptr = tmp; return *ptr; } // nand |
56 | */ | | 56 | */ |
57 | ENTRY_NP(_atomic_nand_16_nv) | | 57 | ENTRY_NP(_atomic_nand_16_nv) |
58 | mov x4, x0 /* need r0 for return value */ | | 58 | mov x4, x0 /* need r0 for return value */ |
59 | 1: ldxrh w0, [x4] /* load old value (*ptr) */ | | 59 | 1: ldxrh w0, [x4] /* load old value (*ptr) */ |
60 | and w0, w0, w1 /* w0 = (*ptr & value) */ | | 60 | and w0, w0, w1 /* w0 = (*ptr & value) */ |
61 | mvn w0, w0 /* w0 = ~(*pte & value), return value */ | | 61 | mvn w0, w0 /* w0 = ~(*ptr & value), return value */ |
62 | stxrh w2, w0, [x4] /* try to store */ | | 62 | stxrh w2, w0, [x4] /* try to store */ |
63 | cbnz w2, 1b /* succeed? no, try again? */ | | 63 | cbnz w2, 1b /* succeed? no, try again? */ |
64 | dmb st | | 64 | dmb st |
65 | ret /* return new value */ | | 65 | ret /* return new value */ |
66 | END(_atomic_nand_16_nv) | | 66 | END(_atomic_nand_16_nv) |
67 | | | 67 | |
68 | ATOMIC_OP_ALIAS(atomic_nand_16_nv,_atomic_nand_16_nv) | | 68 | ATOMIC_OP_ALIAS(atomic_nand_16_nv,_atomic_nand_16_nv) |
69 | ATOMIC_OP_ALIAS(atomic_nand_ushort_nv,_atomic_nand_16_nv) | | 69 | ATOMIC_OP_ALIAS(atomic_nand_ushort_nv,_atomic_nand_16_nv) |
70 | STRONG_ALIAS(__sync_nand_and_fetch_2,_atomic_nand_16_nv) | | 70 | STRONG_ALIAS(__sync_nand_and_fetch_2,_atomic_nand_16_nv) |
71 | STRONG_ALIAS(_atomic_nand_ushort_nv,_atomic_nand_16_nv) | | 71 | STRONG_ALIAS(_atomic_nand_ushort_nv,_atomic_nand_16_nv) |