summaryrefslogtreecommitdiff
path: root/sys/arch/amiga
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>2001-11-06 18:41:11 +0000
committerArtur Grabowski <art@cvs.openbsd.org>2001-11-06 18:41:11 +0000
commit89ae7820c1a454d61cd281925d300bf324cfb4a3 (patch)
tree322119c116dc2ae1a396e832aac803b47d2df136 /sys/arch/amiga
parent1c0a1a534d87ced0c6089cb972b59491152bbdfa (diff)
Let fork1, uvm_fork, and cpu_fork take a function/argument pair as argument,
instead of doing fork1, cpu_set_kpc. This lets us retire cpu_set_kpc and avoid a multiprocessor race. This commit breaks vax because it doesn't look like any other arch, someone working on vax might want to look at this and try to adapt the code to be more like the rest of the world. Idea and uvm parts from NetBSD.
Diffstat (limited to 'sys/arch/amiga')
-rw-r--r--sys/arch/amiga/amiga/trap.c22
-rw-r--r--sys/arch/amiga/amiga/vm_machdep.c50
2 files changed, 12 insertions, 60 deletions
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