14Srgrimes/*-
24Srgrimes * Copyright (c) 1990 The Regents of the University of California.
34Srgrimes * All rights reserved.
4974Sdg * Copyright (c) 1994 John S. Dyson
5974Sdg * All rights reserved.
64Srgrimes *
74Srgrimes * This code is derived from software contributed to Berkeley by
84Srgrimes * William Jolitz.
94Srgrimes *
104Srgrimes * Redistribution and use in source and binary forms, with or without
114Srgrimes * modification, are permitted provided that the following conditions
124Srgrimes * are met:
134Srgrimes * 1. Redistributions of source code must retain the above copyright
144Srgrimes *    notice, this list of conditions and the following disclaimer.
154Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
164Srgrimes *    notice, this list of conditions and the following disclaimer in the
174Srgrimes *    documentation and/or other materials provided with the distribution.
184Srgrimes * 4. Neither the name of the University nor the names of its contributors
194Srgrimes *    may be used to endorse or promote products derived from this software
204Srgrimes *    without specific prior written permission.
214Srgrimes *
224Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
234Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
244Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
254Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
264Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
274Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
284Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
294Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
304Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
314Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
324Srgrimes * SUCH DAMAGE.
334Srgrimes *
34607Srgrimes *	from: @(#)vmparam.h	5.9 (Berkeley) 5/12/91
3550477Speter * $FreeBSD: releng/10.3/sys/i386/include/vmparam.h 282065 2015-04-27 08:02:12Z kib $
364Srgrimes */
374Srgrimes
384Srgrimes
39719Swollman#ifndef _MACHINE_VMPARAM_H_
40719Swollman#define _MACHINE_VMPARAM_H_ 1
41719Swollman
424Srgrimes/*
434Srgrimes * Machine dependent constants for 386.
444Srgrimes */
454Srgrimes
464Srgrimes/*
474Srgrimes * Virtual memory related constants, all in bytes
484Srgrimes */
4936909Sdg#define	MAXTSIZ		(128UL*1024*1024)	/* max text size */
504Srgrimes#ifndef DFLDSIZ
5136909Sdg#define	DFLDSIZ		(128UL*1024*1024)	/* initial data size limit */
524Srgrimes#endif
534Srgrimes#ifndef MAXDSIZ
5430755Sjkh#define	MAXDSIZ		(512UL*1024*1024)	/* max data size */
554Srgrimes#endif
564Srgrimes#ifndef	DFLSSIZ
571288Sdg#define	DFLSSIZ		(8UL*1024*1024)		/* initial stack size limit */
584Srgrimes#endif
594Srgrimes#ifndef	MAXSSIZ
60926Sdg#define	MAXSSIZ		(64UL*1024*1024)	/* max stack size */
614Srgrimes#endif
621288Sdg#ifndef SGROWSIZ
631288Sdg#define SGROWSIZ	(128UL*1024)		/* amount to grow stack */
641288Sdg#endif
654Srgrimes
664Srgrimes/*
67276546Salc * Choose between DENSE and SPARSE based on whether lower execution time or
68276546Salc * lower kernel address space consumption is desired.  Under PAE, kernel
69276546Salc * address space is often in short supply.
70169291Salc */
71276546Salc#ifdef PAE
72276546Salc#define	VM_PHYSSEG_SPARSE
73276546Salc#else
74169291Salc#define	VM_PHYSSEG_DENSE
75276546Salc#endif
76169291Salc
77169291Salc/*
78170319Salc * The number of PHYSSEG entries must be one greater than the number
79170319Salc * of phys_avail entries because the phys_avail entry that spans the
80170319Salc * largest physical address that is accessible by ISA DMA is split
81170319Salc * into two PHYSSEG entries.
82170319Salc */
83170319Salc#define	VM_PHYSSEG_MAX		17
84170319Salc
85170319Salc/*
86172317Salc * Create two free page pools.  Since the i386 kernel virtual address
87170319Salc * space does not include a mapping onto the machine's entire physical
88170319Salc * memory, VM_FREEPOOL_DIRECT is defined as an alias for the default
89170319Salc * pool, VM_FREEPOOL_DEFAULT.
90170319Salc */
91172317Salc#define	VM_NFREEPOOL		2
92172317Salc#define	VM_FREEPOOL_CACHE	1
93170319Salc#define	VM_FREEPOOL_DEFAULT	0
94170319Salc#define	VM_FREEPOOL_DIRECT	0
95170319Salc
96170319Salc/*
97170319Salc * Create two free page lists: VM_FREELIST_DEFAULT is for physical
98170319Salc * pages that are above the largest physical address that is
99170319Salc * accessible by ISA DMA and VM_FREELIST_ISADMA is for physical pages
100170319Salc * that are below that address.
101170319Salc */
102170319Salc#define	VM_NFREELIST		2
103170319Salc#define	VM_FREELIST_DEFAULT	0
104170319Salc#define	VM_FREELIST_ISADMA	1
105170319Salc
106170319Salc/*
107170319Salc * The largest allocation size is 2MB under PAE and 4MB otherwise.
108170319Salc */
109170319Salc#ifdef PAE
110170319Salc#define	VM_NFREEORDER		10
111170319Salc#else
112170319Salc#define	VM_NFREEORDER		11
113170319Salc#endif
114170319Salc
115170319Salc/*
116177624Salc * Enable superpage reservations: 1 level.
117174938Salc */
118174938Salc#ifndef	VM_NRESERVLEVEL
119177624Salc#define	VM_NRESERVLEVEL		1
120174938Salc#endif
121174938Salc
122174938Salc/*
123282065Skib * Level 0 reservations consist of 512 pages when PAE pagetables are
124282065Skib * used, and 1024 pages otherwise.
125174938Salc */
126174938Salc#ifndef	VM_LEVEL_0_ORDER
127282065Skib#if defined(PAE) || defined(PAE_TABLES)
128174938Salc#define	VM_LEVEL_0_ORDER	9
129174938Salc#else
130174938Salc#define	VM_LEVEL_0_ORDER	10
131174938Salc#endif
132174938Salc#endif
133174938Salc
134174938Salc/*
135120654Speter * Kernel physical load address.
136120654Speter */
137120654Speter#ifndef KERNLOAD
138181775Skmacy#if defined(XEN) && !defined(XEN_PRIVILEGED_GUEST)
139181775Skmacy#define	KERNLOAD		0
140181775Skmacy#else
141120654Speter#define	KERNLOAD		(1 << PDRSHIFT)
142120654Speter#endif
143181775Skmacy#endif /* !defined(KERNLOAD) */
144120654Speter
145120654Speter/*
14615472Sphk * Virtual addresses of things.  Derived from the page directory and
14715472Sphk * page table indexes from pmap.h for precision.
14815472Sphk * Because of the page that is both a PD and PT, it looks a little
14915472Sphk * messy at times, but hey, we'll do anything to save a page :-)
1504Srgrimes */
1514Srgrimes
152181775Skmacy#ifdef XEN
153181775Skmacy#define VM_MAX_KERNEL_ADDRESS	HYPERVISOR_VIRT_START
154181775Skmacy#else
155113225Sjake#define VM_MAX_KERNEL_ADDRESS	VADDR(KPTDI+NKPDE-1, NPTEPG-1)
156181775Skmacy#endif
157181775Skmacy
15815472Sphk#define VM_MIN_KERNEL_ADDRESS	VADDR(PTDPTDI, PTDPTDI)
159974Sdg
16015472Sphk#define	KERNBASE		VADDR(KPTDI, 0)
16115472Sphk
16215472Sphk#define UPT_MAX_ADDRESS		VADDR(PTDPTDI, PTDPTDI)
16315472Sphk#define UPT_MIN_ADDRESS		VADDR(PTDPTDI, 0)
16415472Sphk
165111440Sjake#define VM_MAXUSER_ADDRESS	VADDR(PTDPTDI, 0)
16615472Sphk
167237435Skib#define	SHAREDPAGE		(VM_MAXUSER_ADDRESS - PAGE_SIZE)
168237435Skib#define	USRSTACK		SHAREDPAGE
16915472Sphk
17015472Sphk#define VM_MAX_ADDRESS		VADDR(PTDPTDI, PTDPTDI)
1714Srgrimes#define VM_MIN_ADDRESS		((vm_offset_t)0)
1724Srgrimes
17333757Sdyson/*
174266204Sian * How many physical pages per kmem arena virtual page.
17533757Sdyson */
17633757Sdyson#ifndef VM_KMEM_SIZE_SCALE
17733757Sdyson#define	VM_KMEM_SIZE_SCALE	(3)
17833757Sdyson#endif
17933757Sdyson
18033757Sdyson/*
181266204Sian * Optional floor (in bytes) on the size of the kmem arena.
18233757Sdyson */
183266204Sian#ifndef VM_KMEM_SIZE_MIN
184266204Sian#define	VM_KMEM_SIZE_MIN	(12 * 1024 * 1024)
185266204Sian#endif
186266204Sian
187266204Sian/*
188266204Sian * Optional ceiling (in bytes) on the size of the kmem arena: 40% of the
189266204Sian * kernel map rounded to the nearest multiple of the superpage size.
190266204Sian */
19133757Sdyson#ifndef VM_KMEM_SIZE_MAX
192228398Salc#define	VM_KMEM_SIZE_MAX	(((((VM_MAX_KERNEL_ADDRESS - \
193228398Salc    VM_MIN_KERNEL_ADDRESS) >> (PDRSHIFT - 2)) + 5) / 10) << PDRSHIFT)
19433757Sdyson#endif
19533757Sdyson
19633109Sdyson/* initial pagein size of beginning of executable file */
19733109Sdyson#ifndef VM_INITIAL_PAGEIN
19833109Sdyson#define	VM_INITIAL_PAGEIN	16
19933109Sdyson#endif
20033109Sdyson
201221855Smdf#define	ZERO_REGION_SIZE	(64 * 1024)	/* 64KB */
202221855Smdf
203242847Salfred#ifndef VM_MAX_AUTOTUNE_MAXUSERS
204242847Salfred#define VM_MAX_AUTOTUNE_MAXUSERS 384
205242847Salfred#endif
206242847Salfred
207719Swollman#endif /* _MACHINE_VMPARAM_H_ */
208