1*09ff5f3bSriastradh/* $NetBSD: atomic_cas_68000.S,v 1.7 2022/04/06 22:47:56 riastradh Exp $ */ 24e2c4c42Sscw 34e2c4c42Sscw/*- 44e2c4c42Sscw * Copyright (c) 2008 The NetBSD Foundation, Inc. 54e2c4c42Sscw * All rights reserved. 64e2c4c42Sscw * 74e2c4c42Sscw * This code is derived from software contributed to The NetBSD Foundation 84e2c4c42Sscw * by Steve C. Woodford. 94e2c4c42Sscw * 104e2c4c42Sscw * Redistribution and use in source and binary forms, with or without 114e2c4c42Sscw * modification, are permitted provided that the following conditions 124e2c4c42Sscw * are met: 134e2c4c42Sscw * 1. Redistributions of source code must retain the above copyright 144e2c4c42Sscw * notice, this list of conditions and the following disclaimer. 154e2c4c42Sscw * 2. Redistributions in binary form must reproduce the above copyright 164e2c4c42Sscw * notice, this list of conditions and the following disclaimer in the 174e2c4c42Sscw * documentation and/or other materials provided with the distribution. 184e2c4c42Sscw * 194e2c4c42Sscw * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 204e2c4c42Sscw * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 214e2c4c42Sscw * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 224e2c4c42Sscw * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 234e2c4c42Sscw * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 244e2c4c42Sscw * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 254e2c4c42Sscw * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 264e2c4c42Sscw * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 274e2c4c42Sscw * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 284e2c4c42Sscw * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 294e2c4c42Sscw * POSSIBILITY OF SUCH DAMAGE. 304e2c4c42Sscw */ 314e2c4c42Sscw 324e2c4c42Sscw#include <sys/ras.h> 334e2c4c42Sscw#include "atomic_op_asm.h" 344e2c4c42Sscw 354e2c4c42Sscw .text 364e2c4c42Sscw 376740bb54SchsENTRY(_atomic_cas_up) 384e2c4c42Sscw .hidden _C_LABEL(_atomic_cas_up) 394e2c4c42Sscw 4007a0a325Smatt movl 4(%sp), %a0 /* Fetch ptr */ 414e2c4c42Sscw 424e2c4c42SscwRAS_START_ASM_HIDDEN(_atomic_cas) 4307a0a325Smatt movl (%a0), %d0 /* d0 = *ptr */ 4407a0a325Smatt cmpl 8(%sp), %d0 /* Same as old? */ 454e2c4c42Sscw jne 1f /* Nope */ 4607a0a325Smatt movl 12(%sp), (%a0) /* *ptr = new */ 474e2c4c42SscwRAS_END_ASM_HIDDEN(_atomic_cas) 484e2c4c42Sscw1: rts 4965726debSmattEND(_atomic_cas_up) 50d5d5b0e6Smartin 51d5d5b0e6SmartinENTRY(_atomic_cas_16_up) 52d5d5b0e6Smartin .hidden _C_LABEL(_atomic_cas_16_up) 53d5d5b0e6Smartin 54d5d5b0e6Smartin movl 4(%sp), %a0 /* Fetch ptr */ 55d5d5b0e6Smartin 56d5d5b0e6SmartinRAS_START_ASM_HIDDEN(_atomic_cas_16) 57d5d5b0e6Smartin movw (%a0), %d0 /* d0 = *ptr */ 58d5d5b0e6Smartin cmpw 8(%sp), %d0 /* Same as old? */ 59d5d5b0e6Smartin jne 1f /* Nope */ 60d5d5b0e6Smartin movw 12(%sp), (%a0) /* *ptr = new */ 61d5d5b0e6SmartinRAS_END_ASM_HIDDEN(_atomic_cas_16) 62d5d5b0e6Smartin1: rts 63d5d5b0e6SmartinEND(_atomic_cas_16_up) 64d5d5b0e6Smartin 65d5d5b0e6Smartin 66d5d5b0e6SmartinENTRY(_atomic_cas_8_up) 67d5d5b0e6Smartin .hidden _C_LABEL(_atomic_cas_8_up) 68d5d5b0e6Smartin 69d5d5b0e6Smartin movl 4(%sp), %a0 /* Fetch ptr */ 70d5d5b0e6Smartin 71d5d5b0e6SmartinRAS_START_ASM_HIDDEN(_atomic_cas_8) 72d5d5b0e6Smartin movb (%a0), %d0 /* d0 = *ptr */ 73d5d5b0e6Smartin cmpb 8(%sp), %d0 /* Same as old? */ 74d5d5b0e6Smartin jne 1f /* Nope */ 75d5d5b0e6Smartin movb 12(%sp), (%a0) /* *ptr = new */ 76d5d5b0e6SmartinRAS_END_ASM_HIDDEN(_atomic_cas_8) 77d5d5b0e6Smartin1: rts 78d5d5b0e6SmartinEND(_atomic_cas_8_up) 79