xref: /freebsd/sys/powerpc/include/vmparam.h (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
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  */
35 
36 #ifndef _MACHINE_VMPARAM_H_
37 #define	_MACHINE_VMPARAM_H_
38 
39 #ifndef LOCORE
40 #include <machine/md_var.h>
41 #endif
42 
43 #define	USRSTACK	SHAREDPAGE
44 
45 #ifndef	MAXTSIZ
46 #define	MAXTSIZ		(1*1024*1024*1024)		/* max text size */
47 #endif
48 
49 #ifndef	DFLDSIZ
50 #define	DFLDSIZ		(128*1024*1024)		/* default data size */
51 #endif
52 
53 #ifndef	MAXDSIZ
54 #ifdef __powerpc64__
55 #define	MAXDSIZ		(32UL*1024*1024*1024)	/* max data size */
56 #else
57 #define	MAXDSIZ		(1*1024*1024*1024)	/* max data size */
58 #endif
59 #endif
60 
61 #ifndef	DFLSSIZ
62 #define	DFLSSIZ		(8*1024*1024)		/* default stack size */
63 #endif
64 
65 #ifndef	MAXSSIZ
66 #ifdef __powerpc64__
67 #define	MAXSSIZ		(512*1024*1024)		/* max stack size */
68 #else
69 #define	MAXSSIZ		(64*1024*1024)		/* max stack size */
70 #endif
71 #endif
72 
73 #ifdef AIM
74 #define	VM_MAXUSER_ADDRESS32	0xfffff000
75 #else
76 #define	VM_MAXUSER_ADDRESS32	0x7ffff000
77 #endif
78 
79 /*
80  * Would like to have MAX addresses = 0, but this doesn't (currently) work
81  */
82 #ifdef __powerpc64__
83 /*
84  * Virtual addresses of things.  Derived from the page directory and
85  * page table indexes from pmap.h for precision.
86  *
87  * kernel map should be able to start at 0xc008000000000000 -
88  * but at least the functional simulator doesn't like it
89  *
90  * 0x0000000000000000 - 0x000fffffffffffff   user map
91  * 0xc000000000000000 - 0xc007ffffffffffff   direct map
92  * 0xc008000000000000 - 0xc00fffffffffffff   kernel map
93  *
94  */
95 #define	VM_MIN_ADDRESS		0x0000000000000000
96 #define	VM_MAXUSER_ADDRESS	0x000fffffc0000000
97 #define	VM_MAX_ADDRESS		0xc00fffffffffffff
98 #define	VM_MIN_KERNEL_ADDRESS	0xc008000000000000
99 #define	VM_MAX_KERNEL_ADDRESS	0xc0080007ffffffff
100 #define	VM_MAX_SAFE_KERNEL_ADDRESS	VM_MAX_KERNEL_ADDRESS
101 #else
102 #define	VM_MIN_ADDRESS		0
103 #define	VM_MAXUSER_ADDRESS	VM_MAXUSER_ADDRESS32
104 #define	VM_MAX_ADDRESS		0xffffffff
105 #endif
106 
107 #define	SHAREDPAGE		(VM_MAXUSER_ADDRESS - PAGE_SIZE)
108 
109 #define	FREEBSD32_SHAREDPAGE	(VM_MAXUSER_ADDRESS32 - PAGE_SIZE)
110 #define	FREEBSD32_USRSTACK	FREEBSD32_SHAREDPAGE
111 
112 #define	KERNBASE		0x00100100	/* start of kernel virtual */
113 
114 #ifdef AIM
115 #ifndef __powerpc64__
116 #define	VM_MIN_KERNEL_ADDRESS	((vm_offset_t)KERNEL_SR << ADDR_SR_SHFT)
117 #define	VM_MAX_SAFE_KERNEL_ADDRESS (VM_MIN_KERNEL_ADDRESS + 2*SEGMENT_LENGTH -1)
118 #define	VM_MAX_KERNEL_ADDRESS	(VM_MIN_KERNEL_ADDRESS + 3*SEGMENT_LENGTH - 1)
119 #endif
120 
121 /*
122  * Use the direct-mapped BAT registers for UMA small allocs. This
123  * takes pressure off the small amount of available KVA.
124  */
125 #define UMA_MD_SMALL_ALLOC
126 
127 #else /* Book-E */
128 
129 /* Use the direct map for UMA small allocs on powerpc64. */
130 #ifdef __powerpc64__
131 #define UMA_MD_SMALL_ALLOC
132 #else
133 #define	VM_MIN_KERNEL_ADDRESS		0xc0000000
134 #define	VM_MAX_KERNEL_ADDRESS		0xffffefff
135 #define	VM_MAX_SAFE_KERNEL_ADDRESS	VM_MAX_KERNEL_ADDRESS
136 #endif
137 
138 #endif /* AIM/E500 */
139 
140 #if !defined(LOCORE)
141 struct pmap_physseg {
142 	struct pv_entry *pvent;
143 	char *attrs;
144 };
145 #endif
146 
147 #ifdef __powerpc64__
148 #define	VM_PHYSSEG_MAX		63	/* 1? */
149 #else
150 #define	VM_PHYSSEG_MAX		16	/* 1? */
151 #endif
152 
153 #define	PHYS_AVAIL_SZ	256	/* Allows up to 16GB Ram on pSeries with
154 				 * logical memory block size of 64MB.
155 				 * For more Ram increase the lmb or this value.
156 				 */
157 
158 /* XXX This is non-sensical.  Phys avail should hold contiguous regions. */
159 #define	PHYS_AVAIL_ENTRIES	PHYS_AVAIL_SZ
160 
161 /*
162  * The physical address space is densely populated on 32-bit systems,
163  * but may not be on 64-bit ones.
164  */
165 #ifdef __powerpc64__
166 #define	VM_PHYSSEG_SPARSE
167 #else
168 #define	VM_PHYSSEG_DENSE
169 #endif
170 
171 /*
172  * Create two free page pools: VM_FREEPOOL_DEFAULT is the default pool
173  * from which physical pages are allocated and VM_FREEPOOL_DIRECT is
174  * the pool from which physical pages for small UMA objects are
175  * allocated.
176  */
177 #define	VM_NFREEPOOL		2
178 #define	VM_FREEPOOL_DEFAULT	0
179 #define	VM_FREEPOOL_DIRECT	1
180 
181 /*
182  * Create one free page list.
183  */
184 #define	VM_NFREELIST		1
185 #define	VM_FREELIST_DEFAULT	0
186 
187 #ifdef __powerpc64__
188 /* The largest allocation size is 16MB. */
189 #define	VM_NFREEORDER		13
190 #else
191 /* The largest allocation size is 4MB. */
192 #define	VM_NFREEORDER		11
193 #endif
194 
195 #ifndef	VM_NRESERVLEVEL
196 #ifdef __powerpc64__
197 /* Enable superpage reservations: 1 level. */
198 #define	VM_NRESERVLEVEL		1
199 #else
200 /* Disable superpage reservations. */
201 #define	VM_NRESERVLEVEL		0
202 #endif
203 #endif
204 
205 #ifndef	VM_LEVEL_0_ORDER
206 /* Level 0 reservations consist of 512 (RPT) or 4096 (HPT) pages. */
207 #define	VM_LEVEL_0_ORDER	vm_level_0_order
208 #ifndef	__ASSEMBLER__
209 extern	int vm_level_0_order;
210 #endif
211 #endif
212 
213 #ifndef	VM_LEVEL_0_ORDER_MAX
214 #define	VM_LEVEL_0_ORDER_MAX	12
215 #endif
216 
217 #ifdef __powerpc64__
218 #ifdef	SMP
219 #define	PA_LOCK_COUNT	256
220 #endif
221 #endif
222 
223 #ifndef VM_INITIAL_PAGEIN
224 #define	VM_INITIAL_PAGEIN	16
225 #endif
226 
227 #ifndef SGROWSIZ
228 #define	SGROWSIZ	(128UL*1024)		/* amount to grow stack */
229 #endif
230 
231 /*
232  * How many physical pages per kmem arena virtual page.
233  */
234 #ifndef VM_KMEM_SIZE_SCALE
235 #define	VM_KMEM_SIZE_SCALE	(3)
236 #endif
237 
238 /*
239  * Optional floor (in bytes) on the size of the kmem arena.
240  */
241 #ifndef VM_KMEM_SIZE_MIN
242 #define	VM_KMEM_SIZE_MIN	(12 * 1024 * 1024)
243 #endif
244 
245 /*
246  * Optional ceiling (in bytes) on the size of the kmem arena: 40% of the
247  * usable KVA space.
248  */
249 #ifndef VM_KMEM_SIZE_MAX
250 #define VM_KMEM_SIZE_MAX	((VM_MAX_SAFE_KERNEL_ADDRESS - \
251     VM_MIN_KERNEL_ADDRESS + 1) * 2 / 5)
252 #endif
253 
254 #ifdef __powerpc64__
255 #define	ZERO_REGION_SIZE	(2 * 1024 * 1024)	/* 2MB */
256 #else
257 #define	ZERO_REGION_SIZE	(64 * 1024)	/* 64KB */
258 #endif
259 
260 /*
261  * On 32-bit OEA, the only purpose for which sf_buf is used is to implement
262  * an opaque pointer required by the machine-independent parts of the kernel.
263  * That pointer references the vm_page that is "mapped" by the sf_buf.  The
264  * actual mapping is provided by the direct virtual-to-physical mapping.
265  *
266  * On OEA64 and Book-E, we need to do something a little more complicated. Use
267  * the runtime-detected hw_direct_map to pick between the two cases. Our
268  * friends in vm_machdep.c will do the same to ensure nothing gets confused.
269  */
270 #define	SFBUF
271 #define	SFBUF_NOMD
272 
273 /*
274  * We (usually) have a direct map of all physical memory, so provide
275  * a macro to use to get the kernel VA address for a given PA. Check the
276  * value of PMAP_HAS_PMAP before using.
277  */
278 #ifndef LOCORE
279 #ifdef __powerpc64__
280 #define	DMAP_BASE_ADDRESS	0xc000000000000000UL
281 #define	DMAP_MIN_ADDRESS	DMAP_BASE_ADDRESS
282 #define	DMAP_MAX_ADDRESS	0xc007ffffffffffffUL
283 #else
284 #define	DMAP_BASE_ADDRESS	0x00000000UL
285 #define	DMAP_MAX_ADDRESS	0xbfffffffUL
286 #endif
287 #endif
288 
289 #if defined(__powerpc64__) || defined(BOOKE)
290 /*
291  * powerpc64 and Book-E will provide their own page array allocators.
292  *
293  * On AIM, this will allocate a single virtual array, with pages from the
294  * correct memory domains.
295  * On Book-E this will let us put the array in TLB1, removing the need for TLB
296  * thrashing.
297  *
298  * VM_MIN_KERNEL_ADDRESS is just a dummy.  It will get set by the MMU driver.
299  */
300 #define	PA_MIN_ADDRESS		VM_MIN_KERNEL_ADDRESS
301 #define	PMAP_HAS_PAGE_ARRAY	1
302 #endif
303 
304 #if defined(__powerpc64__)
305 /*
306  * Need a page dump array for minidump.
307  */
308 #define MINIDUMP_PAGE_TRACKING	1
309 #else
310 /*
311  * No minidump with 32-bit powerpc.
312  */
313 #define MINIDUMP_PAGE_TRACKING	0
314 #endif
315 
316 #define	PMAP_HAS_DMAP	(hw_direct_map)
317 #define PHYS_TO_DMAP(x) ({						\
318 	KASSERT(hw_direct_map, ("Direct map not provided by PMAP"));	\
319 	(x) | DMAP_BASE_ADDRESS; })
320 #define DMAP_TO_PHYS(x) ({						\
321 	KASSERT(hw_direct_map, ("Direct map not provided by PMAP"));	\
322 	(x) &~ DMAP_BASE_ADDRESS; })
323 
324 /*
325  * No non-transparent large page support in the pmap.
326  */
327 #define	PMAP_HAS_LARGEPAGES	0
328 
329 #endif /* _MACHINE_VMPARAM_H_ */
330