xref: /freebsd/sys/i386/include/vmparam.h (revision c70af4875e5b239a302f2d34d73d6acac2ddd5a9)
15b81b6b3SRodney W. Grimes /*-
25b81b6b3SRodney W. Grimes  * Copyright (c) 1990 The Regents of the University of California.
35b81b6b3SRodney W. Grimes  * All rights reserved.
47f8cb368SDavid Greenman  * Copyright (c) 1994 John S. Dyson
57f8cb368SDavid Greenman  * All rights reserved.
65b81b6b3SRodney W. Grimes  *
75b81b6b3SRodney W. Grimes  * This code is derived from software contributed to Berkeley by
85b81b6b3SRodney W. Grimes  * William Jolitz.
95b81b6b3SRodney W. Grimes  *
105b81b6b3SRodney W. Grimes  * Redistribution and use in source and binary forms, with or without
115b81b6b3SRodney W. Grimes  * modification, are permitted provided that the following conditions
125b81b6b3SRodney W. Grimes  * are met:
135b81b6b3SRodney W. Grimes  * 1. Redistributions of source code must retain the above copyright
145b81b6b3SRodney W. Grimes  *    notice, this list of conditions and the following disclaimer.
155b81b6b3SRodney W. Grimes  * 2. Redistributions in binary form must reproduce the above copyright
165b81b6b3SRodney W. Grimes  *    notice, this list of conditions and the following disclaimer in the
175b81b6b3SRodney W. Grimes  *    documentation and/or other materials provided with the distribution.
185b81b6b3SRodney W. Grimes  * 4. Neither the name of the University nor the names of its contributors
195b81b6b3SRodney W. Grimes  *    may be used to endorse or promote products derived from this software
205b81b6b3SRodney W. Grimes  *    without specific prior written permission.
215b81b6b3SRodney W. Grimes  *
225b81b6b3SRodney W. Grimes  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
235b81b6b3SRodney W. Grimes  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
245b81b6b3SRodney W. Grimes  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
255b81b6b3SRodney W. Grimes  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
265b81b6b3SRodney W. Grimes  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
275b81b6b3SRodney W. Grimes  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
285b81b6b3SRodney W. Grimes  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
295b81b6b3SRodney W. Grimes  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
305b81b6b3SRodney W. Grimes  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
315b81b6b3SRodney W. Grimes  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
325b81b6b3SRodney W. Grimes  * SUCH DAMAGE.
335b81b6b3SRodney W. Grimes  *
34d42d25c4SRodney W. Grimes  *	from: @(#)vmparam.h	5.9 (Berkeley) 5/12/91
35c3aac50fSPeter Wemm  * $FreeBSD$
365b81b6b3SRodney W. Grimes  */
375b81b6b3SRodney W. Grimes 
385b81b6b3SRodney W. Grimes 
396e393973SGarrett Wollman #ifndef _MACHINE_VMPARAM_H_
406e393973SGarrett Wollman #define _MACHINE_VMPARAM_H_ 1
416e393973SGarrett Wollman 
425b81b6b3SRodney W. Grimes /*
435b81b6b3SRodney W. Grimes  * Machine dependent constants for 386.
445b81b6b3SRodney W. Grimes  */
455b81b6b3SRodney W. Grimes 
465b81b6b3SRodney W. Grimes /*
475b81b6b3SRodney W. Grimes  * Virtual memory related constants, all in bytes
485b81b6b3SRodney W. Grimes  */
49f4fabec6SDavid Greenman #define	MAXTSIZ		(128UL*1024*1024)	/* max text size */
505b81b6b3SRodney W. Grimes #ifndef DFLDSIZ
51f4fabec6SDavid Greenman #define	DFLDSIZ		(128UL*1024*1024)	/* initial data size limit */
525b81b6b3SRodney W. Grimes #endif
535b81b6b3SRodney W. Grimes #ifndef MAXDSIZ
547416845fSJordan K. Hubbard #define	MAXDSIZ		(512UL*1024*1024)	/* max data size */
555b81b6b3SRodney W. Grimes #endif
565b81b6b3SRodney W. Grimes #ifndef	DFLSSIZ
5729360eb0SDavid Greenman #define	DFLSSIZ		(8UL*1024*1024)		/* initial stack size limit */
585b81b6b3SRodney W. Grimes #endif
595b81b6b3SRodney W. Grimes #ifndef	MAXSSIZ
60e10a6186SDavid Greenman #define	MAXSSIZ		(64UL*1024*1024)	/* max stack size */
615b81b6b3SRodney W. Grimes #endif
6229360eb0SDavid Greenman #ifndef SGROWSIZ
6329360eb0SDavid Greenman #define SGROWSIZ	(128UL*1024)		/* amount to grow stack */
6429360eb0SDavid Greenman #endif
655b81b6b3SRodney W. Grimes 
665b81b6b3SRodney W. Grimes /*
6704a18977SAlan Cox  * The physical address space is densely populated.
6804a18977SAlan Cox  */
6904a18977SAlan Cox #define	VM_PHYSSEG_DENSE
7004a18977SAlan Cox 
7104a18977SAlan Cox /*
72e5c45405SAlan Cox  * The number of PHYSSEG entries must be one greater than the number
73e5c45405SAlan Cox  * of phys_avail entries because the phys_avail entry that spans the
74e5c45405SAlan Cox  * largest physical address that is accessible by ISA DMA is split
75e5c45405SAlan Cox  * into two PHYSSEG entries.
76e5c45405SAlan Cox  */
77e5c45405SAlan Cox #define	VM_PHYSSEG_MAX		17
78e5c45405SAlan Cox 
79e5c45405SAlan Cox /*
807bfda801SAlan Cox  * Create two free page pools.  Since the i386 kernel virtual address
81e5c45405SAlan Cox  * space does not include a mapping onto the machine's entire physical
82e5c45405SAlan Cox  * memory, VM_FREEPOOL_DIRECT is defined as an alias for the default
83e5c45405SAlan Cox  * pool, VM_FREEPOOL_DEFAULT.
84e5c45405SAlan Cox  */
857bfda801SAlan Cox #define	VM_NFREEPOOL		2
867bfda801SAlan Cox #define	VM_FREEPOOL_CACHE	1
87e5c45405SAlan Cox #define	VM_FREEPOOL_DEFAULT	0
88e5c45405SAlan Cox #define	VM_FREEPOOL_DIRECT	0
89e5c45405SAlan Cox 
90e5c45405SAlan Cox /*
91e5c45405SAlan Cox  * Create two free page lists: VM_FREELIST_DEFAULT is for physical
92e5c45405SAlan Cox  * pages that are above the largest physical address that is
93e5c45405SAlan Cox  * accessible by ISA DMA and VM_FREELIST_ISADMA is for physical pages
94e5c45405SAlan Cox  * that are below that address.
95e5c45405SAlan Cox  */
96e5c45405SAlan Cox #define	VM_NFREELIST		2
97e5c45405SAlan Cox #define	VM_FREELIST_DEFAULT	0
98e5c45405SAlan Cox #define	VM_FREELIST_ISADMA	1
99e5c45405SAlan Cox 
100e5c45405SAlan Cox /*
101e5c45405SAlan Cox  * The largest allocation size is 2MB under PAE and 4MB otherwise.
102e5c45405SAlan Cox  */
103e5c45405SAlan Cox #ifdef PAE
104e5c45405SAlan Cox #define	VM_NFREEORDER		10
105e5c45405SAlan Cox #else
106e5c45405SAlan Cox #define	VM_NFREEORDER		11
107e5c45405SAlan Cox #endif
108e5c45405SAlan Cox 
109e5c45405SAlan Cox /*
110fdcd29b5SAlan Cox  * Enable superpage reservations: 1 level.
111b8e7fc24SAlan Cox  */
112b8e7fc24SAlan Cox #ifndef	VM_NRESERVLEVEL
113fdcd29b5SAlan Cox #define	VM_NRESERVLEVEL		1
114b8e7fc24SAlan Cox #endif
115b8e7fc24SAlan Cox 
116b8e7fc24SAlan Cox /*
117b8e7fc24SAlan Cox  * Level 0 reservations consist of 512 pages under PAE and 1024 pages
118b8e7fc24SAlan Cox  * otherwise.
119b8e7fc24SAlan Cox  */
120b8e7fc24SAlan Cox #ifndef	VM_LEVEL_0_ORDER
121b8e7fc24SAlan Cox #ifdef PAE
122b8e7fc24SAlan Cox #define	VM_LEVEL_0_ORDER	9
123b8e7fc24SAlan Cox #else
124b8e7fc24SAlan Cox #define	VM_LEVEL_0_ORDER	10
125b8e7fc24SAlan Cox #endif
126b8e7fc24SAlan Cox #endif
127b8e7fc24SAlan Cox 
128b8e7fc24SAlan Cox /*
1296ccf265bSPeter Wemm  * Kernel physical load address.
1306ccf265bSPeter Wemm  */
1316ccf265bSPeter Wemm #ifndef KERNLOAD
13293ee134aSKip Macy #if defined(XEN) && !defined(XEN_PRIVILEGED_GUEST)
13393ee134aSKip Macy #define	KERNLOAD		0
13493ee134aSKip Macy #else
1356ccf265bSPeter Wemm #define	KERNLOAD		(1 << PDRSHIFT)
1366ccf265bSPeter Wemm #endif
13793ee134aSKip Macy #endif /* !defined(KERNLOAD) */
1386ccf265bSPeter Wemm 
1396ccf265bSPeter Wemm /*
14068c1eb12SPoul-Henning Kamp  * Virtual addresses of things.  Derived from the page directory and
14168c1eb12SPoul-Henning Kamp  * page table indexes from pmap.h for precision.
14268c1eb12SPoul-Henning Kamp  * Because of the page that is both a PD and PT, it looks a little
14368c1eb12SPoul-Henning Kamp  * messy at times, but hey, we'll do anything to save a page :-)
1445b81b6b3SRodney W. Grimes  */
1455b81b6b3SRodney W. Grimes 
14693ee134aSKip Macy #ifdef XEN
14793ee134aSKip Macy #define VM_MAX_KERNEL_ADDRESS	HYPERVISOR_VIRT_START
14893ee134aSKip Macy #else
14946ea68ddSJake Burkholder #define VM_MAX_KERNEL_ADDRESS	VADDR(KPTDI+NKPDE-1, NPTEPG-1)
15093ee134aSKip Macy #endif
15193ee134aSKip Macy 
15268c1eb12SPoul-Henning Kamp #define VM_MIN_KERNEL_ADDRESS	VADDR(PTDPTDI, PTDPTDI)
1537f8cb368SDavid Greenman 
15468c1eb12SPoul-Henning Kamp #define	KERNBASE		VADDR(KPTDI, 0)
15568c1eb12SPoul-Henning Kamp 
15668c1eb12SPoul-Henning Kamp #define UPT_MAX_ADDRESS		VADDR(PTDPTDI, PTDPTDI)
15768c1eb12SPoul-Henning Kamp #define UPT_MIN_ADDRESS		VADDR(PTDPTDI, 0)
15868c1eb12SPoul-Henning Kamp 
1595cd612b2SJake Burkholder #define VM_MAXUSER_ADDRESS	VADDR(PTDPTDI, 0)
16068c1eb12SPoul-Henning Kamp 
161d69ae412SKonstantin Belousov #define	SHAREDPAGE		(VM_MAXUSER_ADDRESS - PAGE_SIZE)
162d69ae412SKonstantin Belousov #define	USRSTACK		SHAREDPAGE
16368c1eb12SPoul-Henning Kamp 
16468c1eb12SPoul-Henning Kamp #define VM_MAX_ADDRESS		VADDR(PTDPTDI, PTDPTDI)
16568c1eb12SPoul-Henning Kamp #define VM_MIN_ADDRESS		((vm_offset_t)0)
1665b81b6b3SRodney W. Grimes 
167d9bed5beSJohn Dyson /*
168*c70af487SAlan Cox  * How many physical pages per kmem arena virtual page.
169d9bed5beSJohn Dyson  */
170d9bed5beSJohn Dyson #ifndef VM_KMEM_SIZE_SCALE
171d9bed5beSJohn Dyson #define	VM_KMEM_SIZE_SCALE	(3)
172d9bed5beSJohn Dyson #endif
173d9bed5beSJohn Dyson 
174d9bed5beSJohn Dyson /*
175*c70af487SAlan Cox  * Optional floor (in bytes) on the size of the kmem arena.
176*c70af487SAlan Cox  */
177*c70af487SAlan Cox #ifndef VM_KMEM_SIZE_MIN
178*c70af487SAlan Cox #define	VM_KMEM_SIZE_MIN	(12 * 1024 * 1024)
179*c70af487SAlan Cox #endif
180*c70af487SAlan Cox 
181*c70af487SAlan Cox /*
182*c70af487SAlan Cox  * Optional ceiling (in bytes) on the size of the kmem arena: 40% of the
183*c70af487SAlan Cox  * kernel map rounded to the nearest multiple of the superpage size.
184d9bed5beSJohn Dyson  */
185d9bed5beSJohn Dyson #ifndef VM_KMEM_SIZE_MAX
186c5ecbfb4SAlan Cox #define	VM_KMEM_SIZE_MAX	(((((VM_MAX_KERNEL_ADDRESS - \
187c5ecbfb4SAlan Cox     VM_MIN_KERNEL_ADDRESS) >> (PDRSHIFT - 2)) + 5) / 10) << PDRSHIFT)
1887bcc0f3dSTor Egge #endif
1895b81b6b3SRodney W. Grimes 
19095461b45SJohn Dyson /* initial pagein size of beginning of executable file */
19195461b45SJohn Dyson #ifndef VM_INITIAL_PAGEIN
19295461b45SJohn Dyson #define	VM_INITIAL_PAGEIN	16
19395461b45SJohn Dyson #endif
19495461b45SJohn Dyson 
195cfb00e5aSMatthew D Fleming #define	ZERO_REGION_SIZE	(64 * 1024)	/* 64KB */
196cfb00e5aSMatthew D Fleming 
19779f62ed6SAlfred Perlstein #ifndef VM_MAX_AUTOTUNE_MAXUSERS
19879f62ed6SAlfred Perlstein #define VM_MAX_AUTOTUNE_MAXUSERS 384
19979f62ed6SAlfred Perlstein #endif
20079f62ed6SAlfred Perlstein 
2016e393973SGarrett Wollman #endif /* _MACHINE_VMPARAM_H_ */
202