Module Name: src Committed By: matt Date: Tue Jun 14 05:50:25 UTC 2011
Modified Files: src/sys/arch/powerpc/booke: trap.c src/sys/arch/powerpc/ibm4xx: trap.c src/sys/arch/powerpc/powerpc: powerpc_machdep.c trap.c Log Message: Make startlwp and upcallret common instead of having 3 mostly identical copies. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/arch/powerpc/booke/trap.c cvs rdiff -u -r1.59 -r1.60 src/sys/arch/powerpc/ibm4xx/trap.c cvs rdiff -u -r1.53 -r1.54 src/sys/arch/powerpc/powerpc/powerpc_machdep.c cvs rdiff -u -r1.141 -r1.142 src/sys/arch/powerpc/powerpc/trap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/powerpc/booke/trap.c diff -u src/sys/arch/powerpc/booke/trap.c:1.9 src/sys/arch/powerpc/booke/trap.c:1.10 --- src/sys/arch/powerpc/booke/trap.c:1.9 Mon Jun 13 21:12:50 2011 +++ src/sys/arch/powerpc/booke/trap.c Tue Jun 14 05:50:24 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: trap.c,v 1.9 2011/06/13 21:12:50 matt Exp $ */ +/* $NetBSD: trap.c,v 1.10 2011/06/14 05:50:24 matt Exp $ */ /*- * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc. * All rights reserved. @@ -39,7 +39,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.9 2011/06/13 21:12:50 matt Exp $"); +__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.10 2011/06/14 05:50:24 matt Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -51,7 +51,6 @@ #include <sys/savar.h> #endif #include <sys/kauth.h> -#include <sys/kmem.h> #include <sys/ras.h> #include <uvm/uvm_extern.h> @@ -897,26 +896,3 @@ userret(l, tf); } } - -void -upcallret(struct lwp *l) -{ - - mi_userret(l); /* Invoke MI userret code */ -} - -/* - * Start a new LWP - */ -void -startlwp(void *arg) -{ - ucontext_t * const uc = arg; - struct lwp * const l = curlwp; - - int error = cpu_setmcontext(l, &uc->uc_mcontext, uc->uc_flags); - KASSERT(error == 0); - (void)error; - kmem_free(uc, sizeof(ucontext_t)); - upcallret(l); -} Index: src/sys/arch/powerpc/ibm4xx/trap.c diff -u src/sys/arch/powerpc/ibm4xx/trap.c:1.59 src/sys/arch/powerpc/ibm4xx/trap.c:1.60 --- src/sys/arch/powerpc/ibm4xx/trap.c:1.59 Sun Jun 5 16:52:25 2011 +++ src/sys/arch/powerpc/ibm4xx/trap.c Tue Jun 14 05:50:24 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: trap.c,v 1.59 2011/06/05 16:52:25 matt Exp $ */ +/* $NetBSD: trap.c,v 1.60 2011/06/14 05:50:24 matt Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -67,7 +67,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.59 2011/06/05 16:52:25 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.60 2011/06/14 05:50:24 matt Exp $"); #include "opt_altivec.h" #include "opt_ddb.h" @@ -82,7 +82,6 @@ #include <sys/savar.h> #include <sys/userret.h> #include <sys/kauth.h> -#include <sys/kmem.h> #if defined(KGDB) #include <sys/kgdb.h> @@ -707,31 +706,3 @@ return -1; } - -/* - * Start a new LWP - */ -void -startlwp(void *arg) -{ - ucontext_t *uc = arg; - lwp_t *l = curlwp; - int error; - - error = cpu_setmcontext(l, &uc->uc_mcontext, uc->uc_flags); - KASSERT(error == 0); - - kmem_free(uc, sizeof(ucontext_t)); - upcallret(l); -} - -/* - * XXX This is a terrible name. - */ -void -upcallret(struct lwp *l) -{ - - /* Invoke MI userret code */ - mi_userret(l); -} Index: src/sys/arch/powerpc/powerpc/powerpc_machdep.c diff -u src/sys/arch/powerpc/powerpc/powerpc_machdep.c:1.53 src/sys/arch/powerpc/powerpc/powerpc_machdep.c:1.54 --- src/sys/arch/powerpc/powerpc/powerpc_machdep.c:1.53 Tue Jun 14 03:12:43 2011 +++ src/sys/arch/powerpc/powerpc/powerpc_machdep.c Tue Jun 14 05:50:25 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: powerpc_machdep.c,v 1.53 2011/06/14 03:12:43 matt Exp $ */ +/* $NetBSD: powerpc_machdep.c,v 1.54 2011/06/14 05:50:25 matt Exp $ */ /* * Copyright (C) 1995, 1996 Wolfgang Solfrank. @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: powerpc_machdep.c,v 1.53 2011/06/14 03:12:43 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: powerpc_machdep.c,v 1.54 2011/06/14 05:50:25 matt Exp $"); #include "opt_altivec.h" #include "opt_modular.h" @@ -55,11 +55,13 @@ #include <sys/device.h> #include <sys/pcu.h> #include <sys/atomic.h> +#include <sys/kmem.h> #include <sys/xcall.h> #include <dev/mm.h> #include <powerpc/pcb.h> +#include <powerpc/userret.h> #include <powerpc/fpu.h> #if defined(ALTIVEC) || defined(PPC_HAVE_SPE) #include <powerpc/altivec.h> @@ -299,6 +301,33 @@ dumplo = nblks - ctod(dumpsize); } +/* + * Start a new LWP + */ +void +startlwp(void *arg) +{ + ucontext_t * const uc = arg; + lwp_t * const l = curlwp; + struct trapframe * const tf = l->l_md.md_utf; + int error; + + error = cpu_setmcontext(l, &uc->uc_mcontext, uc->uc_flags); + KASSERT(error == 0); + + kmem_free(uc, sizeof(ucontext_t)); + userret(l, tf); +} + +void +upcallret(struct lwp *l) +{ + struct trapframe * const tf = l->l_md.md_utf; + + KERNEL_UNLOCK_LAST(l); + userret(l, tf); +} + void cpu_upcall(struct lwp *l, int type, int nevents, int ninterrupted, void *sas, void *ap, void *sp, sa_upcall_t upcall) @@ -377,9 +406,9 @@ atomic_or_uint(&l->l_dopreempt, DOPREEMPT_ACTIVE); if (ci == cur_ci) { softint_trigger(SOFTINT_KPREEMPT); - } else { - cpu_send_ipi(cpu_index(ci), IPI_KPREEMPT); - } + } else { + cpu_send_ipi(cpu_index(ci), IPI_KPREEMPT); + } return; } #endif Index: src/sys/arch/powerpc/powerpc/trap.c diff -u src/sys/arch/powerpc/powerpc/trap.c:1.141 src/sys/arch/powerpc/powerpc/trap.c:1.142 --- src/sys/arch/powerpc/powerpc/trap.c:1.141 Sun Jun 5 16:52:26 2011 +++ src/sys/arch/powerpc/powerpc/trap.c Tue Jun 14 05:50:25 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: trap.c,v 1.141 2011/06/05 16:52:26 matt Exp $ */ +/* $NetBSD: trap.c,v 1.142 2011/06/14 05:50:25 matt Exp $ */ /* * Copyright (C) 1995, 1996 Wolfgang Solfrank. @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.141 2011/06/05 16:52:26 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.142 2011/06/14 05:50:25 matt Exp $"); #include "opt_altivec.h" #include "opt_ddb.h" @@ -47,7 +47,6 @@ #include <sys/savar.h> #include <sys/systm.h> #include <sys/kauth.h> -#include <sys/kmem.h> #include <uvm/uvm_extern.h> @@ -908,30 +907,3 @@ curpcb->pcb_onfault = 0; return rv; } - -/* - * Start a new LWP - */ -void -startlwp(void *arg) -{ - ucontext_t * const uc = arg; - lwp_t * const l = curlwp; - struct trapframe * const tf = l->l_md.md_utf; - int error; - - error = cpu_setmcontext(l, &uc->uc_mcontext, uc->uc_flags); - KASSERT(error == 0); - - kmem_free(uc, sizeof(ucontext_t)); - userret(l, tf); -} - -void -upcallret(struct lwp *l) -{ - struct trapframe * const tf = l->l_md.md_utf; - - KERNEL_UNLOCK_LAST(l); - userret(l, tf); -}