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#define UMA_MD_SMALL_ALLOC
115
116#ifdef AIM
117#ifndef __powerpc64__
118#define VM_MIN_KERNEL_ADDRESS ((vm_offset_t)KERNEL_SR << ADDR_SR_SHFT)
119#define VM_MAX_SAFE_KERNEL_ADDRESS (VM_MIN_KERNEL_ADDRESS + 2*SEGMENT_LENGTH -1)
120#define VM_MAX_KERNEL_ADDRESS (VM_MIN_KERNEL_ADDRESS + 3*SEGMENT_LENGTH - 1)
121#endif
122
123/*
124 * Use the direct-mapped BAT registers for UMA small allocs. This
125 * takes pressure off the small amount of available KVA.
126 */
127#define UMA_USE_DMAP
128
129#else /* Book-E */
130
131/* Use the direct map for UMA small allocs on powerpc64. */
132#ifdef __powerpc64__
133#define UMA_USE_DMAP
134#else
135#define VM_MIN_KERNEL_ADDRESS 0xc0000000
136#define VM_MAX_KERNEL_ADDRESS 0xffffefff
137#define VM_MAX_SAFE_KERNEL_ADDRESS VM_MAX_KERNEL_ADDRESS
138#endif
139
140#endif /* AIM/E500 */
141
142#if !defined(LOCORE)
143struct pmap_physseg {
144 struct pv_entry *pvent;
145 char *attrs;
146};
147#endif
148
149#ifdef __powerpc64__
150#define VM_PHYSSEG_MAX 63 /* 1? */
151#else
152#define VM_PHYSSEG_MAX 16 /* 1? */
153#endif
154
155#define PHYS_AVAIL_SZ 256 /* Allows up to 16GB Ram on pSeries with
156 * logical memory block size of 64MB.
157 * For more Ram increase the lmb or this value.
158 */
159
160/* XXX This is non-sensical. Phys avail should hold contiguous regions. */
161#define PHYS_AVAIL_ENTRIES PHYS_AVAIL_SZ
162
163/*
164 * The physical address space is densely populated on 32-bit systems,
165 * but may not be on 64-bit ones.
166 */
167#ifdef __powerpc64__
168#define VM_PHYSSEG_SPARSE
169#else
170#define VM_PHYSSEG_DENSE
171#endif
172
173/*
174 * Create two free page pools: VM_FREEPOOL_DEFAULT is the default pool
175 * from which physical pages are allocated and VM_FREEPOOL_DIRECT is
176 * the pool from which physical pages for small UMA objects are
177 * allocated.
178 */
179#define VM_NFREEPOOL 2
180#define VM_FREEPOOL_DEFAULT 0
181#define VM_FREEPOOL_DIRECT 1
182
183/*
184 * Create one free page list.
185 */
186#define VM_NFREELIST 1
187#define VM_FREELIST_DEFAULT 0
188
189#ifdef __powerpc64__
190/* The largest allocation size is 16MB. */
191#define VM_NFREEORDER 13
192#else
193/* The largest allocation size is 4MB. */
194#define VM_NFREEORDER 11
195#endif
196
197#ifndef VM_NRESERVLEVEL
198#ifdef __powerpc64__
199/* Enable superpage reservations: 1 level. */
200#define VM_NRESERVLEVEL 1
201#else
202/* Disable superpage reservations. */
203#define VM_NRESERVLEVEL 0
204#endif
205#endif
206
207#ifndef VM_LEVEL_0_ORDER
208/* Level 0 reservations consist of 512 (RPT) or 4096 (HPT) pages. */
209#define VM_LEVEL_0_ORDER vm_level_0_order
210#ifndef __ASSEMBLER__
211extern int vm_level_0_order;
212#endif
213#endif
214
215#ifndef VM_LEVEL_0_ORDER_MAX
216#define VM_LEVEL_0_ORDER_MAX 12
217#endif
218
219#ifndef VM_INITIAL_PAGEIN
220#define VM_INITIAL_PAGEIN 16
221#endif
222
223#ifndef SGROWSIZ
224#define SGROWSIZ (128UL*1024) /* amount to grow stack */
225#endif
226
227/*
228 * How many physical pages per kmem arena virtual page.
229 */
230#ifndef VM_KMEM_SIZE_SCALE
231#define VM_KMEM_SIZE_SCALE (3)
232#endif
233
234/*
235 * Optional floor (in bytes) on the size of the kmem arena.
236 */
237#ifndef VM_KMEM_SIZE_MIN
238#define VM_KMEM_SIZE_MIN (12 * 1024 * 1024)
239#endif
240
241/*
242 * Optional ceiling (in bytes) on the size of the kmem arena: 40% of the
243 * usable KVA space.
244 */
245#ifndef VM_KMEM_SIZE_MAX
246#define VM_KMEM_SIZE_MAX ((VM_MAX_SAFE_KERNEL_ADDRESS - \
247 VM_MIN_KERNEL_ADDRESS + 1) * 2 / 5)
248#endif
249
250#ifdef __powerpc64__
251#define ZERO_REGION_SIZE (2 * 1024 * 1024) /* 2MB */
252#else
253#define ZERO_REGION_SIZE (64 * 1024) /* 64KB */
254#endif
255
256/*
257 * On 32-bit OEA, the only purpose for which sf_buf is used is to implement
258 * an opaque pointer required by the machine-independent parts of the kernel.
259 * That pointer references the vm_page that is "mapped" by the sf_buf. The
260 * actual mapping is provided by the direct virtual-to-physical mapping.
261 *
262 * On OEA64 and Book-E, we need to do something a little more complicated. Use
263 * the runtime-detected hw_direct_map to pick between the two cases. Our
264 * friends in vm_machdep.c will do the same to ensure nothing gets confused.
265 */
266#define SFBUF
267#define SFBUF_NOMD
268
269/*
270 * We (usually) have a direct map of all physical memory, so provide
271 * a macro to use to get the kernel VA address for a given PA. Check the
272 * value of PMAP_HAS_PMAP before using.
273 */
274#ifndef LOCORE
275#ifdef __powerpc64__
276#define DMAP_BASE_ADDRESS 0xc000000000000000UL
277#define DMAP_MIN_ADDRESS DMAP_BASE_ADDRESS
278#define DMAP_MAX_ADDRESS 0xc007ffffffffffffUL
279#else
280#define DMAP_BASE_ADDRESS 0x00000000UL
281#define DMAP_MAX_ADDRESS 0xbfffffffUL
282#endif
283#endif
284
285#if defined(__powerpc64__) || defined(BOOKE)
286/*
287 * powerpc64 and Book-E will provide their own page array allocators.
288 *
289 * On AIM, this will allocate a single virtual array, with pages from the
290 * correct memory domains.
291 * On Book-E this will let us put the array in TLB1, removing the need for TLB
292 * thrashing.
293 *
294 * VM_MIN_KERNEL_ADDRESS is just a dummy. It will get set by the MMU driver.
295 */
296#define PA_MIN_ADDRESS VM_MIN_KERNEL_ADDRESS
297#define PMAP_HAS_PAGE_ARRAY 1
298#endif
299
300#if defined(__powerpc64__)
301/*
302 * Need a page dump array for minidump.
303 */
304#define MINIDUMP_PAGE_TRACKING 1
305#define MINIDUMP_STARTUP_PAGE_TRACKING 1
306#else
307/*
308 * No minidump with 32-bit powerpc.
309 */
310#define MINIDUMP_PAGE_TRACKING 0
311#define MINIDUMP_STARTUP_PAGE_TRACKING 0
312#endif
313
314#define PMAP_HAS_DMAP (hw_direct_map)
315#define PHYS_TO_DMAP(x) ({ \
316 KASSERT(hw_direct_map, ("Direct map not provided by PMAP")); \
317 (x) | DMAP_BASE_ADDRESS; })
318#define DMAP_TO_PHYS(x) ({ \
319 KASSERT(hw_direct_map, ("Direct map not provided by PMAP")); \
320 (x) &~ DMAP_BASE_ADDRESS; })
321
322/*
323 * No non-transparent large page support in the pmap.
324 */
325#define PMAP_HAS_LARGEPAGES 0
326
327#endif /* _MACHINE_VMPARAM_H_ */