param.h revision 1.46 1 /* $NetBSD: param.h,v 1.46 2001/03/01 15:59:04 pk Exp $ */
2
3 /*
4 * Copyright (c) 1992, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * This software was developed by the Computer Systems Engineering group
8 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
9 * contributed to Berkeley.
10 *
11 * All advertising materials mentioning features or use of this software
12 * must display the following acknowledgement:
13 * This product includes software developed by the University of
14 * California, Lawrence Berkeley Laboratory.
15 *
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
18 * are met:
19 * 1. Redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer.
21 * 2. Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution.
24 * 3. All advertising materials mentioning features or use of this software
25 * must display the following acknowledgement:
26 * This product includes software developed by the University of
27 * California, Berkeley and its contributors.
28 * 4. Neither the name of the University nor the names of its contributors
29 * may be used to endorse or promote products derived from this software
30 * without specific prior written permission.
31 *
32 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
33 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
34 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
35 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
36 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
40 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
41 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
42 * SUCH DAMAGE.
43 *
44 * @(#)param.h 8.1 (Berkeley) 6/11/93
45 */
46 /*
47 * Sun4M support by Aaron Brown, Harvard University.
48 * Changes Copyright (c) 1995 The President and Fellows of Harvard College.
49 * All rights reserved.
50 */
51 #define _MACHINE sparc
52 #define MACHINE "sparc"
53 #define _MACHINE_ARCH sparc
54 #define MACHINE_ARCH "sparc"
55 #define MID_MACHINE MID_SPARC
56
57 #ifdef _KERNEL /* XXX */
58 #ifndef _LOCORE /* XXX */
59 #include <machine/cpu.h> /* XXX */
60 #endif /* XXX */
61 #endif /* XXX */
62
63 /*
64 * Round p (pointer or byte index) up to a correctly-aligned value for
65 * the machine's strictest data type. The result is u_int and must be
66 * cast to any desired pointer type.
67 *
68 * ALIGNED_POINTER is a boolean macro that checks whether an address
69 * is valid to fetch data elements of type t from on this architecture.
70 * This does not reflect the optimal alignment, just the possibility
71 * (within reasonable limits).
72 *
73 */
74 #define ALIGNBYTES 7
75 #define ALIGN(p) (((u_int)(p) + ALIGNBYTES) & ~ALIGNBYTES)
76 #define ALIGNED_POINTER(p,t) ((((u_long)(p)) & (sizeof(t)-1)) == 0)
77
78 #define SUN4_PGSHIFT 13 /* for a sun4 machine */
79 #define SUN4CM_PGSHIFT 12 /* for a sun4c or sun4m machine */
80
81 /*
82 * The following variables are always defined and initialized (in locore)
83 * so independently compiled modules (e.g. LKMs) can be used irrespective
84 * of the `options SUN4?' combination a particular kernel was configured with.
85 * See also the definitions of NBPG, PGOFSET and PGSHIFT below.
86 */
87 #if (defined(_KERNEL) || defined(_STANDALONE)) && !defined(_LOCORE)
88 extern int nbpg, pgofset, pgshift;
89 #endif
90
91 #define KERNBASE 0xf0000000 /* start of kernel virtual space */
92 #define KERNEND 0xfe000000 /* end of kernel virtual space */
93 /* Arbitrarily only use 1/4 of the kernel address space for buffers. */
94 #define VM_MAX_KERNEL_BUF ((KERNEND - KERNBASE)/4)
95 #define PROM_LOADADDR 0x00004000 /* where the prom loads us */
96 #define KERNTEXTOFF (KERNBASE+PROM_LOADADDR)/* start of kernel text */
97
98 #define DEV_BSIZE 512
99 #define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */
100 #define BLKDEV_IOSIZE 2048
101 #define MAXPHYS (64 * 1024)
102
103 #define SSIZE 1 /* initial stack size in pages */
104 #define USPACE 8192
105
106 /*
107 * Constants related to network buffer management.
108 * MCLBYTES must be no larger than NBPG (the software page size), and,
109 * on machines that exchange pages of input or output buffers with mbuf
110 * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
111 * of the hardware page size.
112 */
113 #define MSIZE 256 /* size of an mbuf */
114 #define MCLBYTES 2048 /* enough for whole Ethernet packet */
115 #define MCLSHIFT 11 /* log2(MCLBYTES) */
116 #define MCLOFSET (MCLBYTES - 1)
117
118 #if defined(_KERNEL) && !defined(_LKM)
119 #include "opt_gateway.h"
120 #endif /* _KERNEL && ! _LKM */
121
122 #ifndef NMBCLUSTERS
123 #ifdef GATEWAY
124 #define NMBCLUSTERS 512 /* map size, max cluster allocation */
125 #else
126 #define NMBCLUSTERS 256 /* map size, max cluster allocation */
127 #endif
128 #endif
129
130 /*
131 * Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized
132 * logical pages.
133 */
134 #define NKMEMPAGES_MIN_DEFAULT ((6 * 1024 * 1024) >> PAGE_SHIFT)
135 #define NKMEMPAGES_MAX_DEFAULT ((6 * 1024 * 1024) >> PAGE_SHIFT)
136
137 /* pages ("clicks") to disk blocks */
138 #define ctod(x) ((x) << (PGSHIFT - DEV_BSHIFT))
139 #define dtoc(x) ((x) >> (PGSHIFT - DEV_BSHIFT))
140
141 /* pages to bytes */
142 #define ctob(x) ((x) << PGSHIFT)
143 #define btoc(x) (((x) + PGOFSET) >> PGSHIFT)
144
145 /* bytes to disk blocks */
146 #define btodb(x) ((x) >> DEV_BSHIFT)
147 #define dbtob(x) ((x) << DEV_BSHIFT)
148
149 /*
150 * Map a ``block device block'' to a file system block.
151 * This should be device dependent, and should use the bsize
152 * field from the disk label.
153 * For now though just use DEV_BSIZE.
154 */
155 #define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE / DEV_BSIZE))
156
157 /*
158 * dvmamap manages a range of DVMA addresses intended to create double
159 * mappings of physical memory. In a way, `dvmamap' is a submap of the
160 * VM map `phys_map'. The difference is the use of the `resource map'
161 * routines to manage page allocation, allowing DVMA addresses to be
162 * allocated and freed from within interrupt routines.
163 *
164 * Note that `phys_map' can still be used to allocate memory-backed pages
165 * in DVMA space.
166 */
167 #if defined(_KERNEL) || defined(_STANDALONE)
168 #ifndef _LOCORE
169
170 extern void delay __P((unsigned int));
171 #define DELAY(n) delay(n)
172
173 extern int cputyp;
174
175 #endif /* _LOCORE */
176 #endif /* _KERNEL */
177
178 /*
179 * Values for the cputyp variable.
180 */
181 #define CPU_SUN4 0
182 #define CPU_SUN4C 1
183 #define CPU_SUN4M 2
184 #define CPU_SUN4U 3
185
186 /*
187 * Shorthand CPU-type macros. Enumerate all eight cases.
188 * Let compiler optimize away code conditional on constants.
189 *
190 * On a sun4 machine, the page size is 8192, while on a sun4c and sun4m
191 * it is 4096. Therefore, in the (SUN4 && (SUN4C || SUN4M)) cases below,
192 * NBPG, PGOFSET and PGSHIFT are defined as variables which are initialized
193 * early in locore.s after the machine type has been detected.
194 *
195 * Note that whenever the macros defined below evaluate to expressions
196 * involving variables, the kernel will perform slighly worse due to the
197 * extra memory references they'll generate.
198 */
199 #define CPU_ISSUN4U (0)
200 #define CPU_ISSUN4MOR4U (CPU_ISSUN4M)
201 #if defined(SUN4M) && defined(SUN4C) && defined(SUN4)
202 # define CPU_ISSUN4M (cputyp == CPU_SUN4M)
203 # define CPU_ISSUN4C (cputyp == CPU_SUN4C)
204 # define CPU_ISSUN4 (cputyp == CPU_SUN4)
205 # define CPU_ISSUN4OR4C (cputyp == CPU_SUN4 || cputyp == CPU_SUN4C)
206 # define CPU_ISSUN4COR4M (cputyp == CPU_SUN4C || cputyp == CPU_SUN4M)
207 # define NBPG nbpg
208 # define PGOFSET pgofset
209 # define PGSHIFT pgshift
210 #elif defined(SUN4M) && defined(SUN4C) && !defined(SUN4)
211 # define CPU_ISSUN4M (cputyp == CPU_SUN4M)
212 # define CPU_ISSUN4C (cputyp == CPU_SUN4C)
213 # define CPU_ISSUN4 (0)
214 # define CPU_ISSUN4OR4C (cputyp == CPU_SUN4C)
215 # define CPU_ISSUN4COR4M (cputyp == CPU_SUN4C || cputyp == CPU_SUN4M)
216 # define NBPG 4096
217 # define PGOFSET (NBPG-1)
218 # define PGSHIFT SUN4CM_PGSHIFT
219 #elif defined(SUN4M) && !defined(SUN4C) && defined(SUN4)
220 # define CPU_ISSUN4M (cputyp == CPU_SUN4M)
221 # define CPU_ISSUN4C (0)
222 # define CPU_ISSUN4 (cputyp == CPU_SUN4)
223 # define CPU_ISSUN4OR4C (cputyp == CPU_SUN4)
224 # define CPU_ISSUN4COR4M (cputyp == CPU_SUN4M)
225 # define NBPG nbpg
226 # define PGOFSET pgofset
227 # define PGSHIFT pgshift
228 #elif defined(SUN4M) && !defined(SUN4C) && !defined(SUN4)
229 # define CPU_ISSUN4M (1)
230 # define CPU_ISSUN4C (0)
231 # define CPU_ISSUN4 (0)
232 # define CPU_ISSUN4OR4C (0)
233 # define CPU_ISSUN4COR4M (1)
234 # define NBPG 4096
235 # define PGOFSET (NBPG-1)
236 # define PGSHIFT SUN4CM_PGSHIFT
237 #elif !defined(SUN4M) && defined(SUN4C) && defined(SUN4)
238 # define CPU_ISSUN4M (0)
239 # define CPU_ISSUN4C (cputyp == CPU_SUN4C)
240 # define CPU_ISSUN4 (cputyp == CPU_SUN4)
241 # define CPU_ISSUN4OR4C (1)
242 # define CPU_ISSUN4COR4M (cputyp == CPU_SUN4C)
243 # define NBPG nbpg
244 # define PGOFSET pgofset
245 # define PGSHIFT pgshift
246 #elif !defined(SUN4M) && defined(SUN4C) && !defined(SUN4)
247 # define CPU_ISSUN4M (0)
248 # define CPU_ISSUN4C (1)
249 # define CPU_ISSUN4 (0)
250 # define CPU_ISSUN4OR4C (1)
251 # define CPU_ISSUN4COR4M (1)
252 # define NBPG 4096
253 # define PGOFSET (NBPG-1)
254 # define PGSHIFT SUN4CM_PGSHIFT
255 #elif !defined(SUN4M) && !defined(SUN4C) && defined(SUN4)
256 # define CPU_ISSUN4M (0)
257 # define CPU_ISSUN4C (0)
258 # define CPU_ISSUN4 (1)
259 # define CPU_ISSUN4OR4C (1)
260 # define CPU_ISSUN4COR4M (0)
261 # define NBPG 8192
262 # define PGOFSET (NBPG-1)
263 # define PGSHIFT SUN4_PGSHIFT
264 #elif !defined(SUN4M) && !defined(SUN4C) && !defined(SUN4)
265 # define CPU_ISSUN4M (cputyp == CPU_SUN4M)
266 # define CPU_ISSUN4C (cputyp == CPU_SUN4C)
267 # define CPU_ISSUN4 (cputyp == CPU_SUN4)
268 # define CPU_ISSUN4OR4C (cputyp == CPU_SUN4 || cputyp == CPU_SUN4C)
269 # define CPU_ISSUN4COR4M (cputyp == CPU_SUN4C || cputyp == CPU_SUN4M)
270 # define NBPG nbpg
271 # define PGOFSET pgofset
272 # define PGSHIFT pgshift
273 #endif
274