atomic.h revision 291426
1129198Scognet/* $NetBSD: atomic.h,v 1.1 2002/10/19 12:22:34 bsh Exp $ */ 2129198Scognet 3139735Simp/*- 4129198Scognet * Copyright (C) 2003-2004 Olivier Houchard 5129198Scognet * Copyright (C) 1994-1997 Mark Brinicombe 6129198Scognet * Copyright (C) 1994 Brini 7129198Scognet * All rights reserved. 8129198Scognet * 9129198Scognet * This code is derived from software written for Brini by Mark Brinicombe 10129198Scognet * 11129198Scognet * Redistribution and use in source and binary forms, with or without 12129198Scognet * modification, are permitted provided that the following conditions 13129198Scognet * are met: 14129198Scognet * 1. Redistributions of source code must retain the above copyright 15129198Scognet * notice, this list of conditions and the following disclaimer. 16129198Scognet * 2. Redistributions in binary form must reproduce the above copyright 17129198Scognet * notice, this list of conditions and the following disclaimer in the 18129198Scognet * documentation and/or other materials provided with the distribution. 19129198Scognet * 3. All advertising materials mentioning features or use of this software 20129198Scognet * must display the following acknowledgement: 21129198Scognet * This product includes software developed by Brini. 22129198Scognet * 4. The name of Brini may not be used to endorse or promote products 23129198Scognet * derived from this software without specific prior written permission. 24129198Scognet * 25129198Scognet * THIS SOFTWARE IS PROVIDED BY BRINI ``AS IS'' AND ANY EXPRESS OR 26129198Scognet * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 27129198Scognet * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 28129198Scognet * IN NO EVENT SHALL BRINI BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 29129198Scognet * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 30129198Scognet * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 31129198Scognet * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 32129198Scognet * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 33129198Scognet * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 34129198Scognet * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35129198Scognet * 36129198Scognet * $FreeBSD: head/sys/arm/include/atomic.h 291426 2015-11-28 12:12:28Z mmel $ 37129198Scognet */ 38129198Scognet 39129198Scognet#ifndef _MACHINE_ATOMIC_H_ 40129198Scognet#define _MACHINE_ATOMIC_H_ 41129198Scognet 42129198Scognet#include <sys/types.h> 43271398Sandrew#include <machine/armreg.h> 44129198Scognet 45285631Sandrew#include <machine/acle-compat.h> 46285631Sandrew 47175982Sraj#ifndef _KERNEL 48175982Sraj#include <machine/sysarch.h> 49239268Sgonzo#else 50239268Sgonzo#include <machine/cpuconf.h> 51175982Sraj#endif 52175982Sraj 53285631Sandrew#if __ARM_ARCH >= 6 54285631Sandrew#include <machine/atomic-v6.h> 55239268Sgonzo#else /* < armv6 */ 56285631Sandrew#include <machine/atomic-v4.h> 57239268Sgonzo#endif /* Arch >= v6 */ 58239268Sgonzo 59239268Sgonzostatic __inline int 60144761Scognetatomic_load_32(volatile uint32_t *v) 61144761Scognet{ 62144761Scognet 63144761Scognet return (*v); 64144761Scognet} 65144761Scognet 66144761Scognetstatic __inline void 67144761Scognetatomic_store_32(volatile uint32_t *dst, uint32_t src) 68144761Scognet{ 69144761Scognet *dst = src; 70144761Scognet} 71144761Scognet 72239268Sgonzostatic __inline int 73239268Sgonzoatomic_load_long(volatile u_long *v) 74144761Scognet{ 75144761Scognet 76239268Sgonzo return (*v); 77144761Scognet} 78144761Scognet 79239268Sgonzostatic __inline void 80239268Sgonzoatomic_store_long(volatile u_long *dst, u_long src) 81239268Sgonzo{ 82239268Sgonzo *dst = src; 83239268Sgonzo} 84129198Scognet 85279543Sian#define atomic_clear_ptr atomic_clear_32 86279543Sian#define atomic_set_ptr atomic_set_32 87279543Sian#define atomic_cmpset_ptr atomic_cmpset_32 88279543Sian#define atomic_cmpset_rel_ptr atomic_cmpset_rel_32 89279543Sian#define atomic_cmpset_acq_ptr atomic_cmpset_acq_32 90279543Sian#define atomic_store_ptr atomic_store_32 91279543Sian#define atomic_store_rel_ptr atomic_store_rel_32 92165786Sticso 93165786Sticso#define atomic_add_int atomic_add_32 94239268Sgonzo#define atomic_add_acq_int atomic_add_acq_32 95239268Sgonzo#define atomic_add_rel_int atomic_add_rel_32 96165786Sticso#define atomic_subtract_int atomic_subtract_32 97239268Sgonzo#define atomic_subtract_acq_int atomic_subtract_acq_32 98239268Sgonzo#define atomic_subtract_rel_int atomic_subtract_rel_32 99165786Sticso#define atomic_clear_int atomic_clear_32 100239268Sgonzo#define atomic_clear_acq_int atomic_clear_acq_32 101239268Sgonzo#define atomic_clear_rel_int atomic_clear_rel_32 102137222Scognet#define atomic_set_int atomic_set_32 103239268Sgonzo#define atomic_set_acq_int atomic_set_acq_32 104239268Sgonzo#define atomic_set_rel_int atomic_set_rel_32 105165786Sticso#define atomic_cmpset_int atomic_cmpset_32 106239268Sgonzo#define atomic_cmpset_acq_int atomic_cmpset_acq_32 107239268Sgonzo#define atomic_cmpset_rel_int atomic_cmpset_rel_32 108165786Sticso#define atomic_fetchadd_int atomic_fetchadd_32 109137222Scognet#define atomic_readandclear_int atomic_readandclear_32 110239268Sgonzo#define atomic_load_acq_int atomic_load_acq_32 111239268Sgonzo#define atomic_store_rel_int atomic_store_rel_32 112291426Smmel#define atomic_swap_int atomic_swap_32 113165786Sticso 114129198Scognet#endif /* _MACHINE_ATOMIC_H_ */ 115