vmparam.h revision 1.21 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 *
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_OEA_VMPARAM_H_
31 #define _POWERPC_OEA_VMPARAM_H_
32
33 #include <sys/queue.h>
34
35 /*
36 * Most of the definitions in this can be overriden by a machine-specific
37 * vmparam.h if required. Otherwise a port can just include this file
38 * get the right thing to happen.
39 */
40
41 /*
42 * OEA processors have 4K pages. Override the PAGE_* definitions
43 * to be compile-time constants.
44 */
45 #define PAGE_SHIFT 12
46 #define PAGE_SIZE (1 << PAGE_SHIFT)
47 #define PAGE_MASK (PAGE_SIZE - 1)
48
49 #ifndef USRSTACK
50 #define USRSTACK VM_MAXUSER_ADDRESS
51 #endif
52
53 #ifndef USRSTACK32
54 #define USRSTACK32 VM_MAXUSER_ADDRESS32
55 #endif
56
57 #ifndef MAXTSIZ
58 #define MAXTSIZ (128*1024*1024) /* maximum text size */
59 #endif
60
61 #ifndef MAXDSIZ
62 #define MAXDSIZ (1024*1024*1024) /* maximum data size */
63 #endif
64
65 #ifndef MAXDSIZ32
66 #define MAXDSIZ32 (1024*1024*1024) /* maximum data size */
67 #endif
68
69 #ifndef MAXSSIZ
70 #define MAXSSIZ (32*1024*1024) /* maximum stack size */
71 #endif
72
73 #ifndef MAXSSIZ32
74 #define MAXSSIZ32 (32*1024*1024) /* maximum stack size */
75 #endif
76
77 #ifndef DFLDSIZ
78 #define DFLDSIZ (256*1024*1024) /* default data size */
79 #endif
80
81 #ifndef DFLDSIZ32
82 #define DFLSSIZ32 (256*1024*1024)
83 #endif
84
85 #ifndef DFLSSIZ
86 #define DFLSSIZ (2*1024*1024) /* default stack size */
87 #endif
88
89 #ifndef DFLSSIZ32
90 #define DFLSSIZ32 (2*1024*1024) /* default stack size */
91 #endif
92
93 /*
94 * Default number of pages in the user raw I/O map.
95 */
96 #ifndef USRIOSIZE
97 #define USRIOSIZE 1024
98 #endif
99
100 /*
101 * The number of seconds for a process to be blocked before being
102 * considered very swappable.
103 */
104 #ifndef MAXSLP
105 #define MAXSLP 20
106 #endif
107
108 /*
109 * Segment handling stuff
110 */
111 #define SEGMENT_LENGTH ( 0x10000000L)
112 #define SEGMENT_MASK (~0x0fffffffL)
113
114 /*
115 * Macros to manipulate VSIDs
116 */
117 #if 0
118 /*
119 * Move the SR# to the top bits to make the lower bits entirely random
120 * so to give better PTE distribution.
121 */
122 #define VSID__KEYSHFT (SR_VSID_WIDTH - SR_KEY_LEN)
123 #define VSID_SR_INCREMENT ((1L << VSID__KEYSHFT) - 1)
124 #define VSID__HASHMASK (VSID_SR_INCREMENT - 1)
125 #define VSID_MAKE(sr, hash) \
126 (( \
127 (((sr) << VSID__KEYSHFT) | ((hash) & VSID__HASMASK))
128 << SR_VSID_SHFT) & SR_VSID)
129 #define VSID_TO_SR(vsid) \
130 (((vsid) & SR_VSID) >> (SR_VSID_SHFT + VSID__KEYSHFT))
131 #define VSID_TO_HASH(vsid) \
132 (((vsid) & SR_VSID) >> SR_VSID_SHFT) & VSID__HASHMASK)
133 #else
134 #define VSID__HASHSHFT (SR_KEY_LEN)
135 #define VSID_SR_INCREMENT (1L << 0)
136 #define VSID__KEYMASK ((1L << VSID__HASHSHFT) - 1)
137 #define VSID_MAKE(sr, hash) \
138 (( \
139 (((hash) << VSID__HASHSHFT) | ((sr) & VSID__KEYMASK)) \
140 << SR_VSID_SHFT) & SR_VSID)
141 #define VSID_TO_SR(vsid) \
142 (((vsid) >> SR_VSID_SHFT) & VSID__KEYMASK)
143 #define VSID_TO_HASH(vsid) \
144 (((vsid) & SR_VSID) >> (SR_VSID_SHFT + VSID__HASHSHFT))
145 #endif /*0*/
146
147 #ifndef _LP64
148 /*
149 * Fixed segments
150 */
151 #ifndef USER_SR
152 #define USER_SR 12
153 #endif
154 #ifndef KERNEL_SR
155 #define KERNEL_SR 13
156 #endif
157 #ifndef KERNEL2_SR
158 #define KERNEL2_SR 14
159 #endif
160 #define KERNEL2_SEGMENT VSID_MAKE(KERNEL2_SR, KERNEL_VSIDBITS)
161 #endif
162 #define KERNEL_VSIDBITS 0xfffff
163 #define PHYSMAP_VSIDBITS 0xffffe
164 #define PHYSMAPN_SEGMENT(s) VSID_MAKE(s, PHYSMAP_VSIDBITS)
165 #define KERNEL_SEGMENT VSID_MAKE(KERNEL_SR, KERNEL_VSIDBITS)
166 #define KERNELN_SEGMENT(s) VSID_MAKE(s, KERNEL_VSIDBITS)
167 /* XXXSL: need something here that will never be mapped */
168 #define EMPTY_SEGMENT VSID_MAKE(0, 0xffffe)
169 #define USER_ADDR ((void *)(USER_SR << ADDR_SR_SHFT))
170
171 /*
172 * Some system constants
173 */
174 #ifndef NPMAPS
175 #define NPMAPS 32768 /* Number of pmaps in system */
176 #endif
177
178 #define VM_MIN_ADDRESS ((vaddr_t) 0)
179 #define VM_MAXUSER_ADDRESS32 ((vaddr_t) (uint32_t) ~0xfffL)
180 #ifdef _LP64
181 #define VM_MAXUSER_ADDRESS ((vaddr_t) 1UL << 48) /* 256TB */
182 #else
183 #define VM_MAXUSER_ADDRESS VM_MAXUSER_ADDRESS32
184 #endif
185 #define VM_MAX_ADDRESS VM_MAXUSER_ADDRESS
186 #ifdef _LP64
187 #define VM_MIN_KERNEL_ADDRESS ((vaddr_t) 0xffffffUL << 40) /* top 1TB */
188 #define VM_MAX_KERNEL_ADDRESS ((vaddr_t) -32768)
189 #else
190 #define VM_MIN_KERNEL_ADDRESS ((vaddr_t) (KERNEL_SR << ADDR_SR_SHFT))
191 #define VM_MAX_KERNEL_ADDRESS (VM_MIN_KERNEL_ADDRESS + 2*SEGMENT_LENGTH)
192 #endif
193
194 #define VM_PHYSSEG_STRAT VM_PSTRAT_BIGFIRST
195
196 #ifndef VM_PHYS_SIZE
197 #define VM_PHYS_SIZE (USRIOSIZE * PAGE_SIZE)
198 #endif
199
200 #endif /* _POWERPC_OEA_VMPARAM_H_ */
201