xref: /netbsd/sys/arch/powerpc/include/vmparam.h (revision c37a18e2)
1*c37a18e2Sandvar /*	$NetBSD: vmparam.h,v 1.26 2022/05/11 13:58:43 andvar Exp $	*/
2b9312304Smatt 
3b9312304Smatt #ifndef _POWERPC_VMPARAM_H_
4b9312304Smatt #define _POWERPC_VMPARAM_H_
513dfb724Smatt 
613dfb724Smatt #ifdef _KERNEL_OPT
7b9312304Smatt #include "opt_modular.h"
813dfb724Smatt #include "opt_ppcarch.h"
913dfb724Smatt #endif
1013dfb724Smatt 
11b9312304Smatt /*
12b9312304Smatt  * These are common for BOOKE, IBM4XX, and OEA
13b9312304Smatt  */
14b9312304Smatt #define	VM_FREELIST_DEFAULT	0
15b9312304Smatt #define	VM_FREELIST_FIRST256	1
16b9312304Smatt #define	VM_FREELIST_FIRST16	2
17b9312304Smatt #define	VM_NFREELIST		3
18b9312304Smatt 
19b9312304Smatt #define	VM_PHYSSEG_MAX		16
20b9312304Smatt 
21b9312304Smatt /*
22b9312304Smatt  * The address to which unspecified mapping requests default
237d1220acSsnj  * Put the stack in its own segment and start mmaping at the
24b9312304Smatt  * top of the next lower segment.
25b9312304Smatt  */
26b9312304Smatt #define	__USE_TOPDOWN_VM
2745cf6629Schristos #define VM_DEFAULT_ADDRESS_BOTTOMUP(da, sz) \
2845cf6629Schristos     round_page((vaddr_t)(da) + (vsize_t)maxdmap)
29b9312304Smatt 
30b7c99019Srin #if defined(MODULAR) || defined(_MODULE) || !defined(_KERNEL)
31b9312304Smatt /*
32d2054d59Smatt  * If we are a module or a modular kernel, then we need to defined the range
33*c37a18e2Sandvar  * of our variable page sizes since BOOKE and OEA use 4KB pages while IBM4XX
34d2054d59Smatt  * use 16KB pages.
35b7c99019Srin  * This is also required for userland by jemalloc.
36b9312304Smatt  */
372232602bSchristos #define MIN_PAGE_SHIFT	12			/* BOOKE/OEA */
382232602bSchristos #define MAX_PAGE_SHIFT	14			/* IBM4XX */
392232602bSchristos #define	MIN_PAGE_SIZE	(1 << MIN_PAGE_SHIFT)
402232602bSchristos #define	MAX_PAGE_SIZE	(1 << MAX_PAGE_SHIFT)
41b7c99019Srin #endif /* MODULAR || _MODULE || !_KERNEL */
42b9312304Smatt 
43d2054d59Smatt #if defined(_MODULE)
448aa42ad9Smatt #if defined(_RUMPKERNEL)
458aa42ad9Smatt /*
468aa42ad9Smatt  * Safe definitions for RUMP kernels
478aa42ad9Smatt  */
488aa42ad9Smatt #define	VM_MAXUSER_ADDRESS	0x7fff8000
498aa42ad9Smatt #define	VM_MIN_ADDRESS		0x00000000
508aa42ad9Smatt #define	VM_MAX_ADDRESS		VM_MAXUSER_ADDRESS
518aa42ad9Smatt #define	MAXDSIZ			(1024*1024*1024)
528aa42ad9Smatt #define	MAXSSIZ			(32*1024*1024)
538aa42ad9Smatt #define	MAXTSIZ			(256*1024*1024)
548aa42ad9Smatt #else /* !_RUMPKERNEL */
55b9312304Smatt /*
56b9312304Smatt  * Some modules need some of the constants but those vary between the variants
57b9312304Smatt  * so those constants are exported as linker symbols so they don't take up any
58b9312304Smatt  * space but also avoid an extra load to put into a register.
59b9312304Smatt  */
60b9312304Smatt extern const char __USRSTACK;		/* let the linker resolve it */
61b9312304Smatt 
62b9312304Smatt #define USRSTACK	((vaddr_t)(uintptr_t)&__USRSTACK)
638aa42ad9Smatt #endif /* !_RUMPKERNEL */
64b9312304Smatt 
65b9312304Smatt #else /* !_MODULE */
66b9312304Smatt 
6713dfb724Smatt #if defined(PPC_BOOKE)
6813dfb724Smatt #include <powerpc/booke/vmparam.h>
6913dfb724Smatt #elif defined(PPC_IBM4XX)
7013dfb724Smatt #include <powerpc/ibm4xx/vmparam.h>
7113dfb724Smatt #elif defined(PPC_OEA) || defined (PPC_OEA64) || defined (PPC_OEA64_BRIDGE)
7213dfb724Smatt #include <powerpc/oea/vmparam.h>
738aa42ad9Smatt #elif defined(_KERNEL)
7413dfb724Smatt #error unknown PPC variant
7513dfb724Smatt #endif
76b9312304Smatt 
77b9312304Smatt #endif /* !_MODULE */
78b9312304Smatt 
79ade5e693Srin #if defined(MODULAR) || defined(_MODULE)
80b9312304Smatt /*
81b9312304Smatt  * If we are a module or support modules, we need to define a compatible
82b9312304Smatt  * pmap_physseg since IBM4XX uses one.  This will waste a tiny of space
83b9312304Smatt  * but is needed for compatibility.
84b9312304Smatt  */
85b9312304Smatt #ifndef __HAVE_PMAP_PHYSSEG
86b9312304Smatt #define	__HAVE_PMAP_PHYSSEG
87b9312304Smatt struct pmap_physseg {
88b9312304Smatt 	uintptr_t pmseg_dummy[2];
89b9312304Smatt };
90b9312304Smatt #endif
91b9312304Smatt 
92b9312304Smatt __CTASSERT(sizeof(struct pmap_physseg) == sizeof(uintptr_t) * 2);
93b9312304Smatt #endif /* MODULAR || _MODULE */
94b9312304Smatt 
95b9312304Smatt #endif /* !_POWERPC_VMPARAM_H_ */
96