Improve on cpu_set_upcall:
o Use pcb and tf for the new pcb and the new trapframe and use pcb0 for the old (current) pcb. The mix of pcb, pcb2 and tf was slightly confusing. o Don't define td->td_frame here. It has already been set previously by cpu_thread_setup. Add a KASSERT to make sure pcb and tf are both non-NULL. o Make sure the number of dirty registers is 0 for the new thread. There are no user registers on the backing store because we heven't enter userland yet.
This commit is contained in:
parent
234dfc904a
commit
86f4f6f7b8
@ -120,29 +120,29 @@ cpu_thread_setup(struct thread *td)
|
||||
}
|
||||
|
||||
void
|
||||
cpu_set_upcall(struct thread *td, void *pcb)
|
||||
cpu_set_upcall(struct thread *td, void *pcb0)
|
||||
{
|
||||
struct pcb *pcb2;
|
||||
struct pcb *pcb;
|
||||
struct trapframe *tf;
|
||||
|
||||
pcb2 = td->td_pcb;
|
||||
bcopy(pcb, pcb2, sizeof(*pcb2));
|
||||
pcb = td->td_pcb;
|
||||
KASSERT(pcb != NULL, ("foo"));
|
||||
bcopy(pcb0, pcb, sizeof(*pcb));
|
||||
|
||||
tf = (struct trapframe *)pcb2 - 1;
|
||||
td->td_frame = tf;
|
||||
tf->tf_length = sizeof(struct trapframe);
|
||||
tf = td->td_frame;
|
||||
KASSERT(tf != NULL, ("foo"));
|
||||
tf->tf_flags = FRAME_SYSCALL;
|
||||
|
||||
tf->tf_special.ndirty = 0;
|
||||
tf->tf_scratch.gr8 = 0;
|
||||
tf->tf_scratch.gr9 = 1;
|
||||
tf->tf_scratch.gr10 = 0;
|
||||
|
||||
/* XXX */
|
||||
pcb2->pcb_special.bspstore = td->td_kstack + tf->tf_special.ndirty;
|
||||
pcb2->pcb_special.pfs = 0;
|
||||
pcb2->pcb_current_pmap = vmspace_pmap(td->td_proc->p_vmspace);
|
||||
pcb2->pcb_special.sp = (uintptr_t)tf - 16;
|
||||
pcb2->pcb_special.rp = FDESC_FUNC(fork_trampoline);
|
||||
pcb->pcb_special.bspstore = td->td_kstack;
|
||||
pcb->pcb_special.pfs = 0;
|
||||
pcb->pcb_current_pmap = vmspace_pmap(td->td_proc->p_vmspace);
|
||||
pcb->pcb_special.sp = (uintptr_t)tf - 16;
|
||||
pcb->pcb_special.rp = FDESC_FUNC(fork_trampoline);
|
||||
cpu_set_fork_handler(td, (void (*)(void*))fork_return, td);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user