xref: /minix3/sys/arch/i386/include/vmparam.h (revision 81473dbba0a6059af2bda2995b8175c40428c2c2)
1*81473dbbSBen Gras /*	$NetBSD: vmparam.h,v 1.75 2012/08/15 08:10:28 sborrill Exp $	*/
2f6aac1c3SLionel Sambuc 
3f6aac1c3SLionel Sambuc /*-
4f6aac1c3SLionel Sambuc  * Copyright (c) 1990 The Regents of the University of California.
5f6aac1c3SLionel Sambuc  * All rights reserved.
6f6aac1c3SLionel Sambuc  *
7f6aac1c3SLionel Sambuc  * This code is derived from software contributed to Berkeley by
8f6aac1c3SLionel Sambuc  * William Jolitz.
9f6aac1c3SLionel Sambuc  *
10f6aac1c3SLionel Sambuc  * Redistribution and use in source and binary forms, with or without
11f6aac1c3SLionel Sambuc  * modification, are permitted provided that the following conditions
12f6aac1c3SLionel Sambuc  * are met:
13f6aac1c3SLionel Sambuc  * 1. Redistributions of source code must retain the above copyright
14f6aac1c3SLionel Sambuc  *    notice, this list of conditions and the following disclaimer.
15f6aac1c3SLionel Sambuc  * 2. Redistributions in binary form must reproduce the above copyright
16f6aac1c3SLionel Sambuc  *    notice, this list of conditions and the following disclaimer in the
17f6aac1c3SLionel Sambuc  *    documentation and/or other materials provided with the distribution.
18f6aac1c3SLionel Sambuc  * 3. Neither the name of the University nor the names of its contributors
19f6aac1c3SLionel Sambuc  *    may be used to endorse or promote products derived from this software
20f6aac1c3SLionel Sambuc  *    without specific prior written permission.
21f6aac1c3SLionel Sambuc  *
22f6aac1c3SLionel Sambuc  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23f6aac1c3SLionel Sambuc  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24f6aac1c3SLionel Sambuc  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25f6aac1c3SLionel Sambuc  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26f6aac1c3SLionel Sambuc  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27f6aac1c3SLionel Sambuc  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28f6aac1c3SLionel Sambuc  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29f6aac1c3SLionel Sambuc  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30f6aac1c3SLionel Sambuc  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31f6aac1c3SLionel Sambuc  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32f6aac1c3SLionel Sambuc  * SUCH DAMAGE.
33f6aac1c3SLionel Sambuc  *
34f6aac1c3SLionel Sambuc  *	@(#)vmparam.h	5.9 (Berkeley) 5/12/91
35f6aac1c3SLionel Sambuc  */
36f6aac1c3SLionel Sambuc 
37f6aac1c3SLionel Sambuc #ifndef _I386_VMPARAM_H_
38f6aac1c3SLionel Sambuc #define _I386_VMPARAM_H_
39f6aac1c3SLionel Sambuc 
40*81473dbbSBen Gras #include <sys/tree.h>
41*81473dbbSBen Gras #include <sys/mutex.h>
42*81473dbbSBen Gras 
43f6aac1c3SLionel Sambuc /*
44f6aac1c3SLionel Sambuc  * Machine dependent constants for 386.
45f6aac1c3SLionel Sambuc  */
46f6aac1c3SLionel Sambuc 
47f6aac1c3SLionel Sambuc /*
48f6aac1c3SLionel Sambuc  * Page size on the IA-32 is not variable in the traditional sense.
49f6aac1c3SLionel Sambuc  * We override the PAGE_* definitions to compile-time constants.
50f6aac1c3SLionel Sambuc  */
51f6aac1c3SLionel Sambuc #define	PAGE_SHIFT	12
52f6aac1c3SLionel Sambuc #define	PAGE_SIZE	(1 << PAGE_SHIFT)
53f6aac1c3SLionel Sambuc #define	PAGE_MASK	(PAGE_SIZE - 1)
54f6aac1c3SLionel Sambuc 
55*81473dbbSBen Gras /*
56*81473dbbSBen Gras  * Virtual address space arrangement. On 386, both user and kernel
57*81473dbbSBen Gras  * share the address space, not unlike the vax.
58*81473dbbSBen Gras  * USRSTACK is the top (end) of the user stack. Immediately above the
59*81473dbbSBen Gras  * user stack is the page table map, and then kernel address space.
60*81473dbbSBen Gras  */
61*81473dbbSBen Gras #define	USRSTACK	VM_MAXUSER_ADDRESS
62*81473dbbSBen Gras 
63*81473dbbSBen Gras /*
64*81473dbbSBen Gras  * Virtual memory related constants, all in bytes
65*81473dbbSBen Gras  */
66*81473dbbSBen Gras #define	MAXTSIZ		(256*1024*1024)		/* max text size */
67*81473dbbSBen Gras #ifndef DFLDSIZ
68*81473dbbSBen Gras #define	DFLDSIZ		(256*1024*1024)		/* initial data size limit */
69*81473dbbSBen Gras #endif
70*81473dbbSBen Gras #ifndef MAXDSIZ
71*81473dbbSBen Gras #define	MAXDSIZ		(3U*1024*1024*1024)	/* max data size */
72*81473dbbSBen Gras #endif
73*81473dbbSBen Gras #ifndef	DFLSSIZ
74*81473dbbSBen Gras #define	DFLSSIZ		(2*1024*1024)		/* initial stack size limit */
75*81473dbbSBen Gras #endif
76*81473dbbSBen Gras #ifndef	MAXSSIZ
77*81473dbbSBen Gras #define	MAXSSIZ		(64*1024*1024)		/* max stack size */
78*81473dbbSBen Gras #endif
79*81473dbbSBen Gras 
80*81473dbbSBen Gras /*
81*81473dbbSBen Gras  * IA-32 can't do per-page execute permission, so instead we implement
82*81473dbbSBen Gras  * two executable segments for %cs, one that covers everything and one
83*81473dbbSBen Gras  * that excludes some of the address space (currently just the stack).
84*81473dbbSBen Gras  * I386_MAX_EXE_ADDR is the upper boundary for the smaller segment.
85*81473dbbSBen Gras  */
86*81473dbbSBen Gras #define I386_MAX_EXE_ADDR	(USRSTACK - MAXSSIZ)
87*81473dbbSBen Gras 
88*81473dbbSBen Gras /*
89*81473dbbSBen Gras  * Size of User Raw I/O map
90*81473dbbSBen Gras  */
91*81473dbbSBen Gras #define	USRIOSIZE 	300
92*81473dbbSBen Gras 
93*81473dbbSBen Gras /*
94*81473dbbSBen Gras  * Mach derived constants
95*81473dbbSBen Gras  */
96*81473dbbSBen Gras 
97*81473dbbSBen Gras /* user/kernel map constants */
98*81473dbbSBen Gras #define VM_MIN_ADDRESS		((vaddr_t)0)
99*81473dbbSBen Gras #define	VM_MAXUSER_ADDRESS	((vaddr_t)(PDIR_SLOT_PTE << L2_SHIFT))
100*81473dbbSBen Gras #define	VM_MAX_ADDRESS		\
101*81473dbbSBen Gras 	((vaddr_t)((PDIR_SLOT_PTE << L2_SHIFT) + (PDIR_SLOT_PTE << L1_SHIFT)))
102*81473dbbSBen Gras #define	VM_MIN_KERNEL_ADDRESS	((vaddr_t)(PDIR_SLOT_KERN << L2_SHIFT))
103*81473dbbSBen Gras #define	VM_MAX_KERNEL_ADDRESS	((vaddr_t)((PDIR_SLOT_KERN + NKL2_MAX_ENTRIES) << L2_SHIFT))
104*81473dbbSBen Gras 
105*81473dbbSBen Gras /*
106*81473dbbSBen Gras  * The address to which unspecified mapping requests default
107*81473dbbSBen Gras  */
108*81473dbbSBen Gras #ifdef _KERNEL_OPT
109*81473dbbSBen Gras #include "opt_uvm.h"
110*81473dbbSBen Gras #include "opt_xen.h"
111*81473dbbSBen Gras #endif
112*81473dbbSBen Gras #define __USE_TOPDOWN_VM
113*81473dbbSBen Gras #define VM_DEFAULT_ADDRESS(da, sz) \
114*81473dbbSBen Gras 	trunc_page(USRSTACK - MAXSSIZ - (sz))
115*81473dbbSBen Gras 
116*81473dbbSBen Gras /* XXX max. amount of KVM to be used by buffers. */
117*81473dbbSBen Gras #ifndef VM_MAX_KERNEL_BUF
118*81473dbbSBen Gras #define VM_MAX_KERNEL_BUF	(384 * 1024 * 1024)
119*81473dbbSBen Gras #endif
120*81473dbbSBen Gras 
121*81473dbbSBen Gras /* virtual sizes (bytes) for various kernel submaps */
122*81473dbbSBen Gras #define VM_PHYS_SIZE		(USRIOSIZE*PAGE_SIZE)
123*81473dbbSBen Gras 
124*81473dbbSBen Gras #define VM_PHYSSEG_STRAT	VM_PSTRAT_BIGFIRST
125*81473dbbSBen Gras 
126*81473dbbSBen Gras #ifdef XEN
127*81473dbbSBen Gras #define	VM_PHYSSEG_MAX		1
128*81473dbbSBen Gras #define	VM_NFREELIST		1
129*81473dbbSBen Gras #else
130*81473dbbSBen Gras #define	VM_PHYSSEG_MAX		16	/* 1 "hole" + 15 free lists */
131*81473dbbSBen Gras #define	VM_NFREELIST		2
132*81473dbbSBen Gras #define	VM_FREELIST_FIRST16	1
133*81473dbbSBen Gras #endif /* XEN */
134*81473dbbSBen Gras #define	VM_FREELIST_DEFAULT	0
135*81473dbbSBen Gras 
136f6aac1c3SLionel Sambuc #endif /* _I386_VMPARAM_H_ */
137