From a977d6c75f14582e9a1e812c1c70846411179311 Mon Sep 17 00:00:00 2001 From: Michael Shalayeff Date: Thu, 25 Feb 1999 19:08:51 +0000 Subject: vmapbuf/vunmapbuf --- sys/arch/hppa/hppa/vm_machdep.c | 47 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) (limited to 'sys/arch') diff --git a/sys/arch/hppa/hppa/vm_machdep.c b/sys/arch/hppa/hppa/vm_machdep.c index 31a3b72fd8b..f88c8178770 100644 --- a/sys/arch/hppa/hppa/vm_machdep.c +++ b/sys/arch/hppa/hppa/vm_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_machdep.c,v 1.2 1999/01/10 13:34:18 niklas Exp $ */ +/* $OpenBSD: vm_machdep.c,v 1.3 1999/02/25 19:08:50 mickey Exp $ */ #include #include @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -68,13 +69,21 @@ void cpu_fork(p1, p2) struct proc *p1, *p2; { + p2->p_md.md_flags = p1->p_md.md_flags; + + p2->p_addr->u_pcb = p1->p_addr->u_pcb; + + /* TODO: create the child's kernel stack */ } void cpu_exit(p) struct proc *p; { + /* TODO: anything to be done about FPU */ + vmspace_free(p->p_vmspace); + /* to the switch */ } @@ -94,18 +103,54 @@ cpu_set_kpc(p, pc, arg) } +/* + * Map an IO request into kernel virtual address space. + */ void vmapbuf(bp, len) struct buf *bp; vm_size_t len; { + vm_offset_t faddr, taddr, off, pa; + struct proc *p; + if ((bp->b_flags & B_PHYS) == 0) + panic("vmapbuf"); + p = bp->b_proc; + faddr = trunc_page(bp->b_saveaddr = bp->b_data); + off = (vm_offset_t)bp->b_data - faddr; + len = round_page(off + len); + taddr = kmem_alloc_wait(phys_map, len); + bp->b_data = (caddr_t)(taddr + off); + len = atop(len); + while (len--) { + pa = pmap_extract(vm_map_pmap(&p->p_vmspace->vm_map), faddr); + if (pa == 0) + panic("vmapbuf: null page frame"); + pmap_enter(vm_map_pmap(phys_map), taddr, trunc_page(pa), + VM_PROT_READ|VM_PROT_WRITE, TRUE); + faddr += PAGE_SIZE; + taddr += PAGE_SIZE; + } } +/* + * Unmap IO request from the kernel virtual address space. + */ void vunmapbuf(bp, len) struct buf *bp; vm_size_t len; { + vm_offset_t addr, off; + + if ((bp->b_flags & B_PHYS) == 0) + panic("vunmapbuf"); + addr = trunc_page(bp->b_data); + off = (vm_offset_t)bp->b_data - addr; + len = round_page(off + len); + kmem_free_wakeup(phys_map, addr, len); + bp->b_data = bp->b_saveaddr; + bp->b_saveaddr = NULL; } -- cgit v1.2.3