xref: /freebsd/sys/powerpc/include/vmparam.h (revision dc26651a96b77e7df1abdb29793b4103f2f200ba)
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 #ifndef LOCORE
41 #include <machine/md_var.h>
42 #endif
43 
44 #define	USRSTACK	SHAREDPAGE
45 
46 #ifndef	MAXTSIZ
47 #define	MAXTSIZ		(1*1024*1024*1024)		/* max text size */
48 #endif
49 
50 #ifndef	DFLDSIZ
51 #define	DFLDSIZ		(128*1024*1024)		/* default data size */
52 #endif
53 
54 #ifndef	MAXDSIZ
55 #ifdef __powerpc64__
56 #define	MAXDSIZ		(32UL*1024*1024*1024)	/* max data size */
57 #else
58 #define	MAXDSIZ		(1*1024*1024*1024)	/* max data size */
59 #endif
60 #endif
61 
62 #ifndef	DFLSSIZ
63 #define	DFLSSIZ		(8*1024*1024)		/* default stack size */
64 #endif
65 
66 #ifndef	MAXSSIZ
67 #ifdef __powerpc64__
68 #define	MAXSSIZ		(512*1024*1024)		/* max stack size */
69 #else
70 #define	MAXSSIZ		(64*1024*1024)		/* max stack size */
71 #endif
72 #endif
73 
74 #ifdef AIM
75 #define	VM_MAXUSER_ADDRESS32	((vm_offset_t)0xfffff000)
76 #else
77 #define	VM_MAXUSER_ADDRESS32	((vm_offset_t)0x7ffff000)
78 #endif
79 
80 /*
81  * Would like to have MAX addresses = 0, but this doesn't (currently) work
82  */
83 #if !defined(LOCORE)
84 #ifdef __powerpc64__
85 #define	VM_MIN_ADDRESS		(0x0000000000000000UL)
86 #define	VM_MAXUSER_ADDRESS	(0x3ffffffffffff000UL)
87 #define	VM_MAX_ADDRESS		(0xffffffffffffffffUL)
88 #else
89 #define	VM_MIN_ADDRESS		((vm_offset_t)0)
90 #define	VM_MAXUSER_ADDRESS	VM_MAXUSER_ADDRESS32
91 #define	VM_MAX_ADDRESS		((vm_offset_t)0xffffffff)
92 #endif
93 #define	SHAREDPAGE		(VM_MAXUSER_ADDRESS - PAGE_SIZE)
94 #else /* LOCORE */
95 #ifdef BOOKE
96 #define	VM_MIN_ADDRESS		0
97 #ifdef __powerpc64__
98 #define	VM_MAXUSER_ADDRESS	0x3ffffffffffff000
99 #else
100 #define	VM_MAXUSER_ADDRESS	0x7ffff000
101 #endif
102 #endif
103 #endif /* LOCORE */
104 
105 #define	FREEBSD32_SHAREDPAGE	(VM_MAXUSER_ADDRESS32 - PAGE_SIZE)
106 #define	FREEBSD32_USRSTACK	FREEBSD32_SHAREDPAGE
107 
108 #ifdef __powerpc64__
109 #ifndef LOCORE
110 #define	VM_MIN_KERNEL_ADDRESS		0xe000000000000000UL
111 #define	VM_MAX_KERNEL_ADDRESS		0xe0000007ffffffffUL
112 #else
113 #define	VM_MIN_KERNEL_ADDRESS		0xe000000000000000
114 #define	VM_MAX_KERNEL_ADDRESS		0xe0000007ffffffff
115 #endif
116 #define	VM_MAX_SAFE_KERNEL_ADDRESS	VM_MAX_KERNEL_ADDRESS
117 #endif
118 
119 #ifdef AIM
120 #define	KERNBASE		0x00100100	/* start of kernel virtual */
121 
122 #ifndef __powerpc64__
123 #define	VM_MIN_KERNEL_ADDRESS	((vm_offset_t)KERNEL_SR << ADDR_SR_SHFT)
124 #define	VM_MAX_SAFE_KERNEL_ADDRESS (VM_MIN_KERNEL_ADDRESS + 2*SEGMENT_LENGTH -1)
125 #define	VM_MAX_KERNEL_ADDRESS	(VM_MIN_KERNEL_ADDRESS + 3*SEGMENT_LENGTH - 1)
126 #endif
127 
128 /*
129  * Use the direct-mapped BAT registers for UMA small allocs. This
130  * takes pressure off the small amount of available KVA.
131  */
132 #define UMA_MD_SMALL_ALLOC
133 
134 #else /* Book-E */
135 
136 /* Use the direct map for UMA small allocs on powerpc64. */
137 #ifdef __powerpc64__
138 #define UMA_MD_SMALL_ALLOC
139 #endif
140 
141 #define	KERNBASE		0x04000100	/* start of kernel physical */
142 #ifndef __powerpc64__
143 #define	VM_MIN_KERNEL_ADDRESS	0xc0000000
144 #define	VM_MAX_KERNEL_ADDRESS	0xffffefff
145 #define	VM_MAX_SAFE_KERNEL_ADDRESS	VM_MAX_KERNEL_ADDRESS
146 #endif
147 
148 #endif /* AIM/E500 */
149 
150 #if !defined(LOCORE)
151 struct pmap_physseg {
152 	struct pv_entry *pvent;
153 	char *attrs;
154 };
155 #endif
156 
157 #define	VM_PHYSSEG_MAX		16
158 
159 #define	PHYS_AVAIL_SZ	256	/* Allows up to 16GB Ram on pSeries with
160 				 * logical memory block size of 64MB.
161 				 * For more Ram increase the lmb or this value.
162 				 */
163 
164 /* XXX This is non-sensical.  Phys avail should hold contiguous regions. */
165 #define	PHYS_AVAIL_ENTRIES	PHYS_AVAIL_SZ
166 
167 /*
168  * The physical address space is densely populated on 32-bit systems,
169  * but may not be on 64-bit ones.
170  */
171 #ifdef __powerpc64__
172 #define	VM_PHYSSEG_SPARSE
173 #else
174 #define	VM_PHYSSEG_DENSE
175 #endif
176 
177 /*
178  * Create two free page pools: VM_FREEPOOL_DEFAULT is the default pool
179  * from which physical pages are allocated and VM_FREEPOOL_DIRECT is
180  * the pool from which physical pages for small UMA objects are
181  * allocated.
182  */
183 #define	VM_NFREEPOOL		2
184 #define	VM_FREEPOOL_DEFAULT	0
185 #define	VM_FREEPOOL_DIRECT	1
186 
187 /*
188  * Create one free page list.
189  */
190 #define	VM_NFREELIST		1
191 #define	VM_FREELIST_DEFAULT	0
192 
193 /*
194  * The largest allocation size is 4MB.
195  */
196 #define	VM_NFREEORDER		11
197 
198 /*
199  * Disable superpage reservations.
200  */
201 #ifndef	VM_NRESERVLEVEL
202 #define	VM_NRESERVLEVEL		0
203 #endif
204 
205 #ifndef VM_INITIAL_PAGEIN
206 #define	VM_INITIAL_PAGEIN	16
207 #endif
208 
209 #ifndef SGROWSIZ
210 #define	SGROWSIZ	(128UL*1024)		/* amount to grow stack */
211 #endif
212 
213 /*
214  * How many physical pages per kmem arena virtual page.
215  */
216 #ifndef VM_KMEM_SIZE_SCALE
217 #define	VM_KMEM_SIZE_SCALE	(3)
218 #endif
219 
220 /*
221  * Optional floor (in bytes) on the size of the kmem arena.
222  */
223 #ifndef VM_KMEM_SIZE_MIN
224 #define	VM_KMEM_SIZE_MIN	(12 * 1024 * 1024)
225 #endif
226 
227 /*
228  * Optional ceiling (in bytes) on the size of the kmem arena: 40% of the
229  * usable KVA space.
230  */
231 #ifndef VM_KMEM_SIZE_MAX
232 #define VM_KMEM_SIZE_MAX	((VM_MAX_SAFE_KERNEL_ADDRESS - \
233     VM_MIN_KERNEL_ADDRESS + 1) * 2 / 5)
234 #endif
235 
236 #define	ZERO_REGION_SIZE	(64 * 1024)	/* 64KB */
237 
238 /*
239  * On 32-bit OEA, the only purpose for which sf_buf is used is to implement
240  * an opaque pointer required by the machine-independent parts of the kernel.
241  * That pointer references the vm_page that is "mapped" by the sf_buf.  The
242  * actual mapping is provided by the direct virtual-to-physical mapping.
243  *
244  * On OEA64 and Book-E, we need to do something a little more complicated. Use
245  * the runtime-detected hw_direct_map to pick between the two cases. Our
246  * friends in vm_machdep.c will do the same to ensure nothing gets confused.
247  */
248 #define	SFBUF
249 #define	SFBUF_NOMD
250 
251 /*
252  * We (usually) have a direct map of all physical memory, so provide
253  * a macro to use to get the kernel VA address for a given PA. Check the
254  * value of PMAP_HAS_PMAP before using.
255  */
256 #ifndef LOCORE
257 #ifdef __powerpc64__
258 #define	DMAP_BASE_ADDRESS	0xc000000000000000UL
259 #define	DMAP_MAX_ADDRESS	0xcfffffffffffffffUL
260 #else
261 #define	DMAP_BASE_ADDRESS	0x00000000UL
262 #define	DMAP_MAX_ADDRESS	0xbfffffffUL
263 #endif
264 #endif
265 
266 #define	PMAP_HAS_DMAP	(hw_direct_map)
267 #define PHYS_TO_DMAP(x) ({						\
268 	KASSERT(hw_direct_map, ("Direct map not provided by PMAP"));	\
269 	(x) | DMAP_BASE_ADDRESS; })
270 #define DMAP_TO_PHYS(x) ({						\
271 	KASSERT(hw_direct_map, ("Direct map not provided by PMAP"));	\
272 	(x) &~ DMAP_BASE_ADDRESS; })
273 
274 #endif /* _MACHINE_VMPARAM_H_ */
275