xref: /freebsd/sys/powerpc/include/vmparam.h (revision b37f6c9805edb4b89f0a8c2b78f78a3dcfc0647b)
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 #ifdef AIM
87 #define	VM_MAXUSER_ADDRESS	(0xfffffffffffff000UL)
88 #else
89 #define	VM_MAXUSER_ADDRESS	(0x7ffffffffffff000UL)
90 #endif
91 #define	VM_MAX_ADDRESS		(0xffffffffffffffffUL)
92 #else
93 #define	VM_MIN_ADDRESS		((vm_offset_t)0)
94 #define	VM_MAXUSER_ADDRESS	VM_MAXUSER_ADDRESS32
95 #define	VM_MAX_ADDRESS		((vm_offset_t)0xffffffff)
96 #endif
97 #define	SHAREDPAGE		(VM_MAXUSER_ADDRESS - PAGE_SIZE)
98 #else /* LOCORE */
99 #ifdef BOOKE
100 #define	VM_MIN_ADDRESS		0
101 #ifdef __powerpc64__
102 #define	VM_MAXUSER_ADDRESS	0x7ffffffffffff000
103 #else
104 #define	VM_MAXUSER_ADDRESS	0x7ffff000
105 #endif
106 #endif
107 #endif /* LOCORE */
108 
109 #define	FREEBSD32_SHAREDPAGE	(VM_MAXUSER_ADDRESS32 - PAGE_SIZE)
110 #define	FREEBSD32_USRSTACK	FREEBSD32_SHAREDPAGE
111 
112 #ifdef __powerpc64__
113 #define	VM_MIN_KERNEL_ADDRESS		0xc000000000000000UL
114 #define	VM_MAX_KERNEL_ADDRESS		0xc0000001c7ffffffUL
115 #define	VM_MAX_SAFE_KERNEL_ADDRESS	VM_MAX_KERNEL_ADDRESS
116 #endif
117 
118 #ifdef AIM
119 #define	KERNBASE		0x00100100UL	/* start of kernel virtual */
120 
121 #ifndef __powerpc64__
122 #define	VM_MIN_KERNEL_ADDRESS	((vm_offset_t)KERNEL_SR << ADDR_SR_SHFT)
123 #define	VM_MAX_SAFE_KERNEL_ADDRESS (VM_MIN_KERNEL_ADDRESS + 2*SEGMENT_LENGTH -1)
124 #define	VM_MAX_KERNEL_ADDRESS	(VM_MIN_KERNEL_ADDRESS + 3*SEGMENT_LENGTH - 1)
125 #endif
126 
127 /*
128  * Use the direct-mapped BAT registers for UMA small allocs. This
129  * takes pressure off the small amount of available KVA.
130  */
131 #define UMA_MD_SMALL_ALLOC
132 
133 #else /* Book-E */
134 
135 #ifdef __powerpc64__
136 #ifndef LOCORE
137 #define	KERNBASE	0xc000000000000000UL	/* start of kernel virtual */
138 #else
139 #define	KERNBASE	0xc000000000000000	/* start of kernel virtual */
140 #endif
141 #else
142 #define	KERNBASE		0xc0000000	/* start of kernel virtual */
143 
144 #define	VM_MIN_KERNEL_ADDRESS	KERNBASE
145 #define	VM_MAX_KERNEL_ADDRESS	0xffffefff
146 #define	VM_MAX_SAFE_KERNEL_ADDRESS	VM_MAX_KERNEL_ADDRESS
147 #endif
148 
149 #endif /* AIM/E500 */
150 
151 #if !defined(LOCORE)
152 struct pmap_physseg {
153 	struct pv_entry *pvent;
154 	char *attrs;
155 };
156 #endif
157 
158 #define	VM_PHYSSEG_MAX		16	/* 1? */
159 
160 /*
161  * The physical address space is densely populated on 32-bit systems,
162  * but may not be on 64-bit ones.
163  */
164 #ifdef __powerpc64__
165 #define	VM_PHYSSEG_SPARSE
166 #else
167 #define	VM_PHYSSEG_DENSE
168 #endif
169 
170 /*
171  * Create two free page pools: VM_FREEPOOL_DEFAULT is the default pool
172  * from which physical pages are allocated and VM_FREEPOOL_DIRECT is
173  * the pool from which physical pages for small UMA objects are
174  * allocated.
175  */
176 #define	VM_NFREEPOOL		2
177 #define	VM_FREEPOOL_DEFAULT	0
178 #define	VM_FREEPOOL_DIRECT	1
179 
180 /*
181  * Create one free page list.
182  */
183 #define	VM_NFREELIST		1
184 #define	VM_FREELIST_DEFAULT	0
185 
186 /*
187  * The largest allocation size is 4MB.
188  */
189 #define	VM_NFREEORDER		11
190 
191 /*
192  * Disable superpage reservations.
193  */
194 #ifndef	VM_NRESERVLEVEL
195 #define	VM_NRESERVLEVEL		0
196 #endif
197 
198 #ifndef VM_INITIAL_PAGEIN
199 #define	VM_INITIAL_PAGEIN	16
200 #endif
201 
202 #ifndef SGROWSIZ
203 #define	SGROWSIZ	(128UL*1024)		/* amount to grow stack */
204 #endif
205 
206 /*
207  * How many physical pages per kmem arena virtual page.
208  */
209 #ifndef VM_KMEM_SIZE_SCALE
210 #define	VM_KMEM_SIZE_SCALE	(3)
211 #endif
212 
213 /*
214  * Optional floor (in bytes) on the size of the kmem arena.
215  */
216 #ifndef VM_KMEM_SIZE_MIN
217 #define	VM_KMEM_SIZE_MIN	(12 * 1024 * 1024)
218 #endif
219 
220 /*
221  * Optional ceiling (in bytes) on the size of the kmem arena: 40% of the
222  * usable KVA space.
223  */
224 #ifndef VM_KMEM_SIZE_MAX
225 #define VM_KMEM_SIZE_MAX	((VM_MAX_SAFE_KERNEL_ADDRESS - \
226     VM_MIN_KERNEL_ADDRESS + 1) * 2 / 5)
227 #endif
228 
229 #define	ZERO_REGION_SIZE	(64 * 1024)	/* 64KB */
230 
231 /*
232  * On 32-bit OEA, the only purpose for which sf_buf is used is to implement
233  * an opaque pointer required by the machine-independent parts of the kernel.
234  * That pointer references the vm_page that is "mapped" by the sf_buf.  The
235  * actual mapping is provided by the direct virtual-to-physical mapping.
236  *
237  * On OEA64 and Book-E, we need to do something a little more complicated. Use
238  * the runtime-detected hw_direct_map to pick between the two cases. Our
239  * friends in vm_machdep.c will do the same to ensure nothing gets confused.
240  */
241 #define	SFBUF
242 #define	SFBUF_NOMD
243 
244 /*
245  * We (usually) have a direct map of all physical memory, so provide
246  * a macro to use to get the kernel VA address for a given PA. Returns
247  * 0 if the direct map is unavailable. The location of the direct map
248  * may not be 1:1 in future, so use of the macro is recommended.
249  */
250 #ifdef __powerpc64__
251 #define	DMAP_BASE_ADDRESS	0x0000000000000000UL
252 #else
253 #define	DMAP_BASE_ADDRESS	0x00000000UL
254 #endif
255 
256 #define	PMAP_HAS_DMAP	(hw_direct_map)
257 #define PHYS_TO_DMAP(x) ({						\
258 	KASSERT(hw_direct_map, ("Direct map not provided by PMAP"));	\
259 	(x) | DMAP_BASE_ADDRESS; })
260 #define DMAP_TO_PHYS(x) ({						\
261 	KASSERT(hw_direct_map, ("Direct map not provided by PMAP"));	\
262 	(x) &~ DMAP_BASE_ADDRESS; })
263 
264 #endif /* _MACHINE_VMPARAM_H_ */
265