From a879dab5508570ea8d1672753b53814e65cceb6d Mon Sep 17 00:00:00 2001 From: nisimura Date: Wed, 29 Dec 2010 13:43:58 +0000 Subject: [PATCH] use lwp_getpcb() to hide the detail about how struct pcb is populated. --- sys/arch/sh3/sh3/exception.c | 10 ++++++---- sys/arch/sh3/sh3/vm_machdep.c | 12 +++++++----- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/sys/arch/sh3/sh3/exception.c b/sys/arch/sh3/sh3/exception.c index 4a5fb0e70ac8..c5ba3dc07d04 100644 --- a/sys/arch/sh3/sh3/exception.c +++ b/sys/arch/sh3/sh3/exception.c @@ -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 -__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; diff --git a/sys/arch/sh3/sh3/vm_machdep.c b/sys/arch/sh3/sh3/vm_machdep.c index bd7204ad9fd6..fff4ae26cc27 100644 --- a/sys/arch/sh3/sh3/vm_machdep.c +++ b/sys/arch/sh3/sh3/vm_machdep.c @@ -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 -__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;