vmparam.h revision 1.7 1 /*-
2 * Copyright (c) 2001 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 <matt (at) 3am-softwre.com> of Allegro Networks, Inc.
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 the NetBSD
19 * Foundation, Inc. and its contributors.
20 * 4. Neither the name of The NetBSD Foundation nor the names of its
21 * contributors may be used to endorse or promote products derived
22 * from this software without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
25 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
26 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
28 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
35 */
36
37 #ifndef _POWERPC_OEA_VMPARAM_H_
38 #define _POWERPC_OEA_VMPARAM_H_
39
40 #include <sys/queue.h>
41
42 /*
43 * Most of the definitions in this can be overriden by a machine-specific
44 * vmparam.h if required. Otherwise a port can just include this file
45 * get the right thing to happen.
46 */
47
48 /*
49 * OEA processors have 4K pages. Override the PAGE_* definitions
50 * to be compile-time constants.
51 */
52 #define PAGE_SHIFT 12
53 #define PAGE_SIZE (1 << PAGE_SHIFT)
54 #define PAGE_MASK (PAGE_SIZE - 1)
55
56 #ifndef USRSTACK
57 #define USRSTACK VM_MAXUSER_ADDRESS
58 #endif
59
60 #ifndef USRSTACK32
61 #define USRSTACK32 ((uint32_t)VM_MAXUSER_ADDRESS)
62 #endif
63
64 #ifndef MAXTSIZ
65 #define MAXTSIZ (64*1024*1024) /* maximum text size */
66 #endif
67
68 #ifndef MAXDSIZ
69 #define MAXDSIZ (1024*1024*1024) /* maximum data size */
70 #endif
71
72 #ifndef MAXSSIZ
73 #define MAXSSIZ (32*1024*1024) /* maximum stack size */
74 #endif
75
76 #ifndef DFLDSIZ
77 #define DFLDSIZ (128*1024*1024) /* default data size */
78 #endif
79
80 #ifndef DFLSSIZ
81 #define DFLSSIZ (2*1024*1024) /* default stack size */
82 #endif
83
84 /*
85 * Default maximum amount of shared memory pages
86 */
87 #ifndef SHMMAXPGS
88 #define SHMMAXPGS 1024
89 #endif
90
91 /*
92 * Default number of pages in the user raw I/O map.
93 */
94 #ifndef USRIOSIZE
95 #define USRIOSIZE 1024
96 #endif
97
98 /*
99 * The number of seconds for a process to be blocked before being
100 * considered very swappable.
101 */
102 #ifndef MAXSLP
103 #define MAXSLP 20
104 #endif
105
106 /*
107 * Segment handling stuff
108 */
109 #define SEGMENT_LENGTH ( 0x10000000L)
110 #define SEGMENT_MASK (~0x0fffffffL)
111
112 /*
113 * Macros to manipulate VSIDs
114 */
115 #if 0
116 /*
117 * Move the SR# to the top bits to make the lower bits entirely random
118 * so to give better PTE distribution.
119 */
120 #define VSID__KEYSHFT (SR_VSID_WIDTH - SR_KEY_LEN)
121 #define VSID_SR_INCREMENT ((1L << VSID__KEYSHFT) - 1)
122 #define VSID__HASHMASK (VSID_SR_INCREMENT - 1)
123 #define VSID_MAKE(sr, hash) \
124 (( \
125 (((sr) << VSID__KEYSHFT) | ((hash) & VSID__HASMASK))
126 << SR_VSID_SHFT) & SR_VSID)
127 #define VSID_TO_SR(vsid) \
128 (((vsid) & SR_VSID) >> (SR_VSID_SHFT + VSID__KEYSHFT))
129 #define VSID_TO_HASH(vsid) \
130 (((vsid) & SR_VSID) >> SR_VSID_SHFT) & VSID__HASHMASK)
131 #else
132 #define VSID__HASHSHFT (SR_KEY_LEN)
133 #define VSID_SR_INCREMENT (1L << 0)
134 #define VSID__KEYMASK ((1L << VSID__HASHSHFT) - 1)
135 #define VSID_MAKE(sr, hash) \
136 (( \
137 (((hash) << VSID__HASHSHFT) | ((sr) & VSID__KEYMASK)) \
138 << SR_VSID_SHFT) & SR_VSID)
139 #define VSID_TO_SR(vsid) \
140 (((vsid) >> SR_VSID_SHFT) & VSID__KEYMASK)
141 #define VSID_TO_HASH(vsid) \
142 (((vsid) & SR_VSID) >> (SR_VSID_SHFT + VSID__HASHSHFT))
143 #endif
144
145 /*
146 * Fixed segments
147 */
148 #ifndef USER_SR
149 #define USER_SR 12
150 #endif
151 #ifndef KERNEL_SR
152 #define KERNEL_SR 13
153 #endif
154 #ifndef KERNEL2_SR
155 #define KERNEL2_SR 14
156 #endif
157 #define KERNEL2_SEGMENT VSID_MAKE(KERNEL2_SR, KERNEL_VSIDBITS)
158 #define KERNEL_VSIDBITS 0xfffff
159 #define KERNEL_SEGMENT VSID_MAKE(KERNEL_SR, KERNEL_VSIDBITS)
160 #define EMPTY_SEGMENT VSID_MAKE(0, KERNEL_VSIDBITS)
161 #define USER_ADDR ((void *)(USER_SR << ADDR_SR_SHFT))
162
163 /*
164 * Some system constants
165 */
166 #ifndef NPMAPS
167 #define NPMAPS 32768 /* Number of pmaps in system */
168 #endif
169
170 #define VM_MIN_ADDRESS ((vaddr_t) 0)
171 #define VM_MAXUSER_ADDRESS ((vaddr_t) ~0xfffL)
172 #define VM_MAX_ADDRESS VM_MAXUSER_ADDRESS
173 #define VM_MIN_KERNEL_ADDRESS ((vaddr_t) (KERNEL_SR << ADDR_SR_SHFT))
174 #define VM_MAX_KERNEL_ADDRESS (VM_MIN_KERNEL_ADDRESS + 2*SEGMENT_LENGTH)
175
176 /*
177 * The address to which unspecified mapping requests default
178 * Put the stack in it's own segment and start mmaping at the
179 * top of the next lower segment.
180 */
181 #ifdef _KERNEL_OPT
182 #include "opt_uvm.h"
183 #endif
184 #define __HAVE_TOPDOWN_VM
185 #ifdef USE_TOPDOWN_VM
186 #define VM_DEFAULT_ADDRESS(da, sz) \
187 (((VM_MAXUSER_ADDRESS - MAXSSIZ) & SEGMENT_MASK) - round_page(sz))
188 #endif
189
190 #ifndef VM_PHYSSEG_MAX
191 #define VM_PHYSSEG_MAX 16
192 #endif
193 #define VM_PHYSSEG_STRAT VM_PSTRAT_BIGFIRST
194 #define VM_PHYSSEG_NOADD
195
196 #ifndef VM_PHYS_SIZE
197 #define VM_PHYS_SIZE (USRIOSIZE * PAGE_SIZE)
198 #endif
199
200 #ifndef VM_MAX_KERNEL_BUF
201 #define VM_MAX_KERNEL_BUF (SEGMENT_LENGTH * 3 / 4)
202 #endif
203
204 #define VM_NFREELIST 16 /* 16 distinct memory segments */
205 #define VM_FREELIST_DEFAULT 0
206 #define VM_FREELIST_FIRST256 1
207 #define VM_FREELIST_FIRST16 2
208 #define VM_FREELIST_MAX 3
209
210 #ifndef _LOCORE
211
212 LIST_HEAD(pvo_head, pvo_entry);
213
214 #if __NetBSD_Version__ > 105180000
215 #define __HAVE_VM_PAGE_MD
216
217 struct vm_page_md {
218 struct pvo_head mdpg_pvoh;
219 unsigned int mdpg_attrs;
220 };
221
222 #define VM_MDPAGE_INIT(pg) do { \
223 LIST_INIT(&(pg)->mdpage.mdpg_pvoh); \
224 (pg)->mdpage.mdpg_attrs = 0; \
225 } while (/*CONSTCOND*/0)
226
227 #else
228
229 #define __HAVE_PMAP_PHYSSEG
230
231 struct pmap_physseg {
232 struct pvo_head *pvoh;
233 char *attrs;
234 };
235
236 #endif
237
238 #endif /* _LOCORE */
239
240 #endif /* _POWERPC_OEA_VMPARAM_H_ */
241