diff --git a/common/lib/libc/arch/mips/atomic/atomic_add.S b/common/lib/libc/arch/mips/atomic/atomic_add.S index 30f418856727..886b6d54cf1b 100644 --- a/common/lib/libc/arch/mips/atomic/atomic_add.S +++ b/common/lib/libc/arch/mips/atomic/atomic_add.S @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_add.S,v 1.4 2012/03/14 16:50:34 christos Exp $ */ +/* $NetBSD: atomic_add.S,v 1.5 2015/06/01 23:16:54 matt Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ #include #include "atomic_op_asm.h" -RCSID("$NetBSD: atomic_add.S,v 1.4 2012/03/14 16:50:34 christos Exp $") +RCSID("$NetBSD: atomic_add.S,v 1.5 2015/06/01 23:16:54 matt Exp $") .text .set noreorder @@ -46,12 +46,16 @@ RCSID("$NetBSD: atomic_add.S,v 1.4 2012/03/14 16:50:34 christos Exp $") LEAF(_atomic_add_32) +#if defined(_MIPS_ARCH_OCTEONP) || defined(_MIPS_ARCH_OCTEON2) + saa a1, (a0) +#else 1: INT_LL t0, 0(a0) nop INT_ADDU t0, a1 INT_SC t0, 0(a0) beq t0, zero, 1b nop +#endif j ra nop END(_atomic_add_32) @@ -72,12 +76,16 @@ ATOMIC_OP_ALIAS(atomic_add_32_nv, _atomic_add_32_nv) #if !defined(__mips_o32) LEAF(_atomic_add_64) +#if defined(_MIPS_ARCH_OCTEONP) || defined(_MIPS_ARCH_OCTEON2) + saad a1, (a0) +#else 1: REG_LL t0, 0(a0) nop REG_ADDU t0, a1 REG_SC t0, 0(a0) beq t0, zero, 1b nop +#endif j ra nop END(_atomic_add_64) diff --git a/common/lib/libc/arch/mips/atomic/atomic_cas.S b/common/lib/libc/arch/mips/atomic/atomic_cas.S index 45aec5cb0370..b921c9772bb8 100644 --- a/common/lib/libc/arch/mips/atomic/atomic_cas.S +++ b/common/lib/libc/arch/mips/atomic/atomic_cas.S @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_cas.S,v 1.3 2012/03/14 16:50:34 christos Exp $ */ +/* $NetBSD: atomic_cas.S,v 1.4 2015/06/01 23:16:54 matt Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ #include #include "atomic_op_asm.h" -RCSID("$NetBSD: atomic_cas.S,v 1.3 2012/03/14 16:50:34 christos Exp $") +RCSID("$NetBSD: atomic_cas.S,v 1.4 2015/06/01 23:16:54 matt Exp $") .text .set noat @@ -46,6 +46,9 @@ LEAF(_atomic_cas_32) beq t0, zero, 1b nop move v0, a1 +#ifdef _MIPS_ARCH_OCTEONP + syncw +#endif 2: j ra nop @@ -63,6 +66,9 @@ LEAF(_atomic_cas_64) beq t0, zero, 1b nop move v0, a1 +#ifdef _MIPS_ARCH_OCTEONP + syncw +#endif 2: j ra nop diff --git a/common/lib/libc/arch/mips/atomic/atomic_dec.S b/common/lib/libc/arch/mips/atomic/atomic_dec.S index fdf7fe183383..641ad9b3c73d 100644 --- a/common/lib/libc/arch/mips/atomic/atomic_dec.S +++ b/common/lib/libc/arch/mips/atomic/atomic_dec.S @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_dec.S,v 1.4 2012/03/14 16:50:34 christos Exp $ */ +/* $NetBSD: atomic_dec.S,v 1.5 2015/06/01 23:16:54 matt Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ #include #include "atomic_op_asm.h" -RCSID("$NetBSD: atomic_dec.S,v 1.4 2012/03/14 16:50:34 christos Exp $") +RCSID("$NetBSD: atomic_dec.S,v 1.5 2015/06/01 23:16:54 matt Exp $") .text .set noreorder @@ -45,12 +45,17 @@ RCSID("$NetBSD: atomic_dec.S,v 1.4 2012/03/14 16:50:34 christos Exp $") #endif /* _KERNEL_OPT */ LEAF(_atomic_dec_32) +#if defined(_MIPS_ARCH_OCTEONP) || defined(_MIPS_ARCH_OCTEON2) + li t0, -1 + saa t0, (a0) +#else 1: INT_LL t0, 0(a0) nop INT_ADDU t0, -1 INT_SC t0, 0(a0) beq t0, zero, 1b nop +#endif j ra nop END(_atomic_dec_32) @@ -71,12 +76,17 @@ ATOMIC_OP_ALIAS(atomic_dec_32_nv, _atomic_dec_32_nv) #if !defined(__mips_o32) LEAF(_atomic_dec_64) +#if defined(_MIPS_ARCH_OCTEONP) || defined(_MIPS_ARCH_OCTEON2) + li t0, -1 + saad t0, (a0) +#else 1: REG_LL t0, 0(a0) nop REG_ADDU t0, -1 REG_SC t0, 0(a0) beq t0, zero, 1b nop +#endif j ra nop END(_atomic_dec_64) diff --git a/common/lib/libc/arch/mips/atomic/atomic_inc.S b/common/lib/libc/arch/mips/atomic/atomic_inc.S index 9a86fa142c2e..40fadb8c45d1 100644 --- a/common/lib/libc/arch/mips/atomic/atomic_inc.S +++ b/common/lib/libc/arch/mips/atomic/atomic_inc.S @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_inc.S,v 1.4 2012/03/14 16:50:34 christos Exp $ */ +/* $NetBSD: atomic_inc.S,v 1.5 2015/06/01 23:16:54 matt Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ #include #include "atomic_op_asm.h" -RCSID("$NetBSD: atomic_inc.S,v 1.4 2012/03/14 16:50:34 christos Exp $") +RCSID("$NetBSD: atomic_inc.S,v 1.5 2015/06/01 23:16:54 matt Exp $") .text .set noreorder @@ -46,12 +46,17 @@ RCSID("$NetBSD: atomic_inc.S,v 1.4 2012/03/14 16:50:34 christos Exp $") LEAF(_atomic_inc_32) +#if defined(_MIPS_ARCH_OCTEONP) || defined(_MIPS_ARCH_OCTEON2) + li t0, 1 + saa t0, (a0) +#else 1: INT_LL t0, 0(a0) nop INT_ADDU t0, 1 INT_SC t0, 0(a0) beq t0, zero, 1b nop +#endif j ra nop END(_atomic_inc_32) @@ -72,12 +77,17 @@ ATOMIC_OP_ALIAS(atomic_inc_32_nv, _atomic_inc_32_nv) #if !defined(__mips_o32) LEAF(_atomic_inc_64) +#if defined(_MIPS_ARCH_OCTEONP) || defined(_MIPS_ARCH_OCTEON2) + li t0, 1 + saad t0, (a0) +#else 1: REG_LL t0, 0(a0) nop REG_ADDU t0, 1 REG_SC t0, 0(a0) beq t0, zero, 1b nop +#endif j ra nop END(_atomic_inc_64) diff --git a/common/lib/libc/arch/mips/atomic/atomic_op_asm.h b/common/lib/libc/arch/mips/atomic/atomic_op_asm.h index 34bdd3bea6d0..4caa77a08ef5 100644 --- a/common/lib/libc/arch/mips/atomic/atomic_op_asm.h +++ b/common/lib/libc/arch/mips/atomic/atomic_op_asm.h @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_op_asm.h,v 1.2 2008/04/28 20:22:52 martin Exp $ */ +/* $NetBSD: atomic_op_asm.h,v 1.3 2015/06/01 23:16:54 matt Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -44,4 +44,10 @@ #endif /* _KERNEL */ +#ifdef __OCTEON__ +#define SYNCW syncw +#else +#define SYNCW nop +#endif + #endif /* _ATOMIC_OP_ASM_H_ */ diff --git a/common/lib/libc/arch/mips/atomic/atomic_swap.S b/common/lib/libc/arch/mips/atomic/atomic_swap.S index e43ba88bd41f..591665ff67ad 100644 --- a/common/lib/libc/arch/mips/atomic/atomic_swap.S +++ b/common/lib/libc/arch/mips/atomic/atomic_swap.S @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_swap.S,v 1.4 2012/03/14 16:50:34 christos Exp $ */ +/* $NetBSD: atomic_swap.S,v 1.5 2015/06/01 23:16:54 matt Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ #include #include "atomic_op_asm.h" -RCSID("$NetBSD: atomic_swap.S,v 1.4 2012/03/14 16:50:34 christos Exp $") +RCSID("$NetBSD: atomic_swap.S,v 1.5 2015/06/01 23:16:54 matt Exp $") .text .set noreorder @@ -54,7 +54,7 @@ LEAF(_atomic_swap_32) nop 2: j ra - nop + SYNCW END(_atomic_swap_32) ATOMIC_OP_ALIAS(atomic_swap_32, _atomic_swap_32) @@ -68,7 +68,7 @@ LEAF(_atomic_swap_64) nop 2: j ra - nop + SYNCW END(_atomic_swap_64) ATOMIC_OP_ALIAS(atomic_swap_64, _atomic_swap_64) #endif diff --git a/common/lib/libc/arch/mips/atomic/membar_ops.S b/common/lib/libc/arch/mips/atomic/membar_ops.S index 2f64ba6cb9d6..edafe2f3d0b0 100644 --- a/common/lib/libc/arch/mips/atomic/membar_ops.S +++ b/common/lib/libc/arch/mips/atomic/membar_ops.S @@ -1,4 +1,4 @@ -/* $NetBSD: membar_ops.S,v 1.5 2012/08/03 06:06:44 matt Exp $ */ +/* $NetBSD: membar_ops.S,v 1.6 2015/06/01 23:16:54 matt Exp $ */ /*- * Copyright (c) 2006, 2007 The NetBSD Foundation, Inc. @@ -61,18 +61,35 @@ LEAF(_membar_sync) #endif END(_membar_sync) +#ifdef __OCTEON__ +LEAF(_membar_producer) + j ra + syncw +END(_membar_producer) +#endif + #ifdef _KERNEL STRONG_ALIAS(mb_read, _membar_sync) +#ifdef __OCTEON__ +STRONG_ALIAS(mb_write, _membar_producer) +#else STRONG_ALIAS(mb_write, _membar_sync) +#endif STRONG_ALIAS(mb_memory, _membar_sync) #endif ATOMIC_OP_ALIAS(membar_sync,_membar_sync) ATOMIC_OP_ALIAS(membar_enter,_membar_sync) STRONG_ALIAS(_membar_enter,_membar_sync) +#ifdef __OCTEON__ +ATOMIC_OP_ALIAS(membar_exit,_membar_producer) +STRONG_ALIAS(_membar_exit,_membar_producer) +STRONG_ALIAS(membar_producer,_membar_producer) +#else ATOMIC_OP_ALIAS(membar_exit,_membar_sync) STRONG_ALIAS(_membar_exit,_membar_sync) ATOMIC_OP_ALIAS(membar_producer,_membar_sync) STRONG_ALIAS(_membar_producer,_membar_sync) +#endif ATOMIC_OP_ALIAS(membar_consumer,_membar_sync) STRONG_ALIAS(_membar_consumer,_membar_sync)