xref: /minix3/sys/arch/i386/include/vmparam.h (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc /*	$NetBSD: vmparam.h,v 1.81 2014/07/24 13:42:28 riastradh 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 
4081473dbbSBen Gras #include <sys/tree.h>
4181473dbbSBen Gras #include <sys/mutex.h>
4281473dbbSBen 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 
5581473dbbSBen Gras /*
5681473dbbSBen Gras  * Virtual address space arrangement. On 386, both user and kernel
5781473dbbSBen Gras  * share the address space, not unlike the vax.
5881473dbbSBen Gras  * USRSTACK is the top (end) of the user stack. Immediately above the
5981473dbbSBen Gras  * user stack is the page table map, and then kernel address space.
6081473dbbSBen Gras  */
6181473dbbSBen Gras #define	USRSTACK	VM_MAXUSER_ADDRESS
6281473dbbSBen Gras 
6381473dbbSBen Gras /*
6481473dbbSBen Gras  * Virtual memory related constants, all in bytes
6581473dbbSBen Gras  */
6681473dbbSBen Gras #define	MAXTSIZ		(256*1024*1024)		/* max text size */
6781473dbbSBen Gras #ifndef DFLDSIZ
6881473dbbSBen Gras #define	DFLDSIZ		(256*1024*1024)		/* initial data size limit */
6981473dbbSBen Gras #endif
7081473dbbSBen Gras #ifndef MAXDSIZ
71*0a6a1f1dSLionel Sambuc #define	MAXDSIZ		(3U*1024*1024*1024)	/* 3G max data size */
72*0a6a1f1dSLionel Sambuc #endif
73*0a6a1f1dSLionel Sambuc #ifndef MAXDSIZ_BU
74*0a6a1f1dSLionel Sambuc #define	MAXDSIZ_BU	(2U*1024*1024*1024 +	/* 2.5G max data size for */ \
75*0a6a1f1dSLionel Sambuc 			 1U* 512*1024*1024)	/* bottom-up allocation */ \
76*0a6a1f1dSLionel Sambuc 						/* could be a bit more */
7781473dbbSBen Gras #endif
7881473dbbSBen Gras #ifndef	DFLSSIZ
7981473dbbSBen Gras #define	DFLSSIZ		(2*1024*1024)		/* initial stack size limit */
8081473dbbSBen Gras #endif
8181473dbbSBen Gras #ifndef	MAXSSIZ
8281473dbbSBen Gras #define	MAXSSIZ		(64*1024*1024)		/* max stack size */
8381473dbbSBen Gras #endif
8481473dbbSBen Gras 
8581473dbbSBen Gras /*
8681473dbbSBen Gras  * IA-32 can't do per-page execute permission, so instead we implement
8781473dbbSBen Gras  * two executable segments for %cs, one that covers everything and one
8881473dbbSBen Gras  * that excludes some of the address space (currently just the stack).
8981473dbbSBen Gras  * I386_MAX_EXE_ADDR is the upper boundary for the smaller segment.
9081473dbbSBen Gras  */
9181473dbbSBen Gras #define I386_MAX_EXE_ADDR	(USRSTACK - MAXSSIZ)
9281473dbbSBen Gras 
9381473dbbSBen Gras /*
9481473dbbSBen Gras  * Size of User Raw I/O map
9581473dbbSBen Gras  */
9681473dbbSBen Gras #define	USRIOSIZE 	300
9781473dbbSBen Gras 
9881473dbbSBen Gras /*
9981473dbbSBen Gras  * Mach derived constants
10081473dbbSBen Gras  */
10181473dbbSBen Gras 
10281473dbbSBen Gras /* user/kernel map constants */
10381473dbbSBen Gras #define VM_MIN_ADDRESS		((vaddr_t)0)
10481473dbbSBen Gras #define	VM_MAXUSER_ADDRESS	((vaddr_t)(PDIR_SLOT_PTE << L2_SHIFT))
10581473dbbSBen Gras #define	VM_MAX_ADDRESS		\
10681473dbbSBen Gras 	((vaddr_t)((PDIR_SLOT_PTE << L2_SHIFT) + (PDIR_SLOT_PTE << L1_SHIFT)))
10781473dbbSBen Gras #define	VM_MIN_KERNEL_ADDRESS	((vaddr_t)(PDIR_SLOT_KERN << L2_SHIFT))
10881473dbbSBen Gras #define	VM_MAX_KERNEL_ADDRESS	((vaddr_t)((PDIR_SLOT_KERN + NKL2_MAX_ENTRIES) << L2_SHIFT))
10981473dbbSBen Gras 
11081473dbbSBen Gras /*
11181473dbbSBen Gras  * The address to which unspecified mapping requests default
11281473dbbSBen Gras  */
11381473dbbSBen Gras #ifdef _KERNEL_OPT
11481473dbbSBen Gras #include "opt_uvm.h"
11581473dbbSBen Gras #include "opt_xen.h"
11681473dbbSBen Gras #endif
11781473dbbSBen Gras #define __USE_TOPDOWN_VM
118*0a6a1f1dSLionel Sambuc #define VM_DEFAULT_ADDRESS_TOPDOWN(da, sz) \
11981473dbbSBen Gras     trunc_page(USRSTACK - MAXSSIZ - (sz))
120*0a6a1f1dSLionel Sambuc #define VM_DEFAULT_ADDRESS_BOTTOMUP(da, sz) \
121*0a6a1f1dSLionel Sambuc     round_page((vaddr_t)(da) + (vsize_t)MIN(maxdmap, MAXDSIZ_BU))
12281473dbbSBen Gras 
12381473dbbSBen Gras /* XXX max. amount of KVM to be used by buffers. */
12481473dbbSBen Gras #ifndef VM_MAX_KERNEL_BUF
12581473dbbSBen Gras #define VM_MAX_KERNEL_BUF	(384 * 1024 * 1024)
12681473dbbSBen Gras #endif
12781473dbbSBen Gras 
12881473dbbSBen Gras /* virtual sizes (bytes) for various kernel submaps */
12981473dbbSBen Gras #define VM_PHYS_SIZE		(USRIOSIZE*PAGE_SIZE)
13081473dbbSBen Gras 
13181473dbbSBen Gras #define VM_PHYSSEG_STRAT	VM_PSTRAT_BIGFIRST
13281473dbbSBen Gras 
13381473dbbSBen Gras #ifdef XEN
13481473dbbSBen Gras #define	VM_PHYSSEG_MAX		1
13581473dbbSBen Gras #define	VM_NFREELIST		1
13681473dbbSBen Gras #else
13784d9c625SLionel Sambuc #define	VM_PHYSSEG_MAX		32	/* 1 "hole" + 31 free lists */
138*0a6a1f1dSLionel Sambuc #define	VM_NFREELIST		4
139*0a6a1f1dSLionel Sambuc #define	VM_FREELIST_FIRST16	3
140*0a6a1f1dSLionel Sambuc #define	VM_FREELIST_FIRST1G	2
141*0a6a1f1dSLionel Sambuc #define	VM_FREELIST_FIRST4G	1
14281473dbbSBen Gras #endif /* XEN */
14381473dbbSBen Gras #define	VM_FREELIST_DEFAULT	0
14481473dbbSBen Gras 
145f6aac1c3SLionel Sambuc #endif /* _I386_VMPARAM_H_ */
146