xref: /freebsd/sys/powerpc/include/vmparam.h (revision 51369649b03ece2aed3eb61b0c8214b9aa5b2fa2)
1f9bac91bSBenno Rice /*-
2*51369649SPedro F. Giffuni  * SPDX-License-Identifier: BSD-4-Clause
3*51369649SPedro F. Giffuni  *
4f9bac91bSBenno Rice  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
5f9bac91bSBenno Rice  * Copyright (C) 1995, 1996 TooLs GmbH.
6f9bac91bSBenno Rice  * All rights reserved.
7f9bac91bSBenno Rice  *
8f9bac91bSBenno Rice  * Redistribution and use in source and binary forms, with or without
9f9bac91bSBenno Rice  * modification, are permitted provided that the following conditions
10f9bac91bSBenno Rice  * are met:
11f9bac91bSBenno Rice  * 1. Redistributions of source code must retain the above copyright
12f9bac91bSBenno Rice  *    notice, this list of conditions and the following disclaimer.
13f9bac91bSBenno Rice  * 2. Redistributions in binary form must reproduce the above copyright
14f9bac91bSBenno Rice  *    notice, this list of conditions and the following disclaimer in the
15f9bac91bSBenno Rice  *    documentation and/or other materials provided with the distribution.
16f9bac91bSBenno Rice  * 3. All advertising materials mentioning features or use of this software
17f9bac91bSBenno Rice  *    must display the following acknowledgement:
18f9bac91bSBenno Rice  *	This product includes software developed by TooLs GmbH.
19f9bac91bSBenno Rice  * 4. The name of TooLs GmbH may not be used to endorse or promote products
20f9bac91bSBenno Rice  *    derived from this software without specific prior written permission.
21f9bac91bSBenno Rice  *
22f9bac91bSBenno Rice  * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
23f9bac91bSBenno Rice  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24f9bac91bSBenno Rice  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25f9bac91bSBenno Rice  * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26f9bac91bSBenno Rice  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27f9bac91bSBenno Rice  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28f9bac91bSBenno Rice  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29f9bac91bSBenno Rice  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30f9bac91bSBenno Rice  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31f9bac91bSBenno Rice  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32f9bac91bSBenno Rice  *
33f9bac91bSBenno Rice  *	$NetBSD: vmparam.h,v 1.11 2000/02/11 19:25:16 thorpej Exp $
34f9bac91bSBenno Rice  * $FreeBSD$
35f9bac91bSBenno Rice  */
36f9bac91bSBenno Rice 
37f9bac91bSBenno Rice #ifndef _MACHINE_VMPARAM_H_
38f9bac91bSBenno Rice #define	_MACHINE_VMPARAM_H_
39f9bac91bSBenno Rice 
40640c77e1SKonstantin Belousov #define	USRSTACK	SHAREDPAGE
41f9bac91bSBenno Rice 
42f9bac91bSBenno Rice #ifndef	MAXTSIZ
43615df4c1SJustin Hibbits #define	MAXTSIZ		(1*1024*1024*1024)		/* max text size */
44f9bac91bSBenno Rice #endif
45f9bac91bSBenno Rice 
46f9bac91bSBenno Rice #ifndef	DFLDSIZ
4750b8e360SNathan Whitehorn #define	DFLDSIZ		(128*1024*1024)		/* default data size */
48f9bac91bSBenno Rice #endif
49f9bac91bSBenno Rice 
50f9bac91bSBenno Rice #ifndef	MAXDSIZ
5150b8e360SNathan Whitehorn #define	MAXDSIZ		(1*1024*1024*1024)	/* max data size */
52f9bac91bSBenno Rice #endif
53f9bac91bSBenno Rice 
54f9bac91bSBenno Rice #ifndef	DFLSSIZ
5550b8e360SNathan Whitehorn #define	DFLSSIZ		(8*1024*1024)		/* default stack size */
56f9bac91bSBenno Rice #endif
57f9bac91bSBenno Rice 
58f9bac91bSBenno Rice #ifndef	MAXSSIZ
5950b8e360SNathan Whitehorn #define	MAXSSIZ		(64*1024*1024)		/* max stack size */
60f9bac91bSBenno Rice #endif
61f9bac91bSBenno Rice 
629932a3feSNathan Whitehorn #ifdef AIM
639932a3feSNathan Whitehorn #define	VM_MAXUSER_ADDRESS32	((vm_offset_t)0xfffff000)
649932a3feSNathan Whitehorn #else
659932a3feSNathan Whitehorn #define	VM_MAXUSER_ADDRESS32	((vm_offset_t)0x7ffff000)
669932a3feSNathan Whitehorn #endif
679932a3feSNathan Whitehorn 
68f9bac91bSBenno Rice /*
69ffb56695SRafal Jaworowski  * Would like to have MAX addresses = 0, but this doesn't (currently) work
70ffb56695SRafal Jaworowski  */
71ffb56695SRafal Jaworowski #if !defined(LOCORE)
72c3e289e1SNathan Whitehorn #ifdef __powerpc64__
73c3e289e1SNathan Whitehorn #define	VM_MIN_ADDRESS		(0x0000000000000000UL)
74e683c328SJustin Hibbits #ifdef AIM
759932a3feSNathan Whitehorn #define	VM_MAXUSER_ADDRESS	(0xfffffffffffff000UL)
76e683c328SJustin Hibbits #else
77e683c328SJustin Hibbits #define	VM_MAXUSER_ADDRESS	(0x7ffffffffffff000UL)
78e683c328SJustin Hibbits #endif
79c3e289e1SNathan Whitehorn #define	VM_MAX_ADDRESS		(0xffffffffffffffffUL)
80ffb56695SRafal Jaworowski #else
81c3e289e1SNathan Whitehorn #define	VM_MIN_ADDRESS		((vm_offset_t)0)
829932a3feSNathan Whitehorn #define	VM_MAXUSER_ADDRESS	VM_MAXUSER_ADDRESS32
839932a3feSNathan Whitehorn #define	VM_MAX_ADDRESS		((vm_offset_t)0xffffffff)
84c3e289e1SNathan Whitehorn #endif
859932a3feSNathan Whitehorn #define	SHAREDPAGE		(VM_MAXUSER_ADDRESS - PAGE_SIZE)
86c3e289e1SNathan Whitehorn #else /* LOCORE */
87e683c328SJustin Hibbits #ifdef BOOKE
88ffb56695SRafal Jaworowski #define	VM_MIN_ADDRESS		0
89e683c328SJustin Hibbits #ifdef __powerpc64__
90e683c328SJustin Hibbits #define	VM_MAXUSER_ADDRESS	0x7ffffffffffff000
91e683c328SJustin Hibbits #else
92ffb56695SRafal Jaworowski #define	VM_MAXUSER_ADDRESS	0x7ffff000
93c3e289e1SNathan Whitehorn #endif
94e683c328SJustin Hibbits #endif
95ffb56695SRafal Jaworowski #endif /* LOCORE */
96ffb56695SRafal Jaworowski 
979932a3feSNathan Whitehorn #define	FREEBSD32_SHAREDPAGE	(VM_MAXUSER_ADDRESS32 - PAGE_SIZE)
98640c77e1SKonstantin Belousov #define	FREEBSD32_USRSTACK	FREEBSD32_SHAREDPAGE
99ffb56695SRafal Jaworowski 
100c3e289e1SNathan Whitehorn #ifdef __powerpc64__
101c3e289e1SNathan Whitehorn #define	VM_MIN_KERNEL_ADDRESS		0xc000000000000000UL
102c3e289e1SNathan Whitehorn #define	VM_MAX_KERNEL_ADDRESS		0xc0000001c7ffffffUL
103c3e289e1SNathan Whitehorn #define	VM_MAX_SAFE_KERNEL_ADDRESS	VM_MAX_KERNEL_ADDRESS
104e683c328SJustin Hibbits #endif
105e683c328SJustin Hibbits 
106e683c328SJustin Hibbits #ifdef AIM
107e683c328SJustin Hibbits #define	KERNBASE		0x00100000UL	/* start of kernel virtual */
108e683c328SJustin Hibbits 
109e683c328SJustin Hibbits #ifndef __powerpc64__
110c3e289e1SNathan Whitehorn #define	VM_MIN_KERNEL_ADDRESS	((vm_offset_t)KERNEL_SR << ADDR_SR_SHFT)
111ab739706SNathan Whitehorn #define	VM_MAX_SAFE_KERNEL_ADDRESS (VM_MIN_KERNEL_ADDRESS + 2*SEGMENT_LENGTH -1)
112ab739706SNathan Whitehorn #define	VM_MAX_KERNEL_ADDRESS	(VM_MIN_KERNEL_ADDRESS + 3*SEGMENT_LENGTH - 1)
113c3e289e1SNathan Whitehorn #endif
114ffb56695SRafal Jaworowski 
115ffb56695SRafal Jaworowski /*
116db55e39aSPeter Grehan  * Use the direct-mapped BAT registers for UMA small allocs. This
117db55e39aSPeter Grehan  * takes pressure off the small amount of available KVA.
118db55e39aSPeter Grehan  */
119db55e39aSPeter Grehan #define UMA_MD_SMALL_ALLOC
120db55e39aSPeter Grehan 
121c3e289e1SNathan Whitehorn #else /* Book-E */
122f9bac91bSBenno Rice 
123e683c328SJustin Hibbits #ifdef __powerpc64__
124e683c328SJustin Hibbits #ifndef LOCORE
125e683c328SJustin Hibbits #define	KERNBASE	0xc000000000000000UL	/* start of kernel virtual */
126e683c328SJustin Hibbits #else
127e683c328SJustin Hibbits #define	KERNBASE	0xc000000000000000	/* start of kernel virtual */
128e683c328SJustin Hibbits #endif
129e683c328SJustin Hibbits #else
130ffb56695SRafal Jaworowski #define	KERNBASE		0xc0000000	/* start of kernel virtual */
131ffb56695SRafal Jaworowski 
132ffb56695SRafal Jaworowski #define	VM_MIN_KERNEL_ADDRESS	KERNBASE
133009dedabSJustin Hibbits #define	VM_MAX_KERNEL_ADDRESS	0xffffefff
134a7bb5efaSNathan Whitehorn #define	VM_MAX_SAFE_KERNEL_ADDRESS	VM_MAX_KERNEL_ADDRESS
135e683c328SJustin Hibbits #endif
136ffb56695SRafal Jaworowski 
137ffb56695SRafal Jaworowski #endif /* AIM/E500 */
1387c277971SPeter Grehan 
139ffb56695SRafal Jaworowski #if !defined(LOCORE)
140f9bac91bSBenno Rice struct pmap_physseg {
141f9bac91bSBenno Rice 	struct pv_entry *pvent;
142f9bac91bSBenno Rice 	char *attrs;
143f9bac91bSBenno Rice };
144ffb56695SRafal Jaworowski #endif
145f9bac91bSBenno Rice 
146f9bac91bSBenno Rice #define	VM_PHYSSEG_MAX		16	/* 1? */
147f9bac91bSBenno Rice 
14804a18977SAlan Cox /*
1492bb4662eSNathan Whitehorn  * The physical address space is densely populated on 32-bit systems,
1502bb4662eSNathan Whitehorn  * but may not be on 64-bit ones.
15104a18977SAlan Cox  */
1526d4bd090SJustin Hibbits #ifdef __powerpc64__
1532bb4662eSNathan Whitehorn #define	VM_PHYSSEG_SPARSE
1542bb4662eSNathan Whitehorn #else
15504a18977SAlan Cox #define	VM_PHYSSEG_DENSE
1562bb4662eSNathan Whitehorn #endif
15704a18977SAlan Cox 
1582446e4f0SAlan Cox /*
159966272caSAlan Cox  * Create two free page pools: VM_FREEPOOL_DEFAULT is the default pool
1602446e4f0SAlan Cox  * from which physical pages are allocated and VM_FREEPOOL_DIRECT is
1612446e4f0SAlan Cox  * the pool from which physical pages for small UMA objects are
1622446e4f0SAlan Cox  * allocated.
1632446e4f0SAlan Cox  */
164966272caSAlan Cox #define	VM_NFREEPOOL		2
1652446e4f0SAlan Cox #define	VM_FREEPOOL_DEFAULT	0
1662446e4f0SAlan Cox #define	VM_FREEPOOL_DIRECT	1
1672446e4f0SAlan Cox 
1682446e4f0SAlan Cox /*
1692446e4f0SAlan Cox  * Create one free page list.
1702446e4f0SAlan Cox  */
171f9bac91bSBenno Rice #define	VM_NFREELIST		1
172f9bac91bSBenno Rice #define	VM_FREELIST_DEFAULT	0
173f9bac91bSBenno Rice 
1742446e4f0SAlan Cox /*
1752446e4f0SAlan Cox  * The largest allocation size is 4MB.
1762446e4f0SAlan Cox  */
1772446e4f0SAlan Cox #define	VM_NFREEORDER		11
1782446e4f0SAlan Cox 
179b8e7fc24SAlan Cox /*
180b8e7fc24SAlan Cox  * Disable superpage reservations.
181b8e7fc24SAlan Cox  */
182b8e7fc24SAlan Cox #ifndef	VM_NRESERVLEVEL
183b8e7fc24SAlan Cox #define	VM_NRESERVLEVEL		0
184b8e7fc24SAlan Cox #endif
185b8e7fc24SAlan Cox 
186f9bac91bSBenno Rice #ifndef VM_INITIAL_PAGEIN
187f9bac91bSBenno Rice #define	VM_INITIAL_PAGEIN	16
188f9bac91bSBenno Rice #endif
189f9bac91bSBenno Rice 
190f9bac91bSBenno Rice #ifndef SGROWSIZ
191f9bac91bSBenno Rice #define	SGROWSIZ	(128UL*1024)		/* amount to grow stack */
192f9bac91bSBenno Rice #endif
193f9bac91bSBenno Rice 
194a7bb5efaSNathan Whitehorn /*
195c70af487SAlan Cox  * How many physical pages per kmem arena virtual page.
196a7bb5efaSNathan Whitehorn  */
197c3e289e1SNathan Whitehorn #ifndef VM_KMEM_SIZE_SCALE
198c3e289e1SNathan Whitehorn #define	VM_KMEM_SIZE_SCALE	(3)
199c3e289e1SNathan Whitehorn #endif
200c3e289e1SNathan Whitehorn 
201a7bb5efaSNathan Whitehorn /*
202c70af487SAlan Cox  * Optional floor (in bytes) on the size of the kmem arena.
203c70af487SAlan Cox  */
204c70af487SAlan Cox #ifndef VM_KMEM_SIZE_MIN
205c70af487SAlan Cox #define	VM_KMEM_SIZE_MIN	(12 * 1024 * 1024)
206c70af487SAlan Cox #endif
207c70af487SAlan Cox 
208c70af487SAlan Cox /*
209c70af487SAlan Cox  * Optional ceiling (in bytes) on the size of the kmem arena: 40% of the
210c70af487SAlan Cox  * usable KVA space.
211a7bb5efaSNathan Whitehorn  */
212c3e289e1SNathan Whitehorn #ifndef VM_KMEM_SIZE_MAX
213a7bb5efaSNathan Whitehorn #define VM_KMEM_SIZE_MAX	((VM_MAX_SAFE_KERNEL_ADDRESS - \
214a7bb5efaSNathan Whitehorn     VM_MIN_KERNEL_ADDRESS + 1) * 2 / 5)
215c3e289e1SNathan Whitehorn #endif
216c3e289e1SNathan Whitehorn 
217cfb00e5aSMatthew D Fleming #define	ZERO_REGION_SIZE	(64 * 1024)	/* 64KB */
218cfb00e5aSMatthew D Fleming 
219c8d2ffd6SGleb Smirnoff /*
220c8d2ffd6SGleb Smirnoff  * On 32-bit OEA, the only purpose for which sf_buf is used is to implement
221c8d2ffd6SGleb Smirnoff  * an opaque pointer required by the machine-independent parts of the kernel.
222c8d2ffd6SGleb Smirnoff  * That pointer references the vm_page that is "mapped" by the sf_buf.  The
223c8d2ffd6SGleb Smirnoff  * actual mapping is provided by the direct virtual-to-physical mapping.
224c8d2ffd6SGleb Smirnoff  *
225c8d2ffd6SGleb Smirnoff  * On OEA64 and Book-E, we need to do something a little more complicated. Use
226c8d2ffd6SGleb Smirnoff  * the runtime-detected hw_direct_map to pick between the two cases. Our
227c8d2ffd6SGleb Smirnoff  * friends in vm_machdep.c will do the same to ensure nothing gets confused.
228c8d2ffd6SGleb Smirnoff  */
229c8d2ffd6SGleb Smirnoff #define	SFBUF
230c8d2ffd6SGleb Smirnoff #define	SFBUF_NOMD
231c8d2ffd6SGleb Smirnoff #define	SFBUF_OPTIONAL_DIRECT_MAP	hw_direct_map
23214fb2177SKonstantin Belousov #define	SFBUF_PHYS_DMAP(x)		(x)
233c8d2ffd6SGleb Smirnoff 
234f9bac91bSBenno Rice #endif /* _MACHINE_VMPARAM_H_ */
235