Home | History | Annotate | Line # | Download | only in uvm
uvm_init.c revision 1.2
      1 /*	$NetBSD: uvm_init.c,v 1.2 1998/02/06 22:31:52 thorpej Exp $	*/
      2 
      3 /*
      4  * XXXCDC: "ROUGH DRAFT" QUALITY UVM PRE-RELEASE FILE!
      5  *	   >>>USE AT YOUR OWN RISK, WORK IS NOT FINISHED<<<
      6  */
      7 /*
      8  *
      9  * Copyright (c) 1997 Charles D. Cranor and Washington University.
     10  * All rights reserved.
     11  *
     12  * Redistribution and use in source and binary forms, with or without
     13  * modification, are permitted provided that the following conditions
     14  * are met:
     15  * 1. Redistributions of source code must retain the above copyright
     16  *    notice, this list of conditions and the following disclaimer.
     17  * 2. Redistributions in binary form must reproduce the above copyright
     18  *    notice, this list of conditions and the following disclaimer in the
     19  *    documentation and/or other materials provided with the distribution.
     20  * 3. All advertising materials mentioning features or use of this software
     21  *    must display the following acknowledgement:
     22  *      This product includes software developed by Charles D. Cranor and
     23  *      Washington University.
     24  * 4. The name of the author may not be used to endorse or promote products
     25  *    derived from this software without specific prior written permission.
     26  *
     27  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     28  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     29  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     30  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     31  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     32  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     33  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     34  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     35  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     36  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     37  */
     38 
     39 /*
     40  * uvm_init.c: init the vm system.
     41  */
     42 
     43 #include <sys/param.h>
     44 #include <sys/systm.h>
     45 #include <sys/file.h>
     46 #include <sys/filedesc.h>
     47 #include <sys/resourcevar.h>
     48 #include <sys/mman.h>
     49 #include <sys/mount.h>
     50 #include <sys/proc.h>
     51 #include <sys/malloc.h>
     52 #include <sys/vnode.h>
     53 #include <sys/conf.h>
     54 
     55 
     56 #include <vm/vm.h>
     57 #include <vm/vm_page.h>
     58 #include <vm/vm_kern.h>
     59 
     60 #include <sys/syscallargs.h>
     61 
     62 #include <uvm/uvm.h>
     63 
     64 /*
     65  * struct uvm: we store all global vars in this structure to make them
     66  * easier to spot...
     67  */
     68 
     69 struct uvm uvm;		/* decl */
     70 struct uvmexp uvmexp;	/* decl */
     71 
     72 UVMHIST_DECL(maphist);
     73 
     74 /*
     75  * local prototypes
     76  */
     77 
     78 /*
     79  * uvm_init: init the VM system.   called from kern/init_main.c.
     80  */
     81 
     82 void uvm_init()
     83 
     84 {
     85   vm_offset_t kvm_start, kvm_end;
     86 
     87   /*
     88    * step 0: ensure that the hardware set the page size
     89    */
     90 
     91   if (uvmexp.pagesize == 0) {
     92     panic("uvm_init: page size not set");
     93   }
     94 
     95   /*
     96    * step 1: zero the uvm structure
     97    */
     98 
     99   bzero(&uvm, sizeof(uvm));
    100   averunnable.fscale = FSCALE;
    101 
    102   /*
    103    * step 2: init the page sub-system.  this includes allocating the
    104    * vm_page structures, and setting up all the page queues (and
    105    * locks).  available memory will be put in the "free" queue.
    106    * kvm_start and kvm_end will be set to the area of kernel virtual
    107    * memory which is available for general use.
    108    */
    109 
    110   uvm_page_init(&kvm_start, &kvm_end);
    111 
    112   /*
    113    * step 3: init the map sub-system.  allocates the static pool of
    114    * vm_map_entry structures that are used for "special" kernel maps
    115    * (e.g. kernel_map, kmem_map, etc...).
    116    */
    117 
    118   uvm_map_init();
    119 
    120   /*
    121    * step 4: setup the kernel's virtual memory data structures.  this
    122    * includes setting up the kernel_map/kernel_object and the kmem_map/
    123    * kmem_object.
    124    */
    125 
    126   uvm_km_init(kvm_start, kvm_end);
    127 
    128   /*
    129    * step 5: init the pmap module.   the pmap module is free to allocate
    130    * memory for its private use (e.g. pvlists).
    131    */
    132 
    133   pmap_init();
    134 
    135   /*
    136    * step 6: init the kernel memory allocator.   after this call the
    137    * kernel memory allocator (malloc) can be used.
    138    */
    139 
    140   kmeminit();
    141 
    142   /*
    143    * step 7: init all pagers and the pager_map.
    144    */
    145 
    146   uvm_pager_init();
    147 
    148   /*
    149    * step 8: allocate anons (can add more as we add swap... later)
    150    */
    151 
    152   uvm_anon_init();
    153 
    154   /*
    155    * the VM system is now up!  now that malloc is up we can resize the
    156    * <obj,off> => <page> hash table for general use.
    157    */
    158 
    159   uvm_page_rehash();
    160 
    161   /*
    162    * done!
    163    */
    164 
    165   return;
    166 }
    167