From f8428b2cd3ed0f7863f011c9f43a6ab88e8a8a4e Mon Sep 17 00:00:00 2001 From: dyson Date: Sun, 4 Feb 1996 22:09:12 +0000 Subject: Changed vm_fault_quick in vm_machdep.c to be global. Needed for new pipe code. --- sys/amd64/amd64/vm_machdep.c | 22 +++++++++------------- sys/i386/i386/vm_machdep.c | 22 +++++++++------------- sys/kern/sys_pipe.c | 9 ++++++++- sys/vm/vm_extern.h | 3 ++- 4 files changed, 28 insertions(+), 28 deletions(-) (limited to 'sys') diff --git a/sys/amd64/amd64/vm_machdep.c b/sys/amd64/amd64/vm_machdep.c index 2fa2fa9..4a5590c 100644 --- a/sys/amd64/amd64/vm_machdep.c +++ b/sys/amd64/amd64/vm_machdep.c @@ -69,8 +69,6 @@ #include -static void vm_fault_quick __P((caddr_t v, int prot)); - #ifdef BOUNCE_BUFFERS static vm_offset_t vm_bounce_kva __P((int size, int waitok)); @@ -540,7 +538,7 @@ vm_bounce_init() /* * quick version of vm_fault */ -static void +void vm_fault_quick(v, prot) caddr_t v; int prot; @@ -564,8 +562,8 @@ int cpu_fork(p1, p2) register struct proc *p1, *p2; { - struct pcb *pcb2 = &p2->p_addr->u_pcb; - int sp, offset; + register struct user *up = p2->p_addr; + int offset; /* * Copy pcb and stack from proc p1 to p2. @@ -573,25 +571,23 @@ cpu_fork(p1, p2) * part of the stack. The stack and pcb need to agree; * this is tricky, as the final pcb is constructed by savectx, * but its frame isn't yet on the stack when the stack is copied. + * swtch compensates for this when the child eventually runs. * This should be done differently, with a single call * that copies and updates the pcb+stack, * replacing the bcopy and savectx. */ - - __asm __volatile("movl %%esp,%0" : "=r" (sp)); - offset = sp - (int)kstack; - + p2->p_addr->u_pcb = p1->p_addr->u_pcb; + offset = mvesp() - (int)kstack; bcopy((caddr_t)kstack + offset, (caddr_t)p2->p_addr + offset, (unsigned) ctob(UPAGES) - offset); p2->p_md.md_regs = p1->p_md.md_regs; - *pcb2 = p1->p_addr->u_pcb; - pcb2->pcb_cr3 = vtophys(p2->p_vmspace->vm_pmap.pm_pdir); + pmap_activate(&p2->p_vmspace->vm_pmap, &up->u_pcb); /* - * Returns (0) in parent, (1) in child. + * Return (0) in parent, (1) in child. */ - return (savectx(pcb2)); + return (savectx(&up->u_pcb)); } void diff --git a/sys/i386/i386/vm_machdep.c b/sys/i386/i386/vm_machdep.c index 2fa2fa9..4a5590c 100644 --- a/sys/i386/i386/vm_machdep.c +++ b/sys/i386/i386/vm_machdep.c @@ -69,8 +69,6 @@ #include -static void vm_fault_quick __P((caddr_t v, int prot)); - #ifdef BOUNCE_BUFFERS static vm_offset_t vm_bounce_kva __P((int size, int waitok)); @@ -540,7 +538,7 @@ vm_bounce_init() /* * quick version of vm_fault */ -static void +void vm_fault_quick(v, prot) caddr_t v; int prot; @@ -564,8 +562,8 @@ int cpu_fork(p1, p2) register struct proc *p1, *p2; { - struct pcb *pcb2 = &p2->p_addr->u_pcb; - int sp, offset; + register struct user *up = p2->p_addr; + int offset; /* * Copy pcb and stack from proc p1 to p2. @@ -573,25 +571,23 @@ cpu_fork(p1, p2) * part of the stack. The stack and pcb need to agree; * this is tricky, as the final pcb is constructed by savectx, * but its frame isn't yet on the stack when the stack is copied. + * swtch compensates for this when the child eventually runs. * This should be done differently, with a single call * that copies and updates the pcb+stack, * replacing the bcopy and savectx. */ - - __asm __volatile("movl %%esp,%0" : "=r" (sp)); - offset = sp - (int)kstack; - + p2->p_addr->u_pcb = p1->p_addr->u_pcb; + offset = mvesp() - (int)kstack; bcopy((caddr_t)kstack + offset, (caddr_t)p2->p_addr + offset, (unsigned) ctob(UPAGES) - offset); p2->p_md.md_regs = p1->p_md.md_regs; - *pcb2 = p1->p_addr->u_pcb; - pcb2->pcb_cr3 = vtophys(p2->p_vmspace->vm_pmap.pm_pdir); + pmap_activate(&p2->p_vmspace->vm_pmap, &up->u_pcb); /* - * Returns (0) in parent, (1) in child. + * Return (0) in parent, (1) in child. */ - return (savectx(pcb2)); + return (savectx(&up->u_pcb)); } void diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c index 4e563c9..a337c02 100644 --- a/sys/kern/sys_pipe.c +++ b/sys/kern/sys_pipe.c @@ -185,6 +185,9 @@ free1: return (error); } +/* + * Allocate kva for pipe circular buffer, the space is pageable + */ static void pipespace(cpipe) struct pipe *cpipe; @@ -464,7 +467,7 @@ pipe_build_write_buffer(wpipe, uio) vm_page_t m; - vm_fault_quick( addr, VM_PROT_READ); + vm_fault_quick( (caddr_t) addr, VM_PROT_READ); paddr = pmap_kextract(addr); if (!paddr) { int j; @@ -765,6 +768,10 @@ pipewrite(wpipe, uio, nbio) wakeup(wpipe); } } + + /* + * Don't return EPIPE if I/O was successful + */ if ((wpipe->pipe_buffer.cnt == 0) && (uio->uio_resid == 0) && (error == EPIPE)) diff --git a/sys/vm/vm_extern.h b/sys/vm/vm_extern.h index 38b41c4..c6b3067 100644 --- a/sys/vm/vm_extern.h +++ b/sys/vm/vm_extern.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)vm_extern.h 8.2 (Berkeley) 1/12/94 - * $Id: vm_extern.h,v 1.21 1995/12/11 04:58:04 dyson Exp $ + * $Id: vm_extern.h,v 1.22 1995/12/14 09:54:55 phk Exp $ */ #ifndef _VM_EXTERN_H_ @@ -104,6 +104,7 @@ void vslock __P((caddr_t, u_int)); void vsunlock __P((caddr_t, u_int, int)); void vm_object_print __P((/* db_expr_t */ int, boolean_t, /* db_expr_t */ int, char *)); +void vm_fault_quick __P((caddr_t v, int prot)); #endif /* KERNEL */ -- cgit v1.1