xref: /freebsd/sys/vm/vm_init.c (revision 26f9a76710a312a951848542b9ca1f44100450e2)
126f9a767SRodney W. Grimes 
2df8bae1dSRodney W. Grimes /*
3df8bae1dSRodney W. Grimes  * Copyright (c) 1991, 1993
4df8bae1dSRodney W. Grimes  *	The Regents of the University of California.  All rights reserved.
5df8bae1dSRodney W. Grimes  *
6df8bae1dSRodney W. Grimes  * This code is derived from software contributed to Berkeley by
7df8bae1dSRodney W. Grimes  * The Mach Operating System project at Carnegie-Mellon University.
8df8bae1dSRodney W. Grimes  *
9df8bae1dSRodney W. Grimes  * Redistribution and use in source and binary forms, with or without
10df8bae1dSRodney W. Grimes  * modification, are permitted provided that the following conditions
11df8bae1dSRodney W. Grimes  * are met:
12df8bae1dSRodney W. Grimes  * 1. Redistributions of source code must retain the above copyright
13df8bae1dSRodney W. Grimes  *    notice, this list of conditions and the following disclaimer.
14df8bae1dSRodney W. Grimes  * 2. Redistributions in binary form must reproduce the above copyright
15df8bae1dSRodney W. Grimes  *    notice, this list of conditions and the following disclaimer in the
16df8bae1dSRodney W. Grimes  *    documentation and/or other materials provided with the distribution.
17df8bae1dSRodney W. Grimes  * 3. All advertising materials mentioning features or use of this software
18df8bae1dSRodney W. Grimes  *    must display the following acknowledgement:
19df8bae1dSRodney W. Grimes  *	This product includes software developed by the University of
20df8bae1dSRodney W. Grimes  *	California, Berkeley and its contributors.
21df8bae1dSRodney W. Grimes  * 4. Neither the name of the University nor the names of its contributors
22df8bae1dSRodney W. Grimes  *    may be used to endorse or promote products derived from this software
23df8bae1dSRodney W. Grimes  *    without specific prior written permission.
24df8bae1dSRodney W. Grimes  *
25df8bae1dSRodney W. Grimes  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26df8bae1dSRodney W. Grimes  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27df8bae1dSRodney W. Grimes  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28df8bae1dSRodney W. Grimes  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29df8bae1dSRodney W. Grimes  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30df8bae1dSRodney W. Grimes  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31df8bae1dSRodney W. Grimes  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32df8bae1dSRodney W. Grimes  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33df8bae1dSRodney W. Grimes  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34df8bae1dSRodney W. Grimes  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35df8bae1dSRodney W. Grimes  * SUCH DAMAGE.
36df8bae1dSRodney W. Grimes  *
37df8bae1dSRodney W. Grimes  *	@(#)vm_init.c	8.1 (Berkeley) 6/11/93
38df8bae1dSRodney W. Grimes  *
39df8bae1dSRodney W. Grimes  *
40df8bae1dSRodney W. Grimes  * Copyright (c) 1987, 1990 Carnegie-Mellon University.
41df8bae1dSRodney W. Grimes  * All rights reserved.
42df8bae1dSRodney W. Grimes  *
43df8bae1dSRodney W. Grimes  * Authors: Avadis Tevanian, Jr., Michael Wayne Young
44df8bae1dSRodney W. Grimes  *
45df8bae1dSRodney W. Grimes  * Permission to use, copy, modify and distribute this software and
46df8bae1dSRodney W. Grimes  * its documentation is hereby granted, provided that both the copyright
47df8bae1dSRodney W. Grimes  * notice and this permission notice appear in all copies of the
48df8bae1dSRodney W. Grimes  * software, derivative works or modified versions, and any portions
49df8bae1dSRodney W. Grimes  * thereof, and that both notices appear in supporting documentation.
50df8bae1dSRodney W. Grimes  *
51df8bae1dSRodney W. Grimes  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
52df8bae1dSRodney W. Grimes  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
53df8bae1dSRodney W. Grimes  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
54df8bae1dSRodney W. Grimes  *
55df8bae1dSRodney W. Grimes  * Carnegie Mellon requests users of this software to return to
56df8bae1dSRodney W. Grimes  *
57df8bae1dSRodney W. Grimes  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
58df8bae1dSRodney W. Grimes  *  School of Computer Science
59df8bae1dSRodney W. Grimes  *  Carnegie Mellon University
60df8bae1dSRodney W. Grimes  *  Pittsburgh PA 15213-3890
61df8bae1dSRodney W. Grimes  *
62df8bae1dSRodney W. Grimes  * any improvements or extensions that they make and grant Carnegie the
63df8bae1dSRodney W. Grimes  * rights to redistribute these changes.
64df8bae1dSRodney W. Grimes  */
65df8bae1dSRodney W. Grimes 
66df8bae1dSRodney W. Grimes /*
67df8bae1dSRodney W. Grimes  *	Initialize the Virtual Memory subsystem.
68df8bae1dSRodney W. Grimes  */
69df8bae1dSRodney W. Grimes 
70df8bae1dSRodney W. Grimes #include <sys/param.h>
71df8bae1dSRodney W. Grimes 
72df8bae1dSRodney W. Grimes #include <vm/vm.h>
73df8bae1dSRodney W. Grimes #include <vm/vm_page.h>
74df8bae1dSRodney W. Grimes #include <vm/vm_kern.h>
75df8bae1dSRodney W. Grimes 
76df8bae1dSRodney W. Grimes /*
77df8bae1dSRodney W. Grimes  *	vm_init initializes the virtual memory system.
78df8bae1dSRodney W. Grimes  *	This is done only by the first cpu up.
79df8bae1dSRodney W. Grimes  *
80df8bae1dSRodney W. Grimes  *	The start and end address of physical memory is passed in.
81df8bae1dSRodney W. Grimes  */
82df8bae1dSRodney W. Grimes 
8326f9a767SRodney W. Grimes void
8426f9a767SRodney W. Grimes vm_mem_init()
85df8bae1dSRodney W. Grimes {
86df8bae1dSRodney W. Grimes 	extern vm_offset_t	avail_start, avail_end;
87df8bae1dSRodney W. Grimes 	extern vm_offset_t	virtual_avail, virtual_end;
88df8bae1dSRodney W. Grimes 
89df8bae1dSRodney W. Grimes 	/*
90df8bae1dSRodney W. Grimes 	 *	Initializes resident memory structures.
91df8bae1dSRodney W. Grimes 	 *	From here on, all physical memory is accounted for,
92df8bae1dSRodney W. Grimes 	 *	and we use only virtual addresses.
93df8bae1dSRodney W. Grimes 	 */
94df8bae1dSRodney W. Grimes 
9526f9a767SRodney W. Grimes 	vm_set_page_size();
9626f9a767SRodney W. Grimes 	virtual_avail = vm_page_startup(avail_start, avail_end, virtual_avail);
97df8bae1dSRodney W. Grimes 	/*
98df8bae1dSRodney W. Grimes 	 * Initialize other VM packages
99df8bae1dSRodney W. Grimes 	 */
100df8bae1dSRodney W. Grimes 	vm_object_init(virtual_end - VM_MIN_KERNEL_ADDRESS);
101df8bae1dSRodney W. Grimes 	vm_map_startup();
102df8bae1dSRodney W. Grimes 	kmem_init(virtual_avail, virtual_end);
103df8bae1dSRodney W. Grimes 	pmap_init(avail_start, avail_end);
104df8bae1dSRodney W. Grimes 	vm_pager_init();
105df8bae1dSRodney W. Grimes }
106