PERFORCE change 48831 for review
Juli Mallett
jmallett at FreeBSD.org
Fri Mar 12 15:09:31 PST 2004
http://perforce.freebsd.org/chv.cgi?CH=48831
Change 48831 by jmallett at jmallett_oingo on 2004/03/12 15:08:44
Attempt to do cpu_fork, remove stuff now in swtch.S... Note
that cpu_fork has two debugging printfs that i can't be
bothered to clean out right now, until i have time to look
at some other weirdness.
Affected files ...
.. //depot/projects/mips/sys/mips/mips/vm_machdep.c#9 edit
Differences ...
==== //depot/projects/mips/sys/mips/mips/vm_machdep.c#9 (text+ko) ====
@@ -33,9 +33,11 @@
#include <sys/mutex.h>
#include <sys/time.h>
#include <sys/proc.h>
+#include <sys/user.h>
#include <sys/queue.h>
#include <sys/socketvar.h>
#include <sys/sf_buf.h>
+#include <sys/unistd.h>
#include <machine/cpu.h>
#include <machine/cpufunc.h>
@@ -54,78 +56,114 @@
void
cpu_exit(struct thread *td)
{
+ panic("%s", __func__);
}
void
cpu_fork(struct thread *td, struct proc *p2, struct thread *td2, int flags)
{
-}
+ struct trapframe *tf;
+
+ if ((flags & RFPROC) == 0)
+ return;
+
+ cpu_thread_setup(td2);
+
+ /* Copy the pcb */
+ printf("cpu_fork: copy from %p to %p\n", td->td_pcb, td2->td_pcb);
+ bcopy(td->td_pcb, td2->td_pcb, sizeof(struct pcb));
+
+ /*
+ * Create a fresh stack for the new process.
+ * Copy the trap frame for the return to user mode as if from a
+ * syscall. This copies most of the user mode register values.
+ */
+ tf = (struct trapframe *)td2->td_pcb - 1;
+ printf("cpu_fork: copy from fr %p to tf %p\n", td->td_frame, tf);
+ bcopy(td->td_frame, tf, sizeof(*tf));
+
+ /* Set up trap frame. */
+ td2->td_frame = tf;
-void
-cpu_sched_exit(struct thread *td)
-{
-}
+ /*
+ * Call fork_trampoline into fork_return via the pcb.
+ */
+ td2->td_pcb->pcb_regs[10] = (register_t)fork_trampoline;
+ td2->td_pcb->pcb_regs[0] = (register_t)fork_return;
+ td2->td_pcb->pcb_regs[1] = (register_t)td2;
+ td2->td_pcb->pcb_regs[2] = (register_t)tf;
-void
-cpu_switch(struct thread *old, struct thread *new)
-{
+ /*
+ * Now cpu_switch() can schedule the new process.
+ */
}
void
-cpu_throw(struct thread *old, struct thread *new)
+cpu_sched_exit(struct thread *td)
{
- panic("cpu_throw");
+ panic("%s", __func__);
}
void
cpu_thread_exit(struct thread *td)
{
+ panic("%s", __func__);
}
void
cpu_thread_clean(struct thread *td)
{
+ panic("%s", __func__);
}
void
cpu_thread_setup(struct thread *td)
{
+ td->td_pcb =
+ (struct pcb *)(td->td_kstack + KSTACK_PAGES * PAGE_SIZE) - 1;
}
void
cpu_set_fork_handler(struct thread *td, void (*func)(void *), void *arg)
{
+ panic("%s", __func__);
}
void
cpu_thread_swapin(struct thread *td)
{
+ panic("%s", __func__);
}
void
cpu_thread_swapout(struct thread *td)
{
+ panic("%s", __func__);
}
void
cpu_set_upcall(struct thread *td, struct thread *td0)
{
+ panic("%s", __func__);
}
void
cpu_set_upcall_kse(struct thread *td, struct kse_upcall *ku)
{
+ panic("%s", __func__);
}
struct sf_buf *
sf_buf_alloc(struct vm_page *m)
{
+ panic("%s", __func__);
return (NULL);
}
void
sf_buf_free(void *addr, void *args)
{
+ panic("%s", __func__);
}
void
More information about the p4-projects
mailing list