diff options
author | ian <ian@FreeBSD.org> | 2014-05-14 03:09:37 +0000 |
---|---|---|
committer | ian <ian@FreeBSD.org> | 2014-05-14 03:09:37 +0000 |
commit | f7cf17218ee8bf6a98118da7f5be833e053c2b36 (patch) | |
tree | 9d2af9a13e8605945b5bdeeab8f97eaa7d8aac3b /sys/powerpc/aim | |
parent | 14106897a198286392ed1343f8984675609d1e2a (diff) | |
download | FreeBSD-src-f7cf17218ee8bf6a98118da7f5be833e053c2b36.zip FreeBSD-src-f7cf17218ee8bf6a98118da7f5be833e053c2b36.tar.gz |
MFC r258002, r258024, r258027, r258051, r258052, r258243, r258244, r258002,
r258024, r258027, r258051, r258052, r258243,
Follow up r223485, which made AIM use the ABI thread pointer instead of
PCPU fields for curthread, by doing the same to Book-E.
Use the same implementation of copyinout.c for both AIM and Book-E.
Actually add IOMMU domain to the list of known mappings.
Following the approach with ACPI DMAR on x86, split IOMMU handling into
a variant PCI bus instead of trying to shoehorn it into the PCI host bridge
adapter.
Make sure that TLB1 mappings are aligned correctly.
Diffstat (limited to 'sys/powerpc/aim')
-rw-r--r-- | sys/powerpc/aim/copyinout.c | 522 | ||||
-rw-r--r-- | sys/powerpc/aim/swtch32.S | 198 | ||||
-rw-r--r-- | sys/powerpc/aim/swtch64.S | 287 |
3 files changed, 0 insertions, 1007 deletions
diff --git a/sys/powerpc/aim/copyinout.c b/sys/powerpc/aim/copyinout.c deleted file mode 100644 index 69ba431..0000000 --- a/sys/powerpc/aim/copyinout.c +++ /dev/null @@ -1,522 +0,0 @@ -/*- - * Copyright (C) 2002 Benno Rice - * 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 Benno Rice ``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 TOOLS GMBH 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) 1993 Wolfgang Solfrank. - * Copyright (C) 1993 TooLs GmbH. - * 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 TooLs GmbH. - * 4. The name of TooLs GmbH may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <sys/param.h> -#include <sys/lock.h> -#include <sys/mutex.h> -#include <sys/systm.h> -#include <sys/proc.h> - -#include <vm/vm.h> -#include <vm/pmap.h> -#include <vm/vm_map.h> - -#include <machine/pcb.h> -#include <machine/sr.h> -#include <machine/slb.h> - -int setfault(faultbuf); /* defined in locore.S */ - -/* - * Makes sure that the right segment of userspace is mapped in. - */ - -#ifdef __powerpc64__ -static __inline void -set_user_sr(pmap_t pm, const void *addr) -{ - struct slb *slb; - register_t slbv; - - /* Try lockless look-up first */ - slb = user_va_to_slb_entry(pm, (vm_offset_t)addr); - - if (slb == NULL) { - /* If it isn't there, we need to pre-fault the VSID */ - PMAP_LOCK(pm); - slbv = va_to_vsid(pm, (vm_offset_t)addr) << SLBV_VSID_SHIFT; - PMAP_UNLOCK(pm); - } else { - slbv = slb->slbv; - } - - /* Mark segment no-execute */ - slbv |= SLBV_N; - - /* If we have already set this VSID, we can just return */ - if (curthread->td_pcb->pcb_cpu.aim.usr_vsid == slbv) - return; - - __asm __volatile("isync"); - curthread->td_pcb->pcb_cpu.aim.usr_segm = - (uintptr_t)addr >> ADDR_SR_SHFT; - curthread->td_pcb->pcb_cpu.aim.usr_vsid = slbv; - __asm __volatile ("slbie %0; slbmte %1, %2; isync" :: - "r"(USER_ADDR), "r"(slbv), "r"(USER_SLB_SLBE)); -} -#else -static __inline void -set_user_sr(pmap_t pm, const void *addr) -{ - register_t vsid; - - vsid = va_to_vsid(pm, (vm_offset_t)addr); - - /* Mark segment no-execute */ - vsid |= SR_N; - - /* If we have already set this VSID, we can just return */ - if (curthread->td_pcb->pcb_cpu.aim.usr_vsid == vsid) - return; - - __asm __volatile("isync"); - curthread->td_pcb->pcb_cpu.aim.usr_segm = - (uintptr_t)addr >> ADDR_SR_SHFT; - curthread->td_pcb->pcb_cpu.aim.usr_vsid = vsid; - __asm __volatile("mtsr %0,%1; isync" :: "n"(USER_SR), "r"(vsid)); -} -#endif - -int -copyout(const void *kaddr, void *udaddr, size_t len) -{ - struct thread *td; - pmap_t pm; - faultbuf env; - const char *kp; - char *up, *p; - size_t l; - - td = curthread; - pm = &td->td_proc->p_vmspace->vm_pmap; - - if (setfault(env)) { - td->td_pcb->pcb_onfault = NULL; - return (EFAULT); - } - - kp = kaddr; - up = udaddr; - - while (len > 0) { - p = (char *)USER_ADDR + ((uintptr_t)up & ~SEGMENT_MASK); - - l = ((char *)USER_ADDR + SEGMENT_LENGTH) - p; - if (l > len) - l = len; - - set_user_sr(pm,up); - - bcopy(kp, p, l); - - up += l; - kp += l; - len -= l; - } - - td->td_pcb->pcb_onfault = NULL; - return (0); -} - -int -copyin(const void *udaddr, void *kaddr, size_t len) -{ - struct thread *td; - pmap_t pm; - faultbuf env; - const char *up; - char *kp, *p; - size_t l; - - td = curthread; - pm = &td->td_proc->p_vmspace->vm_pmap; - - if (setfault(env)) { - td->td_pcb->pcb_onfault = NULL; - return (EFAULT); - } - - kp = kaddr; - up = udaddr; - - while (len > 0) { - p = (char *)USER_ADDR + ((uintptr_t)up & ~SEGMENT_MASK); - - l = ((char *)USER_ADDR + SEGMENT_LENGTH) - p; - if (l > len) - l = len; - - set_user_sr(pm,up); - - bcopy(p, kp, l); - - up += l; - kp += l; - len -= l; - } - - td->td_pcb->pcb_onfault = NULL; - return (0); -} - -int -copyinstr(const void *udaddr, void *kaddr, size_t len, size_t *done) -{ - struct thread *td; - pmap_t pm; - faultbuf env; - const char *up; - char *kp; - size_t l; - int rv, c; - - td = curthread; - pm = &td->td_proc->p_vmspace->vm_pmap; - - if (setfault(env)) { - td->td_pcb->pcb_onfault = NULL; - return (EFAULT); - } - - kp = kaddr; - up = udaddr; - - rv = ENAMETOOLONG; - - for (l = 0; len-- > 0; l++) { - if ((c = fubyte(up++)) < 0) { - rv = EFAULT; - break; - } - - if (!(*kp++ = c)) { - l++; - rv = 0; - break; - } - } - - if (done != NULL) { - *done = l; - } - - td->td_pcb->pcb_onfault = NULL; - return (rv); -} - -int -subyte(void *addr, int byte) -{ - struct thread *td; - pmap_t pm; - faultbuf env; - char *p; - - td = curthread; - pm = &td->td_proc->p_vmspace->vm_pmap; - p = (char *)(USER_ADDR + ((uintptr_t)addr & ~SEGMENT_MASK)); - - if (setfault(env)) { - td->td_pcb->pcb_onfault = NULL; - return (-1); - } - - set_user_sr(pm,addr); - - *p = (char)byte; - - td->td_pcb->pcb_onfault = NULL; - return (0); -} - -#ifdef __powerpc64__ -int -suword32(void *addr, int word) -{ - struct thread *td; - pmap_t pm; - faultbuf env; - int *p; - - td = curthread; - pm = &td->td_proc->p_vmspace->vm_pmap; - p = (int *)(USER_ADDR + ((uintptr_t)addr & ~SEGMENT_MASK)); - - if (setfault(env)) { - td->td_pcb->pcb_onfault = NULL; - return (-1); - } - - set_user_sr(pm,addr); - - *p = word; - - td->td_pcb->pcb_onfault = NULL; - return (0); -} -#endif - -int -suword(void *addr, long word) -{ - struct thread *td; - pmap_t pm; - faultbuf env; - long *p; - - td = curthread; - pm = &td->td_proc->p_vmspace->vm_pmap; - p = (long *)(USER_ADDR + ((uintptr_t)addr & ~SEGMENT_MASK)); - - if (setfault(env)) { - td->td_pcb->pcb_onfault = NULL; - return (-1); - } - - set_user_sr(pm,addr); - - *p = word; - - td->td_pcb->pcb_onfault = NULL; - return (0); -} - -#ifdef __powerpc64__ -int -suword64(void *addr, int64_t word) -{ - return (suword(addr, (long)word)); -} -#else -int -suword32(void *addr, int32_t word) -{ - return (suword(addr, (long)word)); -} -#endif - -int -fubyte(const void *addr) -{ - struct thread *td; - pmap_t pm; - faultbuf env; - u_char *p; - int val; - - td = curthread; - pm = &td->td_proc->p_vmspace->vm_pmap; - p = (u_char *)(USER_ADDR + ((uintptr_t)addr & ~SEGMENT_MASK)); - - if (setfault(env)) { - td->td_pcb->pcb_onfault = NULL; - return (-1); - } - - set_user_sr(pm,addr); - - val = *p; - - td->td_pcb->pcb_onfault = NULL; - return (val); -} - -#ifdef __powerpc64__ -int32_t -fuword32(const void *addr) -{ - struct thread *td; - pmap_t pm; - faultbuf env; - int32_t *p, val; - - td = curthread; - pm = &td->td_proc->p_vmspace->vm_pmap; - p = (int32_t *)(USER_ADDR + ((uintptr_t)addr & ~SEGMENT_MASK)); - - if (setfault(env)) { - td->td_pcb->pcb_onfault = NULL; - return (-1); - } - - set_user_sr(pm,addr); - - val = *p; - - td->td_pcb->pcb_onfault = NULL; - return (val); -} -#endif - -long -fuword(const void *addr) -{ - struct thread *td; - pmap_t pm; - faultbuf env; - long *p, val; - - td = curthread; - pm = &td->td_proc->p_vmspace->vm_pmap; - p = (long *)(USER_ADDR + ((uintptr_t)addr & ~SEGMENT_MASK)); - - if (setfault(env)) { - td->td_pcb->pcb_onfault = NULL; - return (-1); - } - - set_user_sr(pm,addr); - - val = *p; - - td->td_pcb->pcb_onfault = NULL; - return (val); -} - -#ifndef __powerpc64__ -int32_t -fuword32(const void *addr) -{ - return ((int32_t)fuword(addr)); -} -#endif - -uint32_t -casuword32(volatile uint32_t *addr, uint32_t old, uint32_t new) -{ - struct thread *td; - pmap_t pm; - faultbuf env; - uint32_t *p, val; - - td = curthread; - pm = &td->td_proc->p_vmspace->vm_pmap; - p = (uint32_t *)(USER_ADDR + ((uintptr_t)addr & ~SEGMENT_MASK)); - - set_user_sr(pm,(const void *)(vm_offset_t)addr); - - if (setfault(env)) { - td->td_pcb->pcb_onfault = NULL; - return (-1); - } - - __asm __volatile ( - "1:\tlwarx %0, 0, %2\n\t" /* load old value */ - "cmplw %3, %0\n\t" /* compare */ - "bne 2f\n\t" /* exit if not equal */ - "stwcx. %4, 0, %2\n\t" /* attempt to store */ - "bne- 1b\n\t" /* spin if failed */ - "b 3f\n\t" /* we've succeeded */ - "2:\n\t" - "stwcx. %0, 0, %2\n\t" /* clear reservation (74xx) */ - "3:\n\t" - : "=&r" (val), "=m" (*p) - : "r" (p), "r" (old), "r" (new), "m" (*p) - : "cc", "memory"); - - td->td_pcb->pcb_onfault = NULL; - - return (val); -} - -#ifndef __powerpc64__ -u_long -casuword(volatile u_long *addr, u_long old, u_long new) -{ - return (casuword32((volatile uint32_t *)addr, old, new)); -} -#else -u_long -casuword(volatile u_long *addr, u_long old, u_long new) -{ - struct thread *td; - pmap_t pm; - faultbuf env; - u_long *p, val; - - td = curthread; - pm = &td->td_proc->p_vmspace->vm_pmap; - p = (u_long *)(USER_ADDR + ((uintptr_t)addr & ~SEGMENT_MASK)); - - set_user_sr(pm,(const void *)(vm_offset_t)addr); - - if (setfault(env)) { - td->td_pcb->pcb_onfault = NULL; - return (-1); - } - - __asm __volatile ( - "1:\tldarx %0, 0, %2\n\t" /* load old value */ - "cmpld %3, %0\n\t" /* compare */ - "bne 2f\n\t" /* exit if not equal */ - "stdcx. %4, 0, %2\n\t" /* attempt to store */ - "bne- 1b\n\t" /* spin if failed */ - "b 3f\n\t" /* we've succeeded */ - "2:\n\t" - "stdcx. %0, 0, %2\n\t" /* clear reservation (74xx) */ - "3:\n\t" - : "=&r" (val), "=m" (*p) - : "r" (p), "r" (old), "r" (new), "m" (*p) - : "cc", "memory"); - - td->td_pcb->pcb_onfault = NULL; - - return (val); -} -#endif - diff --git a/sys/powerpc/aim/swtch32.S b/sys/powerpc/aim/swtch32.S deleted file mode 100644 index fa87aba..0000000 --- a/sys/powerpc/aim/swtch32.S +++ /dev/null @@ -1,198 +0,0 @@ -/* $FreeBSD$ */ -/* $NetBSD: locore.S,v 1.24 2000/05/31 05:09:17 thorpej Exp $ */ - -/*- - * Copyright (C) 2001 Benno Rice - * 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 Benno Rice ``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 TOOLS GMBH 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, 1996 Wolfgang Solfrank. - * Copyright (C) 1995, 1996 TooLs GmbH. - * 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 TooLs GmbH. - * 4. The name of TooLs GmbH may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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 "assym.s" -#include "opt_sched.h" - -#include <sys/syscall.h> - -#include <machine/trap.h> -#include <machine/param.h> -#include <machine/asm.h> - -/* - * void cpu_throw(struct thread *old, struct thread *new) - */ -ENTRY(cpu_throw) - mr %r2, %r4 - b cpu_switchin - -/* - * void cpu_switch(struct thread *old, - * struct thread *new, - * struct mutex *mtx); - * - * Switch to a new thread saving the current state in the old thread. - */ -ENTRY(cpu_switch) - lwz %r6,TD_PCB(%r3) /* Get the old thread's PCB ptr */ - stmw %r12,PCB_CONTEXT(%r6) /* Save the non-volatile GP regs. - These can now be used for scratch */ - - mfcr %r16 /* Save the condition register */ - stw %r16,PCB_CR(%r6) - mflr %r16 /* Save the link register */ - stw %r16,PCB_LR(%r6) - stw %r1,PCB_SP(%r6) /* Save the stack pointer */ - - mr %r14,%r3 /* Copy the old thread ptr... */ - mr %r2,%r4 /* and the new thread ptr in curthread */ - mr %r16,%r5 /* and the new lock */ - mr %r17,%r6 /* and the PCB */ - - lwz %r7,PCB_FLAGS(%r17) - /* Save FPU context if needed */ - andi. %r7, %r7, PCB_FPU - beq .L1 - bl save_fpu - -.L1: - mr %r3,%r14 /* restore old thread ptr */ - lwz %r7,PCB_FLAGS(%r17) - /* Save Altivec context if needed */ - andi. %r7, %r7, PCB_VEC - beq .L2 - bl save_vec - -.L2: - mr %r3,%r14 /* restore old thread ptr */ - bl pmap_deactivate /* Deactivate the current pmap */ - - sync /* Make sure all of that finished */ - stw %r16,TD_LOCK(%r14) /* ULE: update old thread's lock */ - -cpu_switchin: -#if defined(SMP) && defined(SCHED_ULE) - /* Wait for the new thread to become unblocked */ - lis %r6,blocked_lock@ha - addi %r6,%r6,blocked_lock@l -blocked_loop: - lwz %r7,TD_LOCK(%r2) - cmpw %r6,%r7 - beq- blocked_loop - isync -#endif - - mfsprg %r7,0 /* Get the pcpu pointer */ - stw %r2,PC_CURTHREAD(%r7) /* Store new current thread */ - lwz %r17,TD_PCB(%r2) /* Store new current PCB */ - stw %r17,PC_CURPCB(%r7) - - mr %r3,%r2 /* Get new thread ptr */ - bl pmap_activate /* Activate the new address space */ - - lwz %r6, PCB_FLAGS(%r17) - /* Restore FPU context if needed */ - andi. %r6, %r6, PCB_FPU - beq .L3 - mr %r3,%r2 /* Pass curthread to enable_fpu */ - bl enable_fpu - -.L3: - lwz %r6, PCB_FLAGS(%r17) - /* Restore Altivec context if needed */ - andi. %r6, %r6, PCB_VEC - beq .L4 - mr %r3,%r2 /* Pass curthread to enable_vec */ - bl enable_vec - - /* thread to restore is in r3 */ -.L4: - mr %r3,%r17 /* Recover PCB ptr */ - lmw %r12,PCB_CONTEXT(%r3) /* Load the non-volatile GP regs */ - lwz %r5,PCB_CR(%r3) /* Load the condition register */ - mtcr %r5 - lwz %r5,PCB_LR(%r3) /* Load the link register */ - mtlr %r5 - lwz %r5,PCB_AIM_USR_VSID(%r3) /* Load the USER_SR segment reg */ - isync - mtsr USER_SR,%r5 - isync - lwz %r1,PCB_SP(%r3) /* Load the stack pointer */ - /* - * Perform a dummy stwcx. to clear any reservations we may have - * inherited from the previous thread. It doesn't matter if the - * stwcx succeeds or not. pcb_context[0] can be clobbered. - */ - stwcx. %r1, 0, %r3 - blr - -/* - * savectx(pcb) - * Update pcb, saving current processor state - */ -ENTRY(savectx) - stmw %r12,PCB_CONTEXT(%r3) /* Save the non-volatile GP regs */ - mfcr %r4 /* Save the condition register */ - stw %r4,PCB_CR(%r3) - blr - -/* - * fork_trampoline() - * Set up the return from cpu_fork() - */ -ENTRY(fork_trampoline) - lwz %r3,CF_FUNC(%r1) - lwz %r4,CF_ARG0(%r1) - lwz %r5,CF_ARG1(%r1) - bl fork_exit - addi %r1,%r1,CF_SIZE-FSP /* Allow 8 bytes in front of - trapframe to simulate FRAME_SETUP - does when allocating space for - a frame pointer/saved LR */ - b trapexit diff --git a/sys/powerpc/aim/swtch64.S b/sys/powerpc/aim/swtch64.S deleted file mode 100644 index ab6f532..0000000 --- a/sys/powerpc/aim/swtch64.S +++ /dev/null @@ -1,287 +0,0 @@ -/* $FreeBSD$ */ -/* $NetBSD: locore.S,v 1.24 2000/05/31 05:09:17 thorpej Exp $ */ - -/*- - * Copyright (C) 2001 Benno Rice - * 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 Benno Rice ``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 TOOLS GMBH 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, 1996 Wolfgang Solfrank. - * Copyright (C) 1995, 1996 TooLs GmbH. - * 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 TooLs GmbH. - * 4. The name of TooLs GmbH may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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 "assym.s" -#include "opt_sched.h" - -#include <sys/syscall.h> - -#include <machine/trap.h> -#include <machine/param.h> -#include <machine/asm.h> - -/* - * void cpu_throw(struct thread *old, struct thread *new) - */ -ENTRY(cpu_throw) - mr %r13, %r4 - b cpu_switchin - -/* - * void cpu_switch(struct thread *old, - * struct thread *new, - * struct mutex *mtx); - * - * Switch to a new thread saving the current state in the old thread. - */ -ENTRY(cpu_switch) - ld %r6,TD_PCB(%r3) /* Get the old thread's PCB ptr */ - std %r12,PCB_CONTEXT(%r6) /* Save the non-volatile GP regs. - These can now be used for scratch */ - std %r14,PCB_CONTEXT+2*8(%r6) - std %r15,PCB_CONTEXT+3*8(%r6) - std %r16,PCB_CONTEXT+4*8(%r6) - std %r17,PCB_CONTEXT+5*8(%r6) - std %r18,PCB_CONTEXT+6*8(%r6) - std %r19,PCB_CONTEXT+7*8(%r6) - std %r20,PCB_CONTEXT+8*8(%r6) - std %r21,PCB_CONTEXT+9*8(%r6) - std %r22,PCB_CONTEXT+10*8(%r6) - std %r23,PCB_CONTEXT+11*8(%r6) - std %r24,PCB_CONTEXT+12*8(%r6) - std %r25,PCB_CONTEXT+13*8(%r6) - std %r26,PCB_CONTEXT+14*8(%r6) - std %r27,PCB_CONTEXT+15*8(%r6) - std %r28,PCB_CONTEXT+16*8(%r6) - std %r29,PCB_CONTEXT+17*8(%r6) - std %r30,PCB_CONTEXT+18*8(%r6) - std %r31,PCB_CONTEXT+19*8(%r6) - - mfcr %r16 /* Save the condition register */ - std %r16,PCB_CR(%r6) - mflr %r16 /* Save the link register */ - std %r16,PCB_LR(%r6) - std %r1,PCB_SP(%r6) /* Save the stack pointer */ - std %r2,PCB_TOC(%r6) /* Save the TOC pointer */ - - mr %r14,%r3 /* Copy the old thread ptr... */ - mr %r13,%r4 /* and the new thread ptr in curthread*/ - mr %r16,%r5 /* and the new lock */ - mr %r17,%r6 /* and the PCB */ - - stdu %r1,-48(%r1) - - lwz %r7,PCB_FLAGS(%r17) - /* Save FPU context if needed */ - andi. %r7, %r7, PCB_FPU - beq .L1 - bl save_fpu - nop - -.L1: - mr %r3,%r14 /* restore old thread ptr */ - lwz %r7,PCB_FLAGS(%r17) - /* Save Altivec context if needed */ - andi. %r7, %r7, PCB_VEC - beq .L2 - bl save_vec - nop - -.L2: - mr %r3,%r14 /* restore old thread ptr */ - bl pmap_deactivate /* Deactivate the current pmap */ - nop - - addi %r1,%r1,48 - - sync /* Make sure all of that finished */ - std %r16,TD_LOCK(%r14) /* ULE: update old thread's lock */ - -cpu_switchin: -#if defined(SMP) && defined(SCHED_ULE) - /* Wait for the new thread to become unblocked */ - lis %r6,blocked_lock@ha - addi %r6,%r6,blocked_lock@l -blocked_loop: - ld %r7,TD_LOCK(%r13) - cmpd %r6,%r7 - beq- blocked_loop - isync -#endif - - mfsprg %r7,0 /* Get the pcpu pointer */ - std %r13,PC_CURTHREAD(%r7) /* Store new current thread */ - ld %r17,TD_PCB(%r13) /* Store new current PCB */ - std %r17,PC_CURPCB(%r7) - - stdu %r1,-48(%r1) - - mr %r3,%r13 /* Get new thread ptr */ - bl pmap_activate /* Activate the new address space */ - nop - - lwz %r6, PCB_FLAGS(%r17) - /* Restore FPU context if needed */ - andi. %r6, %r6, PCB_FPU - beq .L3 - mr %r3,%r13 /* Pass curthread to enable_fpu */ - bl enable_fpu - nop - -.L3: - lwz %r6, PCB_FLAGS(%r17) - /* Restore Altivec context if needed */ - andi. %r6, %r6, PCB_VEC - beq .L4 - mr %r3,%r13 /* Pass curthread to enable_vec */ - bl enable_vec - nop - - /* thread to restore is in r3 */ -.L4: - addi %r1,%r1,48 - mr %r3,%r17 /* Recover PCB ptr */ - ld %r12,PCB_CONTEXT(%r3) /* Load the non-volatile GP regs. */ - ld %r14,PCB_CONTEXT+2*8(%r3) - ld %r15,PCB_CONTEXT+3*8(%r3) - ld %r16,PCB_CONTEXT+4*8(%r3) - ld %r17,PCB_CONTEXT+5*8(%r3) - ld %r18,PCB_CONTEXT+6*8(%r3) - ld %r19,PCB_CONTEXT+7*8(%r3) - ld %r20,PCB_CONTEXT+8*8(%r3) - ld %r21,PCB_CONTEXT+9*8(%r3) - ld %r22,PCB_CONTEXT+10*8(%r3) - ld %r23,PCB_CONTEXT+11*8(%r3) - ld %r24,PCB_CONTEXT+12*8(%r3) - ld %r25,PCB_CONTEXT+13*8(%r3) - ld %r26,PCB_CONTEXT+14*8(%r3) - ld %r27,PCB_CONTEXT+15*8(%r3) - ld %r28,PCB_CONTEXT+16*8(%r3) - ld %r29,PCB_CONTEXT+17*8(%r3) - ld %r30,PCB_CONTEXT+18*8(%r3) - ld %r31,PCB_CONTEXT+19*8(%r3) - ld %r5,PCB_CR(%r3) /* Load the condition register */ - mtcr %r5 - ld %r5,PCB_LR(%r3) /* Load the link register */ - mtlr %r5 - ld %r1,PCB_SP(%r3) /* Load the stack pointer */ - ld %r2,PCB_TOC(%r3) /* Load the TOC pointer */ - - lis %r5,USER_ADDR@highesta /* Load the copyin/out segment reg */ - ori %r5,%r5,USER_ADDR@highera - sldi %r5,%r5,32 - oris %r5,%r5,USER_ADDR@ha - isync - slbie %r5 - lis %r6,USER_SLB_SLBE@highesta - ori %r6,%r6,USER_SLB_SLBE@highera - sldi %r6,%r6,32 - oris %r6,%r6,USER_SLB_SLBE@ha - ori %r6,%r6,USER_SLB_SLBE@l - ld %r5,PCB_AIM_USR_VSID(%r3) - slbmte %r5,%r6 - isync - - /* - * Perform a dummy stdcx. to clear any reservations we may have - * inherited from the previous thread. It doesn't matter if the - * stdcx succeeds or not. pcb_context[0] can be clobbered. - */ - stdcx. %r1, 0, %r3 - blr - -/* - * savectx(pcb) - * Update pcb, saving current processor state - */ -ENTRY(savectx) - std %r12,PCB_CONTEXT(%r3) /* Save the non-volatile GP regs. */ - std %r13,PCB_CONTEXT+1*8(%r3) - std %r14,PCB_CONTEXT+2*8(%r3) - std %r15,PCB_CONTEXT+3*8(%r3) - std %r16,PCB_CONTEXT+4*8(%r3) - std %r17,PCB_CONTEXT+5*8(%r3) - std %r18,PCB_CONTEXT+6*8(%r3) - std %r19,PCB_CONTEXT+7*8(%r3) - std %r20,PCB_CONTEXT+8*8(%r3) - std %r21,PCB_CONTEXT+9*8(%r3) - std %r22,PCB_CONTEXT+10*8(%r3) - std %r23,PCB_CONTEXT+11*8(%r3) - std %r24,PCB_CONTEXT+12*8(%r3) - std %r25,PCB_CONTEXT+13*8(%r3) - std %r26,PCB_CONTEXT+14*8(%r3) - std %r27,PCB_CONTEXT+15*8(%r3) - std %r28,PCB_CONTEXT+16*8(%r3) - std %r29,PCB_CONTEXT+17*8(%r3) - std %r30,PCB_CONTEXT+18*8(%r3) - std %r31,PCB_CONTEXT+19*8(%r3) - - mfcr %r4 /* Save the condition register */ - std %r4,PCB_CR(%r3) - std %r2,PCB_TOC(%r3) /* Save the TOC pointer */ - blr - -/* - * fork_trampoline() - * Set up the return from cpu_fork() - */ - -ENTRY_NOPROF(fork_trampoline) - ld %r3,CF_FUNC(%r1) - ld %r4,CF_ARG0(%r1) - ld %r5,CF_ARG1(%r1) - - stdu %r1,-48(%r1) - bl fork_exit - nop - addi %r1,%r1,48+CF_SIZE-FSP /* Allow 8 bytes in front of - trapframe to simulate FRAME_SETUP - does when allocating space for - a frame pointer/saved LR */ - b trapexit - nop |