1 /* $NetBSD: atomic.h,v 1.1 2002/10/19 12:22:34 bsh Exp $ */ 2 3 /*- 4 * SPDX-License-Identifier: BSD-4-Clause 5 * 6 * Copyright (C) 2003-2004 Olivier Houchard 7 * Copyright (C) 1994-1997 Mark Brinicombe 8 * Copyright (C) 1994 Brini 9 * All rights reserved. 10 * 11 * This code is derived from software written for Brini by Mark Brinicombe 12 * 13 * Redistribution and use in source and binary forms, with or without 14 * modification, are permitted provided that the following conditions 15 * are met: 16 * 1. Redistributions of source code must retain the above copyright 17 * notice, this list of conditions and the following disclaimer. 18 * 2. Redistributions in binary form must reproduce the above copyright 19 * notice, this list of conditions and the following disclaimer in the 20 * documentation and/or other materials provided with the distribution. 21 * 3. All advertising materials mentioning features or use of this software 22 * must display the following acknowledgement: 23 * This product includes software developed by Brini. 24 * 4. The name of Brini may not be used to endorse or promote products 25 * derived from this software without specific prior written permission. 26 * 27 * THIS SOFTWARE IS PROVIDED BY BRINI ``AS IS'' AND ANY EXPRESS OR 28 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 29 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 30 * IN NO EVENT SHALL BRINI BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 31 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 32 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 33 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 34 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 35 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 36 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 * 38 * $FreeBSD$ 39 */ 40 41 #ifndef _MACHINE_ATOMIC_H_ 42 #define _MACHINE_ATOMIC_H_ 43 44 #include <sys/atomic_common.h> 45 46 #include <machine/armreg.h> 47 48 #ifndef _KERNEL 49 #include <machine/sysarch.h> 50 #endif 51 52 #if __ARM_ARCH >= 6 53 #include <machine/atomic-v6.h> 54 #else /* < armv6 */ 55 #include <machine/atomic-v4.h> 56 #endif /* Arch >= v6 */ 57 58 static __inline int 59 atomic_load_32(volatile uint32_t *v) 60 { 61 62 return (*v); 63 } 64 65 static __inline void 66 atomic_store_32(volatile uint32_t *dst, uint32_t src) 67 { 68 *dst = src; 69 } 70 71 static __inline int 72 atomic_load_long(volatile u_long *v) 73 { 74 75 return (*v); 76 } 77 78 static __inline void 79 atomic_store_long(volatile u_long *dst, u_long src) 80 { 81 *dst = src; 82 } 83 84 #define atomic_clear_ptr atomic_clear_32 85 #define atomic_clear_acq_ptr atomic_clear_acq_32 86 #define atomic_clear_rel_ptr atomic_clear_rel_32 87 #define atomic_set_ptr atomic_set_32 88 #define atomic_set_acq_ptr atomic_set_acq_32 89 #define atomic_set_rel_ptr atomic_set_rel_32 90 #define atomic_fcmpset_ptr atomic_fcmpset_32 91 #define atomic_fcmpset_rel_ptr atomic_fcmpset_rel_32 92 #define atomic_fcmpset_acq_ptr atomic_fcmpset_acq_32 93 #define atomic_cmpset_ptr atomic_cmpset_32 94 #define atomic_cmpset_acq_ptr atomic_cmpset_acq_32 95 #define atomic_cmpset_rel_ptr atomic_cmpset_rel_32 96 #define atomic_load_acq_ptr atomic_load_acq_32 97 #define atomic_store_ptr atomic_store_32 98 #define atomic_store_rel_ptr atomic_store_rel_32 99 #define atomic_swap_ptr atomic_swap_32 100 #define atomic_readandclear_ptr atomic_readandclear_32 101 102 #define atomic_add_int atomic_add_32 103 #define atomic_add_acq_int atomic_add_acq_32 104 #define atomic_add_rel_int atomic_add_rel_32 105 #define atomic_subtract_int atomic_subtract_32 106 #define atomic_subtract_acq_int atomic_subtract_acq_32 107 #define atomic_subtract_rel_int atomic_subtract_rel_32 108 #define atomic_clear_int atomic_clear_32 109 #define atomic_clear_acq_int atomic_clear_acq_32 110 #define atomic_clear_rel_int atomic_clear_rel_32 111 #define atomic_set_int atomic_set_32 112 #define atomic_set_acq_int atomic_set_acq_32 113 #define atomic_set_rel_int atomic_set_rel_32 114 #define atomic_fcmpset_int atomic_fcmpset_32 115 #define atomic_fcmpset_acq_int atomic_fcmpset_acq_32 116 #define atomic_fcmpset_rel_int atomic_fcmpset_rel_32 117 #define atomic_cmpset_int atomic_cmpset_32 118 #define atomic_cmpset_acq_int atomic_cmpset_acq_32 119 #define atomic_cmpset_rel_int atomic_cmpset_rel_32 120 #define atomic_fetchadd_int atomic_fetchadd_32 121 #define atomic_readandclear_int atomic_readandclear_32 122 #define atomic_load_acq_int atomic_load_acq_32 123 #define atomic_store_rel_int atomic_store_rel_32 124 #define atomic_swap_int atomic_swap_32 125 126 #endif /* _MACHINE_ATOMIC_H_ */ 127