vmparam.h revision 282065
1131554Stjr/*-
2131554Stjr * Copyright (c) 1990 The Regents of the University of California.
3131554Stjr * All rights reserved.
4131554Stjr * Copyright (c) 1994 John S. Dyson
5131554Stjr * All rights reserved.
6131554Stjr *
7131554Stjr * This code is derived from software contributed to Berkeley by
8131554Stjr * William Jolitz.
9131554Stjr *
10131554Stjr * Redistribution and use in source and binary forms, with or without
11131554Stjr * modification, are permitted provided that the following conditions
12131554Stjr * are met:
13131554Stjr * 1. Redistributions of source code must retain the above copyright
14131554Stjr *    notice, this list of conditions and the following disclaimer.
15131554Stjr * 2. Redistributions in binary form must reproduce the above copyright
16131554Stjr *    notice, this list of conditions and the following disclaimer in the
17131554Stjr *    documentation and/or other materials provided with the distribution.
18131554Stjr * 4. Neither the name of the University nor the names of its contributors
19131554Stjr *    may be used to endorse or promote products derived from this software
20131554Stjr *    without specific prior written permission.
21131554Stjr *
22131554Stjr * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23131554Stjr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24131554Stjr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25131554Stjr * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26131554Stjr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27131554Stjr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28131554Stjr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29131554Stjr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30131554Stjr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31131554Stjr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32131554Stjr * SUCH DAMAGE.
33131554Stjr *
34131554Stjr *	from: @(#)vmparam.h	5.9 (Berkeley) 5/12/91
35131554Stjr * $FreeBSD: stable/10/sys/i386/include/vmparam.h 282065 2015-04-27 08:02:12Z kib $
36131554Stjr */
37131554Stjr
38131554Stjr
39131554Stjr#ifndef _MACHINE_VMPARAM_H_
40131554Stjr#define _MACHINE_VMPARAM_H_ 1
41131554Stjr
42131554Stjr/*
43131554Stjr * Machine dependent constants for 386.
44131554Stjr */
45131554Stjr
46131554Stjr/*
47131554Stjr * Virtual memory related constants, all in bytes
48131554Stjr */
49131554Stjr#define	MAXTSIZ		(128UL*1024*1024)	/* max text size */
50131554Stjr#ifndef DFLDSIZ
51131554Stjr#define	DFLDSIZ		(128UL*1024*1024)	/* initial data size limit */
52131554Stjr#endif
53131554Stjr#ifndef MAXDSIZ
54131554Stjr#define	MAXDSIZ		(512UL*1024*1024)	/* max data size */
55131554Stjr#endif
56131554Stjr#ifndef	DFLSSIZ
57131554Stjr#define	DFLSSIZ		(8UL*1024*1024)		/* initial stack size limit */
58131554Stjr#endif
59131554Stjr#ifndef	MAXSSIZ
60131554Stjr#define	MAXSSIZ		(64UL*1024*1024)	/* max stack size */
61131554Stjr#endif
62131554Stjr#ifndef SGROWSIZ
63131554Stjr#define SGROWSIZ	(128UL*1024)		/* amount to grow stack */
64131554Stjr#endif
65131554Stjr
66131554Stjr/*
67131554Stjr * Choose between DENSE and SPARSE based on whether lower execution time or
68131554Stjr * lower kernel address space consumption is desired.  Under PAE, kernel
69131554Stjr * address space is often in short supply.
70131554Stjr */
71131554Stjr#ifdef PAE
72131554Stjr#define	VM_PHYSSEG_SPARSE
73131554Stjr#else
74131554Stjr#define	VM_PHYSSEG_DENSE
75131554Stjr#endif
76131554Stjr
77131554Stjr/*
78131554Stjr * The number of PHYSSEG entries must be one greater than the number
79131554Stjr * of phys_avail entries because the phys_avail entry that spans the
80131554Stjr * largest physical address that is accessible by ISA DMA is split
81131554Stjr * into two PHYSSEG entries.
82131554Stjr */
83131554Stjr#define	VM_PHYSSEG_MAX		17
84131554Stjr
85131554Stjr/*
86131554Stjr * Create two free page pools.  Since the i386 kernel virtual address
87131554Stjr * space does not include a mapping onto the machine's entire physical
88131554Stjr * memory, VM_FREEPOOL_DIRECT is defined as an alias for the default
89131554Stjr * pool, VM_FREEPOOL_DEFAULT.
90131554Stjr */
91131554Stjr#define	VM_NFREEPOOL		2
92131554Stjr#define	VM_FREEPOOL_CACHE	1
93131554Stjr#define	VM_FREEPOOL_DEFAULT	0
94131554Stjr#define	VM_FREEPOOL_DIRECT	0
95131554Stjr
96131554Stjr/*
97131554Stjr * Create two free page lists: VM_FREELIST_DEFAULT is for physical
98131554Stjr * pages that are above the largest physical address that is
99131554Stjr * accessible by ISA DMA and VM_FREELIST_ISADMA is for physical pages
100131554Stjr * that are below that address.
101131554Stjr */
102131554Stjr#define	VM_NFREELIST		2
103131554Stjr#define	VM_FREELIST_DEFAULT	0
104131554Stjr#define	VM_FREELIST_ISADMA	1
105131554Stjr
106131554Stjr/*
107131554Stjr * The largest allocation size is 2MB under PAE and 4MB otherwise.
108131554Stjr */
109131554Stjr#ifdef PAE
110131554Stjr#define	VM_NFREEORDER		10
111131554Stjr#else
112131554Stjr#define	VM_NFREEORDER		11
113131554Stjr#endif
114131554Stjr
115131554Stjr/*
116131554Stjr * Enable superpage reservations: 1 level.
117131554Stjr */
118131554Stjr#ifndef	VM_NRESERVLEVEL
119131554Stjr#define	VM_NRESERVLEVEL		1
120131554Stjr#endif
121131554Stjr
122131554Stjr/*
123131554Stjr * Level 0 reservations consist of 512 pages when PAE pagetables are
124131554Stjr * used, and 1024 pages otherwise.
125131554Stjr */
126131554Stjr#ifndef	VM_LEVEL_0_ORDER
127131554Stjr#if defined(PAE) || defined(PAE_TABLES)
128131554Stjr#define	VM_LEVEL_0_ORDER	9
129131554Stjr#else
130131554Stjr#define	VM_LEVEL_0_ORDER	10
131131554Stjr#endif
132131554Stjr#endif
133131554Stjr
134131554Stjr/*
135131554Stjr * Kernel physical load address.
136131554Stjr */
137131554Stjr#ifndef KERNLOAD
138131554Stjr#if defined(XEN) && !defined(XEN_PRIVILEGED_GUEST)
139131554Stjr#define	KERNLOAD		0
140131554Stjr#else
141131554Stjr#define	KERNLOAD		(1 << PDRSHIFT)
142131554Stjr#endif
143131554Stjr#endif /* !defined(KERNLOAD) */
144131554Stjr
145131554Stjr/*
146131554Stjr * Virtual addresses of things.  Derived from the page directory and
147131554Stjr * page table indexes from pmap.h for precision.
148131554Stjr * Because of the page that is both a PD and PT, it looks a little
149131554Stjr * messy at times, but hey, we'll do anything to save a page :-)
150131554Stjr */
151131554Stjr
152131554Stjr#ifdef XEN
153131554Stjr#define VM_MAX_KERNEL_ADDRESS	HYPERVISOR_VIRT_START
154131554Stjr#else
155131554Stjr#define VM_MAX_KERNEL_ADDRESS	VADDR(KPTDI+NKPDE-1, NPTEPG-1)
156131554Stjr#endif
157131554Stjr
158131554Stjr#define VM_MIN_KERNEL_ADDRESS	VADDR(PTDPTDI, PTDPTDI)
159131554Stjr
160131554Stjr#define	KERNBASE		VADDR(KPTDI, 0)
161131554Stjr
162131554Stjr#define UPT_MAX_ADDRESS		VADDR(PTDPTDI, PTDPTDI)
163131554Stjr#define UPT_MIN_ADDRESS		VADDR(PTDPTDI, 0)
164131554Stjr
165131554Stjr#define VM_MAXUSER_ADDRESS	VADDR(PTDPTDI, 0)
166131554Stjr
167131554Stjr#define	SHAREDPAGE		(VM_MAXUSER_ADDRESS - PAGE_SIZE)
168131554Stjr#define	USRSTACK		SHAREDPAGE
169131554Stjr
170131554Stjr#define VM_MAX_ADDRESS		VADDR(PTDPTDI, PTDPTDI)
171131554Stjr#define VM_MIN_ADDRESS		((vm_offset_t)0)
172131554Stjr
173131554Stjr/*
174131554Stjr * How many physical pages per kmem arena virtual page.
175131554Stjr */
176131554Stjr#ifndef VM_KMEM_SIZE_SCALE
177131554Stjr#define	VM_KMEM_SIZE_SCALE	(3)
178131554Stjr#endif
179131554Stjr
180131554Stjr/*
181131554Stjr * Optional floor (in bytes) on the size of the kmem arena.
182131554Stjr */
183131554Stjr#ifndef VM_KMEM_SIZE_MIN
184131554Stjr#define	VM_KMEM_SIZE_MIN	(12 * 1024 * 1024)
185131554Stjr#endif
186131554Stjr
187131554Stjr/*
188131554Stjr * Optional ceiling (in bytes) on the size of the kmem arena: 40% of the
189131554Stjr * kernel map rounded to the nearest multiple of the superpage size.
190131554Stjr */
191131554Stjr#ifndef VM_KMEM_SIZE_MAX
192131554Stjr#define	VM_KMEM_SIZE_MAX	(((((VM_MAX_KERNEL_ADDRESS - \
193131554Stjr    VM_MIN_KERNEL_ADDRESS) >> (PDRSHIFT - 2)) + 5) / 10) << PDRSHIFT)
194131554Stjr#endif
195131554Stjr
196131554Stjr/* initial pagein size of beginning of executable file */
197131554Stjr#ifndef VM_INITIAL_PAGEIN
198131554Stjr#define	VM_INITIAL_PAGEIN	16
199131554Stjr#endif
200131554Stjr
201131554Stjr#define	ZERO_REGION_SIZE	(64 * 1024)	/* 64KB */
202131554Stjr
203131554Stjr#ifndef VM_MAX_AUTOTUNE_MAXUSERS
204131554Stjr#define VM_MAX_AUTOTUNE_MAXUSERS 384
205131554Stjr#endif
206131554Stjr
207131554Stjr#endif /* _MACHINE_VMPARAM_H_ */
208131554Stjr