vmparam.h revision 1.6 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 4 bits to make the lower 20 bits entirely random
118 * so to give better PTE distribution.
119 */
120 #define VSID_MAKE(sr, hash) (((sr) << (ADDR_SR_SHFT-4))|((hash) & 0xfffff))
121 #define VSID_TO_SR(vsid) (((vsid) >> (ADDR_SR_SHFT-4)) & 0xF)
122 #define VSID_TO_HASH(vsid) ((vsid) & 0xfffff)
123 #define VSID_SR_INCREMENT 0x00100000
124 #else
125 #define VSID_MAKE(sr, hash) ((sr) | (((hash) & 0xfffff) << 4))
126 #define VSID_TO_SR(vsid) ((vsid) & 0xF)
127 #define VSID_TO_HASH(vsid) (((vsid) >> 4) & 0xfffff)
128 #define VSID_SR_INCREMENT 0x00000001
129 #endif
130
131 /*
132 * Fixed segments
133 */
134 #ifndef USER_SR
135 #define USER_SR 12
136 #endif
137 #ifndef KERNEL_SR
138 #define KERNEL_SR 13
139 #endif
140 #ifndef KERNEL2_SR
141 #define KERNEL2_SR 14
142 #endif
143 #define KERNEL2_SEGMENT VSID_MAKE(KERNEL2_SR, KERNEL_VSIDBITS)
144 #define KERNEL_VSIDBITS 0xfffff
145 #define KERNEL_SEGMENT VSID_MAKE(KERNEL_SR, KERNEL_VSIDBITS)
146 #define EMPTY_SEGMENT VSID_MAKE(0, KERNEL_VSIDBITS)
147 #define USER_ADDR ((void *)(USER_SR << ADDR_SR_SHFT))
148
149 /*
150 * Some system constants
151 */
152 #ifndef NPMAPS
153 #define NPMAPS 32768 /* Number of pmaps in system */
154 #endif
155
156 #define VM_MIN_ADDRESS ((vaddr_t) 0)
157 #define VM_MAXUSER_ADDRESS ((vaddr_t) ~0xfffL)
158 #define VM_MAX_ADDRESS VM_MAXUSER_ADDRESS
159 #define VM_MIN_KERNEL_ADDRESS ((vaddr_t) (KERNEL_SR << ADDR_SR_SHFT))
160 #define VM_MAX_KERNEL_ADDRESS (VM_MIN_KERNEL_ADDRESS + 2*SEGMENT_LENGTH)
161
162 /*
163 * The address to which unspecified mapping requests default
164 * Put the stack in it's own segment and start mmaping at the
165 * top of the next lower segment.
166 */
167 #ifdef _KERNEL_OPT
168 #include "opt_uvm.h"
169 #endif
170 #define __HAVE_TOPDOWN_VM
171 #ifdef USE_TOPDOWN_VM
172 #define VM_DEFAULT_ADDRESS(da, sz) \
173 (((VM_MAXUSER_ADDRESS - MAXSSIZ) & SEGMENT_MASK) - round_page(sz))
174 #endif
175
176 #ifndef VM_PHYSSEG_MAX
177 #define VM_PHYSSEG_MAX 16
178 #endif
179 #define VM_PHYSSEG_STRAT VM_PSTRAT_BIGFIRST
180 #define VM_PHYSSEG_NOADD
181
182 #ifndef VM_PHYS_SIZE
183 #define VM_PHYS_SIZE (USRIOSIZE * PAGE_SIZE)
184 #endif
185
186 #ifndef VM_MAX_KERNEL_BUF
187 #define VM_MAX_KERNEL_BUF (SEGMENT_LENGTH * 3 / 4)
188 #endif
189
190 #define VM_NFREELIST 16 /* 16 distinct memory segments */
191 #define VM_FREELIST_DEFAULT 0
192 #define VM_FREELIST_FIRST256 1
193 #define VM_FREELIST_FIRST16 2
194 #define VM_FREELIST_MAX 3
195
196 #ifndef _LOCORE
197
198 LIST_HEAD(pvo_head, pvo_entry);
199
200 #if __NetBSD_Version__ > 105180000
201 #define __HAVE_VM_PAGE_MD
202
203 struct vm_page_md {
204 struct pvo_head mdpg_pvoh;
205 unsigned int mdpg_attrs;
206 };
207
208 #define VM_MDPAGE_INIT(pg) do { \
209 LIST_INIT(&(pg)->mdpage.mdpg_pvoh); \
210 (pg)->mdpage.mdpg_attrs = 0; \
211 } while (/*CONSTCOND*/0)
212
213 #else
214
215 #define __HAVE_PMAP_PHYSSEG
216
217 struct pmap_physseg {
218 struct pvo_head *pvoh;
219 char *attrs;
220 };
221
222 #endif
223
224 #endif /* _LOCORE */
225
226 #endif /* _POWERPC_OEA_VMPARAM_H_ */
227