xref: /netbsd-src/common/lib/libc/arch/mips/atomic/atomic_and.S (revision bf8d907e758fe420eb478dc88a22d6c1c0a4be61)
1*bf8d907eSskrll/*	$NetBSD: atomic_and.S,v 1.6 2020/08/06 10:00:21 skrll Exp $	*/
28daf714eSmatt
38daf714eSmatt/*-
48daf714eSmatt * Copyright (c) 2008 The NetBSD Foundation, Inc.
58daf714eSmatt * All rights reserved.
68daf714eSmatt *
78daf714eSmatt * Redistribution and use in source and binary forms, with or without
88daf714eSmatt * modification, are permitted provided that the following conditions
98daf714eSmatt * are met:
108daf714eSmatt * 1. Redistributions of source code must retain the above copyright
118daf714eSmatt *    notice, this list of conditions and the following disclaimer.
128daf714eSmatt * 2. Redistributions in binary form must reproduce the above copyright
138daf714eSmatt *    notice, this list of conditions and the following disclaimer in the
148daf714eSmatt *    documentation and/or other materials provided with the distribution.
158daf714eSmatt *
168daf714eSmatt * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
178daf714eSmatt * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
188daf714eSmatt * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
198daf714eSmatt * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
208daf714eSmatt * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
218daf714eSmatt * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
228daf714eSmatt * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
238daf714eSmatt * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
248daf714eSmatt * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
258daf714eSmatt * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
268daf714eSmatt * POSSIBILITY OF SUCH DAMAGE.
278daf714eSmatt */
288daf714eSmatt
298daf714eSmatt#include <machine/asm.h>
308daf714eSmatt#include "atomic_op_asm.h"
318daf714eSmatt
32*bf8d907eSskrllRCSID("$NetBSD: atomic_and.S,v 1.6 2020/08/06 10:00:21 skrll Exp $")
338daf714eSmatt
348daf714eSmatt	.text
358daf714eSmatt	.set	noreorder
364c44c335Sbouyer#ifdef _KERNEL_OPT
374c44c335Sbouyer#include "opt_cputype.h"
384c44c335Sbouyer#ifndef MIPS3_LOONGSON2F
394c44c335Sbouyer	.set	noat
408daf714eSmatt	.set	nomacro
414c44c335Sbouyer#endif
424c44c335Sbouyer#else /* _KERNEL_OPT */
434c44c335Sbouyer	.set	noat
444c44c335Sbouyer	.set	nomacro
454c44c335Sbouyer#endif /* _KERNEL_OPT */
464c44c335Sbouyer
478daf714eSmatt
488daf714eSmattLEAF(_atomic_and_32)
49*bf8d907eSskrll	LLSCSYNC
508daf714eSmatt1:	INT_LL		t0, 0(a0)
518daf714eSmatt	 nop
528daf714eSmatt	and		t0, a1
538daf714eSmatt	INT_SC		t0, 0(a0)
548daf714eSmatt	beq		t0, zero, 1b
558daf714eSmatt 	 nop
568daf714eSmatt	j		ra
578daf714eSmatt	 nop
588daf714eSmattEND(_atomic_and_32)
598daf714eSmattATOMIC_OP_ALIAS(atomic_and_32, _atomic_and_32)
608daf714eSmatt
618daf714eSmattLEAF(_atomic_and_32_nv)
62*bf8d907eSskrll	LLSCSYNC
638daf714eSmatt1:	INT_LL		v0, 0(a0)
648daf714eSmatt	 nop
658daf714eSmatt	and		v0, a1
668daf714eSmatt	move		t0, v0
678daf714eSmatt	INT_SC		t0, 0(a0)
688daf714eSmatt	beq		t0, zero, 1b
698daf714eSmatt 	 nop
708daf714eSmatt	j		ra
718daf714eSmatt	 nop
728daf714eSmattEND(_atomic_and_32_nv)
738daf714eSmattATOMIC_OP_ALIAS(atomic_and_32_nv, _atomic_and_32_nv)
748daf714eSmatt
758daf714eSmatt#if !defined(__mips_o32)
768daf714eSmattLEAF(_atomic_and_64)
77*bf8d907eSskrll	LLSCSYNC
788daf714eSmatt1:	REG_LL		t0, 0(a0)
798daf714eSmatt	 nop
808daf714eSmatt	and		t0, a1
818daf714eSmatt	REG_SC		t0, 0(a0)
828daf714eSmatt	beq		t0, zero, 1b
838daf714eSmatt 	 nop
848daf714eSmatt	j		ra
858daf714eSmatt	 nop
868daf714eSmattEND(_atomic_and_64)
878daf714eSmattATOMIC_OP_ALIAS(atomic_and_64, _atomic_and_64)
888daf714eSmatt
898daf714eSmattLEAF(_atomic_and_64_nv)
90*bf8d907eSskrll	LLSCSYNC
918daf714eSmatt1:	REG_LL		v0, 0(a0)
928daf714eSmatt	 nop
938daf714eSmatt	and		v0, a1
948daf714eSmatt	move		t0, v0
958daf714eSmatt	REG_SC		t0, 0(a0)
968daf714eSmatt	beq		t0, zero, 1b
978daf714eSmatt 	 nop
988daf714eSmatt	j		ra
998daf714eSmatt	 nop
1008daf714eSmattEND(_atomic_and_64_nv)
1018daf714eSmattATOMIC_OP_ALIAS(atomic_and_64_nv, _atomic_and_64_nv)
1028daf714eSmatt#endif
1038daf714eSmatt
1048daf714eSmatt#ifdef _LP64
1058daf714eSmattSTRONG_ALIAS(_atomic_and_ulong,		_atomic_and_64)
1068daf714eSmattSTRONG_ALIAS(_atomic_and_ulong_nv,	_atomic_and_64_nv)
1078daf714eSmatt#else
1088daf714eSmattSTRONG_ALIAS(_atomic_and_ulong,		_atomic_and_32)
1098daf714eSmattSTRONG_ALIAS(_atomic_and_ulong_nv,	_atomic_and_32_nv)
1108daf714eSmatt#endif
1118daf714eSmattSTRONG_ALIAS(_atomic_and_uint,		_atomic_and_32)
1128daf714eSmattSTRONG_ALIAS(_atomic_and_uint_nv,	_atomic_and_32_nv)
1138daf714eSmatt
1148daf714eSmattATOMIC_OP_ALIAS(atomic_and_uint,	_atomic_and_uint)
1158daf714eSmattATOMIC_OP_ALIAS(atomic_and_uint_nv,	_atomic_and_uint_nv)
1168daf714eSmattATOMIC_OP_ALIAS(atomic_and_ulong,	_atomic_and_ulong)
1178daf714eSmattATOMIC_OP_ALIAS(atomic_and_ulong_nv,	_atomic_and_ulong_nv)
118