summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/alpha/alpha/vm_machdep.c49
-rw-r--r--sys/arch/alpha/include/cpu.h3
-rw-r--r--sys/arch/amiga/amiga/trap.c22
-rw-r--r--sys/arch/amiga/amiga/vm_machdep.c50
-rw-r--r--sys/arch/hp300/hp300/trap.c24
-rw-r--r--sys/arch/hp300/hp300/vm_machdep.c31
-rw-r--r--sys/arch/hppa/hppa/vm_machdep.c31
-rw-r--r--sys/arch/hppa/include/cpu.h3
-rw-r--r--sys/arch/i386/i386/trap.c15
-rw-r--r--sys/arch/i386/i386/vm_machdep.c34
-rw-r--r--sys/arch/i386/include/cpu.h5
-rw-r--r--sys/arch/m68k/m68k/m68k_machdep.c32
-rw-r--r--sys/arch/mac68k/include/cpu.h5
-rw-r--r--sys/arch/mac68k/mac68k/trap.c30
-rw-r--r--sys/arch/mac68k/mac68k/vm_machdep.c36
-rw-r--r--sys/arch/macppc/include/cpu.h4
-rw-r--r--sys/arch/mvme68k/mvme68k/trap.c23
-rw-r--r--sys/arch/mvme68k/mvme68k/vm_machdep.c30
-rw-r--r--sys/arch/mvme88k/include/trap.h3
-rw-r--r--sys/arch/mvme88k/mvme88k/vm_machdep.c26
-rw-r--r--sys/arch/powerpc/powerpc/vm_machdep.c28
-rw-r--r--sys/arch/sparc/include/cpu.h3
-rw-r--r--sys/arch/sparc/sparc/vm_machdep.c59
-rw-r--r--sys/arch/sparc64/include/cpu.h3
-rw-r--r--sys/arch/sparc64/sparc64/vm_machdep.c35
-rw-r--r--sys/arch/sun3/include/cpu.h5
-rw-r--r--sys/arch/sun3/include/machdep.h4
-rw-r--r--sys/arch/sun3/sun3/trap.c32
-rw-r--r--sys/arch/sun3/sun3/vm_machdep.c69
-rw-r--r--sys/arch/vax/vax/vm_machdep.c9
30 files changed, 174 insertions, 529 deletions
diff --git a/sys/arch/alpha/alpha/vm_machdep.c b/sys/arch/alpha/alpha/vm_machdep.c
index 4f78963b675..bf8d1c8ae1c 100644
--- a/sys/arch/alpha/alpha/vm_machdep.c
+++ b/sys/arch/alpha/alpha/vm_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vm_machdep.c,v 1.24 2001/09/19 20:50:55 mickey Exp $ */
+/* $OpenBSD: vm_machdep.c,v 1.25 2001/11/06 18:41:09 art Exp $ */
/* $NetBSD: vm_machdep.c,v 1.55 2000/03/29 03:49:48 simonb Exp $ */
/*
@@ -134,18 +134,19 @@ cpu_exit(p)
* directly to user level with an apparent return value of 0 from
* fork(), while the parent process returns normally.
*
- * p1 is the process being forked; if p1 == &proc0, we are creating
- * a kernel thread, and the return path will later be changed in cpu_set_kpc.
+ * p1 is the process being forked;
*
* If an alternate user-level stack is requested (with non-zero values
* in both the stack and stacksize args), set up the user stack pointer
* accordingly.
*/
void
-cpu_fork(p1, p2, stack, stacksize)
- register struct proc *p1, *p2;
+cpu_fork(p1, p2, stack, stacksize, func, arg)
+ struct proc *p1, *p2;
void *stack;
size_t stacksize;
+ void (*func)(void *);
+ void *arg;
{
struct user *up = p2->p_addr;
@@ -224,51 +225,17 @@ cpu_fork(p1, p2, stack, stacksize)
* Arrange for continuation at child_return(), which
* will return to exception_return(). Note that the child
* process doesn't stay in the kernel for long!
- *
- * This is an inlined version of cpu_set_kpc.
*/
up->u_pcb.pcb_hw.apcb_ksp = (u_int64_t)p2tf;
- up->u_pcb.pcb_context[0] =
- (u_int64_t)child_return; /* s0: pc */
+ up->u_pcb.pcb_context[0] = (u_int64_t)func;
up->u_pcb.pcb_context[1] =
(u_int64_t)exception_return; /* s1: ra */
- up->u_pcb.pcb_context[2] =
- (u_int64_t)p2; /* s2: arg */
+ up->u_pcb.pcb_context[2] = (u_int64_t)arg;
up->u_pcb.pcb_context[7] =
(u_int64_t)switch_trampoline; /* ra: assembly magic */
up->u_pcb.pcb_context[8] = ALPHA_PSL_IPL_0; /* ps: IPL */
}
}
-
-/*
- * cpu_set_kpc:
- *
- * Arrange for in-kernel execution of a process to continue at the
- * named pc, as if the code at that address were called as a function
- * with argument, the current process's process pointer.
- *
- * Note that it's assumed that when the named process returns,
- * exception_return() should be invoked, to return to user mode.
- *
- * (Note that cpu_fork(), above, uses an open-coded version of this.)
- */
-void
-cpu_set_kpc(p, pc, arg)
- struct proc *p;
- void (*pc) __P((void *));
- void *arg;
-{
- struct pcb *pcbp;
-
- pcbp = &p->p_addr->u_pcb;
- pcbp->pcb_context[0] = (u_int64_t)pc; /* s0 - pc to invoke */
- pcbp->pcb_context[1] =
- (u_int64_t)exception_return; /* s1 - return address */
- pcbp->pcb_context[2] = (u_int64_t)arg; /* s2 - arg */
- pcbp->pcb_context[7] =
- (u_int64_t)switch_trampoline; /* ra - assembly magic */
-}
-
/*
* Finish a swapin operation.
* We neded to update the cached PTEs for the user area in the
diff --git a/sys/arch/alpha/include/cpu.h b/sys/arch/alpha/include/cpu.h
index ed68ef7aead..b599120df2e 100644
--- a/sys/arch/alpha/include/cpu.h
+++ b/sys/arch/alpha/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.14 2001/11/04 23:12:46 art Exp $ */
+/* $OpenBSD: cpu.h,v 1.15 2001/11/06 18:41:09 art Exp $ */
/* $NetBSD: cpu.h,v 1.45 2000/08/21 02:03:12 thorpej Exp $ */
/*-
@@ -114,7 +114,6 @@ int alpha_pa_access(u_long);
void ast(struct trapframe *);
int badaddr(void *, size_t);
int badaddr_read(void *, size_t, void *);
-void child_return(void *);
u_int64_t console_restart(struct trapframe *);
void do_sir(void);
void dumpconf(void);
diff --git a/sys/arch/amiga/amiga/trap.c b/sys/arch/amiga/amiga/trap.c
index 836461cf499..01a801fa8b0 100644
--- a/sys/arch/amiga/amiga/trap.c
+++ b/sys/arch/amiga/amiga/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.22 2001/09/13 15:35:05 art Exp $ */
+/* $OpenBSD: trap.c,v 1.23 2001/11/06 18:41:09 art Exp $ */
/* $NetBSD: trap.c,v 1.56 1997/07/16 00:01:47 is Exp $ */
/*
@@ -194,10 +194,8 @@ void trap __P((int, u_int, u_int, struct frame));
int db_trap __P((int, db_regs_t *));
#endif
void syscall __P((register_t, struct frame));
-void child_return __P((struct proc *, struct frame));
void _wb_fault __P((void));
-
void
userret(p, pc, oticks)
struct proc *p;
@@ -947,24 +945,6 @@ syscall(code, frame)
}
/*
- * Process the tail end of a fork() for the child
- */
-void
-child_return(p, frame)
- struct proc *p;
- struct frame frame;
-{
- frame.f_regs[D0] = 0;
- frame.f_sr &= ~PSL_C; /* carry bit */
-
- userret(p, frame.f_pc, p->p_sticks);
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSRET))
- ktrsysret(p, SYS_fork, 0, 0);
-#endif
-}
-
-/*
* Process a pending write back
*/
int
diff --git a/sys/arch/amiga/amiga/vm_machdep.c b/sys/arch/amiga/amiga/vm_machdep.c
index fa38f74c45d..5d59a8db699 100644
--- a/sys/arch/amiga/amiga/vm_machdep.c
+++ b/sys/arch/amiga/amiga/vm_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vm_machdep.c,v 1.23 2001/09/21 02:11:53 miod Exp $ */
+/* $OpenBSD: vm_machdep.c,v 1.24 2001/11/06 18:41:09 art Exp $ */
/* $NetBSD: vm_machdep.c,v 1.30 1997/05/19 10:14:50 veego Exp $ */
/*
@@ -61,10 +61,6 @@
#include <uvm/uvm_extern.h>
#include <machine/pte.h>
-/* XXX - Put this in some header file? */
-void child_return __P((struct proc *, struct frame));
-
-
/*
* Finish a fork operation, with process p2 nearly set up.
* Copy and update the kernel stack and pcb, making the child
@@ -75,14 +71,16 @@ void child_return __P((struct proc *, struct frame));
* the frame pointers on the stack after copying.
*/
void
-cpu_fork(p1, p2, stack, stacksize)
- register struct proc *p1, *p2;
+cpu_fork(p1, p2, stack, stacksize, func, arg)
+ struct proc *p1, *p2;
void *stack;
size_t stacksize;
+ void (*func)(void *);
+ void *arg;
{
- register struct pcb *pcb = &p2->p_addr->u_pcb;
- register struct trapframe *tf;
- register struct switchframe *sf;
+ struct pcb *pcb = &p2->p_addr->u_pcb;
+ struct trapframe *tf;
+ struct switchframe *sf;
extern struct pcb *curpcb;
p2->p_md.md_flags = p1->p_md.md_flags;
@@ -99,7 +97,7 @@ cpu_fork(p1, p2, stack, stacksize)
/*
* Copy the trap frame, and arrange for the child to return directly
- * through return_to_user(). Note the inline cpu_set_kpc();
+ * through return_to_user().
*/
tf = (struct trapframe *)((u_int)p2->p_addr + USPACE) - 1;
p2->p_md.md_regs = (int *)tf;
@@ -113,38 +111,12 @@ cpu_fork(p1, p2, stack, stacksize)
sf = (struct switchframe *)tf - 1;
sf->sf_pc = (u_int)proc_trampoline;
- pcb->pcb_regs[6] = (int)child_return; /* A2 */
- pcb->pcb_regs[7] = (int)p2; /* A3 */
+ pcb->pcb_regs[6] = (int)func; /* A2 */
+ pcb->pcb_regs[7] = (int)arg; /* A3 */
pcb->pcb_regs[11] = (int)sf; /* SSP */
}
/*
- * cpu_set_kpc:
- *
- * Arrange for in-kernel execution of a process to continue at the
- * named pc, as if the code at that address were called as a function
- * with argument, the current process's process pointer.
- *
- * Note that it's assumed that when the named process returns, rei()
- * should be invoked, to return to user mode.
- */
-void
-cpu_set_kpc(p, pc, arg)
- struct proc *p;
- void (*pc) __P((void *));
- void *arg;
-{
- struct pcb *pcbp;
- struct switchframe *sf;
-
- pcbp = &p->p_addr->u_pcb;
- sf = (struct switchframe *)pcbp->pcb_regs[11];
- sf->sf_pc = (u_int)proc_trampoline;
- pcbp->pcb_regs[6] = (int)pc; /* A2 */
- pcbp->pcb_regs[7] = (int)arg; /* A3 */
-}
-
-/*
* cpu_exit is called as the last action during exit.
* We release the address space and machine-dependent resources,
* Block context switches and then call switch_exit() which will
diff --git a/sys/arch/hp300/hp300/trap.c b/sys/arch/hp300/hp300/trap.c
index 40909fb3758..a602ad607dc 100644
--- a/sys/arch/hp300/hp300/trap.c
+++ b/sys/arch/hp300/hp300/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.29 2001/11/04 02:58:54 miod Exp $ */
+/* $OpenBSD: trap.c,v 1.30 2001/11/06 18:41:09 art Exp $ */
/* $NetBSD: trap.c,v 1.57 1998/02/16 20:58:31 thorpej Exp $ */
/*
@@ -115,14 +115,13 @@ extern struct emul emul_sunos;
int writeback __P((struct frame *fp, int docachepush));
void trap __P((int type, u_int code, u_int v, struct frame frame));
void syscall __P((register_t code, struct frame frame));
-void child_return __P((struct proc *, struct frame));
#ifdef DEBUG
void dumpssw __P((u_short));
void dumpwb __P((int, u_short, u_int, u_int));
#endif
-static inline void userret __P((struct proc *p, struct frame *fp,
+void userret __P((struct proc *p, struct frame *fp,
u_quad_t oticks, u_int faultaddr, int fromtrap));
int astpending;
@@ -207,7 +206,7 @@ int mmupid = -1;
* trap and syscall both need the following work done before returning
* to user mode.
*/
-static inline void
+void
userret(p, fp, oticks, faultaddr, fromtrap)
struct proc *p;
struct frame *fp;
@@ -1171,20 +1170,3 @@ bad:
ktrsysret(p, code, error, rval[0]);
#endif
}
-
-void
-child_return(p, frame)
- struct proc *p;
- struct frame frame;
-{
-
- frame.f_regs[D0] = 0;
- frame.f_sr &= ~PSL_C;
- frame.f_format = FMT0;
-
- userret(p, &frame, 0, (u_int)0, 0);
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSRET))
- ktrsysret(p, SYS_fork, 0, 0);
-#endif
-}
diff --git a/sys/arch/hp300/hp300/vm_machdep.c b/sys/arch/hp300/hp300/vm_machdep.c
index 1293e6fa1fe..5c1fc78828e 100644
--- a/sys/arch/hp300/hp300/vm_machdep.c
+++ b/sys/arch/hp300/hp300/vm_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vm_machdep.c,v 1.31 2001/09/21 02:11:57 miod Exp $ */
+/* $OpenBSD: vm_machdep.c,v 1.32 2001/11/06 18:41:09 art Exp $ */
/* $NetBSD: vm_machdep.c,v 1.47 1999/03/26 23:41:29 mycroft Exp $ */
/*
@@ -72,12 +72,13 @@
* the frame pointers on the stack after copying.
*/
void
-cpu_fork(p1, p2, stack, stacksize)
+cpu_fork(p1, p2, stack, stacksize, func, arg)
struct proc *p1, *p2;
void *stack;
size_t stacksize;
+ void (*func)(void *);
+ void *arg;
{
- void child_return __P((struct proc *, struct frame));
struct pcb *pcb = &p2->p_addr->u_pcb;
struct trapframe *tf;
struct switchframe *sf;
@@ -98,7 +99,7 @@ cpu_fork(p1, p2, stack, stacksize)
/*
* Copy the trap frame, and arrange for the child to return directly
- * through child_return(). Note the in-line cpu_set_kpc().
+ * through child_return().
*/
tf = (struct trapframe *)((u_int)p2->p_addr + USPACE) - 1;
p2->p_md.md_regs = (int *)tf;
@@ -112,30 +113,12 @@ cpu_fork(p1, p2, stack, stacksize)
sf = (struct switchframe *)tf - 1;
sf->sf_pc = (u_int)proc_trampoline;
- pcb->pcb_regs[6] = (int)child_return; /* A2 */
- pcb->pcb_regs[7] = (int)p2; /* A3 */
+ pcb->pcb_regs[6] = (int)func; /* A2 */
+ pcb->pcb_regs[7] = (int)arg; /* A3 */
pcb->pcb_regs[11] = (int)sf; /* SSP */
}
/*
- * Arrange for in-kernel execution of a process to continue at the
- * named pc, as if the code at that address were called as a function
- * with the supplied argument.
- *
- * Note that it's assumed that when the named process returns, rei()
- * should be invoked, to return to user code.
- */
-void
-cpu_set_kpc(p, pc, arg)
- struct proc *p;
- void (*pc) __P((void *));
- void *arg;
-{
- p->p_addr->u_pcb.pcb_regs[6] = (int)pc; /* A2 */
- p->p_addr->u_pcb.pcb_regs[7] = (int)arg; /* A3 */
-}
-
-/*
* cpu_exit is called as the last action during exit.
* We release the address space and machine-dependent resources,
* including the memory for the user structure and kernel stack.
diff --git a/sys/arch/hppa/hppa/vm_machdep.c b/sys/arch/hppa/hppa/vm_machdep.c
index 60a0504df69..f7b02d18586 100644
--- a/sys/arch/hppa/hppa/vm_machdep.c
+++ b/sys/arch/hppa/hppa/vm_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vm_machdep.c,v 1.25 2001/09/19 20:50:56 mickey Exp $ */
+/* $OpenBSD: vm_machdep.c,v 1.26 2001/11/06 18:41:09 art Exp $ */
/*
* Copyright (c) 1999-2000 Michael Shalayeff
@@ -181,13 +181,15 @@ cpu_swapout(p)
}
void
-cpu_fork(p1, p2, stack, stacksize)
+cpu_fork(p1, p2, stack, stacksize, func, arg)
struct proc *p1, *p2;
void *stack;
size_t stacksize;
+ void (*func)(void *);
+ void *arg;
{
- register struct pcb *pcbp;
- register struct trapframe *tf;
+ struct pcb *pcbp;
+ struct trapframe *tf;
register_t sp, osp;
#ifdef DIAGNOSTIC
@@ -247,8 +249,8 @@ cpu_fork(p1, p2, stack, stacksize)
osp = sp;
sp += HPPA_FRAME_SIZE + 16*4; /* std frame + calee-save registers */
*HPPA_FRAME_CARG(0, sp) = tf->tf_sp;
- *HPPA_FRAME_CARG(1, sp) = KERNMODE(child_return);
- *HPPA_FRAME_CARG(2, sp) = (register_t)p2;
+ *HPPA_FRAME_CARG(1, sp) = KERNMODE(func);
+ *HPPA_FRAME_CARG(2, sp) = (register_t)arg;
*(register_t*)(sp + HPPA_FRAME_PSP) = osp;
*(register_t*)(sp + HPPA_FRAME_CRP) =
(register_t)switch_trampoline;
@@ -257,23 +259,6 @@ cpu_fork(p1, p2, stack, stacksize)
}
void
-cpu_set_kpc(p, pc, arg)
- struct proc *p;
- void (*pc) __P((void *));
- void *arg;
-{
- struct trapframe *tf = p->p_md.md_regs;
- register_t sp = tf->tf_sp;
-
- /*
- * Overwrite normally stashed there &child_return(p)
- */
- *HPPA_FRAME_CARG(1, sp) = (register_t)pc;
- *HPPA_FRAME_CARG(2, sp) = (register_t)arg;
- fdcache(HPPA_SID_KERNEL, (vaddr_t)sp, HPPA_FRAME_SIZE);
-}
-
-void
cpu_exit(p)
struct proc *p;
{
diff --git a/sys/arch/hppa/include/cpu.h b/sys/arch/hppa/include/cpu.h
index 87e95be610b..ab629b1b318 100644
--- a/sys/arch/hppa/include/cpu.h
+++ b/sys/arch/hppa/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.20 2001/01/29 00:01:58 mickey Exp $ */
+/* $OpenBSD: cpu.h,v 1.21 2001/11/06 18:41:09 art Exp $ */
/*
* Copyright (c) 2000-2001 Michael Shalayeff
@@ -148,7 +148,6 @@ int spcopy __P((pa_space_t ssp, const void *src,
int spstrcpy __P((pa_space_t ssp, const void *src,
pa_space_t dsp, void *dst, size_t size, size_t *rsize));
int copy_on_fault __P((void));
-void child_return __P((struct proc *p));
void switch_trampoline __P((void));
void switch_exit __P((struct proc *p));
int cpu_dumpsize __P((void));
diff --git a/sys/arch/i386/i386/trap.c b/sys/arch/i386/i386/trap.c
index 4e40a39aae1..892ce2bb758 100644
--- a/sys/arch/i386/i386/trap.c
+++ b/sys/arch/i386/i386/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.43 2001/09/20 11:57:18 art Exp $ */
+/* $OpenBSD: trap.c,v 1.44 2001/11/06 18:41:09 art Exp $ */
/* $NetBSD: trap.c,v 1.95 1996/05/05 06:50:02 mycroft Exp $ */
/*-
@@ -753,15 +753,16 @@ syscall(frame)
}
void
-child_return(p, frame)
- struct proc *p;
- struct trapframe frame;
+child_return(arg)
+ void *arg;
{
+ struct proc *p = (struct proc *)arg;
+ struct trapframe *tf = p->p_md.md_regs;
- frame.tf_eax = 0;
- frame.tf_eflags &= ~PSL_C;
+ tf->tf_eax = 0;
+ tf->tf_eflags &= ~PSL_C;
- userret(p, frame.tf_eip, 0);
+ userret(p, tf->tf_eip, 0);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p, SYS_fork, 0, 0);
diff --git a/sys/arch/i386/i386/vm_machdep.c b/sys/arch/i386/i386/vm_machdep.c
index aa62e5497ea..1f9bbce2f03 100644
--- a/sys/arch/i386/i386/vm_machdep.c
+++ b/sys/arch/i386/i386/vm_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vm_machdep.c,v 1.30 2001/09/21 02:11:57 miod Exp $ */
+/* $OpenBSD: vm_machdep.c,v 1.31 2001/11/06 18:41:09 art Exp $ */
/* $NetBSD: vm_machdep.c,v 1.61 1996/05/03 19:42:35 christos Exp $ */
/*-
@@ -83,14 +83,16 @@ void setredzone __P((u_short *, caddr_t));
* the frame pointers on the stack after copying.
*/
void
-cpu_fork(p1, p2, stack, stacksize)
- register struct proc *p1, *p2;
+cpu_fork(p1, p2, stack, stacksize, func, arg)
+ struct proc *p1, *p2;
void *stack;
size_t stacksize;
+ void (*func)(void *);
+ void *arg;
{
- register struct pcb *pcb = &p2->p_addr->u_pcb;
- register struct trapframe *tf;
- register struct switchframe *sf;
+ struct pcb *pcb = &p2->p_addr->u_pcb;
+ struct trapframe *tf;
+ struct switchframe *sf;
#if NNPX > 0
/*
@@ -127,7 +129,7 @@ cpu_fork(p1, p2, stack, stacksize)
/*
* Copy the trapframe, and arrange for the child to return directly
- * through rei(). Note the inline version of cpu_set_kpc().
+ * through rei().
*/
p2->p_md.md_regs = tf = (struct trapframe *)pcb->pcb_tss.tss_esp0 - 1;
*tf = *p1->p_md.md_regs;
@@ -140,24 +142,10 @@ cpu_fork(p1, p2, stack, stacksize)
sf = (struct switchframe *)tf - 1;
sf->sf_ppl = 0;
- sf->sf_esi = (int)child_return;
- sf->sf_ebx = (int)p2;
- sf->sf_eip = (int)proc_trampoline;
- pcb->pcb_esp = (int)sf;
-}
-
-void
-cpu_set_kpc(p, pc, arg)
- struct proc *p;
- void (*pc) __P((void *));
- void *arg;
-{
- struct switchframe *sf =
- (struct switchframe *)p->p_addr->u_pcb.pcb_esp;
-
- sf->sf_esi = (int)pc;
+ sf->sf_esi = (int)func;
sf->sf_ebx = (int)arg;
sf->sf_eip = (int)proc_trampoline;
+ pcb->pcb_esp = (int)sf;
}
void
diff --git a/sys/arch/i386/include/cpu.h b/sys/arch/i386/include/cpu.h
index 58b1a6d7e6d..60c38f6892d 100644
--- a/sys/arch/i386/include/cpu.h
+++ b/sys/arch/i386/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.38 2001/07/13 19:55:41 deraadt Exp $ */
+/* $OpenBSD: cpu.h,v 1.39 2001/11/06 18:41:09 art Exp $ */
/* $NetBSD: cpu.h,v 1.35 1996/05/05 19:29:26 christos Exp $ */
/*-
@@ -230,9 +230,6 @@ int kvtop __P((caddr_t));
void vm86_gpfault __P((struct proc *, int));
#endif /* VM86 */
-/* trap.c */
-void child_return __P((struct proc *, struct trapframe));
-
#ifdef GENERIC
/* swapgeneric.c */
void setconf __P((void));
diff --git a/sys/arch/m68k/m68k/m68k_machdep.c b/sys/arch/m68k/m68k/m68k_machdep.c
index 4b0c39194b8..287d064859f 100644
--- a/sys/arch/m68k/m68k/m68k_machdep.c
+++ b/sys/arch/m68k/m68k/m68k_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: m68k_machdep.c,v 1.1 1997/07/06 07:46:28 downsj Exp $ */
+/* $OpenBSD: m68k_machdep.c,v 1.2 2001/11/06 18:41:09 art Exp $ */
/* $NetBSD: m68k_machdep.c,v 1.3 1997/06/12 09:57:04 veego Exp $ */
/*-
@@ -38,7 +38,37 @@
*/
#include <sys/param.h>
+#include <sys/proc.h>
+#include <sys/syscall.h>
+#include <sys/ktrace.h>
+
+#include <machine/frame.h>
+#include <machine/reg.h>
/* the following is used externally (sysctl_hw) */
char machine_arch[] = MACHINE_ARCH; /* from <machine/param.h> */
+void userret __P((struct proc *, int, u_quad_t)); /* XXX */
+/*
+ * Process the tail end of a fork() for the child
+ *
+ * XXX - this is probably the wrong file.
+ */
+void
+child_return(arg)
+ void *arg;
+{
+ struct proc *p = (struct proc *)arg;
+ struct frame *f = (struct frame *)p->p_md.md_regs;
+
+ f->f_regs[D0] = 0;
+ f->f_sr &= ~PSL_C; /* carry bit */
+ f->f_format = FMT0;
+
+ userret(p, f->f_pc, p->p_sticks);
+#ifdef KTRACE
+ if (KTRPOINT(p, KTR_SYSRET))
+ ktrsysret(p, SYS_fork, 0, 0);
+#endif
+}
+
diff --git a/sys/arch/mac68k/include/cpu.h b/sys/arch/mac68k/include/cpu.h
index d2e4c7c6f74..807d64e7233 100644
--- a/sys/arch/mac68k/include/cpu.h
+++ b/sys/arch/mac68k/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.21 2001/08/20 19:49:03 miod Exp $ */
+/* $OpenBSD: cpu.h,v 1.22 2001/11/06 18:41:09 art Exp $ */
/* $NetBSD: cpu.h,v 1.45 1997/02/10 22:13:40 scottr Exp $ */
/*
@@ -318,9 +318,6 @@ void savectx __P((struct pcb *));
void proc_trampoline __P((void));
void loadustp __P((int));
-/* trap.c */
-void child_return __P((struct proc *, struct frame));
-
/* vm_machdep.c */
void physaccess __P((caddr_t, caddr_t, register int, register int));
void physunaccess __P((caddr_t, register int));
diff --git a/sys/arch/mac68k/mac68k/trap.c b/sys/arch/mac68k/mac68k/trap.c
index c3e2f016602..fdd648b8e2d 100644
--- a/sys/arch/mac68k/mac68k/trap.c
+++ b/sys/arch/mac68k/mac68k/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.28 2001/09/14 08:57:05 art Exp $ */
+/* $OpenBSD: trap.c,v 1.29 2001/11/06 18:41:10 art Exp $ */
/* $NetBSD: trap.c,v 1.68 1998/12/22 08:47:07 scottr Exp $ */
/*
@@ -144,8 +144,8 @@ int mmupid = -1;
void trap __P((int, u_int, u_int, struct frame));
void syscall __P((register_t, struct frame));
-static inline void userret __P((struct proc *p, struct frame *fp,
- u_quad_t oticks, u_int faultaddr, int fromtrap));
+void userret __P((struct proc *p, struct frame *fp, u_quad_t oticks,
+ u_int faultaddr, int fromtrap));
#if defined(M68040)
static int writeback __P((struct frame *, int));
@@ -159,7 +159,7 @@ static void dumpwb __P((int, u_short, u_int, u_int));
* Trap and syscall both need the following work done before returning
* to user mode.
*/
-static __inline void
+void
userret(p, fp, oticks, faultaddr, fromtrap)
struct proc *p;
struct frame *fp;
@@ -1125,25 +1125,3 @@ syscall(code, frame)
ktrsysret(p, code, error, rval[0]);
#endif
}
-
-void child_return __P((struct proc *, struct frame));
-
-/*
- * Process the tail end of a fork() for the child.
- */
-void
-child_return(p, frame)
- struct proc *p;
- struct frame frame;
-{
-
- frame.f_regs[D0] = 0; /* Return value. */
- frame.f_sr &= ~PSL_C; /* carry bit indicates error */
- frame.f_format = FMT0;
-
- userret(p, &frame, 0, (u_int)0, 0);
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSRET))
- ktrsysret(p, SYS_fork, 0, 0);
-#endif
-}
diff --git a/sys/arch/mac68k/mac68k/vm_machdep.c b/sys/arch/mac68k/mac68k/vm_machdep.c
index 2fdb4ad5c4d..6896e457e29 100644
--- a/sys/arch/mac68k/mac68k/vm_machdep.c
+++ b/sys/arch/mac68k/mac68k/vm_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vm_machdep.c,v 1.24 2001/09/21 02:11:58 miod Exp $ */
+/* $OpenBSD: vm_machdep.c,v 1.25 2001/11/06 18:41:10 art Exp $ */
/* $NetBSD: vm_machdep.c,v 1.29 1998/07/28 18:34:55 thorpej Exp $ */
/*
@@ -76,12 +76,13 @@ void savectx __P((struct pcb *));
* the frame pointers on the stack after copying.
*/
void
-cpu_fork(p1, p2, stack, stacksize)
+cpu_fork(p1, p2, stack, stacksize, func, arg)
struct proc *p1, *p2;
void *stack;
size_t stacksize;
+ void (*func)(void *);
+ void *arg;
{
- void child_return __P((struct proc *, struct frame)); /* XXX */
struct pcb *pcb = &p2->p_addr->u_pcb;
struct trapframe *tf;
struct switchframe *sf;
@@ -111,36 +112,11 @@ cpu_fork(p1, p2, stack, stacksize)
sf = (struct switchframe *)tf - 1;
sf->sf_pc = (u_int)proc_trampoline;
- pcb->pcb_regs[6] = (int)child_return; /* A2 */
- pcb->pcb_regs[7] = (int)p2; /* A3 */
+ pcb->pcb_regs[6] = (int)func; /* A2 */
+ pcb->pcb_regs[7] = (int)arg; /* A3 */
pcb->pcb_regs[11] = (int)sf; /* SSP */
}
-/*
- * cpu_set_kpc
- * Arrange for in-kernel execution of a process to continue at the
- * named PC as if the code at that address had been called as a function
- * with one argument--the named process's process pointer.
- *
- * Note that it's assumed that whne the named process returns, rei()
- * should be invoked to return to user mode.
- */
-void
-cpu_set_kpc(p, pc, arg)
- struct proc *p;
- void (*pc) __P((void *));
- void *arg;
-{
- struct pcb *pcbp;
- struct switchframe *sf;
-
- pcbp = &p->p_addr->u_pcb;
- sf = (struct switchframe *)pcbp->pcb_regs[11];
- sf->sf_pc = (u_int)proc_trampoline;
- pcbp->pcb_regs[6] = (int)pc; /* A2 */
- pcbp->pcb_regs[7] = (int)p; /* A3 */
-}
-
void switch_exit __P((struct proc *));
/*
diff --git a/sys/arch/macppc/include/cpu.h b/sys/arch/macppc/include/cpu.h
index bc2918a4d48..d0b6b60f731 100644
--- a/sys/arch/macppc/include/cpu.h
+++ b/sys/arch/macppc/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.1 2001/09/01 15:49:06 drahn Exp $ */
+/* $OpenBSD: cpu.h,v 1.2 2001/11/06 18:41:10 art Exp $ */
/* $NetBSD: cpu.h,v 1.1 1996/09/30 16:34:21 ws Exp $ */
/*
@@ -36,8 +36,6 @@
#include <powerpc/cpu.h>
-void child_return __P((struct proc *));
-
#define CACHELINESIZE 32 /* For now XXX */
static __inline void
diff --git a/sys/arch/mvme68k/mvme68k/trap.c b/sys/arch/mvme68k/mvme68k/trap.c
index 3c74d079b93..84c62fd0794 100644
--- a/sys/arch/mvme68k/mvme68k/trap.c
+++ b/sys/arch/mvme68k/mvme68k/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.35 2001/09/14 09:15:19 art Exp $ */
+/* $OpenBSD: trap.c,v 1.36 2001/11/06 18:41:10 art Exp $ */
/*
* Copyright (c) 1995 Theo de Raadt
@@ -169,14 +169,14 @@ u_char next_sir;
int writeback __P((struct frame *fp, int docachepush));
-static inline void userret __P((struct proc *p, struct frame *fp,
+void userret __P((struct proc *p, struct frame *fp,
u_quad_t oticks, u_int faultaddr, int fromtrap));
/*
* trap and syscall both need the following work done before returning
* to user mode.
*/
-static inline void
+void
userret(p, fp, oticks, faultaddr, fromtrap)
register struct proc *p;
register struct frame *fp;
@@ -1104,23 +1104,6 @@ bad:
#endif
}
-void
-child_return(p, frame)
- struct proc *p;
- struct frame frame;
-{
-
- frame.f_regs[D0] = 0;
- frame.f_sr &= ~PSL_C;
- frame.f_format = FMT0;
-
- userret(p, &frame, 0, (u_int)0, 0);
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSRET))
- ktrsysret(p, SYS_fork, 0, 0);
-#endif
-}
-
/*
* Allocation routines for software interrupts.
*/
diff --git a/sys/arch/mvme68k/mvme68k/vm_machdep.c b/sys/arch/mvme68k/mvme68k/vm_machdep.c
index 091be388e0f..0600b7da920 100644
--- a/sys/arch/mvme68k/mvme68k/vm_machdep.c
+++ b/sys/arch/mvme68k/mvme68k/vm_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vm_machdep.c,v 1.30 2001/09/29 21:26:33 miod Exp $ */
+/* $OpenBSD: vm_machdep.c,v 1.31 2001/11/06 18:41:10 art Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -69,14 +69,16 @@
*/
void
-cpu_fork(p1, p2, stack, stacksize)
- register struct proc *p1, *p2;
+cpu_fork(p1, p2, stack, stacksize, func, arg)
+ struct proc *p1, *p2;
void *stack;
size_t stacksize;
+ void (*func)(void *);
+ void *arg;
{
- register struct pcb *pcb = &p2->p_addr->u_pcb;
- register struct trapframe *tf;
- register struct switchframe *sf;
+ struct pcb *pcb = &p2->p_addr->u_pcb;
+ struct trapframe *tf;
+ struct switchframe *sf;
extern struct pcb *curpcb;
extern void proc_trampoline(), child_return();
@@ -95,7 +97,7 @@ cpu_fork(p1, p2, stack, stacksize)
/*
* Copy the trap frame, and arrange for the child to return directly
- * through return_to_user(). Note the inline version of cpu_set_kpc().
+ * through return_to_user().
*/
tf = (struct trapframe *)((u_int)p2->p_addr + USPACE) - 1;
p2->p_md.md_regs = (int *)tf;
@@ -109,21 +111,11 @@ cpu_fork(p1, p2, stack, stacksize)
sf = (struct switchframe *)tf - 1;
sf->sf_pc = (u_int)proc_trampoline;
- pcb->pcb_regs[6] = (int)child_return; /* A2 */
- pcb->pcb_regs[7] = (int)p2; /* A3 */
+ pcb->pcb_regs[6] = (int)func; /* A2 */
+ pcb->pcb_regs[7] = (int)arg; /* A3 */
pcb->pcb_regs[11] = (int)sf; /* SSP */
}
-void
-cpu_set_kpc(p, pc, arg)
- struct proc *p;
- void (*pc) __P((void *));
- void *arg;
-{
- p->p_addr->u_pcb.pcb_regs[6] = (int)pc; /* A2 */
- p->p_addr->u_pcb.pcb_regs[7] = (int)arg; /* A3 */
-}
-
/*
* cpu_exit is called as the last action during exit.
* We release the address space and machine-dependent resources,
diff --git a/sys/arch/mvme88k/include/trap.h b/sys/arch/mvme88k/include/trap.h
index 1cd82a99237..0da0e54175d 100644
--- a/sys/arch/mvme88k/include/trap.h
+++ b/sys/arch/mvme88k/include/trap.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.h,v 1.11 2001/08/24 22:52:20 miod Exp $ */
+/* $OpenBSD: trap.h,v 1.12 2001/11/06 18:41:10 art Exp $ */
/*
* Mach Operating System
* Copyright (c) 1992 Carnegie Mellon University
@@ -77,7 +77,6 @@ void panictrap(int type, struct m88100_saved_state *frame);
void test_trap(struct m88100_saved_state *frame);
void error_fault(struct m88100_saved_state *frame);
void error_reset(struct m88100_saved_state *frame);
-void child_return(struct proc *p);
unsigned ss_get_value(struct proc *p, unsigned addr, int size);
int ss_put_value(struct proc *p, unsigned addr, unsigned value, int size);
unsigned ss_branch_taken(unsigned inst, unsigned pc,
diff --git a/sys/arch/mvme88k/mvme88k/vm_machdep.c b/sys/arch/mvme88k/mvme88k/vm_machdep.c
index ecaceda6367..00643a78c41 100644
--- a/sys/arch/mvme88k/mvme88k/vm_machdep.c
+++ b/sys/arch/mvme88k/mvme88k/vm_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vm_machdep.c,v 1.35 2001/09/23 02:51:36 miod Exp $ */
+/* $OpenBSD: vm_machdep.c,v 1.36 2001/11/06 18:41:10 art Exp $ */
/*
* Copyright (c) 1998 Steve Murphree, Jr.
@@ -89,7 +89,8 @@ int badpaddr __P((caddr_t, int));
*/
void
-cpu_fork(struct proc *p1, struct proc *p2, void *stack, size_t stacksize)
+cpu_fork(struct proc *p1, struct proc *p2, void *stack, size_t stacksize,
+ void (*func)(void *), void *arg)
{
struct switchframe *p2sf;
int cpu;
@@ -136,7 +137,8 @@ cpu_fork(struct proc *p1, struct proc *p2, void *stack, size_t stacksize)
ksfp = (struct ksigframe *)p2->p_addr->u_pcb.kernel_state.pcb_sp - 1;
- ksfp->func = child_return;
+ ksfp->func = func;
+ ksfp->arg = arg;
ksfp->proc = p2;
/*
@@ -151,24 +153,6 @@ cpu_fork(struct proc *p1, struct proc *p2, void *stack, size_t stacksize)
p2->p_addr->u_pcb.kernel_state.pcb_pc = (u_int)proc_trampoline;
}
-void
-cpu_set_kpc(struct proc *p, void (*func)(void *), void *arg)
-{
- /*
- * override func pointer in ksigframe with func.
- */
-
- struct ksigframe {
- void (*func)(void *);
- void *arg;
- } *ksfp;
-
- ksfp = (struct ksigframe *)p->p_addr->u_pcb.kernel_state.pcb_sp;
-
- ksfp->func = func;
- ksfp->arg = arg;
-}
-
/*
* cpu_exit is called as the last action during exit.
* We release the address space and machine-dependent resources,
diff --git a/sys/arch/powerpc/powerpc/vm_machdep.c b/sys/arch/powerpc/powerpc/vm_machdep.c
index d647410b601..23cdd3f2407 100644
--- a/sys/arch/powerpc/powerpc/vm_machdep.c
+++ b/sys/arch/powerpc/powerpc/vm_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vm_machdep.c,v 1.24 2001/09/21 17:33:15 miod Exp $ */
+/* $OpenBSD: vm_machdep.c,v 1.25 2001/11/06 18:41:10 art Exp $ */
/* $NetBSD: vm_machdep.c,v 1.1 1996/09/30 16:34:57 ws Exp $ */
/*
@@ -50,17 +50,18 @@
* Finish a fork operation, with process p2 nearly set up.
*/
void
-cpu_fork(p1, p2, stack, stacksize)
+cpu_fork(p1, p2, stack, stacksize, func, arg)
struct proc *p1, *p2;
void *stack;
size_t stacksize;
+ void (*func)(void *);
+ void *arg;
{
struct trapframe *tf;
struct callframe *cf;
struct switchframe *sf;
caddr_t stktop1, stktop2;
extern void fork_trampoline __P((void));
- extern void child_return __P((struct proc *));
struct pcb *pcb = &p2->p_addr->u_pcb;
if (p1 == fpuproc)
@@ -100,8 +101,8 @@ cpu_fork(p1, p2, stack, stacksize)
*/
stktop2 -= 16;
cf = (struct callframe *)stktop2;
- cf->r31 = (register_t)child_return;
- cf->r30 = (register_t)p2;
+ cf->r31 = (register_t)func;
+ cf->r30 = (register_t)arg;
/*
* Below that, we allocate the switch frame:
@@ -115,23 +116,6 @@ cpu_fork(p1, p2, stack, stacksize)
pcb->pcb_spl = 0;
}
-/*
- * Set initial pc of process forked by above.
- */
-void
-cpu_set_kpc(p, pc, arg)
- struct proc *p;
- void (*pc) __P((void *));
- void *arg;
-{
- struct switchframe *sf = (struct switchframe *)p->p_addr->u_pcb.pcb_sp;
- struct callframe *cf = (struct callframe *)sf->sp;
-
- cf->r30 = (register_t)arg;
- cf->r31 = (register_t)pc;
- cf++->lr = (register_t)pc;
-}
-
void
cpu_swapin(p)
struct proc *p;
diff --git a/sys/arch/sparc/include/cpu.h b/sys/arch/sparc/include/cpu.h
index b0268a2c0ce..a6082b68af8 100644
--- a/sys/arch/sparc/include/cpu.h
+++ b/sys/arch/sparc/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.10 2000/06/05 11:02:52 art Exp $ */
+/* $OpenBSD: cpu.h,v 1.11 2001/11/06 18:41:10 art Exp $ */
/* $NetBSD: cpu.h,v 1.24 1997/03/15 22:25:15 pk Exp $ */
/*
@@ -207,7 +207,6 @@ void remrunqueue __P((struct proc *));
/* trap.c */
void kill_user_windows __P((struct proc *));
int rwindow_save __P((struct proc *));
-void child_return __P((struct proc *));
/* amd7930intr.s */
void amd7930_trap __P((void));
/* cons.c */
diff --git a/sys/arch/sparc/sparc/vm_machdep.c b/sys/arch/sparc/sparc/vm_machdep.c
index efaa90663c8..9c2f4c238d9 100644
--- a/sys/arch/sparc/sparc/vm_machdep.c
+++ b/sys/arch/sparc/sparc/vm_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vm_machdep.c,v 1.32 2001/09/19 20:50:57 mickey Exp $ */
+/* $OpenBSD: vm_machdep.c,v 1.33 2001/11/06 18:41:10 art Exp $ */
/* $NetBSD: vm_machdep.c,v 1.30 1997/03/10 23:55:40 pk Exp $ */
/*
@@ -387,15 +387,17 @@ vunmapbuf(bp, sz)
* the first element in struct user.
*/
void
-cpu_fork(p1, p2, stack, stacksize)
- register struct proc *p1, *p2;
+cpu_fork(p1, p2, stack, stacksize, func, arg)
+ struct proc *p1, *p2;
void *stack;
size_t stacksize;
+ void (*func)(void *);
+ void *arg;
{
- register struct pcb *opcb = &p1->p_addr->u_pcb;
- register struct pcb *npcb = &p2->p_addr->u_pcb;
- register struct trapframe *tf2;
- register struct rwindow *rp;
+ struct pcb *opcb = &p1->p_addr->u_pcb;
+ struct pcb *npcb = &p2->p_addr->u_pcb;
+ struct trapframe *tf2;
+ struct rwindow *rp;
/*
* Save all user registers to p1's stack or, in the case of
@@ -464,8 +466,8 @@ cpu_fork(p1, p2, stack, stacksize)
/* Construct kernel frame to return to in cpu_switch() */
rp = (struct rwindow *)((u_int)npcb + TOPFRAMEOFF);
- rp->rw_local[0] = (int)child_return; /* Function to call */
- rp->rw_local[1] = (int)p2; /* and its argument */
+ rp->rw_local[0] = (int)func; /* Function to call */
+ rp->rw_local[1] = (int)arg; /* and its argument */
npcb->pcb_pc = (int)proc_trampoline - 8;
npcb->pcb_sp = (int)rp;
@@ -475,45 +477,6 @@ cpu_fork(p1, p2, stack, stacksize)
}
/*
- * cpu_set_kpc:
- *
- * Arrange for in-kernel execution of a process to continue at the
- * named pc, as if the code at that address were called as a function
- * with the current process's process pointer as an argument.
- *
- * Note that it's assumed that when the named process returns,
- * we immediately return to user mode.
- *
- * (Note that cpu_fork(), above, uses an open-coded version of this.)
- */
-void
-cpu_set_kpc(p, pc, arg)
- struct proc *p;
- void (*pc) __P((void *));
- void *arg;
-{
- struct pcb *pcb;
- struct rwindow *rp;
-
- pcb = &p->p_addr->u_pcb;
-
- rp = (struct rwindow *)((u_int)pcb + TOPFRAMEOFF);
- rp->rw_local[0] = (int)pc; /* Function to call */
- rp->rw_local[1] = (int)arg; /* and its argument */
-
- /*
- * Frob PCB:
- * - arrange to return to proc_trampoline() from cpu_switch()
- * - point it at the stack frame constructed above
- * - make it run in a clear set of register windows
- */
- pcb->pcb_pc = (int)proc_trampoline - 8;
- pcb->pcb_sp = (int)rp;
- pcb->pcb_psr &= ~PSR_CWP; /* Run in window #0 */
- pcb->pcb_wim = 1; /* Fence at window #1 */
-}
-
-/*
* cpu_exit is called as the last action during exit.
*
* We clean up a little and then call switchexit() with the old proc
diff --git a/sys/arch/sparc64/include/cpu.h b/sys/arch/sparc64/include/cpu.h
index 4e2a60e9ab0..04b9d78b71f 100644
--- a/sys/arch/sparc64/include/cpu.h
+++ b/sys/arch/sparc64/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.5 2001/09/04 15:19:16 jason Exp $ */
+/* $OpenBSD: cpu.h,v 1.6 2001/11/06 18:41:10 art Exp $ */
/* $NetBSD: cpu.h,v 1.28 2001/06/14 22:56:58 thorpej Exp $ */
/*
@@ -292,7 +292,6 @@ void remrq __P((struct proc *));
/* trap.c */
void kill_user_windows __P((struct proc *));
int rwindow_save __P((struct proc *));
-void child_return __P((struct proc *));
/* amd7930intr.s */
void amd7930_trap __P((void));
/* cons.c */
diff --git a/sys/arch/sparc64/sparc64/vm_machdep.c b/sys/arch/sparc64/sparc64/vm_machdep.c
index 6dc851ef600..d7450d87008 100644
--- a/sys/arch/sparc64/sparc64/vm_machdep.c
+++ b/sys/arch/sparc64/sparc64/vm_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vm_machdep.c,v 1.3 2001/09/19 20:50:58 mickey Exp $ */
+/* $OpenBSD: vm_machdep.c,v 1.4 2001/11/06 18:41:10 art Exp $ */
/* $NetBSD: vm_machdep.c,v 1.38 2001/06/30 00:02:20 eeh Exp $ */
/*
@@ -226,10 +226,12 @@ char cpu_forkname[] = "cpu_fork()";
* accordingly.
*/
void
-cpu_fork(p1, p2, stack, stacksize)
+cpu_fork(p1, p2, stack, stacksize, func, arg)
struct proc *p1, *p2;
void *stack;
size_t stacksize;
+ void (*func)(void *);
+ void *arg;
{
struct pcb *opcb = &p1->p_addr->u_pcb;
struct pcb *npcb = &p2->p_addr->u_pcb;
@@ -321,8 +323,8 @@ cpu_fork(p1, p2, stack, stacksize)
/* Construct kernel frame to return to in cpu_switch() */
rp = (struct rwindow *)((u_long)npcb + TOPFRAMEOFF);
*rp = *(struct rwindow *)((u_long)opcb + TOPFRAMEOFF);
- rp->rw_local[0] = (long)child_return; /* Function to call */
- rp->rw_local[1] = (long)p2; /* and its argument */
+ rp->rw_local[0] = (long)func; /* Function to call */
+ rp->rw_local[1] = (long)arg; /* and its argument */
npcb->pcb_pc = (long)proc_trampoline - 8;
npcb->pcb_sp = (long)rp - STACK_OFFSET;
@@ -344,31 +346,6 @@ cpu_fork(p1, p2, stack, stacksize)
#endif
}
-void
-cpu_set_kpc(p, pc, arg)
- struct proc *p;
- void (*pc) __P((void *));
- void *arg;
-{
- struct pcb *pcb;
- struct rwindow *rp;
-
- pcb = &p->p_addr->u_pcb;
-
- rp = (struct rwindow *)((u_long)pcb + TOPFRAMEOFF);
- rp->rw_local[0] = (long)pc; /* Function to call */
- rp->rw_local[1] = (long)arg; /* and its argument */
-
- /*
- * Frob PCB:
- * - arrange to return to proc_trampoline() from cpu_switch()
- * - point it at the stack frame constructed above
- * - make it run in a clear set of register windows
- */
- pcb->pcb_pc = (long)proc_trampoline - 8;
- pcb->pcb_sp = (long)rp - STACK_OFFSET;
-}
-
/*
* cpu_exit is called as the last action during exit.
*
diff --git a/sys/arch/sun3/include/cpu.h b/sys/arch/sun3/include/cpu.h
index a9093530e2a..0c7d910b1e4 100644
--- a/sys/arch/sun3/include/cpu.h
+++ b/sys/arch/sun3/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.13 2001/09/28 20:40:20 miod Exp $ */
+/* $OpenBSD: cpu.h,v 1.14 2001/11/06 18:41:10 art Exp $ */
/* $NetBSD: cpu.h,v 1.20 1995/12/21 05:02:10 mycroft Exp $ */
/*
@@ -157,9 +157,6 @@ void savectx __P((struct pcb *));
void switch_exit __P((struct proc *));
void proc_trampoline __P((void));
-/* trap.c */
-void child_return __P((void *));
-
#endif /* _KERNEL */
/*
diff --git a/sys/arch/sun3/include/machdep.h b/sys/arch/sun3/include/machdep.h
index ac195f63f87..51f20b4e3c4 100644
--- a/sys/arch/sun3/include/machdep.h
+++ b/sys/arch/sun3/include/machdep.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.h,v 1.15 2001/08/25 11:37:26 espie Exp $ */
+/* $OpenBSD: machdep.h,v 1.16 2001/11/06 18:41:10 art Exp $ */
/*
* Copyright (c) 1994 Gordon W. Ross
@@ -84,8 +84,6 @@ void cache_flush_context(void);
int cachectl __P((int req, caddr_t addr, int len));
-void child_return __P((void *));
-
void cninit __P((void));
void dumpconf __P((void));
diff --git a/sys/arch/sun3/sun3/trap.c b/sys/arch/sun3/sun3/trap.c
index f5f3c079285..f7242c0c6a5 100644
--- a/sys/arch/sun3/sun3/trap.c
+++ b/sys/arch/sun3/sun3/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.26 2001/09/14 09:12:21 art Exp $ */
+/* $OpenBSD: trap.c,v 1.27 2001/11/06 18:41:10 art Exp $ */
/* $NetBSD: trap.c,v 1.63-1.65ish 1997/01/16 15:41:40 gwr Exp $ */
/*
@@ -86,7 +86,7 @@ int nodb_trap __P((int type, struct frame *));
int astpending;
int want_resched;
-static void userret __P((struct proc *, struct frame *, u_quad_t));
+void userret __P((struct proc *, struct frame *, u_quad_t));
char *trap_type[] = {
"Bus error",
@@ -147,7 +147,7 @@ int mmupid = -1;
* trap and syscall both need the following work done before
* returning to user mode.
*/
-static void
+void
userret(p, fp, oticks)
register struct proc *p;
register struct frame *fp;
@@ -748,32 +748,6 @@ syscall(code, frame)
}
/*
- * Set up return-value registers as fork() libc stub expects,
- * and do normal return-to-user-mode stuff.
- */
-void
-child_return(p)
- void *p;
-{
- struct frame *f;
-
- f = (struct frame *)((struct proc *)p)->p_md.md_regs;
- f->f_regs[D0] = 0;
- f->f_sr &= ~PSL_C;
- f->f_format = FMT0;
-
- /*
- * Old ticks (3rd arg) is zero so we will charge the child
- * for any clock ticks that might happen before this point.
- */
- userret((struct proc *)p, f, 0);
-#ifdef KTRACE
- if (KTRPOINT((struct proc *)p, KTR_SYSRET))
- ktrsysret(((struct proc *)p), SYS_fork, 0, 0);
-#endif
-}
-
-/*
* This is used if we hit a kernel breakpoint or trace trap
* when there is no debugger installed (or not attached).
* Drop into the PROM temporarily...
diff --git a/sys/arch/sun3/sun3/vm_machdep.c b/sys/arch/sun3/sun3/vm_machdep.c
index bf7f4f59b99..9b6daee2307 100644
--- a/sys/arch/sun3/sun3/vm_machdep.c
+++ b/sys/arch/sun3/sun3/vm_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vm_machdep.c,v 1.20 2001/09/19 20:50:57 mickey Exp $ */
+/* $OpenBSD: vm_machdep.c,v 1.21 2001/11/06 18:41:10 art Exp $ */
/* $NetBSD: vm_machdep.c,v 1.35 1996/04/26 18:38:06 gwr Exp $ */
/*
@@ -72,15 +72,22 @@
* than the parent. Returns 1 in the child process, 0 in the parent.
*/
void
-cpu_fork(p1, p2, stack, stacksize)
- register struct proc *p1, *p2;
+cpu_fork(p1, p2, stack, stacksize, func, arg)
+ struct proc *p1, *p2;
void *stack;
size_t stacksize;
+ void (*func)(void *);
+ void *arg;
{
- register struct pcb *p1pcb = &p1->p_addr->u_pcb;
- register struct pcb *p2pcb = &p2->p_addr->u_pcb;
- register struct trapframe *p2tf;
- register struct switchframe *p2sf;
+ struct pcb *p1pcb = &p1->p_addr->u_pcb;
+ struct pcb *p2pcb = &p2->p_addr->u_pcb;
+ struct trapframe *p2tf;
+ struct switchframe *p2sf;
+ struct ksigframe {
+ struct switchframe sf;
+ void (*func) (void *);
+ void *arg;
+ } *ksfp;
/*
* Before copying the PCB from the current process,
@@ -130,53 +137,9 @@ cpu_fork(p1, p2, stack, stacksize)
p2sf->sf_pc = (u_int)proc_do_uret;
p2pcb->pcb_regs[11] = (int)p2sf; /* SSP */
- /*
- * This will "push a call" to an arbitrary kernel function
- * onto the stack of p2, very much like signal delivery.
- * When p2 runs, it will find itself in child_return().
- */
- cpu_set_kpc(p2, child_return, p2);
-}
-
-/*
- * cpu_set_kpc:
- *
- * Arrange for in-kernel execution of a process to continue in the
- * named function, as if that function were called with one argument,
- * the current process's process pointer.
- *
- * Note that it's assumed that when the named process returns,
- * rei() should be invoked, to return to user mode. That is
- * accomplished by having cpu_fork set the initial frame with a
- * return address pointing to proc_do_uret() which does the rte.
- *
- * The design allows this function to be implemented as a general
- * "kernel sendsig" utility, that can "push" a call to a kernel
- * function onto any other process kernel stack, in a way very
- * similar to how signal delivery works on a user stack. When
- * the named process is switched to, it will call the function
- * we "pushed" and then proc_trampoline will pop the args that
- * were pushed here and return to where it would have returned
- * before we "pushed" this call.
- */
-void
-cpu_set_kpc(prc, func, arg)
- struct proc *prc;
- void (*func) (void *);
- void *arg;
-{
- struct pcb *pcbp;
- struct ksigframe {
- struct switchframe sf;
- void (*func) (void *);
- void *arg;
- } *ksfp;
-
- pcbp = &prc->p_addr->u_pcb;
-
/* Push a ksig frame onto the kernel stack. */
- ksfp = (struct ksigframe *)pcbp->pcb_regs[11] - 1;
- pcbp->pcb_regs[11] = (int)ksfp;
+ ksfp = (struct ksigframe *)p2pcb->pcb_regs[11] - 1;
+ p2pcb->pcb_regs[11] = (int)ksfp;
/* Now fill it in for proc_trampoline. */
ksfp->sf.sf_pc = (u_int)proc_trampoline;
diff --git a/sys/arch/vax/vax/vm_machdep.c b/sys/arch/vax/vax/vm_machdep.c
index f3bd540ec52..2c19e441160 100644
--- a/sys/arch/vax/vax/vm_machdep.c
+++ b/sys/arch/vax/vax/vm_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vm_machdep.c,v 1.25 2001/11/06 02:49:23 art Exp $ */
+/* $OpenBSD: vm_machdep.c,v 1.26 2001/11/06 18:41:10 art Exp $ */
/* $NetBSD: vm_machdep.c,v 1.67 2000/06/29 07:14:34 mrg Exp $ */
/*
@@ -91,8 +91,7 @@ pagemove(from, to, size)
* directly to user level with an apparent return value of 0 from
* fork(), while the parent process returns normally.
*
- * p1 is the process being forked; if p1 == &proc0, we are creating
- * a kernel thread, and the return path will later be changed in cpu_set_kpc.
+ * p1 is the process being forked;
*
* If an alternate user-level stack is requested (with non-zero values
* in both the stack and stacksize args), set up the user stack pointer
@@ -107,10 +106,12 @@ pagemove(from, to, size)
* forking.
*/
void
-cpu_fork(p1, p2, stack, stacksize)
+cpu_fork(p1, p2, stack, stacksize, func, arg)
struct proc *p1, *p2;
void *stack;
size_t stacksize;
+ void (*func)(void *);
+ void *arg;
{
struct pte *pt;
struct pcb *nyproc;