xref: /netbsd-src/sys/arch/powerpc/include/booke/vmparam.h (revision b1c86f5f087524e68db12794ee9c3e3da1ab17a0)
1 /*-
2  * Copyright (c) 2010 The NetBSD Foundation, Inc.
3  * All rights reserved.
4  *
5  * This code is derived from software contributed to The NetBSD Foundation
6  * by Matt Thomas of 3am Software Foundry, LLC.
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  *
17  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
18  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
21  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 #ifndef _POWERPC_BOOKE_VMPARAM_H_
31 #define _POWERPC_BOOKE_VMPARAM_H_
32 
33 /*
34  * Most of the definitions in this can be overriden by a machine-specific
35  * vmparam.h if required.  Otherwise a port can just include this file
36  * get the right thing to happen.
37  */
38 
39 /*
40  * BookE processors have 4K pages.  Override the PAGE_* definitions to be
41  * compile-time constants.
42  */
43 #define	PAGE_SHIFT	12
44 #define	PAGE_SIZE	(1 << PAGE_SHIFT)
45 #define	PAGE_MASK	(PAGE_SIZE - 1)
46 
47 #ifndef	USRSTACK
48 #define	USRSTACK	VM_MAXUSER_ADDRESS
49 #endif
50 
51 #ifndef	MAXTSIZ
52 #define	MAXTSIZ		(2*256*1024*1024)	/* maximum text size */
53 #endif
54 
55 #ifndef	MAXDSIZ
56 #define	MAXDSIZ		(13*256*1024*1024)	/* maximum data size */
57 #endif
58 
59 #ifndef	MAXSSIZ
60 #define	MAXSSIZ		(1*256*1024*1024-PAGE_SIZE) /* maximum stack size */
61 #endif
62 
63 #ifndef	DFLDSIZ
64 #define	DFLDSIZ		(256*1024*1024)		/* default data size */
65 #endif
66 
67 #ifndef	DFLSSIZ
68 #define	DFLSSIZ		(2*1024*1024)		/* default stack size */
69 #endif
70 
71 /*
72  * Default number of pages in the user raw I/O map.
73  */
74 #ifndef USRIOSIZE
75 #define	USRIOSIZE	1024
76 #endif
77 
78 /*
79  * The number of seconds for a process to be blocked before being
80  * considered very swappable.
81  */
82 #ifndef MAXSLP
83 #define	MAXSLP		20
84 #endif
85 
86 /*
87  * Some system constants
88  */
89 
90 #define	VM_MIN_ADDRESS		((vaddr_t) 0)
91 #define	VM_MAXUSER_ADDRESS	((vaddr_t) -PAGE_SIZE)
92 #define	VM_MAX_ADDRESS		VM_MAXUSER_ADDRESS
93 #define	VM_MIN_KERNEL_ADDRESS	((vaddr_t) 0xe4000000)
94 #define	VM_MAX_KERNEL_ADDRESS	((vaddr_t) 0xfefff000)
95 
96 /*
97  * The address to which unspecified mapping requests default
98  * Put the stack in it's own segment and start mmaping at the
99  * top of the next lower segment.
100  */
101 #ifdef _KERNEL_OPT
102 #include "opt_uvm.h"
103 #endif
104 #define	__USE_TOPDOWN_VM
105 #define	VM_DEFAULT_ADDRESS(da, sz) \
106 	(((VM_MAXUSER_ADDRESS - MAXSSIZ) - round_page(sz))
107 
108 #ifndef VM_PHYSSEG_MAX
109 #define	VM_PHYSSEG_MAX		16
110 #endif
111 #define	VM_PHYSSEG_STRAT	VM_PSTRAT_BIGFIRST
112 #define	VM_PHYSSEG_NOADD
113 
114 #ifndef VM_PHYS_SIZE
115 #define	VM_PHYS_SIZE		(USRIOSIZE * PAGE_SIZE)
116 #endif
117 
118 #define	VM_NFREELIST		2	/* 16 distinct memory segments */
119 #define	VM_FREELIST_DEFAULT	0
120 #define	VM_FREELIST_FIRST16	1
121 #define	VM_FREELIST_MAX		2
122 
123 #ifndef _LOCORE
124 
125 #define	__HAVE_VM_PAGE_MD
126 
127 struct pv_entry {
128 	struct pv_entry *pv_next;
129 	struct pmap *pv_pmap;
130 	vaddr_t pv_va;
131 };
132 
133 struct vm_page_md {
134 	struct pv_entry mdpg_pvlist;
135 	unsigned int mdpg_attrs;
136 };
137 
138 #define	VM_MDPAGE_INIT(pg) do {				\
139 	(pg)->mdpage.mdpg_pvlist.pv_next = NULL;	\
140 	(pg)->mdpage.mdpg_pvlist.pv_pmap = NULL;	\
141 	(pg)->mdpage.mdpg_pvlist.pv_va = 0;		\
142 	(pg)->mdpage.mdpg_attrs = 0;			\
143 } while (/*CONSTCOND*/0)
144 
145 #endif	/* _LOCORE */
146 
147 #endif /* _POWERPC_BOOKE_VMPARAM_H_ */
148