vmparam.h revision 228398
1238405Sjkim/*-
2299389Sjkim * Copyright (c) 1990 The Regents of the University of California.
3299389Sjkim * All rights reserved.
4238405Sjkim * Copyright (c) 1994 John S. Dyson
5238405Sjkim * All rights reserved.
6238405Sjkim *
7238405Sjkim * This code is derived from software contributed to Berkeley by
8238405Sjkim * William Jolitz.
9238405Sjkim *
10238405Sjkim * Redistribution and use in source and binary forms, with or without
11238405Sjkim * modification, are permitted provided that the following conditions
12238405Sjkim * are met:
13238405Sjkim * 1. Redistributions of source code must retain the above copyright
14238405Sjkim *    notice, this list of conditions and the following disclaimer.
15238405Sjkim * 2. Redistributions in binary form must reproduce the above copyright
16238405Sjkim *    notice, this list of conditions and the following disclaimer in the
17238405Sjkim *    documentation and/or other materials provided with the distribution.
18238405Sjkim * 4. Neither the name of the University nor the names of its contributors
19238405Sjkim *    may be used to endorse or promote products derived from this software
20238405Sjkim *    without specific prior written permission.
21238405Sjkim *
22238405Sjkim * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23238405Sjkim * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24238405Sjkim * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25238405Sjkim * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26238405Sjkim * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27238405Sjkim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28238405Sjkim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29238405Sjkim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30238405Sjkim * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31238405Sjkim * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32238405Sjkim * SUCH DAMAGE.
33238405Sjkim *
34238405Sjkim *	from: @(#)vmparam.h	5.9 (Berkeley) 5/12/91
35238405Sjkim * $FreeBSD: head/sys/i386/include/vmparam.h 228398 2011-12-10 18:42:00Z alc $
36238405Sjkim */
37238405Sjkim
38238405Sjkim
39238405Sjkim#ifndef _MACHINE_VMPARAM_H_
40238405Sjkim#define _MACHINE_VMPARAM_H_ 1
41238405Sjkim
42238405Sjkim/*
43238405Sjkim * Machine dependent constants for 386.
44238405Sjkim */
45238405Sjkim
46238405Sjkim/*
47238405Sjkim * Virtual memory related constants, all in bytes
48238405Sjkim */
49238405Sjkim#define	MAXTSIZ		(128UL*1024*1024)	/* max text size */
50238405Sjkim#ifndef DFLDSIZ
51238405Sjkim#define	DFLDSIZ		(128UL*1024*1024)	/* initial data size limit */
52238405Sjkim#endif
53238405Sjkim#ifndef MAXDSIZ
54238405Sjkim#define	MAXDSIZ		(512UL*1024*1024)	/* max data size */
55238405Sjkim#endif
56238405Sjkim#ifndef	DFLSSIZ
57238405Sjkim#define	DFLSSIZ		(8UL*1024*1024)		/* initial stack size limit */
58238405Sjkim#endif
59238405Sjkim#ifndef	MAXSSIZ
60238405Sjkim#define	MAXSSIZ		(64UL*1024*1024)	/* max stack size */
61238405Sjkim#endif
62238405Sjkim#ifndef SGROWSIZ
63238405Sjkim#define SGROWSIZ	(128UL*1024)		/* amount to grow stack */
64238405Sjkim#endif
65238405Sjkim
66238405Sjkim/*
67238405Sjkim * The physical address space is densely populated.
68238405Sjkim */
69238405Sjkim#define	VM_PHYSSEG_DENSE
70238405Sjkim
71238405Sjkim/*
72238405Sjkim * The number of PHYSSEG entries must be one greater than the number
73238405Sjkim * of phys_avail entries because the phys_avail entry that spans the
74238405Sjkim * largest physical address that is accessible by ISA DMA is split
75238405Sjkim * into two PHYSSEG entries.
76238405Sjkim */
77238405Sjkim#define	VM_PHYSSEG_MAX		17
78290207Sjkim
79238405Sjkim/*
80238405Sjkim * Create two free page pools.  Since the i386 kernel virtual address
81238405Sjkim * space does not include a mapping onto the machine's entire physical
82238405Sjkim * memory, VM_FREEPOOL_DIRECT is defined as an alias for the default
83290207Sjkim * pool, VM_FREEPOOL_DEFAULT.
84238405Sjkim */
85290207Sjkim#define	VM_NFREEPOOL		2
86238405Sjkim#define	VM_FREEPOOL_CACHE	1
87290207Sjkim#define	VM_FREEPOOL_DEFAULT	0
88238405Sjkim#define	VM_FREEPOOL_DIRECT	0
89238405Sjkim
90238405Sjkim/*
91238405Sjkim * Create two free page lists: VM_FREELIST_DEFAULT is for physical
92290207Sjkim * pages that are above the largest physical address that is
93238405Sjkim * accessible by ISA DMA and VM_FREELIST_ISADMA is for physical pages
94290207Sjkim * that are below that address.
95238405Sjkim */
96290207Sjkim#define	VM_NFREELIST		2
97238405Sjkim#define	VM_FREELIST_DEFAULT	0
98290207Sjkim#define	VM_FREELIST_ISADMA	1
99238405Sjkim
100238405Sjkim/*
101290207Sjkim * The largest allocation size is 2MB under PAE and 4MB otherwise.
102238405Sjkim */
103290207Sjkim#ifdef PAE
104238405Sjkim#define	VM_NFREEORDER		10
105238405Sjkim#else
106238405Sjkim#define	VM_NFREEORDER		11
107238405Sjkim#endif
108238405Sjkim
109238405Sjkim/*
110238405Sjkim * Only one memory domain.
111238405Sjkim */
112238405Sjkim#ifndef VM_NDOMAIN
113290207Sjkim#define	VM_NDOMAIN		1
114238405Sjkim#endif
115238405Sjkim
116238405Sjkim/*
117290207Sjkim * Enable superpage reservations: 1 level.
118238405Sjkim */
119238405Sjkim#ifndef	VM_NRESERVLEVEL
120238405Sjkim#define	VM_NRESERVLEVEL		1
121238405Sjkim#endif
122290207Sjkim
123238405Sjkim/*
124238405Sjkim * Level 0 reservations consist of 512 pages under PAE and 1024 pages
125290207Sjkim * otherwise.
126238405Sjkim */
127238405Sjkim#ifndef	VM_LEVEL_0_ORDER
128290207Sjkim#ifdef PAE
129238405Sjkim#define	VM_LEVEL_0_ORDER	9
130238405Sjkim#else
131290207Sjkim#define	VM_LEVEL_0_ORDER	10
132238405Sjkim#endif
133290207Sjkim#endif
134238405Sjkim
135238405Sjkim/*
136238405Sjkim * Kernel physical load address.
137238405Sjkim */
138238405Sjkim#ifndef KERNLOAD
139238405Sjkim#if defined(XEN) && !defined(XEN_PRIVILEGED_GUEST)
140238405Sjkim#define	KERNLOAD		0
141238405Sjkim#else
142238405Sjkim#define	KERNLOAD		(1 << PDRSHIFT)
143238405Sjkim#endif
144238405Sjkim#endif /* !defined(KERNLOAD) */
145238405Sjkim
146238405Sjkim/*
147238405Sjkim * Virtual addresses of things.  Derived from the page directory and
148238405Sjkim * page table indexes from pmap.h for precision.
149238405Sjkim * Because of the page that is both a PD and PT, it looks a little
150290207Sjkim * messy at times, but hey, we'll do anything to save a page :-)
151238405Sjkim */
152238405Sjkim
153238405Sjkim#ifdef XEN
154238405Sjkim#define VM_MAX_KERNEL_ADDRESS	HYPERVISOR_VIRT_START
155238405Sjkim#else
156238405Sjkim#define VM_MAX_KERNEL_ADDRESS	VADDR(KPTDI+NKPDE-1, NPTEPG-1)
157238405Sjkim#endif
158238405Sjkim
159238405Sjkim#define VM_MIN_KERNEL_ADDRESS	VADDR(PTDPTDI, PTDPTDI)
160238405Sjkim
161238405Sjkim#define	KERNBASE		VADDR(KPTDI, 0)
162238405Sjkim
163238405Sjkim#define UPT_MAX_ADDRESS		VADDR(PTDPTDI, PTDPTDI)
164238405Sjkim#define UPT_MIN_ADDRESS		VADDR(PTDPTDI, 0)
165238405Sjkim
166238405Sjkim#define VM_MAXUSER_ADDRESS	VADDR(PTDPTDI, 0)
167238405Sjkim
168238405Sjkim#define USRSTACK		VM_MAXUSER_ADDRESS
169238405Sjkim
170238405Sjkim#define VM_MAX_ADDRESS		VADDR(PTDPTDI, PTDPTDI)
171238405Sjkim#define VM_MIN_ADDRESS		((vm_offset_t)0)
172238405Sjkim
173238405Sjkim/* virtual sizes (bytes) for various kernel submaps */
174290207Sjkim#ifndef VM_KMEM_SIZE
175238405Sjkim#define VM_KMEM_SIZE		(12 * 1024 * 1024)
176290207Sjkim#endif
177238405Sjkim
178238405Sjkim/*
179290207Sjkim * How many physical pages per KVA page allocated.
180290207Sjkim * min(max(max(VM_KMEM_SIZE, Physical memory/VM_KMEM_SIZE_SCALE),
181238405Sjkim *     VM_KMEM_SIZE_MIN), VM_KMEM_SIZE_MAX)
182290207Sjkim * is the total KVA space allocated for kmem_map.
183290207Sjkim */
184238405Sjkim#ifndef VM_KMEM_SIZE_SCALE
185238405Sjkim#define	VM_KMEM_SIZE_SCALE	(3)
186290207Sjkim#endif
187290207Sjkim
188238405Sjkim/*
189290207Sjkim * Ceiling on the amount of kmem_map KVA space: 40% of the entire KVA space
190290207Sjkim * rounded to the nearest multiple of the superpage size.
191238405Sjkim */
192238405Sjkim#ifndef VM_KMEM_SIZE_MAX
193290207Sjkim#define	VM_KMEM_SIZE_MAX	(((((VM_MAX_KERNEL_ADDRESS - \
194290207Sjkim    VM_MIN_KERNEL_ADDRESS) >> (PDRSHIFT - 2)) + 5) / 10) << PDRSHIFT)
195238405Sjkim#endif
196290207Sjkim
197290207Sjkim/* initial pagein size of beginning of executable file */
198238405Sjkim#ifndef VM_INITIAL_PAGEIN
199290207Sjkim#define	VM_INITIAL_PAGEIN	16
200238405Sjkim#endif
201290207Sjkim
202290207Sjkim#define	ZERO_REGION_SIZE	(64 * 1024)	/* 64KB */
203238405Sjkim
204238405Sjkim#endif /* _MACHINE_VMPARAM_H_ */
205290207Sjkim