Import unmodified NetBSD libc in trunk
This patch imports the unmodified current version of NetBSD libc. The NetBSD includes are in /nbsd_include, while the libc code itself is split between lib/nbsd_libc and common/lib/libc.
This commit is contained in:
parent
43d1edf88c
commit
b6cbf7203b
3215 changed files with 401041 additions and 0 deletions
37
common/lib/libc/Makefile.inc
Normal file
37
common/lib/libc/Makefile.inc
Normal file
|
@ -0,0 +1,37 @@
|
|||
# $NetBSD: Makefile.inc,v 1.10 2008/10/26 07:22:50 mrg Exp $
|
||||
|
||||
COMMON_DIR:=${.PARSEDIR}
|
||||
COMMON_CODEDIRS=atomic gen gmon inet md net quad stdlib string sys
|
||||
COMMON_CODEDIRS+=hash/sha1 hash/sha2 hash/rmd160
|
||||
|
||||
.if defined(COMMON_MACHINE_ARCH) && !empty(COMMON_MACHINE_ARCH) && \
|
||||
exists(${COMMON_DIR}/arch/${COMMON_MACHINE_ARCH})
|
||||
COMMON_ARCHSUBDIR= ${COMMON_MACHINE_ARCH}
|
||||
.elif defined(LIBKERN_ARCH) && !empty(LIBKERN_ARCH) && \
|
||||
exists(${KERNDIR}/arch/${LIBKERN_ARCH})
|
||||
COMMON_ARCHSUBDIR= ${LIBKERN_ARCH}
|
||||
.elif exists(${COMMON_DIR}/arch/${MACHINE_ARCH})
|
||||
COMMON_ARCHSUBDIR= ${MACHINE_ARCH}
|
||||
.elif exists(${COMMON_DIR}/arch/${MACHINE_CPU})
|
||||
COMMON_ARCHSUBDIR= ${MACHINE_CPU}
|
||||
.endif
|
||||
|
||||
COMMON_ARCHDIR=${COMMON_DIR}/arch/${COMMON_ARCHSUBDIR}
|
||||
|
||||
.for i in ${COMMON_CODEDIRS}
|
||||
.if exists(${COMMON_DIR}/$i)
|
||||
.PATH.c: ${COMMON_DIR}/$i
|
||||
.endif
|
||||
.if exists(${COMMON_ARCHDIR}/${i}/Makefile.inc)
|
||||
.include "${COMMON_ARCHDIR}/${i}/Makefile.inc"
|
||||
.endif
|
||||
.if exists(${COMMON_ARCHDIR}/$i)
|
||||
.PATH.c: ${COMMON_ARCHDIR}/$i
|
||||
.PATH.S: ${COMMON_ARCHDIR}/$i
|
||||
.endif
|
||||
.endfor
|
||||
|
||||
CPPFLAGS+=-I${COMMON_DIR}/quad -I${COMMON_DIR}/string
|
||||
.if defined(COMMON_ARCHSUBDIR)
|
||||
CPPFLAGS+=-I${COMMON_ARCHDIR}/string
|
||||
.endif
|
15
common/lib/libc/arch/alpha/atomic/Makefile.inc
Normal file
15
common/lib/libc/arch/alpha/atomic/Makefile.inc
Normal file
|
@ -0,0 +1,15 @@
|
|||
# $NetBSD: Makefile.inc,v 1.5 2009/01/04 17:54:29 pooka Exp $
|
||||
|
||||
.if defined(LIB) && (${LIB} == "kern" || ${LIB} == "c" || ${LIB} == "pthread" \
|
||||
|| ${LIB} == "rump")
|
||||
|
||||
SRCS+= atomic_add.S atomic_and.S atomic_cas.S atomic_dec.S \
|
||||
atomic_inc.S atomic_or.S atomic_swap.S membar_ops.S
|
||||
|
||||
.endif
|
||||
|
||||
.if defined(LIB) && (${LIB} == "c" || ${LIB} == "pthread")
|
||||
|
||||
SRCS+= atomic_init_cas.c
|
||||
|
||||
.endif
|
88
common/lib/libc/arch/alpha/atomic/atomic_add.S
Normal file
88
common/lib/libc/arch/alpha/atomic/atomic_add.S
Normal file
|
@ -0,0 +1,88 @@
|
|||
/* $NetBSD: atomic_add.S,v 1.4 2008/05/25 15:56:11 chs Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Jason R. Thorpe.
|
||||
*
|
||||
* 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 "atomic_op_asm.h"
|
||||
|
||||
.text
|
||||
|
||||
LEAF(_atomic_add_32, 2)
|
||||
1: ldl_l t1, 0(a0)
|
||||
addl t1, a1, t2
|
||||
stl_c t2, 0(a0)
|
||||
beq t2, 2f
|
||||
RET
|
||||
2: br 1b
|
||||
END(_atomic_add_32)
|
||||
ATOMIC_OP_ALIAS(atomic_add_32,_atomic_add_32)
|
||||
ATOMIC_OP_ALIAS(atomic_add_int,_atomic_add_32)
|
||||
STRONG_ALIAS(_atomic_add_int,_atomic_add_32)
|
||||
|
||||
LEAF(_atomic_add_32_nv, 2)
|
||||
1: ldl_l t1, 0(a0)
|
||||
addl t1, a1, t2
|
||||
mov t2, v0
|
||||
stl_c t2, 0(a0)
|
||||
beq t2, 2f
|
||||
RET
|
||||
2: br 1b
|
||||
END(_atomic_add_32_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_add_32_nv,_atomic_add_32_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_add_int_nv,_atomic_add_32_nv)
|
||||
STRONG_ALIAS(_atomic_add_int_nv,_atomic_add_32_nv)
|
||||
|
||||
LEAF(_atomic_add_64, 2)
|
||||
1: ldq_l t1, 0(a0)
|
||||
addq t1, a1, t2
|
||||
stq_c t2, 0(a0)
|
||||
beq t2, 2f
|
||||
RET
|
||||
2: br 1b
|
||||
END(_atomic_add_64)
|
||||
ATOMIC_OP_ALIAS(atomic_add_64,_atomic_add_64)
|
||||
ATOMIC_OP_ALIAS(atomic_add_long,_atomic_add_64)
|
||||
STRONG_ALIAS(_atomic_add_long,_atomic_add_64)
|
||||
ATOMIC_OP_ALIAS(atomic_add_ptr,_atomic_add_64)
|
||||
STRONG_ALIAS(_atomic_add_ptr,_atomic_add_64)
|
||||
|
||||
LEAF(_atomic_add_64_nv, 2)
|
||||
1: ldq_l t1, 0(a0)
|
||||
addq t1, a1, t2
|
||||
mov t2, v0
|
||||
stq_c t2, 0(a0)
|
||||
beq t2, 2f
|
||||
RET
|
||||
2: br 1b
|
||||
END(_atomic_add_64_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_add_64_nv,_atomic_add_64_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_add_long_nv,_atomic_add_64_nv)
|
||||
STRONG_ALIAS(_atomic_add_long_nv,_atomic_add_64_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_add_ptr_nv,_atomic_add_64_nv)
|
||||
STRONG_ALIAS(_atomic_add_ptr_nv,_atomic_add_64_nv)
|
84
common/lib/libc/arch/alpha/atomic/atomic_and.S
Normal file
84
common/lib/libc/arch/alpha/atomic/atomic_and.S
Normal file
|
@ -0,0 +1,84 @@
|
|||
/* $NetBSD: atomic_and.S,v 1.4 2008/05/25 15:56:11 chs Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Jason R. Thorpe.
|
||||
*
|
||||
* 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 "atomic_op_asm.h"
|
||||
|
||||
.text
|
||||
|
||||
LEAF(_atomic_and_32, 2)
|
||||
1: ldl_l t1, 0(a0)
|
||||
and t1, a1, t2
|
||||
stl_c t2, 0(a0)
|
||||
beq t2, 2f
|
||||
RET
|
||||
2: br 1b
|
||||
END(_atomic_and_32)
|
||||
ATOMIC_OP_ALIAS(atomic_and_32,_atomic_and_32)
|
||||
ATOMIC_OP_ALIAS(atomic_and_uint,_atomic_and_32)
|
||||
STRONG_ALIAS(_atomic_and_uint,_atomic_and_32)
|
||||
|
||||
LEAF(_atomic_and_32_nv, 2)
|
||||
1: ldl_l t1, 0(a0)
|
||||
and t1, a1, t2
|
||||
mov t2, v0
|
||||
stl_c t2, 0(a0)
|
||||
beq t2, 2f
|
||||
RET
|
||||
2: br 1b
|
||||
END(_atomic_and_32_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_and_32_nv,_atomic_and_32_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_and_uint_nv,_atomic_and_32_nv)
|
||||
STRONG_ALIAS(_atomic_and_uint_nv,_atomic_and_32_nv)
|
||||
|
||||
LEAF(_atomic_and_64, 2)
|
||||
1: ldq_l t1, 0(a0)
|
||||
and t1, a1, t2
|
||||
stq_c t2, 0(a0)
|
||||
beq t2, 2f
|
||||
RET
|
||||
2: br 1b
|
||||
END(_atomic_and_64)
|
||||
ATOMIC_OP_ALIAS(atomic_and_64,_atomic_and_64)
|
||||
ATOMIC_OP_ALIAS(atomic_and_ulong,_atomic_and_64)
|
||||
STRONG_ALIAS(_atomic_and_ulong,_atomic_and_64)
|
||||
|
||||
LEAF(_atomic_and_64_nv, 2)
|
||||
1: ldq_l t1, 0(a0)
|
||||
and t1, a1, t2
|
||||
mov t2, v0
|
||||
stq_c t2, 0(a0)
|
||||
beq t2, 2f
|
||||
RET
|
||||
2: br 1b
|
||||
END(_atomic_and_64_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_and_64_nv,_atomic_and_64_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_and_ulong_nv,_atomic_and_64_nv)
|
||||
STRONG_ALIAS(_atomic_and_ulong_nv,_atomic_and_64_nv)
|
78
common/lib/libc/arch/alpha/atomic/atomic_cas.S
Normal file
78
common/lib/libc/arch/alpha/atomic/atomic_cas.S
Normal file
|
@ -0,0 +1,78 @@
|
|||
/* $NetBSD: atomic_cas.S,v 1.5 2008/05/25 15:56:11 chs Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Jason R. Thorpe.
|
||||
*
|
||||
* 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 "atomic_op_asm.h"
|
||||
|
||||
.text
|
||||
|
||||
LEAF(_atomic_cas_32, 3)
|
||||
1: mov a2, t2
|
||||
ldl_l v0, 0(a0)
|
||||
cmpeq v0, a1, t1
|
||||
beq t1, 2f
|
||||
stl_c t2, 0(a0)
|
||||
beq t2, 3f
|
||||
2: RET
|
||||
3: br 1b
|
||||
END(_atomic_cas_32)
|
||||
|
||||
ATOMIC_OP_ALIAS(atomic_cas_32,_atomic_cas_32)
|
||||
ATOMIC_OP_ALIAS(atomic_cas_uint,_atomic_cas_32)
|
||||
STRONG_ALIAS(_atomic_cas_uint,_atomic_cas_32)
|
||||
|
||||
ATOMIC_OP_ALIAS(atomic_cas_32_ni,_atomic_cas_32)
|
||||
STRONG_ALIAS(_atomic_cas_32_ni,_atomic_cas_32)
|
||||
ATOMIC_OP_ALIAS(atomic_cas_uint_ni,_atomic_cas_32)
|
||||
STRONG_ALIAS(_atomic_cas_uint_ni,_atomic_cas_32)
|
||||
|
||||
LEAF(_atomic_cas_64, 3)
|
||||
1: mov a2, t2
|
||||
ldq_l v0, 0(a0)
|
||||
cmpeq v0, a1, t1
|
||||
beq t1, 2f
|
||||
stq_c t2, 0(a0)
|
||||
beq t2, 3f
|
||||
2: RET
|
||||
3: br 1b
|
||||
END(_atomic_cas_64)
|
||||
|
||||
ATOMIC_OP_ALIAS(atomic_cas_64,_atomic_cas_64)
|
||||
ATOMIC_OP_ALIAS(atomic_cas_ulong,_atomic_cas_64)
|
||||
STRONG_ALIAS(_atomic_cas_ulong,_atomic_cas_64)
|
||||
ATOMIC_OP_ALIAS(atomic_cas_ptr,_atomic_cas_64)
|
||||
STRONG_ALIAS(_atomic_cas_ptr,_atomic_cas_64)
|
||||
|
||||
ATOMIC_OP_ALIAS(atomic_cas_64_ni,_atomic_cas_64)
|
||||
STRONG_ALIAS(_atomic_cas_64_ni,_atomic_cas_64)
|
||||
ATOMIC_OP_ALIAS(atomic_cas_ulong_ni,_atomic_cas_64)
|
||||
STRONG_ALIAS(_atomic_cas_ulong_ni,_atomic_cas_64)
|
||||
ATOMIC_OP_ALIAS(atomic_cas_ptr_ni,_atomic_cas_64)
|
||||
STRONG_ALIAS(_atomic_cas_ptr_ni,_atomic_cas_64)
|
88
common/lib/libc/arch/alpha/atomic/atomic_dec.S
Normal file
88
common/lib/libc/arch/alpha/atomic/atomic_dec.S
Normal file
|
@ -0,0 +1,88 @@
|
|||
/* $NetBSD: atomic_dec.S,v 1.4 2008/05/25 15:56:11 chs Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Jason R. Thorpe.
|
||||
*
|
||||
* 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 "atomic_op_asm.h"
|
||||
|
||||
.text
|
||||
|
||||
LEAF(_atomic_dec_32, 1)
|
||||
1: ldl_l t1, 0(a0)
|
||||
subl t1, 1, t2
|
||||
stl_c t2, 0(a0)
|
||||
beq t2, 2f
|
||||
RET
|
||||
2: br 1b
|
||||
END(_atomic_dec_32)
|
||||
ATOMIC_OP_ALIAS(atomic_dec_32,_atomic_dec_32)
|
||||
ATOMIC_OP_ALIAS(atomic_dec_uint,_atomic_dec_32)
|
||||
STRONG_ALIAS(_atomic_dec_uint,_atomic_dec_32)
|
||||
|
||||
LEAF(_atomic_dec_32_nv, 1)
|
||||
1: ldl_l t1, 0(a0)
|
||||
subl t1, 1, t2
|
||||
mov t2, v0
|
||||
stl_c t2, 0(a0)
|
||||
beq t2, 2f
|
||||
RET
|
||||
2: br 1b
|
||||
END(_atomic_dec_32_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_dec_32_nv,_atomic_dec_32_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_dec_uint_nv,_atomic_dec_32_nv)
|
||||
STRONG_ALIAS(_atomic_dec_uint_nv,_atomic_dec_32_nv)
|
||||
|
||||
LEAF(_atomic_dec_64, 1)
|
||||
1: ldq_l t1, 0(a0)
|
||||
subq t1, 1, t2
|
||||
stq_c t2, 0(a0)
|
||||
beq t2, 2f
|
||||
RET
|
||||
2: br 1b
|
||||
END(_atomic_dec_64)
|
||||
ATOMIC_OP_ALIAS(atomic_dec_64,_atomic_dec_64)
|
||||
ATOMIC_OP_ALIAS(atomic_dec_ulong,_atomic_dec_64)
|
||||
STRONG_ALIAS(_atomic_dec_ulong,_atomic_dec_64)
|
||||
ATOMIC_OP_ALIAS(atomic_dec_ptr,_atomic_dec_64)
|
||||
STRONG_ALIAS(_atomic_dec_ptr,_atomic_dec_64)
|
||||
|
||||
LEAF(_atomic_dec_64_nv, 1)
|
||||
1: ldq_l t1, 0(a0)
|
||||
subq t1, 1, t2
|
||||
mov t2, v0
|
||||
stq_c t2, 0(a0)
|
||||
beq t2, 2f
|
||||
RET
|
||||
2: br 1b
|
||||
END(_atomic_dec_64_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_dec_64_nv,_atomic_dec_64_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_dec_ulong_nv,_atomic_dec_64_nv)
|
||||
STRONG_ALIAS(_atomic_dec_ulong_nv,_atomic_dec_64_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_dec_ptr_nv,_atomic_dec_64_nv)
|
||||
STRONG_ALIAS(_atomic_dec_ptr_nv,_atomic_dec_64_nv)
|
88
common/lib/libc/arch/alpha/atomic/atomic_inc.S
Normal file
88
common/lib/libc/arch/alpha/atomic/atomic_inc.S
Normal file
|
@ -0,0 +1,88 @@
|
|||
/* $NetBSD: atomic_inc.S,v 1.4 2008/05/25 15:56:11 chs Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Jason R. Thorpe.
|
||||
*
|
||||
* 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 "atomic_op_asm.h"
|
||||
|
||||
.text
|
||||
|
||||
LEAF(_atomic_inc_32, 1)
|
||||
1: ldl_l t1, 0(a0)
|
||||
addl t1, 1, t2
|
||||
stl_c t2, 0(a0)
|
||||
beq t2, 2f
|
||||
RET
|
||||
2: br 1b
|
||||
END(_atomic_inc_32)
|
||||
ATOMIC_OP_ALIAS(atomic_inc_32,_atomic_inc_32)
|
||||
ATOMIC_OP_ALIAS(atomic_inc_uint,_atomic_inc_32)
|
||||
STRONG_ALIAS(_atomic_inc_uint,_atomic_inc_32)
|
||||
|
||||
LEAF(_atomic_inc_32_nv, 1)
|
||||
1: ldl_l t1, 0(a0)
|
||||
addl t1, 1, t2
|
||||
mov t2, v0
|
||||
stl_c t2, 0(a0)
|
||||
beq t2, 2f
|
||||
RET
|
||||
2: br 1b
|
||||
END(_atomic_inc_32_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_inc_32_nv,_atomic_inc_32_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_inc_uint_nv,_atomic_inc_32_nv)
|
||||
STRONG_ALIAS(_atomic_inc_uint_nv,_atomic_inc_32_nv)
|
||||
|
||||
LEAF(_atomic_inc_64, 1)
|
||||
1: ldq_l t1, 0(a0)
|
||||
addq t1, 1, t2
|
||||
stq_c t2, 0(a0)
|
||||
beq t2, 2f
|
||||
RET
|
||||
2: br 1b
|
||||
END(_atomic_inc_64)
|
||||
ATOMIC_OP_ALIAS(atomic_inc_64,_atomic_inc_64)
|
||||
ATOMIC_OP_ALIAS(atomic_inc_ulong,_atomic_inc_64)
|
||||
STRONG_ALIAS(_atomic_inc_ulong,_atomic_inc_64)
|
||||
ATOMIC_OP_ALIAS(atomic_inc_ptr,_atomic_inc_64)
|
||||
STRONG_ALIAS(_atomic_inc_ptr,_atomic_inc_64)
|
||||
|
||||
LEAF(_atomic_inc_64_nv, 1)
|
||||
1: ldq_l t1, 0(a0)
|
||||
addq t1, 1, t2
|
||||
mov t2, v0
|
||||
stq_c t2, 0(a0)
|
||||
beq t2, 2f
|
||||
RET
|
||||
2: br 1b
|
||||
END(_atomic_inc_64_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_inc_64_nv,_atomic_inc_64_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_inc_ulong_nv,_atomic_inc_64_nv)
|
||||
STRONG_ALIAS(_atomic_inc_ulong_nv,_atomic_inc_64_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_inc_ptr_nv,_atomic_inc_64_nv)
|
||||
STRONG_ALIAS(_atomic_inc_ptr_nv,_atomic_inc_64_nv)
|
47
common/lib/libc/arch/alpha/atomic/atomic_op_asm.h
Normal file
47
common/lib/libc/arch/alpha/atomic/atomic_op_asm.h
Normal file
|
@ -0,0 +1,47 @@
|
|||
/* $NetBSD: atomic_op_asm.h,v 1.3 2008/04/28 20:22:52 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Jason R. Thorpe.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef _ATOMIC_OP_ASM_H_
|
||||
#define _ATOMIC_OP_ASM_H_
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#if defined(_KERNEL)
|
||||
|
||||
#define ATOMIC_OP_ALIAS(a,s) STRONG_ALIAS(a,s)
|
||||
|
||||
#else /* _KERNEL */
|
||||
|
||||
#define ATOMIC_OP_ALIAS(a,s) WEAK_ALIAS(a,s)
|
||||
|
||||
#endif /* _KERNEL */
|
||||
|
||||
#endif /* _ATOMIC_OP_ASM_H_ */
|
84
common/lib/libc/arch/alpha/atomic/atomic_or.S
Normal file
84
common/lib/libc/arch/alpha/atomic/atomic_or.S
Normal file
|
@ -0,0 +1,84 @@
|
|||
/* $NetBSD: atomic_or.S,v 1.4 2008/05/25 15:56:11 chs Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Jason R. Thorpe.
|
||||
*
|
||||
* 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 "atomic_op_asm.h"
|
||||
|
||||
.text
|
||||
|
||||
LEAF(_atomic_or_32, 2)
|
||||
1: ldl_l t1, 0(a0)
|
||||
bis t1, a1, t2
|
||||
stl_c t2, 0(a0)
|
||||
beq t2, 2f
|
||||
RET
|
||||
2: br 1b
|
||||
END(_atomic_or_32)
|
||||
ATOMIC_OP_ALIAS(atomic_or_32,_atomic_or_32)
|
||||
ATOMIC_OP_ALIAS(atomic_or_uint,_atomic_or_32)
|
||||
STRONG_ALIAS(_atomic_or_uint,_atomic_or_32)
|
||||
|
||||
LEAF(_atomic_or_32_nv, 2)
|
||||
1: ldl_l t1, 0(a0)
|
||||
bis t1, a1, t2
|
||||
mov t2, v0
|
||||
stl_c t2, 0(a0)
|
||||
beq t2, 2f
|
||||
RET
|
||||
2: br 1b
|
||||
END(_atomic_or_32_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_or_32_nv,_atomic_or_32_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_or_uint_nv,_atomic_or_32_nv)
|
||||
STRONG_ALIAS(_atomic_or_uint_nv,_atomic_or_32_nv)
|
||||
|
||||
LEAF(_atomic_or_64, 2)
|
||||
1: ldq_l t1, 0(a0)
|
||||
bis t1, a1, t2
|
||||
stq_c t2, 0(a0)
|
||||
beq t2, 2f
|
||||
RET
|
||||
2: br 1b
|
||||
END(_atomic_or_64)
|
||||
ATOMIC_OP_ALIAS(atomic_or_64,_atomic_or_64)
|
||||
ATOMIC_OP_ALIAS(atomic_or_ulong,_atomic_or_64)
|
||||
STRONG_ALIAS(_atomic_or_ulong,_atomic_or_64)
|
||||
|
||||
LEAF(_atomic_or_64_nv, 2)
|
||||
1: ldq_l t1, 0(a0)
|
||||
bis t1, a1, t2
|
||||
mov t2, v0
|
||||
stq_c t2, 0(a0)
|
||||
beq t2, 2f
|
||||
RET
|
||||
2: br 1b
|
||||
END(_atomic_or_64_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_or_64_nv,_atomic_or_64_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_or_ulong_nv,_atomic_or_64_nv)
|
||||
STRONG_ALIAS(_atomic_or_ulong_nv,_atomic_or_64_nv)
|
60
common/lib/libc/arch/alpha/atomic/atomic_swap.S
Normal file
60
common/lib/libc/arch/alpha/atomic/atomic_swap.S
Normal file
|
@ -0,0 +1,60 @@
|
|||
/* $NetBSD: atomic_swap.S,v 1.4 2008/05/25 15:56:11 chs Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Jason R. Thorpe.
|
||||
*
|
||||
* 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 "atomic_op_asm.h"
|
||||
|
||||
.text
|
||||
|
||||
LEAF(_atomic_swap_32, 2)
|
||||
1: ldl_l v0, 0(a0)
|
||||
mov a1, t2
|
||||
stl_c t2, 0(a0)
|
||||
beq t2, 2f
|
||||
RET
|
||||
2: br 1b
|
||||
END(_atomic_swap_32)
|
||||
ATOMIC_OP_ALIAS(atomic_swap_32,_atomic_swap_32)
|
||||
ATOMIC_OP_ALIAS(atomic_swap_uint,_atomic_swap_32)
|
||||
STRONG_ALIAS(_atomic_swap_uint,_atomic_swap_32)
|
||||
|
||||
LEAF(_atomic_swap_64, 2)
|
||||
1: ldq_l v0, 0(a0)
|
||||
mov a1, t2
|
||||
stq_c t2, 0(a0)
|
||||
beq t2, 2f
|
||||
RET
|
||||
2: br 1b
|
||||
END(_atomic_swap_64)
|
||||
ATOMIC_OP_ALIAS(atomic_swap_64,_atomic_swap_64)
|
||||
ATOMIC_OP_ALIAS(atomic_swap_ulong,_atomic_swap_64)
|
||||
STRONG_ALIAS(_atomic_swap_ulong,_atomic_swap_64)
|
||||
ATOMIC_OP_ALIAS(atomic_swap_ptr,_atomic_swap_64)
|
||||
STRONG_ALIAS(_atomic_swap_ptr,_atomic_swap_64)
|
89
common/lib/libc/arch/alpha/atomic/membar_ops.S
Normal file
89
common/lib/libc/arch/alpha/atomic/membar_ops.S
Normal file
|
@ -0,0 +1,89 @@
|
|||
/* $NetBSD: membar_ops.S,v 1.6 2008/05/25 15:56:11 chs Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Jason R. Thorpe.
|
||||
*
|
||||
* 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 "atomic_op_asm.h"
|
||||
|
||||
.text
|
||||
|
||||
#ifdef _KERNEL
|
||||
|
||||
/*
|
||||
* We start out with no-op versions that do nothing. We hot-patch when
|
||||
* we detect a MP system.
|
||||
*/
|
||||
LEAF(_membar_producer, 0)
|
||||
RET
|
||||
nop
|
||||
END(_membar_producer)
|
||||
EXPORT(_membar_producer_end)
|
||||
|
||||
LEAF(_membar_sync, 0)
|
||||
RET
|
||||
nop
|
||||
END(_membar_sync)
|
||||
EXPORT(_membar_sync_end)
|
||||
|
||||
LEAF(_membar_producer_mp, 0)
|
||||
wmb
|
||||
RET
|
||||
END(_membar_producer_mp)
|
||||
EXPORT(_membar_producer_mp_end)
|
||||
|
||||
LEAF(_membar_sync_mp, 0)
|
||||
mb
|
||||
RET
|
||||
END(_membar_sync_mp)
|
||||
EXPORT(_membar_sync_mp_end)
|
||||
|
||||
#else /* _KERNEL */
|
||||
|
||||
LEAF(_membar_producer, 0)
|
||||
mb
|
||||
RET
|
||||
END(_membar_producer)
|
||||
EXPORT(_membar_producer_end)
|
||||
|
||||
LEAF(_membar_sync, 0)
|
||||
mb
|
||||
RET
|
||||
END(_membar_sync)
|
||||
EXPORT(_membar_sync_end)
|
||||
|
||||
#endif /* _KERNEL */
|
||||
|
||||
ATOMIC_OP_ALIAS(membar_producer,_membar_producer)
|
||||
ATOMIC_OP_ALIAS(membar_sync,_membar_sync)
|
||||
ATOMIC_OP_ALIAS(membar_enter,_membar_sync)
|
||||
STRONG_ALIAS(_membar_enter,_membar_sync)
|
||||
ATOMIC_OP_ALIAS(membar_exit,_membar_sync)
|
||||
STRONG_ALIAS(_membar_exit,_membar_sync)
|
||||
ATOMIC_OP_ALIAS(membar_consumer,_membar_sync)
|
||||
STRONG_ALIAS(_membar_consumer,_membar_sync)
|
49
common/lib/libc/arch/alpha/gen/byte_swap_2.S
Normal file
49
common/lib/libc/arch/alpha/gen/byte_swap_2.S
Normal file
|
@ -0,0 +1,49 @@
|
|||
/* $NetBSD: byte_swap_2.S,v 1.3 2008/02/16 17:37:13 apb Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Carnegie-Mellon University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Author: Chris G. Demetriou
|
||||
*
|
||||
* Permission to use, copy, modify and distribute this software and
|
||||
* its documentation is hereby granted, provided that both the copyright
|
||||
* notice and this permission notice appear in all copies of the
|
||||
* software, derivative works or modified versions, and any portions
|
||||
* thereof, and that both notices appear in supporting documentation.
|
||||
*
|
||||
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
|
||||
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
|
||||
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
|
||||
*
|
||||
* Carnegie Mellon requests users of this software to return to
|
||||
*
|
||||
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
|
||||
* School of Computer Science
|
||||
* Carnegie Mellon University
|
||||
* Pittsburgh PA 15213-3890
|
||||
*
|
||||
* any improvements or extensions that they make and grant Carnegie the
|
||||
* rights to redistribute these changes.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
/*
|
||||
* Byte-swap a 2-byte quantity. (Convert 0x0123 to 0x2301.)
|
||||
*
|
||||
* Argument is an unsigned 2-byte integer (uint16_t).
|
||||
*/
|
||||
#if defined(_KERNEL) || defined(_STANDALONE)
|
||||
#define BSWAP16 bswap16
|
||||
#else /* defined(_KERNEL) || defined(_STANDALONE) */
|
||||
#define BSWAP16 __bswap16
|
||||
#endif /* defined(_KERNEL) || defined(_STANDALONE) */
|
||||
LEAF(BSWAP16, 1) /* a0 contains 0x0123 */
|
||||
XLEAF(htons, 1)
|
||||
XLEAF(ntohs, 1)
|
||||
insbl a0, 1, t0 /* t0 = 0x23 */
|
||||
extbl a0, 1, t1 /* t1 = 0x 01 */
|
||||
or t0, t1, v0 /* v0 = 0x2301 */
|
||||
RET
|
||||
END(BSWAP16)
|
55
common/lib/libc/arch/alpha/gen/byte_swap_4.S
Normal file
55
common/lib/libc/arch/alpha/gen/byte_swap_4.S
Normal file
|
@ -0,0 +1,55 @@
|
|||
/* $NetBSD: byte_swap_4.S,v 1.3 2008/02/16 17:37:13 apb Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Carnegie-Mellon University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Author: Chris G. Demetriou
|
||||
*
|
||||
* Permission to use, copy, modify and distribute this software and
|
||||
* its documentation is hereby granted, provided that both the copyright
|
||||
* notice and this permission notice appear in all copies of the
|
||||
* software, derivative works or modified versions, and any portions
|
||||
* thereof, and that both notices appear in supporting documentation.
|
||||
*
|
||||
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
|
||||
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
|
||||
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
|
||||
*
|
||||
* Carnegie Mellon requests users of this software to return to
|
||||
*
|
||||
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
|
||||
* School of Computer Science
|
||||
* Carnegie Mellon University
|
||||
* Pittsburgh PA 15213-3890
|
||||
*
|
||||
* any improvements or extensions that they make and grant Carnegie the
|
||||
* rights to redistribute these changes.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
/*
|
||||
* Byte-swap a 4-byte quantity. (Convert 0x01234567 to 0x67452301.)
|
||||
*
|
||||
* Argument is an unsigned 4-byte integer (uint32_t).
|
||||
*/
|
||||
#if defined(_KERNEL) || defined(_STANDALONE)
|
||||
#define BSWAP32 bswap32
|
||||
#else /* defined(_KERNEL) || defined(_STANDALONE) */
|
||||
#define BSWAP32 __bswap32
|
||||
#endif /* defined(_KERNEL) || defined(_STANDALONE) */
|
||||
LEAF(BSWAP32, 1) /* a0 contains 0x01234567 */
|
||||
XLEAF(htonl, 1)
|
||||
XLEAF(ntohl, 1)
|
||||
insbl a0, 3, t0 /* t0 = 0x67 */
|
||||
extbl a0, 1, t1 /* t1 = 0x 45 */
|
||||
extbl a0, 2, t2 /* t2 = 0x 23 */
|
||||
extbl a0, 3, t3 /* t3 = 0x 01 */
|
||||
sll t1, 16, t1 /* t1 = 0x 45 */
|
||||
sll t2, 8, t2 /* t2 = 0x 23 */
|
||||
or t3, t0, v0 /* v0 = 0x67 01 */
|
||||
or t1, t2, t1 /* t1 = 0x 4523 */
|
||||
or t1, v0, v0 /* v0 = 0x67452301 */
|
||||
RET
|
||||
END(BSWAP32)
|
128
common/lib/libc/arch/alpha/gmon/_mcount.S
Normal file
128
common/lib/libc/arch/alpha/gmon/_mcount.S
Normal file
|
@ -0,0 +1,128 @@
|
|||
/* $NetBSD: _mcount.S,v 1.2 2005/12/21 18:11:11 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Author: Chris G. Demetriou
|
||||
*
|
||||
* Permission to use, copy, modify and distribute this software and
|
||||
* its documentation is hereby granted, provided that both the copyright
|
||||
* notice and this permission notice appear in all copies of the
|
||||
* software, derivative works or modified versions, and any portions
|
||||
* thereof, and that both notices appear in supporting documentation.
|
||||
*
|
||||
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
|
||||
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
|
||||
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
|
||||
*
|
||||
* Carnegie Mellon requests users of this software to return to
|
||||
*
|
||||
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
|
||||
* School of Computer Science
|
||||
* Carnegie Mellon University
|
||||
* Pittsburgh PA 15213-3890
|
||||
*
|
||||
* any improvements or extensions that they make and grant Carnegie the
|
||||
* rights to redistribute these changes.
|
||||
*/
|
||||
|
||||
#if defined(GPROF) && !defined(_STANDALONE)
|
||||
|
||||
#include <machine/asm.h>
|
||||
#include <machine/profile.h>
|
||||
|
||||
#define OFFSET_AT (0 * 8)
|
||||
#define OFFSET_V0 (1 * 8)
|
||||
#define OFFSET_T0 (2 * 8)
|
||||
#define OFFSET_T1 (3 * 8)
|
||||
#define OFFSET_T2 (4 * 8)
|
||||
#define OFFSET_T3 (5 * 8)
|
||||
#define OFFSET_T4 (6 * 8)
|
||||
#define OFFSET_T5 (7 * 8)
|
||||
#define OFFSET_T6 (8 * 8)
|
||||
#define OFFSET_T7 (9 * 8)
|
||||
#define OFFSET_S6 (10 * 8)
|
||||
#define OFFSET_A0 (11 * 8)
|
||||
#define OFFSET_A1 (12 * 8)
|
||||
#define OFFSET_A2 (13 * 8)
|
||||
#define OFFSET_A3 (14 * 8)
|
||||
#define OFFSET_A4 (15 * 8)
|
||||
#define OFFSET_A5 (16 * 8)
|
||||
#define OFFSET_T8 (17 * 8)
|
||||
#define OFFSET_T9 (18 * 8)
|
||||
#define OFFSET_T10 (19 * 8)
|
||||
#define OFFSET_T11 (20 * 8)
|
||||
#define OFFSET_RA (21 * 8)
|
||||
#define OFFSET_T12 (22 * 8)
|
||||
#define OFFSET_GP (23 * 8)
|
||||
#define FRAME_SIZE (24 * 8)
|
||||
|
||||
LEAF_NOPROFILE(_mcount,0) /* XXX */
|
||||
.set noat
|
||||
.set noreorder
|
||||
|
||||
lda sp, -FRAME_SIZE(sp)
|
||||
|
||||
stq at_reg, OFFSET_AT(sp)
|
||||
stq v0, OFFSET_V0(sp)
|
||||
stq t0, OFFSET_T0(sp)
|
||||
stq t1, OFFSET_T1(sp)
|
||||
stq t2, OFFSET_T2(sp)
|
||||
stq t3, OFFSET_T3(sp)
|
||||
stq t4, OFFSET_T4(sp)
|
||||
stq t5, OFFSET_T5(sp)
|
||||
stq t6, OFFSET_T6(sp)
|
||||
stq t7, OFFSET_T7(sp)
|
||||
stq s6, OFFSET_S6(sp) /* XXX because run _after_ prologue. */
|
||||
stq a0, OFFSET_A0(sp)
|
||||
stq a1, OFFSET_A1(sp)
|
||||
stq a2, OFFSET_A2(sp)
|
||||
stq a3, OFFSET_A3(sp)
|
||||
stq a4, OFFSET_A4(sp)
|
||||
stq a5, OFFSET_A5(sp)
|
||||
stq t8, OFFSET_T8(sp)
|
||||
stq t9, OFFSET_T9(sp)
|
||||
stq t10, OFFSET_T10(sp)
|
||||
stq t11, OFFSET_T11(sp)
|
||||
stq ra, OFFSET_RA(sp)
|
||||
stq t12, OFFSET_T12(sp)
|
||||
stq gp, OFFSET_GP(sp)
|
||||
|
||||
br pv, 1f
|
||||
1: LDGP(pv)
|
||||
mov ra, a0
|
||||
mov at_reg, a1
|
||||
CALL(_MCOUNT_FUNC)
|
||||
|
||||
ldq v0, OFFSET_V0(sp)
|
||||
ldq t0, OFFSET_T0(sp)
|
||||
ldq t1, OFFSET_T1(sp)
|
||||
ldq t2, OFFSET_T2(sp)
|
||||
ldq t3, OFFSET_T3(sp)
|
||||
ldq t4, OFFSET_T4(sp)
|
||||
ldq t5, OFFSET_T5(sp)
|
||||
ldq t6, OFFSET_T6(sp)
|
||||
ldq t7, OFFSET_T7(sp)
|
||||
ldq s6, OFFSET_S6(sp) /* XXX because run _after_ prologue. */
|
||||
ldq a0, OFFSET_A0(sp)
|
||||
ldq a1, OFFSET_A1(sp)
|
||||
ldq a2, OFFSET_A2(sp)
|
||||
ldq a3, OFFSET_A3(sp)
|
||||
ldq a4, OFFSET_A4(sp)
|
||||
ldq a5, OFFSET_A5(sp)
|
||||
ldq t8, OFFSET_T8(sp)
|
||||
ldq t9, OFFSET_T9(sp)
|
||||
ldq t10, OFFSET_T10(sp)
|
||||
ldq t11, OFFSET_T11(sp)
|
||||
ldq ra, OFFSET_RA(sp)
|
||||
ldq t12, OFFSET_T12(sp)
|
||||
ldq gp, OFFSET_GP(sp)
|
||||
|
||||
ldq at_reg, OFFSET_AT(sp)
|
||||
|
||||
lda sp, FRAME_SIZE(sp)
|
||||
ret zero, (at_reg), 1
|
||||
|
||||
END(_mcount)
|
||||
#endif
|
288
common/lib/libc/arch/alpha/string/bcopy.S
Normal file
288
common/lib/libc/arch/alpha/string/bcopy.S
Normal file
|
@ -0,0 +1,288 @@
|
|||
/* $NetBSD: bcopy.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1995 Carnegie-Mellon University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Author: Trevor Blackwell. Support for use as memcpy() and memmove()
|
||||
* added by Chris Demetriou.
|
||||
*
|
||||
* Permission to use, copy, modify and distribute this software and
|
||||
* its documentation is hereby granted, provided that both the copyright
|
||||
* notice and this permission notice appear in all copies of the
|
||||
* software, derivative works or modified versions, and any portions
|
||||
* thereof, and that both notices appear in supporting documentation.
|
||||
*
|
||||
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
|
||||
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
|
||||
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
|
||||
*
|
||||
* Carnegie Mellon requests users of this software to return to
|
||||
*
|
||||
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
|
||||
* School of Computer Science
|
||||
* Carnegie Mellon University
|
||||
* Pittsburgh PA 15213-3890
|
||||
*
|
||||
* any improvements or extensions that they make and grant Carnegie the
|
||||
* rights to redistribute these changes.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#if defined(MEMCOPY) || defined(MEMMOVE)
|
||||
#ifdef MEMCOPY
|
||||
#define FUNCTION memcpy
|
||||
#else
|
||||
#define FUNCTION memmove
|
||||
#endif
|
||||
#define SRCREG a1
|
||||
#define DSTREG a0
|
||||
#else /* !(defined(MEMCOPY) || defined(MEMMOVE)) */
|
||||
#define FUNCTION bcopy
|
||||
#define SRCREG a0
|
||||
#define DSTREG a1
|
||||
#endif /* !(defined(MEMCOPY) || defined(MEMMOVE)) */
|
||||
|
||||
#define SIZEREG a2
|
||||
|
||||
/*
|
||||
* Copy bytes.
|
||||
*
|
||||
* void bcopy(char *from, char *to, size_t len);
|
||||
* char *memcpy(void *to, const void *from, size_t len);
|
||||
* char *memmove(void *to, const void *from, size_t len);
|
||||
*
|
||||
* No matter how invoked, the source and destination registers
|
||||
* for calculation. There's no point in copying them to "working"
|
||||
* registers, since the code uses their values "in place," and
|
||||
* copying them would be slower.
|
||||
*/
|
||||
|
||||
LEAF(FUNCTION,3)
|
||||
|
||||
#if defined(MEMCOPY) || defined(MEMMOVE)
|
||||
/* set up return value, while we still can */
|
||||
mov DSTREG,v0
|
||||
#endif
|
||||
|
||||
/* Check for negative length */
|
||||
ble SIZEREG,bcopy_done
|
||||
|
||||
/* Check for overlap */
|
||||
subq DSTREG,SRCREG,t5
|
||||
cmpult t5,SIZEREG,t5
|
||||
bne t5,bcopy_overlap
|
||||
|
||||
/* a3 = end address */
|
||||
addq SRCREG,SIZEREG,a3
|
||||
|
||||
/* Get the first word */
|
||||
ldq_u t2,0(SRCREG)
|
||||
|
||||
/* Do they have the same alignment? */
|
||||
xor SRCREG,DSTREG,t0
|
||||
and t0,7,t0
|
||||
and DSTREG,7,t1
|
||||
bne t0,bcopy_different_alignment
|
||||
|
||||
/* src & dst have same alignment */
|
||||
beq t1,bcopy_all_aligned
|
||||
|
||||
ldq_u t3,0(DSTREG)
|
||||
addq SIZEREG,t1,SIZEREG
|
||||
mskqh t2,SRCREG,t2
|
||||
mskql t3,SRCREG,t3
|
||||
or t2,t3,t2
|
||||
|
||||
/* Dst is 8-byte aligned */
|
||||
|
||||
bcopy_all_aligned:
|
||||
/* If less than 8 bytes,skip loop */
|
||||
subq SIZEREG,1,t0
|
||||
and SIZEREG,7,SIZEREG
|
||||
bic t0,7,t0
|
||||
beq t0,bcopy_samealign_lp_end
|
||||
|
||||
bcopy_samealign_lp:
|
||||
stq_u t2,0(DSTREG)
|
||||
addq DSTREG,8,DSTREG
|
||||
ldq_u t2,8(SRCREG)
|
||||
subq t0,8,t0
|
||||
addq SRCREG,8,SRCREG
|
||||
bne t0,bcopy_samealign_lp
|
||||
|
||||
bcopy_samealign_lp_end:
|
||||
/* If we're done, exit */
|
||||
bne SIZEREG,bcopy_small_left
|
||||
stq_u t2,0(DSTREG)
|
||||
RET
|
||||
|
||||
bcopy_small_left:
|
||||
mskql t2,SIZEREG,t4
|
||||
ldq_u t3,0(DSTREG)
|
||||
mskqh t3,SIZEREG,t3
|
||||
or t4,t3,t4
|
||||
stq_u t4,0(DSTREG)
|
||||
RET
|
||||
|
||||
bcopy_different_alignment:
|
||||
/*
|
||||
* this is the fun part
|
||||
*/
|
||||
addq SRCREG,SIZEREG,a3
|
||||
cmpule SIZEREG,8,t0
|
||||
bne t0,bcopy_da_finish
|
||||
|
||||
beq t1,bcopy_da_noentry
|
||||
|
||||
/* Do the initial partial word */
|
||||
subq zero,DSTREG,t0
|
||||
and t0,7,t0
|
||||
ldq_u t3,7(SRCREG)
|
||||
extql t2,SRCREG,t2
|
||||
extqh t3,SRCREG,t3
|
||||
or t2,t3,t5
|
||||
insql t5,DSTREG,t5
|
||||
ldq_u t6,0(DSTREG)
|
||||
mskql t6,DSTREG,t6
|
||||
or t5,t6,t5
|
||||
stq_u t5,0(DSTREG)
|
||||
addq SRCREG,t0,SRCREG
|
||||
addq DSTREG,t0,DSTREG
|
||||
subq SIZEREG,t0,SIZEREG
|
||||
ldq_u t2,0(SRCREG)
|
||||
|
||||
bcopy_da_noentry:
|
||||
subq SIZEREG,1,t0
|
||||
bic t0,7,t0
|
||||
and SIZEREG,7,SIZEREG
|
||||
beq t0,bcopy_da_finish2
|
||||
|
||||
bcopy_da_lp:
|
||||
ldq_u t3,7(SRCREG)
|
||||
addq SRCREG,8,SRCREG
|
||||
extql t2,SRCREG,t4
|
||||
extqh t3,SRCREG,t5
|
||||
subq t0,8,t0
|
||||
or t4,t5,t5
|
||||
stq t5,0(DSTREG)
|
||||
addq DSTREG,8,DSTREG
|
||||
beq t0,bcopy_da_finish1
|
||||
ldq_u t2,7(SRCREG)
|
||||
addq SRCREG,8,SRCREG
|
||||
extql t3,SRCREG,t4
|
||||
extqh t2,SRCREG,t5
|
||||
subq t0,8,t0
|
||||
or t4,t5,t5
|
||||
stq t5,0(DSTREG)
|
||||
addq DSTREG,8,DSTREG
|
||||
bne t0,bcopy_da_lp
|
||||
|
||||
bcopy_da_finish2:
|
||||
/* Do the last new word */
|
||||
mov t2,t3
|
||||
|
||||
bcopy_da_finish1:
|
||||
/* Do the last partial word */
|
||||
ldq_u t2,-1(a3)
|
||||
extql t3,SRCREG,t3
|
||||
extqh t2,SRCREG,t2
|
||||
or t2,t3,t2
|
||||
br zero,bcopy_samealign_lp_end
|
||||
|
||||
bcopy_da_finish:
|
||||
/* Do the last word in the next source word */
|
||||
ldq_u t3,-1(a3)
|
||||
extql t2,SRCREG,t2
|
||||
extqh t3,SRCREG,t3
|
||||
or t2,t3,t2
|
||||
insqh t2,DSTREG,t3
|
||||
insql t2,DSTREG,t2
|
||||
lda t4,-1(zero)
|
||||
mskql t4,SIZEREG,t5
|
||||
cmovne t5,t5,t4
|
||||
insqh t4,DSTREG,t5
|
||||
insql t4,DSTREG,t4
|
||||
addq DSTREG,SIZEREG,a4
|
||||
ldq_u t6,0(DSTREG)
|
||||
ldq_u t7,-1(a4)
|
||||
bic t6,t4,t6
|
||||
bic t7,t5,t7
|
||||
and t2,t4,t2
|
||||
and t3,t5,t3
|
||||
or t2,t6,t2
|
||||
or t3,t7,t3
|
||||
stq_u t3,-1(a4)
|
||||
stq_u t2,0(DSTREG)
|
||||
RET
|
||||
|
||||
bcopy_overlap:
|
||||
/*
|
||||
* Basically equivalent to previous case, only backwards.
|
||||
* Not quite as highly optimized
|
||||
*/
|
||||
addq SRCREG,SIZEREG,a3
|
||||
addq DSTREG,SIZEREG,a4
|
||||
|
||||
/* less than 8 bytes - don't worry about overlap */
|
||||
cmpule SIZEREG,8,t0
|
||||
bne t0,bcopy_ov_short
|
||||
|
||||
/* Possibly do a partial first word */
|
||||
and a4,7,t4
|
||||
beq t4,bcopy_ov_nostart2
|
||||
subq a3,t4,a3
|
||||
subq a4,t4,a4
|
||||
ldq_u t1,0(a3)
|
||||
subq SIZEREG,t4,SIZEREG
|
||||
ldq_u t2,7(a3)
|
||||
ldq t3,0(a4)
|
||||
extql t1,a3,t1
|
||||
extqh t2,a3,t2
|
||||
or t1,t2,t1
|
||||
mskqh t3,t4,t3
|
||||
mskql t1,t4,t1
|
||||
or t1,t3,t1
|
||||
stq t1,0(a4)
|
||||
|
||||
bcopy_ov_nostart2:
|
||||
bic SIZEREG,7,t4
|
||||
and SIZEREG,7,SIZEREG
|
||||
beq t4,bcopy_ov_lp_end
|
||||
|
||||
bcopy_ov_lp:
|
||||
/* This could be more pipelined, but it doesn't seem worth it */
|
||||
ldq_u t0,-8(a3)
|
||||
subq a4,8,a4
|
||||
ldq_u t1,-1(a3)
|
||||
subq a3,8,a3
|
||||
extql t0,a3,t0
|
||||
extqh t1,a3,t1
|
||||
subq t4,8,t4
|
||||
or t0,t1,t0
|
||||
stq t0,0(a4)
|
||||
bne t4,bcopy_ov_lp
|
||||
|
||||
bcopy_ov_lp_end:
|
||||
beq SIZEREG,bcopy_done
|
||||
|
||||
ldq_u t0,0(SRCREG)
|
||||
ldq_u t1,7(SRCREG)
|
||||
ldq_u t2,0(DSTREG)
|
||||
extql t0,SRCREG,t0
|
||||
extqh t1,SRCREG,t1
|
||||
or t0,t1,t0
|
||||
insql t0,DSTREG,t0
|
||||
mskql t2,DSTREG,t2
|
||||
or t2,t0,t2
|
||||
stq_u t2,0(DSTREG)
|
||||
|
||||
bcopy_done:
|
||||
RET
|
||||
|
||||
bcopy_ov_short:
|
||||
ldq_u t2,0(SRCREG)
|
||||
br zero,bcopy_da_finish
|
||||
|
||||
END(FUNCTION)
|
110
common/lib/libc/arch/alpha/string/bzero.S
Normal file
110
common/lib/libc/arch/alpha/string/bzero.S
Normal file
|
@ -0,0 +1,110 @@
|
|||
/* $NetBSD: bzero.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1995 Carnegie-Mellon University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Author: Trevor Blackwell
|
||||
*
|
||||
* Permission to use, copy, modify and distribute this software and
|
||||
* its documentation is hereby granted, provided that both the copyright
|
||||
* notice and this permission notice appear in all copies of the
|
||||
* software, derivative works or modified versions, and any portions
|
||||
* thereof, and that both notices appear in supporting documentation.
|
||||
*
|
||||
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
|
||||
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
|
||||
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
|
||||
*
|
||||
* Carnegie Mellon requests users of this software to return to
|
||||
*
|
||||
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
|
||||
* School of Computer Science
|
||||
* Carnegie Mellon University
|
||||
* Pittsburgh PA 15213-3890
|
||||
*
|
||||
* any improvements or extensions that they make and grant Carnegie the
|
||||
* rights to redistribute these changes.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
LEAF(bzero,2)
|
||||
ble a1,bzero_done
|
||||
bic a1,63,t3 /* t3 is # bytes to do 64 bytes at a time */
|
||||
|
||||
/* If nothing in first word, ignore it */
|
||||
subq zero,a0,t0
|
||||
and t0,7,t0 /* t0 = (0-size)%8 */
|
||||
beq t0,bzero_nostart1
|
||||
|
||||
cmpult a1,t0,t1 /* if size > size%8 goto noshort */
|
||||
beq t1,bzero_noshort
|
||||
|
||||
/*
|
||||
* The whole thing is less than a word.
|
||||
* Mask off 1..7 bytes, and finish.
|
||||
*/
|
||||
ldq_u t2,0(a0)
|
||||
lda t0,-1(zero) /* t0=-1 */
|
||||
mskql t0,a1,t0 /* Get ff in bytes (a0%8)..((a0+a1-1)%8) */
|
||||
insql t0,a0,t0
|
||||
bic t2,t0,t2 /* zero those bytes in word */
|
||||
stq_u t2,0(a0)
|
||||
RET
|
||||
|
||||
bzero_noshort:
|
||||
/* Handle the first partial word */
|
||||
ldq_u t2,0(a0)
|
||||
subq a1,t0,a1
|
||||
mskql t2,a0,t2 /* zero bytes (a0%8)..7 in word */
|
||||
stq_u t2,0(a0)
|
||||
|
||||
addq a0,t0,a0 /* round a0 up to next word */
|
||||
bic a1,63,t3 /* recalc t3 (# bytes to do 64 bytes at a
|
||||
time) */
|
||||
|
||||
bzero_nostart1:
|
||||
/*
|
||||
* Loop, zeroing 64 bytes at a time
|
||||
*/
|
||||
beq t3,bzero_lp_done
|
||||
bzero_lp:
|
||||
stq zero,0(a0)
|
||||
stq zero,8(a0)
|
||||
stq zero,16(a0)
|
||||
stq zero,24(a0)
|
||||
subq t3,64,t3
|
||||
stq zero,32(a0)
|
||||
stq zero,40(a0)
|
||||
stq zero,48(a0)
|
||||
stq zero,56(a0)
|
||||
addq a0,64,a0
|
||||
bne t3,bzero_lp
|
||||
|
||||
bzero_lp_done:
|
||||
/*
|
||||
* Handle the last 0..7 words.
|
||||
* We mask off the low bits, so we don't need an extra
|
||||
* compare instruction for the loop (just a bne. heh-heh)
|
||||
*/
|
||||
and a1,0x38,t4
|
||||
beq t4,bzero_finish_lp_done
|
||||
bzero_finish_lp:
|
||||
stq zero,0(a0)
|
||||
subq t4,8,t4
|
||||
addq a0,8,a0
|
||||
bne t4,bzero_finish_lp
|
||||
|
||||
/* Do the last partial word */
|
||||
bzero_finish_lp_done:
|
||||
and a1,7,t5 /* 0..7 bytes left */
|
||||
beq t5,bzero_done /* mskqh won't change t0 if t5==0, but I
|
||||
don't want to touch, say, a new VM page */
|
||||
ldq t0,0(a0)
|
||||
mskqh t0,t5,t0
|
||||
stq t0,0(a0)
|
||||
bzero_done:
|
||||
RET
|
||||
|
||||
END(bzero)
|
94
common/lib/libc/arch/alpha/string/ffs.S
Normal file
94
common/lib/libc/arch/alpha/string/ffs.S
Normal file
|
@ -0,0 +1,94 @@
|
|||
/* $NetBSD: ffs.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1995 Christopher G. Demetriou
|
||||
* 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed for the
|
||||
* NetBSD Project. See http://www.NetBSD.org/ for
|
||||
* information about NetBSD.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
*
|
||||
* <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
LEAF(ffs, 1)
|
||||
addl a0, 0, t0
|
||||
beq t0, Lallzero
|
||||
|
||||
/*
|
||||
* Initialize return value (v0), and set up t1 so that it
|
||||
* contains the mask with only the lowest bit set.
|
||||
*/
|
||||
subl zero, t0, t1
|
||||
ldil v0, 1
|
||||
and t0, t1, t1
|
||||
|
||||
and t1, 0xff, t2
|
||||
bne t2, Ldo8
|
||||
|
||||
/*
|
||||
* If lower 16 bits empty, add 16 to result and use upper 16.
|
||||
*/
|
||||
zapnot t1, 0x03, t3
|
||||
bne t3, Ldo16
|
||||
sra t1, 16, t1
|
||||
addl v0, 16, v0
|
||||
|
||||
Ldo16:
|
||||
/*
|
||||
* If lower 8 bits empty, add 8 to result and use upper 8.
|
||||
*/
|
||||
and t1, 0xff, t4
|
||||
bne t4, Ldo8
|
||||
sra t1, 8, t1
|
||||
addl v0, 8, v0
|
||||
|
||||
Ldo8:
|
||||
and t1, 0x0f, t5 /* lower 4 of 8 empty? */
|
||||
and t1, 0x33, t6 /* lower 2 of each 4 empty? */
|
||||
and t1, 0x55, t7 /* lower 1 of each 2 empty? */
|
||||
|
||||
/* If lower 4 bits empty, add 4 to result. */
|
||||
bne t5, Ldo4
|
||||
addl v0, 4, v0
|
||||
|
||||
Ldo4: /* If lower 2 bits of each 4 empty, add 2 to result. */
|
||||
bne t6, Ldo2
|
||||
addl v0, 2, v0
|
||||
|
||||
Ldo2: /* If lower bit of each 2 empty, add 1 to result. */
|
||||
bne t7, Ldone
|
||||
addl v0, 1, v0
|
||||
|
||||
Ldone:
|
||||
RET
|
||||
|
||||
Lallzero:
|
||||
bis zero, zero, v0
|
||||
RET
|
||||
END(ffs)
|
4
common/lib/libc/arch/alpha/string/memcpy.S
Normal file
4
common/lib/libc/arch/alpha/string/memcpy.S
Normal file
|
@ -0,0 +1,4 @@
|
|||
/* $NetBSD: memcpy.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
|
||||
|
||||
#define MEMCOPY
|
||||
#include "bcopy.S"
|
4
common/lib/libc/arch/alpha/string/memmove.S
Normal file
4
common/lib/libc/arch/alpha/string/memmove.S
Normal file
|
@ -0,0 +1,4 @@
|
|||
/* $NetBSD: memmove.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
|
||||
|
||||
#define MEMMOVE
|
||||
#include "bcopy.S"
|
19
common/lib/libc/arch/arm/atomic/Makefile.inc
Normal file
19
common/lib/libc/arch/arm/atomic/Makefile.inc
Normal file
|
@ -0,0 +1,19 @@
|
|||
# $NetBSD: Makefile.inc,v 1.8 2009/01/04 17:54:29 pooka Exp $
|
||||
|
||||
.if defined(LIB) && (${LIB} == "kern" || ${LIB} == "c" || ${LIB} == "pthread" \
|
||||
|| ${LIB} == "rump")
|
||||
|
||||
SRCS+= atomic_add_32_cas.c atomic_add_32_nv_cas.c atomic_and_32_cas.c \
|
||||
atomic_and_32_nv_cas.c atomic_dec_32_cas.c atomic_dec_32_nv_cas.c \
|
||||
atomic_inc_32_cas.c atomic_inc_32_nv_cas.c atomic_or_32_cas.c \
|
||||
atomic_or_32_nv_cas.c atomic_swap_32_cas.c membar_ops_nop.c
|
||||
|
||||
.endif
|
||||
|
||||
.if defined(LIB) && (${LIB} == "c" || ${LIB} == "pthread")
|
||||
|
||||
SRCS+= atomic_init_testset.c
|
||||
SRCS+= atomic_cas_up.S
|
||||
CPPFLAGS+= -D__HAVE_ASM_ATOMIC_CAS_UP
|
||||
|
||||
.endif
|
70
common/lib/libc/arch/arm/atomic/atomic_add_32.S
Normal file
70
common/lib/libc/arch/arm/atomic/atomic_add_32.S
Normal file
|
@ -0,0 +1,70 @@
|
|||
/* $NetBSD: atomic_add_32.S,v 1.2 2008/08/16 07:12:39 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008 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 "atomic_op_asm.h"
|
||||
|
||||
#ifdef _ARM_ARCH_6
|
||||
|
||||
ENTRY_NP(_atomic_add_32)
|
||||
mov r3, r0 /* need r0 for return value */
|
||||
1: ldrex r0, [r3] /* load old value (to be returned) */
|
||||
add r2, r0, r1 /* calculate new value */
|
||||
strex ip, r2, [r3] /* try to store */
|
||||
cmp ip, #0 /* succeed? */
|
||||
bne 1b /* no, try again */
|
||||
RET /* return old value */
|
||||
END(_atomic_add_32)
|
||||
ATOMIC_OP_ALIAS(atomic_add_32,_atomic_add_32)
|
||||
ATOMIC_OP_ALIAS(atomic_add_int,_atomic_add_32)
|
||||
ATOMIC_OP_ALIAS(atomic_add_long,_atomic_add_32)
|
||||
ATOMIC_OP_ALIAS(atomic_add_ptr,_atomic_add_32)
|
||||
STRONG_ALIAS(_atomic_add_int,_atomic_add_32)
|
||||
STRONG_ALIAS(_atomic_add_long,_atomic_add_32)
|
||||
STRONG_ALIAS(_atomic_add_ptr,_atomic_add_32)
|
||||
|
||||
ENTRY_NP(_atomic_add_32_nv)
|
||||
mov r3, r0 /* need r0 for return value */
|
||||
1: ldrex r0, [r3] /* load old value */
|
||||
add r0, r0, r1 /* calculate new value (return value) */
|
||||
strex r2, r0, [r3] /* try to store */
|
||||
cmp r2, #0 /* succeed? */
|
||||
bne 1b /* no, try again? */
|
||||
RET /* return new value */
|
||||
END(_atomic_add_32_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_add_32_nv,_atomic_add_32_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_add_int_nv,_atomic_add_32_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_add_long_nv,_atomic_add_32_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_add_ptr_nv,_atomic_add_32_nv)
|
||||
STRONG_ALIAS(_atomic_add_int_nv,_atomic_add_32_nv)
|
||||
STRONG_ALIAS(_atomic_add_long_nv,_atomic_add_32_nv)
|
||||
STRONG_ALIAS(_atomic_add_ptr_nv,_atomic_add_32_nv)
|
||||
|
||||
#endif /* _ARM_ARCH_6 */
|
66
common/lib/libc/arch/arm/atomic/atomic_and_32.S
Normal file
66
common/lib/libc/arch/arm/atomic/atomic_and_32.S
Normal file
|
@ -0,0 +1,66 @@
|
|||
/* $NetBSD: atomic_and_32.S,v 1.2 2008/08/16 07:12:39 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008 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 "atomic_op_asm.h"
|
||||
|
||||
#ifdef _ARM_ARCH_6
|
||||
|
||||
ENTRY_NP(_atomic_and_32)
|
||||
mov r3, r0 /* need r0 for return value */
|
||||
1: ldrex r0, [r3] /* load old value (to be returned) */
|
||||
and r2, r0, r1 /* calculate new value */
|
||||
strex ip, r2, [r3] /* try to store */
|
||||
cmp ip, #0 /* succeed? */
|
||||
bne 1b /* no, try again */
|
||||
RET /* return old value */
|
||||
END(_atomic_and_32)
|
||||
ATOMIC_OP_ALIAS(atomic_and_32,_atomic_and_32)
|
||||
ATOMIC_OP_ALIAS(atomic_and_uint,_atomic_and_32)
|
||||
ATOMIC_OP_ALIAS(atomic_and_ulong,_atomic_and_32)
|
||||
STRONG_ALIAS(_atomic_and_uint,_atomic_and_32)
|
||||
STRONG_ALIAS(_atomic_and_ulong,_atomic_and_32)
|
||||
|
||||
ENTRY_NP(_atomic_and_32_nv)
|
||||
mov r3, r0 /* need r0 for return value */
|
||||
1: ldrex r0, [r3] /* load old value */
|
||||
and r0, r0, r1 /* calculate new value (return value) */
|
||||
strex r2, r0, [r3] /* try to store */
|
||||
cmp r2, #0 /* succeed? */
|
||||
bne 1b /* no, try again? */
|
||||
RET /* return new value */
|
||||
END(_atomic_and_32_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_and_32_nv,_atomic_and_32_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_and_uint_nv,_atomic_and_32_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_and_ulong_nv,_atomic_and_32_nv)
|
||||
STRONG_ALIAS(_atomic_and_uint_nv,_atomic_and_32_nv)
|
||||
STRONG_ALIAS(_atomic_and_ulong_nv,_atomic_and_32_nv)
|
||||
|
||||
#endif /* _ARM_ARCH_6 */
|
58
common/lib/libc/arch/arm/atomic/atomic_cas_32.S
Normal file
58
common/lib/libc/arch/arm/atomic/atomic_cas_32.S
Normal file
|
@ -0,0 +1,58 @@
|
|||
/* $NetBSD: atomic_cas_32.S,v 1.2 2008/08/16 07:12:39 matt Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2008 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 "atomic_op_asm.h"
|
||||
|
||||
#if defined(_ARM_ARCH_6)
|
||||
/*
|
||||
* ARMv6 has load-exclusive/store-exclusive which works for both user
|
||||
* and kernel.
|
||||
*/
|
||||
ENTRY_NP(_atomic_cas_32)
|
||||
mov r3, r0 /* we need r0 for return value */
|
||||
1:
|
||||
ldrex r0, [r3] /* load old value */
|
||||
teq r0, r1 /* compare? */
|
||||
RETc(ne) /* return if different */
|
||||
strex ip, r2, [r3] /* store new value */
|
||||
cmp ip, #0 /* succeed? */
|
||||
bne 1b /* nope, try again. */
|
||||
RET /* yes, return. */
|
||||
END(_atomic_cas_32)
|
||||
|
||||
ATOMIC_OP_ALIAS(atomic_cas_32,_atomic_cas_32)
|
||||
ATOMIC_OP_ALIAS(atomic_cas_uint,_atomic_cas_32)
|
||||
ATOMIC_OP_ALIAS(atomic_cas_ulong,_atomic_cas_32)
|
||||
ATOMIC_OP_ALIAS(atomic_cas_ptr,_atomic_cas_32)
|
||||
STRONG_ALIAS(_atomic_cas_uint,_atomic_cas_32)
|
||||
STRONG_ALIAS(_atomic_cas_ulong,_atomic_cas_32)
|
||||
STRONG_ALIAS(_atomic_cas_ptr,_atomic_cas_32)
|
||||
|
||||
#endif /* _ARCH_ARM_6 */
|
63
common/lib/libc/arch/arm/atomic/atomic_cas_8.S
Normal file
63
common/lib/libc/arch/arm/atomic/atomic_cas_8.S
Normal file
|
@ -0,0 +1,63 @@
|
|||
/* $NetBSD: atomic_cas_8.S,v 1.1 2008/11/18 15:22:56 matt Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2008 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 <machine/asm.h>
|
||||
|
||||
RCSID("$NetBSD: atomic_cas_8.S,v 1.1 2008/11/18 15:22:56 matt Exp $")
|
||||
|
||||
ENTRY(atomic_cas_8)
|
||||
XPUSH {r4,r5} /* we need some more registers */
|
||||
and r3, r0, #3 /* which byte do we replace? */
|
||||
#if __ARMEB__
|
||||
eor r3, r3, #3 /* bytes are reversed on BE */
|
||||
#endif
|
||||
mov r3, r3, lsl #3 /* multiply by 8 */
|
||||
mov r1, r1, lsl r3 /* mov old value to correct byte */
|
||||
eor r2, r1, r2, lsl r3 /* move new value to correct byte */
|
||||
/* eor r2, r2, r1 */ /* new value is now (old ^ new) */
|
||||
mov r5, #0xff /* load mask */
|
||||
mov r5, r5, lsl r3 /* and move to correct byte */
|
||||
mov r3, r0 /* move pointer */
|
||||
|
||||
1: ldrex r4, [r3] /* load 32bit value */
|
||||
and r0, r4, r5 /* clear other bytes */
|
||||
teq r0, r1 /* equal old value? */
|
||||
bne 2f /* nope, bail. */
|
||||
eor r4, r4, r2 /* new == old ^ (old ^ new) */
|
||||
strex ip, r4, [r3] /* attempt to store it */
|
||||
cmp ip, #0 /* succeed? */
|
||||
bne 1b /* nope, try again. */
|
||||
|
||||
2: XPOP {r4,r5} /* don't need these anymore */
|
||||
and r1, r3, #3
|
||||
#if __ARMEB__
|
||||
eor r1, r1, #3
|
||||
#endif
|
||||
mov r0, r0, lsr r1 /* shift it back to lsb byte */
|
||||
RET
|
43
common/lib/libc/arch/arm/atomic/atomic_cas_up.S
Normal file
43
common/lib/libc/arch/arm/atomic/atomic_cas_up.S
Normal file
|
@ -0,0 +1,43 @@
|
|||
/* $NetBSD: atomic_cas_up.S,v 1.2 2008/05/25 15:56:11 chs Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Steve C. Woodford.
|
||||
*
|
||||
* 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/ras.h>
|
||||
#include <machine/asm.h>
|
||||
|
||||
ENTRY(_atomic_cas_up)
|
||||
.hidden _C_LABEL(_atomic_cas_up)
|
||||
mov r3, r0
|
||||
RAS_START_ASM_HIDDEN(_atomic_cas)
|
||||
ldr r0, [r3]
|
||||
cmp r0, r1
|
||||
streq r2, [r3]
|
||||
RAS_END_ASM_HIDDEN(_atomic_cas)
|
||||
RET
|
69
common/lib/libc/arch/arm/atomic/atomic_dec_32.S
Normal file
69
common/lib/libc/arch/arm/atomic/atomic_dec_32.S
Normal file
|
@ -0,0 +1,69 @@
|
|||
/* $NetBSD: atomic_dec_32.S,v 1.2 2008/08/16 07:12:39 matt Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2008 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 "atomic_op_asm.h"
|
||||
|
||||
#ifdef _ARM_ARCH_6
|
||||
|
||||
ENTRY_NP(_atomic_dec_32)
|
||||
mov r2, r0 /* need r0 for return value */
|
||||
1: ldrex r0, [r2] /* load old value (return value) */
|
||||
sub r1, r0, #1 /* calculate new value */
|
||||
strex r3, r1, [r2] /* try to store */
|
||||
cmp r3, #0 /* succeed? */
|
||||
bne 1b /* no, try again? */
|
||||
RET /* return new value */
|
||||
END(_atomic_dec_32)
|
||||
ATOMIC_OP_ALIAS(atomic_dec_32,_atomic_dec_32)
|
||||
ATOMIC_OP_ALIAS(atomic_dec_uint,_atomic_dec_32)
|
||||
ATOMIC_OP_ALIAS(atomic_dec_ulong,_atomic_dec_32)
|
||||
ATOMIC_OP_ALIAS(atomic_dec_ptr,_atomic_dec_32)
|
||||
STRONG_ALIAS(_atomic_dec_uint,_atomic_dec_32)
|
||||
STRONG_ALIAS(_atomic_dec_ulong,_atomic_dec_32)
|
||||
STRONG_ALIAS(_atomic_dec_ptr,_atomic_dec_32)
|
||||
|
||||
ENTRY_NP(_atomic_dec_32_nv)
|
||||
mov r2, r0 /* need r0 for return value */
|
||||
1: ldrex r0, [r2] /* load old value */
|
||||
sub r0, r0, #1 /* calculate new value (return value) */
|
||||
strex r1, r0, [r2] /* try to store */
|
||||
cmp r1, #0 /* succeed? */
|
||||
bne 1b /* no, try again? */
|
||||
RET /* return new value */
|
||||
END(_atomic_dec_32_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_dec_32_nv,_atomic_dec_32_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_dec_uint_nv,_atomic_dec_32_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_dec_ulong_nv,_atomic_dec_32_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_dec_ptr_nv,_atomic_dec_32_nv)
|
||||
STRONG_ALIAS(_atomic_dec_uint_nv,_atomic_dec_32_nv)
|
||||
STRONG_ALIAS(_atomic_dec_ulong_nv,_atomic_dec_32_nv)
|
||||
STRONG_ALIAS(_atomic_dec_ptr_nv,_atomic_dec_32_nv)
|
||||
|
||||
#endif /* _ARM_ARCH_6 */
|
69
common/lib/libc/arch/arm/atomic/atomic_inc_32.S
Normal file
69
common/lib/libc/arch/arm/atomic/atomic_inc_32.S
Normal file
|
@ -0,0 +1,69 @@
|
|||
/* $NetBSD: atomic_inc_32.S,v 1.2 2008/08/16 07:12:39 matt Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2008 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 "atomic_op_asm.h"
|
||||
|
||||
#ifdef _ARM_ARCH_6
|
||||
|
||||
ENTRY_NP(_atomic_inc_32)
|
||||
mov r2, r0 /* need r0 for return value */
|
||||
1: ldrex r0, [r2] /* load old value (return value) */
|
||||
add r1, r0, #1 /* calculate new value */
|
||||
strex r3, r1, [r2] /* try to store */
|
||||
cmp r3, #0 /* succeed? */
|
||||
bne 1b /* no, try again? */
|
||||
RET /* return new value */
|
||||
END(_atomic_inc_32)
|
||||
ATOMIC_OP_ALIAS(atomic_inc_32,_atomic_inc_32)
|
||||
ATOMIC_OP_ALIAS(atomic_inc_uint,_atomic_inc_32)
|
||||
ATOMIC_OP_ALIAS(atomic_inc_ulong,_atomic_inc_32)
|
||||
ATOMIC_OP_ALIAS(atomic_inc_ptr,_atomic_inc_32)
|
||||
STRONG_ALIAS(_atomic_inc_uint,_atomic_inc_32)
|
||||
STRONG_ALIAS(_atomic_inc_ulong,_atomic_inc_32)
|
||||
STRONG_ALIAS(_atomic_inc_ptr,_atomic_inc_32)
|
||||
|
||||
ENTRY_NP(_atomic_inc_32_nv)
|
||||
mov r2, r0 /* need r0 for return value */
|
||||
1: ldrex r0, [r2] /* load old value */
|
||||
add r0, r0, #1 /* calculate new value (return value) */
|
||||
strex r1, r0, [r2] /* try to store */
|
||||
cmp r1, #0 /* succeed? */
|
||||
bne 1b /* no, try again? */
|
||||
RET /* return new value */
|
||||
END(_atomic_inc_32_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_inc_32_nv,_atomic_inc_32_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_inc_uint_nv,_atomic_inc_32_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_inc_ulong_nv,_atomic_inc_32_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_inc_ptr_nv,_atomic_inc_32_nv)
|
||||
STRONG_ALIAS(_atomic_inc_uint_nv,_atomic_inc_32_nv)
|
||||
STRONG_ALIAS(_atomic_inc_ulong_nv,_atomic_inc_32_nv)
|
||||
STRONG_ALIAS(_atomic_inc_ptr_nv,_atomic_inc_32_nv)
|
||||
|
||||
#endif /* _ARCH_ARM_6 */
|
54
common/lib/libc/arch/arm/atomic/atomic_op_asm.h
Normal file
54
common/lib/libc/arch/arm/atomic/atomic_op_asm.h
Normal file
|
@ -0,0 +1,54 @@
|
|||
/* $NetBSD: atomic_op_asm.h,v 1.2 2008/08/16 07:12:39 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Jason R. Thorpe.
|
||||
*
|
||||
* 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. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation 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 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.
|
||||
*/
|
||||
|
||||
#ifndef _ATOMIC_OP_ASM_H_
|
||||
#define _ATOMIC_OP_ASM_H_
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#if defined(_KERNEL)
|
||||
|
||||
#define ATOMIC_OP_ALIAS(a,s) STRONG_ALIAS(a,s)
|
||||
|
||||
#else /* _KERNEL */
|
||||
|
||||
#define ATOMIC_OP_ALIAS(a,s) WEAK_ALIAS(a,s)
|
||||
|
||||
#endif /* _KERNEL */
|
||||
|
||||
#endif /* _ATOMIC_OP_ASM_H_ */
|
65
common/lib/libc/arch/arm/atomic/atomic_or_32.S
Normal file
65
common/lib/libc/arch/arm/atomic/atomic_or_32.S
Normal file
|
@ -0,0 +1,65 @@
|
|||
/* $NetBSD: atomic_or_32.S,v 1.2 2008/08/16 07:12:39 matt Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2008 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 "atomic_op_asm.h"
|
||||
|
||||
#ifdef _ARM_ARCH_6
|
||||
|
||||
ENTRY_NP(_atomic_or_32)
|
||||
mov r3, r0 /* need r0 for return value */
|
||||
1: ldrex r0, [r3] /* load old value (to be returned) */
|
||||
orr r2, r0, r1 /* calculate new value */
|
||||
strex ip, r2, [r3] /* try to store */
|
||||
cmp ip, #0 /* succeed? */
|
||||
bne 1b /* no, try again */
|
||||
RET /* return old value */
|
||||
END(_atomic_or_32)
|
||||
ATOMIC_OP_ALIAS(atomic_or_32,_atomic_or_32)
|
||||
ATOMIC_OP_ALIAS(atomic_or_uint,_atomic_or_32)
|
||||
ATOMIC_OP_ALIAS(atomic_or_ulong,_atomic_or_32)
|
||||
STRONG_ALIAS(_atomic_or_uint,_atomic_or_32)
|
||||
STRONG_ALIAS(_atomic_or_ulong,_atomic_or_32)
|
||||
|
||||
ENTRY_NP(_atomic_or_32_nv)
|
||||
mov r3, r0 /* need r0 for return value */
|
||||
1: ldrex r0, [r3] /* load old value */
|
||||
orr r0, r0, r1 /* calculate new value (return value) */
|
||||
strex r2, r0, [r3] /* try to store */
|
||||
cmp r2, #0 /* succeed? */
|
||||
bne 1b /* no, try again? */
|
||||
RET /* return new value */
|
||||
END(_atomic_or_32_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_or_32_nv,_atomic_or_32_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_or_uint_nv,_atomic_or_32_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_or_ulong_nv,_atomic_or_32_nv)
|
||||
STRONG_ALIAS(_atomic_or_uint_nv,_atomic_or_32_nv)
|
||||
STRONG_ALIAS(_atomic_or_ulong_nv,_atomic_or_32_nv)
|
||||
|
||||
#endif /* _ARM_ARCH_6 */
|
61
common/lib/libc/arch/arm/atomic/atomic_swap.S
Normal file
61
common/lib/libc/arch/arm/atomic/atomic_swap.S
Normal file
|
@ -0,0 +1,61 @@
|
|||
/* $NetBSD: atomic_swap.S,v 1.2 2008/08/16 07:12:40 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Jason R. Thorpe and Matt Thomas.
|
||||
*
|
||||
* 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. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation 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 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 "atomic_op_asm.h"
|
||||
|
||||
ENTRY_NP(_atomic_swap_32)
|
||||
swp r0, r1, [r0]
|
||||
RET
|
||||
END(_atomic_swap_32)
|
||||
ATOMIC_OP_ALIAS(atomic_swap_32,_atomic_swap_32)
|
||||
ATOMIC_OP_ALIAS(atomic_swap_uint,_atomic_swap_32)
|
||||
ATOMIC_OP_ALIAS(atomic_swap_ulong,_atomic_swap_32)
|
||||
ATOMIC_OP_ALIAS(atomic_swap_ptr,_atomic_swap_32)
|
||||
STRONG_ALIAS(_atomic_swap_uint,_atomic_swap_32)
|
||||
STRONG_ALIAS(_atomic_swap_ulong,_atomic_swap_32)
|
||||
STRONG_ALIAS(_atomic_swap_ptr,_atomic_swap_32)
|
||||
|
||||
ENTRY_NP(_atomic_swap_8)
|
||||
swpb r0, r1, [r0]
|
||||
RET
|
||||
END(_atomic_swap_8)
|
||||
ATOMIC_OP_ALIAS(atomic_swap_8,_atomic_swap_8)
|
||||
ATOMIC_OP_ALIAS(atomic_swap_char,_atomic_swap_8)
|
||||
ATOMIC_OP_ALIAS(atomic_swap_uchar,_atomic_swap_8)
|
||||
STRONG_ALIAS(_atomic_swap_char,_atomic_swap_32)
|
||||
STRONG_ALIAS(_atomic_swap_uchar,_atomic_swap_32)
|
57
common/lib/libc/arch/arm/atomic/membar_ops.S
Normal file
57
common/lib/libc/arch/arm/atomic/membar_ops.S
Normal file
|
@ -0,0 +1,57 @@
|
|||
/* $NetBSD: membar_ops.S,v 1.2 2008/08/16 07:12:40 matt Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2008 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 "atomic_op_asm.h"
|
||||
|
||||
#ifdef _ARM_ARCH_6
|
||||
|
||||
ENTRY_NP(_membar_producer)
|
||||
mcr p15, 0, r0, c7, c10, 4 /* Data Synchronization Barrier */
|
||||
RET
|
||||
END(_membar_producer)
|
||||
ATOMIC_OP_ALIAS(membar_producer,_membar_producer)
|
||||
ATOMIC_OP_ALIAS(membar_write,_membar_producer)
|
||||
STRONG_ALIAS(_membar_write,_membar_producer)
|
||||
|
||||
ENTRY_NP(_membar_sync)
|
||||
mcr p15, 0, r0, c7, c10, 5 /* Data Memory Barrier */
|
||||
RET
|
||||
END(_membar_sync)
|
||||
ATOMIC_OP_ALIAS(membar_sync,_membar_sync)
|
||||
ATOMIC_OP_ALIAS(membar_enter,_membar_sync)
|
||||
ATOMIC_OP_ALIAS(membar_exit,_membar_sync)
|
||||
ATOMIC_OP_ALIAS(membar_consumer,_membar_sync)
|
||||
ATOMIC_OP_ALIAS(membar_read,_membar_sync)
|
||||
STRONG_ALIAS(_membar_enter,_membar_sync)
|
||||
STRONG_ALIAS(_membar_exit,_membar_sync)
|
||||
STRONG_ALIAS(_membar_consumer,_membar_sync)
|
||||
STRONG_ALIAS(_membar_read,_membar_sync)
|
||||
|
||||
#endif /* _ARM_ARCH_6 */
|
47
common/lib/libc/arch/arm/gen/byte_swap_2.S
Normal file
47
common/lib/libc/arch/arm/gen/byte_swap_2.S
Normal file
|
@ -0,0 +1,47 @@
|
|||
/* $NetBSD: byte_swap_2.S,v 1.4 2008/04/28 20:22:52 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Charles M. Hannum.
|
||||
*
|
||||
* 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 <machine/asm.h>
|
||||
|
||||
#if defined(_KERNEL) || defined(_STANDALONE)
|
||||
_ENTRY(_C_LABEL(bswap16))
|
||||
#else
|
||||
_ENTRY(_C_LABEL(__bswap16))
|
||||
#endif
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
_ENTRY(_C_LABEL(ntohs))
|
||||
_ENTRY(_C_LABEL(htons))
|
||||
#endif
|
||||
_PROF_PROLOGUE
|
||||
and r1, r0, #0xff
|
||||
mov r0, r0, lsr #8
|
||||
orr r0, r0, r1, lsl #8
|
||||
RET
|
48
common/lib/libc/arch/arm/gen/byte_swap_4.S
Normal file
48
common/lib/libc/arch/arm/gen/byte_swap_4.S
Normal file
|
@ -0,0 +1,48 @@
|
|||
/* $NetBSD: byte_swap_4.S,v 1.4 2008/04/28 20:22:52 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Neil A. Carson
|
||||
*
|
||||
* 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 <machine/asm.h>
|
||||
|
||||
#if defined(_KERNEL) || defined(_STANDALONE)
|
||||
_ENTRY(_C_LABEL(bswap32))
|
||||
#else
|
||||
_ENTRY(_C_LABEL(__bswap32))
|
||||
#endif
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
_ENTRY(_C_LABEL(ntohl))
|
||||
_ENTRY(_C_LABEL(htonl))
|
||||
#endif
|
||||
_PROF_PROLOGUE
|
||||
eor r1, r0, r0, ror #16
|
||||
bic r1, r1, #0x00FF0000
|
||||
mov r0, r0, ror #8
|
||||
eor r0, r0, r1, lsr #8
|
||||
RET
|
386
common/lib/libc/arch/arm/gen/divsi3.S
Normal file
386
common/lib/libc/arch/arm/gen/divsi3.S
Normal file
|
@ -0,0 +1,386 @@
|
|||
/* $NetBSD: divsi3.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
|
||||
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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 <machine/asm.h>
|
||||
|
||||
/*
|
||||
* stack is aligned as there's a possibility of branching to .L_overflow
|
||||
* which makes a C call
|
||||
*/
|
||||
|
||||
ENTRY(__umodsi3)
|
||||
stmfd sp!, {lr}
|
||||
sub sp, sp, #4 /* align stack */
|
||||
bl .L_udivide
|
||||
add sp, sp, #4 /* unalign stack */
|
||||
mov r0, r1
|
||||
ldmfd sp!, {pc}
|
||||
|
||||
ENTRY(__modsi3)
|
||||
stmfd sp!, {lr}
|
||||
sub sp, sp, #4 /* align stack */
|
||||
bl .L_divide
|
||||
add sp, sp, #4 /* unalign stack */
|
||||
mov r0, r1
|
||||
ldmfd sp!, {pc}
|
||||
|
||||
.L_overflow:
|
||||
#if !defined(_KERNEL) && !defined(_STANDALONE)
|
||||
mov r0, #8 /* SIGFPE */
|
||||
bl PIC_SYM(_C_LABEL(raise), PLT) /* raise it */
|
||||
mov r0, #0
|
||||
#else
|
||||
/* XXX should cause a fatal error */
|
||||
mvn r0, #0
|
||||
#endif
|
||||
RET
|
||||
|
||||
ENTRY(__udivsi3)
|
||||
.L_udivide: /* r0 = r0 / r1; r1 = r0 % r1 */
|
||||
eor r0, r1, r0
|
||||
eor r1, r0, r1
|
||||
eor r0, r1, r0
|
||||
/* r0 = r1 / r0; r1 = r1 % r0 */
|
||||
cmp r0, #1
|
||||
bcc .L_overflow
|
||||
beq .L_divide_l0
|
||||
mov ip, #0
|
||||
movs r1, r1
|
||||
bpl .L_divide_l1
|
||||
orr ip, ip, #0x20000000 /* ip bit 0x20000000 = -ve r1 */
|
||||
movs r1, r1, lsr #1
|
||||
orrcs ip, ip, #0x10000000 /* ip bit 0x10000000 = bit 0 of r1 */
|
||||
b .L_divide_l1
|
||||
|
||||
.L_divide_l0: /* r0 == 1 */
|
||||
mov r0, r1
|
||||
mov r1, #0
|
||||
RET
|
||||
|
||||
ENTRY(__divsi3)
|
||||
.L_divide: /* r0 = r0 / r1; r1 = r0 % r1 */
|
||||
eor r0, r1, r0
|
||||
eor r1, r0, r1
|
||||
eor r0, r1, r0
|
||||
/* r0 = r1 / r0; r1 = r1 % r0 */
|
||||
cmp r0, #1
|
||||
bcc .L_overflow
|
||||
beq .L_divide_l0
|
||||
ands ip, r0, #0x80000000
|
||||
rsbmi r0, r0, #0
|
||||
ands r2, r1, #0x80000000
|
||||
eor ip, ip, r2
|
||||
rsbmi r1, r1, #0
|
||||
orr ip, r2, ip, lsr #1 /* ip bit 0x40000000 = -ve division */
|
||||
/* ip bit 0x80000000 = -ve remainder */
|
||||
|
||||
.L_divide_l1:
|
||||
mov r2, #1
|
||||
mov r3, #0
|
||||
|
||||
/*
|
||||
* If the highest bit of the dividend is set, we have to be
|
||||
* careful when shifting the divisor. Test this.
|
||||
*/
|
||||
movs r1,r1
|
||||
bpl .L_old_code
|
||||
|
||||
/*
|
||||
* At this point, the highest bit of r1 is known to be set.
|
||||
* We abuse this below in the tst instructions.
|
||||
*/
|
||||
tst r1, r0 /*, lsl #0 */
|
||||
bmi .L_divide_b1
|
||||
tst r1, r0, lsl #1
|
||||
bmi .L_divide_b2
|
||||
tst r1, r0, lsl #2
|
||||
bmi .L_divide_b3
|
||||
tst r1, r0, lsl #3
|
||||
bmi .L_divide_b4
|
||||
tst r1, r0, lsl #4
|
||||
bmi .L_divide_b5
|
||||
tst r1, r0, lsl #5
|
||||
bmi .L_divide_b6
|
||||
tst r1, r0, lsl #6
|
||||
bmi .L_divide_b7
|
||||
tst r1, r0, lsl #7
|
||||
bmi .L_divide_b8
|
||||
tst r1, r0, lsl #8
|
||||
bmi .L_divide_b9
|
||||
tst r1, r0, lsl #9
|
||||
bmi .L_divide_b10
|
||||
tst r1, r0, lsl #10
|
||||
bmi .L_divide_b11
|
||||
tst r1, r0, lsl #11
|
||||
bmi .L_divide_b12
|
||||
tst r1, r0, lsl #12
|
||||
bmi .L_divide_b13
|
||||
tst r1, r0, lsl #13
|
||||
bmi .L_divide_b14
|
||||
tst r1, r0, lsl #14
|
||||
bmi .L_divide_b15
|
||||
tst r1, r0, lsl #15
|
||||
bmi .L_divide_b16
|
||||
tst r1, r0, lsl #16
|
||||
bmi .L_divide_b17
|
||||
tst r1, r0, lsl #17
|
||||
bmi .L_divide_b18
|
||||
tst r1, r0, lsl #18
|
||||
bmi .L_divide_b19
|
||||
tst r1, r0, lsl #19
|
||||
bmi .L_divide_b20
|
||||
tst r1, r0, lsl #20
|
||||
bmi .L_divide_b21
|
||||
tst r1, r0, lsl #21
|
||||
bmi .L_divide_b22
|
||||
tst r1, r0, lsl #22
|
||||
bmi .L_divide_b23
|
||||
tst r1, r0, lsl #23
|
||||
bmi .L_divide_b24
|
||||
tst r1, r0, lsl #24
|
||||
bmi .L_divide_b25
|
||||
tst r1, r0, lsl #25
|
||||
bmi .L_divide_b26
|
||||
tst r1, r0, lsl #26
|
||||
bmi .L_divide_b27
|
||||
tst r1, r0, lsl #27
|
||||
bmi .L_divide_b28
|
||||
tst r1, r0, lsl #28
|
||||
bmi .L_divide_b29
|
||||
tst r1, r0, lsl #29
|
||||
bmi .L_divide_b30
|
||||
tst r1, r0, lsl #30
|
||||
bmi .L_divide_b31
|
||||
/*
|
||||
* instead of:
|
||||
* tst r1, r0, lsl #31
|
||||
* bmi .L_divide_b32
|
||||
*/
|
||||
b .L_divide_b32
|
||||
|
||||
.L_old_code:
|
||||
cmp r1, r0
|
||||
bcc .L_divide_b0
|
||||
cmp r1, r0, lsl #1
|
||||
bcc .L_divide_b1
|
||||
cmp r1, r0, lsl #2
|
||||
bcc .L_divide_b2
|
||||
cmp r1, r0, lsl #3
|
||||
bcc .L_divide_b3
|
||||
cmp r1, r0, lsl #4
|
||||
bcc .L_divide_b4
|
||||
cmp r1, r0, lsl #5
|
||||
bcc .L_divide_b5
|
||||
cmp r1, r0, lsl #6
|
||||
bcc .L_divide_b6
|
||||
cmp r1, r0, lsl #7
|
||||
bcc .L_divide_b7
|
||||
cmp r1, r0, lsl #8
|
||||
bcc .L_divide_b8
|
||||
cmp r1, r0, lsl #9
|
||||
bcc .L_divide_b9
|
||||
cmp r1, r0, lsl #10
|
||||
bcc .L_divide_b10
|
||||
cmp r1, r0, lsl #11
|
||||
bcc .L_divide_b11
|
||||
cmp r1, r0, lsl #12
|
||||
bcc .L_divide_b12
|
||||
cmp r1, r0, lsl #13
|
||||
bcc .L_divide_b13
|
||||
cmp r1, r0, lsl #14
|
||||
bcc .L_divide_b14
|
||||
cmp r1, r0, lsl #15
|
||||
bcc .L_divide_b15
|
||||
cmp r1, r0, lsl #16
|
||||
bcc .L_divide_b16
|
||||
cmp r1, r0, lsl #17
|
||||
bcc .L_divide_b17
|
||||
cmp r1, r0, lsl #18
|
||||
bcc .L_divide_b18
|
||||
cmp r1, r0, lsl #19
|
||||
bcc .L_divide_b19
|
||||
cmp r1, r0, lsl #20
|
||||
bcc .L_divide_b20
|
||||
cmp r1, r0, lsl #21
|
||||
bcc .L_divide_b21
|
||||
cmp r1, r0, lsl #22
|
||||
bcc .L_divide_b22
|
||||
cmp r1, r0, lsl #23
|
||||
bcc .L_divide_b23
|
||||
cmp r1, r0, lsl #24
|
||||
bcc .L_divide_b24
|
||||
cmp r1, r0, lsl #25
|
||||
bcc .L_divide_b25
|
||||
cmp r1, r0, lsl #26
|
||||
bcc .L_divide_b26
|
||||
cmp r1, r0, lsl #27
|
||||
bcc .L_divide_b27
|
||||
cmp r1, r0, lsl #28
|
||||
bcc .L_divide_b28
|
||||
cmp r1, r0, lsl #29
|
||||
bcc .L_divide_b29
|
||||
cmp r1, r0, lsl #30
|
||||
bcc .L_divide_b30
|
||||
.L_divide_b32:
|
||||
cmp r1, r0, lsl #31
|
||||
subhs r1, r1,r0, lsl #31
|
||||
addhs r3, r3,r2, lsl #31
|
||||
.L_divide_b31:
|
||||
cmp r1, r0, lsl #30
|
||||
subhs r1, r1,r0, lsl #30
|
||||
addhs r3, r3,r2, lsl #30
|
||||
.L_divide_b30:
|
||||
cmp r1, r0, lsl #29
|
||||
subhs r1, r1,r0, lsl #29
|
||||
addhs r3, r3,r2, lsl #29
|
||||
.L_divide_b29:
|
||||
cmp r1, r0, lsl #28
|
||||
subhs r1, r1,r0, lsl #28
|
||||
addhs r3, r3,r2, lsl #28
|
||||
.L_divide_b28:
|
||||
cmp r1, r0, lsl #27
|
||||
subhs r1, r1,r0, lsl #27
|
||||
addhs r3, r3,r2, lsl #27
|
||||
.L_divide_b27:
|
||||
cmp r1, r0, lsl #26
|
||||
subhs r1, r1,r0, lsl #26
|
||||
addhs r3, r3,r2, lsl #26
|
||||
.L_divide_b26:
|
||||
cmp r1, r0, lsl #25
|
||||
subhs r1, r1,r0, lsl #25
|
||||
addhs r3, r3,r2, lsl #25
|
||||
.L_divide_b25:
|
||||
cmp r1, r0, lsl #24
|
||||
subhs r1, r1,r0, lsl #24
|
||||
addhs r3, r3,r2, lsl #24
|
||||
.L_divide_b24:
|
||||
cmp r1, r0, lsl #23
|
||||
subhs r1, r1,r0, lsl #23
|
||||
addhs r3, r3,r2, lsl #23
|
||||
.L_divide_b23:
|
||||
cmp r1, r0, lsl #22
|
||||
subhs r1, r1,r0, lsl #22
|
||||
addhs r3, r3,r2, lsl #22
|
||||
.L_divide_b22:
|
||||
cmp r1, r0, lsl #21
|
||||
subhs r1, r1,r0, lsl #21
|
||||
addhs r3, r3,r2, lsl #21
|
||||
.L_divide_b21:
|
||||
cmp r1, r0, lsl #20
|
||||
subhs r1, r1,r0, lsl #20
|
||||
addhs r3, r3,r2, lsl #20
|
||||
.L_divide_b20:
|
||||
cmp r1, r0, lsl #19
|
||||
subhs r1, r1,r0, lsl #19
|
||||
addhs r3, r3,r2, lsl #19
|
||||
.L_divide_b19:
|
||||
cmp r1, r0, lsl #18
|
||||
subhs r1, r1,r0, lsl #18
|
||||
addhs r3, r3,r2, lsl #18
|
||||
.L_divide_b18:
|
||||
cmp r1, r0, lsl #17
|
||||
subhs r1, r1,r0, lsl #17
|
||||
addhs r3, r3,r2, lsl #17
|
||||
.L_divide_b17:
|
||||
cmp r1, r0, lsl #16
|
||||
subhs r1, r1,r0, lsl #16
|
||||
addhs r3, r3,r2, lsl #16
|
||||
.L_divide_b16:
|
||||
cmp r1, r0, lsl #15
|
||||
subhs r1, r1,r0, lsl #15
|
||||
addhs r3, r3,r2, lsl #15
|
||||
.L_divide_b15:
|
||||
cmp r1, r0, lsl #14
|
||||
subhs r1, r1,r0, lsl #14
|
||||
addhs r3, r3,r2, lsl #14
|
||||
.L_divide_b14:
|
||||
cmp r1, r0, lsl #13
|
||||
subhs r1, r1,r0, lsl #13
|
||||
addhs r3, r3,r2, lsl #13
|
||||
.L_divide_b13:
|
||||
cmp r1, r0, lsl #12
|
||||
subhs r1, r1,r0, lsl #12
|
||||
addhs r3, r3,r2, lsl #12
|
||||
.L_divide_b12:
|
||||
cmp r1, r0, lsl #11
|
||||
subhs r1, r1,r0, lsl #11
|
||||
addhs r3, r3,r2, lsl #11
|
||||
.L_divide_b11:
|
||||
cmp r1, r0, lsl #10
|
||||
subhs r1, r1,r0, lsl #10
|
||||
addhs r3, r3,r2, lsl #10
|
||||
.L_divide_b10:
|
||||
cmp r1, r0, lsl #9
|
||||
subhs r1, r1,r0, lsl #9
|
||||
addhs r3, r3,r2, lsl #9
|
||||
.L_divide_b9:
|
||||
cmp r1, r0, lsl #8
|
||||
subhs r1, r1,r0, lsl #8
|
||||
addhs r3, r3,r2, lsl #8
|
||||
.L_divide_b8:
|
||||
cmp r1, r0, lsl #7
|
||||
subhs r1, r1,r0, lsl #7
|
||||
addhs r3, r3,r2, lsl #7
|
||||
.L_divide_b7:
|
||||
cmp r1, r0, lsl #6
|
||||
subhs r1, r1,r0, lsl #6
|
||||
addhs r3, r3,r2, lsl #6
|
||||
.L_divide_b6:
|
||||
cmp r1, r0, lsl #5
|
||||
subhs r1, r1,r0, lsl #5
|
||||
addhs r3, r3,r2, lsl #5
|
||||
.L_divide_b5:
|
||||
cmp r1, r0, lsl #4
|
||||
subhs r1, r1,r0, lsl #4
|
||||
addhs r3, r3,r2, lsl #4
|
||||
.L_divide_b4:
|
||||
cmp r1, r0, lsl #3
|
||||
subhs r1, r1,r0, lsl #3
|
||||
addhs r3, r3,r2, lsl #3
|
||||
.L_divide_b3:
|
||||
cmp r1, r0, lsl #2
|
||||
subhs r1, r1,r0, lsl #2
|
||||
addhs r3, r3,r2, lsl #2
|
||||
.L_divide_b2:
|
||||
cmp r1, r0, lsl #1
|
||||
subhs r1, r1,r0, lsl #1
|
||||
addhs r3, r3,r2, lsl #1
|
||||
.L_divide_b1:
|
||||
cmp r1, r0
|
||||
subhs r1, r1, r0
|
||||
addhs r3, r3, r2
|
||||
.L_divide_b0:
|
||||
|
||||
tst ip, #0x20000000
|
||||
bne .L_udivide_l1
|
||||
mov r0, r3
|
||||
cmp ip, #0
|
||||
rsbmi r1, r1, #0
|
||||
movs ip, ip, lsl #1
|
||||
bicmi r0, r0, #0x80000000 /* Fix incase we divided 0x80000000 */
|
||||
rsbmi r0, r0, #0
|
||||
RET
|
||||
|
||||
.L_udivide_l1:
|
||||
tst ip, #0x10000000
|
||||
mov r1, r1, lsl #1
|
||||
orrne r1, r1, #1
|
||||
mov r3, r3, lsl #1
|
||||
cmp r1, r0
|
||||
subhs r1, r1, r0
|
||||
addhs r3, r3, r2
|
||||
mov r0, r3
|
||||
RET
|
85
common/lib/libc/arch/arm/string/ffs.S
Normal file
85
common/lib/libc/arch/arm/string/ffs.S
Normal file
|
@ -0,0 +1,85 @@
|
|||
/* $NetBSD: ffs.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2001 Christopher Gilbert
|
||||
* 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.
|
||||
* 3. The name of the company nor the name of the author may be used to
|
||||
* endorse or promote products derived from this software without specific
|
||||
* prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 <machine/asm.h>
|
||||
|
||||
RCSID("$NetBSD: ffs.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
|
||||
|
||||
/*
|
||||
* ffs - find first set bit, this algorithm isolates the first set
|
||||
* bit, then multiplies the number by 0x0450fbaf which leaves the top
|
||||
* 6 bits as an index into the table. This algorithm should be a win
|
||||
* over the checking each bit in turn as per the C compiled version.
|
||||
*
|
||||
* On ARMv5 we use CLZ (count leading Zero's) and then subtract the result
|
||||
* from 32.
|
||||
*
|
||||
* This is the ffs algorithm devised by d.seal and posted to comp.sys.arm on
|
||||
* 16 Feb 1994.
|
||||
*/
|
||||
|
||||
ENTRY(ffs)
|
||||
#ifdef _ARM_ARCH_5
|
||||
/* (X & -X) gives LSB or zero. */
|
||||
rsb r1, r0, #0
|
||||
and r0, r0, r1
|
||||
clz r0, r0
|
||||
rsb r0, r0, #32
|
||||
RET
|
||||
#else
|
||||
/* Standard trick to isolate bottom bit in r0 or 0 if r0 = 0 on entry */
|
||||
rsb r1, r0, #0
|
||||
ands r0, r0, r1
|
||||
/*
|
||||
* now r0 has at most one set bit, call this X
|
||||
* if X = 0, all further instructions are skipped
|
||||
*/
|
||||
adrne r2, .L_ffs_table
|
||||
orrne r0, r0, r0, lsl #4 /* r0 = X * 0x11 */
|
||||
orrne r0, r0, r0, lsl #6 /* r0 = X * 0x451 */
|
||||
rsbne r0, r0, r0, lsl #16 /* r0 = X * 0x0450fbaf */
|
||||
|
||||
/* now lookup in table indexed on top 6 bits of r0 */
|
||||
ldrneb r0, [ r2, r0, lsr #26 ]
|
||||
|
||||
RET
|
||||
.text;
|
||||
.type .L_ffs_table, _ASM_TYPE_OBJECT;
|
||||
.L_ffs_table:
|
||||
/* 0 1 2 3 4 5 6 7 */
|
||||
.byte 0, 1, 2, 13, 3, 7, 0, 14 /* 0- 7 */
|
||||
.byte 4, 0, 8, 0, 0, 0, 0, 15 /* 8-15 */
|
||||
.byte 11, 5, 0, 0, 9, 0, 0, 26 /* 16-23 */
|
||||
.byte 0, 0, 0, 0, 0, 22, 28, 16 /* 24-31 */
|
||||
.byte 32, 12, 6, 0, 0, 0, 0, 0 /* 32-39 */
|
||||
.byte 10, 0, 0, 25, 0, 0, 21, 27 /* 40-47 */
|
||||
.byte 31, 0, 0, 0, 0, 24, 0, 20 /* 48-55 */
|
||||
.byte 30, 0, 23, 19, 29, 18, 17, 0 /* 56-63 */
|
||||
#endif
|
180
common/lib/libc/arch/arm/string/memcmp.S
Normal file
180
common/lib/libc/arch/arm/string/memcmp.S
Normal file
|
@ -0,0 +1,180 @@
|
|||
/* $NetBSD: memcmp.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 2003 Wasabi Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Written by Steve C. Woodford for Wasabi Systems, Inc.
|
||||
*
|
||||
* 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. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed for the NetBSD Project by
|
||||
* Wasabi Systems, Inc.
|
||||
* 4. The name of Wasabi Systems, Inc. may not be used to endorse
|
||||
* or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC
|
||||
* 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.
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 2002 ARM Ltd
|
||||
* 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.
|
||||
* 3. The name of the company may not be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ARM LTD ``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 ARM LTD 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 <machine/asm.h>
|
||||
|
||||
RCSID("$NetBSD: memcmp.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
|
||||
|
||||
ENTRY(memcmp)
|
||||
mov ip, r0
|
||||
#if defined(_KERNEL) && !defined(_STANDALONE)
|
||||
cmp r2, #0x06
|
||||
beq .Lmemcmp_6bytes
|
||||
#endif
|
||||
mov r0, #0x00
|
||||
|
||||
/* Are both addresses aligned the same way? */
|
||||
cmp r2, #0x00
|
||||
eornes r3, ip, r1
|
||||
RETc(eq) /* len == 0, or same addresses! */
|
||||
tst r3, #0x03
|
||||
subne r2, r2, #0x01
|
||||
bne .Lmemcmp_bytewise2 /* Badly aligned. Do it the slow way */
|
||||
|
||||
/* Word-align the addresses, if necessary */
|
||||
sub r3, r1, #0x05
|
||||
ands r3, r3, #0x03
|
||||
add r3, r3, r3, lsl #1
|
||||
addne pc, pc, r3, lsl #3
|
||||
nop
|
||||
|
||||
/* Compare up to 3 bytes */
|
||||
ldrb r0, [ip], #0x01
|
||||
ldrb r3, [r1], #0x01
|
||||
subs r0, r0, r3
|
||||
RETc(ne)
|
||||
subs r2, r2, #0x01
|
||||
RETc(eq)
|
||||
|
||||
/* Compare up to 2 bytes */
|
||||
ldrb r0, [ip], #0x01
|
||||
ldrb r3, [r1], #0x01
|
||||
subs r0, r0, r3
|
||||
RETc(ne)
|
||||
subs r2, r2, #0x01
|
||||
RETc(eq)
|
||||
|
||||
/* Compare 1 byte */
|
||||
ldrb r0, [ip], #0x01
|
||||
ldrb r3, [r1], #0x01
|
||||
subs r0, r0, r3
|
||||
RETc(ne)
|
||||
subs r2, r2, #0x01
|
||||
RETc(eq)
|
||||
|
||||
/* Compare 4 bytes at a time, if possible */
|
||||
subs r2, r2, #0x04
|
||||
bcc .Lmemcmp_bytewise
|
||||
.Lmemcmp_word_aligned:
|
||||
ldr r0, [ip], #0x04
|
||||
ldr r3, [r1], #0x04
|
||||
subs r2, r2, #0x04
|
||||
cmpcs r0, r3
|
||||
beq .Lmemcmp_word_aligned
|
||||
sub r0, r0, r3
|
||||
|
||||
/* Correct for extra subtraction, and check if done */
|
||||
adds r2, r2, #0x04
|
||||
cmpeq r0, #0x00 /* If done, did all bytes match? */
|
||||
RETc(eq) /* Yup. Just return */
|
||||
|
||||
/* Re-do the final word byte-wise */
|
||||
sub ip, ip, #0x04
|
||||
sub r1, r1, #0x04
|
||||
|
||||
.Lmemcmp_bytewise:
|
||||
add r2, r2, #0x03
|
||||
.Lmemcmp_bytewise2:
|
||||
ldrb r0, [ip], #0x01
|
||||
ldrb r3, [r1], #0x01
|
||||
subs r2, r2, #0x01
|
||||
cmpcs r0, r3
|
||||
beq .Lmemcmp_bytewise2
|
||||
sub r0, r0, r3
|
||||
RET
|
||||
|
||||
#if defined(_KERNEL) && !defined(_STANDALONE)
|
||||
/*
|
||||
* 6 byte compares are very common, thanks to the network stack.
|
||||
* This code is hand-scheduled to reduce the number of stalls for
|
||||
* load results. Everything else being equal, this will be ~32%
|
||||
* faster than a byte-wise memcmp.
|
||||
*/
|
||||
.align 5
|
||||
.Lmemcmp_6bytes:
|
||||
ldrb r3, [r1, #0x00] /* r3 = b2#0 */
|
||||
ldrb r0, [ip, #0x00] /* r0 = b1#0 */
|
||||
ldrb r2, [r1, #0x01] /* r2 = b2#1 */
|
||||
subs r0, r0, r3 /* r0 = b1#0 - b2#0 */
|
||||
ldreqb r3, [ip, #0x01] /* r3 = b1#1 */
|
||||
RETc(ne) /* Return if mismatch on #0 */
|
||||
subs r0, r3, r2 /* r0 = b1#1 - b2#1 */
|
||||
ldreqb r3, [r1, #0x02] /* r3 = b2#2 */
|
||||
ldreqb r0, [ip, #0x02] /* r0 = b1#2 */
|
||||
RETc(ne) /* Return if mismatch on #1 */
|
||||
ldrb r2, [r1, #0x03] /* r2 = b2#3 */
|
||||
subs r0, r0, r3 /* r0 = b1#2 - b2#2 */
|
||||
ldreqb r3, [ip, #0x03] /* r3 = b1#3 */
|
||||
RETc(ne) /* Return if mismatch on #2 */
|
||||
subs r0, r3, r2 /* r0 = b1#3 - b2#3 */
|
||||
ldreqb r3, [r1, #0x04] /* r3 = b2#4 */
|
||||
ldreqb r0, [ip, #0x04] /* r0 = b1#4 */
|
||||
RETc(ne) /* Return if mismatch on #3 */
|
||||
ldrb r2, [r1, #0x05] /* r2 = b2#5 */
|
||||
subs r0, r0, r3 /* r0 = b1#4 - b2#4 */
|
||||
ldreqb r3, [ip, #0x05] /* r3 = b1#5 */
|
||||
RETc(ne) /* Return if mismatch on #4 */
|
||||
sub r0, r3, r2 /* r0 = b1#5 - b2#5 */
|
||||
RET
|
||||
#endif
|
7
common/lib/libc/arch/arm/string/memcpy.S
Normal file
7
common/lib/libc/arch/arm/string/memcpy.S
Normal file
|
@ -0,0 +1,7 @@
|
|||
/* $NetBSD: memcpy.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
|
||||
|
||||
#if !defined(__XSCALE__) || defined(_STANDALONE)
|
||||
#include "memcpy_arm.S"
|
||||
#else
|
||||
#include "memcpy_xscale.S"
|
||||
#endif
|
332
common/lib/libc/arch/arm/string/memcpy_arm.S
Normal file
332
common/lib/libc/arch/arm/string/memcpy_arm.S
Normal file
|
@ -0,0 +1,332 @@
|
|||
/* $NetBSD: memcpy_arm.S,v 1.2 2008/04/28 20:22:52 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Neil A. Carson and Mark Brinicombe
|
||||
*
|
||||
* 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 <machine/asm.h>
|
||||
|
||||
/*
|
||||
* This is one fun bit of code ...
|
||||
* Some easy listening music is suggested while trying to understand this
|
||||
* code e.g. Iron Maiden
|
||||
*
|
||||
* For anyone attempting to understand it :
|
||||
*
|
||||
* The core code is implemented here with simple stubs for memcpy().
|
||||
*
|
||||
* All local labels are prefixed with Lmemcpy_
|
||||
* Following the prefix a label starting f is used in the forward copy code
|
||||
* while a label using b is used in the backwards copy code
|
||||
* The source and destination addresses determine whether a forward or
|
||||
* backward copy is performed.
|
||||
* Separate bits of code are used to deal with the following situations
|
||||
* for both the forward and backwards copy.
|
||||
* unaligned source address
|
||||
* unaligned destination address
|
||||
* Separate copy routines are used to produce an optimised result for each
|
||||
* of these cases.
|
||||
* The copy code will use LDM/STM instructions to copy up to 32 bytes at
|
||||
* a time where possible.
|
||||
*
|
||||
* Note: r12 (aka ip) can be trashed during the function along with
|
||||
* r0-r3 although r0-r2 have defined uses i.e. src, dest, len through out.
|
||||
* Additional registers are preserved prior to use i.e. r4, r5 & lr
|
||||
*
|
||||
* Apologies for the state of the comments ;-)
|
||||
*/
|
||||
/* LINTSTUB: Func: void *memcpy(void *dst, const void *src, size_t len) */
|
||||
ENTRY(memcpy)
|
||||
/* save leaf functions having to store this away */
|
||||
stmdb sp!, {r0, lr} /* memcpy() returns dest addr */
|
||||
|
||||
subs r2, r2, #4
|
||||
blt .Lmemcpy_l4 /* less than 4 bytes */
|
||||
ands r12, r0, #3
|
||||
bne .Lmemcpy_destul /* oh unaligned destination addr */
|
||||
ands r12, r1, #3
|
||||
bne .Lmemcpy_srcul /* oh unaligned source addr */
|
||||
|
||||
.Lmemcpy_t8:
|
||||
/* We have aligned source and destination */
|
||||
subs r2, r2, #8
|
||||
blt .Lmemcpy_l12 /* less than 12 bytes (4 from above) */
|
||||
subs r2, r2, #0x14
|
||||
blt .Lmemcpy_l32 /* less than 32 bytes (12 from above) */
|
||||
stmdb sp!, {r4} /* borrow r4 */
|
||||
|
||||
/* blat 32 bytes at a time */
|
||||
/* XXX for really big copies perhaps we should use more registers */
|
||||
.Lmemcpy_loop32:
|
||||
ldmia r1!, {r3, r4, r12, lr}
|
||||
stmia r0!, {r3, r4, r12, lr}
|
||||
ldmia r1!, {r3, r4, r12, lr}
|
||||
stmia r0!, {r3, r4, r12, lr}
|
||||
subs r2, r2, #0x20
|
||||
bge .Lmemcpy_loop32
|
||||
|
||||
cmn r2, #0x10
|
||||
ldmgeia r1!, {r3, r4, r12, lr} /* blat a remaining 16 bytes */
|
||||
stmgeia r0!, {r3, r4, r12, lr}
|
||||
subge r2, r2, #0x10
|
||||
ldmia sp!, {r4} /* return r4 */
|
||||
|
||||
.Lmemcpy_l32:
|
||||
adds r2, r2, #0x14
|
||||
|
||||
/* blat 12 bytes at a time */
|
||||
.Lmemcpy_loop12:
|
||||
ldmgeia r1!, {r3, r12, lr}
|
||||
stmgeia r0!, {r3, r12, lr}
|
||||
subges r2, r2, #0x0c
|
||||
bge .Lmemcpy_loop12
|
||||
|
||||
.Lmemcpy_l12:
|
||||
adds r2, r2, #8
|
||||
blt .Lmemcpy_l4
|
||||
|
||||
subs r2, r2, #4
|
||||
ldrlt r3, [r1], #4
|
||||
strlt r3, [r0], #4
|
||||
ldmgeia r1!, {r3, r12}
|
||||
stmgeia r0!, {r3, r12}
|
||||
subge r2, r2, #4
|
||||
|
||||
.Lmemcpy_l4:
|
||||
/* less than 4 bytes to go */
|
||||
adds r2, r2, #4
|
||||
#ifdef __APCS_26_
|
||||
ldmeqia sp!, {r0, pc}^ /* done */
|
||||
#else
|
||||
ldmeqia sp!, {r0, pc} /* done */
|
||||
#endif
|
||||
/* copy the crud byte at a time */
|
||||
cmp r2, #2
|
||||
ldrb r3, [r1], #1
|
||||
strb r3, [r0], #1
|
||||
ldrgeb r3, [r1], #1
|
||||
strgeb r3, [r0], #1
|
||||
ldrgtb r3, [r1], #1
|
||||
strgtb r3, [r0], #1
|
||||
ldmia sp!, {r0, pc}
|
||||
|
||||
/* erg - unaligned destination */
|
||||
.Lmemcpy_destul:
|
||||
rsb r12, r12, #4
|
||||
cmp r12, #2
|
||||
|
||||
/* align destination with byte copies */
|
||||
ldrb r3, [r1], #1
|
||||
strb r3, [r0], #1
|
||||
ldrgeb r3, [r1], #1
|
||||
strgeb r3, [r0], #1
|
||||
ldrgtb r3, [r1], #1
|
||||
strgtb r3, [r0], #1
|
||||
subs r2, r2, r12
|
||||
blt .Lmemcpy_l4 /* less the 4 bytes */
|
||||
|
||||
ands r12, r1, #3
|
||||
beq .Lmemcpy_t8 /* we have an aligned source */
|
||||
|
||||
/* erg - unaligned source */
|
||||
/* This is where it gets nasty ... */
|
||||
.Lmemcpy_srcul:
|
||||
bic r1, r1, #3
|
||||
ldr lr, [r1], #4
|
||||
cmp r12, #2
|
||||
bgt .Lmemcpy_srcul3
|
||||
beq .Lmemcpy_srcul2
|
||||
cmp r2, #0x0c
|
||||
blt .Lmemcpy_srcul1loop4
|
||||
sub r2, r2, #0x0c
|
||||
stmdb sp!, {r4, r5}
|
||||
|
||||
.Lmemcpy_srcul1loop16:
|
||||
#ifdef __ARMEB__
|
||||
mov r3, lr, lsl #8
|
||||
#else
|
||||
mov r3, lr, lsr #8
|
||||
#endif
|
||||
ldmia r1!, {r4, r5, r12, lr}
|
||||
#ifdef __ARMEB__
|
||||
orr r3, r3, r4, lsr #24
|
||||
mov r4, r4, lsl #8
|
||||
orr r4, r4, r5, lsr #24
|
||||
mov r5, r5, lsl #8
|
||||
orr r5, r5, r12, lsr #24
|
||||
mov r12, r12, lsl #8
|
||||
orr r12, r12, lr, lsr #24
|
||||
#else
|
||||
orr r3, r3, r4, lsl #24
|
||||
mov r4, r4, lsr #8
|
||||
orr r4, r4, r5, lsl #24
|
||||
mov r5, r5, lsr #8
|
||||
orr r5, r5, r12, lsl #24
|
||||
mov r12, r12, lsr #8
|
||||
orr r12, r12, lr, lsl #24
|
||||
#endif
|
||||
stmia r0!, {r3-r5, r12}
|
||||
subs r2, r2, #0x10
|
||||
bge .Lmemcpy_srcul1loop16
|
||||
ldmia sp!, {r4, r5}
|
||||
adds r2, r2, #0x0c
|
||||
blt .Lmemcpy_srcul1l4
|
||||
|
||||
.Lmemcpy_srcul1loop4:
|
||||
#ifdef __ARMEB__
|
||||
mov r12, lr, lsl #8
|
||||
#else
|
||||
mov r12, lr, lsr #8
|
||||
#endif
|
||||
ldr lr, [r1], #4
|
||||
#ifdef __ARMEB__
|
||||
orr r12, r12, lr, lsr #24
|
||||
#else
|
||||
orr r12, r12, lr, lsl #24
|
||||
#endif
|
||||
str r12, [r0], #4
|
||||
subs r2, r2, #4
|
||||
bge .Lmemcpy_srcul1loop4
|
||||
|
||||
.Lmemcpy_srcul1l4:
|
||||
sub r1, r1, #3
|
||||
b .Lmemcpy_l4
|
||||
|
||||
.Lmemcpy_srcul2:
|
||||
cmp r2, #0x0c
|
||||
blt .Lmemcpy_srcul2loop4
|
||||
sub r2, r2, #0x0c
|
||||
stmdb sp!, {r4, r5}
|
||||
|
||||
.Lmemcpy_srcul2loop16:
|
||||
#ifdef __ARMEB__
|
||||
mov r3, lr, lsl #16
|
||||
#else
|
||||
mov r3, lr, lsr #16
|
||||
#endif
|
||||
ldmia r1!, {r4, r5, r12, lr}
|
||||
#ifdef __ARMEB__
|
||||
orr r3, r3, r4, lsr #16
|
||||
mov r4, r4, lsl #16
|
||||
orr r4, r4, r5, lsr #16
|
||||
mov r5, r5, lsl #16
|
||||
orr r5, r5, r12, lsr #16
|
||||
mov r12, r12, lsl #16
|
||||
orr r12, r12, lr, lsr #16
|
||||
#else
|
||||
orr r3, r3, r4, lsl #16
|
||||
mov r4, r4, lsr #16
|
||||
orr r4, r4, r5, lsl #16
|
||||
mov r5, r5, lsr #16
|
||||
orr r5, r5, r12, lsl #16
|
||||
mov r12, r12, lsr #16
|
||||
orr r12, r12, lr, lsl #16
|
||||
#endif
|
||||
stmia r0!, {r3-r5, r12}
|
||||
subs r2, r2, #0x10
|
||||
bge .Lmemcpy_srcul2loop16
|
||||
ldmia sp!, {r4, r5}
|
||||
adds r2, r2, #0x0c
|
||||
blt .Lmemcpy_srcul2l4
|
||||
|
||||
.Lmemcpy_srcul2loop4:
|
||||
#ifdef __ARMEB__
|
||||
mov r12, lr, lsl #16
|
||||
#else
|
||||
mov r12, lr, lsr #16
|
||||
#endif
|
||||
ldr lr, [r1], #4
|
||||
#ifdef __ARMEB__
|
||||
orr r12, r12, lr, lsr #16
|
||||
#else
|
||||
orr r12, r12, lr, lsl #16
|
||||
#endif
|
||||
str r12, [r0], #4
|
||||
subs r2, r2, #4
|
||||
bge .Lmemcpy_srcul2loop4
|
||||
|
||||
.Lmemcpy_srcul2l4:
|
||||
sub r1, r1, #2
|
||||
b .Lmemcpy_l4
|
||||
|
||||
.Lmemcpy_srcul3:
|
||||
cmp r2, #0x0c
|
||||
blt .Lmemcpy_srcul3loop4
|
||||
sub r2, r2, #0x0c
|
||||
stmdb sp!, {r4, r5}
|
||||
|
||||
.Lmemcpy_srcul3loop16:
|
||||
#ifdef __ARMEB__
|
||||
mov r3, lr, lsl #24
|
||||
#else
|
||||
mov r3, lr, lsr #24
|
||||
#endif
|
||||
ldmia r1!, {r4, r5, r12, lr}
|
||||
#ifdef __ARMEB__
|
||||
orr r3, r3, r4, lsr #8
|
||||
mov r4, r4, lsl #24
|
||||
orr r4, r4, r5, lsr #8
|
||||
mov r5, r5, lsl #24
|
||||
orr r5, r5, r12, lsr #8
|
||||
mov r12, r12, lsl #24
|
||||
orr r12, r12, lr, lsr #8
|
||||
#else
|
||||
orr r3, r3, r4, lsl #8
|
||||
mov r4, r4, lsr #24
|
||||
orr r4, r4, r5, lsl #8
|
||||
mov r5, r5, lsr #24
|
||||
orr r5, r5, r12, lsl #8
|
||||
mov r12, r12, lsr #24
|
||||
orr r12, r12, lr, lsl #8
|
||||
#endif
|
||||
stmia r0!, {r3-r5, r12}
|
||||
subs r2, r2, #0x10
|
||||
bge .Lmemcpy_srcul3loop16
|
||||
ldmia sp!, {r4, r5}
|
||||
adds r2, r2, #0x0c
|
||||
blt .Lmemcpy_srcul3l4
|
||||
|
||||
.Lmemcpy_srcul3loop4:
|
||||
#ifdef __ARMEB__
|
||||
mov r12, lr, lsl #24
|
||||
#else
|
||||
mov r12, lr, lsr #24
|
||||
#endif
|
||||
ldr lr, [r1], #4
|
||||
#ifdef __ARMEB__
|
||||
orr r12, r12, lr, lsr #8
|
||||
#else
|
||||
orr r12, r12, lr, lsl #8
|
||||
#endif
|
||||
str r12, [r0], #4
|
||||
subs r2, r2, #4
|
||||
bge .Lmemcpy_srcul3loop4
|
||||
|
||||
.Lmemcpy_srcul3l4:
|
||||
sub r1, r1, #1
|
||||
b .Lmemcpy_l4
|
1893
common/lib/libc/arch/arm/string/memcpy_xscale.S
Normal file
1893
common/lib/libc/arch/arm/string/memcpy_xscale.S
Normal file
File diff suppressed because it is too large
Load diff
581
common/lib/libc/arch/arm/string/memmove.S
Normal file
581
common/lib/libc/arch/arm/string/memmove.S
Normal file
|
@ -0,0 +1,581 @@
|
|||
/* $NetBSD: memmove.S,v 1.3 2008/04/28 20:22:52 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Neil A. Carson and Mark Brinicombe
|
||||
*
|
||||
* 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 <machine/asm.h>
|
||||
|
||||
#ifndef _BCOPY
|
||||
/* LINTSTUB: Func: void *memmove(void *, const void *, size_t) */
|
||||
ENTRY(memmove)
|
||||
#else
|
||||
/* bcopy = memcpy/memmove with arguments reversed. */
|
||||
/* LINTSTUB: Func: void bcopy(void *, void *, size_t) */
|
||||
ENTRY(bcopy)
|
||||
/* switch the source and destination registers */
|
||||
eor r0, r1, r0
|
||||
eor r1, r0, r1
|
||||
eor r0, r1, r0
|
||||
#endif
|
||||
/* Do the buffers overlap? */
|
||||
cmp r0, r1
|
||||
RETc(eq) /* Bail now if src/dst are the same */
|
||||
subhs r3, r0, r1 /* if (dst > src) r3 = dst - src */
|
||||
sublo r3, r1, r0 /* if (src > dst) r3 = src - dst */
|
||||
cmp r3, r2 /* if (r3 >= len) we have an overlap */
|
||||
bhs PIC_SYM(_C_LABEL(memcpy), PLT)
|
||||
|
||||
/* Determine copy direction */
|
||||
cmp r1, r0
|
||||
bcc .Lmemmove_backwards
|
||||
|
||||
moveq r0, #0 /* Quick abort for len=0 */
|
||||
RETc(eq)
|
||||
|
||||
stmdb sp!, {r0, lr} /* memmove() returns dest addr */
|
||||
subs r2, r2, #4
|
||||
blt .Lmemmove_fl4 /* less than 4 bytes */
|
||||
ands r12, r0, #3
|
||||
bne .Lmemmove_fdestul /* oh unaligned destination addr */
|
||||
ands r12, r1, #3
|
||||
bne .Lmemmove_fsrcul /* oh unaligned source addr */
|
||||
|
||||
.Lmemmove_ft8:
|
||||
/* We have aligned source and destination */
|
||||
subs r2, r2, #8
|
||||
blt .Lmemmove_fl12 /* less than 12 bytes (4 from above) */
|
||||
subs r2, r2, #0x14
|
||||
blt .Lmemmove_fl32 /* less than 32 bytes (12 from above) */
|
||||
stmdb sp!, {r4} /* borrow r4 */
|
||||
|
||||
/* blat 32 bytes at a time */
|
||||
/* XXX for really big copies perhaps we should use more registers */
|
||||
.Lmemmove_floop32:
|
||||
ldmia r1!, {r3, r4, r12, lr}
|
||||
stmia r0!, {r3, r4, r12, lr}
|
||||
ldmia r1!, {r3, r4, r12, lr}
|
||||
stmia r0!, {r3, r4, r12, lr}
|
||||
subs r2, r2, #0x20
|
||||
bge .Lmemmove_floop32
|
||||
|
||||
cmn r2, #0x10
|
||||
ldmgeia r1!, {r3, r4, r12, lr} /* blat a remaining 16 bytes */
|
||||
stmgeia r0!, {r3, r4, r12, lr}
|
||||
subge r2, r2, #0x10
|
||||
ldmia sp!, {r4} /* return r4 */
|
||||
|
||||
.Lmemmove_fl32:
|
||||
adds r2, r2, #0x14
|
||||
|
||||
/* blat 12 bytes at a time */
|
||||
.Lmemmove_floop12:
|
||||
ldmgeia r1!, {r3, r12, lr}
|
||||
stmgeia r0!, {r3, r12, lr}
|
||||
subges r2, r2, #0x0c
|
||||
bge .Lmemmove_floop12
|
||||
|
||||
.Lmemmove_fl12:
|
||||
adds r2, r2, #8
|
||||
blt .Lmemmove_fl4
|
||||
|
||||
subs r2, r2, #4
|
||||
ldrlt r3, [r1], #4
|
||||
strlt r3, [r0], #4
|
||||
ldmgeia r1!, {r3, r12}
|
||||
stmgeia r0!, {r3, r12}
|
||||
subge r2, r2, #4
|
||||
|
||||
.Lmemmove_fl4:
|
||||
/* less than 4 bytes to go */
|
||||
adds r2, r2, #4
|
||||
ldmeqia sp!, {r0, pc} /* done */
|
||||
|
||||
/* copy the crud byte at a time */
|
||||
cmp r2, #2
|
||||
ldrb r3, [r1], #1
|
||||
strb r3, [r0], #1
|
||||
ldrgeb r3, [r1], #1
|
||||
strgeb r3, [r0], #1
|
||||
ldrgtb r3, [r1], #1
|
||||
strgtb r3, [r0], #1
|
||||
ldmia sp!, {r0, pc}
|
||||
|
||||
/* erg - unaligned destination */
|
||||
.Lmemmove_fdestul:
|
||||
rsb r12, r12, #4
|
||||
cmp r12, #2
|
||||
|
||||
/* align destination with byte copies */
|
||||
ldrb r3, [r1], #1
|
||||
strb r3, [r0], #1
|
||||
ldrgeb r3, [r1], #1
|
||||
strgeb r3, [r0], #1
|
||||
ldrgtb r3, [r1], #1
|
||||
strgtb r3, [r0], #1
|
||||
subs r2, r2, r12
|
||||
blt .Lmemmove_fl4 /* less the 4 bytes */
|
||||
|
||||
ands r12, r1, #3
|
||||
beq .Lmemmove_ft8 /* we have an aligned source */
|
||||
|
||||
/* erg - unaligned source */
|
||||
/* This is where it gets nasty ... */
|
||||
.Lmemmove_fsrcul:
|
||||
bic r1, r1, #3
|
||||
ldr lr, [r1], #4
|
||||
cmp r12, #2
|
||||
bgt .Lmemmove_fsrcul3
|
||||
beq .Lmemmove_fsrcul2
|
||||
cmp r2, #0x0c
|
||||
blt .Lmemmove_fsrcul1loop4
|
||||
sub r2, r2, #0x0c
|
||||
stmdb sp!, {r4, r5}
|
||||
|
||||
.Lmemmove_fsrcul1loop16:
|
||||
#ifdef __ARMEB__
|
||||
mov r3, lr, lsl #8
|
||||
#else
|
||||
mov r3, lr, lsr #8
|
||||
#endif
|
||||
ldmia r1!, {r4, r5, r12, lr}
|
||||
#ifdef __ARMEB__
|
||||
orr r3, r3, r4, lsr #24
|
||||
mov r4, r4, lsl #8
|
||||
orr r4, r4, r5, lsr #24
|
||||
mov r5, r5, lsl #8
|
||||
orr r5, r5, r12, lsr #24
|
||||
mov r12, r12, lsl #8
|
||||
orr r12, r12, lr, lsr #24
|
||||
#else
|
||||
orr r3, r3, r4, lsl #24
|
||||
mov r4, r4, lsr #8
|
||||
orr r4, r4, r5, lsl #24
|
||||
mov r5, r5, lsr #8
|
||||
orr r5, r5, r12, lsl #24
|
||||
mov r12, r12, lsr #8
|
||||
orr r12, r12, lr, lsl #24
|
||||
#endif
|
||||
stmia r0!, {r3-r5, r12}
|
||||
subs r2, r2, #0x10
|
||||
bge .Lmemmove_fsrcul1loop16
|
||||
ldmia sp!, {r4, r5}
|
||||
adds r2, r2, #0x0c
|
||||
blt .Lmemmove_fsrcul1l4
|
||||
|
||||
.Lmemmove_fsrcul1loop4:
|
||||
#ifdef __ARMEB__
|
||||
mov r12, lr, lsl #8
|
||||
#else
|
||||
mov r12, lr, lsr #8
|
||||
#endif
|
||||
ldr lr, [r1], #4
|
||||
#ifdef __ARMEB__
|
||||
orr r12, r12, lr, lsr #24
|
||||
#else
|
||||
orr r12, r12, lr, lsl #24
|
||||
#endif
|
||||
str r12, [r0], #4
|
||||
subs r2, r2, #4
|
||||
bge .Lmemmove_fsrcul1loop4
|
||||
|
||||
.Lmemmove_fsrcul1l4:
|
||||
sub r1, r1, #3
|
||||
b .Lmemmove_fl4
|
||||
|
||||
.Lmemmove_fsrcul2:
|
||||
cmp r2, #0x0c
|
||||
blt .Lmemmove_fsrcul2loop4
|
||||
sub r2, r2, #0x0c
|
||||
stmdb sp!, {r4, r5}
|
||||
|
||||
.Lmemmove_fsrcul2loop16:
|
||||
#ifdef __ARMEB__
|
||||
mov r3, lr, lsl #16
|
||||
#else
|
||||
mov r3, lr, lsr #16
|
||||
#endif
|
||||
ldmia r1!, {r4, r5, r12, lr}
|
||||
#ifdef __ARMEB__
|
||||
orr r3, r3, r4, lsr #16
|
||||
mov r4, r4, lsl #16
|
||||
orr r4, r4, r5, lsr #16
|
||||
mov r5, r5, lsl #16
|
||||
orr r5, r5, r12, lsr #16
|
||||
mov r12, r12, lsl #16
|
||||
orr r12, r12, lr, lsr #16
|
||||
#else
|
||||
orr r3, r3, r4, lsl #16
|
||||
mov r4, r4, lsr #16
|
||||
orr r4, r4, r5, lsl #16
|
||||
mov r5, r5, lsr #16
|
||||
orr r5, r5, r12, lsl #16
|
||||
mov r12, r12, lsr #16
|
||||
orr r12, r12, lr, lsl #16
|
||||
#endif
|
||||
stmia r0!, {r3-r5, r12}
|
||||
subs r2, r2, #0x10
|
||||
bge .Lmemmove_fsrcul2loop16
|
||||
ldmia sp!, {r4, r5}
|
||||
adds r2, r2, #0x0c
|
||||
blt .Lmemmove_fsrcul2l4
|
||||
|
||||
.Lmemmove_fsrcul2loop4:
|
||||
#ifdef __ARMEB__
|
||||
mov r12, lr, lsl #16
|
||||
#else
|
||||
mov r12, lr, lsr #16
|
||||
#endif
|
||||
ldr lr, [r1], #4
|
||||
#ifdef __ARMEB__
|
||||
orr r12, r12, lr, lsr #16
|
||||
#else
|
||||
orr r12, r12, lr, lsl #16
|
||||
#endif
|
||||
str r12, [r0], #4
|
||||
subs r2, r2, #4
|
||||
bge .Lmemmove_fsrcul2loop4
|
||||
|
||||
.Lmemmove_fsrcul2l4:
|
||||
sub r1, r1, #2
|
||||
b .Lmemmove_fl4
|
||||
|
||||
.Lmemmove_fsrcul3:
|
||||
cmp r2, #0x0c
|
||||
blt .Lmemmove_fsrcul3loop4
|
||||
sub r2, r2, #0x0c
|
||||
stmdb sp!, {r4, r5}
|
||||
|
||||
.Lmemmove_fsrcul3loop16:
|
||||
#ifdef __ARMEB__
|
||||
mov r3, lr, lsl #24
|
||||
#else
|
||||
mov r3, lr, lsr #24
|
||||
#endif
|
||||
ldmia r1!, {r4, r5, r12, lr}
|
||||
#ifdef __ARMEB__
|
||||
orr r3, r3, r4, lsr #8
|
||||
mov r4, r4, lsl #24
|
||||
orr r4, r4, r5, lsr #8
|
||||
mov r5, r5, lsl #24
|
||||
orr r5, r5, r12, lsr #8
|
||||
mov r12, r12, lsl #24
|
||||
orr r12, r12, lr, lsr #8
|
||||
#else
|
||||
orr r3, r3, r4, lsl #8
|
||||
mov r4, r4, lsr #24
|
||||
orr r4, r4, r5, lsl #8
|
||||
mov r5, r5, lsr #24
|
||||
orr r5, r5, r12, lsl #8
|
||||
mov r12, r12, lsr #24
|
||||
orr r12, r12, lr, lsl #8
|
||||
#endif
|
||||
stmia r0!, {r3-r5, r12}
|
||||
subs r2, r2, #0x10
|
||||
bge .Lmemmove_fsrcul3loop16
|
||||
ldmia sp!, {r4, r5}
|
||||
adds r2, r2, #0x0c
|
||||
blt .Lmemmove_fsrcul3l4
|
||||
|
||||
.Lmemmove_fsrcul3loop4:
|
||||
#ifdef __ARMEB__
|
||||
mov r12, lr, lsl #24
|
||||
#else
|
||||
mov r12, lr, lsr #24
|
||||
#endif
|
||||
ldr lr, [r1], #4
|
||||
#ifdef __ARMEB__
|
||||
orr r12, r12, lr, lsr #8
|
||||
#else
|
||||
orr r12, r12, lr, lsl #8
|
||||
#endif
|
||||
str r12, [r0], #4
|
||||
subs r2, r2, #4
|
||||
bge .Lmemmove_fsrcul3loop4
|
||||
|
||||
.Lmemmove_fsrcul3l4:
|
||||
sub r1, r1, #1
|
||||
b .Lmemmove_fl4
|
||||
|
||||
.Lmemmove_backwards:
|
||||
add r1, r1, r2
|
||||
add r0, r0, r2
|
||||
subs r2, r2, #4
|
||||
blt .Lmemmove_bl4 /* less than 4 bytes */
|
||||
ands r12, r0, #3
|
||||
bne .Lmemmove_bdestul /* oh unaligned destination addr */
|
||||
ands r12, r1, #3
|
||||
bne .Lmemmove_bsrcul /* oh unaligned source addr */
|
||||
|
||||
.Lmemmove_bt8:
|
||||
/* We have aligned source and destination */
|
||||
subs r2, r2, #8
|
||||
blt .Lmemmove_bl12 /* less than 12 bytes (4 from above) */
|
||||
stmdb sp!, {r4, lr}
|
||||
subs r2, r2, #0x14 /* less than 32 bytes (12 from above) */
|
||||
blt .Lmemmove_bl32
|
||||
|
||||
/* blat 32 bytes at a time */
|
||||
/* XXX for really big copies perhaps we should use more registers */
|
||||
.Lmemmove_bloop32:
|
||||
ldmdb r1!, {r3, r4, r12, lr}
|
||||
stmdb r0!, {r3, r4, r12, lr}
|
||||
ldmdb r1!, {r3, r4, r12, lr}
|
||||
stmdb r0!, {r3, r4, r12, lr}
|
||||
subs r2, r2, #0x20
|
||||
bge .Lmemmove_bloop32
|
||||
|
||||
.Lmemmove_bl32:
|
||||
cmn r2, #0x10
|
||||
ldmgedb r1!, {r3, r4, r12, lr} /* blat a remaining 16 bytes */
|
||||
stmgedb r0!, {r3, r4, r12, lr}
|
||||
subge r2, r2, #0x10
|
||||
adds r2, r2, #0x14
|
||||
ldmgedb r1!, {r3, r12, lr} /* blat a remaining 12 bytes */
|
||||
stmgedb r0!, {r3, r12, lr}
|
||||
subge r2, r2, #0x0c
|
||||
ldmia sp!, {r4, lr}
|
||||
|
||||
.Lmemmove_bl12:
|
||||
adds r2, r2, #8
|
||||
blt .Lmemmove_bl4
|
||||
subs r2, r2, #4
|
||||
ldrlt r3, [r1, #-4]!
|
||||
strlt r3, [r0, #-4]!
|
||||
ldmgedb r1!, {r3, r12}
|
||||
stmgedb r0!, {r3, r12}
|
||||
subge r2, r2, #4
|
||||
|
||||
.Lmemmove_bl4:
|
||||
/* less than 4 bytes to go */
|
||||
adds r2, r2, #4
|
||||
RETc(eq)
|
||||
|
||||
/* copy the crud byte at a time */
|
||||
cmp r2, #2
|
||||
ldrb r3, [r1, #-1]!
|
||||
strb r3, [r0, #-1]!
|
||||
ldrgeb r3, [r1, #-1]!
|
||||
strgeb r3, [r0, #-1]!
|
||||
ldrgtb r3, [r1, #-1]!
|
||||
strgtb r3, [r0, #-1]!
|
||||
RET
|
||||
|
||||
/* erg - unaligned destination */
|
||||
.Lmemmove_bdestul:
|
||||
cmp r12, #2
|
||||
|
||||
/* align destination with byte copies */
|
||||
ldrb r3, [r1, #-1]!
|
||||
strb r3, [r0, #-1]!
|
||||
ldrgeb r3, [r1, #-1]!
|
||||
strgeb r3, [r0, #-1]!
|
||||
ldrgtb r3, [r1, #-1]!
|
||||
strgtb r3, [r0, #-1]!
|
||||
subs r2, r2, r12
|
||||
blt .Lmemmove_bl4 /* less than 4 bytes to go */
|
||||
ands r12, r1, #3
|
||||
beq .Lmemmove_bt8 /* we have an aligned source */
|
||||
|
||||
/* erg - unaligned source */
|
||||
/* This is where it gets nasty ... */
|
||||
.Lmemmove_bsrcul:
|
||||
bic r1, r1, #3
|
||||
ldr r3, [r1, #0]
|
||||
cmp r12, #2
|
||||
blt .Lmemmove_bsrcul1
|
||||
beq .Lmemmove_bsrcul2
|
||||
cmp r2, #0x0c
|
||||
blt .Lmemmove_bsrcul3loop4
|
||||
sub r2, r2, #0x0c
|
||||
stmdb sp!, {r4, r5, lr}
|
||||
|
||||
.Lmemmove_bsrcul3loop16:
|
||||
#ifdef __ARMEB__
|
||||
mov lr, r3, lsr #8
|
||||
#else
|
||||
mov lr, r3, lsl #8
|
||||
#endif
|
||||
ldmdb r1!, {r3-r5, r12}
|
||||
#ifdef __ARMEB__
|
||||
orr lr, lr, r12, lsl #24
|
||||
mov r12, r12, lsr #8
|
||||
orr r12, r12, r5, lsl #24
|
||||
mov r5, r5, lsr #8
|
||||
orr r5, r5, r4, lsl #24
|
||||
mov r4, r4, lsr #8
|
||||
orr r4, r4, r3, lsl #24
|
||||
#else
|
||||
orr lr, lr, r12, lsr #24
|
||||
mov r12, r12, lsl #8
|
||||
orr r12, r12, r5, lsr #24
|
||||
mov r5, r5, lsl #8
|
||||
orr r5, r5, r4, lsr #24
|
||||
mov r4, r4, lsl #8
|
||||
orr r4, r4, r3, lsr #24
|
||||
#endif
|
||||
stmdb r0!, {r4, r5, r12, lr}
|
||||
subs r2, r2, #0x10
|
||||
bge .Lmemmove_bsrcul3loop16
|
||||
ldmia sp!, {r4, r5, lr}
|
||||
adds r2, r2, #0x0c
|
||||
blt .Lmemmove_bsrcul3l4
|
||||
|
||||
.Lmemmove_bsrcul3loop4:
|
||||
#ifdef __ARMEB__
|
||||
mov r12, r3, lsr #8
|
||||
#else
|
||||
mov r12, r3, lsl #8
|
||||
#endif
|
||||
ldr r3, [r1, #-4]!
|
||||
#ifdef __ARMEB__
|
||||
orr r12, r12, r3, lsl #24
|
||||
#else
|
||||
orr r12, r12, r3, lsr #24
|
||||
#endif
|
||||
str r12, [r0, #-4]!
|
||||
subs r2, r2, #4
|
||||
bge .Lmemmove_bsrcul3loop4
|
||||
|
||||
.Lmemmove_bsrcul3l4:
|
||||
add r1, r1, #3
|
||||
b .Lmemmove_bl4
|
||||
|
||||
.Lmemmove_bsrcul2:
|
||||
cmp r2, #0x0c
|
||||
blt .Lmemmove_bsrcul2loop4
|
||||
sub r2, r2, #0x0c
|
||||
stmdb sp!, {r4, r5, lr}
|
||||
|
||||
.Lmemmove_bsrcul2loop16:
|
||||
#ifdef __ARMEB__
|
||||
mov lr, r3, lsr #16
|
||||
#else
|
||||
mov lr, r3, lsl #16
|
||||
#endif
|
||||
ldmdb r1!, {r3-r5, r12}
|
||||
#ifdef __ARMEB__
|
||||
orr lr, lr, r12, lsl #16
|
||||
mov r12, r12, lsr #16
|
||||
orr r12, r12, r5, lsl #16
|
||||
mov r5, r5, lsr #16
|
||||
orr r5, r5, r4, lsl #16
|
||||
mov r4, r4, lsr #16
|
||||
orr r4, r4, r3, lsl #16
|
||||
#else
|
||||
orr lr, lr, r12, lsr #16
|
||||
mov r12, r12, lsl #16
|
||||
orr r12, r12, r5, lsr #16
|
||||
mov r5, r5, lsl #16
|
||||
orr r5, r5, r4, lsr #16
|
||||
mov r4, r4, lsl #16
|
||||
orr r4, r4, r3, lsr #16
|
||||
#endif
|
||||
stmdb r0!, {r4, r5, r12, lr}
|
||||
subs r2, r2, #0x10
|
||||
bge .Lmemmove_bsrcul2loop16
|
||||
ldmia sp!, {r4, r5, lr}
|
||||
adds r2, r2, #0x0c
|
||||
blt .Lmemmove_bsrcul2l4
|
||||
|
||||
.Lmemmove_bsrcul2loop4:
|
||||
#ifdef __ARMEB__
|
||||
mov r12, r3, lsr #16
|
||||
#else
|
||||
mov r12, r3, lsl #16
|
||||
#endif
|
||||
ldr r3, [r1, #-4]!
|
||||
#ifdef __ARMEB__
|
||||
orr r12, r12, r3, lsl #16
|
||||
#else
|
||||
orr r12, r12, r3, lsr #16
|
||||
#endif
|
||||
str r12, [r0, #-4]!
|
||||
subs r2, r2, #4
|
||||
bge .Lmemmove_bsrcul2loop4
|
||||
|
||||
.Lmemmove_bsrcul2l4:
|
||||
add r1, r1, #2
|
||||
b .Lmemmove_bl4
|
||||
|
||||
.Lmemmove_bsrcul1:
|
||||
cmp r2, #0x0c
|
||||
blt .Lmemmove_bsrcul1loop4
|
||||
sub r2, r2, #0x0c
|
||||
stmdb sp!, {r4, r5, lr}
|
||||
|
||||
.Lmemmove_bsrcul1loop32:
|
||||
#ifdef __ARMEB__
|
||||
mov lr, r3, lsr #24
|
||||
#else
|
||||
mov lr, r3, lsl #24
|
||||
#endif
|
||||
ldmdb r1!, {r3-r5, r12}
|
||||
#ifdef __ARMEB__
|
||||
orr lr, lr, r12, lsl #8
|
||||
mov r12, r12, lsr #24
|
||||
orr r12, r12, r5, lsl #8
|
||||
mov r5, r5, lsr #24
|
||||
orr r5, r5, r4, lsl #8
|
||||
mov r4, r4, lsr #24
|
||||
orr r4, r4, r3, lsl #8
|
||||
#else
|
||||
orr lr, lr, r12, lsr #8
|
||||
mov r12, r12, lsl #24
|
||||
orr r12, r12, r5, lsr #8
|
||||
mov r5, r5, lsl #24
|
||||
orr r5, r5, r4, lsr #8
|
||||
mov r4, r4, lsl #24
|
||||
orr r4, r4, r3, lsr #8
|
||||
#endif
|
||||
stmdb r0!, {r4, r5, r12, lr}
|
||||
subs r2, r2, #0x10
|
||||
bge .Lmemmove_bsrcul1loop32
|
||||
ldmia sp!, {r4, r5, lr}
|
||||
adds r2, r2, #0x0c
|
||||
blt .Lmemmove_bsrcul1l4
|
||||
|
||||
.Lmemmove_bsrcul1loop4:
|
||||
#ifdef __ARMEB__
|
||||
mov r12, r3, lsr #24
|
||||
#else
|
||||
mov r12, r3, lsl #24
|
||||
#endif
|
||||
ldr r3, [r1, #-4]!
|
||||
#ifdef __ARMEB__
|
||||
orr r12, r12, r3, lsl #8
|
||||
#else
|
||||
orr r12, r12, r3, lsr #8
|
||||
#endif
|
||||
str r12, [r0, #-4]!
|
||||
subs r2, r2, #4
|
||||
bge .Lmemmove_bsrcul1loop4
|
||||
|
||||
.Lmemmove_bsrcul1l4:
|
||||
add r1, r1, #1
|
||||
b .Lmemmove_bl4
|
235
common/lib/libc/arch/arm/string/memset.S
Normal file
235
common/lib/libc/arch/arm/string/memset.S
Normal file
|
@ -0,0 +1,235 @@
|
|||
/* $NetBSD: memset.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 2003 Wasabi Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Written by Steve C. Woodford for Wasabi Systems, Inc.
|
||||
*
|
||||
* 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. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed for the NetBSD Project by
|
||||
* Wasabi Systems, Inc.
|
||||
* 4. The name of Wasabi Systems, Inc. may not be used to endorse
|
||||
* or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC
|
||||
* 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.
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 1995 Mark Brinicombe.
|
||||
* 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Mark Brinicombe.
|
||||
* 4. The name of the company nor the name of the author may be used to
|
||||
* endorse or promote products derived from this software without specific
|
||||
* prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 <machine/asm.h>
|
||||
|
||||
/*
|
||||
* memset: Sets a block of memory to the specified value
|
||||
*
|
||||
* On entry:
|
||||
* r0 - dest address
|
||||
* r1 - byte to write
|
||||
* r2 - number of bytes to write
|
||||
*
|
||||
* On exit:
|
||||
* r0 - dest address
|
||||
*/
|
||||
#ifdef _BZERO
|
||||
/* LINTSTUB: Func: void bzero(void *, size_t) */
|
||||
ENTRY(bzero)
|
||||
mov r3, #0x00
|
||||
#else
|
||||
/* LINTSTUB: Func: void *memset(void *, int, size_t) */
|
||||
ENTRY(memset)
|
||||
and r3, r1, #0xff /* We deal with bytes */
|
||||
mov r1, r2
|
||||
#endif
|
||||
cmp r1, #0x04 /* Do we have less than 4 bytes */
|
||||
mov ip, r0
|
||||
blt .Lmemset_lessthanfour
|
||||
|
||||
/* Ok first we will word align the address */
|
||||
ands r2, ip, #0x03 /* Get the bottom two bits */
|
||||
bne .Lmemset_wordunaligned /* The address is not word aligned */
|
||||
|
||||
/* We are now word aligned */
|
||||
.Lmemset_wordaligned:
|
||||
#ifndef _BZERO
|
||||
orr r3, r3, r3, lsl #8 /* Extend value to 16-bits */
|
||||
#endif
|
||||
#ifdef __XSCALE__
|
||||
tst ip, #0x04 /* Quad-align for Xscale */
|
||||
#else
|
||||
cmp r1, #0x10
|
||||
#endif
|
||||
#ifndef _BZERO
|
||||
orr r3, r3, r3, lsl #16 /* Extend value to 32-bits */
|
||||
#endif
|
||||
#ifdef __XSCALE__
|
||||
subne r1, r1, #0x04 /* Quad-align if necessary */
|
||||
strne r3, [ip], #0x04
|
||||
cmp r1, #0x10
|
||||
#endif
|
||||
blt .Lmemset_loop4 /* If less than 16 then use words */
|
||||
mov r2, r3 /* Duplicate data */
|
||||
cmp r1, #0x80 /* If < 128 then skip the big loop */
|
||||
blt .Lmemset_loop32
|
||||
|
||||
/* Do 128 bytes at a time */
|
||||
.Lmemset_loop128:
|
||||
subs r1, r1, #0x80
|
||||
#ifdef __XSCALE__
|
||||
strged r2, [ip], #0x08
|
||||
strged r2, [ip], #0x08
|
||||
strged r2, [ip], #0x08
|
||||
strged r2, [ip], #0x08
|
||||
strged r2, [ip], #0x08
|
||||
strged r2, [ip], #0x08
|
||||
strged r2, [ip], #0x08
|
||||
strged r2, [ip], #0x08
|
||||
strged r2, [ip], #0x08
|
||||
strged r2, [ip], #0x08
|
||||
strged r2, [ip], #0x08
|
||||
strged r2, [ip], #0x08
|
||||
strged r2, [ip], #0x08
|
||||
strged r2, [ip], #0x08
|
||||
strged r2, [ip], #0x08
|
||||
strged r2, [ip], #0x08
|
||||
#else
|
||||
stmgeia ip!, {r2-r3}
|
||||
stmgeia ip!, {r2-r3}
|
||||
stmgeia ip!, {r2-r3}
|
||||
stmgeia ip!, {r2-r3}
|
||||
stmgeia ip!, {r2-r3}
|
||||
stmgeia ip!, {r2-r3}
|
||||
stmgeia ip!, {r2-r3}
|
||||
stmgeia ip!, {r2-r3}
|
||||
stmgeia ip!, {r2-r3}
|
||||
stmgeia ip!, {r2-r3}
|
||||
stmgeia ip!, {r2-r3}
|
||||
stmgeia ip!, {r2-r3}
|
||||
stmgeia ip!, {r2-r3}
|
||||
stmgeia ip!, {r2-r3}
|
||||
stmgeia ip!, {r2-r3}
|
||||
stmgeia ip!, {r2-r3}
|
||||
#endif
|
||||
bgt .Lmemset_loop128
|
||||
RETc(eq) /* Zero length so just exit */
|
||||
|
||||
add r1, r1, #0x80 /* Adjust for extra sub */
|
||||
|
||||
/* Do 32 bytes at a time */
|
||||
.Lmemset_loop32:
|
||||
subs r1, r1, #0x20
|
||||
#ifdef __XSCALE__
|
||||
strged r2, [ip], #0x08
|
||||
strged r2, [ip], #0x08
|
||||
strged r2, [ip], #0x08
|
||||
strged r2, [ip], #0x08
|
||||
#else
|
||||
stmgeia ip!, {r2-r3}
|
||||
stmgeia ip!, {r2-r3}
|
||||
stmgeia ip!, {r2-r3}
|
||||
stmgeia ip!, {r2-r3}
|
||||
#endif
|
||||
bgt .Lmemset_loop32
|
||||
RETc(eq) /* Zero length so just exit */
|
||||
|
||||
adds r1, r1, #0x10 /* Partially adjust for extra sub */
|
||||
|
||||
/* Deal with 16 bytes or more */
|
||||
#ifdef __XSCALE__
|
||||
strged r2, [ip], #0x08
|
||||
strged r2, [ip], #0x08
|
||||
#else
|
||||
stmgeia ip!, {r2-r3}
|
||||
stmgeia ip!, {r2-r3}
|
||||
#endif
|
||||
RETc(eq) /* Zero length so just exit */
|
||||
|
||||
addlt r1, r1, #0x10 /* Possibly adjust for extra sub */
|
||||
|
||||
/* We have at least 4 bytes so copy as words */
|
||||
.Lmemset_loop4:
|
||||
subs r1, r1, #0x04
|
||||
strge r3, [ip], #0x04
|
||||
bgt .Lmemset_loop4
|
||||
RETc(eq) /* Zero length so just exit */
|
||||
|
||||
#ifdef __XSCALE__
|
||||
/* Compensate for 64-bit alignment check */
|
||||
adds r1, r1, #0x04
|
||||
RETc(eq)
|
||||
cmp r1, #2
|
||||
#else
|
||||
cmp r1, #-2
|
||||
#endif
|
||||
|
||||
strb r3, [ip], #0x01 /* Set 1 byte */
|
||||
strgeb r3, [ip], #0x01 /* Set another byte */
|
||||
strgtb r3, [ip] /* and a third */
|
||||
RET /* Exit */
|
||||
|
||||
.Lmemset_wordunaligned:
|
||||
rsb r2, r2, #0x004
|
||||
strb r3, [ip], #0x01 /* Set 1 byte */
|
||||
cmp r2, #0x02
|
||||
strgeb r3, [ip], #0x01 /* Set another byte */
|
||||
sub r1, r1, r2
|
||||
strgtb r3, [ip], #0x01 /* and a third */
|
||||
cmp r1, #0x04 /* More than 4 bytes left? */
|
||||
bge .Lmemset_wordaligned /* Yup */
|
||||
|
||||
.Lmemset_lessthanfour:
|
||||
cmp r1, #0x00
|
||||
RETc(eq) /* Zero length so exit */
|
||||
strb r3, [ip], #0x01 /* Set 1 byte */
|
||||
cmp r1, #0x02
|
||||
strgeb r3, [ip], #0x01 /* Set another byte */
|
||||
strgtb r3, [ip] /* and a third */
|
||||
RET /* Exit */
|
43
common/lib/libc/arch/arm/string/strcmp.S
Normal file
43
common/lib/libc/arch/arm/string/strcmp.S
Normal file
|
@ -0,0 +1,43 @@
|
|||
/* $NetBSD: strcmp.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2002 ARM Ltd
|
||||
* 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.
|
||||
* 3. The name of the company may not be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ARM LTD ``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 ARM LTD 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 <machine/asm.h>
|
||||
|
||||
RCSID("$NetBSD: strcmp.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
|
||||
|
||||
ENTRY(strcmp)
|
||||
1:
|
||||
ldrb r2, [r0], #1
|
||||
ldrb r3, [r1], #1
|
||||
cmp r2, #1
|
||||
cmpcs r2, r3
|
||||
beq 1b
|
||||
sub r0, r2, r3
|
||||
RET
|
51
common/lib/libc/arch/arm/string/strncmp.S
Normal file
51
common/lib/libc/arch/arm/string/strncmp.S
Normal file
|
@ -0,0 +1,51 @@
|
|||
/* $NetBSD: strncmp.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2002 ARM Ltd
|
||||
* 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.
|
||||
* 3. The name of the company may not be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ARM LTD ``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 ARM LTD 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 <machine/asm.h>
|
||||
|
||||
RCSID("$NetBSD: strncmp.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
|
||||
|
||||
ENTRY(strncmp)
|
||||
/* if ((len - 1) < 0) return 0 */
|
||||
subs r2, r2, #1
|
||||
movmi r0, #0
|
||||
RETc(mi)
|
||||
|
||||
/* ip == last src address to compare */
|
||||
add ip, r0, r2
|
||||
1:
|
||||
ldrb r2, [r0], #1
|
||||
ldrb r3, [r1], #1
|
||||
cmp ip, r0
|
||||
cmpcs r2, #1
|
||||
cmpcs r2, r3
|
||||
beq 1b
|
||||
sub r0, r2, r3
|
||||
RET
|
23
common/lib/libc/arch/hppa/atomic/Makefile.inc
Normal file
23
common/lib/libc/arch/hppa/atomic/Makefile.inc
Normal file
|
@ -0,0 +1,23 @@
|
|||
# $NetBSD: Makefile.inc,v 1.8 2011/01/17 07:29:17 skrll Exp $
|
||||
|
||||
.if defined(LIB)
|
||||
|
||||
. if (${LIB} == "kern" || ${LIB} == "c" || ${LIB} == "pthread" || \
|
||||
${LIB} == "rump")
|
||||
|
||||
SRCS+= atomic_add_32_cas.c atomic_add_32_nv_cas.c atomic_and_32_cas.c \
|
||||
atomic_and_32_nv_cas.c atomic_dec_32_cas.c atomic_dec_32_nv_cas.c \
|
||||
atomic_inc_32_cas.c atomic_inc_32_nv_cas.c atomic_or_32_cas.c \
|
||||
atomic_or_32_nv_cas.c atomic_swap_32_cas.c membar_ops_nop.c
|
||||
|
||||
. endif
|
||||
|
||||
. if (${LIB} == "c" || ${LIB} == "pthread")
|
||||
|
||||
SRCS+= atomic_init_testset.c
|
||||
SRCS+= atomic_cas_up.S
|
||||
CPPFLAGS+= -D__HAVE_ASM_ATOMIC_CAS_UP
|
||||
|
||||
. endif
|
||||
|
||||
.endif
|
46
common/lib/libc/arch/hppa/atomic/atomic_cas_up.S
Normal file
46
common/lib/libc/arch/hppa/atomic/atomic_cas_up.S
Normal file
|
@ -0,0 +1,46 @@
|
|||
/* $NetBSD: atomic_cas_up.S,v 1.2 2011/01/16 12:07:26 skrll Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Nick Hudson
|
||||
*
|
||||
* 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/ras.h>
|
||||
#include <machine/asm.h>
|
||||
|
||||
LEAF_ENTRY_NOPROFILE(_atomic_cas_up)
|
||||
.hidden _C_LABEL(_atomic_cas_up)
|
||||
|
||||
RAS_START_ASM_HIDDEN(_atomic_cas)
|
||||
ldw 0(%arg0), %ret0
|
||||
comb,<>,n %arg1, %ret0, 1f
|
||||
stw %arg2, 0(%arg0)
|
||||
RAS_END_ASM_HIDDEN(_atomic_cas)
|
||||
1:
|
||||
bv,n %r0(%rp)
|
||||
|
||||
EXIT(_atomic_cas_up)
|
67
common/lib/libc/arch/hppa/atomic/membar_ops.S
Normal file
67
common/lib/libc/arch/hppa/atomic/membar_ops.S
Normal file
|
@ -0,0 +1,67 @@
|
|||
/* $NetBSD: membar_ops.S,v 1.1 2011/01/17 07:40:21 skrll Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Jason R. Thorpe, and by Andrew Doran.
|
||||
*
|
||||
* 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 "atomic_op_asm.h"
|
||||
|
||||
RCSID("$NetBSD: membar_ops.S,v 1.1 2011/01/17 07:40:21 skrll Exp $")
|
||||
|
||||
.text
|
||||
|
||||
LEAF_ENTRY(_membar_consumer)
|
||||
sync
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
bv %r0(%rp)
|
||||
nop
|
||||
EXIT(_membar_consumer)
|
||||
|
||||
LEAF_ENTRY(_membar_producer)
|
||||
sync
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
bv %r0(%rp)
|
||||
nop
|
||||
EXIT(_membar_producer)
|
||||
|
||||
ATOMIC_OP_ALIAS(membar_producer,_membar_producer)
|
||||
ATOMIC_OP_ALIAS(membar_consumer,_membar_consumer)
|
||||
ATOMIC_OP_ALIAS(membar_enter,_membar_consumer)
|
||||
STRONG_ALIAS(_membar_enter,_membar_consumer)
|
||||
ATOMIC_OP_ALIAS(membar_exit,_membar_producer)
|
||||
STRONG_ALIAS(_membar_exit,_membar_producer)
|
||||
ATOMIC_OP_ALIAS(membar_sync,_membar_producer)
|
||||
STRONG_ALIAS(_membar_sync,_membar_producer)
|
17
common/lib/libc/arch/i386/atomic/Makefile.inc
Normal file
17
common/lib/libc/arch/i386/atomic/Makefile.inc
Normal file
|
@ -0,0 +1,17 @@
|
|||
# $NetBSD: Makefile.inc,v 1.7 2009/01/04 17:54:29 pooka Exp $
|
||||
|
||||
.if defined(LIB) && (${LIB} == "kern" || ${LIB} == "c" || ${LIB} == "pthread" \
|
||||
|| ${LIB} == "rump")
|
||||
|
||||
SRCS+= atomic_add_64_cas.c atomic_add_64_nv_cas.c atomic_and_64_cas.c \
|
||||
atomic_and_64_nv_cas.c atomic_dec_64_cas.c atomic_dec_64_nv_cas.c \
|
||||
atomic_inc_64_cas.c atomic_inc_64_nv_cas.c atomic_or_64_cas.c \
|
||||
atomic_or_64_nv_cas.c atomic_swap_64_cas.c atomic.S
|
||||
|
||||
.endif
|
||||
|
||||
.if defined(LIB) && (${LIB} == "c" || ${LIB} == "pthread")
|
||||
|
||||
SRCS+= atomic_init_cas.c
|
||||
|
||||
.endif
|
384
common/lib/libc/arch/i386/atomic/atomic.S
Normal file
384
common/lib/libc/arch/i386/atomic/atomic.S
Normal file
|
@ -0,0 +1,384 @@
|
|||
/* $NetBSD: atomic.S,v 1.19 2011/01/12 23:12:10 joerg Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Jason R. Thorpe, and by Andrew Doran.
|
||||
*
|
||||
* 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/param.h>
|
||||
#include <machine/asm.h>
|
||||
|
||||
#ifdef _KERNEL
|
||||
#define ALIAS(f, t) STRONG_ALIAS(f,t)
|
||||
#else
|
||||
#define ALIAS(f, t) WEAK_ALIAS(f,t)
|
||||
#endif
|
||||
|
||||
#ifdef _HARDKERNEL
|
||||
#define LOCK(n) .Lpatch ## n: lock
|
||||
#define ENDLABEL(a) _ALIGN_TEXT; LABEL(a)
|
||||
#else
|
||||
#define LOCK(n) lock
|
||||
#define ENDLABEL(a) /* nothing */
|
||||
#endif
|
||||
|
||||
.text
|
||||
|
||||
ENTRY(_atomic_add_32)
|
||||
movl 4(%esp), %edx
|
||||
movl 8(%esp), %eax
|
||||
LOCK(1)
|
||||
addl %eax, (%edx)
|
||||
ret
|
||||
|
||||
ENTRY(_atomic_add_32_nv)
|
||||
movl 4(%esp), %edx
|
||||
movl 8(%esp), %eax
|
||||
movl %eax, %ecx
|
||||
LOCK(2)
|
||||
xaddl %eax, (%edx)
|
||||
addl %ecx, %eax
|
||||
ret
|
||||
|
||||
ENTRY(_atomic_and_32)
|
||||
movl 4(%esp), %edx
|
||||
movl 8(%esp), %eax
|
||||
LOCK(3)
|
||||
andl %eax, (%edx)
|
||||
ret
|
||||
|
||||
ENTRY(_atomic_and_32_nv)
|
||||
movl 4(%esp), %edx
|
||||
movl (%edx), %eax
|
||||
0:
|
||||
movl %eax, %ecx
|
||||
andl 8(%esp), %ecx
|
||||
LOCK(4)
|
||||
cmpxchgl %ecx, (%edx)
|
||||
jnz 1f
|
||||
movl %ecx, %eax
|
||||
ret
|
||||
1:
|
||||
jmp 0b
|
||||
|
||||
ENTRY(_atomic_dec_32)
|
||||
movl 4(%esp), %edx
|
||||
LOCK(5)
|
||||
decl (%edx)
|
||||
ret
|
||||
|
||||
ENTRY(_atomic_dec_32_nv)
|
||||
movl 4(%esp), %edx
|
||||
movl $-1, %eax
|
||||
LOCK(6)
|
||||
xaddl %eax, (%edx)
|
||||
decl %eax
|
||||
ret
|
||||
|
||||
ENTRY(_atomic_inc_32)
|
||||
movl 4(%esp), %edx
|
||||
LOCK(7)
|
||||
incl (%edx)
|
||||
ret
|
||||
|
||||
ENTRY(_atomic_inc_32_nv)
|
||||
movl 4(%esp), %edx
|
||||
movl $1, %eax
|
||||
LOCK(8)
|
||||
xaddl %eax, (%edx)
|
||||
incl %eax
|
||||
ret
|
||||
|
||||
ENTRY(_atomic_or_32)
|
||||
movl 4(%esp), %edx
|
||||
movl 8(%esp), %eax
|
||||
LOCK(9)
|
||||
orl %eax, (%edx)
|
||||
ret
|
||||
|
||||
ENTRY(_atomic_or_32_nv)
|
||||
movl 4(%esp), %edx
|
||||
movl (%edx), %eax
|
||||
0:
|
||||
movl %eax, %ecx
|
||||
orl 8(%esp), %ecx
|
||||
LOCK(10)
|
||||
cmpxchgl %ecx, (%edx)
|
||||
jnz 1f
|
||||
movl %ecx, %eax
|
||||
ret
|
||||
1:
|
||||
jmp 0b
|
||||
|
||||
ENTRY(_atomic_swap_32)
|
||||
movl 4(%esp), %edx
|
||||
movl 8(%esp), %eax
|
||||
xchgl %eax, (%edx)
|
||||
ret
|
||||
|
||||
ENTRY(_atomic_cas_32)
|
||||
movl 4(%esp), %edx
|
||||
movl 8(%esp), %eax
|
||||
movl 12(%esp), %ecx
|
||||
LOCK(12)
|
||||
cmpxchgl %ecx, (%edx)
|
||||
/* %eax now contains the old value */
|
||||
ret
|
||||
|
||||
ENTRY(_atomic_cas_32_ni)
|
||||
movl 4(%esp), %edx
|
||||
movl 8(%esp), %eax
|
||||
movl 12(%esp), %ecx
|
||||
cmpxchgl %ecx, (%edx)
|
||||
/* %eax now contains the old value */
|
||||
ret
|
||||
|
||||
ENTRY(_membar_consumer)
|
||||
LOCK(13)
|
||||
addl $0, -4(%esp)
|
||||
ret
|
||||
ENDLABEL(membar_consumer_end)
|
||||
|
||||
ENTRY(_membar_producer)
|
||||
/* A store is enough */
|
||||
movl $0, -4(%esp)
|
||||
ret
|
||||
ENDLABEL(membar_producer_end)
|
||||
|
||||
ENTRY(_membar_sync)
|
||||
LOCK(14)
|
||||
addl $0, -4(%esp)
|
||||
ret
|
||||
ENDLABEL(membar_sync_end)
|
||||
|
||||
#ifdef _HARDKERNEL
|
||||
ENTRY(_atomic_cas_64)
|
||||
pushf
|
||||
cli
|
||||
pushl %edi
|
||||
pushl %ebx
|
||||
movl 12(%esp), %edi
|
||||
movl 16(%esp), %eax
|
||||
movl 20(%esp), %edx
|
||||
movl 24(%esp), %ebx
|
||||
movl 28(%esp), %ecx
|
||||
cmpl 0(%edi), %eax
|
||||
jne 2f
|
||||
cmpl 4(%edi), %edx
|
||||
jne 2f
|
||||
movl %ebx, 0(%edi)
|
||||
movl %ecx, 4(%edi)
|
||||
1:
|
||||
popl %ebx
|
||||
popl %edi
|
||||
popf
|
||||
ret
|
||||
2:
|
||||
movl 0(%edi), %eax
|
||||
movl 4(%edi), %edx
|
||||
jmp 1b
|
||||
ENDLABEL(_atomic_cas_64_end)
|
||||
|
||||
ENTRY(_atomic_cas_cx8)
|
||||
pushl %edi
|
||||
pushl %ebx
|
||||
movl 12(%esp), %edi
|
||||
movl 16(%esp), %eax
|
||||
movl 20(%esp), %edx
|
||||
movl 24(%esp), %ebx
|
||||
movl 28(%esp), %ecx
|
||||
LOCK(15)
|
||||
cmpxchg8b (%edi)
|
||||
popl %ebx
|
||||
popl %edi
|
||||
ret
|
||||
#ifdef GPROF
|
||||
.space 16, 0x90
|
||||
#else
|
||||
.space 32, 0x90
|
||||
#endif
|
||||
ENDLABEL(_atomic_cas_cx8_end)
|
||||
|
||||
ENTRY(sse2_lfence)
|
||||
lfence
|
||||
ret
|
||||
ENDLABEL(sse2_lfence_end)
|
||||
|
||||
ENTRY(sse2_mfence)
|
||||
mfence
|
||||
ret
|
||||
ENDLABEL(sse2_mfence_end)
|
||||
|
||||
atomic_lockpatch:
|
||||
.globl atomic_lockpatch
|
||||
.long .Lpatch1, .Lpatch2, .Lpatch3, .Lpatch4, .Lpatch5
|
||||
.long .Lpatch6, .Lpatch7, .Lpatch8, .Lpatch9, .Lpatch10
|
||||
.long .Lpatch12, .Lpatch13, .Lpatch14, .Lpatch15, 0
|
||||
#else
|
||||
ENTRY(_atomic_cas_64)
|
||||
pushl %edi
|
||||
pushl %ebx
|
||||
movl 12(%esp), %edi
|
||||
movl 16(%esp), %eax
|
||||
movl 20(%esp), %edx
|
||||
movl 24(%esp), %ebx
|
||||
movl 28(%esp), %ecx
|
||||
lock
|
||||
cmpxchg8b (%edi)
|
||||
popl %ebx
|
||||
popl %edi
|
||||
ret
|
||||
#endif /* _HARDKERNEL */
|
||||
|
||||
ALIAS(atomic_add_32,_atomic_add_32)
|
||||
ALIAS(atomic_add_int,_atomic_add_32)
|
||||
ALIAS(atomic_add_long,_atomic_add_32)
|
||||
ALIAS(atomic_add_ptr,_atomic_add_32)
|
||||
|
||||
ALIAS(atomic_add_32_nv,_atomic_add_32_nv)
|
||||
ALIAS(atomic_add_int_nv,_atomic_add_32_nv)
|
||||
ALIAS(atomic_add_long_nv,_atomic_add_32_nv)
|
||||
ALIAS(atomic_add_ptr_nv,_atomic_add_32_nv)
|
||||
|
||||
ALIAS(atomic_and_32,_atomic_and_32)
|
||||
ALIAS(atomic_and_uint,_atomic_and_32)
|
||||
ALIAS(atomic_and_ulong,_atomic_and_32)
|
||||
ALIAS(atomic_and_ptr,_atomic_and_32)
|
||||
|
||||
ALIAS(atomic_and_32_nv,_atomic_and_32_nv)
|
||||
ALIAS(atomic_and_uint_nv,_atomic_and_32_nv)
|
||||
ALIAS(atomic_and_ulong_nv,_atomic_and_32_nv)
|
||||
ALIAS(atomic_and_ptr_nv,_atomic_and_32_nv)
|
||||
|
||||
ALIAS(atomic_dec_32,_atomic_dec_32)
|
||||
ALIAS(atomic_dec_uint,_atomic_dec_32)
|
||||
ALIAS(atomic_dec_ulong,_atomic_dec_32)
|
||||
ALIAS(atomic_dec_ptr,_atomic_dec_32)
|
||||
|
||||
ALIAS(atomic_dec_32_nv,_atomic_dec_32_nv)
|
||||
ALIAS(atomic_dec_uint_nv,_atomic_dec_32_nv)
|
||||
ALIAS(atomic_dec_ulong_nv,_atomic_dec_32_nv)
|
||||
ALIAS(atomic_dec_ptr_nv,_atomic_dec_32_nv)
|
||||
|
||||
ALIAS(atomic_inc_32,_atomic_inc_32)
|
||||
ALIAS(atomic_inc_uint,_atomic_inc_32)
|
||||
ALIAS(atomic_inc_ulong,_atomic_inc_32)
|
||||
ALIAS(atomic_inc_ptr,_atomic_inc_32)
|
||||
|
||||
ALIAS(atomic_inc_32_nv,_atomic_inc_32_nv)
|
||||
ALIAS(atomic_inc_uint_nv,_atomic_inc_32_nv)
|
||||
ALIAS(atomic_inc_ulong_nv,_atomic_inc_32_nv)
|
||||
ALIAS(atomic_inc_ptr_nv,_atomic_inc_32_nv)
|
||||
|
||||
ALIAS(atomic_or_32,_atomic_or_32)
|
||||
ALIAS(atomic_or_uint,_atomic_or_32)
|
||||
ALIAS(atomic_or_ulong,_atomic_or_32)
|
||||
ALIAS(atomic_or_ptr,_atomic_or_32)
|
||||
|
||||
ALIAS(atomic_or_32_nv,_atomic_or_32_nv)
|
||||
ALIAS(atomic_or_uint_nv,_atomic_or_32_nv)
|
||||
ALIAS(atomic_or_ulong_nv,_atomic_or_32_nv)
|
||||
ALIAS(atomic_or_ptr_nv,_atomic_or_32_nv)
|
||||
|
||||
ALIAS(atomic_swap_32,_atomic_swap_32)
|
||||
ALIAS(atomic_swap_uint,_atomic_swap_32)
|
||||
ALIAS(atomic_swap_ulong,_atomic_swap_32)
|
||||
ALIAS(atomic_swap_ptr,_atomic_swap_32)
|
||||
|
||||
ALIAS(atomic_cas_32,_atomic_cas_32)
|
||||
ALIAS(atomic_cas_uint,_atomic_cas_32)
|
||||
ALIAS(atomic_cas_ulong,_atomic_cas_32)
|
||||
ALIAS(atomic_cas_ptr,_atomic_cas_32)
|
||||
|
||||
ALIAS(atomic_cas_32_ni,_atomic_cas_32_ni)
|
||||
ALIAS(atomic_cas_uint_ni,_atomic_cas_32_ni)
|
||||
ALIAS(atomic_cas_ulong_ni,_atomic_cas_32_ni)
|
||||
ALIAS(atomic_cas_ptr_ni,_atomic_cas_32_ni)
|
||||
|
||||
ALIAS(atomic_cas_64,_atomic_cas_64)
|
||||
ALIAS(atomic_cas_64_ni,_atomic_cas_64)
|
||||
|
||||
ALIAS(membar_consumer,_membar_consumer)
|
||||
ALIAS(membar_producer,_membar_producer)
|
||||
ALIAS(membar_enter,_membar_consumer)
|
||||
ALIAS(membar_exit,_membar_producer)
|
||||
ALIAS(membar_sync,_membar_sync)
|
||||
|
||||
STRONG_ALIAS(_atomic_add_int,_atomic_add_32)
|
||||
STRONG_ALIAS(_atomic_add_long,_atomic_add_32)
|
||||
STRONG_ALIAS(_atomic_add_ptr,_atomic_add_32)
|
||||
|
||||
STRONG_ALIAS(_atomic_add_int_nv,_atomic_add_32_nv)
|
||||
STRONG_ALIAS(_atomic_add_long_nv,_atomic_add_32_nv)
|
||||
STRONG_ALIAS(_atomic_add_ptr_nv,_atomic_add_32_nv)
|
||||
|
||||
STRONG_ALIAS(_atomic_and_uint,_atomic_and_32)
|
||||
STRONG_ALIAS(_atomic_and_ulong,_atomic_and_32)
|
||||
STRONG_ALIAS(_atomic_and_ptr,_atomic_and_32)
|
||||
|
||||
STRONG_ALIAS(_atomic_and_uint_nv,_atomic_and_32_nv)
|
||||
STRONG_ALIAS(_atomic_and_ulong_nv,_atomic_and_32_nv)
|
||||
STRONG_ALIAS(_atomic_and_ptr_nv,_atomic_and_32_nv)
|
||||
|
||||
STRONG_ALIAS(_atomic_dec_uint,_atomic_dec_32)
|
||||
STRONG_ALIAS(_atomic_dec_ulong,_atomic_dec_32)
|
||||
STRONG_ALIAS(_atomic_dec_ptr,_atomic_dec_32)
|
||||
|
||||
STRONG_ALIAS(_atomic_dec_uint_nv,_atomic_dec_32_nv)
|
||||
STRONG_ALIAS(_atomic_dec_ulong_nv,_atomic_dec_32_nv)
|
||||
STRONG_ALIAS(_atomic_dec_ptr_nv,_atomic_dec_32_nv)
|
||||
|
||||
STRONG_ALIAS(_atomic_inc_uint,_atomic_inc_32)
|
||||
STRONG_ALIAS(_atomic_inc_ulong,_atomic_inc_32)
|
||||
STRONG_ALIAS(_atomic_inc_ptr,_atomic_inc_32)
|
||||
|
||||
STRONG_ALIAS(_atomic_inc_uint_nv,_atomic_inc_32_nv)
|
||||
STRONG_ALIAS(_atomic_inc_ulong_nv,_atomic_inc_32_nv)
|
||||
STRONG_ALIAS(_atomic_inc_ptr_nv,_atomic_inc_32_nv)
|
||||
|
||||
STRONG_ALIAS(_atomic_or_uint,_atomic_or_32)
|
||||
STRONG_ALIAS(_atomic_or_ulong,_atomic_or_32)
|
||||
STRONG_ALIAS(_atomic_or_ptr,_atomic_or_32)
|
||||
|
||||
STRONG_ALIAS(_atomic_or_uint_nv,_atomic_or_32_nv)
|
||||
STRONG_ALIAS(_atomic_or_ulong_nv,_atomic_or_32_nv)
|
||||
STRONG_ALIAS(_atomic_or_ptr_nv,_atomic_or_32_nv)
|
||||
|
||||
STRONG_ALIAS(_atomic_swap_uint,_atomic_swap_32)
|
||||
STRONG_ALIAS(_atomic_swap_ulong,_atomic_swap_32)
|
||||
STRONG_ALIAS(_atomic_swap_ptr,_atomic_swap_32)
|
||||
|
||||
STRONG_ALIAS(_atomic_cas_uint,_atomic_cas_32)
|
||||
STRONG_ALIAS(_atomic_cas_ulong,_atomic_cas_32)
|
||||
STRONG_ALIAS(_atomic_cas_ptr,_atomic_cas_32)
|
||||
|
||||
STRONG_ALIAS(_atomic_cas_uint_ni,_atomic_cas_32_ni)
|
||||
STRONG_ALIAS(_atomic_cas_ulong_ni,_atomic_cas_32_ni)
|
||||
STRONG_ALIAS(_atomic_cas_ptr_ni,_atomic_cas_32_ni)
|
||||
|
||||
STRONG_ALIAS(_membar_enter,_membar_consumer)
|
||||
STRONG_ALIAS(_membar_exit,_membar_producer)
|
52
common/lib/libc/arch/i386/gen/byte_swap_2.S
Normal file
52
common/lib/libc/arch/i386/gen/byte_swap_2.S
Normal file
|
@ -0,0 +1,52 @@
|
|||
/* $NetBSD: byte_swap_2.S,v 1.3 2007/11/28 17:03:35 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* William Jolitz.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* from: @(#)htons.s 5.2 (Berkeley) 12/17/90
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
#if defined(LIBC_SCCS)
|
||||
RCSID("$NetBSD: byte_swap_2.S,v 1.3 2007/11/28 17:03:35 ad Exp $")
|
||||
#endif
|
||||
|
||||
#if defined(_KERNEL) || defined(_STANDALONE)
|
||||
_ENTRY(_C_LABEL(bswap16))
|
||||
#else /* defined(_KERNEL) || defined(_STANDALONE) */
|
||||
_ENTRY(_C_LABEL(__bswap16))
|
||||
#endif /* defined(_KERNEL) || defined(_STANDALONE) */
|
||||
_ENTRY(_C_LABEL(ntohs))
|
||||
_ENTRY(_C_LABEL(htons))
|
||||
_PROF_PROLOGUE
|
||||
movzwl 4(%esp),%eax
|
||||
xchgb %al, %ah
|
||||
ret
|
52
common/lib/libc/arch/i386/gen/byte_swap_4.S
Normal file
52
common/lib/libc/arch/i386/gen/byte_swap_4.S
Normal file
|
@ -0,0 +1,52 @@
|
|||
/* $NetBSD: byte_swap_4.S,v 1.3 2007/11/28 17:03:35 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* William Jolitz.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* from: @(#)htonl.s 5.3 (Berkeley) 12/17/90
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
#if defined(LIBC_SCCS)
|
||||
RCSID("$NetBSD: byte_swap_4.S,v 1.3 2007/11/28 17:03:35 ad Exp $")
|
||||
#endif
|
||||
|
||||
#if defined(_KERNEL) || defined(_STANDALONE)
|
||||
_ENTRY(_C_LABEL(bswap32))
|
||||
#else /* defined(_KERNEL) || defined(_STANDALONE) */
|
||||
_ENTRY(_C_LABEL(__bswap32))
|
||||
#endif /* defined(_KERNEL) || defined(_STANDALONE) */
|
||||
_ENTRY(_C_LABEL(ntohl))
|
||||
_ENTRY(_C_LABEL(htonl))
|
||||
_PROF_PROLOGUE
|
||||
movl 4(%esp),%eax
|
||||
bswap %eax
|
||||
ret
|
20
common/lib/libc/arch/i386/string/ffs.S
Normal file
20
common/lib/libc/arch/i386/string/ffs.S
Normal file
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#if defined(LIBC_SCCS)
|
||||
RCSID("$NetBSD: ffs.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
|
||||
#endif
|
||||
|
||||
ENTRY(ffs)
|
||||
bsfl 4(%esp),%eax
|
||||
jz L1 /* ZF is set if all bits are 0 */
|
||||
incl %eax /* bits numbered from 1, not 0 */
|
||||
ret
|
||||
|
||||
_ALIGN_TEXT
|
||||
L1: xorl %eax,%eax /* clear result */
|
||||
ret
|
109
common/lib/libc/arch/i386/string/memchr.S
Normal file
109
common/lib/libc/arch/i386/string/memchr.S
Normal file
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@acorntoolworks.com>
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#if defined(LIBC_SCCS)
|
||||
RCSID("$NetBSD: memchr.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
|
||||
#endif
|
||||
|
||||
ENTRY(memchr)
|
||||
pushl %esi
|
||||
movl 8(%esp),%eax
|
||||
movzbl 12(%esp),%ecx
|
||||
movl 16(%esp),%esi
|
||||
|
||||
/*
|
||||
* Align to word boundary.
|
||||
* Consider unrolling loop?
|
||||
*/
|
||||
testl %esi,%esi /* nbytes == 0? */
|
||||
je .Lzero
|
||||
.Lalign:
|
||||
testb $3,%al
|
||||
je .Lword_aligned
|
||||
cmpb (%eax),%cl
|
||||
je .Ldone
|
||||
incl %eax
|
||||
decl %esi
|
||||
jnz .Lalign
|
||||
jmp .Lzero
|
||||
|
||||
.Lword_aligned:
|
||||
/* copy char to all bytes in word */
|
||||
movb %cl,%ch
|
||||
movl %ecx,%edx
|
||||
sall $16,%ecx
|
||||
orl %edx,%ecx
|
||||
|
||||
_ALIGN_TEXT
|
||||
.Lloop:
|
||||
cmpl $3,%esi /* nbytes > 4 */
|
||||
jbe .Lbyte
|
||||
movl (%eax),%edx
|
||||
addl $4,%eax
|
||||
xorl %ecx,%edx
|
||||
subl $4,%esi
|
||||
subl $0x01010101,%edx
|
||||
testl $0x80808080,%edx
|
||||
je .Lloop
|
||||
|
||||
/*
|
||||
* In rare cases, the above loop may exit prematurely. We must
|
||||
* return to the loop if none of the bytes in the word are
|
||||
* equal to ch.
|
||||
*/
|
||||
|
||||
/*
|
||||
* High load-use latency on the Athlon leads to significant
|
||||
* stalls, so we preload the next char as soon as possible
|
||||
* instead of using cmp mem8, reg8.
|
||||
*
|
||||
* Alignment here avoids a stall on the Athlon, even though
|
||||
* it's not a branch target.
|
||||
*/
|
||||
_ALIGN_TEXT
|
||||
cmpb -4(%eax),%cl /* 1st byte == ch? */
|
||||
movb -3(%eax),%dl
|
||||
jne 1f
|
||||
subl $4,%eax
|
||||
jmp .Ldone
|
||||
|
||||
_ALIGN_TEXT
|
||||
1: cmpb %dl,%cl /* 2nd byte == ch? */
|
||||
movb -2(%eax),%dl
|
||||
jne 1f
|
||||
subl $3,%eax
|
||||
jmp .Ldone
|
||||
|
||||
_ALIGN_TEXT
|
||||
1: cmpb %dl,%cl /* 3rd byte == ch? */
|
||||
movb -1(%eax),%dl
|
||||
jne 1f
|
||||
subl $2,%eax
|
||||
jmp .Ldone
|
||||
|
||||
_ALIGN_TEXT
|
||||
1: cmpb %dl,%cl /* 4th byte == ch? */
|
||||
jne .Lloop
|
||||
decl %eax
|
||||
jmp .Ldone
|
||||
|
||||
.Lbyte:
|
||||
testl %esi,%esi
|
||||
je .Lzero
|
||||
.Lbyte_loop:
|
||||
cmpb (%eax),%cl
|
||||
je .Ldone
|
||||
incl %eax
|
||||
decl %esi
|
||||
jnz .Lbyte_loop
|
||||
|
||||
.Lzero:
|
||||
xorl %eax,%eax
|
||||
|
||||
.Ldone:
|
||||
popl %esi
|
||||
ret
|
47
common/lib/libc/arch/i386/string/memcmp.S
Normal file
47
common/lib/libc/arch/i386/string/memcmp.S
Normal file
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#if defined(LIBC_SCCS)
|
||||
RCSID("$NetBSD: memcmp.S,v 1.2 2007/11/12 18:41:59 ad Exp $")
|
||||
#endif
|
||||
|
||||
ENTRY(memcmp)
|
||||
pushl %edi
|
||||
pushl %esi
|
||||
movl 12(%esp),%edi
|
||||
movl 16(%esp),%esi
|
||||
|
||||
movl 20(%esp),%ecx /* compare by words */
|
||||
shrl $2,%ecx
|
||||
repe
|
||||
cmpsl
|
||||
jne L5 /* do we match so far? */
|
||||
|
||||
movl 20(%esp),%ecx /* compare remainder by bytes */
|
||||
andl $3,%ecx
|
||||
repe
|
||||
cmpsb
|
||||
jne L6 /* do we match? */
|
||||
|
||||
xorl %eax,%eax /* we match, return zero */
|
||||
popl %esi
|
||||
popl %edi
|
||||
ret
|
||||
|
||||
L5: movl $4,%ecx /* We know that one of the next */
|
||||
subl %ecx,%edi /* four pairs of bytes do not */
|
||||
subl %ecx,%esi /* match. */
|
||||
repe
|
||||
cmpsb
|
||||
L6: xorl %eax,%eax /* Perform unsigned comparison */
|
||||
movb -1(%edi),%al
|
||||
xorl %edx,%edx
|
||||
movb -1(%esi),%dl
|
||||
subl %edx,%eax
|
||||
popl %esi
|
||||
popl %edi
|
||||
ret
|
133
common/lib/libc/arch/i386/string/memcpy.S
Normal file
133
common/lib/libc/arch/i386/string/memcpy.S
Normal file
|
@ -0,0 +1,133 @@
|
|||
/* $NetBSD: memcpy.S,v 1.3 2007/11/12 18:41:59 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from locore.s.
|
||||
* Optimised by David Laight 2003
|
||||
*
|
||||
* 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 <machine/asm.h>
|
||||
|
||||
#if defined(LIBC_SCCS)
|
||||
RCSID("$NetBSD: memcpy.S,v 1.3 2007/11/12 18:41:59 ad Exp $")
|
||||
#endif
|
||||
|
||||
/*
|
||||
* (ov)bcopy (src,dst,cnt)
|
||||
* ws@tools.de (Wolfgang Solfrank, TooLs GmbH) +49-228-985800
|
||||
*/
|
||||
|
||||
#ifdef BCOPY
|
||||
ENTRY(bcopy)
|
||||
#else
|
||||
#ifdef MEMMOVE
|
||||
ENTRY(memmove)
|
||||
#else
|
||||
#define MEMCPY
|
||||
#define NO_OVERLAP
|
||||
ENTRY(memcpy)
|
||||
#endif
|
||||
#endif
|
||||
push %esi
|
||||
mov %edi,%edx
|
||||
#if defined(MEMCPY) || defined(MEMMOVE)
|
||||
movl 8(%esp),%edi
|
||||
movl 12(%esp),%esi
|
||||
#else
|
||||
movl 8(%esp),%esi
|
||||
movl 12(%esp),%edi
|
||||
#endif
|
||||
movl 16(%esp),%ecx
|
||||
#if defined(NO_OVERLAP)
|
||||
movl %ecx,%eax
|
||||
#else
|
||||
movl %edi,%eax
|
||||
subl %esi,%eax
|
||||
cmpl %ecx,%eax /* overlapping? */
|
||||
movl %ecx,%eax
|
||||
jb .Lbackwards
|
||||
#endif
|
||||
/* nope, copy forwards. */
|
||||
shrl $2,%ecx /* copy by words */
|
||||
rep
|
||||
movsl
|
||||
and $3,%eax /* any bytes left? */
|
||||
jnz .Ltrailing
|
||||
.Ldone:
|
||||
#if defined(MEMCPY) || defined(MEMMOVE)
|
||||
movl 8(%esp),%eax
|
||||
#endif
|
||||
mov %edx,%edi
|
||||
pop %esi
|
||||
ret
|
||||
|
||||
.Ltrailing:
|
||||
cmp $2,%eax
|
||||
jb 1f
|
||||
movw (%esi),%ax
|
||||
movw %ax,(%edi)
|
||||
je .Ldone
|
||||
movb 2(%esi),%al
|
||||
movb %al,2(%edi)
|
||||
jmp .Ldone
|
||||
1: movb (%esi),%al
|
||||
movb %al,(%edi)
|
||||
jmp .Ldone
|
||||
|
||||
#if !defined(NO_OVERLAP)
|
||||
.Lbackwards:
|
||||
addl %ecx,%edi /* copy backwards. */
|
||||
addl %ecx,%esi
|
||||
and $3,%eax /* any fractional bytes? */
|
||||
jnz .Lback_align
|
||||
.Lback_aligned:
|
||||
shrl $2,%ecx
|
||||
subl $4,%esi
|
||||
subl $4,%edi
|
||||
std
|
||||
rep
|
||||
movsl
|
||||
cld
|
||||
jmp .Ldone
|
||||
|
||||
.Lback_align:
|
||||
sub %eax,%esi
|
||||
sub %eax,%edi
|
||||
cmp $2,%eax
|
||||
jb 1f
|
||||
je 2f
|
||||
movb 2(%esi),%al
|
||||
movb %al,2(%edi)
|
||||
2: movw (%esi),%ax
|
||||
movw %ax,(%edi)
|
||||
jmp .Lback_aligned
|
||||
1: movb (%esi),%al
|
||||
movb %al,(%edi)
|
||||
jmp .Lback_aligned
|
||||
#endif
|
4
common/lib/libc/arch/i386/string/memmove.S
Normal file
4
common/lib/libc/arch/i386/string/memmove.S
Normal file
|
@ -0,0 +1,4 @@
|
|||
/* $NetBSD: memmove.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
|
||||
|
||||
#define MEMMOVE
|
||||
#include "memcpy.S"
|
106
common/lib/libc/arch/i386/string/memset.S
Normal file
106
common/lib/libc/arch/i386/string/memset.S
Normal file
|
@ -0,0 +1,106 @@
|
|||
/* $NetBSD: memset.S,v 1.4 2008/04/29 06:53:01 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by David Laight.
|
||||
*
|
||||
* 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 <machine/asm.h>
|
||||
|
||||
#if defined(LIBC_SCCS)
|
||||
RCSID("$NetBSD: memset.S,v 1.4 2008/04/29 06:53:01 martin Exp $")
|
||||
#endif
|
||||
|
||||
#ifdef BZERO
|
||||
ENTRY(bzero)
|
||||
#else
|
||||
ENTRY(memset)
|
||||
#endif
|
||||
#ifdef BZERO
|
||||
movl 8(%esp),%ecx
|
||||
xor %eax,%eax
|
||||
#else
|
||||
movl 12(%esp),%ecx
|
||||
movzbl 8(%esp),%eax /* unsigned char, zero extend */
|
||||
#endif
|
||||
cmpl $0x0f,%ecx /* avoid mispredicted branch... */
|
||||
|
||||
pushl %edi
|
||||
movl 8(%esp),%edi
|
||||
|
||||
/*
|
||||
* if the string is too short, it's really not worth the overhead
|
||||
* of aligning to word boundries, etc. So we jump to a plain
|
||||
* unaligned set.
|
||||
*
|
||||
* NB aligning the transfer is actually pointless on my athlon 700,
|
||||
* It does make a difference to a PII though.
|
||||
*
|
||||
* The PII, PIII and PIV all seem to have a massive performance
|
||||
* drop when the initial target address is an odd multiple of 4.
|
||||
*/
|
||||
jbe .Lby_bytes
|
||||
|
||||
#ifndef BZERO
|
||||
movb %al,%ah /* copy char to all bytes in word */
|
||||
movl %eax,%edx
|
||||
sall $16,%eax
|
||||
orl %edx,%eax
|
||||
#endif
|
||||
|
||||
movl %edi,%edx /* detect misalignment */
|
||||
neg %edx
|
||||
andl $7,%edx
|
||||
jnz .Lalign
|
||||
.Laligned:
|
||||
movl %eax,-4(%edi,%ecx) /* zap last 4 bytes */
|
||||
shrl $2,%ecx /* zero by words */
|
||||
rep
|
||||
stosl
|
||||
.Ldone:
|
||||
#ifndef BZERO
|
||||
movl 8(%esp),%eax /* return address of buffer */
|
||||
#endif
|
||||
pop %edi
|
||||
ret
|
||||
|
||||
.Lalign:
|
||||
movl %eax,(%edi) /* zap first 8 bytes */
|
||||
movl %eax,4(%edi)
|
||||
subl %edx,%ecx /* remove from main count */
|
||||
add %edx,%edi
|
||||
jmp .Laligned
|
||||
|
||||
.Lby_bytes:
|
||||
rep
|
||||
stosb
|
||||
|
||||
#ifndef BZERO
|
||||
movl 8(%esp),%eax /* return address of buffer */
|
||||
#endif
|
||||
popl %edi
|
||||
ret
|
127
common/lib/libc/arch/i386/string/strcat.S
Normal file
127
common/lib/libc/arch/i386/string/strcat.S
Normal file
|
@ -0,0 +1,127 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@acorntoolworks.com>
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#if defined(LIBC_SCCS)
|
||||
RCSID("$NetBSD: strcat.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
|
||||
#endif
|
||||
|
||||
ENTRY(strcat)
|
||||
pushl %ebx
|
||||
movl 8(%esp),%ecx
|
||||
movl 12(%esp),%eax
|
||||
|
||||
/*
|
||||
* Align destination to word boundary.
|
||||
* Consider unrolling loop?
|
||||
*/
|
||||
.Lscan:
|
||||
.Lscan_align:
|
||||
testb $3,%cl
|
||||
je .Lscan_aligned
|
||||
cmpb $0,(%ecx)
|
||||
je .Lcopy
|
||||
incl %ecx
|
||||
jmp .Lscan_align
|
||||
|
||||
_ALIGN_TEXT
|
||||
.Lscan_aligned:
|
||||
.Lscan_loop:
|
||||
movl (%ecx),%ebx
|
||||
addl $4,%ecx
|
||||
leal -0x01010101(%ebx),%edx
|
||||
testl $0x80808080,%edx
|
||||
je .Lscan_loop
|
||||
|
||||
/*
|
||||
* In rare cases, the above loop may exit prematurely. We must
|
||||
* return to the loop if none of the bytes in the word equal 0.
|
||||
*/
|
||||
|
||||
/*
|
||||
* The optimal code for determining whether each byte is zero
|
||||
* differs by processor. This space-optimized code should be
|
||||
* acceptable on all, especially since we don't expect it to
|
||||
* be run frequently,
|
||||
*/
|
||||
|
||||
testb %bl,%bl /* 1st byte == 0? */
|
||||
jne 1f
|
||||
subl $4,%ecx
|
||||
jmp .Lcopy
|
||||
|
||||
1: testb %bh,%bh /* 2nd byte == 0? */
|
||||
jne 1f
|
||||
subl $3,%ecx
|
||||
jmp .Lcopy
|
||||
|
||||
1: shrl $16,%ebx
|
||||
testb %bl,%bl /* 3rd byte == 0? */
|
||||
jne 1f
|
||||
subl $2,%ecx
|
||||
jmp .Lcopy
|
||||
|
||||
1: testb %bh,%bh /* 4th byte == 0? */
|
||||
jne .Lscan_loop
|
||||
subl $1,%ecx
|
||||
|
||||
/*
|
||||
* Align source to a word boundary.
|
||||
* Consider unrolling loop?
|
||||
*/
|
||||
.Lcopy:
|
||||
.Lcopy_align:
|
||||
testl $3,%eax
|
||||
je .Lcopy_aligned
|
||||
movb (%eax),%bl
|
||||
incl %eax
|
||||
movb %bl,(%ecx)
|
||||
incl %ecx
|
||||
testb %bl,%bl
|
||||
jne .Lcopy_align
|
||||
jmp .Ldone
|
||||
|
||||
_ALIGN_TEXT
|
||||
.Lcopy_loop:
|
||||
movl %ebx,(%ecx)
|
||||
addl $4,%ecx
|
||||
.Lcopy_aligned:
|
||||
movl (%eax),%ebx
|
||||
addl $4,%eax
|
||||
leal -0x01010101(%ebx),%edx
|
||||
testl $0x80808080,%edx
|
||||
je .Lcopy_loop
|
||||
|
||||
/*
|
||||
* In rare cases, the above loop may exit prematurely. We must
|
||||
* return to the loop if none of the bytes in the word equal 0.
|
||||
*/
|
||||
|
||||
movb %bl,(%ecx)
|
||||
incl %ecx
|
||||
testb %bl,%bl
|
||||
je .Ldone
|
||||
|
||||
movb %bh,(%ecx)
|
||||
incl %ecx
|
||||
testb %bh,%bh
|
||||
je .Ldone
|
||||
|
||||
shrl $16,%ebx
|
||||
movb %bl,(%ecx)
|
||||
incl %ecx
|
||||
testb %bl,%bl
|
||||
je .Ldone
|
||||
|
||||
movb %bh,(%ecx)
|
||||
incl %ecx
|
||||
testb %bh,%bh
|
||||
jne .Lcopy_aligned
|
||||
|
||||
.Ldone:
|
||||
movl 8(%esp),%eax
|
||||
popl %ebx
|
||||
ret
|
103
common/lib/libc/arch/i386/string/strchr.S
Normal file
103
common/lib/libc/arch/i386/string/strchr.S
Normal file
|
@ -0,0 +1,103 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@acorntoolworks.com>
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#if defined(LIBC_SCCS)
|
||||
RCSID("$NetBSD: strchr.S,v 1.2 2009/07/17 19:37:57 dsl Exp $")
|
||||
#endif
|
||||
|
||||
ENTRY(strchr)
|
||||
pushl %esi
|
||||
pushl %ebx
|
||||
movl 12(%esp),%eax
|
||||
movzbl 16(%esp),%ecx
|
||||
|
||||
/*
|
||||
* Align to word boundary.
|
||||
* Consider unrolling loop?
|
||||
*/
|
||||
.Lalign:
|
||||
testb $3,%al
|
||||
je .Lword_aligned
|
||||
movb (%eax),%bl
|
||||
cmpb %cl,%bl
|
||||
je .Ldone
|
||||
testb %bl,%bl
|
||||
je .Lzero
|
||||
incl %eax
|
||||
jmp .Lalign
|
||||
|
||||
.Lword_aligned:
|
||||
/* copy char to all bytes in word */
|
||||
movb %cl,%ch
|
||||
movl %ecx,%edx
|
||||
sall $16,%ecx
|
||||
orl %edx,%ecx
|
||||
|
||||
/* Check whether any byte in the word is equal to ch or 0. */
|
||||
_ALIGN_TEXT
|
||||
.Lloop:
|
||||
movl (%eax),%ebx
|
||||
addl $4,%eax
|
||||
movl %ebx,%esi
|
||||
leal -0x01010101(%ebx),%edx
|
||||
xorl %ecx,%esi
|
||||
subl $0x01010101,%esi
|
||||
orl %esi,%edx
|
||||
testl $0x80808080,%edx
|
||||
je .Lloop
|
||||
|
||||
/*
|
||||
* In rare cases, the above loop may exit prematurely. We must
|
||||
* return to the loop if none of the bytes in the word match
|
||||
* ch or are equal to 0.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Alignment here avoids a stall on the Athlon, even though
|
||||
* it's not a branch target.
|
||||
*/
|
||||
|
||||
_ALIGN_TEXT
|
||||
cmpb %cl,%bl /* 1st byte == ch? */
|
||||
jne 1f
|
||||
subl $4,%eax
|
||||
jmp .Ldone
|
||||
1: testb %bl,%bl /* 1st byte == 0? */
|
||||
je .Lzero
|
||||
|
||||
cmpb %cl,%bh /* 2nd byte == ch? */
|
||||
jne 1f
|
||||
subl $3,%eax
|
||||
jmp .Ldone
|
||||
1: testb %bh,%bh /* 2nd byte == 0? */
|
||||
je .Lzero
|
||||
|
||||
shrl $16,%ebx
|
||||
cmpb %cl,%bl /* 3rd byte == ch? */
|
||||
jne 1f
|
||||
subl $2,%eax
|
||||
jmp .Ldone
|
||||
1: testb %bl,%bl /* 3rd byte == 0? */
|
||||
je .Lzero
|
||||
|
||||
cmpb %cl,%bh /* 4th byte == ch? */
|
||||
jne 1f
|
||||
decl %eax
|
||||
jmp .Ldone
|
||||
1: testb %bh,%bh /* 4th byte == 0? */
|
||||
jne .Lloop
|
||||
|
||||
.Lzero:
|
||||
/* If a ch wasn't found, return 0. */
|
||||
xorl %eax,%eax
|
||||
|
||||
.Ldone:
|
||||
popl %ebx
|
||||
popl %esi
|
||||
ret
|
||||
|
||||
STRONG_ALIAS(index,strchr)
|
77
common/lib/libc/arch/i386/string/strcmp.S
Normal file
77
common/lib/libc/arch/i386/string/strcmp.S
Normal file
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@acorntoolworks.com>
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#if defined(LIBC_SCCS)
|
||||
RCSID("$NetBSD: strcmp.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
|
||||
#endif
|
||||
|
||||
ENTRY(strcmp)
|
||||
pushl %esi
|
||||
pushl %ebx
|
||||
movl 12(%esp),%ebx
|
||||
movl 16(%esp),%esi
|
||||
|
||||
/*
|
||||
* Align s1 to word boundary.
|
||||
* Consider unrolling loop?
|
||||
*/
|
||||
.Ls1align:
|
||||
testb $3,%bl
|
||||
je .Ls1aligned
|
||||
movb (%ebx),%al
|
||||
incl %ebx
|
||||
movb (%esi),%dl
|
||||
incl %esi
|
||||
testb %al,%al
|
||||
je .Ldone
|
||||
cmpb %al,%dl
|
||||
je .Ls1align
|
||||
jmp .Ldone
|
||||
|
||||
/*
|
||||
* Check whether s2 is aligned to a word boundary. If it is, we
|
||||
* can compare by words. Otherwise we have to compare by bytes.
|
||||
*/
|
||||
.Ls1aligned:
|
||||
testl $3,%esi
|
||||
jne .Lbyte_loop
|
||||
|
||||
subl $4,%ebx
|
||||
subl $4,%esi
|
||||
|
||||
_ALIGN_TEXT
|
||||
.Lword_loop:
|
||||
movl 4(%ebx),%eax
|
||||
addl $4,%ebx
|
||||
movl 4(%esi),%edx
|
||||
addl $4,%esi
|
||||
cmpl %eax,%edx
|
||||
jne .Lbyte_loop
|
||||
subl $0x01010101,%edx
|
||||
notl %eax
|
||||
andl %eax,%edx
|
||||
testl $0x80808080,%edx
|
||||
je .Lword_loop
|
||||
|
||||
_ALIGN_TEXT
|
||||
.Lbyte_loop:
|
||||
movb (%ebx),%al
|
||||
incl %ebx
|
||||
movb (%esi),%dl
|
||||
incl %esi
|
||||
testb %al,%al
|
||||
je .Ldone
|
||||
cmpb %al,%dl
|
||||
je .Lbyte_loop
|
||||
|
||||
.Ldone:
|
||||
movzbl %al,%eax
|
||||
movzbl %dl,%edx
|
||||
subl %edx,%eax
|
||||
popl %ebx
|
||||
popl %esi
|
||||
ret
|
86
common/lib/libc/arch/i386/string/strcpy.S
Normal file
86
common/lib/libc/arch/i386/string/strcpy.S
Normal file
|
@ -0,0 +1,86 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@acorntoolworks.com>
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#if defined(LIBC_SCCS)
|
||||
RCSID("$NetBSD: strcpy.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This strcpy implementation copies a byte at a time until the
|
||||
* source pointer is aligned to a word boundary, it then copies by
|
||||
* words until it finds a word containing a zero byte, and finally
|
||||
* copies by bytes until the end of the string is reached.
|
||||
*
|
||||
* While this may result in unaligned stores if the source and
|
||||
* destination pointers are unaligned with respect to each other,
|
||||
* it is still faster than either byte copies or the overhead of
|
||||
* an implementation suitable for machines with strict alignment
|
||||
* requirements.
|
||||
*/
|
||||
|
||||
ENTRY(strcpy)
|
||||
pushl %ebx
|
||||
movl 8(%esp),%ecx
|
||||
movl 12(%esp),%eax
|
||||
|
||||
/*
|
||||
* Align source to a word boundary.
|
||||
* Consider unrolling loop?
|
||||
*/
|
||||
_ALIGN_TEXT
|
||||
.Lalign:
|
||||
testl $3,%eax
|
||||
je .Lword_aligned
|
||||
movb (%eax),%bl
|
||||
incl %eax
|
||||
movb %bl,(%ecx)
|
||||
incl %ecx
|
||||
testb %bl,%bl
|
||||
jne .Lalign
|
||||
jmp .Ldone
|
||||
|
||||
_ALIGN_TEXT
|
||||
.Lloop:
|
||||
movl %ebx,(%ecx)
|
||||
addl $4,%ecx
|
||||
.Lword_aligned:
|
||||
movl (%eax),%ebx
|
||||
addl $4,%eax
|
||||
leal -0x01010101(%ebx),%edx
|
||||
testl $0x80808080,%edx
|
||||
je .Lloop
|
||||
|
||||
/*
|
||||
* In rare cases, the above loop may exit prematurely. We must
|
||||
* return to the loop if none of the bytes in the word equal 0.
|
||||
*/
|
||||
|
||||
movb %bl,(%ecx)
|
||||
incl %ecx
|
||||
testb %bl,%bl
|
||||
je .Ldone
|
||||
|
||||
movb %bh,(%ecx)
|
||||
incl %ecx
|
||||
testb %bh,%bh
|
||||
je .Ldone
|
||||
|
||||
shrl $16,%ebx
|
||||
movb %bl,(%ecx)
|
||||
incl %ecx
|
||||
testb %bl,%bl
|
||||
je .Ldone
|
||||
|
||||
movb %bh,(%ecx)
|
||||
incl %ecx
|
||||
testb %bh,%bh
|
||||
jne .Lword_aligned
|
||||
|
||||
.Ldone:
|
||||
movl 8(%esp),%eax
|
||||
popl %ebx
|
||||
ret
|
141
common/lib/libc/arch/i386/string/strlen.S
Normal file
141
common/lib/libc/arch/i386/string/strlen.S
Normal file
|
@ -0,0 +1,141 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@acorntoolworks.com>
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#if defined(LIBC_SCCS)
|
||||
RCSID("$NetBSD: strlen.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
|
||||
#endif
|
||||
|
||||
ENTRY(strlen)
|
||||
movl 4(%esp),%eax
|
||||
|
||||
.Lalign:
|
||||
/* Consider unrolling loop? */
|
||||
testb $3,%al
|
||||
je .Lword_aligned
|
||||
cmpb $0,(%eax)
|
||||
je .Ldone
|
||||
incl %eax
|
||||
jmp .Lalign
|
||||
|
||||
/*
|
||||
* There are many well known branch-free sequences which are used
|
||||
* for determining whether a zero-byte is contained within a word.
|
||||
* These sequences are generally much more efficent than loading
|
||||
* and comparing each byte individually.
|
||||
*
|
||||
* The expression [1,2]:
|
||||
*
|
||||
* (1) ~(((x & 0x7f7f7f7f) + 0x7f7f7f7f) | (x | 0x7f7f7f7f))
|
||||
*
|
||||
* evaluates to a non-zero value if any of the bytes in the
|
||||
* original word is zero.
|
||||
*
|
||||
* It also has the useful property that bytes in the result word
|
||||
* that correspond to non-zero bytes in the original word have
|
||||
* the value 0x00, while bytes corresponding to zero bytes have
|
||||
* the value 0x80. This allows calculation of the first (and
|
||||
* last) occurrence of a zero byte within the word (useful for C's
|
||||
* str* primitives) by counting the number of leading (or
|
||||
* trailing) zeros and dividing the result by 8. On machines
|
||||
* without (or with slow) clz() / ctz() instructions, testing
|
||||
* each byte in the result word for zero is necessary.
|
||||
*
|
||||
* This typically takes 4 instructions (5 on machines without
|
||||
* "not-or") not including those needed to load the constant.
|
||||
*
|
||||
*
|
||||
* The expression:
|
||||
*
|
||||
* (2) ((x - 0x01010101) & ~x & 0x80808080)
|
||||
*
|
||||
* evaluates to a non-zero value if any of the bytes in the
|
||||
* original word is zero.
|
||||
*
|
||||
* On little endian machines, the first byte in the result word
|
||||
* that corresponds to a zero byte in the original byte is 0x80,
|
||||
* so clz() can be used as above. On big endian machines, and
|
||||
* little endian machines without (or with a slow) clz() insn,
|
||||
* testing each byte in the original for zero is necessary.
|
||||
*
|
||||
* This typically takes 3 instructions (4 on machines without
|
||||
* "and with complement") not including those needed to load
|
||||
* constants.
|
||||
*
|
||||
*
|
||||
* The expression:
|
||||
*
|
||||
* (3) ((x - 0x01010101) & 0x80808080)
|
||||
*
|
||||
* always evaluates to a non-zero value if any of the bytes in
|
||||
* the original word is zero. However, in rare cases, it also
|
||||
* evaluates to a non-zero value when none of the bytes in the
|
||||
* original word is zero.
|
||||
*
|
||||
* To account for possible false positives, each byte of the
|
||||
* original word must be checked when the expression evaluates to
|
||||
* a non-zero value. However, because it is simpler than those
|
||||
* presented above, code that uses it will be faster as long as
|
||||
* the rate of false positives is low.
|
||||
*
|
||||
* This is likely, because the the false positive can only occur
|
||||
* if the most siginificant bit of a byte within the word is set.
|
||||
* The expression will never fail for typical 7-bit ASCII strings.
|
||||
*
|
||||
* This typically takes 2 instructions not including those needed
|
||||
* to load constants.
|
||||
*
|
||||
*
|
||||
* [1] Henry S. Warren Jr., "Hacker's Delight", Addison-Westley 2003
|
||||
*
|
||||
* [2] International Business Machines, "The PowerPC Compiler Writer's
|
||||
* Guide", Warthman Associates, 1996
|
||||
*/
|
||||
|
||||
_ALIGN_TEXT
|
||||
.Lword_aligned:
|
||||
.Lloop:
|
||||
movl (%eax),%ecx
|
||||
addl $4,%eax
|
||||
leal -0x01010101(%ecx),%edx
|
||||
testl $0x80808080,%edx
|
||||
je .Lloop
|
||||
|
||||
/*
|
||||
* In rare cases, the above loop may exit prematurely. We must
|
||||
* return to the loop if none of the bytes in the word equal 0.
|
||||
*/
|
||||
|
||||
/*
|
||||
* The optimal code for determining whether each byte is zero
|
||||
* differs by processor. This space-optimized code should be
|
||||
* acceptable on all, especially since we don't expect it to
|
||||
* be run frequently,
|
||||
*/
|
||||
|
||||
testb %cl,%cl /* 1st byte == 0? */
|
||||
jne 1f
|
||||
subl $4,%eax
|
||||
jmp .Ldone
|
||||
|
||||
1: testb %ch,%ch /* 2nd byte == 0? */
|
||||
jne 1f
|
||||
subl $3,%eax
|
||||
jmp .Ldone
|
||||
|
||||
1: shrl $16,%ecx
|
||||
testb %cl,%cl /* 3rd byte == 0? */
|
||||
jne 1f
|
||||
subl $2,%eax
|
||||
jmp .Ldone
|
||||
|
||||
1: testb %ch,%ch /* 4th byte == 0? */
|
||||
jne .Lloop
|
||||
decl %eax
|
||||
|
||||
.Ldone:
|
||||
subl 4(%esp),%eax
|
||||
ret
|
96
common/lib/libc/arch/i386/string/strrchr.S
Normal file
96
common/lib/libc/arch/i386/string/strrchr.S
Normal file
|
@ -0,0 +1,96 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@acorntoolworks.com>
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#if defined(LIBC_SCCS)
|
||||
RCSID("$NetBSD: strrchr.S,v 1.2 2009/07/17 19:37:57 dsl Exp $")
|
||||
#endif
|
||||
|
||||
ENTRY(strrchr)
|
||||
pushl %esi
|
||||
pushl %edi
|
||||
pushl %ebx
|
||||
movl 16(%esp),%edx
|
||||
movzbl 20(%esp),%ecx
|
||||
|
||||
/* zero return value */
|
||||
xorl %eax,%eax
|
||||
|
||||
/*
|
||||
* Align to word boundary.
|
||||
* Consider unrolling loop?
|
||||
*/
|
||||
.Lalign:
|
||||
testb $3,%dl
|
||||
je .Lword_aligned
|
||||
movb (%edx),%bl
|
||||
cmpb %cl,%bl
|
||||
jne 1f
|
||||
movl %edx,%eax
|
||||
1: testb %bl,%bl
|
||||
je .Ldone
|
||||
incl %edx
|
||||
jmp .Lalign
|
||||
|
||||
.Lword_aligned:
|
||||
/* copy char to all bytes in word */
|
||||
movb %cl,%ch
|
||||
movl %ecx,%edi
|
||||
sall $16,%ecx
|
||||
orl %edi,%ecx
|
||||
|
||||
/* Check whether any byte in the word is equal to ch or 0. */
|
||||
_ALIGN_TEXT
|
||||
.Lloop:
|
||||
movl (%edx),%ebx
|
||||
addl $4,%edx
|
||||
movl %ebx,%esi
|
||||
leal -0x01010101(%ebx),%edi
|
||||
xorl %ecx,%esi
|
||||
subl $0x01010101,%esi
|
||||
orl %esi,%edi
|
||||
testl $0x80808080,%edi
|
||||
je .Lloop
|
||||
|
||||
/*
|
||||
* In rare cases, the above loop may exit prematurely. We must
|
||||
* return to the loop if none of the bytes in the word match
|
||||
* ch or are equal to 0.
|
||||
*/
|
||||
|
||||
_ALIGN_TEXT
|
||||
cmpb %cl,%bl /* 1st byte == ch? */
|
||||
jne 1f
|
||||
leal -4(%edx),%eax
|
||||
1: testb %bl,%bl /* 1st byte == 0? */
|
||||
je .Ldone
|
||||
|
||||
cmpb %cl,%bh /* 2nd byte == ch? */
|
||||
jne 1f
|
||||
leal -3(%edx),%eax
|
||||
1: testb %bh,%bh /* 2nd byte == 0? */
|
||||
je .Ldone
|
||||
|
||||
shrl $16,%ebx
|
||||
cmpb %cl,%bl /* 3rd byte == ch? */
|
||||
jne 1f
|
||||
leal -2(%edx),%eax
|
||||
1: testb %bl,%bl /* 3rd byte == 0? */
|
||||
je .Ldone
|
||||
|
||||
cmpb %cl,%bh /* 4th byte == ch? */
|
||||
jne 1f
|
||||
leal -1(%edx),%eax
|
||||
1: testb %bh,%bh /* 4th byte == 0? */
|
||||
jne .Lloop
|
||||
|
||||
.Ldone:
|
||||
popl %ebx
|
||||
popl %edi
|
||||
popl %esi
|
||||
ret
|
||||
|
||||
STRONG_ALIAS(rindex,strrchr)
|
21
common/lib/libc/arch/ia64/atomic/Makefile.inc
Normal file
21
common/lib/libc/arch/ia64/atomic/Makefile.inc
Normal file
|
@ -0,0 +1,21 @@
|
|||
# $NetBSD: Makefile.inc,v 1.3 2009/01/04 17:54:29 pooka Exp $
|
||||
|
||||
.if defined(LIB) && (${LIB} == "kern" || ${LIB} == "c" || ${LIB} == "pthread" \
|
||||
|| ${LIB} == "rump")
|
||||
|
||||
SRCS+= atomic_add_32_cas.c atomic_add_32_nv_cas.c \
|
||||
atomic_add_64_cas.c atomic_add_64_nv_cas.c \
|
||||
atomic_and_32_cas.c atomic_and_32_nv_cas.c \
|
||||
atomic_and_64_cas.c atomic_and_64_nv_cas.c \
|
||||
atomic_or_32_cas.c atomic_or_32_nv_cas.c \
|
||||
atomic_or_64_cas.c atomic_or_64_nv_cas.c
|
||||
|
||||
SRCS+= atomic.S
|
||||
|
||||
.endif
|
||||
|
||||
.if defined(LIB) && (${LIB} == "c" || ${LIB} == "pthread")
|
||||
|
||||
SRCS += atomic_init_cas.c
|
||||
|
||||
.endif
|
270
common/lib/libc/arch/ia64/atomic/atomic.S
Normal file
270
common/lib/libc/arch/ia64/atomic/atomic.S
Normal file
|
@ -0,0 +1,270 @@
|
|||
/* $NetBSD: atomic.S,v 1.5 2009/11/09 14:22:02 skrll Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Takayoshi Kochi.
|
||||
*
|
||||
* 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 <machine/asm.h>
|
||||
|
||||
#ifdef _KERNEL
|
||||
#define ALIAS(f, t) STRONG_ALIAS(f,t)
|
||||
#else
|
||||
#define ALIAS(f, t) WEAK_ALIAS(f,t)
|
||||
#endif
|
||||
|
||||
.text
|
||||
|
||||
ENTRY(_atomic_dec_32,1)
|
||||
fetchadd4.rel r8=[r32],-1
|
||||
br.ret.sptk rp
|
||||
END(_atomic_dec_32)
|
||||
|
||||
ENTRY(_atomic_dec_64,1)
|
||||
fetchadd8.rel r8=[r32],-1
|
||||
br.ret.sptk rp
|
||||
END(_atomic_dec_64)
|
||||
|
||||
ENTRY(_atomic_dec_32_nv,1)
|
||||
fetchadd4.rel r8=[r32],-1
|
||||
br.ret.sptk rp
|
||||
END(_atomic_dec_32_nv)
|
||||
|
||||
ENTRY(_atomic_dec_64_nv,1)
|
||||
fetchadd8.rel r8=[r32],-1
|
||||
br.ret.sptk rp
|
||||
END(_atomic_dec_64_nv)
|
||||
|
||||
ENTRY(_atomic_inc_32,1)
|
||||
fetchadd4.rel r8=[r32],1
|
||||
br.ret.sptk rp
|
||||
END(_atomic_inc_32)
|
||||
|
||||
ENTRY(_atomic_inc_64,1)
|
||||
fetchadd8.rel r8=[r32],1
|
||||
br.ret.sptk rp
|
||||
END(_atomic_inc_64)
|
||||
|
||||
ENTRY(_atomic_inc_32_nv,1)
|
||||
fetchadd4.rel r8=[r32],1
|
||||
br.ret.sptk rp
|
||||
END(_atomic_inc_32_nv)
|
||||
|
||||
ENTRY(_atomic_inc_64_nv,1)
|
||||
fetchadd8.rel r8=[r32],1
|
||||
br.ret.sptk rp
|
||||
END(_atomic_inc_64_nv)
|
||||
|
||||
ENTRY(_atomic_swap_32,2)
|
||||
xchg4 r8=[r32],r33
|
||||
;;
|
||||
mov r33=r8
|
||||
br.ret.sptk rp
|
||||
END(_atomic_swap_32)
|
||||
|
||||
ENTRY(_atomic_swap_64,2)
|
||||
xchg8 r8=[r32],r33
|
||||
;;
|
||||
mov r33=r8
|
||||
br.ret.sptk rp
|
||||
END(_atomic_swap_64)
|
||||
|
||||
ENTRY(_atomic_cas_32,3)
|
||||
mov ar.ccv=r33
|
||||
;;
|
||||
cmpxchg4.acq r8=[r32],r34,ar.ccv
|
||||
br.ret.sptk rp
|
||||
END(_atomic_cas_32)
|
||||
|
||||
ENTRY(_atomic_cas_64,3)
|
||||
mov ar.ccv=r33
|
||||
;;
|
||||
cmpxchg8.acq r8=[r32],r34,ar.ccv
|
||||
br.ret.sptk rp
|
||||
END(_atomic_cas_64)
|
||||
|
||||
ENTRY(_membar_consumer,0)
|
||||
mf
|
||||
br.ret.sptk rp
|
||||
END(_membar_consumer)
|
||||
|
||||
ENTRY(_membar_producer,0)
|
||||
mf
|
||||
br.ret.sptk rp
|
||||
END(_membar_producer)
|
||||
|
||||
ENTRY(_membar_enter,0)
|
||||
mf
|
||||
br.ret.sptk rp
|
||||
END(_membar_enter)
|
||||
|
||||
ENTRY(_membar_exit,0)
|
||||
mf
|
||||
br.ret.sptk rp
|
||||
END(_membar_exit)
|
||||
|
||||
ENTRY(_membar_sync,0)
|
||||
mf
|
||||
br.ret.sptk rp
|
||||
END(_membar_sync)
|
||||
|
||||
|
||||
ALIAS(atomic_add_32,_atomic_add_32)
|
||||
ALIAS(atomic_add_int,_atomic_add_32)
|
||||
ALIAS(atomic_add_64,_atomic_add_64)
|
||||
ALIAS(atomic_add_long,_atomic_add_64)
|
||||
ALIAS(atomic_add_ptr,_atomic_add_64)
|
||||
|
||||
ALIAS(atomic_add_32_nv,_atomic_add_32_nv)
|
||||
ALIAS(atomic_add_int_nv,_atomic_add_32_nv)
|
||||
ALIAS(atomic_add_64_nv,_atomic_add_64_nv)
|
||||
ALIAS(atomic_add_long_nv,_atomic_add_64_nv)
|
||||
ALIAS(atomic_add_ptr_nv,_atomic_add_64_nv)
|
||||
|
||||
ALIAS(atomic_and_32,_atomic_and_32)
|
||||
ALIAS(atomic_and_uint,_atomic_and_32)
|
||||
ALIAS(atomic_and_64,_atomic_and_64)
|
||||
ALIAS(atomic_and_ulong,_atomic_and_64)
|
||||
ALIAS(atomic_and_ptr,_atomic_and_64)
|
||||
|
||||
ALIAS(atomic_and_32_nv,_atomic_and_32_nv)
|
||||
ALIAS(atomic_and_uint_nv,_atomic_and_32_nv)
|
||||
ALIAS(atomic_and_64_nv,_atomic_and_64_nv)
|
||||
ALIAS(atomic_and_ulong_nv,_atomic_and_64_nv)
|
||||
ALIAS(atomic_and_ptr_nv,_atomic_and_64_nv)
|
||||
|
||||
ALIAS(atomic_dec_32,_atomic_dec_32)
|
||||
ALIAS(atomic_dec_uint,_atomic_dec_32)
|
||||
ALIAS(atomic_dec_64,_atomic_dec_64)
|
||||
ALIAS(atomic_dec_ulong,_atomic_dec_64)
|
||||
ALIAS(atomic_dec_ptr,_atomic_dec_64)
|
||||
|
||||
ALIAS(atomic_dec_32_nv,_atomic_dec_32_nv)
|
||||
ALIAS(atomic_dec_uint_nv,_atomic_dec_32_nv)
|
||||
ALIAS(atomic_dec_64_nv,_atomic_dec_64_nv)
|
||||
ALIAS(atomic_dec_ulong_nv,_atomic_dec_64_nv)
|
||||
ALIAS(atomic_dec_ptr_nv,_atomic_dec_64_nv)
|
||||
|
||||
ALIAS(atomic_inc_32,_atomic_inc_32)
|
||||
ALIAS(atomic_inc_uint,_atomic_inc_32)
|
||||
ALIAS(atomic_inc_64,_atomic_inc_64)
|
||||
ALIAS(atomic_inc_ulong,_atomic_inc_64)
|
||||
ALIAS(atomic_inc_ptr,_atomic_inc_64)
|
||||
|
||||
ALIAS(atomic_inc_32_nv,_atomic_inc_32_nv)
|
||||
ALIAS(atomic_inc_uint_nv,_atomic_inc_32_nv)
|
||||
ALIAS(atomic_inc_64_nv,_atomic_inc_64_nv)
|
||||
ALIAS(atomic_inc_ulong_nv,_atomic_inc_64_nv)
|
||||
ALIAS(atomic_inc_ptr_nv,_atomic_inc_64_nv)
|
||||
|
||||
ALIAS(atomic_or_32,_atomic_or_32)
|
||||
ALIAS(atomic_or_uint,_atomic_or_32)
|
||||
ALIAS(atomic_or_64,_atomic_or_64)
|
||||
ALIAS(atomic_or_ulong,_atomic_or_64)
|
||||
ALIAS(atomic_or_ptr,_atomic_or_64)
|
||||
|
||||
ALIAS(atomic_or_32_nv,_atomic_or_32_nv)
|
||||
ALIAS(atomic_or_uint_nv,_atomic_or_32_nv)
|
||||
ALIAS(atomic_or_64_nv,_atomic_or_64_nv)
|
||||
ALIAS(atomic_or_ulong_nv,_atomic_or_64_nv)
|
||||
ALIAS(atomic_or_ptr_nv,_atomic_or_64_nv)
|
||||
|
||||
ALIAS(atomic_swap_32,_atomic_swap_32)
|
||||
ALIAS(atomic_swap_uint,_atomic_swap_32)
|
||||
ALIAS(atomic_swap_64,_atomic_swap_64)
|
||||
ALIAS(atomic_swap_ulong,_atomic_swap_64)
|
||||
ALIAS(atomic_swap_ptr,_atomic_swap_64)
|
||||
|
||||
ALIAS(atomic_cas_32,_atomic_cas_32)
|
||||
ALIAS(atomic_cas_uint,_atomic_cas_32)
|
||||
ALIAS(atomic_cas_64,_atomic_cas_64)
|
||||
ALIAS(atomic_cas_ulong,_atomic_cas_64)
|
||||
ALIAS(atomic_cas_ptr,_atomic_cas_64)
|
||||
|
||||
ALIAS(atomic_cas_32_ni,_atomic_cas_32)
|
||||
ALIAS(atomic_cas_uint_ni,_atomic_cas_32)
|
||||
ALIAS(atomic_cas_64_ni,_atomic_cas_64)
|
||||
ALIAS(atomic_cas_ulong_ni,_atomic_cas_64)
|
||||
ALIAS(atomic_cas_ptr_ni,_atomic_cas_64)
|
||||
|
||||
ALIAS(membar_consumer,_membar_consumer)
|
||||
ALIAS(membar_producer,_membar_producer)
|
||||
ALIAS(membar_enter,_membar_enter)
|
||||
ALIAS(membar_exit,_membar_exit)
|
||||
ALIAS(membar_sync,_membar_sync)
|
||||
|
||||
STRONG_ALIAS(_atomic_add_int,_atomic_add_32)
|
||||
STRONG_ALIAS(_atomic_add_long,_atomic_add_64)
|
||||
STRONG_ALIAS(_atomic_add_ptr,_atomic_add_64)
|
||||
|
||||
STRONG_ALIAS(_atomic_add_int_nv,_atomic_add_32_nv)
|
||||
STRONG_ALIAS(_atomic_add_long_nv,_atomic_add_64_nv)
|
||||
STRONG_ALIAS(_atomic_add_ptr_nv,_atomic_add_64_nv)
|
||||
|
||||
STRONG_ALIAS(_atomic_and_uint,_atomic_and_32)
|
||||
STRONG_ALIAS(_atomic_and_ulong,_atomic_and_64)
|
||||
STRONG_ALIAS(_atomic_and_ptr,_atomic_and_64)
|
||||
|
||||
STRONG_ALIAS(_atomic_and_uint_nv,_atomic_and_32_nv)
|
||||
STRONG_ALIAS(_atomic_and_ulong_nv,_atomic_and_64_nv)
|
||||
STRONG_ALIAS(_atomic_and_ptr_nv,_atomic_and_64_nv)
|
||||
|
||||
STRONG_ALIAS(_atomic_dec_uint,_atomic_dec_32)
|
||||
STRONG_ALIAS(_atomic_dec_ulong,_atomic_dec_64)
|
||||
STRONG_ALIAS(_atomic_dec_ptr,_atomic_dec_64)
|
||||
|
||||
STRONG_ALIAS(_atomic_dec_uint_nv,_atomic_dec_32_nv)
|
||||
STRONG_ALIAS(_atomic_dec_ulong_nv,_atomic_dec_64_nv)
|
||||
STRONG_ALIAS(_atomic_dec_ptr_nv,_atomic_dec_64_nv)
|
||||
|
||||
STRONG_ALIAS(_atomic_inc_uint,_atomic_inc_32)
|
||||
STRONG_ALIAS(_atomic_inc_ulong,_atomic_inc_64)
|
||||
STRONG_ALIAS(_atomic_inc_ptr,_atomic_inc_64)
|
||||
|
||||
STRONG_ALIAS(_atomic_inc_uint_nv,_atomic_inc_32_nv)
|
||||
STRONG_ALIAS(_atomic_inc_ulong_nv,_atomic_inc_64_nv)
|
||||
STRONG_ALIAS(_atomic_inc_ptr_nv,_atomic_inc_64_nv)
|
||||
|
||||
STRONG_ALIAS(_atomic_or_uint,_atomic_or_32)
|
||||
STRONG_ALIAS(_atomic_or_ulong,_atomic_or_64)
|
||||
STRONG_ALIAS(_atomic_or_ptr,_atomic_or_64)
|
||||
|
||||
STRONG_ALIAS(_atomic_or_uint_nv,_atomic_or_32_nv)
|
||||
STRONG_ALIAS(_atomic_or_ulong_nv,_atomic_or_64_nv)
|
||||
STRONG_ALIAS(_atomic_or_ptr_nv,_atomic_or_64_nv)
|
||||
|
||||
STRONG_ALIAS(_atomic_swap_uint,_atomic_swap_32)
|
||||
STRONG_ALIAS(_atomic_swap_ulong,_atomic_swap_64)
|
||||
STRONG_ALIAS(_atomic_swap_ptr,_atomic_swap_64)
|
||||
|
||||
STRONG_ALIAS(_atomic_cas_uint,_atomic_cas_32)
|
||||
STRONG_ALIAS(_atomic_cas_ulong,_atomic_cas_64)
|
||||
STRONG_ALIAS(_atomic_cas_ptr,_atomic_cas_64)
|
||||
|
||||
STRONG_ALIAS(_atomic_cas_uint_ni,_atomic_cas_32)
|
||||
STRONG_ALIAS(_atomic_cas_ulong_ni,_atomic_cas_64)
|
||||
STRONG_ALIAS(_atomic_cas_ptr_ni,_atomic_cas_64)
|
41
common/lib/libc/arch/m68k/atomic/Makefile.inc
Normal file
41
common/lib/libc/arch/m68k/atomic/Makefile.inc
Normal file
|
@ -0,0 +1,41 @@
|
|||
# $NetBSD: Makefile.inc,v 1.9 2009/01/04 17:54:29 pooka Exp $
|
||||
|
||||
#
|
||||
# Note: The atomic operations here in these assembly files are atomic
|
||||
# only with respect to regular memory on uniprocessor systems. Since
|
||||
# we don't support any MP m68k systems, this is just fine. If we ever
|
||||
# do, then these routines will probably need to be replaced with CAS-
|
||||
# based routines (CAS generates an atomic bus cycle, whereas these
|
||||
# others are merely single-instruction).
|
||||
#
|
||||
|
||||
.if defined(LIB) && (${LIB} == "kern" || ${LIB} == "c" || ${LIB} == "pthread" \
|
||||
|| ${LIB} == "rump")
|
||||
.if ${MACHINE_ARCH} != "m68000"
|
||||
|
||||
SRCS+= atomic_add.S atomic_and.S atomic_cas.S atomic_dec.S \
|
||||
atomic_inc.S atomic_or.S atomic_swap.S membar_ops_nop.c
|
||||
|
||||
.else
|
||||
|
||||
SRCS+= atomic_add_32_cas.c atomic_add_32_nv_cas.c atomic_and_32_cas.c \
|
||||
atomic_and_32_nv_cas.c atomic_dec_32_cas.c atomic_dec_32_nv_cas.c \
|
||||
atomic_inc_32_cas.c atomic_inc_32_nv_cas.c atomic_or_32_cas.c \
|
||||
atomic_or_32_nv_cas.c atomic_swap_32_cas.c membar_ops_nop.c
|
||||
|
||||
.endif
|
||||
.endif
|
||||
|
||||
.if defined(LIB) && (${LIB} == "c" || ${LIB} == "pthread")
|
||||
.if ${MACHINE_ARCH} != "m68000"
|
||||
|
||||
SRCS+= atomic_init_cas.c
|
||||
|
||||
.else
|
||||
|
||||
SRCS+= atomic_init_testset.c
|
||||
SRCS+= atomic_cas_68000.S
|
||||
CPPFLAGS+= -D__HAVE_ASM_ATOMIC_CAS_UP
|
||||
|
||||
.endif
|
||||
.endif
|
65
common/lib/libc/arch/m68k/atomic/atomic_add.S
Normal file
65
common/lib/libc/arch/m68k/atomic/atomic_add.S
Normal file
|
@ -0,0 +1,65 @@
|
|||
/* $NetBSD: atomic_add.S,v 1.4 2008/05/25 15:56:11 chs Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Jason R. Thorpe.
|
||||
*
|
||||
* 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 "atomic_op_asm.h"
|
||||
|
||||
.text
|
||||
.align 2
|
||||
|
||||
ENTRY(_atomic_add_32)
|
||||
movl %sp@(4), %a0
|
||||
movl %sp@(8), %d0
|
||||
addl %d0, %a0@
|
||||
rts
|
||||
ATOMIC_OP_ALIAS(atomic_add_32,_atomic_add_32)
|
||||
ATOMIC_OP_ALIAS(atomic_add_int,_atomic_add_32)
|
||||
STRONG_ALIAS(_atomic_add_int,_atomic_add_32)
|
||||
ATOMIC_OP_ALIAS(atomic_add_long,_atomic_add_32)
|
||||
STRONG_ALIAS(_atomic_add_long,_atomic_add_32)
|
||||
ATOMIC_OP_ALIAS(atomic_add_ptr,_atomic_add_32)
|
||||
STRONG_ALIAS(_atomic_add_ptr,_atomic_add_32)
|
||||
|
||||
ENTRY(_atomic_add_32_nv)
|
||||
movl %sp@(4), %a0
|
||||
1: movl %a0@, %d0
|
||||
movl %d0, %d1
|
||||
addl %sp@(8), %d0
|
||||
casl %d1, %d0, %a0@
|
||||
bne 1b
|
||||
movl %d0, %a0 /* pointers return also in %a0 */
|
||||
rts
|
||||
ATOMIC_OP_ALIAS(atomic_add_32_nv,_atomic_add_32_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_add_int_nv,_atomic_add_32_nv)
|
||||
STRONG_ALIAS(_atomic_add_int_nv,_atomic_add_32_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_add_long_nv,_atomic_add_32_nv)
|
||||
STRONG_ALIAS(_atomic_add_long_nv,_atomic_add_32_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_add_ptr_nv,_atomic_add_32_nv)
|
||||
STRONG_ALIAS(_atomic_add_ptr_nv,_atomic_add_32_nv)
|
63
common/lib/libc/arch/m68k/atomic/atomic_and.S
Normal file
63
common/lib/libc/arch/m68k/atomic/atomic_and.S
Normal file
|
@ -0,0 +1,63 @@
|
|||
/* $NetBSD: atomic_and.S,v 1.6 2008/05/25 15:56:11 chs Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Jason R. Thorpe.
|
||||
*
|
||||
* 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 "atomic_op_asm.h"
|
||||
|
||||
.text
|
||||
|
||||
ENTRY(_atomic_and_32)
|
||||
movl %sp@(4), %a0
|
||||
movl %sp@(8), %d0
|
||||
andl %d0, %a0@
|
||||
rts
|
||||
ATOMIC_OP_ALIAS(atomic_and_32,_atomic_and_32)
|
||||
ATOMIC_OP_ALIAS(atomic_and_uint,_atomic_and_32)
|
||||
STRONG_ALIAS(_atomic_and_uint,_atomic_and_32)
|
||||
ATOMIC_OP_ALIAS(atomic_and_ulong,_atomic_and_32)
|
||||
STRONG_ALIAS(_atomic_and_ulong,_atomic_and_32)
|
||||
ATOMIC_OP_ALIAS(atomic_and_ptr,_atomic_and_32)
|
||||
STRONG_ALIAS(_atomic_and_ptr,_atomic_and_32)
|
||||
|
||||
ENTRY(_atomic_and_32_nv)
|
||||
movl %sp@(4), %a0
|
||||
1: movl %a0@, %d0
|
||||
movl %d0, %d1
|
||||
andl %sp@(8), %d0
|
||||
casl %d1, %d0, %a0@
|
||||
bne 1b
|
||||
rts
|
||||
ATOMIC_OP_ALIAS(atomic_and_32_nv,_atomic_and_32_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_and_uint_nv,_atomic_and_32_nv)
|
||||
STRONG_ALIAS(_atomic_and_uint_nv,_atomic_and_32_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_and_ulong_nv,_atomic_and_32_nv)
|
||||
STRONG_ALIAS(_atomic_and_ulong_nv,_atomic_and_32_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_and_ptr_nv,_atomic_and_32_nv)
|
||||
STRONG_ALIAS(_atomic_and_ptr_nv,_atomic_and_32_nv)
|
60
common/lib/libc/arch/m68k/atomic/atomic_cas.S
Normal file
60
common/lib/libc/arch/m68k/atomic/atomic_cas.S
Normal file
|
@ -0,0 +1,60 @@
|
|||
/* $NetBSD: atomic_cas.S,v 1.5 2008/05/25 15:56:11 chs Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Jason R. Thorpe.
|
||||
*
|
||||
* 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 "atomic_op_asm.h"
|
||||
|
||||
.text
|
||||
|
||||
ENTRY(_atomic_cas_32)
|
||||
movl %sp@(4), %a0
|
||||
movl %sp@(8), %d0
|
||||
movl %sp@(12), %d1
|
||||
casl %d0, %d1, %a0@
|
||||
/* %d0 now contains the old value */
|
||||
movl %d0, %a0 /* pointers return also in %a0 */
|
||||
rts
|
||||
|
||||
ATOMIC_OP_ALIAS(atomic_cas_32,_atomic_cas_32)
|
||||
ATOMIC_OP_ALIAS(atomic_cas_uint,_atomic_cas_32)
|
||||
STRONG_ALIAS(_atomic_cas_uint,_atomic_cas_32)
|
||||
ATOMIC_OP_ALIAS(atomic_cas_ulong,_atomic_cas_32)
|
||||
STRONG_ALIAS(_atomic_cas_ulong,_atomic_cas_32)
|
||||
ATOMIC_OP_ALIAS(atomic_cas_ptr,_atomic_cas_32)
|
||||
STRONG_ALIAS(_atomic_cas_ptr,_atomic_cas_32)
|
||||
|
||||
ATOMIC_OP_ALIAS(atomic_cas_32_ni,_atomic_cas_32)
|
||||
STRONG_ALIAS(_atomic_cas_32_ni,_atomic_cas_32)
|
||||
ATOMIC_OP_ALIAS(atomic_cas_uint_ni,_atomic_cas_32)
|
||||
STRONG_ALIAS(_atomic_cas_uint_ni,_atomic_cas_32)
|
||||
ATOMIC_OP_ALIAS(atomic_cas_ulong_ni,_atomic_cas_32)
|
||||
STRONG_ALIAS(_atomic_cas_ulong_ni,_atomic_cas_32)
|
||||
ATOMIC_OP_ALIAS(atomic_cas_ptr_ni,_atomic_cas_32)
|
||||
STRONG_ALIAS(_atomic_cas_ptr_ni,_atomic_cas_32)
|
49
common/lib/libc/arch/m68k/atomic/atomic_cas_68000.S
Normal file
49
common/lib/libc/arch/m68k/atomic/atomic_cas_68000.S
Normal file
|
@ -0,0 +1,49 @@
|
|||
/* $NetBSD: atomic_cas_68000.S,v 1.3 2008/05/25 15:56:11 chs Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Steve C. Woodford.
|
||||
*
|
||||
* 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/ras.h>
|
||||
#include "atomic_op_asm.h"
|
||||
|
||||
.text
|
||||
|
||||
ENTRY(_atomic_cas_up)
|
||||
.hidden _C_LABEL(_atomic_cas_up)
|
||||
|
||||
movl %sp@(4), %a0 /* Fetch ptr */
|
||||
|
||||
RAS_START_ASM_HIDDEN(_atomic_cas)
|
||||
movl %a0@, %d0 /* d0 = *ptr */
|
||||
cmpl %sp@(8), %d0 /* Same as old? */
|
||||
jne 1f /* Nope */
|
||||
movl %sp@(12), %a0@ /* *ptr = new */
|
||||
RAS_END_ASM_HIDDEN(_atomic_cas)
|
||||
1: rts
|
||||
|
63
common/lib/libc/arch/m68k/atomic/atomic_dec.S
Normal file
63
common/lib/libc/arch/m68k/atomic/atomic_dec.S
Normal file
|
@ -0,0 +1,63 @@
|
|||
/* $NetBSD: atomic_dec.S,v 1.4 2008/05/25 15:56:11 chs Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Jason R. Thorpe.
|
||||
*
|
||||
* 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 "atomic_op_asm.h"
|
||||
|
||||
.text
|
||||
|
||||
ENTRY(_atomic_dec_32)
|
||||
movl %sp@(4), %a0
|
||||
subql #1, %a0@
|
||||
rts
|
||||
ATOMIC_OP_ALIAS(atomic_dec_32,_atomic_dec_32)
|
||||
ATOMIC_OP_ALIAS(atomic_dec_uint,_atomic_dec_32)
|
||||
STRONG_ALIAS(_atomic_dec_uint,_atomic_dec_32)
|
||||
ATOMIC_OP_ALIAS(atomic_dec_ulong,_atomic_dec_32)
|
||||
STRONG_ALIAS(_atomic_dec_ulong,_atomic_dec_32)
|
||||
ATOMIC_OP_ALIAS(atomic_dec_ptr,_atomic_dec_32)
|
||||
STRONG_ALIAS(_atomic_dec_ptr,_atomic_dec_32)
|
||||
|
||||
ENTRY(_atomic_dec_32_nv)
|
||||
movl %sp@(4), %a0
|
||||
1: movl %a0@, %d0
|
||||
movl %d0, %d1
|
||||
subql #1, %d0
|
||||
casl %d1, %d0, %a0@
|
||||
bne 1b
|
||||
movl %d0, %a0 /* pointers return also in %a0 */
|
||||
rts
|
||||
ATOMIC_OP_ALIAS(atomic_dec_32_nv,_atomic_dec_32_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_dec_uint_nv,_atomic_dec_32_nv)
|
||||
STRONG_ALIAS(_atomic_dec_uint_nv,_atomic_dec_32_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_dec_ulong_nv,_atomic_dec_32_nv)
|
||||
STRONG_ALIAS(_atomic_dec_ulong_nv,_atomic_dec_32_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_dec_ptr_nv,_atomic_dec_32_nv)
|
||||
STRONG_ALIAS(_atomic_dec_ptr_nv,_atomic_dec_32_nv)
|
63
common/lib/libc/arch/m68k/atomic/atomic_inc.S
Normal file
63
common/lib/libc/arch/m68k/atomic/atomic_inc.S
Normal file
|
@ -0,0 +1,63 @@
|
|||
/* $NetBSD: atomic_inc.S,v 1.4 2008/05/25 15:56:11 chs Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Jason R. Thorpe.
|
||||
*
|
||||
* 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 "atomic_op_asm.h"
|
||||
|
||||
.text
|
||||
|
||||
ENTRY(_atomic_inc_32)
|
||||
movl %sp@(4), %a0
|
||||
addql #1, %a0@
|
||||
rts
|
||||
ATOMIC_OP_ALIAS(atomic_inc_32,_atomic_inc_32)
|
||||
ATOMIC_OP_ALIAS(atomic_inc_uint,_atomic_inc_32)
|
||||
STRONG_ALIAS(_atomic_inc_uint,_atomic_inc_32)
|
||||
ATOMIC_OP_ALIAS(atomic_inc_ulong,_atomic_inc_32)
|
||||
STRONG_ALIAS(_atomic_inc_ulong,_atomic_inc_32)
|
||||
ATOMIC_OP_ALIAS(atomic_inc_ptr,_atomic_inc_32)
|
||||
STRONG_ALIAS(_atomic_inc_ptr,_atomic_inc_32)
|
||||
|
||||
ENTRY(_atomic_inc_32_nv)
|
||||
movl %sp@(4), %a0
|
||||
1: movl %a0@, %d0
|
||||
movl %d0, %d1
|
||||
addql #1, %d0
|
||||
casl %d1, %d0, %a0@
|
||||
bne 1b
|
||||
movl %d0, %a0 /* pointers return also in %a0 */
|
||||
rts
|
||||
ATOMIC_OP_ALIAS(atomic_inc_32_nv,_atomic_inc_32_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_inc_uint_nv,_atomic_inc_32_nv)
|
||||
STRONG_ALIAS(_atomic_inc_uint_nv,_atomic_inc_32_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_inc_ulong_nv,_atomic_inc_32_nv)
|
||||
STRONG_ALIAS(_atomic_inc_ulong_nv,_atomic_inc_32_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_inc_ptr_nv,_atomic_inc_32_nv)
|
||||
STRONG_ALIAS(_atomic_inc_ptr_nv,_atomic_inc_32_nv)
|
47
common/lib/libc/arch/m68k/atomic/atomic_op_asm.h
Normal file
47
common/lib/libc/arch/m68k/atomic/atomic_op_asm.h
Normal file
|
@ -0,0 +1,47 @@
|
|||
/* $NetBSD: atomic_op_asm.h,v 1.3 2008/04/28 20:22:52 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Jason R. Thorpe.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef _ATOMIC_OP_ASM_H_
|
||||
#define _ATOMIC_OP_ASM_H_
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#if defined(_KERNEL)
|
||||
|
||||
#define ATOMIC_OP_ALIAS(a,s) STRONG_ALIAS(a,s)
|
||||
|
||||
#else /* _KERNEL */
|
||||
|
||||
#define ATOMIC_OP_ALIAS(a,s) WEAK_ALIAS(a,s)
|
||||
|
||||
#endif /* _KERNEL */
|
||||
|
||||
#endif /* _ATOMIC_OP_ASM_H_ */
|
63
common/lib/libc/arch/m68k/atomic/atomic_or.S
Normal file
63
common/lib/libc/arch/m68k/atomic/atomic_or.S
Normal file
|
@ -0,0 +1,63 @@
|
|||
/* $NetBSD: atomic_or.S,v 1.6 2008/05/25 15:56:11 chs Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Jason R. Thorpe.
|
||||
*
|
||||
* 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 "atomic_op_asm.h"
|
||||
|
||||
.text
|
||||
|
||||
ENTRY(_atomic_or_32)
|
||||
movl %sp@(4), %a0
|
||||
movl %sp@(8), %d0
|
||||
orl %d0, %a0@
|
||||
rts
|
||||
ATOMIC_OP_ALIAS(atomic_or_32,_atomic_or_32)
|
||||
ATOMIC_OP_ALIAS(atomic_or_uint,_atomic_or_32)
|
||||
STRONG_ALIAS(_atomic_or_uint,_atomic_or_32)
|
||||
ATOMIC_OP_ALIAS(atomic_or_ulong,_atomic_or_32)
|
||||
STRONG_ALIAS(_atomic_or_ulong,_atomic_or_32)
|
||||
ATOMIC_OP_ALIAS(atomic_or_ptr,_atomic_or_32)
|
||||
STRONG_ALIAS(_atomic_or_ptr,_atomic_or_32)
|
||||
|
||||
ENTRY(_atomic_or_32_nv)
|
||||
movl %sp@(4), %a0
|
||||
1: movl %a0@, %d0
|
||||
movl %d0, %d1
|
||||
orl %sp@(8), %d0
|
||||
casl %d1, %d0, %a0@
|
||||
bne 1b
|
||||
rts
|
||||
ATOMIC_OP_ALIAS(atomic_or_32_nv,_atomic_or_32_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_or_uint_nv,_atomic_or_32_nv)
|
||||
STRONG_ALIAS(_atomic_or_uint_nv,_atomic_or_32_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_or_ulong_nv,_atomic_or_32_nv)
|
||||
STRONG_ALIAS(_atomic_or_ulong_nv,_atomic_or_32_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_or_ptr_nv,_atomic_or_32_nv)
|
||||
STRONG_ALIAS(_atomic_or_ptr_nv,_atomic_or_32_nv)
|
51
common/lib/libc/arch/m68k/atomic/atomic_swap.S
Normal file
51
common/lib/libc/arch/m68k/atomic/atomic_swap.S
Normal file
|
@ -0,0 +1,51 @@
|
|||
/* $NetBSD: atomic_swap.S,v 1.4 2008/05/25 15:56:11 chs Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Jason R. Thorpe.
|
||||
*
|
||||
* 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 "atomic_op_asm.h"
|
||||
|
||||
.text
|
||||
|
||||
ENTRY(_atomic_swap_32)
|
||||
movl %sp@(4), %a0
|
||||
1: movl %a0@, %d0
|
||||
movl %sp@(8), %d1
|
||||
casl %d0, %d1, %a0@
|
||||
bne 1b
|
||||
/* %d0 now contains the old value */
|
||||
movl %d0, %a0 /* pointers return also in %a0 */
|
||||
rts
|
||||
ATOMIC_OP_ALIAS(atomic_swap_32,_atomic_swap_32)
|
||||
ATOMIC_OP_ALIAS(atomic_swap_uint,_atomic_swap_32)
|
||||
STRONG_ALIAS(_atomic_swap_uint,_atomic_swap_32)
|
||||
ATOMIC_OP_ALIAS(atomic_swap_ulong,_atomic_swap_32)
|
||||
STRONG_ALIAS(_atomic_swap_ulong,_atomic_swap_32)
|
||||
ATOMIC_OP_ALIAS(atomic_swap_ptr,_atomic_swap_32)
|
||||
STRONG_ALIAS(_atomic_swap_ptr,_atomic_swap_32)
|
38
common/lib/libc/arch/m68k/gen/bswap16.S
Normal file
38
common/lib/libc/arch/m68k/gen/bswap16.S
Normal file
|
@ -0,0 +1,38 @@
|
|||
/* $NetBSD: bswap16.S,v 1.2 2007/09/19 20:31:34 he Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1996 Scott Reynolds. 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 <machine/asm.h>
|
||||
|
||||
#if defined(_KERNEL) || defined(_STANDALONE)
|
||||
_ENTRY(_C_LABEL(bswap16))
|
||||
#else /* defined(_KERNEL) || defined(_STANDALONE) */
|
||||
_ENTRY(_C_LABEL(__bswap16))
|
||||
#endif /* defined(_KERNEL) || defined(_STANDALONE) */
|
||||
movl %sp@(4),%d0
|
||||
rolw #8,%d0
|
||||
rts
|
40
common/lib/libc/arch/m68k/gen/bswap32.S
Normal file
40
common/lib/libc/arch/m68k/gen/bswap32.S
Normal file
|
@ -0,0 +1,40 @@
|
|||
/* $NetBSD: bswap32.S,v 1.2 2007/09/19 20:31:34 he Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1996 Scott Reynolds. 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 <machine/asm.h>
|
||||
|
||||
#if defined(_KERNEL) || defined(_STANDALONE)
|
||||
_ENTRY(_C_LABEL(bswap32))
|
||||
#else /* defined(_KERNEL) || defined(_STANDALONE) */
|
||||
_ENTRY(_C_LABEL(__bswap32))
|
||||
#endif /* defined(_KERNEL) || defined(_STANDALONE) */
|
||||
movl %sp@(4),%d0
|
||||
rolw #8,%d0
|
||||
swap %d0
|
||||
rolw #8,%d0
|
||||
rts
|
40
common/lib/libc/arch/m68k/gen/bswap64.S
Normal file
40
common/lib/libc/arch/m68k/gen/bswap64.S
Normal file
|
@ -0,0 +1,40 @@
|
|||
/* $NetBSD: bswap64.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1996 Scott Reynolds. 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 <machine/asm.h>
|
||||
|
||||
ENTRY(bswap64)
|
||||
movl %sp@(4),%d1
|
||||
movl %sp@(8),%d0
|
||||
rolw #8,%d1
|
||||
rolw #8,%d0
|
||||
swap %d1
|
||||
swap %d0
|
||||
rolw #8,%d0
|
||||
rolw #8,%d1
|
||||
rts
|
67
common/lib/libc/arch/m68k/gen/divsi3.S
Normal file
67
common/lib/libc/arch/m68k/gen/divsi3.S
Normal file
|
@ -0,0 +1,67 @@
|
|||
/* $NetBSD: divsi3.S,v 1.2 2006/01/05 22:33:34 he Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* the Systems Programming Group of the University of Utah Computer
|
||||
* Science Department.
|
||||
*
|
||||
* 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 <machine/asm.h>
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
#if 0
|
||||
RCSID("from: @(#)divsi3.s 5.1 (Berkeley) 6/7/90")
|
||||
#else
|
||||
RCSID("$NetBSD: divsi3.S,v 1.2 2006/01/05 22:33:34 he Exp $")
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
/* int / int */
|
||||
ENTRY(__divsi3)
|
||||
#ifndef __mc68010__
|
||||
movel %sp@(4),%d0
|
||||
divsl %sp@(8),%d0
|
||||
rts
|
||||
#else
|
||||
| NB: this requires that __udivsi3 preserve %a0:
|
||||
movel %sp@(4), %d1 | load the dividend
|
||||
bpl 1f
|
||||
negl %sp@(4) | store abs(dividend)
|
||||
1: movel %sp@(8), %d0 | load the divisor
|
||||
bpl 2f
|
||||
negl %sp@(8) | store abs(divisor)
|
||||
2: eorl %d1, %d0
|
||||
bpl 3f | branch if sgn(divisor) == sgn(dividend)
|
||||
movel %sp@+, %a0 | pop return address
|
||||
pea %pc@(Lret) | push our return address
|
||||
3: jmp _C_LABEL(__udivsi3)
|
||||
Lret: negl %d0 | negate quotient
|
||||
jmp %a0@
|
||||
#endif /* __mc68010__ */
|
68
common/lib/libc/arch/m68k/gen/modsi3.S
Normal file
68
common/lib/libc/arch/m68k/gen/modsi3.S
Normal file
|
@ -0,0 +1,68 @@
|
|||
/* $NetBSD: modsi3.S,v 1.3 2006/01/13 16:07:59 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* the Systems Programming Group of the University of Utah Computer
|
||||
* Science Department.
|
||||
*
|
||||
* 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 <machine/asm.h>
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
#if 0
|
||||
RCSID("from: @(#)modsi3.s 5.1 (Berkeley) 6/7/90")
|
||||
#else
|
||||
RCSID("$NetBSD: modsi3.S,v 1.3 2006/01/13 16:07:59 christos Exp $")
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
/* int % int */
|
||||
ENTRY(__modsi3)
|
||||
#ifndef __mc68010__
|
||||
movel %sp@(4),%d1
|
||||
divsll %sp@(8),%d0:%d1
|
||||
rts
|
||||
#else
|
||||
| NB: this requires that __udivsi3 preserve %a0 and return
|
||||
| the modulus in %d1:
|
||||
movel %sp@+, %a0 | pop return address
|
||||
movel %sp@(4), %d1 | load the divisor
|
||||
bpl 1f
|
||||
negl %sp@(4) | store abs(divisor)
|
||||
1: movel %sp@, %d0 | load the dividend
|
||||
pea %pc@(Lret) | push our return address
|
||||
bpl 2f
|
||||
negl %sp@(4) | store abs(dividend)
|
||||
subql #2, %sp@ | adjust return address
|
||||
2: jmp _C_LABEL(__udivsi3)
|
||||
negl %d1 | negate modulus
|
||||
Lret: movl %d1, %d0 | move modulus into %d0
|
||||
jmp %a0@
|
||||
#endif /* __mc68010__ */
|
68
common/lib/libc/arch/m68k/gen/mulsi3.S
Normal file
68
common/lib/libc/arch/m68k/gen/mulsi3.S
Normal file
|
@ -0,0 +1,68 @@
|
|||
/* $NetBSD: mulsi3.S,v 1.2 2006/01/05 22:33:34 he Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* the Systems Programming Group of the University of Utah Computer
|
||||
* Science Department.
|
||||
*
|
||||
* 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 <machine/asm.h>
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
#if 0
|
||||
RCSID("from: @(#)mulsi3.s 5.1 (Berkeley) 6/7/90")
|
||||
#else
|
||||
RCSID("$NetBSD: mulsi3.S,v 1.2 2006/01/05 22:33:34 he Exp $")
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
/* int * int */
|
||||
ENTRY(__mulsi3)
|
||||
#ifndef __mc68010__
|
||||
movel %sp@(4),%d0
|
||||
mulsl %sp@(8),%d0
|
||||
#else
|
||||
| NB: this requires that __udivsi3 preserve %a0 and return
|
||||
| the modulus in %d1:
|
||||
movew %sp@(6), %d0
|
||||
movel %d0, %a0 | save B
|
||||
muluw %sp@(8), %d0 | %d0 holds B * C
|
||||
movew %sp@(10), %d1
|
||||
movel %d1, %a1 | save D
|
||||
muluw %sp@(4), %d1 | %d1 holds A * D
|
||||
addw %d1, %d0 | %d0 holds (B * C) + (A * D)
|
||||
swap %d0
|
||||
clrw %d0 | %d0 holds ((B * C) + (A * D)) << 16
|
||||
exg %a0, %d0 | restore B
|
||||
movel %a1, %d1 | restore D
|
||||
muluw %d1, %d0 | %d0 holds B * D
|
||||
addl %a0, %d0 | final result
|
||||
#endif /* __mc68010__ */
|
||||
rts
|
126
common/lib/libc/arch/m68k/gen/udivsi3.S
Normal file
126
common/lib/libc/arch/m68k/gen/udivsi3.S
Normal file
|
@ -0,0 +1,126 @@
|
|||
/* $NetBSD: udivsi3.S,v 1.2 2006/01/05 22:33:34 he Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* the Systems Programming Group of the University of Utah Computer
|
||||
* Science Department.
|
||||
*
|
||||
* 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 <machine/asm.h>
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
#if 0
|
||||
RCSID("from: @(#)udivsi3.s 5.1 (Berkeley) 6/7/90")
|
||||
#else
|
||||
RCSID("$NetBSD: udivsi3.S,v 1.2 2006/01/05 22:33:34 he Exp $")
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
/* unsigned / unsigned */
|
||||
ENTRY(__udivsi3)
|
||||
#ifndef __mc68010__
|
||||
movel %sp@(4),%d0
|
||||
divul %sp@(8),%d0
|
||||
rts
|
||||
#else
|
||||
movel %d2, %sp@- | save %d2
|
||||
movel %sp@(12), %d0 | load divisor
|
||||
movel %sp@(8), %d1 | load dividend
|
||||
|
||||
| first, we divide the divisor and dividend by two until
|
||||
| the divisor fits into 16 bits:
|
||||
1: cmpil #0x10000, %d0
|
||||
bcs 2f
|
||||
lsrl #1, %d0
|
||||
lsrl #1, %d1
|
||||
bra 1b
|
||||
2:
|
||||
|
||||
| now we can do the divide. to avoid overflow, we have to
|
||||
| do the divide in two parts, high and low, and add the
|
||||
| results together:
|
||||
movew %d1, %d2 | save low(dividend)
|
||||
clrw %d1
|
||||
swap %d1 | %d1 = dividend >> 16
|
||||
divuw %d0, %d1 | do the high divide
|
||||
moveal %d1, %a1 | save high divide result
|
||||
movew %d2, %d1 | concat(remainder, low(dividend))
|
||||
divuw %d0, %d1 | do the low divide
|
||||
movel %a1, %d0 | recover high divide result
|
||||
swap %d0
|
||||
clrw %d0 | %d0 = finished high divide result
|
||||
andil #0xffff, %d1 | %d1 = finished low divide result
|
||||
addl %d1, %d0 | %d0 = quotient guess
|
||||
|
||||
| the quotient we have so far is only a guess. the divide we
|
||||
| did above was really the divide of some dividendB by some
|
||||
| divisorB, where the following hold:
|
||||
|
|
||||
| (dividend - divisor) <= dividendB <= dividend
|
||||
| (divisor / 2) < divisorB <= divisor
|
||||
|
|
||||
| so our guess quotient cannot be less than our real desired
|
||||
| quotient. however, it might be one too big.
|
||||
|
|
||||
| to adjust this quotient, we multiply it by the original
|
||||
| divisor and subtract the result from the original dividend.
|
||||
| if the result is nonnegative, our guessed quotient was
|
||||
| correct, and the subtraction result is our remainder.
|
||||
| if the result is negative, our guessed quotient was one
|
||||
| too big, and the subtraction result plus the original
|
||||
| divisor is our remainder.
|
||||
|
|
||||
| as in mulsi3, we have to do the multiply in stages to avoid
|
||||
| overflow:
|
||||
|
||||
movel %sp@(12), %d2 | load divisor
|
||||
swap %d2
|
||||
movel %d0, %d1
|
||||
muluw %d2, %d1 | high(divisor) * low(guess)
|
||||
moveal %d1, %a1 | save high(divisor) * low(guess)
|
||||
swap %d2
|
||||
movel %d0, %d1
|
||||
swap %d1
|
||||
muluw %d2, %d1 | low(divisor) * high(guess)
|
||||
addl %a1, %d1
|
||||
swap %d1
|
||||
clrw %d1 | %d1 = finished high multiply result
|
||||
moveal %d2, %a1 | save original divisor
|
||||
muluw %d0, %d2 | low(guess) * low(divisor)
|
||||
addl %d1, %d2 | %d2 = guess * divisor
|
||||
|
||||
movel %sp@(8), %d1 | load original dividend
|
||||
subl %d2, %d1 | subtract
|
||||
bcc 3f
|
||||
subql #1, %d0 | adjust quotient
|
||||
addl %a1, %d1 | adjust remainder
|
||||
3: movel %sp@+, %d2 | restore %d2
|
||||
rts
|
||||
#endif /* __mc68010__ */
|
59
common/lib/libc/arch/m68k/gen/umodsi3.S
Normal file
59
common/lib/libc/arch/m68k/gen/umodsi3.S
Normal file
|
@ -0,0 +1,59 @@
|
|||
/* $NetBSD: umodsi3.S,v 1.2 2006/01/05 22:33:34 he Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* the Systems Programming Group of the University of Utah Computer
|
||||
* Science Department.
|
||||
*
|
||||
* 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 <machine/asm.h>
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
#if 0
|
||||
RCSID("from: @(#)umodsi3.s 5.1 (Berkeley) 6/7/90")(
|
||||
#else
|
||||
RCSID("$NetBSD: umodsi3.S,v 1.2 2006/01/05 22:33:34 he Exp $")
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
/* unsigned % unsigned */
|
||||
ENTRY(__umodsi3)
|
||||
#ifndef __mc68010__
|
||||
movel %sp@(4),%d1
|
||||
divull %sp@(8),%d0:%d1
|
||||
rts
|
||||
#else
|
||||
| NB: this requires that __udivsi3 preserve the %a0
|
||||
| register, and that it returns the modulus in %d1:
|
||||
movel %sp@+, %a0 | pop the return address
|
||||
jsr _C_LABEL(__udivsi3)
|
||||
movel %d1, %d0 | move the modulus into %d0
|
||||
jmp %a0@ | return
|
||||
#endif /* __mc68010__ */
|
50
common/lib/libc/arch/m68k/net/htonl.S
Normal file
50
common/lib/libc/arch/m68k/net/htonl.S
Normal file
|
@ -0,0 +1,50 @@
|
|||
/* $NetBSD: htonl.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* the Systems Programming Group of the University of Utah Computer
|
||||
* Science Department.
|
||||
*
|
||||
* 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 <machine/asm.h>
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
#if 0
|
||||
RCSID("from: @(#)htonl.s 5.1 (Berkeley) 5/12/90")
|
||||
#else
|
||||
RCSID("$NetBSD: htonl.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
/* netorder = htonl(hostorder) */
|
||||
|
||||
ENTRY(htonl)
|
||||
movl %sp@(4),%d0
|
||||
rts
|
51
common/lib/libc/arch/m68k/net/htons.S
Normal file
51
common/lib/libc/arch/m68k/net/htons.S
Normal file
|
@ -0,0 +1,51 @@
|
|||
/* $NetBSD: htons.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* the Systems Programming Group of the University of Utah Computer
|
||||
* Science Department.
|
||||
*
|
||||
* 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 <machine/asm.h>
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
#if 0
|
||||
RCSID("from: @(#)htons.s 5.1 (Berkeley) 5/12/90")
|
||||
#else
|
||||
RCSID("$NetBSD: htons.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
/* hostorder = htons(netorder) */
|
||||
|
||||
ENTRY(htons)
|
||||
clrl %d0
|
||||
movw %sp@(6),%d0
|
||||
rts
|
50
common/lib/libc/arch/m68k/net/ntohl.S
Normal file
50
common/lib/libc/arch/m68k/net/ntohl.S
Normal file
|
@ -0,0 +1,50 @@
|
|||
/* $NetBSD: ntohl.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* the Systems Programming Group of the University of Utah Computer
|
||||
* Science Department.
|
||||
*
|
||||
* 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 <machine/asm.h>
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
#if 0
|
||||
RCSID("from: @(#)ntohl.s 5.1 (Berkeley) 5/12/90")
|
||||
#else
|
||||
RCSID("$NetBSD: ntohl.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
/* hostorder = ntohl(netorder) */
|
||||
|
||||
ENTRY(ntohl)
|
||||
movl %sp@(4),%d0
|
||||
rts
|
51
common/lib/libc/arch/m68k/net/ntohs.S
Normal file
51
common/lib/libc/arch/m68k/net/ntohs.S
Normal file
|
@ -0,0 +1,51 @@
|
|||
/* $NetBSD: ntohs.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* the Systems Programming Group of the University of Utah Computer
|
||||
* Science Department.
|
||||
*
|
||||
* 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 <machine/asm.h>
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
#if 0
|
||||
RCSID("from: @(#)ntohs.s 5.1 (Berkeley) 5/12/90")
|
||||
#else
|
||||
RCSID("$NetBSD: ntohs.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
/* hostorder = ntohs(netorder) */
|
||||
|
||||
ENTRY(ntohs)
|
||||
clrl %d0
|
||||
movw %sp@(6),%d0
|
||||
rts
|
167
common/lib/libc/arch/m68k/string/bcmp.S
Normal file
167
common/lib/libc/arch/m68k/string/bcmp.S
Normal file
|
@ -0,0 +1,167 @@
|
|||
/* $NetBSD: bcmp.S,v 1.2 2008/04/28 20:22:52 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by J.T. Conklin.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* the Systems Programming Group of the University of Utah Computer
|
||||
* Science Department.
|
||||
*
|
||||
* 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 <machine/asm.h>
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
#if 0
|
||||
RCSID("from: @(#)bcmp.s 5.1 (Berkeley) 5/12/90")
|
||||
#else
|
||||
RCSID("$NetBSD: bcmp.S,v 1.2 2008/04/28 20:22:52 martin Exp $")
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
ENTRY(bcmp)
|
||||
movl %sp@(4),%a0 | string 1
|
||||
movl %sp@(8),%a1 | string 2
|
||||
movl %sp@(12),%d1 | length
|
||||
|
||||
/*
|
||||
* It isn't worth the overhead of aligning to {long}word boundries
|
||||
* if the string is too short.
|
||||
*/
|
||||
cmpl #8,%d1
|
||||
jlt Lbcbyte
|
||||
|
||||
#ifdef __mc68010__
|
||||
/*
|
||||
* The 68010 cannot access a word or long on an odd boundary,
|
||||
* period. If the source and the destination addresses aren't
|
||||
* of the same evenness, we're forced to do a bytewise compare.
|
||||
*/
|
||||
movl %a0,%d0
|
||||
addl %a1,%d0
|
||||
btst #0,%d0
|
||||
jne Lbcbyte
|
||||
#endif /* __mc68010__ */
|
||||
|
||||
/* word align */
|
||||
movl %a0,%d0
|
||||
btst #0,%d0
|
||||
jeq Lbcalgndw
|
||||
cmpmb %a0@+,%a1@+
|
||||
jne Lbcnoteq
|
||||
subql #1,%d1
|
||||
Lbcalgndw:
|
||||
/* long word align */
|
||||
btst #1,%d0
|
||||
jeq Lbcalgndl
|
||||
cmpmw %a0@+,%a1@+
|
||||
jne Lbcnoteq
|
||||
subql #2,%d1
|
||||
Lbcalgndl:
|
||||
/* compare by 8 longwords */
|
||||
movl %d1,%d0
|
||||
lsrl #5,%d0 | cnt = len / 32
|
||||
jeq Lbclong | if (cnt)
|
||||
andl #31,%d1 | len %= 32
|
||||
subql #1,%d0 | set up for dbf
|
||||
Lbc32loop:
|
||||
cmpml %a0@+,%a1@+ | compare 8 longwords
|
||||
jne Lbcnoteq | not equal, return non-zero
|
||||
cmpml %a0@+,%a1@+
|
||||
jne Lbcnoteq
|
||||
cmpml %a0@+,%a1@+
|
||||
jne Lbcnoteq
|
||||
cmpml %a0@+,%a1@+
|
||||
jne Lbcnoteq
|
||||
cmpml %a0@+,%a1@+
|
||||
jne Lbcnoteq
|
||||
cmpml %a0@+,%a1@+
|
||||
jne Lbcnoteq
|
||||
cmpml %a0@+,%a1@+
|
||||
jne Lbcnoteq
|
||||
cmpml %a0@+,%a1@+
|
||||
jne Lbcnoteq
|
||||
dbf %d0,Lbc32loop | till done
|
||||
clrw %d0
|
||||
subql #1,%d0
|
||||
jcc Lbc32loop
|
||||
|
||||
Lbclong:
|
||||
/* compare by longwords */
|
||||
movl %d1,%d0
|
||||
lsrl #2,%d0 | cnt = len / 4
|
||||
jeq Lbcbyte | if (cnt)
|
||||
subql #1,%d0 | set up for dbf
|
||||
Lbclloop:
|
||||
cmpml %a0@+,%a1@+ | compare a longword
|
||||
jne Lbcnoteq | not equal, return non-zero
|
||||
dbf %d0,Lbclloop | till done
|
||||
andl #3,%d1 | len %= 4
|
||||
jeq Lbcdone
|
||||
|
||||
subql #1,%d1 | set up for dbf
|
||||
Lbcbloop:
|
||||
cmpmb %a0@+,%a1@+ | compare a byte
|
||||
jne Lbcnoteq | not equal, return non-zero
|
||||
Lbcbyte:
|
||||
dbf %d1,Lbcbloop
|
||||
Lbcdone:
|
||||
movql #0,%d0
|
||||
rts
|
||||
|
||||
Lbcnoteq:
|
||||
movql #1,%d0
|
||||
rts
|
256
common/lib/libc/arch/m68k/string/bcopy.S
Normal file
256
common/lib/libc/arch/m68k/string/bcopy.S
Normal file
|
@ -0,0 +1,256 @@
|
|||
/* $NetBSD: bcopy.S,v 1.2 2008/04/28 20:22:52 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by J.T. Conklin.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* the Systems Programming Group of the University of Utah Computer
|
||||
* Science Department.
|
||||
*
|
||||
* 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 <machine/asm.h>
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
#if 0
|
||||
RCSID("from: @(#)bcopy.s 5.1 (Berkeley) 5/12/90")
|
||||
#else
|
||||
RCSID("$NetBSD: bcopy.S,v 1.2 2008/04/28 20:22:52 martin Exp $")
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
|
||||
#ifdef MEMCOPY
|
||||
ENTRY(memcpy)
|
||||
#else
|
||||
#ifdef MEMMOVE
|
||||
ENTRY(memmove)
|
||||
#else
|
||||
ENTRY(bcopy)
|
||||
#endif
|
||||
#endif
|
||||
#if defined(MEMCOPY) || defined(MEMMOVE)
|
||||
movl %sp@(4),%a1 | dest address
|
||||
movl %sp@(8),%a0 | src address
|
||||
#else
|
||||
movl %sp@(4),%a0 | src address
|
||||
movl %sp@(8),%a1 | dest address
|
||||
#endif
|
||||
movl %sp@(12),%d1 | count
|
||||
|
||||
cmpl %a1,%a0 | src after dest?
|
||||
jlt Lbcback | yes, must copy backwards
|
||||
|
||||
/*
|
||||
* It isn't worth the overhead of aligning to {long}word boundries
|
||||
* if the string is too short.
|
||||
*/
|
||||
cmpl #8,%d1
|
||||
jlt Lbcfbyte
|
||||
|
||||
#ifdef __mc68010__
|
||||
/*
|
||||
* The 68010 cannot access a word or long on an odd boundary,
|
||||
* period. If the source and the destination addresses aren't
|
||||
* of the same evenness, we're forced to do a bytewise copy.
|
||||
*/
|
||||
movl %a0,%d0
|
||||
addl %a1,%d0
|
||||
btst #0,%d0
|
||||
jne Lbcfbyte
|
||||
#endif /* __mc68010__ */
|
||||
|
||||
/* word align */
|
||||
movl %a1,%d0
|
||||
btst #0,%d0 | if (dst & 1)
|
||||
jeq Lbcfalgndw |
|
||||
movb %a0@+,%a1@+ | *(char *)dst++ = *(char *) src++
|
||||
subql #1,%d1 | len--
|
||||
Lbcfalgndw:
|
||||
/* long word align */
|
||||
btst #1,%d0 | if (dst & 2)
|
||||
jeq Lbcfalgndl
|
||||
movw %a0@+,%a1@+ | *(short *)dst++ = *(short *) dst++
|
||||
subql #2,%d1 | len -= 2
|
||||
Lbcfalgndl:
|
||||
/* copy by 8 longwords */
|
||||
movel %d1,%d0
|
||||
lsrl #5,%d0 | cnt = len / 32
|
||||
jeq Lbcflong | if (cnt)
|
||||
andl #31,%d1 | len %= 32
|
||||
subql #1,%d0 | set up for dbf
|
||||
Lbcf32loop:
|
||||
movl %a0@+,%a1@+ | copy 8 long words
|
||||
movl %a0@+,%a1@+
|
||||
movl %a0@+,%a1@+
|
||||
movl %a0@+,%a1@+
|
||||
movl %a0@+,%a1@+
|
||||
movl %a0@+,%a1@+
|
||||
movl %a0@+,%a1@+
|
||||
movl %a0@+,%a1@+
|
||||
dbf %d0,Lbcf32loop | till done
|
||||
clrw %d0
|
||||
subql #1,%d0
|
||||
jcc Lbcf32loop
|
||||
|
||||
Lbcflong:
|
||||
/* copy by longwords */
|
||||
movel %d1,%d0
|
||||
lsrl #2,%d0 | cnt = len / 4
|
||||
jeq Lbcfbyte | if (cnt)
|
||||
subql #1,%d0 | set up for dbf
|
||||
Lbcflloop:
|
||||
movl %a0@+,%a1@+ | copy longwords
|
||||
dbf %d0,Lbcflloop | til done
|
||||
andl #3,%d1 | len %= 4
|
||||
jeq Lbcdone
|
||||
|
||||
subql #1,%d1 | set up for dbf
|
||||
Lbcfbloop:
|
||||
movb %a0@+,%a1@+ | copy bytes
|
||||
Lbcfbyte:
|
||||
dbf %d1,Lbcfbloop | till done
|
||||
Lbcdone:
|
||||
#if defined(MEMCOPY) || defined(MEMMOVE)
|
||||
movl %sp@(4),%d0 | dest address
|
||||
#if defined(__SVR4_ABI__)
|
||||
moveal %d0,%a0
|
||||
#endif
|
||||
#endif
|
||||
rts
|
||||
|
||||
|
||||
Lbcback:
|
||||
addl %d1,%a0 | src pointer to end
|
||||
addl %d1,%a1 | dest pointer to end
|
||||
|
||||
/*
|
||||
* It isn't worth the overhead of aligning to {long}word boundries
|
||||
* if the string is too short.
|
||||
*/
|
||||
cmpl #8,%d1
|
||||
jlt Lbcbbyte
|
||||
|
||||
#ifdef __mc68010__
|
||||
/*
|
||||
* The 68010 cannot access a word or long on an odd boundary,
|
||||
* period. If the source and the destination addresses aren't
|
||||
* of the same evenness, we're forced to do a bytewise copy.
|
||||
*/
|
||||
movl %a0,%d0
|
||||
addl %a1,%d0
|
||||
btst #0,%d0
|
||||
jne Lbcbbyte
|
||||
#endif /* __mc68010__ */
|
||||
|
||||
/* word align */
|
||||
movl %a1,%d0
|
||||
btst #0,%d0 | if (dst & 1)
|
||||
jeq Lbcbalgndw |
|
||||
movb %a0@-,%a1@- | *(char *)dst-- = *(char *) src--
|
||||
subql #1,%d1 | len--
|
||||
Lbcbalgndw:
|
||||
/* long word align */
|
||||
btst #1,%d0 | if (dst & 2)
|
||||
jeq Lbcbalgndl
|
||||
movw %a0@-,%a1@- | *(short *)dst-- = *(short *) dst--
|
||||
subql #2,%d1 | len -= 2
|
||||
Lbcbalgndl:
|
||||
/* copy by 8 longwords */
|
||||
movel %d1,%d0
|
||||
lsrl #5,%d0 | cnt = len / 32
|
||||
jeq Lbcblong | if (cnt)
|
||||
andl #31,%d1 | len %= 32
|
||||
subql #1,%d0 | set up for dbf
|
||||
Lbcb32loop:
|
||||
movl %a0@-,%a1@- | copy 8 long words
|
||||
movl %a0@-,%a1@-
|
||||
movl %a0@-,%a1@-
|
||||
movl %a0@-,%a1@-
|
||||
movl %a0@-,%a1@-
|
||||
movl %a0@-,%a1@-
|
||||
movl %a0@-,%a1@-
|
||||
movl %a0@-,%a1@-
|
||||
dbf %d0,Lbcb32loop | till done
|
||||
clrw %d0
|
||||
subql #1,%d0
|
||||
jcc Lbcb32loop
|
||||
|
||||
Lbcblong:
|
||||
/* copy by longwords */
|
||||
movel %d1,%d0
|
||||
lsrl #2,%d0 | cnt = len / 4
|
||||
jeq Lbcbbyte | if (cnt)
|
||||
subql #1,%d0 | set up for dbf
|
||||
Lbcblloop:
|
||||
movl %a0@-,%a1@- | copy longwords
|
||||
dbf %d0,Lbcblloop | til done
|
||||
andl #3,%d1 | len %= 4
|
||||
jeq Lbcdone
|
||||
|
||||
subql #1,%d1 | set up for dbf
|
||||
Lbcbbloop:
|
||||
movb %a0@-,%a1@- | copy bytes
|
||||
Lbcbbyte:
|
||||
dbf %d1,Lbcbbloop | till done
|
||||
|
||||
#if defined(MEMCOPY) || defined(MEMMOVE)
|
||||
movl %sp@(4),%d0 | dest address
|
||||
#if defined(__SVR4_ABI__)
|
||||
moveal %d0,%a0
|
||||
#endif
|
||||
#endif
|
||||
rts
|
141
common/lib/libc/arch/m68k/string/bzero.S
Normal file
141
common/lib/libc/arch/m68k/string/bzero.S
Normal file
|
@ -0,0 +1,141 @@
|
|||
/* $NetBSD: bzero.S,v 1.2 2008/04/28 20:22:52 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by J.T. Conklin.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* the Systems Programming Group of the University of Utah Computer
|
||||
* Science Department.
|
||||
*
|
||||
* 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 <machine/asm.h>
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
#if 0
|
||||
RCSID("from: @(#)bzero.s 5.1 (Berkeley) 5/12/90")
|
||||
#else
|
||||
RCSID("$NetBSD: bzero.S,v 1.2 2008/04/28 20:22:52 martin Exp $")
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
ENTRY(bzero)
|
||||
movl %d2,%sp@-
|
||||
movl %sp@(8),%a0 | destination
|
||||
movl %sp@(12),%d1 | count
|
||||
|
||||
movql #0,%d2
|
||||
|
||||
/*
|
||||
* It isn't worth the overhead of aligning to {long}word boundries
|
||||
* if the string is too short.
|
||||
*/
|
||||
cmpl #8,%d1
|
||||
jlt Lbzbyte
|
||||
|
||||
/* word align */
|
||||
movl %a0,%d0
|
||||
btst #0,%d0 | if (dst & 1)
|
||||
jeq Lbzalgndw |
|
||||
movb %d2,%a0@+ | *(char *)dst++ = 0
|
||||
subql #1,%d1 | len--
|
||||
Lbzalgndw:
|
||||
/* long word align */
|
||||
btst #1,%d0 | if (dst & 2)
|
||||
jeq Lbzalgndl |
|
||||
movw %d2,%a0@+ | *(short *)dst++ = 0
|
||||
subql #2,%d1 | len -= 2
|
||||
Lbzalgndl:
|
||||
/* zero by 8 longwords */
|
||||
movel %d1,%d0
|
||||
lsrl #5,%d0 | cnt = len / 32
|
||||
jeq Lbzlong | if (cnt)
|
||||
andl #31,%d1 | len %= 32
|
||||
subql #1,%d0 | set up for dbf
|
||||
Lbz32loop:
|
||||
movl %d2,%a0@+ | zero 8 long words
|
||||
movl %d2,%a0@+
|
||||
movl %d2,%a0@+
|
||||
movl %d2,%a0@+
|
||||
movl %d2,%a0@+
|
||||
movl %d2,%a0@+
|
||||
movl %d2,%a0@+
|
||||
movl %d2,%a0@+
|
||||
dbf %d0,Lbz32loop | till done
|
||||
clrw %d0
|
||||
subql #1,%d0
|
||||
jcc Lbz32loop
|
||||
|
||||
Lbzlong:
|
||||
/* copy by longwords */
|
||||
movel %d1,%d0
|
||||
lsrl #2,%d0 | cnt = len / 4
|
||||
jeq Lbzbyte | if (cnt)
|
||||
subql #1,%d0 | set up for dbf
|
||||
Lbzlloop:
|
||||
movl %d2,%a0@+ | clear longwords
|
||||
dbf %d0,Lbzlloop | till done
|
||||
andl #3,%d1 | len %= 4
|
||||
jeq Lbzdone
|
||||
|
||||
subql #1,%d1 | set up for dbf
|
||||
Lbzbloop:
|
||||
movb %d2,%a0@+ | zero bytes
|
||||
Lbzbyte:
|
||||
dbf %d1,Lbzbloop | till done
|
||||
Lbzdone:
|
||||
movl %sp@+,%d2
|
||||
rts
|
74
common/lib/libc/arch/m68k/string/ffs.S
Normal file
74
common/lib/libc/arch/m68k/string/ffs.S
Normal file
|
@ -0,0 +1,74 @@
|
|||
/* $NetBSD: ffs.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* the Systems Programming Group of the University of Utah Computer
|
||||
* Science Department.
|
||||
*
|
||||
* 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 <machine/asm.h>
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
#if 0
|
||||
RCSID("from: @(#)ffs.s 5.1 (Berkeley) 5/12/90")
|
||||
#else
|
||||
RCSID("$NetBSD: ffs.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
/* bit = ffs(value) */
|
||||
|
||||
#ifndef __mc68010__
|
||||
|
||||
ENTRY(ffs)
|
||||
movl %sp@(4),%d0
|
||||
movl %d0,%d1
|
||||
negl %d0
|
||||
andl %d0,%d1
|
||||
movql #32,%d0
|
||||
bfffo %d1{#0:#32},%d1
|
||||
subl %d1,%d0
|
||||
rts
|
||||
|
||||
#else /* __mc68010__ */
|
||||
|
||||
ENTRY(ffs)
|
||||
movl %sp@(4),%d0
|
||||
jeq L2
|
||||
movql #31,%d1
|
||||
L1:
|
||||
lsrl #1,%d0
|
||||
dbcs %d1,L1
|
||||
movql #32,%d0
|
||||
subl %d1,%d0
|
||||
L2:
|
||||
rts
|
||||
|
||||
#endif /* __mc68010__ */
|
100
common/lib/libc/arch/m68k/string/memcmp.S
Normal file
100
common/lib/libc/arch/m68k/string/memcmp.S
Normal file
|
@ -0,0 +1,100 @@
|
|||
/* $NetBSD: memcmp.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* the Systems Programming Group of the University of Utah Computer
|
||||
* Science Department.
|
||||
*
|
||||
* 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 <machine/asm.h>
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
#if 0
|
||||
RCSID("from: @(#)bcmp.s 5.1 (Berkeley) 5/12/90")
|
||||
#else
|
||||
RCSID("$NetBSD: memcmp.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
/* memcmp(s1, s2, n) */
|
||||
|
||||
/*
|
||||
* This is probably not the best we can do, but it is still 2-10 times
|
||||
* faster than the C version in the portable gen directory.
|
||||
*
|
||||
* Things that might help:
|
||||
* - longword align when possible (only on the 68020)
|
||||
* - use nested DBcc instructions or use one and limit size to 64K
|
||||
*/
|
||||
ENTRY(memcmp)
|
||||
movl %sp@(4),%a0 | string 1
|
||||
movl %sp@(8),%a1 | string 2
|
||||
movl %sp@(12),%d0 | length
|
||||
jeq bcdone | if zero, nothing to do
|
||||
movl %a0,%d1
|
||||
btst #0,%d1 | string 1 address odd?
|
||||
jeq bceven | no, skip alignment
|
||||
cmpmb %a0@+,%a1@+ | yes, compare a byte
|
||||
jne bcnoteq | not equal, return non-zero
|
||||
subql #1,%d0 | adjust count
|
||||
jeq bcdone | count 0, reutrn zero
|
||||
bceven:
|
||||
movl %a1,%d1
|
||||
btst #0,%d1 | string 2 address odd?
|
||||
jne bcbloop | yes, no hope for alignment, compare bytes
|
||||
movl %d0,%d1 | no, both even
|
||||
lsrl #2,%d1 | convert count to longword count
|
||||
jeq bcbloop | count 0, skip longword loop
|
||||
bclloop:
|
||||
cmpml %a0@+,%a1@+ | compare a longword
|
||||
jne bcnoteql | not equal, return non-zero
|
||||
subql #1,%d1 | adjust count
|
||||
jne bclloop | still more, keep comparing
|
||||
andl #3,%d0 | what remains
|
||||
jeq bcdone | nothing, all done
|
||||
bcbloop:
|
||||
cmpmb %a0@+,%a1@+ | compare a byte
|
||||
jne bcnoteq | not equal, return non-zero
|
||||
subql #1,%d0 | adjust count
|
||||
jne bcbloop | still more, keep going
|
||||
rts
|
||||
bcnoteql:
|
||||
subql #4,%a0
|
||||
subql #4,%a1
|
||||
movl #4,%d0
|
||||
jra bcbloop
|
||||
bcnoteq:
|
||||
clrl %d0
|
||||
clrl %d1
|
||||
movb %a0@-,%d0
|
||||
movb %a1@-,%d1
|
||||
subl %d1,%d0
|
||||
bcdone:
|
||||
rts
|
4
common/lib/libc/arch/m68k/string/memcpy.S
Normal file
4
common/lib/libc/arch/m68k/string/memcpy.S
Normal file
|
@ -0,0 +1,4 @@
|
|||
/* $NetBSD: memcpy.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
|
||||
|
||||
#define MEMCOPY
|
||||
#include "bcopy.S"
|
4
common/lib/libc/arch/m68k/string/memmove.S
Normal file
4
common/lib/libc/arch/m68k/string/memmove.S
Normal file
|
@ -0,0 +1,4 @@
|
|||
/* $NetBSD: memmove.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
|
||||
|
||||
#define MEMMOVE
|
||||
#include "bcopy.S"
|
162
common/lib/libc/arch/m68k/string/memset.S
Normal file
162
common/lib/libc/arch/m68k/string/memset.S
Normal file
|
@ -0,0 +1,162 @@
|
|||
/* $NetBSD: memset.S,v 1.2 2008/04/28 20:22:52 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by J.T. Conklin.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* the Systems Programming Group of the University of Utah Computer
|
||||
* Science Department.
|
||||
*
|
||||
* 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 <machine/asm.h>
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
#if 0
|
||||
RCSID("from: @(#)bzero.s 5.1 (Berkeley) 5/12/90")
|
||||
#else
|
||||
RCSID("$NetBSD: memset.S,v 1.2 2008/04/28 20:22:52 martin Exp $")
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
ENTRY(memset)
|
||||
movl %d2,%sp@-
|
||||
movl %sp@(8),%a0 | destination
|
||||
movl %sp@(16),%d1 | count
|
||||
movb %sp@(15),%d2 | character
|
||||
|
||||
/*
|
||||
* It isn't worth the overhead of aligning to {long}word boundries
|
||||
* if the string is too short.
|
||||
*/
|
||||
cmpl #15,%d1
|
||||
jlt Lbzbyte
|
||||
|
||||
clrl %d0 | replicate byte to fill longword
|
||||
movb %d2,%d0
|
||||
movl %d0,%d2
|
||||
lsll #8,%d0
|
||||
orl %d0,%d2
|
||||
lsll #8,%d0
|
||||
orl %d0,%d2
|
||||
lsll #8,%d0
|
||||
orl %d0,%d2
|
||||
|
||||
/* word align */
|
||||
movl %a0,%d0
|
||||
btst #0,%d0 | if (dst & 1)
|
||||
jeq Lbzalgndw |
|
||||
movb %d2,%a0@+ | *(char *)dst++ = X
|
||||
subql #1,%d1 | len--
|
||||
addql #1,%d0
|
||||
Lbzalgndw:
|
||||
#ifndef __mc68010__
|
||||
/* long word align */
|
||||
btst #1,%d0 | if (dst & 2)
|
||||
jeq Lbzalgndl |
|
||||
movw %d2,%a0@+ | *(short *)dst++ = X
|
||||
subql #2,%d1 | len -= 2
|
||||
Lbzalgndl:
|
||||
/* set by 8 longwords */
|
||||
movel %d1,%d0
|
||||
lsrl #5,%d0 | cnt = len / 32
|
||||
jeq Lbzlong | if (cnt)
|
||||
andl #31,%d1 | len %= 32
|
||||
subql #1,%d0 | set up for dbf
|
||||
Lbz32loop:
|
||||
movl %d2,%a0@+ | set 8 long words
|
||||
movl %d2,%a0@+
|
||||
movl %d2,%a0@+
|
||||
movl %d2,%a0@+
|
||||
movl %d2,%a0@+
|
||||
movl %d2,%a0@+
|
||||
movl %d2,%a0@+
|
||||
movl %d2,%a0@+
|
||||
dbf %d0,Lbz32loop | till done
|
||||
clrw %d0
|
||||
subql #1,%d0
|
||||
jcc Lbz32loop
|
||||
#endif /* !__mc68010__ */
|
||||
|
||||
Lbzlong:
|
||||
/* set by longwords */
|
||||
movel %d1,%d0
|
||||
lsrl #2,%d0 | cnt = len / 4
|
||||
jeq Lbzbyte | if (cnt)
|
||||
subql #1,%d0 | set up for dbf
|
||||
Lbzlloop:
|
||||
movl %d2,%a0@+ | clear longwords
|
||||
dbf %d0,Lbzlloop | till done
|
||||
#ifdef __mc68010__
|
||||
clrw %d0
|
||||
subql #1,%d0
|
||||
jcc Lbzlloop
|
||||
#endif /* __mc68010__ */
|
||||
andl #3,%d1 | len %= 4
|
||||
jeq Lbzdone
|
||||
|
||||
subql #1,%d1 | set up for dbf
|
||||
Lbzbloop:
|
||||
movb %d2,%a0@+ | set bytes
|
||||
Lbzbyte:
|
||||
dbf %d1,Lbzbloop | till done
|
||||
Lbzdone:
|
||||
movl %sp@(8),%d0 | return destination
|
||||
#ifdef __SVR4_ABI__
|
||||
moveal %d0,%a0
|
||||
#endif
|
||||
movl %sp@+,%d2
|
||||
rts
|
60
common/lib/libc/arch/m68k/string/strcat.S
Normal file
60
common/lib/libc/arch/m68k/string/strcat.S
Normal file
|
@ -0,0 +1,60 @@
|
|||
/* $NetBSD: strcat.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* the Systems Programming Group of the University of Utah Computer
|
||||
* Science Department.
|
||||
*
|
||||
* 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 <machine/asm.h>
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
#if 0
|
||||
RCSID("from: @(#)strcpy.s 5.1 (Berkeley) 5/12/90")
|
||||
#else
|
||||
RCSID("$NetBSD: strcat.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
ENTRY(strcat)
|
||||
movl %sp@(8),%a0 | a0 = fromaddr
|
||||
movl %sp@(4),%d0 | return value is toaddr
|
||||
movl %d0,%a1 | a1 = toaddr
|
||||
Lslloop:
|
||||
tstb %a1@+ | null?
|
||||
jne Lslloop | no, keep going
|
||||
subql #1,%a1
|
||||
Lscloop:
|
||||
movb %a0@+,%a1@+ | copy a byte
|
||||
jne Lscloop | copied non-null, keep going
|
||||
#ifdef __SVR4_ABI__
|
||||
moveal %d0,%a0
|
||||
#endif
|
||||
rts
|
63
common/lib/libc/arch/m68k/string/strchr.S
Normal file
63
common/lib/libc/arch/m68k/string/strchr.S
Normal file
|
@ -0,0 +1,63 @@
|
|||
/* $NetBSD: strchr.S,v 1.2 2009/07/17 19:37:57 dsl Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* the Systems Programming Group of the University of Utah Computer
|
||||
* Science Department.
|
||||
*
|
||||
* 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 <machine/asm.h>
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
#if 0
|
||||
RCSID("from: @(#)index.s 5.1 (Berkeley) 5/12/90")
|
||||
#else
|
||||
RCSID("$NetBSD: strchr.S,v 1.2 2009/07/17 19:37:57 dsl Exp $")
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
ENTRY(strchr)
|
||||
movl %sp@(4),%a0 | string
|
||||
movb %sp@(11),%d0 | char to look for
|
||||
ixloop:
|
||||
cmpb %a0@,%d0 | found our char?
|
||||
jeq ixfound | yes, break out
|
||||
tstb %a0@+ | null?
|
||||
jne ixloop | no, keep going
|
||||
moveq #0,%d0 | not found, return null
|
||||
#ifdef __SVR4_ABI__
|
||||
moveal %d0,%a0
|
||||
#endif
|
||||
rts
|
||||
ixfound:
|
||||
movl %a0,%d0 | found, return pointer
|
||||
rts
|
||||
|
||||
STRONG_ALIAS(index,strchr)
|
71
common/lib/libc/arch/m68k/string/strcmp.S
Normal file
71
common/lib/libc/arch/m68k/string/strcmp.S
Normal file
|
@ -0,0 +1,71 @@
|
|||
/* $NetBSD: strcmp.S,v 1.2 2008/04/28 20:22:52 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Hiroshi Horimoto <horimoto@cs-aoi.cs.sist.ac.jp> and
|
||||
* by J.T. Conklin <jtc@NetBSD.org>.
|
||||
*
|
||||
* 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 <machine/asm.h>
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
RCSID("$NetBSD: strcmp.S,v 1.2 2008/04/28 20:22:52 martin Exp $")
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
ENTRY(strcmp)
|
||||
movl %sp@(4),%a0
|
||||
movl %sp@(8),%a1
|
||||
L1: /* unrolled by 4 for 680[23]0's */
|
||||
movb %a0@+,%d1
|
||||
jeq L2
|
||||
subb %a1@+,%d1
|
||||
jne L3
|
||||
|
||||
movb %a0@+,%d1
|
||||
jeq L2
|
||||
subb %a1@+,%d1
|
||||
jne L3
|
||||
|
||||
movb %a0@+,%d1
|
||||
jeq L2
|
||||
subb %a1@+,%d1
|
||||
jne L3
|
||||
|
||||
movb %a0@+,%d1
|
||||
jeq L2
|
||||
subb %a1@+,%d1
|
||||
jeq L1
|
||||
|
||||
L3: scs %d0
|
||||
EXTBL(%d0)
|
||||
movb %d1,%d0
|
||||
rts
|
||||
|
||||
L2: movq #0,%d0
|
||||
movb %a1@,%d0
|
||||
negl %d0
|
||||
rts
|
56
common/lib/libc/arch/m68k/string/strcpy.S
Normal file
56
common/lib/libc/arch/m68k/string/strcpy.S
Normal file
|
@ -0,0 +1,56 @@
|
|||
/* $NetBSD: strcpy.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* the Systems Programming Group of the University of Utah Computer
|
||||
* Science Department.
|
||||
*
|
||||
* 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 <machine/asm.h>
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
#if 0
|
||||
RCSID("from: @(#)strcpy.s 5.1 (Berkeley) 5/12/90")
|
||||
#else
|
||||
RCSID("$NetBSD: strcpy.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
ENTRY(strcpy)
|
||||
movl %sp@(8),%a0 | a0 = fromaddr
|
||||
movl %sp@(4),%d0 | return value is toaddr
|
||||
movl %d0,%a1 | a1 = toaddr
|
||||
Lscloop:
|
||||
movb %a0@+,%a1@+ | copy a byte
|
||||
jne Lscloop | copied non-null, keep going
|
||||
#ifdef __SVR4_ABI__
|
||||
moveal %d0,%a0
|
||||
#endif
|
||||
rts
|
54
common/lib/libc/arch/m68k/string/strlen.S
Normal file
54
common/lib/libc/arch/m68k/string/strlen.S
Normal file
|
@ -0,0 +1,54 @@
|
|||
/* $NetBSD: strlen.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* the Systems Programming Group of the University of Utah Computer
|
||||
* Science Department.
|
||||
*
|
||||
* 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 <machine/asm.h>
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
#if 0
|
||||
RCSID("from: @(#)strlen.s 5.1 (Berkeley) 5/12/90")
|
||||
#else
|
||||
RCSID("$NetBSD: strlen.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
ENTRY(strlen)
|
||||
movl %sp@(4),%a0 | string
|
||||
movl %a0,%d0
|
||||
notl %d0
|
||||
Lslloop:
|
||||
tstb %a0@+ | null?
|
||||
jne Lslloop | no, keep going
|
||||
addl %a0,%d0
|
||||
rts
|
78
common/lib/libc/arch/m68k/string/strncmp.S
Normal file
78
common/lib/libc/arch/m68k/string/strncmp.S
Normal file
|
@ -0,0 +1,78 @@
|
|||
/* $NetBSD: strncmp.S,v 1.2 2008/04/28 20:22:52 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Hiroshi Horimoto <horimoto@cs-aoi.cs.sist.ac.jp> and
|
||||
* by J.T. Conklin <jtc@NetBSD.org>.
|
||||
*
|
||||
* 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 <machine/asm.h>
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
RCSID("$NetBSD: strncmp.S,v 1.2 2008/04/28 20:22:52 martin Exp $")
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
ENTRY(strncmp)
|
||||
movl %sp@(12),%d0
|
||||
jeq L4
|
||||
movl %sp@(4),%a0
|
||||
movl %sp@(8),%a1
|
||||
L1: /* unroll by 4 for m680[23]0's */
|
||||
movb %a0@+,%d1
|
||||
jeq L2
|
||||
subb %a1@+,%d1
|
||||
jne L3
|
||||
subql #1,%d0
|
||||
jeq L4
|
||||
|
||||
movb %a0@+,%d1
|
||||
jeq L2
|
||||
subb %a1@+,%d1
|
||||
jne L3
|
||||
subql #1,%d0
|
||||
jeq L4
|
||||
|
||||
movb %a0@+,%d1
|
||||
jeq L2
|
||||
subb %a1@+,%d1
|
||||
jne L3
|
||||
subql #1,%d0
|
||||
jeq L4
|
||||
|
||||
movb %a0@+,%d1
|
||||
jeq L2
|
||||
subb %a1@+,%d1
|
||||
jne L3
|
||||
subql #1,%d0
|
||||
jne L1
|
||||
L4: rts
|
||||
|
||||
L2: subb %a1@,%d1
|
||||
L3: scs %d0
|
||||
EXTBL(%d0)
|
||||
movb %d1,%d0
|
||||
rts
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue