Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 12 Mar 2004 15:09:29 -0800 (PST)
From:      Juli Mallett <jmallett@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 48831 for review
Message-ID:  <200403122309.i2CN9ToM017293@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=48831

Change 48831 by jmallett@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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200403122309.i2CN9ToM017293>