Make startlwp and upcallret common instead of having 3 mostly identical copies.

This commit is contained in:
matt 2011-06-14 05:50:24 +00:00
parent 4ed8a65b0d
commit eeac0b0545
4 changed files with 40 additions and 92 deletions

View File

@ -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 @@ __KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.9 2011/06/13 21:12:50 matt Exp $");
#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 @@ trap(enum ppc_booke_exceptions trap_code, struct trapframe *tf)
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);
}

View File

@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.59 2011/06/05 16:52:25 matt Exp $");
#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 @@ fix_unaligned(struct lwp *l, struct trapframe *tf)
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);
}

View File

@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: powerpc_machdep.c,v 1.53 2011/06/14 03:12:43 matt Ex
#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 @@ cpu_dumpconf(void)
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 @@ cpu_need_resched(struct cpu_info *ci, int flags)
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

View File

@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.141 2011/06/05 16:52:26 matt Exp $");
#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 @@ copyoutstr(const void *kaddr, void *udaddr, size_t len, size_t *done)
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);
}