diff options
author | peter <peter@FreeBSD.org> | 1995-12-30 19:02:48 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 1995-12-30 19:02:48 +0000 |
commit | ab124e78b0271ddb904b761b31e5c9a0cf24e070 (patch) | |
tree | 0cf1447720c45721ed3d214a4eaaa6834bda155d /sys/vm | |
parent | 15748830d0fcd29294a1969a1012655e74908c1e (diff) | |
download | FreeBSD-src-ab124e78b0271ddb904b761b31e5c9a0cf24e070.zip FreeBSD-src-ab124e78b0271ddb904b761b31e5c9a0cf24e070.tar.gz |
recording cvs-1.6 file death
Diffstat (limited to 'sys/vm')
-rw-r--r-- | sys/vm/vm_user.c | 130 | ||||
-rw-r--r-- | sys/vm/vm_vmio.c | 389 |
2 files changed, 0 insertions, 519 deletions
diff --git a/sys/vm/vm_user.c b/sys/vm/vm_user.c deleted file mode 100644 index 104e814..0000000 --- a/sys/vm/vm_user.c +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * The Mach Operating System project at Carnegie-Mellon University. - * - * 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 the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 THE REGENTS 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. - * - * from: @(#)vm_user.c 8.2 (Berkeley) 1/12/94 - * - * - * Copyright (c) 1987, 1990 Carnegie-Mellon University. - * All rights reserved. - * - * Authors: Avadis Tevanian, Jr., Michael Wayne Young - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - * - * $Id: vm_user.c,v 1.8 1995/02/20 18:08:18 davidg Exp $ - */ - -/* - * User-exported virtual memory functions. - */ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/proc.h> - -#include <vm/vm.h> - -simple_lock_data_t vm_alloc_lock; /* XXX */ - -/* - * Similar to vm_allocate but assigns an explicit pager. - */ -int -vm_allocate_with_pager(map, addr, size, anywhere, pager, poffset, internal) - register vm_map_t map; - register vm_offset_t *addr; - register vm_size_t size; - boolean_t anywhere; - vm_pager_t pager; - vm_offset_t poffset; - boolean_t internal; -{ - register vm_object_t object; - register int result; - - if (map == NULL) - return (KERN_INVALID_ARGUMENT); - - *addr = trunc_page(*addr); - size = round_page(size); - - /* - * Lookup the pager/paging-space in the object cache. If it's not - * there, then create a new object and cache it. - */ - object = vm_object_lookup(pager); - if (object == NULL) { - object = vm_object_allocate(size); - /* - * From Mike Hibler: "unnamed anonymous objects should never - * be on the hash list ... For now you can just change - * vm_allocate_with_pager to not do vm_object_enter if this is - * an internal object ..." - */ - if (!internal) - vm_object_enter(object, pager); - } - if (internal) - object->flags |= OBJ_INTERNAL; - else { - object->flags &= ~OBJ_INTERNAL; - cnt.v_nzfod -= atop(size); - } - - result = vm_map_find(map, object, poffset, addr, size, anywhere); - if (result != KERN_SUCCESS) - vm_object_deallocate(object); - else if (pager != NULL) - vm_object_setpager(object, pager, (vm_offset_t) 0, TRUE); - return (result); -} diff --git a/sys/vm/vm_vmio.c b/sys/vm/vm_vmio.c deleted file mode 100644 index 8450c92..0000000 --- a/sys/vm/vm_vmio.c +++ /dev/null @@ -1,389 +0,0 @@ -/* - * Copyright (c) 1994 John S. Dyson - * All rights reserved. - * - * 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 immediately at the beginning of the file, without modification, - * 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. Absolutely no warranty of function or purpose is made by the author - * John S. Dyson. - * 4. Modifications may be freely made to this file if the above conditions - * are met. - * - * $Id$ - */ -/* - * THIS IS PRELIMINARY, BUGGY AND NON-WORKING CODE - * WHEN THIS NOTICE IS REMOVED -- IT WILL WORK... :-). - * - * THINGS TO DO: - * COMMENTS, THE SYSTEM ALMOST RUNS WITH IT. THIS IS CURRENTLY MEANT - * ONLY AS A PLACEHOLDER!!! - */ -#define VMIO -#include "param.h" -#include "proc.h" -#include "malloc.h" -#include "vm_param.h" -#include "vm.h" -#include "lock.h" -#include "queue.h" -#include "vm_prot.h" -#include "vm_object.h" -#include "vm_page.h" -#include "vnode_pager.h" -#include "vm_map.h" -#include "vm_pageout.h" -#include "vnode.h" -#include "uio.h" -#include "mount.h" - -/* #include "buf.h" */ -#include "miscfs/specfs/specdev.h" -/* #include "vmio.h" */ - -int vnode_pager_initialized; -extern vm_map_t pager_map; - -struct buf * getpbuf(); -void relpbuf(struct buf *bp); - -/* - * map an object into kva - * return 1 if all are in memory, and 0 if any are fake. - */ -int -vmio_alloc_pages( vm_object_t object, vm_offset_t start, - vm_offset_t size, vm_page_t *ms) { - - int pagecount; - vm_page_t m; - int i,j; - int s; - vm_offset_t kva; - struct buf *bp; - int ioneeded=0; - - pagecount = size / PAGE_SIZE; - - for(i=0;i<pagecount;i++) { - vm_page_t m; - m = vm_page_lookup( object, start + i * PAGE_SIZE); - if( m) { - /* - * See if something else has already gotten this page - */ - if( m->busy || (m->flags & (PG_VMIO|PG_BUSY))) { - /* - * Something has the page, so we have to - * release all the pages we've gotten to - * this point, wait for the page to unbusy - * and then start over. - */ - int j; - for(j = 0; j < i; j++) { - vm_page_t n; - n = ms[j]; - if( n) { - /* - * unbusy the page. - */ - PAGE_WAKEUP(n); - if( n->flags & PG_FAKE) - vm_page_free(n); - } - } - m->flags |= PG_WANTED; - tsleep((caddr_t)m, PVM, "vngpwt", 0); - return -1; - } - m->flags |= PG_REFERENCED; - } else { - m = (vm_page_t) vm_page_alloc( object, - start + i * PAGE_SIZE); - if( !m) { - VM_WAIT; - for(j=0;j<i;j++) { - vm_page_t n; - n = ms[j]; - if( n) { - PAGE_WAKEUP(n); - if( n->flags & PG_FAKE) - vm_page_free(n); - } - } - return -1; - } - } - ms[i] = m; - } - /* - * hold the pages and assign them to the mapping - */ - for(i=0;i<pagecount;i++) { - m = ms[i]; - vm_page_hold(m); - if( m->flags & PG_FAKE) - ++ioneeded; - - vm_page_deactivate(m); - if( (m->flags & PG_ACTIVE) == 0) - vm_page_activate(m); - m->flags |= PG_VMIO; - m->flags &= ~PG_BUSY; - ++m->act_count; - pmap_page_protect( VM_PAGE_TO_PHYS(m), VM_PROT_READ); - } - return ioneeded; - -} - -void -vmio_rawiodone( struct buf *bp) { - int s; - int i; - vm_object_t object; - vm_page_t m; - - if( bp->b_bufsize != bp->b_bcount) - bzero( bp->b_data + bp->b_bcount, bp->b_bufsize - bp->b_bcount); - printf("rawdone: (blk: %d, count: %d)\n", - bp->b_blkno, bp->b_bcount); - s = splbio(); - object = bp->b_pages[0]->object; - for( i = 0; i < bp->b_npages; i++) { - m = bp->b_pages[i]; - if( m) { - --m->busy; - if( m->busy == 0) { - m->flags |= PG_CLEAN; - m->flags &= ~(PG_LAUNDRY|PG_FAKE); - PAGE_WAKEUP(m); - } - } else { - panic("vmio_rawiodone: page is gone!!!"); - } - } - HOLDRELE(bp->b_vp); - relpbuf(bp); - --object->paging_in_progress; - if( object->paging_in_progress == 0) - wakeup((caddr_t)object); - splx(s); - return; -} - -void -vmio_get_pager(struct vnode *vp) { - if( vp->v_type == VREG) { - vm_object_t object; - vm_pager_t pager; - if((vp->v_vmdata == NULL) || (vp->v_flag & VVMIO) == 0) { - pager = (vm_pager_t) vnode_pager_alloc(vp, 0, 0, 0); - object = (vm_object_t) vp->v_vmdata; - if( object->pager != pager) - panic("vmio_get_pager: pager/object mismatch"); - (void) vm_object_lookup( pager); - pager_cache( object, TRUE); - vp->v_flag |= VVMIO; - } else { - object = (vm_object_t) vp->v_vmdata; - pager = object->pager; - if( pager == NULL) { - panic("vmio_get_pager: pager missing"); - } - (void) vm_object_lookup( pager); - } - } -} - -void -vmio_free_pager( struct vnode *vp) { - if( vp->v_vmdata == NULL) - panic("vmio_free_pager: object missing"); - vm_object_deallocate( (vm_object_t) vp->v_vmdata); -} - -void -vmio_aread( struct buf *lbp) { - struct vnode *vp, *dp; - vm_object_t object; - vm_offset_t offset; - vm_offset_t size; - vm_offset_t off; - int forcemore; - int runp; - int s; - - s = splbio(); - vp = lbp->b_vp; - object = (vm_object_t) vp->v_vmdata; - offset = trunc_page(lbp->b_lblkno * vp->v_mount->mnt_stat.f_iosize); - size = round_page(lbp->b_bcount); - forcemore = 0; - printf("queueing read: iosize: %d, b_lblkno: %d, offset: %d, size: %d:", - vp->v_mount->mnt_stat.f_iosize, - lbp->b_lblkno, offset, size); - - for(off = 0; off < size; ) { - vm_offset_t curoff; - int pgidx, pgcnt, i; - struct buf *bp; - pgidx = off / PAGE_SIZE; - if( !forcemore) { - while( (off < size) && - (lbp->b_pages[pgidx]->flags & PG_FAKE) == 0) { - off = trunc_page(off) + PAGE_SIZE; - pgidx += 1; - } - } - if( off >= size) - break; - bp = getpbuf(); - - ++object->paging_in_progress; - - curoff = offset + off; - VOP_BMAP( vp, curoff / vp->v_mount->mnt_stat.f_iosize, - &dp, &bp->b_blkno, &runp); - - bp->b_bcount = (runp + 1) * vp->v_mount->mnt_stat.f_iosize; - if( off + bp->b_bcount > size) - bp->b_bcount = size - off; - bp->b_bufsize = round_page(bp->b_bcount); - - pgcnt = bp->b_bufsize / PAGE_SIZE; - for(i=0;i<pgcnt;i++) { - ++lbp->b_pages[pgidx+i]->busy; - bp->b_pages[i] = lbp->b_pages[pgidx+i]; - bp->b_pages[i]->flags |= PG_BUSY; - } - bp->b_npages = pgcnt; - pmap_qenter((vm_offset_t) bp->b_data, &lbp->b_pages[pgidx], pgcnt); - bp->b_data += curoff - trunc_page(curoff); - off += bp->b_bcount; - if( off & (PAGE_SIZE - 1)) - forcemore = 1; - else - forcemore = 0; - /* - * round up physical size for real devices - */ - if( dp->v_type == VBLK || dp->v_type == VCHR) { - bp->b_bcount = (bp->b_bcount + DEV_BSIZE - 1) & ~(DEV_BSIZE - 1); - } - /* - * and map the pages to be read into the kva - */ - VHOLD(vp); - /* build a minimal buffer header */ - bp->b_flags = B_BUSY | B_READ | B_CALL | B_ASYNC; - bp->b_iodone = vmio_rawiodone; - /* B_PHYS is not set, but it is nice to fill this in */ - bp->b_proc = curproc; - bp->b_rcred = bp->b_wcred = bp->b_proc->p_ucred; - if( bp->b_rcred != NOCRED) - crhold(bp->b_rcred); - if( bp->b_wcred != NOCRED) - crhold(bp->b_wcred); - bp->b_lblkno = bp->b_blkno; -/* bp->b_vp = dp; */ - bgetvp( dp, bp); - printf(" p: (blk: %d, coff: %d, off: %d, count: %d)", - bp->b_blkno, curoff, off, bp->b_bcount); - - /* Should be a BLOCK or character DEVICE if we get here */ - bp->b_dev = dp->v_rdev; - - /* do the input */ - VOP_STRATEGY(bp); - } - printf("\n"); - splx(s); -} - -int -vmio_getblk( struct buf *bp) { - struct vnode *vp; - vm_object_t object; - vm_offset_t offset; - vm_offset_t size; - vm_page_t ms[(MAXBSIZE + PAGE_SIZE - 1)/PAGE_SIZE]; - int rtval; - - vp = bp->b_vp; - if( (object = (vm_object_t) vp->v_vmdata) == NULL) - panic("vmio_build_bp: object missing"); - - offset = trunc_page(bp->b_lblkno * vp->v_mount->mnt_stat.f_iosize); - size = round_page(bp->b_bcount); - printf("vmio_getblk: off:%d(0x%x) blk: %d, size: %d", - offset, offset, bp->b_lblkno, size); - - bp->b_flags &= ~B_CACHE; - if( (rtval = vmio_alloc_pages( object, offset, size, ms)) == 0) { - bp->b_flags |= B_CACHE; - printf("(cached)\n"); - } else { - printf("(ioneeded:%d)\n", rtval); - } - - if( rtval < 0) { - printf("vmio_getblk: vmio_alloc_pages busy\n"); - return 0; - } - - bp->b_npages = size / PAGE_SIZE; - pmap_qenter((vm_offset_t) bp->b_data, ms, bp->b_npages); - bp->b_flags |= B_VMIO; - bp->b_bufsize = size; - bcopy( ms, bp->b_pages, bp->b_npages * sizeof(vm_page_t)); - return 1; -} - -int -vmio_biowait( struct buf *lbp) { - int i; - int s; - printf("vmio_biowait -->"); -restart: - s = splbio(); - for(i=lbp->b_npages-1;i >= 0; --i) { - if( lbp->b_pages[i]->busy || (lbp->b_pages[i]->flags & PG_BUSY)) { - lbp->b_pages[i]->flags |= PG_WANTED; - printf(" waiting on page %d of xfer at %d, flags: 0x%x\n", - i, lbp->b_blkno, lbp->b_pages[i]->flags); - tsleep( (caddr_t) lbp->b_pages[i], PVM, "vbiowt", 0); - splx(s); - goto restart; - } - } - splx(s); - printf("vmio_biowait: finished\n"); - return 1; -} - -void -vmio_brelse( struct buf *lbp) { - int i; - int nfullpages = lbp->b_bcount / PAGE_SIZE; - pmap_qremove((vm_offset_t) lbp->b_data, lbp->b_npages); - for(i=0;i<lbp->b_npages;i++) { - if( (i < nfullpages) && ((lbp->b_flags & B_DELWRI) == 0)) - lbp->b_pages[i]->flags |= PG_CLEAN; - if( lbp->b_flags & B_DELWRI) - lbp->b_pages[i]->flags &= ~PG_CLEAN; - lbp->b_pages[i]->flags &= ~PG_VMIO; - vm_page_unhold(lbp->b_pages[i]); - PAGE_WAKEUP(lbp->b_pages[i]); - } - lbp->b_flags &= ~B_VMIO; - lbp->b_flags |= B_INVAL; - lbp->b_bufsize = 0; -} |