atomic_dec.S revision 1.3
11.3Sbouyer/* $NetBSD: atomic_dec.S,v 1.3 2011/08/27 13:23:52 bouyer Exp $ */ 21.2Smatt 31.2Smatt/*- 41.2Smatt * Copyright (c) 2008 The NetBSD Foundation, Inc. 51.2Smatt * All rights reserved. 61.2Smatt * 71.2Smatt * Redistribution and use in source and binary forms, with or without 81.2Smatt * modification, are permitted provided that the following conditions 91.2Smatt * are met: 101.2Smatt * 1. Redistributions of source code must retain the above copyright 111.2Smatt * notice, this list of conditions and the following disclaimer. 121.2Smatt * 2. Redistributions in binary form must reproduce the above copyright 131.2Smatt * notice, this list of conditions and the following disclaimer in the 141.2Smatt * documentation and/or other materials provided with the distribution. 151.2Smatt * 161.2Smatt * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 171.2Smatt * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 181.2Smatt * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 191.2Smatt * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 201.2Smatt * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 211.2Smatt * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 221.2Smatt * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 231.2Smatt * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 241.2Smatt * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 251.2Smatt * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 261.2Smatt * POSSIBILITY OF SUCH DAMAGE. 271.2Smatt */ 281.2Smatt 291.2Smatt#include <sys/cdefs.h> 301.2Smatt#include <machine/asm.h> 311.2Smatt#include "atomic_op_asm.h" 321.2Smatt 331.3SbouyerRCSID("$NetBSD: atomic_dec.S,v 1.3 2011/08/27 13:23:52 bouyer Exp $") 341.2Smatt 351.2Smatt .text 361.3Sbouyer .set noreorder 371.3Sbouyer#ifdef _KERNEL_OPT 381.3Sbouyer#include "opt_cputype.h" 391.3Sbouyer#ifndef MIPS3_LOONGSON2F 401.3Sbouyer .set noat 411.3Sbouyer .set nomacro 421.3Sbouyer#endif 431.3Sbouyer#else /* _KERNEL_OPT */ 441.2Smatt .set noat 451.2Smatt .set nomacro 461.3Sbouyer#endif /* _KERNEL_OPT */ 471.2Smatt 481.2SmattLEAF(_atomic_dec_32) 491.2Smatt1: INT_LL t0, 0(a0) 501.2Smatt nop 511.2Smatt INT_ADDU t0, -1 521.2Smatt INT_SC t0, 0(a0) 531.2Smatt beq t0, zero, 1b 541.2Smatt nop 551.2Smatt j ra 561.2Smatt nop 571.2SmattEND(_atomic_dec_32) 581.2SmattATOMIC_OP_ALIAS(atomic_dec_32, _atomic_dec_32) 591.2Smatt 601.2SmattLEAF(_atomic_dec_32_nv) 611.2Smatt1: INT_LL v0, 0(a0) 621.2Smatt nop 631.2Smatt INT_ADDU v0, -1 641.2Smatt move t0, v0 651.2Smatt INT_SC t0, 0(a0) 661.2Smatt beq t0, zero, 1b 671.2Smatt nop 681.2Smatt j ra 691.2Smatt nop 701.2SmattEND(_atomic_dec_32_nv) 711.2SmattATOMIC_OP_ALIAS(atomic_dec_32_nv, _atomic_dec_32_nv) 721.2Smatt 731.2Smatt#if !defined(__mips_o32) 741.2SmattLEAF(_atomic_dec_64) 751.2Smatt1: REG_LL t0, 0(a0) 761.2Smatt nop 771.2Smatt REG_ADDU t0, -1 781.2Smatt REG_SC t0, 0(a0) 791.2Smatt beq t0, zero, 1b 801.2Smatt nop 811.2Smatt j ra 821.2Smatt nop 831.2SmattEND(_atomic_dec_64) 841.2SmattATOMIC_OP_ALIAS(atomic_dec_64, _atomic_dec_64) 851.2Smatt 861.2SmattLEAF(_atomic_dec_64_nv) 871.2Smatt1: REG_LL v0, 0(a0) 881.2Smatt nop 891.2Smatt REG_ADDU v0, -1 901.2Smatt move t0, v0 911.2Smatt REG_SC t0, 0(a0) 921.2Smatt beq t0, zero, 1b 931.2Smatt nop 941.2Smatt j ra 951.2Smatt nop 961.2SmattEND(_atomic_dec_64_nv) 971.2SmattATOMIC_OP_ALIAS(atomic_dec_64_nv, _atomic_dec_64_nv) 981.2Smatt#endif 991.2Smatt 1001.2Smatt#ifdef _LP64 1011.2SmattSTRONG_ALIAS(_atomic_dec_ptr, _atomic_dec_64) 1021.2SmattSTRONG_ALIAS(_atomic_dec_ptr_nv, _atomic_dec_64_nv) 1031.2SmattSTRONG_ALIAS(_atomic_dec_ulong, _atomic_dec_64) 1041.2SmattSTRONG_ALIAS(_atomic_dec_ulong_nv, _atomic_dec_64_nv) 1051.2Smatt#else 1061.2SmattSTRONG_ALIAS(_atomic_dec_ptr, _atomic_dec_32) 1071.2SmattSTRONG_ALIAS(_atomic_dec_ptr_nv, _atomic_dec_32_nv) 1081.2SmattSTRONG_ALIAS(_atomic_dec_ulong, _atomic_dec_32) 1091.2SmattSTRONG_ALIAS(_atomic_dec_ulong_nv, _atomic_dec_32_nv) 1101.2Smatt#endif 1111.2SmattSTRONG_ALIAS(_atomic_dec_uint, _atomic_dec_32) 1121.2SmattSTRONG_ALIAS(_atomic_dec_uint_nv, _atomic_dec_32_nv) 1131.2Smatt 1141.2SmattATOMIC_OP_ALIAS(atomic_dec_ptr, _atomic_dec_ptr) 1151.2SmattATOMIC_OP_ALIAS(atomic_dec_ptr_nv, _atomic_dec_ptr_nv) 1161.2SmattATOMIC_OP_ALIAS(atomic_dec_uint, _atomic_dec_uint) 1171.2SmattATOMIC_OP_ALIAS(atomic_dec_uint_nv, _atomic_dec_uint_nv) 1181.2SmattATOMIC_OP_ALIAS(atomic_dec_ulong, _atomic_dec_ulong) 1191.2SmattATOMIC_OP_ALIAS(atomic_dec_ulong_nv, _atomic_dec_ulong_nv) 120