Mon Dec 14 00:39:01 2009 UTC ()
Merge from matt-nb5-mips64
(matt)
diff -r1.9 -r1.10 src/common/lib/libc/arch/mips/atomic/Makefile.inc
diff -r0 -r1.2 src/common/lib/libc/arch/mips/atomic/atomic_add.S
diff -r0 -r1.2 src/common/lib/libc/arch/mips/atomic/atomic_and.S
diff -r0 -r1.2 src/common/lib/libc/arch/mips/atomic/atomic_cas.S
diff -r0 -r1.2 src/common/lib/libc/arch/mips/atomic/atomic_dec.S
diff -r0 -r1.2 src/common/lib/libc/arch/mips/atomic/atomic_inc.S
diff -r0 -r1.2 src/common/lib/libc/arch/mips/atomic/atomic_or.S
diff -r0 -r1.2 src/common/lib/libc/arch/mips/atomic/atomic_swap.S
diff -r1.3 -r1.4 src/common/lib/libc/arch/mips/atomic/membar_ops.S
diff -r1.2 -r1.3 src/common/lib/libc/arch/mips/gen/byte_swap_2.S
diff -r1.2 -r1.3 src/common/lib/libc/arch/mips/gen/byte_swap_4.S
diff -r0 -r1.2 src/common/lib/libc/arch/mips/gen/byte_swap_8.S
diff -r1.2 -r1.3 src/common/lib/libc/arch/mips/string/bcopy.S
diff -r1.1 -r1.2 src/common/lib/libc/arch/mips/string/ffs.S
diff -r1.1 -r1.2 src/common/lib/libc/arch/mips/string/strcmp.S
diff -r1.1 -r1.2 src/common/lib/libc/arch/mips/string/strlen.S
diff -r1.1 -r0 src/common/lib/libc/arch/mips/string/memset.S
diff -r1.6 -r1.7 src/common/lib/libc/atomic/atomic_init_testset.c
diff -r0 -r1.2 src/common/lib/libc/string/bzero2.c
diff -r0 -r1.2 src/common/lib/libc/string/memset2.c
--- src/common/lib/libc/arch/mips/atomic/Makefile.inc 2009/01/04 17:54:29 1.9
+++ src/common/lib/libc/arch/mips/atomic/Makefile.inc 2009/12/14 00:38:59 1.10
| @@ -1,28 +1,45 @@ | | | @@ -1,28 +1,45 @@ |
1 | # $NetBSD: Makefile.inc,v 1.9 2009/01/04 17:54:29 pooka Exp $ | | 1 | # $NetBSD: Makefile.inc,v 1.10 2009/12/14 00:38:59 matt Exp $ |
2 | | | 2 | |
3 | .if defined(LIB) && (${LIB} == "kern" || ${LIB} == "c" || ${LIB} == "pthread" \ | | 3 | .if defined(LIB) && (${LIB} == "kern" || ${LIB} == "c" || ${LIB} == "pthread" \ |
4 | || ${LIB} == "rump") | | 4 | || ${LIB} == "rump") |
5 | | | 5 | |
6 | SRCS+= atomic_add_32_cas.c atomic_add_32_nv_cas.c atomic_and_32_cas.c \ | | 6 | .if ${MACHINE_ARCH:Mmips64*} == "" |
7 | atomic_and_32_nv_cas.c atomic_dec_32_cas.c atomic_dec_32_nv_cas.c \ | | 7 | SRCS+= atomic_add_32_cas.c atomic_add_32_nv_cas.c \ |
8 | atomic_inc_32_cas.c atomic_inc_32_nv_cas.c atomic_or_32_cas.c \ | | 8 | atomic_and_32_cas.c atomic_and_32_nv_cas.c \ |
9 | atomic_or_32_nv_cas.c atomic_swap_32_cas.c atomic_add_64_cas.c \ | | 9 | atomic_dec_32_cas.c atomic_dec_32_nv_cas.c \ |
10 | atomic_add_64_nv_cas.c atomic_and_64_cas.c atomic_and_64_nv_cas.c \ | | 10 | atomic_inc_32_cas.c atomic_inc_32_nv_cas.c \ |
11 | atomic_dec_64_cas.c atomic_dec_64_nv_cas.c atomic_inc_64_cas.c \ | | 11 | atomic_or_32_cas.c atomic_or_32_nv_cas.c \ |
12 | atomic_inc_64_nv_cas.c atomic_or_64_cas.c atomic_or_64_nv_cas.c \ | | 12 | atomic_swap_32_cas.c \ |
13 | atomic_swap_64_cas.c membar_ops.o | | 13 | atomic_add_64_cas.c atomic_add_64_nv_cas.c \ |
| | | 14 | atomic_and_64_cas.c atomic_and_64_nv_cas.c \ |
| | | 15 | atomic_dec_64_cas.c atomic_dec_64_nv_cas.c \ |
| | | 16 | atomic_inc_64_cas.c atomic_inc_64_nv_cas.c \ |
| | | 17 | atomic_or_64_cas.c atomic_or_64_nv_cas.c \ |
| | | 18 | atomic_swap_64_cas.c |
14 | | | 19 | |
| | | 20 | CPPFLAGS+= -D__HAVE_ASM_ATOMIC_CAS_UP |
| | | 21 | |
| | | 22 | .else |
| | | 23 | SRCS+= atomic_add.S atomic_dec.S atomic_inc.S |
| | | 24 | SRCS+= atomic_and.S atomic_or.S |
| | | 25 | SRCS+= atomic_swap.S |
| | | 26 | .endif |
| | | 27 | |
| | | 28 | SRCS+= membar_ops.S |
15 | .endif | | 29 | .endif |
16 | | | 30 | |
17 | .if defined(LIB) && (${LIB} == "c" || ${LIB} == "pthread") | | 31 | .if defined(LIB) && (${LIB} == "c" || ${LIB} == "pthread") |
18 | | | 32 | |
19 | SRCS+= membar_ops_nop.c atomic_init_testset.c atomic_cas_up.S | | 33 | .if ${MACHINE_ARCH:Mmips64*} == "" |
20 | CPPFLAGS+= -D__HAVE_ASM_ATOMIC_CAS_UP | | 34 | SRCS+= atomic_init_testset.c atomic_cas_up.S |
| | | 35 | .else |
| | | 36 | SRCS+= atomic_cas.S atomic_init_cas.c |
| | | 37 | .endif |
21 | | | 38 | |
22 | .endif | | 39 | .endif |
23 | | | 40 | |
24 | .if defined(LIB) && (${LIB} == "kern" || ${LIB} == "rump") | | 41 | .if defined(LIB) && (${LIB} == "kern" || ${LIB} == "rump") |
25 | | | 42 | |
26 | SRCS+= membar_ops.S | | 43 | SRCS+= membar_ops.S |
27 | | | 44 | |
28 | .endif | | 45 | .endif |
/* $NetBSD: atomic_add.S,v 1.2 2009/12/14 00:38:59 matt Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <machine/asm.h>
#include "atomic_op_asm.h"
RCSID("$NetBSD: atomic_add.S,v 1.2 2009/12/14 00:38:59 matt Exp $")
.text
.set noat
.set noreorder
.set nomacro
LEAF(_atomic_add_32)
1: INT_LL t0, 0(a0)
nop
INT_ADDU t0, a1
INT_SC t0, 0(a0)
beq t0, zero, 1b
nop
j ra
nop
END(_atomic_add_32)
ATOMIC_OP_ALIAS(atomic_add_32, _atomic_add_32)
LEAF(_atomic_add_32_nv)
1: INT_LL v0, 0(a0)
nop
INT_ADDU v0, a1
move t0, v0
INT_SC t0, 0(a0)
beq t0, zero, 1b
nop
j ra
nop
END(_atomic_add_32_nv)
ATOMIC_OP_ALIAS(atomic_add_32_nv, _atomic_add_32_nv)
#if !defined(__mips_o32)
LEAF(_atomic_add_64)
1: REG_LL t0, 0(a0)
nop
REG_ADDU t0, a1
REG_SC t0, 0(a0)
beq t0, zero, 1b
nop
j ra
nop
END(_atomic_add_64)
ATOMIC_OP_ALIAS(atomic_add_64, _atomic_add_64)
LEAF(_atomic_add_64_nv)
1: REG_LL v0, 0(a0)
nop
REG_ADDU v0, a1
move t0, v0
REG_SC t0, 0(a0)
beq t0, zero, 1b
nop
j ra
nop
END(_atomic_add_64_nv)
ATOMIC_OP_ALIAS(atomic_add_64_nv, _atomic_add_64_nv)
#endif
#ifdef _LP64
STRONG_ALIAS(_atomic_add_long, _atomic_add_64)
STRONG_ALIAS(_atomic_add_long_nv, _atomic_add_64_nv)
STRONG_ALIAS(_atomic_add_ptr, _atomic_add_64)
STRONG_ALIAS(_atomic_add_ptr_nv, _atomic_add_64_nv)
#else
STRONG_ALIAS(_atomic_add_long, _atomic_add_32)
STRONG_ALIAS(_atomic_add_long_nv, _atomic_add_32_nv)
STRONG_ALIAS(_atomic_add_ptr, _atomic_add_32)
STRONG_ALIAS(_atomic_add_ptr_nv, _atomic_add_32_nv)
#endif
STRONG_ALIAS(_atomic_add_int, _atomic_add_32)
STRONG_ALIAS(_atomic_add_int_nv, _atomic_add_32_nv)
ATOMIC_OP_ALIAS(atomic_add_int, _atomic_add_int)
ATOMIC_OP_ALIAS(atomic_add_int_nv, _atomic_add_int_nv)
ATOMIC_OP_ALIAS(atomic_add_ptr, _atomic_add_ptr)
ATOMIC_OP_ALIAS(atomic_add_ptr_nv, _atomic_add_ptr_nv)
ATOMIC_OP_ALIAS(atomic_add_long, _atomic_add_long)
ATOMIC_OP_ALIAS(atomic_add_long_nv, _atomic_add_long_nv)
/* $NetBSD: atomic_and.S,v 1.2 2009/12/14 00:38:59 matt Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <machine/asm.h>
#include "atomic_op_asm.h"
RCSID("$NetBSD: atomic_and.S,v 1.2 2009/12/14 00:38:59 matt Exp $")
.text
.set noat
.set noreorder
.set nomacro
LEAF(_atomic_and_32)
1: INT_LL t0, 0(a0)
nop
and t0, a1
INT_SC t0, 0(a0)
beq t0, zero, 1b
nop
j ra
nop
END(_atomic_and_32)
ATOMIC_OP_ALIAS(atomic_and_32, _atomic_and_32)
LEAF(_atomic_and_32_nv)
1: INT_LL v0, 0(a0)
nop
and v0, a1
move t0, v0
INT_SC t0, 0(a0)
beq t0, zero, 1b
nop
j ra
nop
END(_atomic_and_32_nv)
ATOMIC_OP_ALIAS(atomic_and_32_nv, _atomic_and_32_nv)
#if !defined(__mips_o32)
LEAF(_atomic_and_64)
1: REG_LL t0, 0(a0)
nop
and t0, a1
REG_SC t0, 0(a0)
beq t0, zero, 1b
nop
j ra
nop
END(_atomic_and_64)
ATOMIC_OP_ALIAS(atomic_and_64, _atomic_and_64)
LEAF(_atomic_and_64_nv)
1: REG_LL v0, 0(a0)
nop
and v0, a1
move t0, v0
REG_SC t0, 0(a0)
beq t0, zero, 1b
nop
j ra
nop
END(_atomic_and_64_nv)
ATOMIC_OP_ALIAS(atomic_and_64_nv, _atomic_and_64_nv)
#endif
#ifdef _LP64
STRONG_ALIAS(_atomic_and_ulong, _atomic_and_64)
STRONG_ALIAS(_atomic_and_ulong_nv, _atomic_and_64_nv)
#else
STRONG_ALIAS(_atomic_and_ulong, _atomic_and_32)
STRONG_ALIAS(_atomic_and_ulong_nv, _atomic_and_32_nv)
#endif
STRONG_ALIAS(_atomic_and_uint, _atomic_and_32)
STRONG_ALIAS(_atomic_and_uint_nv, _atomic_and_32_nv)
ATOMIC_OP_ALIAS(atomic_and_uint, _atomic_and_uint)
ATOMIC_OP_ALIAS(atomic_and_uint_nv, _atomic_and_uint_nv)
ATOMIC_OP_ALIAS(atomic_and_ulong, _atomic_and_ulong)
ATOMIC_OP_ALIAS(atomic_and_ulong_nv, _atomic_and_ulong_nv)
/* $NetBSD: atomic_cas.S,v 1.2 2009/12/14 00:39:00 matt Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <machine/asm.h>
#include "atomic_op_asm.h"
RCSID("$NetBSD: atomic_cas.S,v 1.2 2009/12/14 00:39:00 matt Exp $")
.text
.set noat
.set noreorder
.set nomacro
LEAF(_atomic_cas_32)
1: INT_LL v0, 0(a0)
nop
bne v0, a1, 2f
nop
move t0, a2
INT_SC t0, 0(a0)
beq t0, zero, 1b
nop
move v0, a1
2:
j ra
nop
END(_atomic_cas_32)
ATOMIC_OP_ALIAS(atomic_cas_32, _atomic_cas_32)
#if !defined(__mips_o32)
LEAF(_atomic_cas_64)
1: REG_LL v0, 0(a0)
nop
bne v0, a1, 2f
nop
move t0, a2
REG_SC t0, 0(a0)
beq t0, zero, 1b
nop
move v0, a1
2:
j ra
nop
END(_atomic_cas_64)
ATOMIC_OP_ALIAS(atomic_cas_64, _atomic_cas_64)
#endif
#ifdef _LP64
STRONG_ALIAS(_atomic_cas_ptr, _atomic_cas_64)
STRONG_ALIAS(_atomic_cas_ptr_ni, _atomic_cas_64)
STRONG_ALIAS(_atomic_cas_ulong, _atomic_cas_64)
STRONG_ALIAS(_atomic_cas_ulong_ni, _atomic_cas_64)
#else
STRONG_ALIAS(_atomic_cas_ptr, _atomic_cas_32)
STRONG_ALIAS(_atomic_cas_ptr_ni, _atomic_cas_32)
STRONG_ALIAS(_atomic_cas_ulong, _atomic_cas_32)
STRONG_ALIAS(_atomic_cas_ulong_ni, _atomic_cas_32)
#endif
STRONG_ALIAS(_atomic_cas_uint, _atomic_cas_32)
STRONG_ALIAS(_atomic_cas_uint_ni, _atomic_cas_32)
ATOMIC_OP_ALIAS(atomic_cas_ptr, _atomic_cas_ptr)
ATOMIC_OP_ALIAS(atomic_cas_ptr_ni, _atomic_cas_ptr_ni)
ATOMIC_OP_ALIAS(atomic_cas_uint, _atomic_cas_uint)
ATOMIC_OP_ALIAS(atomic_cas_uint_ni, _atomic_cas_uint_ni)
ATOMIC_OP_ALIAS(atomic_cas_ulong, _atomic_cas_ulong)
ATOMIC_OP_ALIAS(atomic_cas_ulong_ni, _atomic_cas_ulong_ni)
/* $NetBSD: atomic_dec.S,v 1.2 2009/12/14 00:39:00 matt Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <machine/asm.h>
#include "atomic_op_asm.h"
RCSID("$NetBSD: atomic_dec.S,v 1.2 2009/12/14 00:39:00 matt Exp $")
.text
.set noat
.set noreorder
.set nomacro
LEAF(_atomic_dec_32)
1: INT_LL t0, 0(a0)
nop
INT_ADDU t0, -1
INT_SC t0, 0(a0)
beq t0, zero, 1b
nop
j ra
nop
END(_atomic_dec_32)
ATOMIC_OP_ALIAS(atomic_dec_32, _atomic_dec_32)
LEAF(_atomic_dec_32_nv)
1: INT_LL v0, 0(a0)
nop
INT_ADDU v0, -1
move t0, v0
INT_SC t0, 0(a0)
beq t0, zero, 1b
nop
j ra
nop
END(_atomic_dec_32_nv)
ATOMIC_OP_ALIAS(atomic_dec_32_nv, _atomic_dec_32_nv)
#if !defined(__mips_o32)
LEAF(_atomic_dec_64)
1: REG_LL t0, 0(a0)
nop
REG_ADDU t0, -1
REG_SC t0, 0(a0)
beq t0, zero, 1b
nop
j ra
nop
END(_atomic_dec_64)
ATOMIC_OP_ALIAS(atomic_dec_64, _atomic_dec_64)
LEAF(_atomic_dec_64_nv)
1: REG_LL v0, 0(a0)
nop
REG_ADDU v0, -1
move t0, v0
REG_SC t0, 0(a0)
beq t0, zero, 1b
nop
j ra
nop
END(_atomic_dec_64_nv)
ATOMIC_OP_ALIAS(atomic_dec_64_nv, _atomic_dec_64_nv)
#endif
#ifdef _LP64
STRONG_ALIAS(_atomic_dec_ptr, _atomic_dec_64)
STRONG_ALIAS(_atomic_dec_ptr_nv, _atomic_dec_64_nv)
STRONG_ALIAS(_atomic_dec_ulong, _atomic_dec_64)
STRONG_ALIAS(_atomic_dec_ulong_nv, _atomic_dec_64_nv)
#else
STRONG_ALIAS(_atomic_dec_ptr, _atomic_dec_32)
STRONG_ALIAS(_atomic_dec_ptr_nv, _atomic_dec_32_nv)
STRONG_ALIAS(_atomic_dec_ulong, _atomic_dec_32)
STRONG_ALIAS(_atomic_dec_ulong_nv, _atomic_dec_32_nv)
#endif
STRONG_ALIAS(_atomic_dec_uint, _atomic_dec_32)
STRONG_ALIAS(_atomic_dec_uint_nv, _atomic_dec_32_nv)
ATOMIC_OP_ALIAS(atomic_dec_ptr, _atomic_dec_ptr)
ATOMIC_OP_ALIAS(atomic_dec_ptr_nv, _atomic_dec_ptr_nv)
ATOMIC_OP_ALIAS(atomic_dec_uint, _atomic_dec_uint)
ATOMIC_OP_ALIAS(atomic_dec_uint_nv, _atomic_dec_uint_nv)
ATOMIC_OP_ALIAS(atomic_dec_ulong, _atomic_dec_ulong)
ATOMIC_OP_ALIAS(atomic_dec_ulong_nv, _atomic_dec_ulong_nv)
/* $NetBSD: atomic_inc.S,v 1.2 2009/12/14 00:39:00 matt Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <machine/asm.h>
#include "atomic_op_asm.h"
RCSID("$NetBSD: atomic_inc.S,v 1.2 2009/12/14 00:39:00 matt Exp $")
.text
.set noat
.set noreorder
.set nomacro
LEAF(_atomic_inc_32)
1: INT_LL t0, 0(a0)
nop
INT_ADDU t0, 1
INT_SC t0, 0(a0)
beq t0, zero, 1b
nop
j ra
nop
END(_atomic_inc_32)
ATOMIC_OP_ALIAS(atomic_inc_32, _atomic_inc_32)
LEAF(_atomic_inc_32_nv)
1: INT_LL v0, 0(a0)
nop
INT_ADDU v0, 1
move t0, v0
INT_SC t0, 0(a0)
beq t0, zero, 1b
nop
j ra
nop
END(_atomic_inc_32_nv)
ATOMIC_OP_ALIAS(atomic_inc_32_nv, _atomic_inc_32_nv)
#if !defined(__mips_o32)
LEAF(_atomic_inc_64)
1: REG_LL t0, 0(a0)
nop
REG_ADDU t0, 1
REG_SC t0, 0(a0)
beq t0, zero, 1b
nop
j ra
nop
END(_atomic_inc_64)
ATOMIC_OP_ALIAS(atomic_inc_64, _atomic_inc_64)
LEAF(_atomic_inc_64_nv)
1: REG_LL v0, 0(a0)
nop
REG_ADDU v0, 1
move t0, v0
REG_SC t0, 0(a0)
beq t0, zero, 1b
nop
j ra
nop
END(_atomic_inc_64_nv)
ATOMIC_OP_ALIAS(atomic_inc_64_nv, _atomic_inc_64_nv)
#endif
#ifdef _LP64
STRONG_ALIAS(_atomic_inc_ptr, _atomic_inc_64)
STRONG_ALIAS(_atomic_inc_ptr_nv, _atomic_inc_64_nv)
STRONG_ALIAS(_atomic_inc_ulong, _atomic_inc_64)
STRONG_ALIAS(_atomic_inc_ulong_nv, _atomic_inc_64_nv)
#else
STRONG_ALIAS(_atomic_inc_ptr, _atomic_inc_32)
STRONG_ALIAS(_atomic_inc_ptr_nv, _atomic_inc_32_nv)
STRONG_ALIAS(_atomic_inc_ulong, _atomic_inc_32)
STRONG_ALIAS(_atomic_inc_ulong_nv, _atomic_inc_32_nv)
#endif
STRONG_ALIAS(_atomic_inc_uint, _atomic_inc_32)
STRONG_ALIAS(_atomic_inc_uint_nv, _atomic_inc_32_nv)
ATOMIC_OP_ALIAS(atomic_inc_ptr, _atomic_inc_ptr)
ATOMIC_OP_ALIAS(atomic_inc_ptr_nv, _atomic_inc_ptr_nv)
ATOMIC_OP_ALIAS(atomic_inc_uint, _atomic_inc_uint)
ATOMIC_OP_ALIAS(atomic_inc_uint_nv, _atomic_inc_uint_nv)
ATOMIC_OP_ALIAS(atomic_inc_ulong, _atomic_inc_ulong)
ATOMIC_OP_ALIAS(atomic_inc_ulong_nv, _atomic_inc_ulong_nv)
/* $NetBSD: atomic_or.S,v 1.2 2009/12/14 00:39:00 matt Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <machine/asm.h>
#include "atomic_op_asm.h"
.text
.set noat
.set noreorder
.set nomacro
LEAF(_atomic_or_32)
1: INT_LL t0, 0(a0)
nop
or t0, a1
INT_SC t0, 0(a0)
beq t0, zero, 1b
nop
j ra
nop
END(_atomic_or_32)
ATOMIC_OP_ALIAS(atomic_or_32, _atomic_or_32)
LEAF(_atomic_or_32_nv)
1: INT_LL v0, 0(a0)
nop
or v0, a1
move t0, v0
INT_SC t0, 0(a0)
beq t0, zero, 1b
nop
j ra
nop
END(_atomic_or_32_nv)
ATOMIC_OP_ALIAS(atomic_or_32_nv, _atomic_or_32_nv)
#if !defined(__mips_o32)
LEAF(_atomic_or_64)
1: REG_LL t0, 0(a0)
nop
or t0, a1
REG_SC t0, 0(a0)
beq t0, zero, 1b
nop
j ra
nop
END(_atomic_or_64)
ATOMIC_OP_ALIAS(atomic_or_64, _atomic_or_64)
LEAF(_atomic_or_64_nv)
1: REG_LL v0, 0(a0)
nop
or v0, a1
move t0, v0
REG_SC t0, 0(a0)
beq t0, zero, 1b
nop
j ra
nop
END(_atomic_or_64_nv)
ATOMIC_OP_ALIAS(atomic_or_64_nv, _atomic_or_64_nv)
#endif
#ifdef _LP64
STRONG_ALIAS(_atomic_or_ulong, _atomic_or_64)
STRONG_ALIAS(_atomic_or_ulong_nv, _atomic_or_64_nv)
#else
STRONG_ALIAS(_atomic_or_ulong, _atomic_or_32)
STRONG_ALIAS(_atomic_or_ulong_nv, _atomic_or_32_nv)
#endif
STRONG_ALIAS(_atomic_or_uint, _atomic_or_32)
STRONG_ALIAS(_atomic_or_uint_nv, _atomic_or_32_nv)
ATOMIC_OP_ALIAS(atomic_or_uint, _atomic_or_uint)
ATOMIC_OP_ALIAS(atomic_or_uint_nv, _atomic_or_uint_nv)
ATOMIC_OP_ALIAS(atomic_or_ulong, _atomic_or_ulong)
ATOMIC_OP_ALIAS(atomic_or_ulong_nv, _atomic_or_ulong_nv)
/* $NetBSD: atomic_swap.S,v 1.2 2009/12/14 00:39:00 matt Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <machine/asm.h>
#include "atomic_op_asm.h"
RCSID("$NetBSD: atomic_swap.S,v 1.2 2009/12/14 00:39:00 matt Exp $")
.text
.set noat
.set noreorder
.set nomacro
LEAF(_atomic_swap_32)
1: INT_LL v0, 0(a0)
nop
move t0, a1
INT_SC t0, 0(a0)
beq t0, zero, 1b
nop
2:
j ra
nop
END(_atomic_swap_32)
ATOMIC_OP_ALIAS(atomic_swap_32, _atomic_swap_32)
#if !defined(__mips_o32)
LEAF(_atomic_swap_64)
1: REG_LL v0, 0(a0)
nop
move t0, a1
REG_SC t0, 0(a0)
beq t0, zero, 1b
nop
2:
j ra
nop
END(_atomic_swap_64)
ATOMIC_OP_ALIAS(atomic_swap_64, _atomic_swap_64)
#endif
#ifdef _LP64
STRONG_ALIAS(_atomic_swap_ptr, _atomic_swap_64)
STRONG_ALIAS(_atomic_swap_ulong, _atomic_swap_64)
#else
STRONG_ALIAS(_atomic_swap_ptr, _atomic_swap_32)
STRONG_ALIAS(_atomic_swap_ulong, _atomic_swap_32)
#endif
STRONG_ALIAS(_atomic_swap_uint, _atomic_swap_32)
ATOMIC_OP_ALIAS(atomic_swap_ptr, _atomic_swap_ptr)
ATOMIC_OP_ALIAS(atomic_swap_uint, _atomic_swap_uint)
ATOMIC_OP_ALIAS(atomic_swap_ulong, _atomic_swap_ulong)
--- src/common/lib/libc/arch/mips/atomic/membar_ops.S 2008/05/25 15:56:12 1.3
+++ src/common/lib/libc/arch/mips/atomic/membar_ops.S 2009/12/14 00:39:00 1.4
| @@ -1,70 +1,77 @@ | | | @@ -1,70 +1,77 @@ |
1 | /* $NetBSD: membar_ops.S,v 1.3 2008/05/25 15:56:12 chs Exp $ */ | | 1 | /* $NetBSD: membar_ops.S,v 1.4 2009/12/14 00:39:00 matt Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2006, 2007 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2006, 2007 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Jason R. Thorpe, and by Andrew Doran. | | 8 | * by Jason R. Thorpe, and by Andrew Doran. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
15 | * 2. Redistributions in binary form must reproduce the above copyright | | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
16 | * notice, this list of conditions and the following disclaimer in the | | 16 | * notice, this list of conditions and the following disclaimer in the |
17 | * documentation and/or other materials provided with the distribution. | | 17 | * documentation and/or other materials provided with the distribution. |
18 | * | | 18 | * |
19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | | 19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS |
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | * POSSIBILITY OF SUCH DAMAGE. | | 29 | * POSSIBILITY OF SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | #include "atomic_op_asm.h" | | 32 | #include "atomic_op_asm.h" |
33 | | | 33 | |
| | | 34 | #if defined(_KERNEL) |
| | | 35 | |
34 | #ifdef _KERNEL_OPT | | 36 | #ifdef _KERNEL_OPT |
35 | #include "opt_cputype.h" | | 37 | #include "opt_cputype.h" |
36 | #include "opt_lockdebug.h" | | 38 | #include "opt_lockdebug.h" |
37 | #include "opt_multiprocessor.h" | | 39 | #include "opt_multiprocessor.h" |
38 | #endif | | 40 | #endif |
39 | | | 41 | |
40 | #if defined(_KERNEL) | | | |
41 | | | 42 | |
42 | #include <machine/cpu.h> | | 43 | #include <machine/cpu.h> |
43 | | | 44 | |
44 | #if MIPS_HAS_LLSC != 0 && defined(MULTIPROCESSOR) | | 45 | #if (MIPS_HAS_LLSC != 0 && defined(MULTIPROCESSOR)) || !defined(__mips_o32) |
| | | 46 | #define SYNC sync |
| | | 47 | #endif |
| | | 48 | #elif !defined(__mips_o32) |
45 | #define SYNC sync | | 49 | #define SYNC sync |
46 | #else | | | |
47 | #define SYNC /* nothing */ | | | |
48 | #endif | | 50 | #endif |
49 | | | 51 | |
50 | .text | | 52 | .text |
51 | | | 53 | |
52 | LEAF(_membar_sync) | | 54 | LEAF(_membar_sync) |
53 | SYNC | | | |
54 | j ra | | 55 | j ra |
| | | 56 | #ifdef SYNC |
| | | 57 | SYNC |
| | | 58 | #else |
55 | nop | | 59 | nop |
| | | 60 | #endif |
56 | END(_membar_sync) | | 61 | END(_membar_sync) |
57 | | | 62 | |
| | | 63 | #ifdef _KERNEL |
| | | 64 | STRONG_ALIAS(mb_read, _membar_sync) |
| | | 65 | STRONG_ALIAS(mb_write, _membar_sync) |
| | | 66 | STRONG_ALIAS(mb_memory, _membar_sync) |
| | | 67 | #endif |
| | | 68 | |
58 | ATOMIC_OP_ALIAS(membar_sync,_membar_sync) | | 69 | ATOMIC_OP_ALIAS(membar_sync,_membar_sync) |
59 | ATOMIC_OP_ALIAS(membar_enter,_membar_sync) | | 70 | ATOMIC_OP_ALIAS(membar_enter,_membar_sync) |
60 | STRONG_ALIAS(_membar_enter,_membar_sync) | | 71 | STRONG_ALIAS(_membar_enter,_membar_sync) |
61 | ATOMIC_OP_ALIAS(membar_exit,_membar_sync) | | 72 | ATOMIC_OP_ALIAS(membar_exit,_membar_sync) |
62 | STRONG_ALIAS(_membar_exit,_membar_sync) | | 73 | STRONG_ALIAS(_membar_exit,_membar_sync) |
63 | ATOMIC_OP_ALIAS(membar_producer,_membar_sync) | | 74 | ATOMIC_OP_ALIAS(membar_producer,_membar_sync) |
64 | STRONG_ALIAS(_membar_producer,_membar_sync) | | 75 | STRONG_ALIAS(_membar_producer,_membar_sync) |
65 | ATOMIC_OP_ALIAS(membar_consumer,_membar_sync) | | 76 | ATOMIC_OP_ALIAS(membar_consumer,_membar_sync) |
66 | STRONG_ALIAS(_membar_consumer,_membar_sync) | | 77 | STRONG_ALIAS(_membar_consumer,_membar_sync) |
67 | | | | |
68 | #else /* _KERNEL */ | | | |
69 | | | | |
70 | #endif /* _KERNEL */ | | | |
--- src/common/lib/libc/arch/mips/gen/byte_swap_2.S 2006/02/08 21:52:36 1.2
+++ src/common/lib/libc/arch/mips/gen/byte_swap_2.S 2009/12/14 00:39:00 1.3
| @@ -1,74 +1,83 @@ | | | @@ -1,74 +1,83 @@ |
1 | /* $NetBSD: byte_swap_2.S,v 1.2 2006/02/08 21:52:36 simonb Exp $ */ | | 1 | /* $NetBSD: byte_swap_2.S,v 1.3 2009/12/14 00:39:00 matt Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1991, 1993 | | 4 | * Copyright (c) 1991, 1993 |
5 | * The Regents of the University of California. All rights reserved. | | 5 | * The Regents of the University of California. All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to Berkeley by | | 7 | * This code is derived from software contributed to Berkeley by |
8 | * Ralph Campbell. | | 8 | * Ralph Campbell. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
15 | * 2. Redistributions in binary form must reproduce the above copyright | | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
16 | * notice, this list of conditions and the following disclaimer in the | | 16 | * notice, this list of conditions and the following disclaimer in the |
17 | * documentation and/or other materials provided with the distribution. | | 17 | * documentation and/or other materials provided with the distribution. |
18 | * 3. Neither the name of the University nor the names of its contributors | | 18 | * 3. Neither the name of the University nor the names of its contributors |
19 | * may be used to endorse or promote products derived from this software | | 19 | * may be used to endorse or promote products derived from this software |
20 | * without specific prior written permission. | | 20 | * without specific prior written permission. |
21 | * | | 21 | * |
22 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | | 22 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | | 23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | | 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | | 25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
32 | * SUCH DAMAGE. | | 32 | * SUCH DAMAGE. |
33 | */ | | 33 | */ |
34 | | | 34 | |
35 | #include <mips/asm.h> | | 35 | #include <mips/asm.h> |
36 | | | 36 | |
37 | #if defined(LIBC_SCCS) && !defined(lint) | | 37 | #if defined(LIBC_SCCS) && !defined(lint) |
38 | ASMSTR("from: @(#)htons.s 8.1 (Berkeley) 6/4/93") | | 38 | #if 0 |
39 | ASMSTR("$NetBSD: byte_swap_2.S,v 1.2 2006/02/08 21:52:36 simonb Exp $") | | 39 | RCSID("from: @(#)htons.s 8.1 (Berkeley) 6/4/93") |
| | | 40 | #else |
| | | 41 | RCSID("$NetBSD: byte_swap_2.S,v 1.3 2009/12/14 00:39:00 matt Exp $") |
| | | 42 | #endif |
40 | #endif /* LIBC_SCCS and not lint */ | | 43 | #endif /* LIBC_SCCS and not lint */ |
41 | | | 44 | |
42 | #undef _LOCORE | | 45 | #undef _LOCORE |
43 | #define _LOCORE /* XXX not really, just assembly-code source */ | | 46 | #define _LOCORE /* XXX not really, just assembly-code source */ |
44 | #include <machine/endian.h> | | 47 | #include <machine/endian.h> |
45 | | | 48 | |
46 | #if defined(_KERNEL) || defined(_STANDALONE) | | 49 | #if defined(_KERNEL) || defined(_STANDALONE) |
47 | #define BSWAP16_NAME bswap16 | | 50 | #define BSWAP16_NAME bswap16 |
48 | #else | | 51 | #else |
49 | #ifdef __ABICALLS__ | | | |
50 | .abicalls | | | |
51 | #endif | | | |
52 | #define BSWAP16_NAME __bswap16 | | 52 | #define BSWAP16_NAME __bswap16 |
53 | #endif | | 53 | #endif |
54 | | | 54 | |
55 | NLEAF(BSWAP16_NAME) | | 55 | NLEAF(BSWAP16_NAME) |
56 | #if BYTE_ORDER == LITTLE_ENDIAN | | 56 | #if BYTE_ORDER == LITTLE_ENDIAN |
57 | ALEAF(htons) | | 57 | ALEAF(htons) |
58 | ALEAF(ntohs) | | 58 | ALEAF(ntohs) |
59 | #endif | | 59 | #endif |
| | | 60 | #if (__mips == 32 || __mips == 64) && __mips_isa_rev == 2 |
| | | 61 | /* |
| | | 62 | * If we are on MIPS32r2 or MIPS64r2, use the new instructions |
| | | 63 | */ |
| | | 64 | wsbh a0, a0 # word swap bytes within halfwords |
| | | 65 | and v0, a0, 0xffff # bound it to 16bits |
| | | 66 | j ra |
| | | 67 | #else |
60 | srl v0, a0, 8 | | 68 | srl v0, a0, 8 |
61 | and v0, v0, 0xff | | 69 | and v0, v0, 0xff |
62 | sll v1, a0, 8 | | 70 | sll v1, a0, 8 |
63 | and v1, v1, 0xff00 | | 71 | and v1, v1, 0xff00 |
64 | or v0, v0, v1 | | 72 | or v0, v0, v1 |
65 | j ra | | 73 | j ra |
| | | 74 | #endif |
66 | END(BSWAP16_NAME) | | 75 | END(BSWAP16_NAME) |
67 | | | 76 | |
68 | #if BYTE_ORDER == BIG_ENDIAN | | 77 | #if BYTE_ORDER == BIG_ENDIAN |
69 | NLEAF(htons) | | 78 | NLEAF(htons) |
70 | ALEAF(ntohs) | | 79 | ALEAF(ntohs) |
71 | move v0, a0 | | 80 | move v0, a0 |
72 | j ra | | 81 | j ra |
73 | END(htons) | | 82 | END(htons) |
74 | #endif | | 83 | #endif |
--- src/common/lib/libc/arch/mips/gen/byte_swap_4.S 2006/02/08 21:52:36 1.2
+++ src/common/lib/libc/arch/mips/gen/byte_swap_4.S 2009/12/14 00:39:00 1.3
| @@ -1,78 +1,87 @@ | | | @@ -1,78 +1,87 @@ |
1 | /* $NetBSD: byte_swap_4.S,v 1.2 2006/02/08 21:52:36 simonb Exp $ */ | | 1 | /* $NetBSD: byte_swap_4.S,v 1.3 2009/12/14 00:39:00 matt Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1991, 1993 | | 4 | * Copyright (c) 1991, 1993 |
5 | * The Regents of the University of California. All rights reserved. | | 5 | * The Regents of the University of California. All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to Berkeley by | | 7 | * This code is derived from software contributed to Berkeley by |
8 | * Ralph Campbell. | | 8 | * Ralph Campbell. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
15 | * 2. Redistributions in binary form must reproduce the above copyright | | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
16 | * notice, this list of conditions and the following disclaimer in the | | 16 | * notice, this list of conditions and the following disclaimer in the |
17 | * documentation and/or other materials provided with the distribution. | | 17 | * documentation and/or other materials provided with the distribution. |
18 | * 3. Neither the name of the University nor the names of its contributors | | 18 | * 3. Neither the name of the University nor the names of its contributors |
19 | * may be used to endorse or promote products derived from this software | | 19 | * may be used to endorse or promote products derived from this software |
20 | * without specific prior written permission. | | 20 | * without specific prior written permission. |
21 | * | | 21 | * |
22 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | | 22 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | | 23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | | 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | | 25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
32 | * SUCH DAMAGE. | | 32 | * SUCH DAMAGE. |
33 | */ | | 33 | */ |
34 | | | 34 | |
35 | #include <mips/asm.h> | | 35 | #include <mips/asm.h> |
36 | | | 36 | |
37 | #if defined(LIBC_SCCS) && !defined(lint) | | 37 | #if defined(LIBC_SCCS) && !defined(lint) |
38 | ASMSTR("from: @(#)htonl.s 8.1 (Berkeley) 6/4/93") | | 38 | #if 0 |
39 | ASMSTR("$NetBSD: byte_swap_4.S,v 1.2 2006/02/08 21:52:36 simonb Exp $") | | 39 | RCSID("from: @(#)htonl.s 8.1 (Berkeley) 6/4/93") |
| | | 40 | #else |
| | | 41 | RCSID("$NetBSD: byte_swap_4.S,v 1.3 2009/12/14 00:39:00 matt Exp $") |
| | | 42 | #endif |
40 | #endif /* LIBC_SCCS and not lint */ | | 43 | #endif /* LIBC_SCCS and not lint */ |
41 | | | 44 | |
42 | #undef _LOCORE | | 45 | #undef _LOCORE |
43 | #define _LOCORE /* XXX not really, just assembly-code source */ | | 46 | #define _LOCORE /* XXX not really, just assembly-code source */ |
44 | #include <machine/endian.h> | | 47 | #include <machine/endian.h> |
45 | | | 48 | |
46 | #if defined(_KERNEL) || defined(_STANDALONE) | | 49 | #if defined(_KERNEL) || defined(_STANDALONE) |
47 | #define BSWAP32_NAME bswap32 | | 50 | #define BSWAP32_NAME bswap32 |
48 | #else | | 51 | #else |
49 | #ifdef __ABICALLS__ | | | |
50 | .abicalls | | | |
51 | #endif | | | |
52 | #define BSWAP32_NAME __bswap32 | | 52 | #define BSWAP32_NAME __bswap32 |
53 | #endif | | 53 | #endif |
54 | | | 54 | |
55 | NLEAF(BSWAP32_NAME) # a0 = 0x11223344, return 0x44332211 | | 55 | NLEAF(BSWAP32_NAME) # a0 = 0x11223344, return 0x44332211 |
56 | #if BYTE_ORDER == LITTLE_ENDIAN | | 56 | #if BYTE_ORDER == LITTLE_ENDIAN |
57 | ALEAF(htonl) # a0 = 0x11223344, return 0x44332211 | | 57 | ALEAF(htonl) # a0 = 0x11223344, return 0x44332211 |
58 | ALEAF(ntohl) | | 58 | ALEAF(ntohl) |
59 | #endif | | 59 | #endif |
| | | 60 | #if (__mips == 32 || __mips == 64) && __mips_isa_rev == 2 |
| | | 61 | /* |
| | | 62 | * If we are on MIPS32R2 or MIPS64R2 it's much easier |
| | | 63 | */ |
| | | 64 | wsbh a0, a0 # word swap bytes within halfwords |
| | | 65 | rotr v0, a0, 16 # rotate word 16bits |
| | | 66 | j ra |
| | | 67 | #else |
60 | srl v1, a0, 24 # v1 = 0x00000011 | | 68 | srl v1, a0, 24 # v1 = 0x00000011 |
61 | sll v0, a0, 24 # v0 = 0x44000000 | | 69 | sll v0, a0, 24 # v0 = 0x44000000 |
62 | or v0, v0, v1 | | 70 | or v0, v0, v1 |
63 | and v1, a0, 0xff00 | | 71 | and v1, a0, 0xff00 |
64 | sll v1, v1, 8 # v1 = 0x00330000 | | 72 | sll v1, v1, 8 # v1 = 0x00330000 |
65 | or v0, v0, v1 | | 73 | or v0, v0, v1 |
66 | srl v1, a0, 8 | | 74 | srl v1, a0, 8 |
67 | and v1, v1, 0xff00 # v1 = 0x00002200 | | 75 | and v1, v1, 0xff00 # v1 = 0x00002200 |
68 | or v0, v0, v1 | | 76 | or v0, v0, v1 |
69 | j ra | | 77 | j ra |
| | | 78 | #endif |
70 | END(BSWAP32_NAME) | | 79 | END(BSWAP32_NAME) |
71 | | | 80 | |
72 | #if BYTE_ORDER == BIG_ENDIAN | | 81 | #if BYTE_ORDER == BIG_ENDIAN |
73 | NLEAF(htonl) # a0 = 0x11223344, return 0x44332211 | | 82 | NLEAF(htonl) # a0 = 0x11223344, return 0x44332211 |
74 | ALEAF(ntohl) | | 83 | ALEAF(ntohl) |
75 | move v0, a0 | | 84 | move v0, a0 |
76 | j ra | | 85 | j ra |
77 | END(htonl) | | 86 | END(htonl) |
78 | #endif | | 87 | #endif |
/* $NetBSD: byte_swap_8.S,v 1.2 2009/12/14 00:39:00 matt Exp $ */
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Ralph Campbell.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <mips/asm.h>
#if defined(LIBC_SCCS) && !defined(lint)
RCSID("$NetBSD: byte_swap_8.S,v 1.2 2009/12/14 00:39:00 matt Exp $")
#endif /* LIBC_SCCS and not lint */
#undef _LOCORE
#define _LOCORE /* XXX not really, just assembly-code source */
#include <machine/endian.h>
NLEAF(bswap64) # a0 = 0xffeeddccbbaa9988 return 0x8899aabbccddeeff
#if (__mips == 32 || __mips == 64) && __mips_isa_rev == 2
#if !defined(__mips_o32)
/*
* If we are on MIPS32r2 or MIPS64r2 use the new instructions.
*/
dsbh v0, a0 # dwords swap bytes within halfwords
dshd v0, v0 # dwords swap halwords within dwords
j ra
#else /* defined(__mips_o32) */
/*
* If we are on MIPS32r2 or MIPS64r2 use the new instructions.
* (except we must use the 32bit versions)
*/
wsbh v1, a0 # word swap bytes within halfwords
wsbh v0, a1 # word swap bytes within halfwords
rotr v1, v1, 16 # rotate word 16bits and swap word
rotr v0, v0, 16 # rotate word 16bits and swap word
j ra
#endif /* defined(__mips_o32) */
#elif !defined(__mips_o32)
# a0 = 0xffeeddccbbaa9988
li t0, 0xffff # t0 = 0x000000000000ffff
dsll t1, t0, 32 # t1 = 0x0000ffff00000000
or t0, t1 # t0 = 0x0000ffff0000ffff
dsll t2, t0, 8 # t2 = 0x00ffff0000ffff00
xor t2, t0 # t2 = 0x00ff00ff00ff00ff
/*
* We could swap by halfword, but that would be one instruction longer.
*/
dsrl ta0, a0, 32 # ta0 = 0x00000000ffeeddcc
dsll ta1, a0, 32 # ta1 = 0xbbaa998800000000
or a1, ta0, ta1 # a1 = 0xbbaa9988ffeeddcc
# words swapped
and ta0, a1, t0 # ta0 = 0x000099880000ddcc
dsrl ta1, a1, 16 # ta1 = 0x0000bbaa9988ffee
and ta1, t0 # ta1 = 0x0000bbaa0000ffee
dsll a2, ta0, 16 # a2 = 0x99880000ddcc0000
or a2, ta1 # a2 = 0x9988bbaaddccffee
# halfwords swapped
and ta0, a2, t2 # ta0 = 0x008800aa00cc00ee
dsrl ta1, a2, 8 # ta1 = 0x009988bbaaddccff
and ta1, t2 # ta1 = 0x009900bb00dd00ff
dsll v0, ta0, 8 # v0 = 0x8800aa00cc00ee00
or v0, ta1 # v0 = 0x8899aabbccddeeff
# bytes swapped
j ra
#else /* defined(__mips_o32) */
/*
* 32bit ABI.
*/
# a0 = 0xccddeeff
# a1 = 0x8899aabb
srl t0, a0, 24 # t0 = 0x000000cc
srl t1, a1, 24 # t1 = 0x00000088
sll ta0, a0, 24 # ta0 = 0xff000000
sll ta1, a1, 24 # ta1 = 0xbb000000
or ta0, ta0, t0 # ta0 = 0xff0000cc
or ta1, ta1, t1 # ta1 = 0xbb000088
and t0, a0, 0xff00 # t0 = 0x0000ee00
and t1, a1, 0xff00 # t1 = 0x0000aa00
sll t0, t0, 8 # t0 = 0x00ee0000
sll t1, t1, 8 # t1 = 0x00aa0000
or ta0, ta0, t0 # ta0 = 0xffee00cc
or ta1, ta1, t1 # ta1 = 0xbbaa0088
srl t0, a0, 8 # t0 = 0x00ccddee
srl t1, a1, 8 # t1 = 0x008899aa
and t0, t0, 0xff00 # t0 = 0x0000dd00
and t1, t1, 0xff00 # t1 = 0x00009900
or v1, ta0, t0 # v1 = 0xffeeddcc
or v0, ta1, t1 # v0 = 0xbbaa9988
j ra
#endif /* defined(__mips_o32) */
END(bswap64)
--- src/common/lib/libc/arch/mips/string/bcopy.S 2005/12/27 11:23:53 1.2
+++ src/common/lib/libc/arch/mips/string/bcopy.S 2009/12/14 00:39:00 1.3
| @@ -1,294 +1,294 @@ | | | @@ -1,294 +1,294 @@ |
1 | /* $NetBSD: bcopy.S,v 1.2 2005/12/27 11:23:53 tsutsui Exp $ */ | | 1 | /* $NetBSD: bcopy.S,v 1.3 2009/12/14 00:39:00 matt Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Mach Operating System | | 4 | * Mach Operating System |
5 | * Copyright (c) 1993 Carnegie Mellon University | | 5 | * Copyright (c) 1993 Carnegie Mellon University |
6 | * All Rights Reserved. | | 6 | * All Rights Reserved. |
7 | * | | 7 | * |
8 | * Permission to use, copy, modify and distribute this software and its | | 8 | * Permission to use, copy, modify and distribute this software and its |
9 | * documentation is hereby granted, provided that both the copyright | | 9 | * documentation is hereby granted, provided that both the copyright |
10 | * notice and this permission notice appear in all copies of the | | 10 | * notice and this permission notice appear in all copies of the |
11 | * software, derivative works or modified versions, and any portions | | 11 | * software, derivative works or modified versions, and any portions |
12 | * thereof, and that both notices appear in supporting documentation. | | 12 | * thereof, and that both notices appear in supporting documentation. |
13 | * | | 13 | * |
14 | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" | | 14 | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" |
15 | * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR | | 15 | * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR |
16 | * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. | | 16 | * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. |
17 | * | | 17 | * |
18 | * Carnegie Mellon requests users of this software to return to | | 18 | * Carnegie Mellon requests users of this software to return to |
19 | * | | 19 | * |
20 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU | | 20 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU |
21 | * School of Computer Science | | 21 | * School of Computer Science |
22 | * Carnegie Mellon University | | 22 | * Carnegie Mellon University |
23 | * Pittsburgh PA 15213-3890 | | 23 | * Pittsburgh PA 15213-3890 |
24 | * | | 24 | * |
25 | * any improvements or extensions that they make and grant Carnegie Mellon | | 25 | * any improvements or extensions that they make and grant Carnegie Mellon |
26 | * the rights to redistribute these changes. | | 26 | * the rights to redistribute these changes. |
27 | */ | | 27 | */ |
28 | | | 28 | |
29 | /* | | 29 | /* |
30 | * File: mips_bcopy.s | | 30 | * File: mips_bcopy.s |
31 | * Author: Chris Maeda | | 31 | * Author: Chris Maeda |
32 | * Date: June 1993 | | 32 | * Date: June 1993 |
33 | * | | 33 | * |
34 | * Fast copy routine. Derived from aligned_block_copy. | | 34 | * Fast copy routine. Derived from aligned_block_copy. |
35 | */ | | 35 | */ |
36 | | | 36 | |
37 | | | 37 | |
38 | #include <mips/asm.h> | | 38 | #include <mips/asm.h> |
39 | #ifndef _LOCORE | | 39 | #ifndef _LOCORE |
40 | #define _LOCORE /* XXX not really, just assembly-code source */ | | 40 | #define _LOCORE /* XXX not really, just assembly-code source */ |
41 | #endif | | 41 | #endif |
42 | #include <machine/endian.h> | | 42 | #include <machine/endian.h> |
43 | | | 43 | |
44 | | | 44 | |
45 | #if defined(LIBC_SCCS) && !defined(lint) | | 45 | #if defined(LIBC_SCCS) && !defined(lint) |
46 | ASMSTR("from: @(#)mips_bcopy.s 2.2 CMU 18/06/93") | | 46 | #if 0 |
47 | ASMSTR("$NetBSD: bcopy.S,v 1.2 2005/12/27 11:23:53 tsutsui Exp $") | | 47 | RCSID("from: @(#)mips_bcopy.s 2.2 CMU 18/06/93") |
48 | #endif /* LIBC_SCCS and not lint */ | | 48 | #else |
49 | | | 49 | RCSID("$NetBSD: bcopy.S,v 1.3 2009/12/14 00:39:00 matt Exp $") |
50 | #ifdef __ABICALLS__ | | | |
51 | .abicalls | | | |
52 | #endif | | 50 | #endif |
| | | 51 | #endif /* LIBC_SCCS and not lint */ |
53 | | | 52 | |
54 | /* | | 53 | /* |
55 | * bcopy(caddr_t src, caddr_t dst, unsigned int len) | | 54 | * bcopy(caddr_t src, caddr_t dst, unsigned int len) |
56 | * | | 55 | * |
57 | * a0 src address | | 56 | * a0 src address |
58 | * a1 dst address | | 57 | * a1 dst address |
59 | * a2 length | | 58 | * a2 length |
60 | */ | | 59 | */ |
61 | | | 60 | |
62 | #if defined(MEMCOPY) || defined(MEMMOVE) | | 61 | #if defined(MEMCOPY) || defined(MEMMOVE) |
63 | #ifdef MEMCOPY | | 62 | #ifdef MEMCOPY |
64 | #define FUNCTION memcpy | | 63 | #define FUNCTION memcpy |
65 | #else | | 64 | #else |
66 | #define FUNCTION memmove | | 65 | #define FUNCTION memmove |
67 | #endif | | 66 | #endif |
68 | #define SRCREG a1 | | 67 | #define SRCREG a1 |
69 | #define DSTREG a0 | | 68 | #define DSTREG a0 |
70 | #else | | 69 | #else |
71 | #define FUNCTION bcopy | | 70 | #define FUNCTION bcopy |
72 | #define SRCREG a0 | | 71 | #define SRCREG a0 |
73 | #define DSTREG a1 | | 72 | #define DSTREG a1 |
74 | #endif | | 73 | #endif |
75 | | | 74 | |
76 | #define SIZEREG a2 | | 75 | #define SIZEREG a2 |
77 | | | 76 | |
78 | LEAF(FUNCTION) | | 77 | LEAF(FUNCTION) |
79 | .set noat | | 78 | .set noat |
80 | .set noreorder | | 79 | .set noreorder |
81 | | | 80 | |
82 | #if defined(MEMCOPY) || defined(MEMMOVE) | | 81 | #if defined(MEMCOPY) || defined(MEMMOVE) |
83 | /* set up return value, while we still can */ | | 82 | /* set up return value, while we still can */ |
84 | move v0,DSTREG | | 83 | move v0,DSTREG |
85 | #endif | | 84 | #endif |
86 | /* | | 85 | /* |
87 | * Make sure we can copy forwards. | | 86 | * Make sure we can copy forwards. |
88 | */ | | 87 | */ |
89 | sltu t0,SRCREG,DSTREG # t0 == SRCREG < DSTREG | | 88 | sltu t0,SRCREG,DSTREG # t0 == SRCREG < DSTREG |
90 | bne t0,zero,6f # copy backwards | | 89 | bne t0,zero,6f # copy backwards |
91 | | | 90 | |
92 | /* | | 91 | /* |
93 | * There are four alignment cases (with frequency) | | 92 | * There are four alignment cases (with frequency) |
94 | * (Based on measurements taken with a DECstation 5000/200 | | 93 | * (Based on measurements taken with a DECstation 5000/200 |
95 | * inside a Mach kernel.) | | 94 | * inside a Mach kernel.) |
96 | * | | 95 | * |
97 | * aligned -> aligned (mostly) | | 96 | * aligned -> aligned (mostly) |
98 | * unaligned -> aligned (sometimes) | | 97 | * unaligned -> aligned (sometimes) |
99 | * aligned,unaligned -> unaligned (almost never) | | 98 | * aligned,unaligned -> unaligned (almost never) |
100 | * | | 99 | * |
101 | * Note that we could add another case that checks if | | 100 | * Note that we could add another case that checks if |
102 | * the destination and source are unaligned but the | | 101 | * the destination and source are unaligned but the |
103 | * copy is alignable. eg if src and dest are both | | 102 | * copy is alignable. eg if src and dest are both |
104 | * on a halfword boundary. | | 103 | * on a halfword boundary. |
105 | */ | | 104 | */ |
106 | andi t1,DSTREG,3 # get last 3 bits of dest | | 105 | andi t1,DSTREG,(SZREG-1) # get last bits of dest |
107 | bne t1,zero,3f | | 106 | bne t1,zero,3f # dest unaligned |
108 | andi t0,SRCREG,3 # get last 3 bits of src | | 107 | andi t0,SRCREG,(SZREG-1) # get last bits of src |
109 | bne t0,zero,5f | | 108 | bne t0,zero,5f |
110 | | | 109 | |
111 | /* | | 110 | /* |
112 | * Forward aligned->aligned copy, 8*4 bytes at a time. | | 111 | * Forward aligned->aligned copy, 8 words at a time. |
113 | */ | | 112 | */ |
114 | li AT,-32 | | 113 | 98: |
115 | and t0,SIZEREG,AT # count truncated to multiple of 32 */ | | 114 | li AT,-(SZREG*8) |
116 | addu a3,SRCREG,t0 # run fast loop up to this address | | 115 | and t0,SIZEREG,AT # count truncated to multiples |
117 | sltu AT,SRCREG,a3 # any work to do? | | 116 | PTR_ADDU a3,SRCREG,t0 # run fast loop up to this addr |
118 | beq AT,zero,2f | | 117 | sltu AT,SRCREG,a3 # any work to do? |
119 | subu SIZEREG,t0 | | 118 | beq AT,zero,2f |
| | | 119 | PTR_SUBU SIZEREG,t0 |
120 | | | 120 | |
121 | /* | | 121 | /* |
122 | * loop body | | 122 | * loop body |
123 | */ | | 123 | */ |
124 | 1: # cp | | 124 | 1: # cp |
125 | lw t3,0(SRCREG) | | 125 | REG_L t3,(0*SZREG)(SRCREG) |
126 | lw v1,4(SRCREG) | | 126 | REG_L v1,(1*SZREG)(SRCREG) |
127 | lw t0,8(SRCREG) | | 127 | REG_L t0,(2*SZREG)(SRCREG) |
128 | lw t1,12(SRCREG) | | 128 | REG_L t1,(3*SZREG)(SRCREG) |
129 | addu SRCREG,32 | | 129 | PTR_ADDU SRCREG,SZREG*8 |
130 | sw t3,0(DSTREG) | | 130 | REG_S t3,(0*SZREG)(DSTREG) |
131 | sw v1,4(DSTREG) | | 131 | REG_S v1,(1*SZREG)(DSTREG) |
132 | sw t0,8(DSTREG) | | 132 | REG_S t0,(2*SZREG)(DSTREG) |
133 | sw t1,12(DSTREG) | | 133 | REG_S t1,(3*SZREG)(DSTREG) |
134 | lw t1,-4(SRCREG) | | 134 | REG_L t1,(-1*SZREG)(SRCREG) |
135 | lw t0,-8(SRCREG) | | 135 | REG_L t0,(-2*SZREG)(SRCREG) |
136 | lw v1,-12(SRCREG) | | 136 | REG_L v1,(-3*SZREG)(SRCREG) |
137 | lw t3,-16(SRCREG) | | 137 | REG_L t3,(-4*SZREG)(SRCREG) |
138 | addu DSTREG,32 | | 138 | PTR_ADDU DSTREG,SZREG*8 |
139 | sw t1,-4(DSTREG) | | 139 | REG_S t1,(-1*SZREG)(DSTREG) |
140 | sw t0,-8(DSTREG) | | 140 | REG_S t0,(-2*SZREG)(DSTREG) |
141 | sw v1,-12(DSTREG) | | 141 | REG_S v1,(-3*SZREG)(DSTREG) |
142 | bne SRCREG,a3,1b | | 142 | bne SRCREG,a3,1b |
143 | sw t3,-16(DSTREG) | | 143 | REG_S t3,(-4*SZREG)(DSTREG) |
144 | | | 144 | |
145 | /* | | 145 | /* |
146 | * Copy a word at a time, no loop unrolling. | | 146 | * Copy a word at a time, no loop unrolling. |
147 | */ | | 147 | */ |
148 | 2: # wordcopy | | 148 | 2: # wordcopy |
149 | andi t2,SIZEREG,3 # get byte count / 4 | | 149 | andi t2,SIZEREG,(SZREG-1) # get byte count / SZREG |
150 | subu t2,SIZEREG,t2 # t2 = number of words to copy * 4 | | 150 | PTR_SUBU t2,SIZEREG,t2 # t2 = words to copy * SZREG |
151 | beq t2,zero,3f | | 151 | beq t2,zero,3f |
152 | addu t0,SRCREG,t2 # stop at t0 | | 152 | PTR_ADDU t0,SRCREG,t2 # stop at t0 |
153 | subu SIZEREG,SIZEREG,t2 | | 153 | PTR_SUBU SIZEREG,SIZEREG,t2 |
154 | 1: | | 154 | 1: |
155 | lw t3,0(SRCREG) | | 155 | REG_L t3,0(SRCREG) |
156 | addu SRCREG,4 | | 156 | PTR_ADDU SRCREG,SZREG |
157 | sw t3,0(DSTREG) | | 157 | REG_S t3,0(DSTREG) |
158 | bne SRCREG,t0,1b | | 158 | bne SRCREG,t0,1b |
159 | addu DSTREG,4 | | 159 | PTR_ADDU DSTREG,SZREG |
160 | | | 160 | |
161 | 3: # bytecopy | | 161 | 3: # bytecopy |
162 | beq SIZEREG,zero,4f # nothing left to do? | | 162 | beq SIZEREG,zero,4f # nothing left to do? |
163 | nop | | 163 | nop |
164 | 1: | | 164 | 1: |
165 | lb t3,0(SRCREG) | | 165 | lb t3,0(SRCREG) |
166 | addu SRCREG,1 | | 166 | PTR_ADDU SRCREG,1 |
167 | sb t3,0(DSTREG) | | 167 | sb t3,0(DSTREG) |
168 | subu SIZEREG,1 | | 168 | PTR_SUBU SIZEREG,1 |
169 | bgtz SIZEREG,1b | | 169 | bgtz SIZEREG,1b |
170 | addu DSTREG,1 | | 170 | PTR_ADDU DSTREG,1 |
171 | | | 171 | |
172 | 4: # copydone | | 172 | 4: # copydone |
173 | j ra | | 173 | j ra |
174 | nop | | 174 | nop |
175 | | | 175 | |
176 | /* | | 176 | /* |
177 | * Copy from unaligned source to aligned dest. | | 177 | * Copy from unaligned source to aligned dest. |
178 | */ | | 178 | */ |
179 | 5: # destaligned | | 179 | 5: # destaligned |
180 | andi t0,SIZEREG,3 # t0 = bytecount mod 4 | | 180 | andi t0,SIZEREG,(SZREG-1) # t0 = bytecount mod SZREG |
181 | subu a3,SIZEREG,t0 # number of words to transfer | | 181 | PTR_SUBU a3,SIZEREG,t0 # number of words to transfer |
182 | beq a3,zero,3b | | 182 | beq a3,zero,3b |
183 | nop | | 183 | nop |
184 | move SIZEREG,t0 # this many to do after we are done | | 184 | move SIZEREG,t0 # this many to do after we are done |
185 | addu a3,SRCREG,a3 # stop point | | 185 | PTR_ADDU a3,SRCREG,a3 # stop point |
186 | | | 186 | |
187 | 1: | | 187 | 1: |
188 | LWHI t3,0(SRCREG) | | 188 | REG_LHI t3,0(SRCREG) |
189 | LWLO t3,3(SRCREG) | | 189 | REG_LLO t3,SZREG-1(SRCREG) |
190 | addi SRCREG,4 | | 190 | PTR_ADDI SRCREG,SZREG |
191 | sw t3,0(DSTREG) | | 191 | REG_S t3,0(DSTREG) |
192 | bne SRCREG,a3,1b | | 192 | bne SRCREG,a3,1b |
193 | addi DSTREG,4 | | 193 | PTR_ADDI DSTREG,SZREG |
194 | | | 194 | |
195 | j 3b | | 195 | b 3b |
196 | nop | | 196 | nop |
197 | | | 197 | |
198 | 6: # backcopy -- based on above | | 198 | 6: # backcopy -- based on above |
199 | addu SRCREG,SIZEREG | | 199 | PTR_ADDU SRCREG,SIZEREG |
200 | addu DSTREG,SIZEREG | | 200 | PTR_ADDU DSTREG,SIZEREG |
201 | andi t1,DSTREG,3 # get last 3 bits of dest | | 201 | andi t1,DSTREG,SZREG-1 # get last 3 bits of dest |
202 | bne t1,zero,3f | | 202 | bne t1,zero,3f |
203 | andi t0,SRCREG,3 # get last 3 bits of src | | 203 | andi t0,SRCREG,SZREG-1 # get last 3 bits of src |
204 | bne t0,zero,5f | | 204 | bne t0,zero,5f |
205 | | | 205 | |
206 | /* | | 206 | /* |
207 | * Forward aligned->aligned copy, 8*4 bytes at a time. | | 207 | * Forward aligned->aligned copy, 8*4 bytes at a time. |
208 | */ | | 208 | */ |
209 | li AT,-32 | | 209 | li AT,(-8*SZREG) |
210 | and t0,SIZEREG,AT # count truncated to multiple of 32 | | 210 | and t0,SIZEREG,AT # count truncated to multiple of 32 |
211 | beq t0,zero,2f # any work to do? | | 211 | beq t0,zero,2f # any work to do? |
212 | subu SIZEREG,t0 | | 212 | PTR_SUBU SIZEREG,t0 |
213 | subu a3,SRCREG,t0 | | 213 | PTR_SUBU a3,SRCREG,t0 |
214 | | | 214 | |
215 | /* | | 215 | /* |
216 | * loop body | | 216 | * loop body |
217 | */ | | 217 | */ |
218 | 1: # cp | | 218 | 1: # cp |
219 | lw t3,-16(SRCREG) | | 219 | REG_L t3,(-4*SZREG)(SRCREG) |
220 | lw v1,-12(SRCREG) | | 220 | REG_L v1,(-3*SZREG)(SRCREG) |
221 | lw t0,-8(SRCREG) | | 221 | REG_L t0,(-2*SZREG)(SRCREG) |
222 | lw t1,-4(SRCREG) | | 222 | REG_L t1,(-1*SZREG)(SRCREG) |
223 | subu SRCREG,32 | | 223 | PTR_SUBU SRCREG,8*SZREG |
224 | sw t3,-16(DSTREG) | | 224 | REG_S t3,(-4*SZREG)(DSTREG) |
225 | sw v1,-12(DSTREG) | | 225 | REG_S v1,(-3*SZREG)(DSTREG) |
226 | sw t0,-8(DSTREG) | | 226 | REG_S t0,(-2*SZREG)(DSTREG) |
227 | sw t1,-4(DSTREG) | | 227 | REG_S t1,(-1*SZREG)(DSTREG) |
228 | lw t1,12(SRCREG) | | 228 | REG_L t1,(3*SZREG)(SRCREG) |
229 | lw t0,8(SRCREG) | | 229 | REG_L t0,(2*SZREG)(SRCREG) |
230 | lw v1,4(SRCREG) | | 230 | REG_L v1,(1*SZREG)(SRCREG) |
231 | lw t3,0(SRCREG) | | 231 | REG_L t3,(0*SZREG)(SRCREG) |
232 | subu DSTREG,32 | | 232 | PTR_SUBU DSTREG,8*SZREG |
233 | sw t1,12(DSTREG) | | 233 | REG_S t1,(3*SZREG)(DSTREG) |
234 | sw t0,8(DSTREG) | | 234 | REG_S t0,(2*SZREG)(DSTREG) |
235 | sw v1,4(DSTREG) | | 235 | REG_S v1,(1*SZREG)(DSTREG) |
236 | bne SRCREG,a3,1b | | 236 | bne SRCREG,a3,1b |
237 | sw t3,0(DSTREG) | | 237 | REG_S t3,(0*SZREG)(DSTREG) |
238 | | | 238 | |
239 | /* | | 239 | /* |
240 | * Copy a word at a time, no loop unrolling. | | 240 | * Copy a word at a time, no loop unrolling. |
241 | */ | | 241 | */ |
242 | 2: # wordcopy | | 242 | 2: # wordcopy |
243 | andi t2,SIZEREG,3 # get byte count / 4 | | 243 | andi t2,SIZEREG,SZREG-1 # get byte count / 4 |
244 | subu t2,SIZEREG,t2 # t2 = number of words to copy * 4 | | 244 | PTR_SUBU t2,SIZEREG,t2 # t2 = number of words to copy |
245 | beq t2,zero,3f | | 245 | beq t2,zero,3f |
246 | subu t0,SRCREG,t2 # stop at t0 | | 246 | PTR_SUBU t0,SRCREG,t2 # stop at t0 |
247 | subu SIZEREG,SIZEREG,t2 | | 247 | PTR_SUBU SIZEREG,SIZEREG,t2 |
248 | 1: | | 248 | 1: |
249 | lw t3,-4(SRCREG) | | 249 | REG_L t3,-SZREG(SRCREG) |
250 | subu SRCREG,4 | | 250 | PTR_SUBU SRCREG,SZREG |
251 | sw t3,-4(DSTREG) | | 251 | REG_S t3,-SZREG(DSTREG) |
252 | bne SRCREG,t0,1b | | 252 | bne SRCREG,t0,1b |
253 | subu DSTREG,4 | | 253 | PTR_SUBU DSTREG,SZREG |
254 | | | 254 | |
255 | 3: # bytecopy | | 255 | 3: # bytecopy |
256 | beq SIZEREG,zero,4f # nothing left to do? | | 256 | beq SIZEREG,zero,4f # nothing left to do? |
257 | nop | | 257 | nop |
258 | 1: | | 258 | 1: |
259 | lb t3,-1(SRCREG) | | 259 | lb t3,-1(SRCREG) |
260 | subu SRCREG,1 | | 260 | PTR_SUBU SRCREG,1 |
261 | sb t3,-1(DSTREG) | | 261 | sb t3,-1(DSTREG) |
262 | subu SIZEREG,1 | | 262 | PTR_SUBU SIZEREG,1 |
263 | bgtz SIZEREG,1b | | 263 | bgtz SIZEREG,1b |
264 | subu DSTREG,1 | | 264 | PTR_SUBU DSTREG,1 |
265 | | | 265 | |
266 | 4: # copydone | | 266 | 4: # copydone |
267 | j ra | | 267 | j ra |
268 | nop | | 268 | nop |
269 | | | 269 | |
270 | /* | | 270 | /* |
271 | * Copy from unaligned source to aligned dest. | | 271 | * Copy from unaligned source to aligned dest. |
272 | */ | | 272 | */ |
273 | 5: # destaligned | | 273 | 5: # destaligned |
274 | andi t0,SIZEREG,3 # t0 = bytecount mod 4 | | 274 | andi t0,SIZEREG,SZREG-1 # t0 = bytecount mod 4 |
275 | subu a3,SIZEREG,t0 # number of words to transfer | | 275 | PTR_SUBU a3,SIZEREG,t0 # number of words to transfer |
276 | beq a3,zero,3b | | 276 | beq a3,zero,3b |
277 | nop | | 277 | nop |
278 | move SIZEREG,t0 # this many to do after we are done | | 278 | move SIZEREG,t0 # this many to do after we are done |
279 | subu a3,SRCREG,a3 # stop point | | 279 | PTR_SUBU a3,SRCREG,a3 # stop point |
280 | | | 280 | |
281 | 1: | | 281 | 1: |
282 | LWHI t3,-4(SRCREG) | | 282 | REG_LHI t3,-SZREG(SRCREG) |
283 | LWLO t3,-1(SRCREG) | | 283 | REG_LLO t3,-1(SRCREG) |
284 | subu SRCREG,4 | | 284 | PTR_SUBU SRCREG,SZREG |
285 | sw t3,-4(DSTREG) | | 285 | REG_S t3,-SZREG(DSTREG) |
286 | bne SRCREG,a3,1b | | 286 | bne SRCREG,a3,1b |
287 | subu DSTREG,4 | | 287 | PTR_SUBU DSTREG,SZREG |
288 | | | 288 | |
289 | j 3b | | 289 | b 3b |
290 | nop | | 290 | nop |
291 | | | 291 | |
292 | .set reorder | | 292 | .set reorder |
293 | .set at | | 293 | .set at |
294 | END(FUNCTION) | | 294 | END(FUNCTION) |
--- src/common/lib/libc/arch/mips/string/ffs.S 2005/12/20 19:28:49 1.1
+++ src/common/lib/libc/arch/mips/string/ffs.S 2009/12/14 00:39:00 1.2
| @@ -1,58 +1,54 @@ | | | @@ -1,58 +1,54 @@ |
1 | /* $NetBSD: ffs.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */ | | 1 | /* $NetBSD: ffs.S,v 1.2 2009/12/14 00:39:00 matt Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1991, 1993 | | 4 | * Copyright (c) 1991, 1993 |
5 | * The Regents of the University of California. All rights reserved. | | 5 | * The Regents of the University of California. All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to Berkeley by | | 7 | * This code is derived from software contributed to Berkeley by |
8 | * Ralph Campbell. | | 8 | * Ralph Campbell. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
15 | * 2. Redistributions in binary form must reproduce the above copyright | | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
16 | * notice, this list of conditions and the following disclaimer in the | | 16 | * notice, this list of conditions and the following disclaimer in the |
17 | * documentation and/or other materials provided with the distribution. | | 17 | * documentation and/or other materials provided with the distribution. |
18 | * 3. Neither the name of the University nor the names of its contributors | | 18 | * 3. Neither the name of the University nor the names of its contributors |
19 | * may be used to endorse or promote products derived from this software | | 19 | * may be used to endorse or promote products derived from this software |
20 | * without specific prior written permission. | | 20 | * without specific prior written permission. |
21 | * | | 21 | * |
22 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | | 22 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | | 23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | | 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | | 25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
32 | * SUCH DAMAGE. | | 32 | * SUCH DAMAGE. |
33 | */ | | 33 | */ |
34 | | | 34 | |
35 | #include <mips/asm.h> | | 35 | #include <mips/asm.h> |
36 | | | 36 | |
37 | #if defined(LIBC_SCCS) && !defined(lint) | | 37 | #if defined(LIBC_SCCS) && !defined(lint) |
38 | ASMSTR("from: @(#)ffs.s 8.1 (Berkeley) 6/4/93") | | 38 | /* RCSID("from: @(#)ffs.s 8.1 (Berkeley) 6/4/93") */ |
39 | ASMSTR("$NetBSD: ffs.S,v 1.1 2005/12/20 19:28:49 christos Exp $") | | 39 | RCSID("$NetBSD: ffs.S,v 1.2 2009/12/14 00:39:00 matt Exp $") |
40 | #endif /* LIBC_SCCS and not lint */ | | 40 | #endif /* LIBC_SCCS and not lint */ |
41 | | | 41 | |
42 | #ifdef __ABICALLS__ | | | |
43 | .abicalls | | | |
44 | #endif | | | |
45 | | | | |
46 | /* bit = ffs(value) */ | | 42 | /* bit = ffs(value) */ |
47 | | | 43 | |
48 | LEAF(ffs) | | 44 | LEAF(ffs) |
49 | move v0, zero | | 45 | move v0, zero |
50 | beq a0, zero, done | | 46 | beq a0, zero, done |
51 | 1: | | 47 | 1: |
52 | and v1, a0, 1 # bit set? | | 48 | and v1, a0, 1 # bit set? |
53 | addu v0, v0, 1 | | 49 | addu v0, v0, 1 |
54 | srl a0, a0, 1 | | 50 | srl a0, a0, 1 |
55 | beq v1, zero, 1b # no, continue | | 51 | beq v1, zero, 1b # no, continue |
56 | done: | | 52 | done: |
57 | j ra | | 53 | j ra |
58 | END(ffs) | | 54 | END(ffs) |
--- src/common/lib/libc/arch/mips/string/strcmp.S 2005/12/20 19:28:50 1.1
+++ src/common/lib/libc/arch/mips/string/strcmp.S 2009/12/14 00:39:00 1.2
| @@ -1,67 +1,63 @@ | | | @@ -1,67 +1,63 @@ |
1 | /* $NetBSD: strcmp.S,v 1.1 2005/12/20 19:28:50 christos Exp $ */ | | 1 | /* $NetBSD: strcmp.S,v 1.2 2009/12/14 00:39:00 matt Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1991, 1993 | | 4 | * Copyright (c) 1991, 1993 |
5 | * The Regents of the University of California. All rights reserved. | | 5 | * The Regents of the University of California. All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to Berkeley by | | 7 | * This code is derived from software contributed to Berkeley by |
8 | * Ralph Campbell. | | 8 | * Ralph Campbell. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
15 | * 2. Redistributions in binary form must reproduce the above copyright | | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
16 | * notice, this list of conditions and the following disclaimer in the | | 16 | * notice, this list of conditions and the following disclaimer in the |
17 | * documentation and/or other materials provided with the distribution. | | 17 | * documentation and/or other materials provided with the distribution. |
18 | * 3. Neither the name of the University nor the names of its contributors | | 18 | * 3. Neither the name of the University nor the names of its contributors |
19 | * may be used to endorse or promote products derived from this software | | 19 | * may be used to endorse or promote products derived from this software |
20 | * without specific prior written permission. | | 20 | * without specific prior written permission. |
21 | * | | 21 | * |
22 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | | 22 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | | 23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | | 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | | 25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
32 | * SUCH DAMAGE. | | 32 | * SUCH DAMAGE. |
33 | */ | | 33 | */ |
34 | | | 34 | |
35 | #include <mips/asm.h> | | 35 | #include <mips/asm.h> |
36 | | | 36 | |
37 | #if defined(LIBC_SCCS) && !defined(lint) | | 37 | #if defined(LIBC_SCCS) && !defined(lint) |
38 | ASMSTR("from: @(#)strcmp.s 8.1 (Berkeley) 6/4/93") | | 38 | /* RCSID("from: @(#)strcmp.s 8.1 (Berkeley) 6/4/93") */ |
39 | ASMSTR("$NetBSD: strcmp.S,v 1.1 2005/12/20 19:28:50 christos Exp $") | | 39 | RCSID("$NetBSD: strcmp.S,v 1.2 2009/12/14 00:39:00 matt Exp $") |
40 | #endif /* LIBC_SCCS and not lint */ | | 40 | #endif /* LIBC_SCCS and not lint */ |
41 | | | 41 | |
42 | #ifdef __ABICALLS__ | | | |
43 | .abicalls | | | |
44 | #endif | | | |
45 | | | | |
46 | /* | | 42 | /* |
47 | * NOTE: this version assumes unsigned chars in order to be "8 bit clean". | | 43 | * NOTE: this version assumes unsigned chars in order to be "8 bit clean". |
48 | */ | | 44 | */ |
49 | LEAF(strcmp) | | 45 | LEAF(strcmp) |
50 | 1: | | 46 | 1: |
51 | lbu t0, 0(a0) # get two bytes and compare them | | 47 | lbu t0, 0(a0) # get two bytes and compare them |
52 | lbu t1, 0(a1) | | 48 | lbu t1, 0(a1) |
53 | beq t0, zero, LessOrEq # end of first string? | | 49 | beq t0, zero, LessOrEq # end of first string? |
54 | bne t0, t1, NotEq | | 50 | bne t0, t1, NotEq |
55 | lbu t0, 1(a0) # unroll loop | | 51 | lbu t0, 1(a0) # unroll loop |
56 | lbu t1, 1(a1) | | 52 | lbu t1, 1(a1) |
57 | add a0, a0, 2 | | 53 | PTR_ADD a0, a0, 2 |
58 | beq t0, zero, LessOrEq # end of first string? | | 54 | beq t0, zero, LessOrEq # end of first string? |
59 | add a1, a1, 2 | | 55 | PTR_ADD a1, a1, 2 |
60 | beq t0, t1, 1b | | 56 | beq t0, t1, 1b |
61 | NotEq: | | 57 | NotEq: |
62 | subu v0, t0, t1 | | 58 | subu v0, t0, t1 |
63 | j ra | | 59 | j ra |
64 | LessOrEq: | | 60 | LessOrEq: |
65 | subu v0, zero, t1 | | 61 | subu v0, zero, t1 |
66 | j ra | | 62 | j ra |
67 | END(strcmp) | | 63 | END(strcmp) |
--- src/common/lib/libc/arch/mips/string/strlen.S 2005/12/20 19:28:50 1.1
+++ src/common/lib/libc/arch/mips/string/strlen.S 2009/12/14 00:39:00 1.2
| @@ -1,54 +1,50 @@ | | | @@ -1,54 +1,50 @@ |
1 | /* $NetBSD: strlen.S,v 1.1 2005/12/20 19:28:50 christos Exp $ */ | | 1 | /* $NetBSD: strlen.S,v 1.2 2009/12/14 00:39:00 matt Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1991, 1993 | | 4 | * Copyright (c) 1991, 1993 |
5 | * The Regents of the University of California. All rights reserved. | | 5 | * The Regents of the University of California. All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to Berkeley by | | 7 | * This code is derived from software contributed to Berkeley by |
8 | * Ralph Campbell. | | 8 | * Ralph Campbell. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
15 | * 2. Redistributions in binary form must reproduce the above copyright | | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
16 | * notice, this list of conditions and the following disclaimer in the | | 16 | * notice, this list of conditions and the following disclaimer in the |
17 | * documentation and/or other materials provided with the distribution. | | 17 | * documentation and/or other materials provided with the distribution. |
18 | * 3. Neither the name of the University nor the names of its contributors | | 18 | * 3. Neither the name of the University nor the names of its contributors |
19 | * may be used to endorse or promote products derived from this software | | 19 | * may be used to endorse or promote products derived from this software |
20 | * without specific prior written permission. | | 20 | * without specific prior written permission. |
21 | * | | 21 | * |
22 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | | 22 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | | 23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | | 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | | 25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
32 | * SUCH DAMAGE. | | 32 | * SUCH DAMAGE. |
33 | */ | | 33 | */ |
34 | | | 34 | |
35 | #include <mips/asm.h> | | 35 | #include <mips/asm.h> |
36 | | | 36 | |
37 | #if defined(LIBC_SCCS) && !defined(lint) | | 37 | #if defined(LIBC_SCCS) && !defined(lint) |
38 | ASMSTR("from: @(#)strlen.s 8.1 (Berkeley) 6/4/93") | | 38 | /* RCSID("from: @(#)strlen.s 8.1 (Berkeley) 6/4/93") */ |
39 | ASMSTR("$NetBSD: strlen.S,v 1.1 2005/12/20 19:28:50 christos Exp $") | | 39 | RCSID("$NetBSD: strlen.S,v 1.2 2009/12/14 00:39:00 matt Exp $") |
40 | #endif /* LIBC_SCCS and not lint */ | | 40 | #endif /* LIBC_SCCS and not lint */ |
41 | | | 41 | |
42 | #ifdef __ABICALLS__ | | | |
43 | .abicalls | | | |
44 | #endif | | | |
45 | | | | |
46 | LEAF(strlen) | | 42 | LEAF(strlen) |
47 | addu v1, a0, 1 | | 43 | PTR_ADDU v1, a0, 1 |
48 | 1: | | 44 | 1: |
49 | lb v0, 0(a0) # get byte from string | | 45 | lb v0, 0(a0) # get byte from string |
50 | addu a0, a0, 1 # increment pointer | | 46 | PTR_ADDU a0, a0, 1 # increment pointer |
51 | bne v0, zero, 1b # continue if not end | | 47 | bne v0, zero, 1b # continue if not end |
52 | subu v0, a0, v1 # compute length - 1 for '\0' char | | 48 | PTR_SUBU v0, a0, v1 # compute length - 1 for '\0' char |
53 | j ra | | 49 | j ra |
54 | END(strlen) | | 50 | END(strlen) |
--- src/common/lib/libc/atomic/atomic_init_testset.c 2009/01/30 14:29:44 1.6
+++ src/common/lib/libc/atomic/atomic_init_testset.c 2009/12/14 00:39:00 1.7
| @@ -1,154 +1,154 @@ | | | @@ -1,154 +1,154 @@ |
1 | /* $NetBSD: atomic_init_testset.c,v 1.6 2009/01/30 14:29:44 skrll Exp $ */ | | 1 | /* $NetBSD: atomic_init_testset.c,v 1.7 2009/12/14 00:39:00 matt Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2008 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2008 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
15 | * | | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | | 16 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS |
17 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 17 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
26 | * POSSIBILITY OF SUCH DAMAGE. | | 26 | * POSSIBILITY OF SUCH DAMAGE. |
27 | */ | | 27 | */ |
28 | | | 28 | |
29 | /* | | 29 | /* |
30 | * libc glue for atomic operations where the hardware does not provide | | 30 | * libc glue for atomic operations where the hardware does not provide |
31 | * compare-and-swap. It's assumed that this will only be used on 32-bit | | 31 | * compare-and-swap. It's assumed that this will only be used on 32-bit |
32 | * platforms. | | 32 | * platforms. |
33 | * | | 33 | * |
34 | * This should be compiled with '-fno-reorder-blocks -fomit-frame-pointer' | | 34 | * This should be compiled with '-fno-reorder-blocks -fomit-frame-pointer' |
35 | * if using gcc. | | 35 | * if using gcc. |
36 | */ | | 36 | */ |
37 | | | 37 | |
38 | #include <sys/cdefs.h> | | 38 | #include <sys/cdefs.h> |
39 | __RCSID("$NetBSD: atomic_init_testset.c,v 1.6 2009/01/30 14:29:44 skrll Exp $"); | | 39 | __RCSID("$NetBSD: atomic_init_testset.c,v 1.7 2009/12/14 00:39:00 matt Exp $"); |
40 | | | 40 | |
41 | #include "atomic_op_namespace.h" | | 41 | #include "atomic_op_namespace.h" |
42 | | | 42 | |
43 | #include <sys/types.h> | | 43 | #include <sys/types.h> |
44 | #include <sys/atomic.h> | | 44 | #include <sys/atomic.h> |
45 | #include <sys/lock.h> | | 45 | #include <sys/lock.h> |
46 | #include <sys/ras.h> | | 46 | #include <sys/ras.h> |
47 | #include <sys/sysctl.h> | | 47 | #include <sys/sysctl.h> |
48 | | | 48 | |
49 | #include <string.h> | | 49 | #include <string.h> |
50 | | | 50 | |
51 | #define I2 __SIMPLELOCK_UNLOCKED, __SIMPLELOCK_UNLOCKED, | | 51 | #define I2 __SIMPLELOCK_UNLOCKED, __SIMPLELOCK_UNLOCKED, |
52 | #define I16 I2 I2 I2 I2 I2 I2 I2 I2 | | 52 | #define I16 I2 I2 I2 I2 I2 I2 I2 I2 |
53 | #define I128 I16 I16 I16 I16 I16 I16 I16 I16 | | 53 | #define I128 I16 I16 I16 I16 I16 I16 I16 I16 |
54 | | | 54 | |
55 | static __cpu_simple_lock_t atomic_locks[128] = { I128 }; | | 55 | static __cpu_simple_lock_t atomic_locks[128] = { I128 }; |
56 | | | 56 | |
57 | #ifdef __HAVE_ASM_ATOMIC_CAS_UP | | 57 | #ifdef __HAVE_ASM_ATOMIC_CAS_UP |
58 | extern uint32_t _atomic_cas_up(volatile uint32_t *, uint32_t, uint32_t); | | 58 | extern uint32_t _atomic_cas_up(volatile uint32_t *, uint32_t, uint32_t); |
59 | #else | | 59 | #else |
60 | static uint32_t _atomic_cas_up(volatile uint32_t *, uint32_t, uint32_t); | | 60 | static uint32_t _atomic_cas_up(volatile uint32_t *, uint32_t, uint32_t); |
61 | #endif | | 61 | #endif |
62 | | | 62 | |
63 | static uint32_t (*_atomic_cas_fn)(volatile uint32_t *, uint32_t, uint32_t) = | | 63 | static uint32_t (*_atomic_cas_fn)(volatile uint32_t *, uint32_t, uint32_t) = |
64 | _atomic_cas_up; | | 64 | _atomic_cas_up; |
65 | | | 65 | |
66 | void __libc_atomic_init(void) __attribute__ ((visibility("hidden"))); | | 66 | void __libc_atomic_init(void) __attribute__ ((visibility("hidden"))); |
67 | | | 67 | |
68 | RAS_DECL(_atomic_cas); | | 68 | RAS_DECL(_atomic_cas); |
69 | | | 69 | |
70 | #ifndef __HAVE_ASM_ATOMIC_CAS_UP | | 70 | #ifndef __HAVE_ASM_ATOMIC_CAS_UP |
71 | static uint32_t | | 71 | static uint32_t |
72 | _atomic_cas_up(volatile uint32_t *ptr, uint32_t old, uint32_t new) | | 72 | _atomic_cas_up(volatile uint32_t *ptr, uint32_t old, uint32_t new) |
73 | { | | 73 | { |
74 | uint32_t ret; | | 74 | uint32_t ret; |
75 | | | 75 | |
76 | RAS_START(_atomic_cas); | | 76 | RAS_START(_atomic_cas); |
77 | ret = *ptr; | | 77 | ret = *ptr; |
78 | if (__predict_false(ret != old)) { | | 78 | if (__predict_false(ret != old)) { |
79 | return ret; | | 79 | return ret; |
80 | } | | 80 | } |
81 | *ptr = new; | | 81 | *ptr = new; |
82 | RAS_END(_atomic_cas); | | 82 | RAS_END(_atomic_cas); |
83 | | | 83 | |
84 | return ret; | | 84 | return ret; |
85 | } | | 85 | } |
86 | #endif | | 86 | #endif |
87 | | | 87 | |
88 | static uint32_t | | 88 | static uint32_t |
89 | _atomic_cas_mp(volatile uint32_t *ptr, uint32_t old, uint32_t new) | | 89 | _atomic_cas_mp(volatile uint32_t *ptr, uint32_t old, uint32_t new) |
90 | { | | 90 | { |
91 | __cpu_simple_lock_t *lock; | | 91 | __cpu_simple_lock_t *lock; |
92 | uint32_t ret; | | 92 | uint32_t ret; |
93 | | | 93 | |
94 | lock = &atomic_locks[((uint32_t)ptr >> 3) & 127]; | | 94 | lock = &atomic_locks[((uintptr_t)ptr >> 3) & 127]; |
95 | __cpu_simple_lock(lock); | | 95 | __cpu_simple_lock(lock); |
96 | ret = *ptr; | | 96 | ret = *ptr; |
97 | if (__predict_true(ret == old)) { | | 97 | if (__predict_true(ret == old)) { |
98 | *ptr = new; | | 98 | *ptr = new; |
99 | } | | 99 | } |
100 | __cpu_simple_unlock(lock); | | 100 | __cpu_simple_unlock(lock); |
101 | | | 101 | |
102 | return ret; | | 102 | return ret; |
103 | } | | 103 | } |
104 | | | 104 | |
105 | uint32_t | | 105 | uint32_t |
106 | _atomic_cas_32(volatile uint32_t *ptr, uint32_t old, uint32_t new) | | 106 | _atomic_cas_32(volatile uint32_t *ptr, uint32_t old, uint32_t new) |
107 | { | | 107 | { |
108 | | | 108 | |
109 | return (*_atomic_cas_fn)(ptr, old, new); | | 109 | return (*_atomic_cas_fn)(ptr, old, new); |
110 | } | | 110 | } |
111 | | | 111 | |
112 | void | | 112 | void |
113 | __libc_atomic_init(void) | | 113 | __libc_atomic_init(void) |
114 | { | | 114 | { |
115 | int ncpu, mib[2]; | | 115 | int ncpu, mib[2]; |
116 | size_t len; | | 116 | size_t len; |
117 | | | 117 | |
118 | _atomic_cas_fn = _atomic_cas_mp; | | 118 | _atomic_cas_fn = _atomic_cas_mp; |
119 | | | 119 | |
120 | mib[0] = CTL_HW; | | 120 | mib[0] = CTL_HW; |
121 | mib[1] = HW_NCPU; | | 121 | mib[1] = HW_NCPU; |
122 | len = sizeof(ncpu); | | 122 | len = sizeof(ncpu); |
123 | if (sysctl(mib, 2, &ncpu, &len, NULL, 0) == -1) | | 123 | if (sysctl(mib, 2, &ncpu, &len, NULL, 0) == -1) |
124 | return; | | 124 | return; |
125 | if (ncpu > 1) | | 125 | if (ncpu > 1) |
126 | return; | | 126 | return; |
127 | if (rasctl(RAS_ADDR(_atomic_cas), RAS_SIZE(_atomic_cas), | | 127 | if (rasctl(RAS_ADDR(_atomic_cas), RAS_SIZE(_atomic_cas), |
128 | RAS_INSTALL) == 0) { | | 128 | RAS_INSTALL) == 0) { |
129 | _atomic_cas_fn = _atomic_cas_up; | | 129 | _atomic_cas_fn = _atomic_cas_up; |
130 | return; | | 130 | return; |
131 | } | | 131 | } |
132 | } | | 132 | } |
133 | | | 133 | |
134 | #undef atomic_cas_32 | | 134 | #undef atomic_cas_32 |
135 | #undef atomic_cas_uint | | 135 | #undef atomic_cas_uint |
136 | #undef atomic_cas_ulong | | 136 | #undef atomic_cas_ulong |
137 | #undef atomic_cas_ptr | | 137 | #undef atomic_cas_ptr |
138 | | | 138 | |
139 | atomic_op_alias(atomic_cas_32,_atomic_cas_32) | | 139 | atomic_op_alias(atomic_cas_32,_atomic_cas_32) |
140 | atomic_op_alias(atomic_cas_uint,_atomic_cas_32) | | 140 | atomic_op_alias(atomic_cas_uint,_atomic_cas_32) |
141 | __strong_alias(_atomic_cas_uint,_atomic_cas_32) | | 141 | __strong_alias(_atomic_cas_uint,_atomic_cas_32) |
142 | atomic_op_alias(atomic_cas_ulong,_atomic_cas_32) | | 142 | atomic_op_alias(atomic_cas_ulong,_atomic_cas_32) |
143 | __strong_alias(_atomic_cas_ulong,_atomic_cas_32) | | 143 | __strong_alias(_atomic_cas_ulong,_atomic_cas_32) |
144 | atomic_op_alias(atomic_cas_ptr,_atomic_cas_32) | | 144 | atomic_op_alias(atomic_cas_ptr,_atomic_cas_32) |
145 | __strong_alias(_atomic_cas_ptr,_atomic_cas_32) | | 145 | __strong_alias(_atomic_cas_ptr,_atomic_cas_32) |
146 | | | 146 | |
147 | atomic_op_alias(atomic_cas_32_ni,_atomic_cas_32) | | 147 | atomic_op_alias(atomic_cas_32_ni,_atomic_cas_32) |
148 | __strong_alias(_atomic_cas_32_ni,_atomic_cas_32) | | 148 | __strong_alias(_atomic_cas_32_ni,_atomic_cas_32) |
149 | atomic_op_alias(atomic_cas_uint_ni,_atomic_cas_32) | | 149 | atomic_op_alias(atomic_cas_uint_ni,_atomic_cas_32) |
150 | __strong_alias(_atomic_cas_uint_ni,_atomic_cas_32) | | 150 | __strong_alias(_atomic_cas_uint_ni,_atomic_cas_32) |
151 | atomic_op_alias(atomic_cas_ulong_ni,_atomic_cas_32) | | 151 | atomic_op_alias(atomic_cas_ulong_ni,_atomic_cas_32) |
152 | __strong_alias(_atomic_cas_ulong_ni,_atomic_cas_32) | | 152 | __strong_alias(_atomic_cas_ulong_ni,_atomic_cas_32) |
153 | atomic_op_alias(atomic_cas_ptr_ni,_atomic_cas_32) | | 153 | atomic_op_alias(atomic_cas_ptr_ni,_atomic_cas_32) |
154 | __strong_alias(_atomic_cas_ptr_ni,_atomic_cas_32) | | 154 | __strong_alias(_atomic_cas_ptr_ni,_atomic_cas_32) |
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas <matt@3am-software.com>.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#define BZERO
#include "memset2.c"
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: bzero2.c,v 1.2 2009/12/14 00:39:01 matt Exp $");
#endif /* LIBC_SCCS and not lint */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas <matt@3am-software.com>.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/types.h>
#if !defined(_KERNEL) && !defined(_STANDALONE)
#include <assert.h>
#include <limits.h>
#include <string.h>
#include <inttypes.h>
#else
#include <lib/libkern/libkern.h>
#include <machine/limits.h>
#endif
#include <sys/endian.h>
#include <machine/types.h>
#ifdef TEST
#include <assert.h>
#define _DIAGASSERT(a) assert(a)
#endif
#ifdef _FORTIFY_SOURCE
#undef bzero
#undef memset
#endif
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: memset2.c,v 1.2 2009/12/14 00:39:01 matt Exp $");
#endif /* LIBC_SCCS and not lint */
/*
* Assume uregister_t is the widest non-synthetic unsigned type.
*/
typedef uregister_t memword_t;
#ifdef BZERO
static inline
#define memset memset0
#endif
#ifdef TEST
static
#define memset test_memset
#endif
#ifdef CTASSERT
CTASSERT((~(memword_t)0U >> 1) != ~(memword_t)0U);
#endif
void *
memset(void *addr, int c, size_t len)
{
memword_t *dstp = addr;
memword_t *edstp;
memword_t fill;
#ifndef __OPTIMIZE_SIZE__
memword_t keep_mask = 0;
#endif
size_t fill_count;
_DIAGASSERT(addr != 0);
if (__predict_false(len == 0))
return addr;
/*
* Pad out the fill byte (v) across a memword_t.
* The conditional at the end prevents GCC from complaing about
* shift count >= width of type
*/
fill = c;
fill |= fill << 8;
fill |= fill << 16;
fill |= fill << (sizeof(c) < sizeof(fill) ? 32 : 0);
/*
* Get the number of unaligned bytes to fill in the first word.
*/
fill_count = -(uintptr_t)addr & (sizeof(memword_t) - 1);
if (__predict_false(fill_count != 0)) {
#ifndef __OPTIMIZE_SIZE__
/*
* We want to clear <fill_count> trailing bytes in the word.
* On big/little endian, these are the least/most significant,
* bits respectively. So as we shift, the keep_mask will only
* have bits set for the bytes we won't be filling.
*/
#if BYTE_ORDER == BIG_ENDIAN
keep_mask = ~(memword_t)0U << (fill_count * 8);
#endif
#if BYTE_ORDER == LITTLE_ENDIAN
keep_mask = ~(memword_t)0U >> (fill_count * 8);
#endif
/*
* Make sure dstp is aligned to a memword_t boundary.
*/
dstp = (memword_t *)((uintptr_t)addr & -sizeof(memword_t));
if (len >= fill_count) {
/*
* If we can fill the rest of this word, then we mask
* off the bytes we are filling and then fill in those
* bytes with the new fill value.
*/
*dstp = (*dstp & keep_mask) | (fill & ~keep_mask);
len -= fill_count;
if (__predict_false(len == 0))
return addr;
/*
* Since we were able to fill the rest of this word,
* we will advance to the next word and thus have no
* bytes to preserve.
*
* If we don't have enough to fill the rest of this
* word, we will fall through the following loop
* (since there are no full words to fill). Then we
* use the keep_mask above to preserve the leading
* bytes of word.
*/
dstp++;
keep_mask = 0;
} else {
len += (uintptr_t)addr & (sizeof(memword_t) - 1);
}
#else /* __OPTIMIZE_SIZE__ */
uint8_t *dp, *ep;
if (len < fill_count)
fill_count = len;
for (dp = (uint8_t *)dstp, ep = dp + fill_count;
dp != ep; dp++)
*dp = fill;
if ((len -= fill_count) == 0)
return addr;
dstp = (memword_t *)ep;
#endif /* __OPTIMIZE_SIZE__ */
}
/*
* Simply fill memory one word at time (for as many full words we have
* to write).
*/
for (edstp = dstp + len / sizeof(memword_t); dstp != edstp; dstp++)
*dstp = fill;
/*
* We didn't subtract out the full words we just filled since we know
* by the time we get here we will have less than a words worth to
* write. So we can concern ourselves with only the subword len bits.
*/
len &= sizeof(memword_t)-1;
if (len > 0) {
#ifndef __OPTIMIZE_SIZE__
/*
* We want to clear <len> leading bytes in the word.
* On big/little endian, these are the most/least significant
* bits, respectively, But as we want the mask of the bytes to
* keep, we have to complement the mask. So after we shift,
* the keep_mask will only have bits set for the bytes we won't
* be filling.
*
* But the keep_mask could already have bytes to preserve
* if the amount to fill was less than the amount of traiing
* space in the first word.
*/
#if BYTE_ORDER == BIG_ENDIAN
keep_mask |= ~(memword_t)0U >> (len * 8);
#endif
#if BYTE_ORDER == LITTLE_ENDIAN
keep_mask |= ~(memword_t)0U << (len * 8);
#endif
/*
* Now we mask off the bytes we are filling and then fill in
* those bytes with the new fill value.
*/
*dstp = (*dstp & keep_mask) | (fill & ~keep_mask);
#else /* __OPTIMIZE_SIZE__ */
uint8_t *dp, *ep;
for (dp = (uint8_t *)dstp, ep = dp + len;
dp != ep; dp++)
*dp = fill;
#endif /* __OPTIMIZE_SIZE__ */
}
/*
* Return the initial addr
*/
return addr;
}
#ifdef BZERO
/*
* For bzero, simply inline memset and let the compiler optimize things away.
*/
void
bzero(void *addr, size_t len)
{
memset(addr, 0, len);
}
#endif
#ifdef TEST
#include <stdbool.h>
#include <stdio.h>
#undef memset
static union {
uint8_t bytes[sizeof(memword_t) * 4];
memword_t words[4];
} testmem;
int
main(int argc, char **argv)
{
size_t start;
size_t len;
bool failed = false;
for (start = 1; start < sizeof(testmem) - 1; start++) {
for (len = 1; start + len < sizeof(testmem) - 1; len++) {
bool ok = true;
size_t i;
uint8_t check_value;
memset(testmem.bytes, 0xff, sizeof(testmem));
test_memset(testmem.bytes + start, 0x00, len);
for (i = 0; i < sizeof(testmem); i++) {
if (i == 0 || i == start + len)
check_value = 0xff;
else if (i == start)
check_value = 0x00;
if (testmem.bytes[i] != check_value) {
if (ok)
printf("pass @ %zu .. %zu failed",
start, start + len - 1);
ok = false;
printf(" [%zu]=0x%02x(!0x%02x)",
i, testmem.bytes[i], check_value);
}
}
if (!ok) {
printf("\n");
failed = 1;
}
}
}
return failed ? 1 : 0;
}
#endif /* TEST */