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