2002-04-04 03:33:26 +04:00
|
|
|
/* $NetBSD: vm_machdep.c,v 1.16 2002/04/03 23:33:29 thorpej Exp $ */
|
1996-02-01 02:14:53 +03:00
|
|
|
|
|
|
|
/*
|
1998-05-01 01:22:00 +04:00
|
|
|
* Copyright (c) 1994-1998 Mark Brinicombe.
|
1996-02-01 02:14:53 +03:00
|
|
|
* Copyright (c) 1994 Brini.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software written for Brini by Mark Brinicombe
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by Brini.
|
|
|
|
* 4. The name of the company nor the name of the author may be used to
|
|
|
|
* endorse or promote products derived from this software without specific
|
|
|
|
* prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY BRINI ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
|
|
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL BRINI OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
|
|
|
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* RiscBSD kernel project
|
|
|
|
*
|
|
|
|
* vm_machdep.h
|
|
|
|
*
|
1996-04-27 07:00:27 +04:00
|
|
|
* vm machine specific bits
|
1996-02-01 02:14:53 +03:00
|
|
|
*
|
|
|
|
* Created : 08/10/94
|
|
|
|
*/
|
|
|
|
|
1998-07-06 05:56:40 +04:00
|
|
|
#include "opt_armfpe.h"
|
1998-07-06 06:40:42 +04:00
|
|
|
#include "opt_pmap_debug.h"
|
1998-06-03 00:41:46 +04:00
|
|
|
|
1996-02-01 02:14:53 +03:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/vnode.h>
|
|
|
|
#include <sys/buf.h>
|
|
|
|
#include <sys/user.h>
|
|
|
|
#include <sys/exec.h>
|
|
|
|
#include <sys/syslog.h>
|
|
|
|
|
1998-06-03 00:41:46 +04:00
|
|
|
#include <uvm/uvm_extern.h>
|
|
|
|
|
1996-02-01 02:14:53 +03:00
|
|
|
#include <machine/cpu.h>
|
|
|
|
#include <machine/pmap.h>
|
|
|
|
#include <machine/reg.h>
|
|
|
|
#include <machine/vmparam.h>
|
|
|
|
|
|
|
|
#ifdef ARMFPE
|
2001-11-24 04:26:23 +03:00
|
|
|
#include <arm/fpe-arm/armfpe.h>
|
1996-02-01 02:14:53 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
extern pv_addr_t systempage;
|
|
|
|
|
1996-06-04 01:46:15 +04:00
|
|
|
int process_read_regs __P((struct proc *p, struct reg *regs));
|
|
|
|
int process_read_fpregs __P((struct proc *p, struct fpreg *regs));
|
|
|
|
|
2001-11-19 23:38:58 +03:00
|
|
|
void switch_exit __P((struct proc *p));
|
1998-02-22 02:27:10 +03:00
|
|
|
extern void proc_trampoline __P((void));
|
1996-02-01 02:14:53 +03:00
|
|
|
|
|
|
|
/*
|
1998-06-02 18:34:55 +04:00
|
|
|
* Special compilation symbols:
|
|
|
|
*
|
|
|
|
* STACKCHECKS - Fill undefined and supervisor stacks with a known pattern
|
|
|
|
* on forking and check the pattern on exit, reporting
|
|
|
|
* the amount of stack used.
|
1996-02-01 02:14:53 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Finish a fork operation, with process p2 nearly set up.
|
2000-01-21 01:18:54 +03:00
|
|
|
* Copy and update the pcb and trap frame, making the child ready to run.
|
|
|
|
*
|
|
|
|
* Rig the child's kernel stack so that it will start out in
|
|
|
|
* proc_trampoline() and call child_return() with p2 as an
|
|
|
|
* argument. This causes the newly-created child process to go
|
|
|
|
* directly to user level with an apparent return value of 0 from
|
|
|
|
* fork(), while the parent process returns normally.
|
|
|
|
*
|
|
|
|
* p1 is the process being forked; if p1 == &proc0, we are creating
|
2000-05-28 09:48:59 +04:00
|
|
|
* a kernel thread, and the return path and argument are specified with
|
|
|
|
* `func' and `arg'.
|
2000-01-21 01:18:54 +03:00
|
|
|
*
|
|
|
|
* If an alternate user-level stack is requested (with non-zero values
|
|
|
|
* in both the stack and stacksize args), set up the user stack pointer
|
|
|
|
* accordingly.
|
1996-02-01 02:14:53 +03:00
|
|
|
*/
|
1996-03-14 00:16:15 +03:00
|
|
|
void
|
2000-05-28 09:48:59 +04:00
|
|
|
cpu_fork(p1, p2, stack, stacksize, func, arg)
|
1996-03-14 00:16:15 +03:00
|
|
|
struct proc *p1;
|
|
|
|
struct proc *p2;
|
1999-05-14 01:58:32 +04:00
|
|
|
void *stack;
|
|
|
|
size_t stacksize;
|
2000-05-28 09:48:59 +04:00
|
|
|
void (*func) __P((void *));
|
|
|
|
void *arg;
|
1996-02-01 02:14:53 +03:00
|
|
|
{
|
1996-03-14 00:16:15 +03:00
|
|
|
struct pcb *pcb = (struct pcb *)&p2->p_addr->u_pcb;
|
|
|
|
struct trapframe *tf;
|
|
|
|
struct switchframe *sf;
|
1996-02-01 02:14:53 +03:00
|
|
|
|
1997-10-14 15:23:54 +04:00
|
|
|
#ifdef PMAP_DEBUG
|
1996-02-01 02:14:53 +03:00
|
|
|
if (pmap_debug_level >= 0)
|
1997-10-14 15:23:54 +04:00
|
|
|
printf("cpu_fork: %p %p %p %p\n", p1, p2, curproc, &proc0);
|
1998-02-22 02:27:10 +03:00
|
|
|
#endif /* PMAP_DEBUG */
|
1996-02-01 02:14:53 +03:00
|
|
|
|
1998-11-11 09:41:23 +03:00
|
|
|
#if 0 /* XXX */
|
|
|
|
if (p1 == curproc) {
|
|
|
|
/* Sync the PCB before we copy it. */
|
|
|
|
savectx(curpcb);
|
|
|
|
}
|
1996-10-16 02:07:41 +04:00
|
|
|
#endif
|
1996-02-01 02:14:53 +03:00
|
|
|
|
1996-10-16 02:07:41 +04:00
|
|
|
/* Copy the pcb */
|
1996-03-14 00:16:15 +03:00
|
|
|
*pcb = p1->p_addr->u_pcb;
|
1996-02-01 02:14:53 +03:00
|
|
|
|
1996-10-16 02:07:41 +04:00
|
|
|
/*
|
|
|
|
* Set up the undefined stack for the process.
|
1996-10-17 06:50:14 +04:00
|
|
|
* Note: this stack is not in use if we are forking from p1
|
1996-10-16 02:07:41 +04:00
|
|
|
*/
|
2001-09-09 14:33:42 +04:00
|
|
|
pcb->pcb_un.un_32.pcb32_und_sp = (u_int)p2->p_addr +
|
|
|
|
USPACE_UNDEF_STACK_TOP;
|
|
|
|
pcb->pcb_un.un_32.pcb32_sp = (u_int)p2->p_addr + USPACE_SVC_STACK_TOP;
|
1996-02-01 02:14:53 +03:00
|
|
|
|
1996-10-16 02:07:41 +04:00
|
|
|
#ifdef STACKCHECKS
|
|
|
|
/* Fill the undefined stack with a known pattern */
|
1998-06-02 18:34:55 +04:00
|
|
|
memset(((u_char *)p2->p_addr) + USPACE_UNDEF_STACK_BOTTOM, 0xdd,
|
|
|
|
(USPACE_UNDEF_STACK_TOP - USPACE_UNDEF_STACK_BOTTOM));
|
1996-10-16 02:07:41 +04:00
|
|
|
/* Fill the kernel stack with a known pattern */
|
1998-06-02 18:34:55 +04:00
|
|
|
memset(((u_char *)p2->p_addr) + USPACE_SVC_STACK_BOTTOM, 0xdd,
|
|
|
|
(USPACE_SVC_STACK_TOP - USPACE_SVC_STACK_BOTTOM));
|
1996-10-17 06:50:14 +04:00
|
|
|
#endif /* STACKCHECKS */
|
1996-02-01 02:14:53 +03:00
|
|
|
|
1997-10-14 15:23:54 +04:00
|
|
|
#ifdef PMAP_DEBUG
|
1996-02-01 02:14:53 +03:00
|
|
|
if (pmap_debug_level >= 0) {
|
1998-02-22 02:27:10 +03:00
|
|
|
printf("p1->procaddr=%p p1->procaddr->u_pcb=%p pid=%d pmap=%p\n",
|
|
|
|
p1->p_addr, &p1->p_addr->u_pcb, p1->p_pid,
|
1997-10-06 05:12:05 +04:00
|
|
|
p1->p_vmspace->vm_map.pmap);
|
1998-02-22 02:27:10 +03:00
|
|
|
printf("p2->procaddr=%p p2->procaddr->u_pcb=%p pid=%d pmap=%p\n",
|
|
|
|
p2->p_addr, &p2->p_addr->u_pcb, p2->p_pid,
|
1997-10-06 05:12:05 +04:00
|
|
|
p2->p_vmspace->vm_map.pmap);
|
1996-02-01 02:14:53 +03:00
|
|
|
}
|
1998-02-22 02:27:10 +03:00
|
|
|
#endif /* PMAP_DEBUG */
|
1996-02-01 02:14:53 +03:00
|
|
|
|
1998-01-03 01:36:33 +03:00
|
|
|
pmap_activate(p2);
|
1996-02-01 02:14:53 +03:00
|
|
|
|
|
|
|
#ifdef ARMFPE
|
1996-10-16 02:07:41 +04:00
|
|
|
/* Initialise a new FP context for p2 and copy the context from p1 */
|
1996-02-01 02:14:53 +03:00
|
|
|
arm_fpe_core_initcontext(FP_CONTEXT(p2));
|
|
|
|
arm_fpe_copycontext(FP_CONTEXT(p1), FP_CONTEXT(p2));
|
1996-10-17 06:50:14 +04:00
|
|
|
#endif /* ARMFPE */
|
1996-02-01 02:14:53 +03:00
|
|
|
|
2001-09-09 14:33:42 +04:00
|
|
|
p2->p_addr->u_pcb.pcb_tf = tf =
|
|
|
|
(struct trapframe *)pcb->pcb_un.un_32.pcb32_sp - 1;
|
2001-02-28 21:15:42 +03:00
|
|
|
*tf = *p1->p_addr->u_pcb.pcb_tf;
|
1999-05-14 01:58:32 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If specified, give the child a different stack.
|
|
|
|
*/
|
|
|
|
if (stack != NULL)
|
|
|
|
tf->tf_usr_sp = (u_int)stack + stacksize;
|
|
|
|
|
1996-03-14 00:16:15 +03:00
|
|
|
sf = (struct switchframe *)tf - 1;
|
2002-01-30 02:02:48 +03:00
|
|
|
sf->sf_spl = 0; /* always equivalent to spl0() */
|
2000-05-28 09:48:59 +04:00
|
|
|
sf->sf_r4 = (u_int)func;
|
|
|
|
sf->sf_r5 = (u_int)arg;
|
1996-03-14 00:16:15 +03:00
|
|
|
sf->sf_pc = (u_int)proc_trampoline;
|
2001-09-09 14:33:42 +04:00
|
|
|
pcb->pcb_un.un_32.pcb32_sp = (u_int)sf;
|
1996-03-14 00:16:15 +03:00
|
|
|
}
|
1996-02-01 02:14:53 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* cpu_exit is called as the last action during exit.
|
|
|
|
*
|
|
|
|
* We clean up a little and then call switch_exit() with the old proc as an
|
1998-09-09 04:07:48 +04:00
|
|
|
* argument. switch_exit() first switches to proc0's context, and finally
|
|
|
|
* jumps into switch() to wait for another process to wake up.
|
1996-02-01 02:14:53 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
|
|
|
cpu_exit(p)
|
|
|
|
register struct proc *p;
|
|
|
|
{
|
|
|
|
#ifdef ARMFPE
|
1996-10-16 02:07:41 +04:00
|
|
|
/* Abort any active FP operation and deactivate the context */
|
1996-02-01 02:14:53 +03:00
|
|
|
arm_fpe_core_abort(FP_CONTEXT(p), NULL, NULL);
|
|
|
|
arm_fpe_core_changecontext(0);
|
1996-10-17 06:50:14 +04:00
|
|
|
#endif /* ARMFPE */
|
1996-02-01 02:14:53 +03:00
|
|
|
|
1996-10-16 02:07:41 +04:00
|
|
|
#ifdef STACKCHECKS
|
|
|
|
/* Report how much stack has been used - debugging */
|
|
|
|
if (p) {
|
1996-02-01 02:14:53 +03:00
|
|
|
u_char *ptr;
|
|
|
|
int loop;
|
|
|
|
|
|
|
|
ptr = ((u_char *)p2->p_addr) + USPACE_UNDEF_STACK_BOTTOM;
|
1996-10-16 02:07:41 +04:00
|
|
|
for (loop = 0; loop < (USPACE_UNDEF_STACK_TOP - USPACE_UNDEF_STACK_BOTTOM)
|
|
|
|
&& *ptr == 0xdd; ++loop, ++ptr) ;
|
1996-02-01 02:14:53 +03:00
|
|
|
log(LOG_INFO, "%d bytes of undefined stack fill pattern\n", loop);
|
|
|
|
ptr = ((u_char *)p2->p_addr) + USPACE_SVC_STACK_BOTTOM;
|
1996-10-16 02:07:41 +04:00
|
|
|
for (loop = 0; loop < (USPACE_SVC_STACK_TOP - USPACE_SVC_STACK_BOTTOM)
|
|
|
|
&& *ptr == 0xdd; ++loop, ++ptr) ;
|
1996-02-01 02:14:53 +03:00
|
|
|
log(LOG_INFO, "%d bytes of svc stack fill pattern\n", loop);
|
|
|
|
}
|
1996-10-17 06:50:14 +04:00
|
|
|
#endif /* STACKCHECKS */
|
1998-06-03 00:41:46 +04:00
|
|
|
uvmexp.swtch++;
|
2001-11-19 23:38:58 +03:00
|
|
|
switch_exit(p);
|
1996-02-01 02:14:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
cpu_swapin(p)
|
|
|
|
struct proc *p;
|
|
|
|
{
|
2001-10-18 13:26:08 +04:00
|
|
|
#if 0
|
|
|
|
/* Don't do this. See the comment in cpu_swapout(). */
|
1997-10-14 15:23:54 +04:00
|
|
|
#ifdef PMAP_DEBUG
|
1996-02-01 02:14:53 +03:00
|
|
|
if (pmap_debug_level >= 0)
|
1997-10-06 05:12:05 +04:00
|
|
|
printf("cpu_swapin(%p, %d, %s, %p)\n", p, p->p_pid,
|
|
|
|
p->p_comm, p->p_vmspace->vm_map.pmap);
|
1998-02-22 02:27:10 +03:00
|
|
|
#endif /* PMAP_DEBUG */
|
1996-02-01 02:14:53 +03:00
|
|
|
|
2002-04-04 03:33:26 +04:00
|
|
|
if (vector_page < KERNEL_BASE) {
|
|
|
|
/* Map the vector page */
|
|
|
|
pmap_enter(p->p_vmspace->vm_map.pmap, vector_page,
|
|
|
|
systempage.pv_pa, VM_PROT_READ, VM_PROT_READ|PMAP_WIRED);
|
|
|
|
pmap_update(p->p_vmspace->vm_map.pmap);
|
|
|
|
}
|
2001-10-18 13:26:08 +04:00
|
|
|
#endif
|
1996-02-01 02:14:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
cpu_swapout(p)
|
|
|
|
struct proc *p;
|
|
|
|
{
|
2001-10-18 13:26:08 +04:00
|
|
|
#if 0
|
|
|
|
/*
|
|
|
|
* Don't do this! If the pmap is shared with another process,
|
|
|
|
* it will loose it's page0 entry. That's bad news indeed.
|
|
|
|
*/
|
1997-10-14 15:23:54 +04:00
|
|
|
#ifdef PMAP_DEBUG
|
1998-05-01 01:22:00 +04:00
|
|
|
if (pmap_debug_level >= 0)
|
1997-10-06 05:12:05 +04:00
|
|
|
printf("cpu_swapout(%p, %d, %s, %p)\n", p, p->p_pid,
|
1998-01-20 04:18:18 +03:00
|
|
|
p->p_comm, &p->p_vmspace->vm_map.pmap);
|
1998-02-22 02:27:10 +03:00
|
|
|
#endif /* PMAP_DEBUG */
|
1996-02-01 02:14:53 +03:00
|
|
|
|
2002-04-04 03:33:26 +04:00
|
|
|
if (vector_page < KERNEL_BASE) {
|
|
|
|
/* Free the system page mapping */
|
|
|
|
pmap_remove(p->p_vmspace->vm_map.pmap, vector_page,
|
|
|
|
vector_page + NBPG);
|
|
|
|
pmap_update(p->p_vmspace->vm_map.pmap);
|
|
|
|
}
|
2001-10-18 13:26:08 +04:00
|
|
|
#endif
|
1996-02-01 02:14:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Move pages from one kernel virtual address to another.
|
|
|
|
* Both addresses are assumed to reside in the Sysmap,
|
2002-02-26 18:13:19 +03:00
|
|
|
* and size must be a multiple of NBPG.
|
1996-02-01 02:14:53 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
|
|
|
pagemove(from, to, size)
|
|
|
|
caddr_t from, to;
|
1996-04-27 07:00:27 +04:00
|
|
|
size_t size;
|
1996-02-01 02:14:53 +03:00
|
|
|
{
|
|
|
|
register pt_entry_t *fpte, *tpte;
|
|
|
|
|
1999-12-05 00:13:19 +03:00
|
|
|
if (size % NBPG)
|
2001-08-05 09:07:27 +04:00
|
|
|
panic("pagemove: size=%08lx", (u_long) size);
|
1996-02-01 02:14:53 +03:00
|
|
|
|
1997-10-14 15:23:54 +04:00
|
|
|
#ifdef PMAP_DEBUG
|
1996-02-01 02:14:53 +03:00
|
|
|
if (pmap_debug_level >= 0)
|
2001-08-05 09:07:27 +04:00
|
|
|
printf("pagemove: V%p to %p size %08lx\n",
|
|
|
|
from, to, (u_long) size);
|
1998-02-22 02:27:10 +03:00
|
|
|
#endif /* PMAP_DEBUG */
|
|
|
|
|
2001-07-28 17:28:03 +04:00
|
|
|
fpte = vtopte((vaddr_t)from);
|
|
|
|
tpte = vtopte((vaddr_t)to);
|
1996-02-01 02:14:53 +03:00
|
|
|
|
1996-10-16 02:07:41 +04:00
|
|
|
/*
|
|
|
|
* Make sure the cache does not have dirty data for the
|
1998-07-08 04:12:33 +04:00
|
|
|
* pages we are moving. Pages in the buffers are only
|
|
|
|
* ever moved with pagemove, so we only need to clean
|
|
|
|
* the 'from' area.
|
1996-10-16 02:07:41 +04:00
|
|
|
*/
|
1998-07-08 04:12:33 +04:00
|
|
|
|
2002-01-25 22:19:22 +03:00
|
|
|
cpu_dcache_wbinv_range((vaddr_t) from, size);
|
1996-02-01 02:14:53 +03:00
|
|
|
|
|
|
|
while (size > 0) {
|
|
|
|
*tpte++ = *fpte;
|
|
|
|
*fpte++ = 0;
|
|
|
|
size -= NBPG;
|
|
|
|
}
|
2001-07-28 17:28:03 +04:00
|
|
|
//cpu_tlb_flushD();
|
1996-02-01 02:14:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1999-05-27 02:07:36 +04:00
|
|
|
* Map a user I/O request into kernel virtual address space.
|
|
|
|
* Note: the pages are already locked by uvm_vslock(), so we
|
|
|
|
* do not need to pass an access_type to pmap_enter().
|
1996-02-01 02:14:53 +03:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
vmapbuf(bp, len)
|
|
|
|
struct buf *bp;
|
2001-03-04 22:05:55 +03:00
|
|
|
vsize_t len;
|
1996-02-01 02:14:53 +03:00
|
|
|
{
|
2001-03-04 22:05:55 +03:00
|
|
|
vaddr_t faddr, taddr, off;
|
2001-08-11 16:57:25 +04:00
|
|
|
paddr_t fpa;
|
|
|
|
|
1996-02-01 02:14:53 +03:00
|
|
|
|
1997-10-14 15:23:54 +04:00
|
|
|
#ifdef PMAP_DEBUG
|
1996-02-01 02:14:53 +03:00
|
|
|
if (pmap_debug_level >= 0)
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("vmapbuf: bp=%08x buf=%08x len=%08x\n", (u_int)bp,
|
1996-02-01 02:14:53 +03:00
|
|
|
(u_int)bp->b_data, (u_int)len);
|
1998-02-22 02:27:10 +03:00
|
|
|
#endif /* PMAP_DEBUG */
|
1996-02-01 02:14:53 +03:00
|
|
|
|
|
|
|
if ((bp->b_flags & B_PHYS) == 0)
|
|
|
|
panic("vmapbuf");
|
|
|
|
|
2001-08-11 16:57:25 +04:00
|
|
|
faddr = trunc_page((vaddr_t)bp->b_saveaddr = bp->b_data);
|
2001-03-04 22:05:55 +03:00
|
|
|
off = (vaddr_t)bp->b_data - faddr;
|
1996-02-01 02:14:53 +03:00
|
|
|
len = round_page(off + len);
|
2001-09-21 03:32:23 +04:00
|
|
|
taddr = uvm_km_valloc_wait(phys_map, len);
|
1996-02-01 02:14:53 +03:00
|
|
|
bp->b_data = (caddr_t)(taddr + off);
|
1998-05-01 01:22:00 +04:00
|
|
|
|
1996-02-01 02:14:53 +03:00
|
|
|
/*
|
|
|
|
* The region is locked, so we expect that pmap_pte() will return
|
|
|
|
* non-NULL.
|
|
|
|
*/
|
2001-08-11 16:57:25 +04:00
|
|
|
while (len) {
|
|
|
|
(void) pmap_extract(vm_map_pmap(&bp->b_proc->p_vmspace->vm_map),
|
|
|
|
faddr, &fpa);
|
2001-08-21 01:52:09 +04:00
|
|
|
pmap_enter(pmap_kernel(), taddr, fpa,
|
|
|
|
VM_PROT_READ|VM_PROT_WRITE, PMAP_WIRED);
|
2001-08-11 16:57:25 +04:00
|
|
|
faddr += PAGE_SIZE;
|
|
|
|
taddr += PAGE_SIZE;
|
|
|
|
len -= PAGE_SIZE;
|
|
|
|
}
|
2001-09-11 01:19:08 +04:00
|
|
|
pmap_update(pmap_kernel());
|
1996-02-01 02:14:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1999-05-27 02:19:33 +04:00
|
|
|
* Unmap a previously-mapped user I/O request.
|
1996-02-01 02:14:53 +03:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
vunmapbuf(bp, len)
|
|
|
|
struct buf *bp;
|
2001-03-04 22:05:55 +03:00
|
|
|
vsize_t len;
|
1996-02-01 02:14:53 +03:00
|
|
|
{
|
2001-03-04 22:05:55 +03:00
|
|
|
vaddr_t addr, off;
|
1996-02-01 02:14:53 +03:00
|
|
|
|
1997-10-14 15:23:54 +04:00
|
|
|
#ifdef PMAP_DEBUG
|
1996-02-01 02:14:53 +03:00
|
|
|
if (pmap_debug_level >= 0)
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("vunmapbuf: bp=%08x buf=%08x len=%08x\n",
|
1996-02-01 02:14:53 +03:00
|
|
|
(u_int)bp, (u_int)bp->b_data, (u_int)len);
|
1998-02-22 02:27:10 +03:00
|
|
|
#endif /* PMAP_DEBUG */
|
1996-02-01 02:14:53 +03:00
|
|
|
|
|
|
|
if ((bp->b_flags & B_PHYS) == 0)
|
|
|
|
panic("vunmapbuf");
|
|
|
|
|
1996-10-16 02:07:41 +04:00
|
|
|
/*
|
|
|
|
* Make sure the cache does not have dirty data for the
|
|
|
|
* pages we had mapped.
|
|
|
|
*/
|
2000-03-27 00:42:21 +04:00
|
|
|
addr = trunc_page((vaddr_t)bp->b_data);
|
2001-03-04 22:05:55 +03:00
|
|
|
off = (vaddr_t)bp->b_data - addr;
|
1996-02-01 02:14:53 +03:00
|
|
|
len = round_page(off + len);
|
2001-08-21 01:52:09 +04:00
|
|
|
|
|
|
|
pmap_remove(pmap_kernel(), addr, addr + len);
|
2001-09-11 01:19:08 +04:00
|
|
|
pmap_update(pmap_kernel());
|
2001-08-11 16:57:25 +04:00
|
|
|
uvm_km_free_wakeup(phys_map, addr, len);
|
1996-02-01 02:14:53 +03:00
|
|
|
bp->b_data = bp->b_saveaddr;
|
|
|
|
bp->b_saveaddr = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* End of vm_machdep.c */
|