diff options
author | Dale Rahn <drahn@cvs.openbsd.org> | 2005-12-14 19:42:26 +0000 |
---|---|---|
committer | Dale Rahn <drahn@cvs.openbsd.org> | 2005-12-14 19:42:26 +0000 |
commit | b4dd2134f7764ae61583b89d15009b76214c5ac8 (patch) | |
tree | 6b2153fc3fbb27d50a6cf80f014518b32d422eab /lib/librthread | |
parent | 91c9d7dd77056cbaaa771219196c1e2ba3372c03 (diff) |
Initial versions of arm code, in-tree development (not yet working).
Diffstat (limited to 'lib/librthread')
-rw-r--r-- | lib/librthread/arch/arm/_atomic_lock.c | 43 | ||||
-rw-r--r-- | lib/librthread/arch/arm/rfork_thread.S | 46 |
2 files changed, 89 insertions, 0 deletions
diff --git a/lib/librthread/arch/arm/_atomic_lock.c b/lib/librthread/arch/arm/_atomic_lock.c new file mode 100644 index 00000000000..094a3c4c27f --- /dev/null +++ b/lib/librthread/arch/arm/_atomic_lock.c @@ -0,0 +1,43 @@ +/* $OpenBSD: _atomic_lock.c,v 1.1 2005/12/14 19:42:25 drahn Exp $ */ + +/* + * Copyright (c) 2004 Dale Rahn. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE 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. + */ + +/* + * Atomic lock for arm + */ + +#include "spinlock.h" + +int +_atomic_lock(volatile _spinlock_lock_t *lock) +{ + _spinlock_lock_t old; + + __asm__("swp %0, %2, [%1]" + : "=r" (old), "=r" (lock) + : "r" (_SPINLOCK_LOCKED), "1" (lock) ); + + return (old != _SPINLOCK_UNLOCKED); +} diff --git a/lib/librthread/arch/arm/rfork_thread.S b/lib/librthread/arch/arm/rfork_thread.S new file mode 100644 index 00000000000..ad6ebb408c2 --- /dev/null +++ b/lib/librthread/arch/arm/rfork_thread.S @@ -0,0 +1,46 @@ +/* $OpenBSD: rfork_thread.S,v 1.1 2005/12/14 19:42:25 drahn Exp $ */ +/* + * Copyright (c) 2005 Dale Rahn <drahn@openbsd.org> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ +#include <sys/syscall.h> +#include <machine/asm.h> +#include "../../../libc/arch/arm/SYS.h" + +/* + * r0 r1 r2 r3 + * rfork_thread(flags, stack_addr, start_fnc, start_arg); + */ + +ENTRY(rfork_thread) + stmdb sp!, {r1-r4,sl,fp,lr} + + + SYSTRAP(rfork) + bcs 1f + + /* check if we are parent or child */ + cmp r0, #0 + ldmia sp!, {r1-r4,sl,fp,lr} + movne pc, lr + + /* child */ + mov sp, r1 + mov r0, r3 + mov lr, pc + mov pc, r2 + SYSTRAP(exit) +1: + ldmia sp!, {r1-r4,sl,fp,lr} + b PIC_SYM(CERROR, PLT) |