use lwp_getpcb() to hide the detail about how struct pcb is populated.

This commit is contained in:
nisimura 2010-12-29 13:43:58 +00:00
parent 2ea5b50e4b
commit a879dab550
2 changed files with 13 additions and 9 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: exception.c,v 1.56 2010/12/20 00:25:43 matt Exp $ */
/* $NetBSD: exception.c,v 1.57 2010/12/29 13:43:58 nisimura Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc. All rights reserved.
@ -79,7 +79,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: exception.c,v 1.56 2010/12/20 00:25:43 matt Exp $");
__KERNEL_RCSID(0, "$NetBSD: exception.c,v 1.57 2010/12/29 13:43:58 nisimura Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@ -139,6 +139,7 @@ general_exception(struct lwp *l, struct trapframe *tf, uint32_t va)
{
int expevt = tf->tf_expevt;
bool usermode = !KERNELMODE(tf->tf_ssr);
struct pcb *pcb;
ksiginfo_t ksi;
uint32_t trapcode;
#ifdef DDB
@ -191,8 +192,9 @@ general_exception(struct lwp *l, struct trapframe *tf, uint32_t va)
case EXPEVT_ADDR_ERR_LD: /* FALLTHROUGH */
case EXPEVT_ADDR_ERR_ST:
KDASSERT(l->l_md.md_pcb->pcb_onfault != NULL);
tf->tf_spc = (int)l->l_md.md_pcb->pcb_onfault;
pcb = lwp_getpcb(l);
KDASSERT(pcb->pcb_onfault != NULL);
tf->tf_spc = (int)pcb->pcb_onfault;
tf->tf_r0 = EFAULT;
if (tf->tf_spc == 0)
goto do_panic;

View File

@ -1,4 +1,4 @@
/* $NetBSD: vm_machdep.c,v 1.67 2010/04/23 19:18:10 rmind Exp $ */
/* $NetBSD: vm_machdep.c,v 1.68 2010/12/29 13:43:58 nisimura Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc. All rights reserved.
@ -81,7 +81,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.67 2010/04/23 19:18:10 rmind Exp $");
__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.68 2010/12/29 13:43:58 nisimura Exp $");
#include "opt_kstack_debug.h"
@ -134,6 +134,7 @@ void
cpu_lwp_fork(struct lwp *l1, struct lwp *l2, void *stack,
size_t stacksize, void (*func)(void *), void *arg)
{
struct pcb *pcb;
struct switchframe *sf;
#if 0 /* FIXME: probably wrong for yamt-idlelwp */
@ -151,7 +152,8 @@ cpu_lwp_fork(struct lwp *l1, struct lwp *l2, void *stack,
l2->l_md.md_regs->tf_r15 = (u_int)stack + stacksize;
/* When l2 is switched to, jump to the trampoline */
sf = &l2->l_md.md_pcb->pcb_sf;
pcb = lwp_getpcb(l2);
sf = &pcb->pcb_sf;
sf->sf_pr = (int)lwp_trampoline;
sf->sf_r10 = (int)l2; /* "new" lwp for lwp_startup() */
sf->sf_r11 = (int)arg; /* hook function/argument */
@ -166,14 +168,14 @@ cpu_lwp_fork(struct lwp *l1, struct lwp *l2, void *stack,
void
cpu_setfunc(struct lwp *l, void (*func)(void *), void *arg)
{
struct switchframe *sf;
struct pcb *pcb = lwp_getpcb(l);
struct switchframe *sf = &pcb->pcb_sf;
sh3_setup_uarea(l);
l->l_md.md_regs->tf_ssr = PSL_USERSET;
/* When lwp is switched to, jump to the trampoline */
sf = &l->l_md.md_pcb->pcb_sf;
sf->sf_pr = (int)lwp_setfunc_trampoline;
sf->sf_r11 = (int)arg; /* hook function/argument */
sf->sf_r12 = (int)func;