param.h revision 1.22 1 /* $NetBSD: param.h,v 1.22 1996/03/04 05:04:38 cgd 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 /*
48 * Machine dependent constants for Sun-4c (SPARCstation)
49 */
50 #define _MACHINE sparc
51 #define MACHINE "sparc"
52 #define _MACHINE_ARCH sparc
53 #define MACHINE_ARCH "sparc"
54 #define MID_MACHINE MID_SPARC
55
56 #ifdef _KERNEL /* XXX */
57 #ifndef _LOCORE /* XXX */
58 #include <machine/cpu.h> /* XXX */
59 #endif /* XXX */
60 #endif /* XXX */
61
62 #if defined(SUN4M)
63 /*
64 * The sun4m supports multiple CPUs. Currently, we only support uniprocessor
65 * operations, but we map in the interrupt registers for everybody just for
66 * kicks. This constant affects the `fixed' virtual device addresses
67 * defined in <sparc/vaddrs.h>.
68 */
69 #define NCPU_MAX 4 /* XXX: are there 4m's with > 4 CPUs? */
70 #endif
71
72 /*
73 * Round p (pointer or byte index) up to a correctly-aligned value for
74 * the machine's strictest data type. The result is u_int and must be
75 * cast to any desired pointer type.
76 */
77 #define ALIGNBYTES 7
78 #define ALIGN(p) (((u_int)(p) + ALIGNBYTES) & ~ALIGNBYTES)
79
80 #define SUN4_PGSHIFT 13 /* for a sun4 machine */
81 #define SUN4CM_PGSHIFT 12 /* for a sun4c or sun4m machine */
82
83 /*
84 * Three possible cases:
85 * sun4 only 8192 bytes/page
86 * sun4c/sun4m only 4096 bytes/page
87 * sun4/sun4c/sun4m either of the above
88 *
89 * In the later case NBPG, PGOFSET, and PGSHIFT are encoded in variables
90 * initialized early in locore.s. Since they are variables, rather than
91 * simple constants, the kernel will not perform slighly worse.
92 */
93 #if defined(SUN4) && !defined(SUN4C) && !defined(SUN4M)
94 #define NBPG 8192 /* bytes/page */
95 #define PGOFSET (NBPG-1) /* byte offset into page */
96 #define PGSHIFT SUN4_PGSHIFT /* log2(NBPG) */
97 #endif
98 #if !defined(SUN4) && (defined(SUN4C) || defined(SUN4M))
99 #define NBPG 4096 /* bytes/page */
100 #define PGOFSET (NBPG-1) /* byte offset into page */
101 #define PGSHIFT SUN4CM_PGSHIFT /* log2(NBPG) */
102 #endif
103 #if defined(SUN4) && (defined(SUN4C) || defined(SUN4M))
104 #if defined(_KERNEL) && !defined(_LOCORE)
105 extern int nbpg, pgofset, pgshift;
106 #endif
107 #define NBPG nbpg /* bytes/page */
108 #define PGOFSET pgofset /* byte offset into page */
109 #define PGSHIFT pgshift /* log2(NBPG) */
110 #endif
111
112 #define KERNBASE 0xf8000000 /* start of kernel virtual space */
113 #define KERNTEXTOFF 0xf8004000 /* start of kernel text */
114
115 #define DEV_BSIZE 512
116 #define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */
117 #define BLKDEV_IOSIZE 2048
118 #define MAXPHYS (64 * 1024)
119
120 #define CLSIZE 1
121 #define CLSIZELOG2 0
122
123 /* NOTE: SSIZE must be multiple of CLSIZE */
124 #define SSIZE 1 /* initial stack size in pages */
125 #define USPACE 8192
126
127 /*
128 * Constants related to network buffer management.
129 * MCLBYTES must be no larger than CLBYTES (the software page size), and,
130 * on machines that exchange pages of input or output buffers with mbuf
131 * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
132 * of the hardware page size.
133 */
134 #define MSIZE 128 /* size of an mbuf */
135 #define MCLBYTES 2048 /* enough for whole Ethernet packet */
136 #define MCLSHIFT 11 /* log2(MCLBYTES) */
137 #define MCLOFSET (MCLBYTES - 1)
138
139 #ifndef NMBCLUSTERS
140 #ifdef GATEWAY
141 #define NMBCLUSTERS 512 /* map size, max cluster allocation */
142 #else
143 #define NMBCLUSTERS 256 /* map size, max cluster allocation */
144 #endif
145 #endif
146
147 /*
148 * Size of kernel malloc arena in CLBYTES-sized logical pages.
149 */
150 #ifndef NKMEMCLUSTERS
151 #define NKMEMCLUSTERS (6 * 1024 * 1024 / CLBYTES)
152 #endif
153
154 /* pages ("clicks") to disk blocks */
155 #define ctod(x) ((x) << (PGSHIFT - DEV_BSHIFT))
156 #define dtoc(x) ((x) >> (PGSHIFT - DEV_BSHIFT))
157
158 /* pages to bytes */
159 #define ctob(x) ((x) << PGSHIFT)
160 #define btoc(x) (((x) + PGOFSET) >> PGSHIFT)
161
162 /* bytes to disk blocks */
163 #define btodb(x) ((x) >> DEV_BSHIFT)
164 #define dbtob(x) ((x) << DEV_BSHIFT)
165
166 /*
167 * Map a ``block device block'' to a file system block.
168 * This should be device dependent, and should use the bsize
169 * field from the disk label.
170 * For now though just use DEV_BSIZE.
171 */
172 #define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE / DEV_BSIZE))
173
174 /*
175 * dvmamap manages a range of DVMA addresses intended to create double
176 * mappings of physical memory. In a way, `dvmamap' is a submap of the
177 * VM map `phys_map'. The difference is the use of the `resource map'
178 * routines to manage page allocation, allowing DVMA addresses to be
179 * allocated and freed from within interrupt routines.
180 *
181 * Note that `phys_map' can still be used to allocate memory-backed pages
182 * in DVMA space.
183 */
184 #ifdef _KERNEL
185 #ifndef _LOCORE
186 extern vm_offset_t dvma_base;
187 extern vm_offset_t dvma_end;
188 extern struct map *dvmamap;
189 /*
190 * The dvma resource map is defined in page units, which are numbered 1 to N.
191 * Use these macros to convert to/from virtual addresses.
192 */
193 #define rctov(n) (ctob(((n)-1))+dvma_base)
194 #define vtorc(v) ((btoc((v)-dvma_base))+1)
195
196 extern caddr_t kdvma_mapin __P((caddr_t, int, int));
197 extern caddr_t dvma_malloc __P((size_t, void *, int));
198 extern void dvma_free __P((caddr_t, size_t, void *));
199
200
201 extern void delay __P((unsigned int));
202 #define DELAY(n) delay(n)
203
204 extern int cputyp;
205 extern int cpumod;
206 #endif /* _LOCORE */
207 #endif /* _KERNEL */
208
209 /*
210 * Values for the cputyp variable.
211 */
212 #define CPU_SUN4 0
213 #define CPU_SUN4C 1
214 #define CPU_SUN4M 2
215 /*
216 * Values for cpumod (cpu model) variable. XXX currently valid only for sun4
217 */
218 #define SUN4_100 0x22
219 #define SUN4_200 0x21
220 #define SUN4_300 0x23
221 #define SUN4_400 0x24
222
223 /*
224 * Shorthand CPU-type macros. Enumerate all eight cases.
225 * Let compiler optimize away code conditionals on constants.
226 */
227 #if defined(SUN4M) && defined(SUN4C) && defined(SUN4)
228 # define CPU_ISSUN4M (cputyp == CPU_SUN4M)
229 # define CPU_ISSUN4C (cputyp == CPU_SUN4C)
230 # define CPU_ISSUN4 (cputyp == CPU_SUN4)
231 # define CPU_ISSUN4OR4C (cputyp == CPU_SUN4 || cputyp == CPU_SUN4C)
232 # define CPU_ISSUN4COR4M (cputyp == CPU_SUN4C || cputyp == CPU_SUN4M)
233 #elif defined(SUN4M) && defined(SUN4C) && !defined(SUN4)
234 # define CPU_ISSUN4M (cputyp == CPU_SUN4M)
235 # define CPU_ISSUN4C (cputyp == CPU_SUN4C)
236 # define CPU_ISSUN4 (0)
237 # define CPU_ISSUN4OR4C (cputyp == CPU_SUN4C)
238 # define CPU_ISSUN4COR4M (cputyp == CPU_SUN4C || cputyp == CPU_SUN4M)
239 #elif defined(SUN4M) && !defined(SUN4C) && defined(SUN4)
240 # define CPU_ISSUN4M (cputyp == CPU_SUN4M)
241 # define CPU_ISSUN4C (0)
242 # define CPU_ISSUN4 (cputyp == CPU_SUN4)
243 # define CPU_ISSUN4OR4C (cputyp == CPU_SUN4)
244 # define CPU_ISSUN4COR4M (cputyp == CPU_SUN4M)
245 #elif defined(SUN4M) && !defined(SUN4C) && !defined(SUN4)
246 # define CPU_ISSUN4M (1)
247 # define CPU_ISSUN4C (0)
248 # define CPU_ISSUN4 (0)
249 # define CPU_ISSUN4OR4C (0)
250 # define CPU_ISSUN4COR4M (1)
251 #elif !defined(SUN4M) && defined(SUN4C) && defined(SUN4)
252 # define CPU_ISSUN4M (0)
253 # define CPU_ISSUN4C (cputyp == CPU_SUN4C)
254 # define CPU_ISSUN4 (cputyp == CPU_SUN4)
255 # define CPU_ISSUN4OR4C (1)
256 # define CPU_ISSUN4COR4M (cputyp == CPU_SUN4C)
257 #elif !defined(SUN4M) && defined(SUN4C) && !defined(SUN4)
258 # define CPU_ISSUN4M (0)
259 # define CPU_ISSUN4C (1)
260 # define CPU_ISSUN4 (0)
261 # define CPU_ISSUN4OR4C (1)
262 # define CPU_ISSUN4COR4M (1)
263 #elif !defined(SUN4M) && !defined(SUN4C) && defined(SUN4)
264 # define CPU_ISSUN4M (0)
265 # define CPU_ISSUN4C (0)
266 # define CPU_ISSUN4 (1)
267 # define CPU_ISSUN4OR4C (1)
268 # define CPU_ISSUN4COR4M (0)
269 #elif !defined(SUN4M) && !defined(SUN4C) && !defined(SUN4)
270 # define CPU_ISSUN4M (0)
271 # define CPU_ISSUN4C (0)
272 # define CPU_ISSUN4 (0)
273 # define CPU_ISSUN4OR4C (0)
274 # define CPU_ISSUN4COR4M (0)
275 #endif
276