1 1.8 skrll /* $NetBSD: atomic_cas_up.S,v 1.8 2020/03/09 11:21:54 skrll Exp $ */ 2 1.1 scw 3 1.1 scw /*- 4 1.1 scw * Copyright (c) 2008 The NetBSD Foundation, Inc. 5 1.1 scw * All rights reserved. 6 1.1 scw * 7 1.1 scw * This code is derived from software contributed to The NetBSD Foundation 8 1.1 scw * by Steve C. Woodford. 9 1.1 scw * 10 1.1 scw * Redistribution and use in source and binary forms, with or without 11 1.1 scw * modification, are permitted provided that the following conditions 12 1.1 scw * are met: 13 1.1 scw * 1. Redistributions of source code must retain the above copyright 14 1.1 scw * notice, this list of conditions and the following disclaimer. 15 1.1 scw * 2. Redistributions in binary form must reproduce the above copyright 16 1.1 scw * notice, this list of conditions and the following disclaimer in the 17 1.1 scw * documentation and/or other materials provided with the distribution. 18 1.1 scw * 19 1.1 scw * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 1.1 scw * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 1.1 scw * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 1.1 scw * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 1.1 scw * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 1.1 scw * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 1.1 scw * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 1.1 scw * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 1.1 scw * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 1.1 scw * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 1.1 scw * POSSIBILITY OF SUCH DAMAGE. 30 1.1 scw */ 31 1.1 scw 32 1.1 scw #include <sys/ras.h> 33 1.1 scw #include <machine/asm.h> 34 1.1 scw 35 1.2 chs ENTRY(_atomic_cas_up) 36 1.1 scw .hidden _C_LABEL(_atomic_cas_up) 37 1.1 scw mov r3, r0 38 1.4 matt .align 0 39 1.1 scw RAS_START_ASM_HIDDEN(_atomic_cas) 40 1.1 scw ldr r0, [r3] 41 1.1 scw cmp r0, r1 42 1.4 matt #if defined(__thumb__) 43 1.4 matt beq 1f 44 1.8 skrll str r2, [r3] 45 1.4 matt #else 46 1.1 scw streq r2, [r3] 47 1.4 matt #endif 48 1.4 matt .align 0 49 1.1 scw RAS_END_ASM_HIDDEN(_atomic_cas) 50 1.4 matt 1: RET 51 1.3 matt END(_atomic_cas_up) 52 1.5 matt 53 1.6 matt #if defined(__HAVE_ASM_ATOMIC_CAS_64_UP) 54 1.6 matt ARM_ENTRY(_atomic_cas_64_up) 55 1.6 matt push {r4-r5} 56 1.6 matt mov ip, r0 57 1.7 matt ldrd r4, r5, [sp, #8] 58 1.6 matt .align 0 59 1.6 matt RAS_START_ASM_HIDDEN(_atomic_cas_64) 60 1.6 matt ldrd r0, r1, [ip] 61 1.6 matt cmp r0, r2 62 1.6 matt cmpeq r1, r3 63 1.6 matt strdeq r4, r5, [ip] 64 1.6 matt .align 0 65 1.6 matt RAS_END_ASM_HIDDEN(_atomic_cas_64) 66 1.6 matt 1: pop {r4-r5} 67 1.6 matt bx lr 68 1.6 matt END(_atomic_cas_64_up) 69 1.6 matt #endif /* __HAVE_ASM_ATOMIC_64_UP */ 70 1.6 matt 71 1.5 matt ENTRY(_atomic_cas_16_up) 72 1.5 matt mov r3, r0 73 1.5 matt .align 0 74 1.5 matt RAS_START_ASM_HIDDEN(_atomic_cas_16) 75 1.5 matt ldrh r0, [r3] 76 1.5 matt cmp r0, r1 77 1.5 matt #if defined(__thumb__) 78 1.5 matt beq 1f 79 1.8 skrll strh r2, [r3] 80 1.5 matt #else 81 1.5 matt strheq r2, [r3] 82 1.5 matt #endif 83 1.5 matt .align 0 84 1.5 matt RAS_END_ASM_HIDDEN(_atomic_cas_16) 85 1.5 matt 1: RET 86 1.5 matt END(_atomic_cas_16_up) 87 1.5 matt 88 1.5 matt ENTRY(_atomic_cas_8_up) 89 1.5 matt mov r3, r0 90 1.5 matt .align 0 91 1.5 matt RAS_START_ASM_HIDDEN(_atomic_cas_8) 92 1.5 matt ldrb r0, [r3] 93 1.5 matt cmp r0, r1 94 1.5 matt #if defined(__thumb__) 95 1.5 matt beq 1f 96 1.8 skrll strb r2, [r3] 97 1.5 matt #else 98 1.5 matt strbeq r2, [r3] 99 1.5 matt #endif 100 1.5 matt .align 0 101 1.5 matt RAS_END_ASM_HIDDEN(_atomic_cas_8) 102 1.5 matt 1: RET 103 1.5 matt END(_atomic_cas_8_up) 104