From owner-p4-projects Sun Sep 1 0:24: 2 2002 Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 4D27E37B401; Sun, 1 Sep 2002 00:23:54 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E6E5F37B400 for ; Sun, 1 Sep 2002 00:23:53 -0700 (PDT) Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 88D8043E6E for ; Sun, 1 Sep 2002 00:23:53 -0700 (PDT) (envelope-from mini@freebsd.org) Received: from freefall.freebsd.org (perforce@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.4/8.12.4) with ESMTP id g817NrJU024465 for ; Sun, 1 Sep 2002 00:23:53 -0700 (PDT) (envelope-from mini@freebsd.org) Received: (from perforce@localhost) by freefall.freebsd.org (8.12.4/8.12.4/Submit) id g817Nrm3024462 for perforce@freebsd.org; Sun, 1 Sep 2002 00:23:53 -0700 (PDT) Date: Sun, 1 Sep 2002 00:23:53 -0700 (PDT) Message-Id: <200209010723.g817Nrm3024462@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: perforce set sender to mini@freebsd.org using -f From: Jonathan Mini Subject: PERFORCE change 16890 for review To: Perforce Change Reviews Sender: owner-p4-projects@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG http://people.freebsd.org/~peter/p4db/chv.cgi?CH=16890 Change 16890 by mini@mini_stylus on 2002/09/01 00:22:54 Add cpu_set_upcall() back, which we need to initialize the pcb and inital trampoline for a kernel thread. Affected files ... .. //depot/projects/kse/sys/i386/i386/vm_machdep.c#63 edit Differences ... ==== //depot/projects/kse/sys/i386/i386/vm_machdep.c#63 (text+ko) ==== @@ -307,10 +307,66 @@ td->td_frame = (struct trapframe *)((caddr_t)td->td_pcb - 16) - 1; } -struct md_store { - struct pcb mds_pcb; - struct trapframe mds_frame; -}; +/* + * Initialize machine state (pcb and trap frame) for a new thread about to + * upcall. + */ +void +cpu_set_upcall(struct thread *td, void *pcb) +{ + struct pcb *pcb2; + + td->td_flags |= TDF_UPCALLING; + + /* Point the pcb to the top of the stack. */ + pcb2 = td->td_pcb; + + /* + * Copy the upcall pcb. This loads kernel regs. + * Those not loaded individually below get their default + * values here. + * + * XXXKSE It might be a good idea to simply skip this as + * the values of the other registers may be unimportant. + * This would remove any requirement for knowing the KSE + * at this time (see the matching comment below for + * more analysis) (need a good safe default). + */ + bcopy(pcb, pcb2, sizeof(*pcb2)); + + /* + * Create a new fresh stack for the new thread. + * The -16 is so we can expand the trapframe if we go to vm86. + * Don't forget to set this stack value into whatever supplies + * the address for the fault handlers. + * The contexts are filled in at the time we actually DO the + * upcall as only then do we know which KSE we got. + */ + td->td_frame = (struct trapframe *)((caddr_t)pcb2 - 16) - 1; + + /* + * Set registers for trampoline to user mode. Leave space for the + * return address on stack. These are the kernel mode register values. + */ + pcb2->pcb_cr3 = vtophys(vmspace_pmap(td->td_proc->p_vmspace)->pm_pdir); + pcb2->pcb_edi = 0; + pcb2->pcb_esi = (int)fork_return; /* trampoline arg */ + pcb2->pcb_ebp = 0; + pcb2->pcb_esp = (int)td->td_frame - sizeof(void *); /* trampoline arg */ + pcb2->pcb_ebx = (int)td; /* trampoline arg */ + pcb2->pcb_eip = (int)fork_trampoline; + pcb2->pcb_psl &= ~(PSL_I); /* interrupts must be disabled */ + /* + * If we didn't copy the pcb, we'd need to do the following registers: + * pcb2->pcb_dr*: cloned above. + * pcb2->pcb_savefpu: cloned above. + * pcb2->pcb_flags: cloned above. + * pcb2->pcb_onfault: cloned above (always NULL here?). + * pcb2->pcb_gs: cloned above. XXXKSE ??? + * pcb2->pcb_ext: cleared below. + */ + pcb2->pcb_ext = NULL; +} void cpu_wait(p) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message