11.4Sskrll/*	$NetBSD: atomic_cas_up.S,v 1.4 2014/01/29 11:34:25 skrll Exp $	*/
21.1Sskrll
31.1Sskrll/*-
41.4Sskrll * Copyright (c) 2008, 2014 The NetBSD Foundation, Inc.
51.1Sskrll * All rights reserved.
61.1Sskrll *
71.1Sskrll * This code is derived from software contributed to The NetBSD Foundation
81.1Sskrll * by Nick Hudson
91.1Sskrll *
101.1Sskrll * Redistribution and use in source and binary forms, with or without
111.1Sskrll * modification, are permitted provided that the following conditions
121.1Sskrll * are met:
131.1Sskrll * 1. Redistributions of source code must retain the above copyright
141.1Sskrll *    notice, this list of conditions and the following disclaimer.
151.1Sskrll * 2. Redistributions in binary form must reproduce the above copyright
161.1Sskrll *    notice, this list of conditions and the following disclaimer in the
171.1Sskrll *    documentation and/or other materials provided with the distribution.
181.1Sskrll *
191.1Sskrll * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
201.1Sskrll * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
211.1Sskrll * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
221.1Sskrll * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
231.1Sskrll * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
241.1Sskrll * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
251.1Sskrll * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
261.1Sskrll * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
271.1Sskrll * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
281.1Sskrll * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
291.1Sskrll * POSSIBILITY OF SUCH DAMAGE.
301.1Sskrll */
311.1Sskrll
321.1Sskrll#include <sys/ras.h>
331.1Sskrll#include <machine/asm.h>
341.1Sskrll
351.1SskrllLEAF_ENTRY_NOPROFILE(_atomic_cas_up)
361.1Sskrll	.hidden	_C_LABEL(_atomic_cas_up)
371.1Sskrll
381.1SskrllRAS_START_ASM_HIDDEN(_atomic_cas)
391.1Sskrll	ldw	0(%arg0), %ret0
401.1Sskrll	comb,<>,n	%arg1, %ret0, 1f
411.1Sskrll	stw	%arg2, 0(%arg0)
421.1SskrllRAS_END_ASM_HIDDEN(_atomic_cas)
431.1Sskrll1:
441.1Sskrll	bv,n	%r0(%rp)
451.1Sskrll
461.1SskrllEXIT(_atomic_cas_up)
471.3Sskrll
481.3SskrllLEAF_ENTRY_NOPROFILE(_atomic_cas_16_up)
491.3Sskrll	.hidden	_C_LABEL(_atomic_cas_16_up)
501.3Sskrll
511.3SskrllRAS_START_ASM_HIDDEN(_atomic_cas_16)
521.3Sskrll	ldh	0(%arg0),%ret0
531.3Sskrll	comb,<>,n	%arg1, %ret0, 1f
541.3Sskrll	sth	%arg2, 0(%arg0)
551.3SskrllRAS_END_ASM_HIDDEN(_atomic_cas_16)
561.3Sskrll1:
571.3Sskrll	bv,n	%r0(%rp)
581.3SskrllEXIT(_atomic_cas_16_up)
591.3Sskrll
601.3SskrllLEAF_ENTRY_NOPROFILE(_atomic_cas_8_up)
611.3Sskrll	.hidden	_C_LABEL(_atomic_cas_8_up)
621.3Sskrll
631.3SskrllRAS_START_ASM_HIDDEN(_atomic_cas_8)
641.3Sskrll	ldb	0(%arg0),%ret0
651.3Sskrll	comb,<>,n	%arg1, %ret0, 1f
661.3Sskrll	stb	%arg2, 0(%arg0)
671.3SskrllRAS_END_ASM_HIDDEN(_atomic_cas_8)
681.3Sskrll1:
691.3Sskrll	bv,n	%r0(%rp)
701.3SskrllEXIT(_atomic_cas_8_up)
71