diff options
Diffstat (limited to 'lib/libpthread/arch')
54 files changed, 0 insertions, 2774 deletions
diff --git a/lib/libpthread/arch/alpha/uthread_machdep.c b/lib/libpthread/arch/alpha/uthread_machdep.c deleted file mode 100644 index fa9c604d06f..00000000000 --- a/lib/libpthread/arch/alpha/uthread_machdep.c +++ /dev/null @@ -1,49 +0,0 @@ -/* $OpenBSD: uthread_machdep.c,v 1.2 2002/05/10 10:17:22 art Exp $ */ -/* David Leonard, <d@csee.uq.edu.au>. Public domain. */ - -/* - * Machine-dependent thread state functions for OpenBSD/alpha - */ - -#include <pthread.h> -#include "pthread_private.h" - -#define ALIGNBYTES 15 - -struct frame { - long ra; - long s[7]; - long t12; - long fs[8]; -}; - -/* - * Given a stack and an entry function, initialise a state - * structure that can be later switched to. - */ -void -_thread_machdep_init(statep, base, len, entry) - struct _machdep_state* statep; - void *base; - int len; - void (*entry)(void); -{ - struct frame *f; - - f = (struct frame *)(((u_int64_t)base + len - sizeof *f) & ~ALIGNBYTES); - f->ra = f->t12 = (u_int64_t)entry; - - statep->sp = (u_int64_t)f; -} - -void -_thread_machdep_save_float_state(statep) - struct _machdep_state* statep; -{ -} - -void -_thread_machdep_restore_float_state(statep) - struct _machdep_state* statep; -{ -} diff --git a/lib/libpthread/arch/alpha/uthread_machdep.h b/lib/libpthread/arch/alpha/uthread_machdep.h deleted file mode 100644 index 9bd580d5f1c..00000000000 --- a/lib/libpthread/arch/alpha/uthread_machdep.h +++ /dev/null @@ -1,6 +0,0 @@ -/* $OpenBSD: uthread_machdep.h,v 1.8 2002/01/04 14:46:18 art Exp $ */ -/* David Leonard, <d@csee.uq.edu.au>. Public domain. */ - -struct _machdep_state { - u_int64_t sp; -}; diff --git a/lib/libpthread/arch/alpha/uthread_machdep_asm.S b/lib/libpthread/arch/alpha/uthread_machdep_asm.S deleted file mode 100644 index 054d8a52d22..00000000000 --- a/lib/libpthread/arch/alpha/uthread_machdep_asm.S +++ /dev/null @@ -1,79 +0,0 @@ -/* $OpenBSD: uthread_machdep_asm.S,v 1.4 2002/12/12 18:26:18 marc Exp $ */ -/* David Leonard, <d@csee.uq.edu.au>. Public domain. */ - -#include <machine/asm.h> - -#define INTOFF(n) ((n)*8) -#define FPOFF(n) (INTOFF(9) + (n)*8) -#define ALIGN(x) (((x)+15)&~15) -#define FRAMESIZE ALIGN(FPOFF(8)) - - .set noreorder - .globl _thread_machdep_switch - .ent _thread_machdep_switch, 2 -_thread_machdep_switch: - .frame sp, FRAMESIZE, ra - ldgp gp, 0(pv) - lda sp, -FRAMESIZE(sp) - - stq ra, INTOFF(0)(sp) - stq s0, INTOFF(1)(sp) - stq s1, INTOFF(2)(sp) - stq s2, INTOFF(3)(sp) - stq s3, INTOFF(4)(sp) - stq s4, INTOFF(5)(sp) - stq s5, INTOFF(6)(sp) - stq s6, INTOFF(7)(sp) - stq t12, INTOFF(8)(sp) - - stt fs0, FPOFF(0)(sp) - stt fs1, FPOFF(1)(sp) - stt fs2, FPOFF(2)(sp) - stt fs3, FPOFF(3)(sp) - stt fs4, FPOFF(4)(sp) - stt fs5, FPOFF(5)(sp) - stt fs6, FPOFF(6)(sp) - stt fs7, FPOFF(7)(sp) - - stq sp, 0(a1) - or a0, zero, pv - ldq sp, 0(a0) - - ldt fs7, FPOFF(7)(sp) - ldt fs6, FPOFF(6)(sp) - ldt fs5, FPOFF(5)(sp) - ldt fs4, FPOFF(4)(sp) - ldt fs3, FPOFF(3)(sp) - ldt fs2, FPOFF(2)(sp) - ldt fs1, FPOFF(1)(sp) - ldt fs0, FPOFF(0)(sp) - - ldq t12, INTOFF(8)(sp) - ldq s6, INTOFF(7)(sp) - ldq s5, INTOFF(6)(sp) - ldq s4, INTOFF(5)(sp) - ldq s3, INTOFF(4)(sp) - ldq s2, INTOFF(3)(sp) - ldq s1, INTOFF(2)(sp) - ldq s0, INTOFF(1)(sp) - ldq ra, INTOFF(0)(sp) - - lda sp,FRAMESIZE(sp) - RET - - .end _thread_machdep_switch - -LEAF(_atomic_lock,1) - LDGP(pv) - - /* NOTE: using ldl_l/stl_c instead of - ldq_l and ldq_c as machine/spinlock.h - defines _spinlock_lock_t as int */ -0: ldl_l v0, 0(a0) /* read existing lock value */ - mov 1, t0 /* locked value to store */ - stl_c t0, 0(a0) /* attempt to store, status in t0 */ - beq t0, 1f /* branch forward to optimise prediction */ - mb /* sync with other processors */ - RET /* return with v0==0 if lock obtained */ -1: br 0b /* loop to try again */ -END(_atomic_lock) diff --git a/lib/libpthread/arch/amd64/_atomic_lock.c b/lib/libpthread/arch/amd64/_atomic_lock.c deleted file mode 100644 index e2cadd6f26a..00000000000 --- a/lib/libpthread/arch/amd64/_atomic_lock.c +++ /dev/null @@ -1,26 +0,0 @@ -/* $OpenBSD: _atomic_lock.c,v 1.4 2009/06/01 22:52:38 guenther Exp $ */ - -/* David Leonard, <d@csee.uq.edu.au>. Public domain. */ - -/* - * Atomic lock for amd64 -- taken from i386 code. - */ - -#include "spinlock.h" - -int -_atomic_lock(volatile _spinlock_lock_t *lock) -{ - _spinlock_lock_t old; - - /* - * Use the eXCHanGe instruction to swap the lock value with - * a local variable containing the locked state. - */ - old = _SPINLOCK_LOCKED; - __asm__("xchg %0,(%2)" - : "=r" (old) - : "0" (old), "r" (lock)); - - return (old != _SPINLOCK_UNLOCKED); -} diff --git a/lib/libpthread/arch/amd64/uthread_machdep.c b/lib/libpthread/arch/amd64/uthread_machdep.c deleted file mode 100644 index 29a8de00718..00000000000 --- a/lib/libpthread/arch/amd64/uthread_machdep.c +++ /dev/null @@ -1,108 +0,0 @@ -/* $OpenBSD: uthread_machdep.c,v 1.5 2011/01/04 05:34:09 guenther Exp $ */ - -/* - * Copyright (c) 2004 Theo de Raadt - * - * 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 <machine/param.h> -#include <pthread.h> -#include "pthread_private.h" - -struct frame { - long fr_gs; - long fr_fs; - long fr_es; - long fr_ds; - - long flag; - long fr_r15; - long fr_r14; - long fr_r13; - long fr_r12; - - long fr_r11; - long fr_r10; - long fr_r9; - long fr_r8; - - long fr_rdi; - long fr_rsi; - long fr_rbp; - - long fr_rbx; - long fr_rdx; - long fr_rcx; - long fr_rax; - - long fr_rip; - int fr_cs; /* XXX unreachable? */ - int pad; -}; - -#define copyreg(reg, lval) \ - __asm__("mov %%" #reg ", %0" : "=g"(lval)) - -/* - * Given a stack and an entry function, initialise a state - * structure that can be later switched to. - */ -void -_thread_machdep_init(struct _machdep_state* statep, void *base, int len, - void (*entry)(void)) -{ - struct frame *f; - int foo; - - /* Locate the initial frame, aligned at the top of the stack */ - f = (struct frame *)(((long)base + len - sizeof *f) & ~ALIGNBYTES); - - copyreg(cs, foo); - f->fr_cs = foo; - copyreg(ds, foo); - f->fr_ds = foo; - copyreg(es, foo); - f->fr_es = foo; - copyreg(fs, foo); - f->fr_fs = foo; - copyreg(gs, foo); - f->fr_gs = foo; - - f->fr_rbp = (long)-1; - f->fr_rip = (long)entry; - - statep->rsp = (long)f; - - _thread_machdep_save_float_state(statep); -} - -#define fxsave(addr) __asm("fxsave %0" : "=m" (*addr)) -#define fxrstor(addr) __asm("fxrstor %0" : : "m" (*addr)) -#define fwait() __asm("fwait") -#define fninit() __asm("fninit") - -void -_thread_machdep_save_float_state(struct _machdep_state *ms) -{ - fxsave(&ms->fpreg); - fninit(); - fwait(); -} - -void -_thread_machdep_restore_float_state(struct _machdep_state *ms) -{ - fxrstor(&ms->fpreg); -} diff --git a/lib/libpthread/arch/amd64/uthread_machdep.h b/lib/libpthread/arch/amd64/uthread_machdep.h deleted file mode 100644 index 34532db8b48..00000000000 --- a/lib/libpthread/arch/amd64/uthread_machdep.h +++ /dev/null @@ -1,26 +0,0 @@ -/* $OpenBSD: uthread_machdep.h,v 1.3 2004/02/25 04:10:53 deraadt Exp $ */ - -/* - * Copyright (c) 2004 Theo de Raadt - * - * 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/types.h> -#include <machine/fpu.h> - -struct _machdep_state { - long rsp; - /* must be 128-bit aligned */ - struct savefpu fpreg __attribute__ ((aligned (16))); -}; diff --git a/lib/libpthread/arch/amd64/uthread_machdep_asm.S b/lib/libpthread/arch/amd64/uthread_machdep_asm.S deleted file mode 100644 index 818d157de93..00000000000 --- a/lib/libpthread/arch/amd64/uthread_machdep_asm.S +++ /dev/null @@ -1,88 +0,0 @@ -/* $OpenBSD: uthread_machdep_asm.S,v 1.3 2004/02/25 04:10:53 deraadt Exp $ */ - -/* - * Copyright (c) 2004 Theo de Raadt - * - * 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 <machine/asm.h> - -/* - * Switch stacks - */ - -/* void _thread_machdep_switch(new, oldsave); */ -ENTRY(_thread_machdep_switch) - pushq %rax - pushq %rcx - pushq %rdx - pushq %rbx - - pushq %rbp - pushq %rsi - pushq %rdi - - pushq %r8 - pushq %r9 - pushq %r10 - pushq %r11 - - pushq %r12 - pushq %r13 - pushq %r14 - pushq %r15 - movq $0xdeaf12345678beaf, %r15 - pushq %r15 - - movl %ds,%eax - pushq %rax - movl %es,%eax - pushq %rax - movl %fs,%eax - pushq %rax - movl %gs,%eax - pushq %rax - - movq %rsp, 0(%rsi) /* *arg2 = %rsp */ - movq 0(%rdi), %rsp /* %rsp = *arg1 */ - - popq %rax - movl %eax,%gs - popq %rax - movl %eax,%fs - popq %rax - movl %eax,%es - popq %rax - movl %eax,%ds - - popq %r15 # flag word. - popq %r15 - popq %r14 - popq %r13 - popq %r12 - - popq %r11 - popq %r10 - popq %r9 - popq %r8 - - popq %rdi - popq %rsi - popq %rbp - - popq %rbx - popq %rdx - popq %rcx - popq %rax - ret diff --git a/lib/libpthread/arch/arm/_atomic_lock.c b/lib/libpthread/arch/arm/_atomic_lock.c deleted file mode 100644 index 94637a13b74..00000000000 --- a/lib/libpthread/arch/arm/_atomic_lock.c +++ /dev/null @@ -1,43 +0,0 @@ -/* $OpenBSD: _atomic_lock.c,v 1.2 2004/02/09 15:27:12 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/libpthread/arch/arm/uthread_machdep.c b/lib/libpthread/arch/arm/uthread_machdep.c deleted file mode 100644 index 469d5a43a16..00000000000 --- a/lib/libpthread/arch/arm/uthread_machdep.c +++ /dev/null @@ -1,109 +0,0 @@ -/* $OpenBSD: uthread_machdep.c,v 1.6 2011/08/03 20:19:46 miod 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. - */ - -#include <pthread.h> -#include "pthread_private.h" - -#define ALIGNBYTES 0x7 - -/* Register save frame as it appears on the stack */ -struct frame { - int r[12-4]; - int fp; /* r12 */ - int ip; /* r13 */ - int lr; /* r14 */ - int cpsr; - double fpr[6]; /* sizeof(fp)+sizeof(fs) == 52 */ - int fs; - /* The rest are only valid in the initial frame */ - int next_fp; - int next_ip; - int next_lr; - int oldpc; -}; - -/* - * Given a stack and an entry function, initialise a state - * structure that can be later switched to. - */ -void -_thread_machdep_init(statep, base, len, entry) - struct _machdep_state* statep; - void *base; - int len; - void (*entry)(void); -{ - struct frame *f; - int cpsr; - - /* Locate the initial frame, aligned at the top of the stack */ - f = (struct frame *)(((int)base + len - sizeof *f) & ~ALIGNBYTES); - - f->fp = (int)&f->next_fp; - f->ip = (int)0; - f->lr = (int)entry; - f->next_fp = 0; /* for gdb */ - f->next_lr = 0; /* for gdb */ - - /* Initialise the new thread with all the state from this thread. */ - - __asm__ volatile ("mrs %0, cpsr_all" : "=r" (cpsr)); - f->cpsr = cpsr; - - __asm__ volatile ("stmia %0, {r4-r12}":: "r"(&f->r[0])); - -#ifndef __SOFTFP__ - __asm__ volatile ("sfm f4, 4, [%0], #0":: "r"(&f->fpr[0])); - - __asm__ volatile ("rfs 0; stfd 0, %0" : "=m"(f->fs)); -#endif - - statep->frame = (int)f; -} - - -/* - * No-op float saves. - * (Floating point registers were saved in _thread_machdep_switch()) - */ - -void -_thread_machdep_save_float_state(statep) - struct _machdep_state* statep; -{ -#if !defined(__SOFTFP__) && !defined (__lint__) -#error finish FP save -#endif -} - -void -_thread_machdep_restore_float_state(statep) - struct _machdep_state* statep; -{ -#if !defined(__SOFTFP__) && !defined (__lint__) -#error finish FP save -#endif -} diff --git a/lib/libpthread/arch/arm/uthread_machdep.h b/lib/libpthread/arch/arm/uthread_machdep.h deleted file mode 100644 index 7572667faf1..00000000000 --- a/lib/libpthread/arch/arm/uthread_machdep.h +++ /dev/null @@ -1,30 +0,0 @@ -/* $OpenBSD: uthread_machdep.h,v 1.2 2004/02/25 04:16:54 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. - */ - -struct _machdep_state { - int frame; -}; - diff --git a/lib/libpthread/arch/arm/uthread_machdep_asm.S b/lib/libpthread/arch/arm/uthread_machdep_asm.S deleted file mode 100644 index 272f8c3bf39..00000000000 --- a/lib/libpthread/arch/arm/uthread_machdep_asm.S +++ /dev/null @@ -1,76 +0,0 @@ -/* $OpenBSD: uthread_machdep_asm.S,v 1.2 2004/02/21 05:29:16 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. - */ - -#include <machine/asm.h> - -/* THESE MUST BE IN SYNC WITH uthread_machdep.c:struct frame */ -#define OFFSET_R 0 /* offsetof(struct frame, r) */ -#define OFFSET_FP ((12-4)*4) -#define OFFSET_LR (OFFSET_FP+4) -#define OFFSET_CPSR (OFFSET_LR+4) -#define OFFSET_FPR (OFFSET_CPSR+4) -#define OFFSET_FS (OFFSET_FPR+(6*8)) -#define FRAME_SIZE (OFFSET_FS+4) - - -/* - * r0 is pointer to new save area - restore from here - * r1 is pointer to old save area - put pointer to stack save area here - */ -ENTRY(_thread_machdep_switch) - mov ip, sp - sub sp, sp, #FRAME_SIZE+4 - add r2, sp, #4 - stmia r2, {r4-r11} - str fp, [r2, #OFFSET_FP] - str lr, [r2, #OFFSET_LR] - - mrs r3, cpsr_all - str r3, [r2, #OFFSET_CPSR] -#ifndef __VFP_FP__ - sfm f4, 4, [r2, #OFFSET_FPR] - rfs r3 - str r3, [r2, #OFFSET_FS] -#endif - - str sp, [r1, #0] - ldr sp, [r0, #0] - add r2, sp, #4 - - ldmfd r2, {r4-r11} - ldr fp, [r2, #OFFSET_FP] - ldr lr, [r2, #OFFSET_LR] - - ldr r3, [r2, #OFFSET_CPSR] - msr cpsr_f, r3 -#ifndef __VFP_FP__ - lfm f4, 4, [r2, #OFFSET_FPR] - ldr r3, [r2, #OFFSET_FS] - wfs r3 -#endif - - add sp, sp, #FRAME_SIZE+4 - mov pc, lr diff --git a/lib/libpthread/arch/hppa/_atomic_lock.c b/lib/libpthread/arch/hppa/_atomic_lock.c deleted file mode 100644 index 427a8108d95..00000000000 --- a/lib/libpthread/arch/hppa/_atomic_lock.c +++ /dev/null @@ -1,15 +0,0 @@ -/* $OpenBSD: _atomic_lock.c,v 1.3 2011/11/14 15:16:12 jsing Exp $ */ -/* - * Atomic lock for hppa - */ -#include "spinlock.h" - -int -_atomic_lock(volatile _spinlock_lock_t *lock) -{ - register register_t old; - - __asm__("ldcws 0(%1), %0" : "=r" (old): "r" (lock)); - - return (old == _SPINLOCK_LOCKED); -} diff --git a/lib/libpthread/arch/hppa/uthread_machdep.h b/lib/libpthread/arch/hppa/uthread_machdep.h deleted file mode 100644 index cb9325f7c7c..00000000000 --- a/lib/libpthread/arch/hppa/uthread_machdep.h +++ /dev/null @@ -1,7 +0,0 @@ -/* $OpenBSD: uthread_machdep.h,v 1.6 2002/11/01 00:05:45 mickey Exp $ */ - -struct _machdep_state { - u_long sp; - u_long fp; - u_int64_t fpregs[32]; -}; diff --git a/lib/libpthread/arch/hppa/uthread_machdep_asm.S b/lib/libpthread/arch/hppa/uthread_machdep_asm.S deleted file mode 100644 index fe476df338d..00000000000 --- a/lib/libpthread/arch/hppa/uthread_machdep_asm.S +++ /dev/null @@ -1,168 +0,0 @@ -/* $OpenBSD: uthread_machdep_asm.S,v 1.3 2007/07/07 15:46:56 kettenis Exp $ */ -/* Michael Shalayeff <mickey@openbsd.org>. Public Domain. */ - -#include <machine/asm.h> -#define _LOCORE -#include <machine/frame.h> - -#define FRAMESIZE 0x60 - -/* - * void _thread_machdep_init(statep, base, len, entry) - * struct _machdep_state *statep; - * void *base; - * int len; - * void (*entry)(void); - */ -ENTRY(_thread_machdep_init,FRAMESIZE) - ldo 7(arg1), arg1 - dep r0, 31, 3, arg1 - ldo HPPA_FRAME_SIZE(arg1), arg1 - ldo FRAMESIZE(arg1), t1 - stw t1, 0(arg0) - stw arg1, 4(arg0) - - bb,>=,n arg3, 30, _thread$noplabel - depi 0, 31, 2, arg3 - ldw 4(arg3), t1 - ldw 0(arg3), arg3 - stw t1, 0x44(arg1) - -_thread$noplabel - bv r0(rp) - stw arg3, 0(arg1) -EXIT(_thread_machdep_init) - -/* - * void _thread_machdep_switch(newstate, oldstate); - * struct _machdep_state *newstate, *oldstate; - */ -ENTRY(_thread_machdep_switch,0) - copy sp, t1 - ldo FRAMESIZE(sp), sp - stw sp, 0(arg1) - stw t1, 4(arg1) - stw r2, 0x00(t1) - stw r3, 0x04(t1) - stw r4, 0x08(t1) - stw r5, 0x0c(t1) - stw r6, 0x10(t1) - stw r7, 0x14(t1) - stw r8, 0x18(t1) - stw r9, 0x1c(t1) - stw r10, 0x20(t1) - stw r11, 0x24(t1) - stw r12, 0x28(t1) - stw r13, 0x2c(t1) - stw r14, 0x30(t1) - stw r15, 0x34(t1) - stw r16, 0x38(t1) - stw r17, 0x3c(t1) - stw r18, 0x40(t1) - stw r19, 0x44(t1) - - ldw 0(arg0), sp - ldw 4(arg0), t1 - ldw 0x00(t1), r2 - ldw 0x04(t1), r3 - ldw 0x08(t1), r4 - ldw 0x0c(t1), r5 - ldw 0x10(t1), r6 - ldw 0x14(t1), r7 - ldw 0x18(t1), r8 - ldw 0x1c(t1), r9 - ldw 0x20(t1), r10 - ldw 0x24(t1), r11 - ldw 0x28(t1), r12 - ldw 0x2c(t1), r13 - ldw 0x30(t1), r14 - ldw 0x34(t1), r15 - ldw 0x38(t1), r16 - ldw 0x3c(t1), r17 - ldw 0x40(t1), r18 - ldw 0x44(t1), r19 - bv r0(rp) - ldo -FRAMESIZE(sp), sp -EXIT(_thread_machdep_switch) - -/* - * void _thread_machdep_save_float_state(struct _machdep_state* statep); - */ -ENTRY(_thread_machdep_save_float_state,0) - ldo 8(arg0), arg0 - fstds,ma fr0 , 8(arg0) - fstds,ma fr1 , 8(arg0) - fstds,ma fr2 , 8(arg0) - fstds,ma fr3 , 8(arg0) - fstds,ma fr4 , 8(arg0) - fstds,ma fr5 , 8(arg0) - fstds,ma fr6 , 8(arg0) - fstds,ma fr7 , 8(arg0) - fstds,ma fr8 , 8(arg0) - fstds,ma fr9 , 8(arg0) - fstds,ma fr10, 8(arg0) - fstds,ma fr11, 8(arg0) - fstds,ma fr12, 8(arg0) - fstds,ma fr13, 8(arg0) - fstds,ma fr14, 8(arg0) - fstds,ma fr15, 8(arg0) - fstds,ma fr16, 8(arg0) - fstds,ma fr17, 8(arg0) - fstds,ma fr18, 8(arg0) - fstds,ma fr19, 8(arg0) - fstds,ma fr20, 8(arg0) - fstds,ma fr21, 8(arg0) - fstds,ma fr22, 8(arg0) - fstds,ma fr23, 8(arg0) - fstds,ma fr24, 8(arg0) - fstds,ma fr25, 8(arg0) - fstds,ma fr26, 8(arg0) - fstds,ma fr27, 8(arg0) - fstds,ma fr28, 8(arg0) - fstds,ma fr29, 8(arg0) - fstds,ma fr30, 8(arg0) - bv r0(rp) - fstd,ma fr31, 8(arg0) -EXIT(_thread_machdep_save_float_state) - -/* - * void _thread_machdep_restore_float_state(struct _machdep_state* statep); - */ -ENTRY(_thread_machdep_restore_float_state,0) - ldo 8*32(arg0), arg0 - fldds,ma -8(arg0), fr31 - fldds,ma -8(arg0), fr30 - fldds,ma -8(arg0), fr29 - fldds,ma -8(arg0), fr28 - fldds,ma -8(arg0), fr27 - fldds,ma -8(arg0), fr26 - fldds,ma -8(arg0), fr25 - fldds,ma -8(arg0), fr24 - fldds,ma -8(arg0), fr23 - fldds,ma -8(arg0), fr22 - fldds,ma -8(arg0), fr21 - fldds,ma -8(arg0), fr20 - fldds,ma -8(arg0), fr19 - fldds,ma -8(arg0), fr18 - fldds,ma -8(arg0), fr17 - fldds,ma -8(arg0), fr16 - fldds,ma -8(arg0), fr15 - fldds,ma -8(arg0), fr14 - fldds,ma -8(arg0), fr13 - fldds,ma -8(arg0), fr12 - fldds,ma -8(arg0), fr11 - fldds,ma -8(arg0), fr10 - fldds,ma -8(arg0), fr9 - fldds,ma -8(arg0), fr8 - fldds,ma -8(arg0), fr7 - fldds,ma -8(arg0), fr6 - fldds,ma -8(arg0), fr5 - fldds,ma -8(arg0), fr4 - fldds,ma -8(arg0), fr3 - fldds,ma -8(arg0), fr2 - fldds,ma -8(arg0), fr1 - bv %r0(rp) - fldds,ma -8(arg0), fr0 -EXIT(_thread_machdep_restore_float_state) - - .end diff --git a/lib/libpthread/arch/hppa64/_atomic_lock.c b/lib/libpthread/arch/hppa64/_atomic_lock.c deleted file mode 100644 index e9ca71cf721..00000000000 --- a/lib/libpthread/arch/hppa64/_atomic_lock.c +++ /dev/null @@ -1,15 +0,0 @@ -/* $OpenBSD: _atomic_lock.c,v 1.2 2011/11/14 15:16:12 jsing Exp $ */ -/* - * Atomic lock for hppa - */ -#include "spinlock.h" - -int -_atomic_lock(volatile _spinlock_lock_t *lock) -{ - register register_t old; - - __asm__("ldcws 0(%1), %0" : "=r" (old): "r" (lock)); - - return (old == _SPINLOCK_LOCKED); -} diff --git a/lib/libpthread/arch/hppa64/uthread_machdep.h b/lib/libpthread/arch/hppa64/uthread_machdep.h deleted file mode 100644 index da0810bab10..00000000000 --- a/lib/libpthread/arch/hppa64/uthread_machdep.h +++ /dev/null @@ -1,7 +0,0 @@ -/* $OpenBSD: uthread_machdep.h,v 1.1 2011/08/04 14:23:36 kettenis Exp $ */ - -struct _machdep_state { - u_long sp; - u_long fp; - u_int64_t fpregs[32]; -}; diff --git a/lib/libpthread/arch/hppa64/uthread_machdep_asm.S b/lib/libpthread/arch/hppa64/uthread_machdep_asm.S deleted file mode 100644 index 2fa991fc62f..00000000000 --- a/lib/libpthread/arch/hppa64/uthread_machdep_asm.S +++ /dev/null @@ -1,109 +0,0 @@ -/* $OpenBSD: uthread_machdep_asm.S,v 1.1 2011/08/04 14:23:36 kettenis Exp $ */ -/* Michael Shalayeff <mickey@openbsd.org>. Public Domain. */ - -#include <machine/asm.h> -#define _LOCORE -#include <machine/frame.h> - -/* - * void _thread_machdep_init(statep, base, len, entry) - * struct _machdep_state *statep; - * void *base; - * int len; - * void (*entry)(void); - */ -ENTRY(_thread_machdep_init,0) - bv %r0(%rp) - nop -EXIT(_thread_machdep_init) - -/* - * void _thread_machdep_switch(newstate, oldstate); - * struct _machdep_state *newstate, *oldstate; - */ -ENTRY(_thread_machdep_switch,0) - bv %r0(%rp) - nop -EXIT(_thread_machdep_switch) - -/* - * void _thread_machdep_save_float_state(struct _machdep_state* statep); - */ -ENTRY(_thread_machdep_save_float_state,0) - ldo 8(%arg0), %arg0 - fstd,ma %fr0, 8(%arg0) - fstd,ma %fr1, 8(%arg0) - fstd,ma %fr2, 8(%arg0) - fstd,ma %fr3, 8(%arg0) - fstd,ma %fr4, 8(%arg0) - fstd,ma %fr5, 8(%arg0) - fstd,ma %fr6, 8(%arg0) - fstd,ma %fr7, 8(%arg0) - fstd,ma %fr8, 8(%arg0) - fstd,ma %fr9, 8(%arg0) - fstd,ma %fr10, 8(%arg0) - fstd,ma %fr11, 8(%arg0) - fstd,ma %fr12, 8(%arg0) - fstd,ma %fr13, 8(%arg0) - fstd,ma %fr14, 8(%arg0) - fstd,ma %fr15, 8(%arg0) - fstd,ma %fr16, 8(%arg0) - fstd,ma %fr17, 8(%arg0) - fstd,ma %fr18, 8(%arg0) - fstd,ma %fr19, 8(%arg0) - fstd,ma %fr20, 8(%arg0) - fstd,ma %fr21, 8(%arg0) - fstd,ma %fr22, 8(%arg0) - fstd,ma %fr23, 8(%arg0) - fstd,ma %fr24, 8(%arg0) - fstd,ma %fr25, 8(%arg0) - fstd,ma %fr26, 8(%arg0) - fstd,ma %fr27, 8(%arg0) - fstd,ma %fr28, 8(%arg0) - fstd,ma %fr29, 8(%arg0) - fstd,ma %fr30, 8(%arg0) - bv %r0(%rp) - fstd,ma %fr31, 8(%arg0) -EXIT(_thread_machdep_save_float_state) - -/* - * void _thread_machdep_restore_float_state(struct _machdep_state* statep); - */ -ENTRY(_thread_machdep_restore_float_state,0) - ldo 8*32(%arg0), %arg0 - fldd,ma -8(%arg0), %fr31 - fldd,ma -8(%arg0), %fr30 - fldd,ma -8(%arg0), %fr29 - fldd,ma -8(%arg0), %fr28 - fldd,ma -8(%arg0), %fr27 - fldd,ma -8(%arg0), %fr26 - fldd,ma -8(%arg0), %fr25 - fldd,ma -8(%arg0), %fr24 - fldd,ma -8(%arg0), %fr23 - fldd,ma -8(%arg0), %fr22 - fldd,ma -8(%arg0), %fr21 - fldd,ma -8(%arg0), %fr20 - fldd,ma -8(%arg0), %fr19 - fldd,ma -8(%arg0), %fr18 - fldd,ma -8(%arg0), %fr17 - fldd,ma -8(%arg0), %fr16 - fldd,ma -8(%arg0), %fr15 - fldd,ma -8(%arg0), %fr14 - fldd,ma -8(%arg0), %fr13 - fldd,ma -8(%arg0), %fr12 - fldd,ma -8(%arg0), %fr11 - fldd,ma -8(%arg0), %fr10 - fldd,ma -8(%arg0), %fr9 - fldd,ma -8(%arg0), %fr8 - fldd,ma -8(%arg0), %fr7 - fldd,ma -8(%arg0), %fr6 - fldd,ma -8(%arg0), %fr5 - fldd,ma -8(%arg0), %fr4 - fldd,ma -8(%arg0), %fr3 - fldd,ma -8(%arg0), %fr2 - fldd,ma -8(%arg0), %fr1 - bv %r0(%rp) - fldd,ma -8(%arg0), %fr0 -EXIT(_thread_machdep_restore_float_state) - - .end diff --git a/lib/libpthread/arch/i386/_atomic_lock.c b/lib/libpthread/arch/i386/_atomic_lock.c deleted file mode 100644 index 9bf4d82b994..00000000000 --- a/lib/libpthread/arch/i386/_atomic_lock.c +++ /dev/null @@ -1,25 +0,0 @@ -/* $OpenBSD: _atomic_lock.c,v 1.8 2010/12/03 19:44:22 miod Exp $ */ -/* David Leonard, <d@csee.uq.edu.au>. Public domain. */ - -/* - * Atomic lock for i386 - */ - -#include <spinlock.h> - -int -_atomic_lock(volatile _spinlock_lock_t *lock) -{ - _spinlock_lock_t old; - - /* - * Use the eXCHanGe instruction to swap the lock value with - * a local variable containing the locked state. - */ - old = _SPINLOCK_LOCKED; - __asm__("xchg %0,(%2)" - : "=r" (old) - : "0" (old), "r" (lock)); - - return (old != _SPINLOCK_UNLOCKED); -} diff --git a/lib/libpthread/arch/i386/uthread_machdep.c b/lib/libpthread/arch/i386/uthread_machdep.c deleted file mode 100644 index 8d9d5da9da5..00000000000 --- a/lib/libpthread/arch/i386/uthread_machdep.c +++ /dev/null @@ -1,136 +0,0 @@ -/* $OpenBSD: uthread_machdep.c,v 1.6 2008/01/28 18:48:41 kettenis Exp $ */ -/* David Leonard, <d@csee.uq.edu.au>. Public domain. */ - -/* - * Machine-dependent thread state functions for OpenBSD/i386. - */ - -#include <sys/param.h> -#include <sys/sysctl.h> -#include <machine/cpu.h> -#include <pthread.h> -#include "pthread_private.h" - -struct frame { - int fr_gs; - int fr_fs; - int fr_es; - int fr_ds; - - int fr_edi; - int fr_esi; - int fr_ebp; - int fr_esp; - int fr_ebx; - int fr_edx; - int fr_ecx; - int fr_eax; - - int fr_eip; - int fr_cs; /* XXX unreachable? */ -}; - -#define copyreg(reg, lval) \ - __asm__("mov %%" #reg ", %0" : "=g"(lval)) - -static int _thread_machdep_osfxsr(void); - -static int -_thread_machdep_osfxsr(void) -{ - int mib[] = { CTL_MACHDEP, CPU_OSFXSR }; - static int sse = -1; - size_t len; - int val; - - if (sse == -1) { - len = sizeof (val); - if (sysctl(mib, 2, &val, &len, NULL, 0) == -1) - return (0); - if (val) - sse = 1; - else - sse = 0; - } - return (sse); -} - -/* - * Given a stack and an entry function, initialise a state - * structure that can be later switched to. - */ -void -_thread_machdep_init(struct _machdep_state* statep, void *base, int len, - void (*entry)(void)) -{ - struct frame *f; - - /* - * Locate the initial frame at the top of the stack. For the - * stack to end up properly (16-byte) aligned, we need to - * align the frame at an odd 8-byte boundary. - */ - f = (struct frame *)((((int)base + len - sizeof *f) & ~15) - 8); - - /* Set up initial frame */ - f->fr_esp = (int)&f->fr_edi; - copyreg(cs, f->fr_cs); - copyreg(ds, f->fr_ds); - copyreg(es, f->fr_es); - copyreg(fs, f->fr_fs); - copyreg(gs, f->fr_gs); - f->fr_ebp = (int)-1; - f->fr_eip = (int)entry; - - statep->esp = (int)f; - - _thread_machdep_save_float_state(statep); - /* - * The current thread float state is saved into the new thread stack. - * Later pthread_create calls _thread_kern_sched which saves the current - * thread float state again into its own stack. However all float state - * saves must be balanced with a restore on i386 due to the fninit(). - * Restore the current thread float state here so that the next save - * gets the correct state. - */ - _thread_machdep_restore_float_state(statep); -} - -/* - * Floating point save restore copied from code in npx.c - * (without really understanding what it does). - */ -#define fldcw(addr) __asm("fldcw %0" : : "m" (*addr)) -#define fnsave(addr) __asm("fnsave %0" : "=m" (*addr)) -#define fninit() __asm("fninit") -#define frstor(addr) __asm("frstor %0" : : "m" (*addr)) -#define fxsave(addr) __asm("fxsave %0" : "=m" (*addr)) -#define fxrstor(addr) __asm("fxrstor %0" : : "m" (*addr)) -#define fwait() __asm("fwait") - -void -_thread_machdep_save_float_state(struct _machdep_state *ms) -{ - union savefpu *addr = &ms->fpreg; - - if (_thread_machdep_osfxsr()) { - fwait(); - fxsave(&addr->sv_xmm); - fninit(); - } else - fnsave(&addr->sv_87); - fwait(); -} - -void -_thread_machdep_restore_float_state(struct _machdep_state *ms) -{ - union savefpu *addr = &ms->fpreg; - - if (_thread_machdep_osfxsr()) { - fxrstor(&addr->sv_xmm); - fwait(); - } else - frstor(&addr->sv_87); - -} diff --git a/lib/libpthread/arch/i386/uthread_machdep.h b/lib/libpthread/arch/i386/uthread_machdep.h deleted file mode 100644 index becb026755f..00000000000 --- a/lib/libpthread/arch/i386/uthread_machdep.h +++ /dev/null @@ -1,10 +0,0 @@ -/* $OpenBSD: uthread_machdep.h,v 1.10 2010/06/30 19:04:51 kettenis Exp $ */ -/* David Leonard, <d@csee.uq.edu.au>. Public domain. */ - -#include <machine/npx.h> - -struct _machdep_state { - int esp; - /* must be 128-bit aligned */ - union savefpu fpreg __attribute__ ((aligned (16))); -}; diff --git a/lib/libpthread/arch/i386/uthread_machdep_asm.S b/lib/libpthread/arch/i386/uthread_machdep_asm.S deleted file mode 100644 index 06652fd210f..00000000000 --- a/lib/libpthread/arch/i386/uthread_machdep_asm.S +++ /dev/null @@ -1,27 +0,0 @@ -/* $OpenBSD: uthread_machdep_asm.S,v 1.1 2000/09/25 01:16:40 d Exp $ */ -/* David Leonard, <d@csee.uq.edu.au>. Public domain. */ - -#include <machine/asm.h> - -/* - * Switch stacks - */ - -/* void _thread_machdep_switch(new, oldsave); */ -ENTRY(_thread_machdep_switch) - pushal /* pushl %eax,%ecx,%edx,%ebx,%esp,%ebp,%esi,%edi */ - pushl %ds - pushl %es - pushl %fs - pushl %gs -#define DISTANCE ((8+1+1+1+1)*4) - movl (DISTANCE+8)(%esp), %eax /* %eax = arg2 */ - movl %esp, 0(%eax) /* *arg2 = %esp */ - movl (DISTANCE+4)(%esp), %eax /* %eax = arg1 */ - movl 0(%eax), %esp /* %esp = *arg1 */ - popl %gs - popl %fs - popl %es - popl %ds - popal /* popl %edi,%esi,%ebp,%esp,%ebx,%edx,%ecx,%eax */ - ret diff --git a/lib/libpthread/arch/m68k/_atomic_lock.c b/lib/libpthread/arch/m68k/_atomic_lock.c deleted file mode 100644 index cc4effe06f9..00000000000 --- a/lib/libpthread/arch/m68k/_atomic_lock.c +++ /dev/null @@ -1,38 +0,0 @@ -/* $OpenBSD: _atomic_lock.c,v 1.7 2008/10/02 23:27:23 deraadt Exp $ */ -/* David Leonard, <d@csee.uq.edu.au>. Public domain. */ - -/* - * Atomic lock for m68k - */ - -#include "spinlock.h" - -int -_atomic_lock(volatile _spinlock_lock_t *lock) -{ - _spinlock_lock_t old; - - /* - * The Compare And Swap instruction (mc68020 and above) - * compares its first operand with the memory addressed by - * the third. If they are the same value, the second operand - * is stored at the address. Otherwise the 1st operand (register) - * is loaded with the contents of the 3rd operand. - * - * old = 0; - * CAS(old, 1, *lock); - * if (old == 1) { lock was acquired } - * - * From the MC68030 User's Manual (Motorola), page `3-13': - * CAS Dc,Du,<ea>: - * (<ea> - Dc) -> cc; - * if Z then Du -> <ea> - * else <ea> -> Dc; - */ - old = _SPINLOCK_UNLOCKED; - __asm__("casl %0, %2, %1" : "=d" (old), "=m" (*lock) - : "d" (_SPINLOCK_LOCKED), - "0" (old), "1" (*lock) - : "cc"); - return (old != _SPINLOCK_UNLOCKED); -} diff --git a/lib/libpthread/arch/m68k/uthread_machdep.c b/lib/libpthread/arch/m68k/uthread_machdep.c deleted file mode 100644 index 77c8019d1da..00000000000 --- a/lib/libpthread/arch/m68k/uthread_machdep.c +++ /dev/null @@ -1,54 +0,0 @@ -/* $OpenBSD: uthread_machdep.c,v 1.2 2003/06/02 08:11:15 miod Exp $ */ -/* David Leonard, <d@csee.uq.edu.au>. Public domain. */ - -/* - * Machine-dependent thread state functions for OpenBSD/m68k - */ - -#include <pthread.h> -#include "pthread_private.h" - -#define ALIGNBYTES 0x3 - -struct frame { - int d2,d3,d4,d5,d6,d7; - int a2,a3,a4,a5,fp; - int link; /* frame link */ - int ra; -}; - -/* - * Given a stack and an entry function, initialise a state - * structure that can be later switched to. - */ -void -_thread_machdep_init(statep, base, len, entry) - struct _machdep_state* statep; - void *base; - int len; - void (*entry)(void); -{ - struct frame *f; - - /* Locate the initial frame, aligned at the top of the stack */ - f = (struct frame *)(((int)base + len - sizeof *f) & ~ALIGNBYTES); - - f->ra = (int)entry; - f->link = 0; - f->fp = (int)&f->link; - statep->sp = (int)f; -} - -void -_thread_machdep_save_float_state(statep) - struct _machdep_state* statep; -{ - /* fsave is a privileged instruction */ -} - -void -_thread_machdep_restore_float_state(statep) - struct _machdep_state* statep; -{ - /* frestore is a privileged instruction */ -} diff --git a/lib/libpthread/arch/m68k/uthread_machdep.h b/lib/libpthread/arch/m68k/uthread_machdep.h deleted file mode 100644 index d9bb9935ca6..00000000000 --- a/lib/libpthread/arch/m68k/uthread_machdep.h +++ /dev/null @@ -1,6 +0,0 @@ -/* $OpenBSD: uthread_machdep.h,v 1.4 2000/10/04 05:55:34 d Exp $ */ -/* David Leonard, <d@csee.uq.edu.au>. Public domain. */ - -struct _machdep_state { - int sp; -}; diff --git a/lib/libpthread/arch/m68k/uthread_machdep_asm.S b/lib/libpthread/arch/m68k/uthread_machdep_asm.S deleted file mode 100644 index 30e4397b838..00000000000 --- a/lib/libpthread/arch/m68k/uthread_machdep_asm.S +++ /dev/null @@ -1,18 +0,0 @@ -/* $OpenBSD: uthread_machdep_asm.S,v 1.1 2000/09/25 09:03:44 d Exp $ */ -/* David Leonard, <d@csee.uq.edu.au>. Public domain. */ - -#include <machine/asm.h> - -#define SA(x) (((x)+3)&~3) -#define FRAMESIZE 4*11 - -ENTRY(_thread_machdep_switch) - link a6, #-SA(FRAMESIZE) - moveml #0x7CFC, sp@ /* d2-d7,a2-a6 */ - movel a6@(8), a0 - movel a6@(12), a1 - movel sp, a1@ - movel a0@, sp - moveml sp@, #0x7CFC - unlk a6 - rts diff --git a/lib/libpthread/arch/m88k/_atomic_lock.c b/lib/libpthread/arch/m88k/_atomic_lock.c deleted file mode 100644 index c156eb7da57..00000000000 --- a/lib/libpthread/arch/m88k/_atomic_lock.c +++ /dev/null @@ -1,51 +0,0 @@ -/* $OpenBSD: _atomic_lock.c,v 1.4 2004/02/27 22:19:46 deraadt Exp $ */ - -/* - * Copyright (c) 2003, Miodrag Vallat. - * - * 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 m88k - */ - -#include "spinlock.h" - -int -_atomic_lock(volatile _spinlock_lock_t *lock) -{ - _spinlock_lock_t old; - - old = _SPINLOCK_LOCKED; - __asm__ __volatile__ - ("xmem %0, %2, r0" : "=r" (old) : "0" (old), "r" (lock)); - - return (old != _SPINLOCK_UNLOCKED); -} - -int -_atomic_is_locked(volatile _spinlock_lock_t *lock) -{ - - return (*lock != _SPINLOCK_UNLOCKED); -} diff --git a/lib/libpthread/arch/m88k/uthread_machdep.c b/lib/libpthread/arch/m88k/uthread_machdep.c deleted file mode 100644 index c73fe479eb0..00000000000 --- a/lib/libpthread/arch/m88k/uthread_machdep.c +++ /dev/null @@ -1,73 +0,0 @@ -/* $OpenBSD: uthread_machdep.c,v 1.2 2004/03/02 23:41:29 miod Exp $ */ - -/* - * Copyright (c) 2004 Theo de Raadt - * - * 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. - */ - -/* - * Machine-dependent thread state functions for m88k - */ - -#include <pthread.h> -#include "pthread_private.h" - -#define ALIGNBYTES 7 - -struct frame { - long regs[28]; /* r4-r30, r1 */ -}; - -/* - * Given a stack and an entry function, initialise a state - * structure that can be later switched to. - */ -void -_thread_machdep_init(statep, base, len, entry) - struct _machdep_state* statep; - void *base; - int len; - void (*entry)(void); -{ - struct frame *f; - - f = (struct frame *)(((u_int32_t)base + len - sizeof *f) & ~ALIGNBYTES); - f->regs[27] = (u_int32_t)entry; /* ``saved'' r1 */ - - statep->sp = (int)f; -} - -void -_thread_machdep_save_float_state(statep) - struct _machdep_state* statep; -{ - int fpreg; - - __asm__ __volatile__ ("fldcr %0, fcr62" : "=r" (fpreg)); - statep->fpsr = fpreg; - __asm__ __volatile__ ("fldcr %0, fcr63" : "=r" (fpreg)); - statep->fpcr = fpreg; -} - -void -_thread_machdep_restore_float_state(statep) - struct _machdep_state* statep; -{ - int fpreg; - - fpreg = statep->fpsr; - __asm__ __volatile__ ("fstcr %0, fcr62" : : "r" (fpreg)); - fpreg = statep->fpcr; - __asm__ __volatile__ ("fstcr %0, fcr63" : : "r" (fpreg)); -} diff --git a/lib/libpthread/arch/m88k/uthread_machdep.h b/lib/libpthread/arch/m88k/uthread_machdep.h deleted file mode 100644 index 073af3e031c..00000000000 --- a/lib/libpthread/arch/m88k/uthread_machdep.h +++ /dev/null @@ -1,23 +0,0 @@ -/* $OpenBSD: uthread_machdep.h,v 1.5 2004/02/27 22:19:46 deraadt Exp $ */ - -/* - * Copyright (c) 2004 Theo de Raadt - * - * 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. - */ - -struct _machdep_state { - u_int sp; - int fpsr; - int fpcr; -}; diff --git a/lib/libpthread/arch/m88k/uthread_machdep_asm.S b/lib/libpthread/arch/m88k/uthread_machdep_asm.S deleted file mode 100644 index dcf997650d8..00000000000 --- a/lib/libpthread/arch/m88k/uthread_machdep_asm.S +++ /dev/null @@ -1,66 +0,0 @@ -/* $OpenBSD: uthread_machdep_asm.S,v 1.2 2004/03/02 23:41:29 miod Exp $ */ - -/* - * Copyright (c) 2004 Theo de Raadt - * - * 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 <machine/asm.h> - -/* - * void _thread_machdep_switch(new, oldsave); - */ -ENTRY(_thread_machdep_switch) - subu r31, r31, 4 * 28 - - /* save all registers but r0, r2, r3 and r31 on stack */ - st.d r4, r31, 4 * 0 - st.d r6, r31, 4 * 2 - st.d r8, r31, 4 * 4 - st.d r10, r31, 4 * 6 - st.d r12, r31, 4 * 8 - st.d r14, r31, 4 * 10 - st.d r16, r31, 4 * 12 - st.d r18, r31, 4 * 14 - st.d r20, r31, 4 * 16 - st.d r22, r31, 4 * 18 - st.d r24, r31, 4 * 20 - st.d r26, r31, 4 * 22 - st.d r28, r31, 4 * 24 - st r30, r31, 4 * 26 - st r1, r31, 4 * 27 - - /* exchange stacks */ - st r31, r3, 0 /* oldsave->frame = r31 */ - ld r31, r2, 0 /* r31 = oldsave->frame */ - - /* restore registers */ - ld.d r4, r31, 4 * 0 - ld.d r6, r31, 4 * 2 - ld.d r8, r31, 4 * 4 - ld.d r10, r31, 4 * 6 - ld.d r12, r31, 4 * 8 - ld.d r14, r31, 4 * 10 - ld.d r16, r31, 4 * 12 - ld.d r18, r31, 4 * 14 - ld.d r20, r31, 4 * 16 - ld.d r22, r31, 4 * 18 - ld.d r24, r31, 4 * 20 - ld.d r26, r31, 4 * 22 - ld.d r28, r31, 4 * 24 - ld r30, r31, 4 * 26 - ld r1, r31, 4 * 27 - - jmp.n r1 - addu r31, r31, 4 * 28 diff --git a/lib/libpthread/arch/mips64/_atomic_lock.c b/lib/libpthread/arch/mips64/_atomic_lock.c deleted file mode 100644 index e85335f7466..00000000000 --- a/lib/libpthread/arch/mips64/_atomic_lock.c +++ /dev/null @@ -1,24 +0,0 @@ -/* $OpenBSD: _atomic_lock.c,v 1.3 2009/06/01 23:17:52 miod Exp $ */ - -/* - * Atomic lock for mips - * Written by Miodrag Vallat <miod@openbsd.org> - placed in the public domain. - */ - -#include "spinlock.h" - -int -_atomic_lock(volatile _spinlock_lock_t *lock) -{ - _spinlock_lock_t old; - - __asm__ __volatile__ ( - "1: ll %0, 0(%1)\n" - " sc %2, 0(%1)\n" - " beqz %2, 1b\n" - " nop\n" : - "=r"(old) : - "r"(lock), "r"(_SPINLOCK_LOCKED) : "memory"); - - return (old != _SPINLOCK_UNLOCKED); -} diff --git a/lib/libpthread/arch/mips64/_spinlock.h b/lib/libpthread/arch/mips64/_spinlock.h deleted file mode 100644 index d1f543f2faa..00000000000 --- a/lib/libpthread/arch/mips64/_spinlock.h +++ /dev/null @@ -1,6 +0,0 @@ -/* $OpenBSD: _spinlock.h,v 1.1 2004/08/11 17:41:34 pefo Exp $ */ - -#define _SPINLOCK_UNLOCKED (0) -#define _SPINLOCK_LOCKED (1) -typedef int _spinlock_lock_t; - diff --git a/lib/libpthread/arch/mips64/uthread_machdep.c b/lib/libpthread/arch/mips64/uthread_machdep.c deleted file mode 100644 index 66e57641cb7..00000000000 --- a/lib/libpthread/arch/mips64/uthread_machdep.c +++ /dev/null @@ -1,57 +0,0 @@ -/* $OpenBSD: uthread_machdep.c,v 1.3 2004/11/02 21:36:11 pefo Exp $ */ -/* David Leonard, <d@csee.uq.edu.au>. Public domain. */ - -/* - * Machine-dependent thread state functions for OpenBSD/mips - */ - -#include <pthread.h> -#include "pthread_private.h" - -#define ALIGNBYTES 0x3 - -struct frame { - long s[9]; /* s0..s8 */ - double f[8]; /* $f24..$f31 */ - long fcr; - long t9; /* XXX only used when bootstrapping */ - long ra; - -/* XXX args should not be here for N32 or N64 ABIs */ - long arg[4], cra, cfp; /* ABI space for debuggers */ -}; - -/* - * Given a stack and an entry function, initialise a state - * structure that can be later switched to. - */ -void -_thread_machdep_init(statep, base, len, entry) - struct _machdep_state* statep; - void *base; - int len; - void (*entry)(void); -{ - struct frame *f; - - /* Locate the initial frame, aligned at the top of the stack */ - f = (struct frame *)(((long)base + len - sizeof *f) & ~ALIGNBYTES); - - f->ra = (long)entry; - f->t9 = (long)entry; - f->fcr = 0; - - statep->frame = (long)f; -} - -void -_thread_machdep_save_float_state(statep) - struct _machdep_state* statep; -{ -} - -void -_thread_machdep_restore_float_state(statep) - struct _machdep_state* statep; -{ -} diff --git a/lib/libpthread/arch/mips64/uthread_machdep.h b/lib/libpthread/arch/mips64/uthread_machdep.h deleted file mode 100644 index e3d31729b7b..00000000000 --- a/lib/libpthread/arch/mips64/uthread_machdep.h +++ /dev/null @@ -1,6 +0,0 @@ -/* $OpenBSD: uthread_machdep.h,v 1.2 2004/09/09 16:59:21 pefo Exp $ */ -/* David Leonard, <d@csee.uq.edu.au>. Public domain. */ - -struct _machdep_state { - long frame; -}; diff --git a/lib/libpthread/arch/mips64/uthread_machdep_asm.S b/lib/libpthread/arch/mips64/uthread_machdep_asm.S deleted file mode 100644 index a3c0a6e8366..00000000000 --- a/lib/libpthread/arch/mips64/uthread_machdep_asm.S +++ /dev/null @@ -1,96 +0,0 @@ -/* $OpenBSD: uthread_machdep_asm.S,v 1.3 2004/11/02 21:36:11 pefo Exp $ */ -/* David Leonard, <d@csee.uq.edu.au>. Public domain. */ - -#include <machine/asm.h> - -/* - * Save layout: - * - * ----------- - * +152 | sp | - * +144 | t9 | - * ----------- - * +136 | fcr | - * ----------- - * +128 | f31 | - * +120 | f30 | - * +112 | f29 | - * +104 | f28 | - * +96 | f27 | - * +88 | f26 | - * +80 | f25 | - * +72 | f24 | - * ----------- - * +64 | s8 | - * +56 | s7 | - * +48 | s6 | - * +40 | s5 | - * +32 | s4 | - * +24 | s3 | - * +16 | s2 | - * +8 | s1 | - * sp -> | s0 | - * ----------- - */ - -#define SOFF(n) ((n)*REGSZ) -#define FPOFF(n) (SOFF(9) + (n)*8) -#define REGOFF(n) (FPOFF(9) + (n)*REGSZ) - -#define FRAMESIZE (REGOFF(2) + REGSZ*4+REGSZ+REGSZ) - -NON_LEAF(_thread_machdep_switch, FRAMESIZE, ra) - PTR_ADDU sp, sp, -FRAMESIZE - - REG_S s0, SOFF(0)(sp) - REG_S s1, SOFF(1)(sp) - REG_S s2, SOFF(2)(sp) - REG_S s3, SOFF(3)(sp) - REG_S s4, SOFF(4)(sp) - REG_S s5, SOFF(5)(sp) - REG_S s6, SOFF(6)(sp) - REG_S s7, SOFF(7)(sp) - REG_S s8, SOFF(8)(sp) - s.d $f24, FPOFF(0)(sp) - s.d $f25, FPOFF(1)(sp) - s.d $f26, FPOFF(2)(sp) - s.d $f27, FPOFF(3)(sp) - s.d $f28, FPOFF(4)(sp) - s.d $f29, FPOFF(5)(sp) - s.d $f30, FPOFF(6)(sp) - s.d $f31, FPOFF(7)(sp) - REG_S t9, REGOFF(0)(sp) - REG_S ra, REGOFF(1)(sp) - cfc1 t9, $31 - REG_S t9, FPOFF(8)(sp) - - REG_S sp, 0(a1) - REG_L sp, 0(a0) - - .set noreorder /* avoid nops */ - REG_L t9, FPOFF(8)(sp) - ctc1 t9, $31 - REG_L ra, REGOFF(1)(sp) - REG_L t9, REGOFF(0)(sp) - l.d $f24, FPOFF(0)(sp) - l.d $f25, FPOFF(1)(sp) - l.d $f26, FPOFF(2)(sp) - l.d $f27, FPOFF(3)(sp) - l.d $f28, FPOFF(4)(sp) - l.d $f29, FPOFF(5)(sp) - l.d $f30, FPOFF(6)(sp) - l.d $f31, FPOFF(7)(sp) - REG_L s8, SOFF(8)(sp) - REG_L s7, SOFF(7)(sp) - REG_L s6, SOFF(6)(sp) - REG_L s5, SOFF(5)(sp) - REG_L s4, SOFF(4)(sp) - REG_L s3, SOFF(3)(sp) - REG_L s2, SOFF(2)(sp) - REG_L s1, SOFF(1)(sp) - REG_L s0, SOFF(0)(sp) - .set reorder - - PTR_ADDU sp, sp, FRAMESIZE - j ra -END(_thread_machdep_switch) diff --git a/lib/libpthread/arch/powerpc/_atomic_lock.c b/lib/libpthread/arch/powerpc/_atomic_lock.c deleted file mode 100644 index f7a80bd9697..00000000000 --- a/lib/libpthread/arch/powerpc/_atomic_lock.c +++ /dev/null @@ -1,53 +0,0 @@ -/* $OpenBSD: _atomic_lock.c,v 1.8 2008/10/01 14:59:18 drahn Exp $ */ -/* - * Copyright (c) 1998 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. - */ - -/* - * Atomic lock for powerpc - */ - -#include "spinlock.h" - -int -_atomic_lock(volatile _spinlock_lock_t *lock) -{ - _spinlock_lock_t old; - - __asm__("1: lwarx 0,0,%1 \n" - " stwcx. %2,0,%1 \n" - " bne- 1b \n" - " mr %0, 0 \n" - : "=r" (old), "=r" (lock) - : "r" (_SPINLOCK_LOCKED), "1" (lock) : "0" - ); - - return (old != _SPINLOCK_UNLOCKED); - - /* - * Dale <drahn@openbsd.org> says: - * Side note. to prevent two processes from accessing - * the same address with the lwarx in one instruction - * and the stwcx in another process, the current powerpc - * kernel uses a stwcx instruction without the corresponding - * lwarx which causes any reservation of a process - * to be removed. if a context switch occurs - * between the two accesses the store will not occur - * and the condition code will cause it to loop. If on - * a dual processor machine, the reserve will cause - * appropriate bus cycle accesses to notify other - * processors. - */ -} diff --git a/lib/libpthread/arch/powerpc/uthread_machdep.c b/lib/libpthread/arch/powerpc/uthread_machdep.c deleted file mode 100644 index 51735790825..00000000000 --- a/lib/libpthread/arch/powerpc/uthread_machdep.c +++ /dev/null @@ -1,86 +0,0 @@ -/* $OpenBSD: uthread_machdep.c,v 1.5 2006/09/29 14:35:28 otto Exp $ */ -/* David Leonard, <d@csee.uq.edu.au>. Public domain */ - -#include <pthread.h> -#include "pthread_private.h" - -#define ALIGNBYTES 0xf - -/* Register save frame as it appears on the stack */ -struct frame { - int r1; - int reserved; - int gp[32-14]; - int lr, cr, ctr, xer; - double fp[32]; - double fs; - /* The rest are only valid in the initial frame */ - int next_r1; - int next_lr; -}; - -/* - * Given a stack and an entry function, initialise a state - * structure that can be later switched to. - */ -void -_thread_machdep_init(statep, base, len, entry) - struct _machdep_state* statep; - void *base; - int len; - void (*entry)(void); -{ - struct frame *f; - - /* Locate the initial frame, aligned at the top of the stack */ - f = (struct frame *)(((int)base - 16 + len - sizeof *f) & ~ALIGNBYTES); - - f->r1 = (int)&f->next_r1; - f->reserved = 0; - f->lr = (int)entry; - f->next_r1 = 0; /* for gdb */ - f->next_lr = 0; /* for gdb */ - - /* Initialise the new thread with all the state from this thread. */ - -#define copyreg(x) __asm__ volatile ("stw " #x ", %0" : "=m"(f->gp[x-14])) - copyreg(14); copyreg(15); copyreg(16); copyreg(17); copyreg(18); - copyreg(19); copyreg(20); copyreg(21); copyreg(22); copyreg(23); - copyreg(24); copyreg(25); copyreg(26); copyreg(27); copyreg(28); - copyreg(29); copyreg(30); copyreg(31); - -#define copysreg(nm) __asm__ volatile ("mf" #nm " %0" : "=r"(f->nm)) - copysreg(cr); copysreg(ctr); copysreg(xer); - -#define copyfreg(x) __asm__ volatile ("stfd " #x ", %0" : "=m"(f->fp[x])) - copyfreg(0); copyfreg(1); copyfreg(2); copyfreg(3); - copyfreg(4); copyfreg(5); copyfreg(6); copyfreg(7); - copyfreg(8); copyfreg(9); copyfreg(10); copyfreg(11); - copyfreg(12); copyfreg(13); copyfreg(14); copyfreg(15); - copyfreg(16); copyfreg(17); copyfreg(18); copyfreg(19); - copyfreg(20); copyfreg(21); copyfreg(22); copyfreg(23); - copyfreg(24); copyfreg(25); copyfreg(26); copyfreg(27); - copyfreg(28); copyfreg(29); copyfreg(30); copyfreg(31); - - __asm__ volatile ("mffs 0; stfd 0, %0" : "=m"(f->fs)); - - statep->frame = (int)f; -} - - -/* - * No-op float saves. - * (Floating point registers were saved in _thread_machdep_switch()) - */ - -void -_thread_machdep_save_float_state(statep) - struct _machdep_state* statep; -{ -} - -void -_thread_machdep_restore_float_state(statep) - struct _machdep_state* statep; -{ -} diff --git a/lib/libpthread/arch/powerpc/uthread_machdep.h b/lib/libpthread/arch/powerpc/uthread_machdep.h deleted file mode 100644 index 54c864e71a4..00000000000 --- a/lib/libpthread/arch/powerpc/uthread_machdep.h +++ /dev/null @@ -1,7 +0,0 @@ -/* $OpenBSD: uthread_machdep.h,v 1.5 2000/10/04 05:55:35 d Exp $ */ -/* David Leonard, <d@csee.uq.edu.au>. Public domain. */ - -struct _machdep_state { - int frame; -}; - diff --git a/lib/libpthread/arch/powerpc/uthread_machdep_asm.S b/lib/libpthread/arch/powerpc/uthread_machdep_asm.S deleted file mode 100644 index b6a5a1acbea..00000000000 --- a/lib/libpthread/arch/powerpc/uthread_machdep_asm.S +++ /dev/null @@ -1,135 +0,0 @@ -/* $OpenBSD: uthread_machdep_asm.S,v 1.2 2003/01/27 21:45:24 drahn Exp $ */ -/* David Leonard, <d@csee.uq.edu.au>. Public domain. */ - -#include <machine/asm.h> - -/* These need to be kept in sync with uthread_machdep.c */ -#define REGOFF(n) (2*4 + (n-14)*4) -#define FPOFF(n) (REGOFF(36) + (n)*8) -#define FRAMESIZE FPOFF(33) - -#define SA(x) (((x)+0xf)&~0xf) - -ENTRY(_thread_machdep_switch) - stwu 1, -SA(FRAMESIZE)(1) - - /* Save context into frame */ - stw 14, REGOFF(14)(1) - stw 15, REGOFF(15)(1) - stw 16, REGOFF(16)(1) - stw 17, REGOFF(17)(1) - stw 18, REGOFF(18)(1) - stw 19, REGOFF(19)(1) - stw 20, REGOFF(20)(1) - stw 21, REGOFF(21)(1) - stw 22, REGOFF(22)(1) - stw 23, REGOFF(23)(1) - stw 24, REGOFF(24)(1) - stw 25, REGOFF(25)(1) - stw 26, REGOFF(26)(1) - stw 27, REGOFF(27)(1) - stw 28, REGOFF(28)(1) - stw 29, REGOFF(29)(1) - stw 30, REGOFF(30)(1) - stw 31, REGOFF(31)(1) - mflr 0; stw 0, REGOFF(32)(1) - mfcr 0; stw 0, REGOFF(33)(1) - mfctr 0; stw 0, REGOFF(34)(1) - mfxer 0; stw 0, REGOFF(35)(1) - stfd 0, FPOFF(0)(1) - stfd 1, FPOFF(1)(1) - stfd 2, FPOFF(2)(1) - stfd 3, FPOFF(3)(1) - stfd 4, FPOFF(4)(1) - stfd 5, FPOFF(5)(1) - stfd 6, FPOFF(6)(1) - stfd 7, FPOFF(7)(1) - stfd 8, FPOFF(8)(1) - stfd 9, FPOFF(9)(1) - stfd 10, FPOFF(10)(1) - stfd 11, FPOFF(11)(1) - stfd 12, FPOFF(12)(1) - stfd 13, FPOFF(13)(1) - stfd 14, FPOFF(14)(1) - stfd 15, FPOFF(15)(1) - stfd 16, FPOFF(16)(1) - stfd 17, FPOFF(17)(1) - stfd 18, FPOFF(18)(1) - stfd 19, FPOFF(19)(1) - stfd 20, FPOFF(20)(1) - stfd 21, FPOFF(21)(1) - stfd 22, FPOFF(22)(1) - stfd 23, FPOFF(23)(1) - stfd 24, FPOFF(24)(1) - stfd 25, FPOFF(25)(1) - stfd 26, FPOFF(26)(1) - stfd 27, FPOFF(27)(1) - stfd 28, FPOFF(28)(1) - stfd 29, FPOFF(29)(1) - stfd 30, FPOFF(30)(1) - stfd 31, FPOFF(31)(1) - mffs 0; stfd 0, FPOFF(32)(1) - - /* Switch stacks */ - stw 1, 0(4) - lwz 1, 0(3) - - /* Restore context from the frame */ - lfd 0, FPOFF(32)(1); mtfsf 0xff, 0 - lfd 31, FPOFF(31)(1) - lfd 30, FPOFF(30)(1) - lfd 29, FPOFF(29)(1) - lfd 28, FPOFF(28)(1) - lfd 27, FPOFF(27)(1) - lfd 26, FPOFF(26)(1) - lfd 25, FPOFF(25)(1) - lfd 24, FPOFF(24)(1) - lfd 23, FPOFF(23)(1) - lfd 22, FPOFF(22)(1) - lfd 21, FPOFF(21)(1) - lfd 20, FPOFF(20)(1) - lfd 19, FPOFF(19)(1) - lfd 18, FPOFF(18)(1) - lfd 17, FPOFF(17)(1) - lfd 16, FPOFF(16)(1) - lfd 15, FPOFF(15)(1) - lfd 14, FPOFF(14)(1) - lfd 13, FPOFF(13)(1) - lfd 12, FPOFF(12)(1) - lfd 11, FPOFF(11)(1) - lfd 10, FPOFF(10)(1) - lfd 9, FPOFF(9)(1) - lfd 8, FPOFF(8)(1) - lfd 7, FPOFF(7)(1) - lfd 6, FPOFF(6)(1) - lfd 5, FPOFF(5)(1) - lfd 4, FPOFF(4)(1) - lfd 3, FPOFF(3)(1) - lfd 2, FPOFF(2)(1) - lfd 1, FPOFF(1)(1) - lfd 0, FPOFF(0)(1) - - lwz 0, REGOFF(35)(1); mtxer 0 - lwz 0, REGOFF(34)(1); mtctr 0 - lwz 0, REGOFF(33)(1); mtcr 0 - lwz 0, REGOFF(32)(1); mtlr 0 - lwz 31, REGOFF(31)(1) - lwz 30, REGOFF(30)(1) - lwz 29, REGOFF(29)(1) - lwz 28, REGOFF(28)(1) - lwz 27, REGOFF(27)(1) - lwz 26, REGOFF(26)(1) - lwz 25, REGOFF(25)(1) - lwz 24, REGOFF(24)(1) - lwz 23, REGOFF(23)(1) - lwz 22, REGOFF(22)(1) - lwz 21, REGOFF(21)(1) - lwz 20, REGOFF(20)(1) - lwz 19, REGOFF(19)(1) - lwz 18, REGOFF(18)(1) - lwz 17, REGOFF(17)(1) - lwz 16, REGOFF(16)(1) - lwz 15, REGOFF(15)(1) - lwz 14, REGOFF(14)(1) - la 1, SA(FRAMESIZE)(1) - blr diff --git a/lib/libpthread/arch/sh/_atomic_lock.c b/lib/libpthread/arch/sh/_atomic_lock.c deleted file mode 100644 index 3431e69b3a8..00000000000 --- a/lib/libpthread/arch/sh/_atomic_lock.c +++ /dev/null @@ -1,53 +0,0 @@ -/* $OpenBSD: _atomic_lock.c,v 1.3 2008/06/26 05:42:05 ray Exp $ */ - -/*- - * Copyright (c) 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Gregory McGarry. - * - * 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 "spinlock.h" - -int -_atomic_lock(volatile _spinlock_lock_t *lock) -{ - _spinlock_lock_t old; - - __asm volatile( - " tas.b %0 \n" - " mov #0, %1 \n" - " rotcl %1 \n" - : "=m" (*lock), "=r" (old)); - - return (old == 0); -} - -int -_atomic_is_locked(volatile _spinlock_lock_t *lock) -{ - - return (*lock != _SPINLOCK_UNLOCKED); -} diff --git a/lib/libpthread/arch/sh/uthread_machdep.c b/lib/libpthread/arch/sh/uthread_machdep.c deleted file mode 100644 index b507e01e440..00000000000 --- a/lib/libpthread/arch/sh/uthread_machdep.c +++ /dev/null @@ -1,83 +0,0 @@ -/* $OpenBSD: uthread_machdep.c,v 1.2 2007/03/02 06:11:54 miod Exp $ */ - -/* - * Copyright (c) 2007 Miodrag Vallat. - * - * 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, this permission notice, and the disclaimer below - * 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 <pthread.h> -#include "pthread_private.h" - -#define STACK_ALIGNMENT 4 - -struct regframe { - /* return address */ - register_t pr; - /* call-saved general registers */ - register_t r14; - register_t r13; - register_t r12; - register_t r11; - register_t r10; - register_t r9; - register_t r8; - register_t macl; - register_t mach; -#if defined(__SH4__) && !defined(__SH4_NOFPU__) - /* call-saved floating point registers */ - register_t fr12; - register_t fr13; - register_t fr14; - register_t fr15; - register_t xd12; - register_t xd13; - register_t xd14; - register_t xd15; - /* floating point control registers */ - register_t fpul; - register_t fpscr; -#endif -}; - -void -_thread_machdep_init(struct _machdep_state* statep, void *base, int len, - void (*entry)(void)) -{ - struct regframe *regs; - - regs = (struct regframe *) - (((u_int32_t)base + len - sizeof *regs) & ~(STACK_ALIGNMENT - 1)); - regs->pr = (register_t)entry; -#if defined(__SH4__) && !defined(__SH4_NOFPU__) - __asm__ __volatile__ ("sts fpscr, %0" : "=r" (regs->fpscr)); -#endif - - statep->sp = (u_int)regs; -} - -/* - * Floating point state is saved with the general registers in - * _thread_machdep_switch(). - */ - -void -_thread_machdep_save_float_state(struct _machdep_state* statep) -{ -} - -void -_thread_machdep_restore_float_state(struct _machdep_state* statep) -{ -} diff --git a/lib/libpthread/arch/sh/uthread_machdep.h b/lib/libpthread/arch/sh/uthread_machdep.h deleted file mode 100644 index 3277ec156c1..00000000000 --- a/lib/libpthread/arch/sh/uthread_machdep.h +++ /dev/null @@ -1,5 +0,0 @@ -/* $OpenBSD: uthread_machdep.h,v 1.2 2007/02/19 21:03:50 miod Exp $ */ - -struct _machdep_state { - u_int sp; -}; diff --git a/lib/libpthread/arch/sh/uthread_machdep_asm.S b/lib/libpthread/arch/sh/uthread_machdep_asm.S deleted file mode 100644 index 13b7111a692..00000000000 --- a/lib/libpthread/arch/sh/uthread_machdep_asm.S +++ /dev/null @@ -1,97 +0,0 @@ -/* $OpenBSD: uthread_machdep_asm.S,v 1.2 2007/03/02 06:11:54 miod Exp $ */ - -/* - * Copyright (c) 2007 Miodrag Vallat. - * - * 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, this permission notice, and the disclaimer below - * 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 <machine/asm.h> - -/* - * void _thread_machdep_switch(new, oldsave); - */ -ENTRY(_thread_machdep_switch) - /* - * On entry: r4 = new, r5 = oldsave - */ - - /* - * Save current context on the stack. - */ -#if defined(__SH4__) && !defined(__SH4_NOFPU__) - sts.l fpscr, @-r15 - mov #0, r1 - sts.l fpul, @-r15 - lds r1, fpscr - fmov.s fr15, @-r15 /* note that we can't do double stores... */ - fmov.s fr14, @-r15 /* ...as we don't control stack alignment. */ - fmov.s fr13, @-r15 - fmov.s fr12, @-r15 - frchg - fmov.s fr15, @-r15 - fmov.s fr14, @-r15 - fmov.s fr13, @-r15 - fmov.s fr12, @-r15 -#endif - sts.l mach, @-r15 - sts.l macl, @-r15 - mov.l r8, @-r15 - mov.l r9, @-r15 - mov.l r10, @-r15 - mov.l r11, @-r15 - mov.l r12, @-r15 - mov.l r13, @-r15 - mov.l r14, @-r15 - sts.l pr, @-r15 - - /* - * Switch stacks. - */ - mov.l r15, @r5 - mov.l @r4, r15 - - /* - * Restore new context. - */ - lds.l @r15+, pr - mov.l @r15+, r14 - mov.l @r15+, r13 - mov.l @r15+, r12 - mov.l @r15+, r11 - mov.l @r15+, r10 - mov.l @r15+, r9 - mov.l @r15+, r8 - lds.l @r15+, macl -#if defined(__SH4__) && !defined(__SH4_NOFPU__) - mov #0, r1 - lds.l @r15+, mach - lds r1, fpscr - frchg - fmov.s @r15+, fr12 - fmov.s @r15+, fr13 - fmov.s @r15+, fr14 - fmov.s @r15+, fr15 - frchg - fmov.s @r15+, fr12 - fmov.s @r15+, fr13 - fmov.s @r15+, fr14 - fmov.s @r15+, fr15 - lds.l @r15+, fpul - rts - lds.l @r15+, fpscr -#else - rts - lds.l @r15+, mach -#endif diff --git a/lib/libpthread/arch/sparc/_atomic_lock.c b/lib/libpthread/arch/sparc/_atomic_lock.c deleted file mode 100644 index e45bb609837..00000000000 --- a/lib/libpthread/arch/sparc/_atomic_lock.c +++ /dev/null @@ -1,43 +0,0 @@ -/* $OpenBSD: _atomic_lock.c,v 1.9 2008/10/02 23:27:23 deraadt Exp $ */ -/* David Leonard, <d@csee.uq.edu.au>. Public domain. */ - -/* - * Atomic lock for sparc - */ - -#include "spinlock.h" - -int -_atomic_lock(volatile _spinlock_lock_t * lock) -{ - _spinlock_lock_t old; - - /* - * " ldstub [address], reg_rd - * - * The atomic load-store instructions copy a byte from memory - * into r[rd]m then rewrite the addressed byte in memory to all - * ones [_SPINLOCK_LOCKED]. The operation is performed - * atomically, that is, without allowing intervening interrupts - * or deferred traps. In a multiprocessor system, two or more - * processors executing atomic load-store unsigned byte [...] - * addressing the same byte [...] simultaneously are guaranteed - * to execute them in an undefined, but serial order." - * - p101, The SPARC Architecture Manual (version 8) Prentice-Hall - * - * "LDSTUB loads a byte value from memory to a register and writes - * the value FF_16 into the addressed byte atomically. LDSTUB - * is the classic test-and-set instruction. Like SWAP, it has - * a consensus number of two and so cannot resolve more than - * two contending processes in a wait-free fashion." - * - p129, The SPARC Architecture Manual (version 9) Prentice-Hall - * (See also section J.6 (spinlocks)) - * - * (No change to the condition codes are documented.) - */ - __asm__("ldstub %0,%1" - : "=m" (*lock), "=r" (old) - : "0" (*lock)); - - return (old == _SPINLOCK_LOCKED); -} diff --git a/lib/libpthread/arch/sparc/uthread_machdep.c b/lib/libpthread/arch/sparc/uthread_machdep.c deleted file mode 100644 index f7599ef4636..00000000000 --- a/lib/libpthread/arch/sparc/uthread_machdep.c +++ /dev/null @@ -1,49 +0,0 @@ -/* $OpenBSD: uthread_machdep.c,v 1.3 2003/01/31 04:46:16 marc Exp $ */ - -/* - * Machine-dependent thread state functions for OpenBSD/sparc. - */ - -#include <machine/frame.h> -#include <machine/param.h> -#include <pthread.h> -#include "pthread_private.h" - -extern void _thread_machdep_fpsave(u_int32_t *, u_int64_t *); -extern void _thread_machdep_fprestore(u_int32_t *, u_int64_t *); - -/* - * Given a stack and an entry function, initialise a state - * structure that can be later switched to. - */ -void -_thread_machdep_init(statep, base, len, entry) - struct _machdep_state* statep; - void *base; - int len; - void (*entry)(void); -{ - struct frame *f; - - /* Locate the initial frame, aligned at the top of the stack */ - f = (struct frame *)(((int)base + len - sizeof *f) & ~ALIGNBYTES); - - f->fr_fp = (struct frame *)-1; /* purposefully misaligned */ - f->fr_pc = -1; /* for gdb */ - statep->fp = (int)f; - statep->pc = -8 + (int)entry; -} - -void -_thread_machdep_save_float_state(statep) - struct _machdep_state* statep; -{ - _thread_machdep_fpsave(&statep->fs_csr, &statep->fs_regs[0]); -} - -void -_thread_machdep_restore_float_state(statep) - struct _machdep_state* statep; -{ - _thread_machdep_fprestore(&statep->fs_csr, &statep->fs_regs[0]); -} diff --git a/lib/libpthread/arch/sparc/uthread_machdep.h b/lib/libpthread/arch/sparc/uthread_machdep.h deleted file mode 100644 index 087d47de53d..00000000000 --- a/lib/libpthread/arch/sparc/uthread_machdep.h +++ /dev/null @@ -1,11 +0,0 @@ -/* $OpenBSD: uthread_machdep.h,v 1.6 2003/01/26 20:24:36 jason Exp $ */ -/* David Leonard, <d@csee.uq.edu.au>. Public domain. */ - -struct _machdep_state { - int fp; /* frame pointer */ - int pc; /* program counter */ - - u_int32_t fs_csr; /* FP control/status */ - u_int32_t fs_enabled; /* enabled? */ - u_int64_t fs_regs[16]; /* 16 64bit registers */ -}; diff --git a/lib/libpthread/arch/sparc/uthread_machdep_asm.S b/lib/libpthread/arch/sparc/uthread_machdep_asm.S deleted file mode 100644 index 03baf530bef..00000000000 --- a/lib/libpthread/arch/sparc/uthread_machdep_asm.S +++ /dev/null @@ -1,97 +0,0 @@ -/* $OpenBSD: uthread_machdep_asm.S,v 1.9 2004/02/02 20:43:37 brad Exp $ */ -/* David Leonard <d@csee.uq.edu.au>. Public domain. */ - -#include <machine/asm.h> -#include <machine/trap.h> - -/* - * Switch stacks. - * On sparc this also means we switch register windows. - */ - -#define SA(x) (((x)+7)&(~0x7)) -#define MINFRAME ((16+1+6)*4) - -/* - * void _thread_machdep_switch(newstate, oldstate); - * struct _machdep_state *newstate, *oldstate; - */ -ENTRY(_thread_machdep_switch) - - /* new window */ - save %sp, -SA(MINFRAME), %sp - - /* flush all windows (except current one) into memory frames */ - t ST_FLUSHWIN - - /* switch the stack pointer and return address */ - st %fp, [%i1 + 0] - st %i7, [%i1 + 4] - ld [%i0 + 0], %fp - ld [%i0 + 4], %i7 - - /* return to saved window at new %fp */ - ret - restore - -/* - * void _thread_machdep_fpsave(csr, regs) - * u_int32_t *csr; - * u_int64_t *regs; - */ -ENTRY(_thread_machdep_fpsave) - /* - * If %psr were readable, exitting could be faster. The EF - * bit is only set if the FPU is enabled, and we only need - * to save fpu state if it is enabled. But, RDPSR is a - * privileged instruction. - */ - - /* save registers */ - st %fsr, [%o0] - std %f0, [%o1 + 0 * 8] - std %f2, [%o1 + 1 * 8] - std %f4, [%o1 + 2 * 8] - std %f6, [%o1 + 3 * 8] - std %f8, [%o1 + 4 * 8] - std %f10, [%o1 + 5 * 8] - std %f12, [%o1 + 6 * 8] - std %f14, [%o1 + 7 * 8] - std %f16, [%o1 + 8 * 8] - std %f18, [%o1 + 9 * 8] - std %f20, [%o1 + 10 * 8] - std %f22, [%o1 + 11 * 8] - std %f24, [%o1 + 12 * 8] - std %f26, [%o1 + 13 * 8] - std %f28, [%o1 + 14 * 8] - std %f30, [%o1 + 15 * 8] - retl - nop - -/* - * void _thread_machdep_fprestore(csr, regs) - * u_int32_t *csr; - * u_int64_t *regs; - */ -ENTRY(_thread_machdep_fprestore) - ldd [%o1 + 0 * 8], %f0 - ldd [%o1 + 1 * 8], %f2 - ldd [%o1 + 2 * 8], %f4 - ldd [%o1 + 3 * 8], %f6 - ldd [%o1 + 4 * 8], %f8 - ldd [%o1 + 5 * 8], %f10 - ldd [%o1 + 6 * 8], %f12 - ldd [%o1 + 7 * 8], %f14 - ldd [%o1 + 8 * 8], %f16 - ldd [%o1 + 9 * 8], %f18 - ldd [%o1 + 10 * 8], %f20 - ldd [%o1 + 11 * 8], %f22 - ldd [%o1 + 12 * 8], %f24 - ldd [%o1 + 13 * 8], %f26 - ldd [%o1 + 14 * 8], %f28 - ldd [%o1 + 15 * 8], %f30 - ld [%o0], %fsr - /* ldfsr needs three instructions to be stable, ensure that here */ - nop - retl - nop diff --git a/lib/libpthread/arch/sparc64/_atomic_lock.c b/lib/libpthread/arch/sparc64/_atomic_lock.c deleted file mode 100644 index de4548fb3a8..00000000000 --- a/lib/libpthread/arch/sparc64/_atomic_lock.c +++ /dev/null @@ -1,43 +0,0 @@ -/* $OpenBSD: _atomic_lock.c,v 1.5 2008/10/02 23:27:23 deraadt Exp $ */ -/* David Leonard, <d@csee.uq.edu.au>. Public domain. */ - -/* - * Atomic lock for sparc64 - */ - -#include "spinlock.h" - -int -_atomic_lock(volatile _spinlock_lock_t * lock) -{ - _spinlock_lock_t old; - - /* - * " ldstub [address], reg_rd - * - * The atomic load-store instructions copy a byte from memory - * into r[rd]m then rewrite the addressed byte in memory to all - * ones [_SPINLOCK_LOCKED]. The operation is performed - * atomically, that is, without allowing intervening interrupts - * or deferred traps. In a multiprocessor system, two or more - * processors executing atomic load-store unsigned byte [...] - * addressing the same byte [...] simultaneously are guaranteed - * to execute them in an undefined, but serial order." - * - p101, The SPARC Architecture Manual (version 8) Prentice-Hall - * - * "LDSTUB loads a byte value from memory to a register and writes - * the value FF_16 into the addressed byte atomically. LDSTUB - * is the classic test-and-set instruction. Like SWAP, it has - * a consensus number of two and so cannot resolve more than - * two contending processes in a wait-free fashion." - * - p129, The SPARC Architecture Manual (version 9) Prentice-Hall - * (See also section J.6 (spinlocks)) - * - * (No change to the condition codes are documented.) - */ - __asm__("ldstub %0,%1" - : "=m" (*lock), "=r" (old) - : "0" (*lock)); - - return (old == _SPINLOCK_LOCKED); -} diff --git a/lib/libpthread/arch/sparc64/uthread_machdep.c b/lib/libpthread/arch/sparc64/uthread_machdep.c deleted file mode 100644 index 06be142b4ee..00000000000 --- a/lib/libpthread/arch/sparc64/uthread_machdep.c +++ /dev/null @@ -1,47 +0,0 @@ -/* $OpenBSD: uthread_machdep.c,v 1.4 2004/02/02 10:05:55 brad Exp $ */ - -/* - * Machine-dependent thread state functions for OpenBSD/sparc64. - */ - -#include <sys/types.h> -#include <machine/frame.h> -#include <machine/param.h> -#include <pthread.h> -#include "pthread_private.h" - -/* - * Given a stack and an entry function, initialise a state - * structure that can be later switched to. - */ -void -_thread_machdep_init(statep, base, len, entry) - struct _machdep_state* statep; - void *base; - int len; - void (*entry)(void); -{ - struct frame64 *f; - - /* Locate the initial frame, aligned at the top of the stack */ - f = (struct frame64 *)(((long)base + len - sizeof *f) & ~ALIGNBYTES); - - f->fr_fp = 0; /* purposefully misaligned */ - f->fr_pc = -1; /* for gdb */ - statep->fp = (u_long)f - BIAS; - statep->pc = -8 + (u_long)entry; -} - -void -_thread_machdep_save_float_state(statep) - struct _machdep_state* statep; -{ - _thread_machdep_fpsave(&statep->fs_fprs); -} - -void -_thread_machdep_restore_float_state(statep) - struct _machdep_state* statep; -{ - _thread_machdep_fprestore(&statep->fs_fprs); -} diff --git a/lib/libpthread/arch/sparc64/uthread_machdep.h b/lib/libpthread/arch/sparc64/uthread_machdep.h deleted file mode 100644 index 4c746423983..00000000000 --- a/lib/libpthread/arch/sparc64/uthread_machdep.h +++ /dev/null @@ -1,15 +0,0 @@ -/* $OpenBSD: uthread_machdep.h,v 1.3 2003/01/24 21:05:45 jason Exp $ */ -/* Arutr Grabowski <art@openbsd.org>. Public domain. */ - -struct _machdep_state { - long fp; /* frame pointer */ - long pc; /* program counter */ - - /* floating point state */ - u_int64_t fs_fprs; /* fp register window status */ - u_int64_t fs_fsr; /* fp status */ - u_int64_t fs_regs[32]; /* 32 64 bit registers */ -}; - -extern void _thread_machdep_fpsave(u_int64_t *); -extern void _thread_machdep_fprestore(u_int64_t *); diff --git a/lib/libpthread/arch/sparc64/uthread_machdep_asm.S b/lib/libpthread/arch/sparc64/uthread_machdep_asm.S deleted file mode 100644 index 7b4ab4cea94..00000000000 --- a/lib/libpthread/arch/sparc64/uthread_machdep_asm.S +++ /dev/null @@ -1,135 +0,0 @@ -/* $OpenBSD: uthread_machdep_asm.S,v 1.9 2010/05/25 20:05:48 kettenis Exp $ */ -/* David Leonard <d@csee.uq.edu.au>. Public domain. */ - -#include <machine/asm.h> -#include <machine/trap.h> -#include <machine/frame.h> - -/* - * Switch stacks. - * - * On sparc64 this also means we switch register windows. - */ - -/* - * void _thread_machdep_switch(long newstate[2], long savestate[2], int flags); - */ -ENTRY(_thread_machdep_switch) - - /* new window */ - save %sp, -CC64FSZ, %sp - - /* flush all windows (except current one) into memory frames */ - flushw - - /* switch the stack pointer and return address */ - stx %fp, [%i1 + 0] - stx %i7, [%i1 + 8] - ldx [%i0 + 0], %fp - ldx [%i0 + 8], %i7 - - /* return to saved window at new %fp */ - ret - restore - -#define FPRS_ENA 0x4 /* fpu enabled */ -#define FPRS_DU 0x2 /* lower unit dirty */ -#define FPRS_DL 0x1 /* upper unit dirty */ - -ENTRY(_thread_machdep_fpsave) - rd %fprs, %o1 - stx %o1, [%o0] - andcc %o1, FPRS_ENA, %g0 - bz 1f - nop - - stx %fsr, [%o0 + 8] - add %o0, 16, %o0 - - std %f0, [%o0 + 0 * 8] /* store registers */ - std %f2, [%o0 + 1 * 8] - std %f4, [%o0 + 2 * 8] - std %f6, [%o0 + 3 * 8] - std %f8, [%o0 + 4 * 8] - std %f10, [%o0 + 5 * 8] - std %f12, [%o0 + 6 * 8] - std %f14, [%o0 + 7 * 8] - std %f16, [%o0 + 8 * 8] - std %f18, [%o0 + 9 * 8] - std %f20, [%o0 + 10 * 8] - std %f22, [%o0 + 11 * 8] - std %f24, [%o0 + 12 * 8] - std %f26, [%o0 + 13 * 8] - std %f28, [%o0 + 14 * 8] - std %f30, [%o0 + 15 * 8] - - std %f32, [%o0 + 16 * 8] /* store registers */ - std %f34, [%o0 + 17 * 8] - std %f36, [%o0 + 18 * 8] - std %f38, [%o0 + 19 * 8] - std %f40, [%o0 + 20 * 8] - std %f42, [%o0 + 21 * 8] - std %f44, [%o0 + 22 * 8] - std %f46, [%o0 + 23 * 8] - std %f48, [%o0 + 24 * 8] - std %f50, [%o0 + 25 * 8] - std %f52, [%o0 + 26 * 8] - std %f54, [%o0 + 27 * 8] - std %f56, [%o0 + 28 * 8] - std %f58, [%o0 + 29 * 8] - std %f60, [%o0 + 30 * 8] - std %f62, [%o0 + 31 * 8] - - /* disable fpu and mark both sides clean */ - wr %g0, 0, %fprs - -1: - retl - nop - -ENTRY(_thread_machdep_fprestore) - ldx [%o0], %o1 /* o1 = fprs */ - andcc %o1, FPRS_ENA, %g0 - bz 1f - nop - - wr %o1, 0, %fprs - ldx [%o0 + 8], %fsr - add %o0, 16, %o0 - - ldd [%o0 + 0 * 8], %f0 - ldd [%o0 + 1 * 8], %f2 - ldd [%o0 + 2 * 8], %f4 - ldd [%o0 + 3 * 8], %f6 - ldd [%o0 + 4 * 8], %f8 - ldd [%o0 + 5 * 8], %f10 - ldd [%o0 + 6 * 8], %f12 - ldd [%o0 + 7 * 8], %f14 - ldd [%o0 + 8 * 8], %f16 - ldd [%o0 + 9 * 8], %f18 - ldd [%o0 + 10 * 8], %f20 - ldd [%o0 + 11 * 8], %f22 - ldd [%o0 + 12 * 8], %f24 - ldd [%o0 + 13 * 8], %f26 - ldd [%o0 + 14 * 8], %f28 - ldd [%o0 + 15 * 8], %f30 - - ldd [%o0 + 16 * 8], %f32 - ldd [%o0 + 17 * 8], %f34 - ldd [%o0 + 18 * 8], %f36 - ldd [%o0 + 19 * 8], %f38 - ldd [%o0 + 20 * 8], %f40 - ldd [%o0 + 21 * 8], %f42 - ldd [%o0 + 22 * 8], %f44 - ldd [%o0 + 23 * 8], %f46 - ldd [%o0 + 24 * 8], %f48 - ldd [%o0 + 25 * 8], %f50 - ldd [%o0 + 26 * 8], %f52 - ldd [%o0 + 27 * 8], %f54 - ldd [%o0 + 28 * 8], %f56 - ldd [%o0 + 29 * 8], %f58 - ldd [%o0 + 30 * 8], %f60 - ldd [%o0 + 31 * 8], %f62 -1: - retl - nop diff --git a/lib/libpthread/arch/vax/_atomic_lock.c b/lib/libpthread/arch/vax/_atomic_lock.c deleted file mode 100644 index 5a9736995fe..00000000000 --- a/lib/libpthread/arch/vax/_atomic_lock.c +++ /dev/null @@ -1,42 +0,0 @@ -/* $OpenBSD: _atomic_lock.c,v 1.4 2003/05/19 18:31:49 miod Exp $ */ - -/* - * Atomic lock for vax - * Written by Miodrag Vallat <miod@openbsd.org> - placed in the public domain. - */ - -#include "spinlock.h" - -int -_atomic_lock(volatile _spinlock_lock_t *lock) -{ - _spinlock_lock_t old; - - /* - * The Branch on Bit Set and Set Interlocked instruction - * sets a given bit in a register or a memory location, as an - * atomic, interlocked operation. - * If the bit was set, execution continues at the branch - * location. - * - * For more details, please refer to the Vax Architecture - * Reference Manual, chapter 3 (Instructions), section - * ``Control instructions''. - */ - __asm__ ( - "movl $1, %1\n" /* _SPINLOCK_LOCKED */ - "bbssi $0, %0, 1f\n" - "movl $0, %1\n" /* _SPINLOCK_UNLOCKED */ - "1: \n" - : "=m" (*lock), "=r" (old) : "0" (*lock) - ); - - return (old != _SPINLOCK_UNLOCKED); -} - -int -_atomic_is_locked(volatile _spinlock_lock_t *lock) -{ - - return (*lock != _SPINLOCK_UNLOCKED); -} diff --git a/lib/libpthread/arch/vax/uthread_machdep.c b/lib/libpthread/arch/vax/uthread_machdep.c deleted file mode 100644 index 0315cec578a..00000000000 --- a/lib/libpthread/arch/vax/uthread_machdep.c +++ /dev/null @@ -1,72 +0,0 @@ -/* $OpenBSD: uthread_machdep.c,v 1.2 2003/05/27 22:59:33 miod Exp $ */ - -/* - * Machine-dependent thread state functions for OpenBSD/vax - * Written by Miodrag Vallat <miod@openbsd.org> - placed in the public domain. - */ - -#include <pthread.h> -#include "pthread_private.h" - -/* XXX we need <machine/asm.h> but it conflicts with <machine/cdefs.h> */ -#undef _C_LABEL -#undef WEAK_ALIAS -#include <machine/asm.h> - -#define ALIGNBYTES 3 - -struct frame { - /* a CALLS frame */ - long condition; /* sp and fp point here */ - long psw; - long ap; /* r12 */ - long fp; /* r13 */ - long pc; /* r15 */ - long r[10]; /* r2 - r11 */ - long numarg; /* ap points here */ -}; - -/* - * Given a stack and an entry function, initialize a state - * structure that can be later switched to. - */ -void -_thread_machdep_init(struct _machdep_state* statep, void *base, int len, - void (*entry)(void)) -{ - struct frame *f; - - /* Locate the initial frame, aligned at the top of the stack */ - f = (struct frame *)(((long)base + len - sizeof *f) & ~ALIGNBYTES); - - /* Set up initial frame */ - f->condition = 0; - f->psw = (1 << 29) /* CALLS */ | - ((R2|R3|R4|R5|R6|R7|R8|R9|R10|R11) << 16); - f->ap = (long)&f->numarg; - f->fp = (long)f; - - /* - * DANGER WILL ROBINSON! The thread entry point is a CALLS target - * routine, hence it starts with two bytes being the entry - * mask. We rely here upon the following facts: - * - MI code will always pass _thread_start as the entry argument - * - the entry mask for _thread_start is zero (no registers saved) - */ - f->pc = (long)entry + 2; /* skip entry mask */ - f->numarg = 0; /* safety */ - - statep->frame = f->fp; -} - -void -_thread_machdep_save_float_state(struct _machdep_state* statep) -{ - /* nothing to do */ -} - -void -_thread_machdep_restore_float_state(struct _machdep_state* statep) -{ - /* nothing to do */ -} diff --git a/lib/libpthread/arch/vax/uthread_machdep.h b/lib/libpthread/arch/vax/uthread_machdep.h deleted file mode 100644 index 75fefff1655..00000000000 --- a/lib/libpthread/arch/vax/uthread_machdep.h +++ /dev/null @@ -1,6 +0,0 @@ -/* $OpenBSD: uthread_machdep.h,v 1.1 2001/01/27 21:23:57 hugh Exp $ */ -/* David Leonard, <d@csee.uq.edu.au>. Public domain. */ - -struct _machdep_state { - int frame; -}; diff --git a/lib/libpthread/arch/vax/uthread_machdep_asm.S b/lib/libpthread/arch/vax/uthread_machdep_asm.S deleted file mode 100644 index b423a08ca93..00000000000 --- a/lib/libpthread/arch/vax/uthread_machdep_asm.S +++ /dev/null @@ -1,18 +0,0 @@ -/* $OpenBSD: uthread_machdep_asm.S,v 1.1 2003/05/27 22:59:33 miod Exp $ */ - -#include <machine/asm.h> - -/* - * Switch stacks - * Written by Miodrag Vallat <miod@openbsd.org> - placed in the public domain. - */ - -/* void _thread_machdep_switch(new, oldsave); */ -ENTRY(_thread_machdep_switch, R2|R3|R4|R5|R6|R7|R8|R9|R10|R11) - movl 8(ap), r0 /* r0 = oldsave */ - movl fp, 0(r0) /* save fp */ - - movl 4(ap), r0 /* r0 = new */ - movl 0(r0), fp - - ret |