1*3fc2996bSsimonb /* $NetBSD: atomic_op_asm.h,v 1.10 2021/07/28 08:01:10 simonb Exp $ */ 2c7572a70Smatt 3c7572a70Smatt /*- 4c7572a70Smatt * Copyright (c) 2007 The NetBSD Foundation, Inc. 5c7572a70Smatt * All rights reserved. 6c7572a70Smatt * 7c7572a70Smatt * This code is derived from software contributed to The NetBSD Foundation 8c7572a70Smatt * by Jason R. Thorpe. 9c7572a70Smatt * 10c7572a70Smatt * Redistribution and use in source and binary forms, with or without 11c7572a70Smatt * modification, are permitted provided that the following conditions 12c7572a70Smatt * are met: 13c7572a70Smatt * 1. Redistributions of source code must retain the above copyright 14c7572a70Smatt * notice, this list of conditions and the following disclaimer. 15c7572a70Smatt * 2. Redistributions in binary form must reproduce the above copyright 16c7572a70Smatt * notice, this list of conditions and the following disclaimer in the 17c7572a70Smatt * documentation and/or other materials provided with the distribution. 18c7572a70Smatt * 3. All advertising materials mentioning features or use of this software 19c7572a70Smatt * must display the following acknowledgement: 20c7572a70Smatt * This product includes software developed by the NetBSD 21c7572a70Smatt * Foundation, Inc. and its contributors. 22c7572a70Smatt * 4. Neither the name of The NetBSD Foundation nor the names of its 23c7572a70Smatt * contributors may be used to endorse or promote products derived 24c7572a70Smatt * from this software without specific prior written permission. 25c7572a70Smatt * 26c7572a70Smatt * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 27c7572a70Smatt * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 28c7572a70Smatt * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 29c7572a70Smatt * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 30c7572a70Smatt * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 31c7572a70Smatt * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 32c7572a70Smatt * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33c7572a70Smatt * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 34c7572a70Smatt * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 35c7572a70Smatt * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36c7572a70Smatt * POSSIBILITY OF SUCH DAMAGE. 37c7572a70Smatt */ 38c7572a70Smatt 39c7572a70Smatt #ifndef _ATOMIC_OP_ASM_H_ 40c7572a70Smatt #define _ATOMIC_OP_ASM_H_ 41c7572a70Smatt 42c7572a70Smatt #include <machine/asm.h> 43c7572a70Smatt 44ab7ecd2cSmatt #if defined(_KERNEL) || defined(_STANDALONE) 45c7572a70Smatt 46c7572a70Smatt #define ATOMIC_OP_ALIAS(a,s) STRONG_ALIAS(a,s) 47c7572a70Smatt 48c7572a70Smatt #else /* _KERNEL */ 49c7572a70Smatt 50c7572a70Smatt #define ATOMIC_OP_ALIAS(a,s) WEAK_ALIAS(a,s) 51b290679aSmartin #ifdef _LIBC 52b290679aSmartin #define CRT_ALIAS(a,s) STRONG_ALIAS(a,s) 53b290679aSmartin #endif 54c7572a70Smatt 55c7572a70Smatt #endif /* _KERNEL */ 56c7572a70Smatt 57b9b9bd89Smatt #ifdef __ARMEB__ 58b9b9bd89Smatt #define HI r0 59b9b9bd89Smatt #define LO r1 60b9b9bd89Smatt #define NHI r2 61b9b9bd89Smatt #define NLO r3 62918e319dSmatt #define THI r4 63918e319dSmatt #define TLO r5 64b9b9bd89Smatt #else 65b9b9bd89Smatt #define LO r0 66b9b9bd89Smatt #define HI r1 67b9b9bd89Smatt #define NLO r2 68b9b9bd89Smatt #define NHI r3 69918e319dSmatt #define TLO r4 70918e319dSmatt #define THI r5 71b9b9bd89Smatt #endif 72b9b9bd89Smatt 73b290679aSmartin #ifndef CRT_ALIAS 74b290679aSmartin #define CRT_ALIAS(a,s) 75b290679aSmartin #endif 76b290679aSmartin 778e8c0784Sskrll #ifdef _ARM_ARCH_7 788e8c0784Sskrll #define DMB dmb ish 798e8c0784Sskrll #define DMBST dmb ishst 808e8c0784Sskrll #else 818e8c0784Sskrll #define DMB mcr p15, 0, r0, c7, c10, 5 /* Data Memory Barrier */ 828e8c0784Sskrll #define DMBST DMB 838e8c0784Sskrll #endif 848e8c0784Sskrll 85c7572a70Smatt #endif /* _ATOMIC_OP_ASM_H_ */ 86