Home | History | Annotate | Line # | Download | only in atomic
      1  1.7   skrll /*	$NetBSD: atomic_inc.S,v 1.7 2020/08/06 10:00:21 skrll Exp $	*/
      2  1.2    matt 
      3  1.2    matt /*-
      4  1.2    matt  * Copyright (c) 2008 The NetBSD Foundation, Inc.
      5  1.2    matt  * All rights reserved.
      6  1.2    matt  *
      7  1.2    matt  * Redistribution and use in source and binary forms, with or without
      8  1.2    matt  * modification, are permitted provided that the following conditions
      9  1.2    matt  * are met:
     10  1.2    matt  * 1. Redistributions of source code must retain the above copyright
     11  1.2    matt  *    notice, this list of conditions and the following disclaimer.
     12  1.2    matt  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.2    matt  *    notice, this list of conditions and the following disclaimer in the
     14  1.2    matt  *    documentation and/or other materials provided with the distribution.
     15  1.6   skrll  *
     16  1.2    matt  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     17  1.2    matt  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     18  1.2    matt  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     19  1.2    matt  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     20  1.2    matt  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     21  1.2    matt  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     22  1.2    matt  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     23  1.2    matt  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     24  1.2    matt  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     25  1.2    matt  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     26  1.2    matt  * POSSIBILITY OF SUCH DAMAGE.
     27  1.2    matt  */
     28  1.2    matt 
     29  1.2    matt #include <machine/asm.h>
     30  1.2    matt #include "atomic_op_asm.h"
     31  1.2    matt 
     32  1.7   skrll RCSID("$NetBSD: atomic_inc.S,v 1.7 2020/08/06 10:00:21 skrll Exp $")
     33  1.2    matt 
     34  1.2    matt 	.text
     35  1.3  bouyer 	.set	noreorder
     36  1.3  bouyer #ifdef _KERNEL_OPT
     37  1.3  bouyer #include "opt_cputype.h"
     38  1.3  bouyer #ifndef MIPS3_LOONGSON2F
     39  1.3  bouyer 	.set	noat
     40  1.3  bouyer 	.set	nomacro
     41  1.3  bouyer #endif
     42  1.3  bouyer #else /* _KERNEL_OPT */
     43  1.2    matt 	.set	noat
     44  1.2    matt 	.set	nomacro
     45  1.3  bouyer #endif /* _KERNEL_OPT */
     46  1.3  bouyer 
     47  1.2    matt 
     48  1.2    matt LEAF(_atomic_inc_32)
     49  1.5    matt #if defined(_MIPS_ARCH_OCTEONP) || defined(_MIPS_ARCH_OCTEON2)
     50  1.5    matt 	li		t0, 1
     51  1.5    matt 	saa		t0, (a0)
     52  1.5    matt #else
     53  1.7   skrll 	LLSCSYNC
     54  1.2    matt 1:	INT_LL		t0, 0(a0)
     55  1.2    matt 	 nop
     56  1.2    matt 	INT_ADDU	t0, 1
     57  1.2    matt 	INT_SC		t0, 0(a0)
     58  1.2    matt 	beq		t0, zero, 1b
     59  1.2    matt  	 nop
     60  1.5    matt #endif
     61  1.2    matt 	j		ra
     62  1.2    matt 	 nop
     63  1.2    matt END(_atomic_inc_32)
     64  1.2    matt ATOMIC_OP_ALIAS(atomic_inc_32, _atomic_inc_32)
     65  1.2    matt 
     66  1.2    matt LEAF(_atomic_inc_32_nv)
     67  1.7   skrll 	LLSCSYNC
     68  1.2    matt 1:	INT_LL		v0, 0(a0)
     69  1.2    matt 	 nop
     70  1.2    matt 	INT_ADDU	v0, 1
     71  1.2    matt 	move		t0, v0
     72  1.2    matt 	INT_SC		t0, 0(a0)
     73  1.2    matt 	beq		t0, zero, 1b
     74  1.2    matt  	 nop
     75  1.2    matt 	j		ra
     76  1.2    matt 	 nop
     77  1.2    matt END(_atomic_inc_32_nv)
     78  1.2    matt ATOMIC_OP_ALIAS(atomic_inc_32_nv, _atomic_inc_32_nv)
     79  1.2    matt 
     80  1.2    matt #if !defined(__mips_o32)
     81  1.2    matt LEAF(_atomic_inc_64)
     82  1.5    matt #if defined(_MIPS_ARCH_OCTEONP) || defined(_MIPS_ARCH_OCTEON2)
     83  1.5    matt 	li		t0, 1
     84  1.5    matt 	saad		t0, (a0)
     85  1.5    matt #else
     86  1.7   skrll 	LLSCSYNC
     87  1.2    matt 1:	REG_LL		t0, 0(a0)
     88  1.2    matt 	 nop
     89  1.2    matt 	REG_ADDU	t0, 1
     90  1.2    matt 	REG_SC		t0, 0(a0)
     91  1.2    matt 	beq		t0, zero, 1b
     92  1.2    matt  	 nop
     93  1.5    matt #endif
     94  1.2    matt 	j		ra
     95  1.2    matt 	 nop
     96  1.2    matt END(_atomic_inc_64)
     97  1.2    matt ATOMIC_OP_ALIAS(atomic_inc_64, _atomic_inc_64)
     98  1.2    matt 
     99  1.2    matt LEAF(_atomic_inc_64_nv)
    100  1.7   skrll 	LLSCSYNC
    101  1.2    matt 1:	REG_LL		v0, 0(a0)
    102  1.2    matt 	 nop
    103  1.2    matt 	REG_ADDU	v0, 1
    104  1.2    matt 	move		t0, v0
    105  1.2    matt 	REG_SC		t0, 0(a0)
    106  1.2    matt 	beq		t0, zero, 1b
    107  1.2    matt  	 nop
    108  1.2    matt 	j		ra
    109  1.2    matt 	 nop
    110  1.2    matt END(_atomic_inc_64_nv)
    111  1.2    matt ATOMIC_OP_ALIAS(atomic_inc_64_nv, _atomic_inc_64_nv)
    112  1.2    matt #endif
    113  1.2    matt 
    114  1.2    matt #ifdef _LP64
    115  1.2    matt STRONG_ALIAS(_atomic_inc_ptr,		_atomic_inc_64)
    116  1.2    matt STRONG_ALIAS(_atomic_inc_ptr_nv,	_atomic_inc_64_nv)
    117  1.2    matt STRONG_ALIAS(_atomic_inc_ulong,		_atomic_inc_64)
    118  1.2    matt STRONG_ALIAS(_atomic_inc_ulong_nv,	_atomic_inc_64_nv)
    119  1.2    matt #else
    120  1.2    matt STRONG_ALIAS(_atomic_inc_ptr,		_atomic_inc_32)
    121  1.2    matt STRONG_ALIAS(_atomic_inc_ptr_nv,	_atomic_inc_32_nv)
    122  1.2    matt STRONG_ALIAS(_atomic_inc_ulong,		_atomic_inc_32)
    123  1.2    matt STRONG_ALIAS(_atomic_inc_ulong_nv,	_atomic_inc_32_nv)
    124  1.2    matt #endif
    125  1.2    matt STRONG_ALIAS(_atomic_inc_uint,		_atomic_inc_32)
    126  1.2    matt STRONG_ALIAS(_atomic_inc_uint_nv,	_atomic_inc_32_nv)
    127  1.2    matt 
    128  1.2    matt ATOMIC_OP_ALIAS(atomic_inc_ptr,		_atomic_inc_ptr)
    129  1.2    matt ATOMIC_OP_ALIAS(atomic_inc_ptr_nv,	_atomic_inc_ptr_nv)
    130  1.2    matt ATOMIC_OP_ALIAS(atomic_inc_uint,	_atomic_inc_uint)
    131  1.2    matt ATOMIC_OP_ALIAS(atomic_inc_uint_nv,	_atomic_inc_uint_nv)
    132  1.2    matt ATOMIC_OP_ALIAS(atomic_inc_ulong,	_atomic_inc_ulong)
    133  1.2    matt ATOMIC_OP_ALIAS(atomic_inc_ulong_nv,	_atomic_inc_ulong_nv)
    134