param.h revision 1.11.8.2 1 /* $NetBSD: param.h,v 1.11.8.2 1999/12/27 18:33:58 wrstuden 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 * Copyright (c) 1996-1999 Eduardo Horvath
49 *
50 * Redistribution and use in source and binary forms, with or without
51 * modification, are permitted provided that the following conditions
52 * are met:
53 * 1. Redistributions of source code must retain the above copyright
54 * notice, this list of conditions and the following disclaimer.
55 *
56 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
57 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
59 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE
60 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
61 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
62 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
64 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
65 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
66 * SUCH DAMAGE.
67 *
68 */
69
70
71
72 #define _MACHINE sparc64
73 #define MACHINE "sparc64"
74 #ifdef __arch64__
75 #define _MACHINE_ARCH sparc64
76 #define MACHINE_ARCH "sparc64"
77 #define MID_MACHINE MID_SPARC64
78 #else
79 #define _MACHINE_ARCH sparc
80 #define MACHINE_ARCH "sparc"
81 #define MID_MACHINE MID_SPARC
82 #endif
83
84 #ifdef _KERNEL /* XXX */
85 #ifndef _LOCORE /* XXX */
86 #include <machine/cpu.h> /* XXX */
87 #endif /* XXX */
88 #endif /* XXX */
89
90 /*
91 * Round p (pointer or byte index) up to a correctly-aligned value for
92 * the machine's strictest data type. The result is u_int and must be
93 * cast to any desired pointer type.
94 *
95 * ALIGNED_POINTER is a boolean macro that checks whether an address
96 * is valid to fetch data elements of type t from on this architecture.
97 * This does not reflect the optimal alignment, just the possibility
98 * (within reasonable limits).
99 *
100 */
101 #define ALIGNBYTES32 0x7
102 #define ALIGNBYTES64 0xf
103 #ifdef __arch64__
104 #define ALIGNBYTES ALIGNBYTES64
105 #else
106 #define ALIGNBYTES ALIGNBYTES32
107 #endif
108 #define ALIGN(p) (((u_long)(p) + ALIGNBYTES) & ~ALIGNBYTES)
109 #define ALIGN32(p) (((u_long)(p) + ALIGNBYTES32) & ~ALIGNBYTES32)
110 #define ALIGNED_POINTER(p,t) ((((u_long)(p)) & (sizeof(t)-1)) == 0)
111
112
113 /*
114 * The following variables are always defined and initialized (in locore)
115 * so independently compiled modules (e.g. LKMs) can be used irrespective
116 * of the `options SUN4?' combination a particular kernel was configured with.
117 * See also the definitions of NBPG, PGOFSET and PGSHIFT below.
118 */
119 #if (defined(_KERNEL) || defined(_STANDALONE)) && !defined(_LOCORE)
120 extern int nbpg, pgofset, pgshift;
121 #endif
122
123 #define KERNBASE 0xf1000000 /* start of kernel virtual space */
124 #define KERNEND 0xfe000000 /* start of kernel virtual space */
125 #define VM_MAX_KERNEL_BUF ((KERNEND-KERNBASE)/4)
126
127 #define DEF_BSIZE 512
128 #define DEF_BSHIFT 9 /* log2(DEF_BSIZE) */
129 #define BLKDEV_IOSIZE 2048
130 #define MAXPHYS (64 * 1024)
131
132 #ifdef __arch64__
133 /* We get stack overflows w/8K stacks in 64-bit mode */
134 #define SSIZE 2 /* initial stack size in pages */
135 #else
136 #define SSIZE 1
137 #endif
138 #define USPACE (SSIZE*8192)
139
140 /*
141 * Constants related to network buffer management.
142 * MCLBYTES must be no larger than NBPG (the software page size), and,
143 * on machines that exchange pages of input or output buffers with mbuf
144 * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
145 * of the hardware page size.
146 */
147 #define MSIZE 128 /* size of an mbuf */
148 #define MCLBYTES 2048 /* enough for whole Ethernet packet */
149 #define MCLSHIFT 11 /* log2(MCLBYTES) */
150 #define MCLOFSET (MCLBYTES - 1)
151
152 #if defined(_KERNEL) && !defined(_LKM)
153 #include "opt_gateway.h"
154 #include "opt_non_po2_blocks.h"
155 #endif /* _KERNEL && ! _LKM */
156
157 #ifndef NMBCLUSTERS
158 #ifdef GATEWAY
159 #define NMBCLUSTERS 512 /* map size, max cluster allocation */
160 #else
161 #define NMBCLUSTERS 256 /* map size, max cluster allocation */
162 #endif
163 #endif
164
165 #define MSGBUFSIZE NBPG
166
167 /*
168 * Size of kernel malloc arena in NBPG-sized logical pages.
169 */
170 #ifndef NKMEMCLUSTERS
171 #define NKMEMCLUSTERS (6 * 1024 * 1024 / NBPG)
172 #endif
173
174 /* pages ("clicks") to disk blocks */
175 #define ctod(x, sh) ((x) << (PGSHIFT - (sh)))
176 #define dtoc(x, sh) ((x) >> (PGSHIFT - (sh)))
177
178 /* pages to bytes */
179 #define ctob(x) ((x) << PGSHIFT)
180 #define btoc(x) (((x) + PGOFSET) >> PGSHIFT)
181
182 /* bytes to disk blocks */
183 #if defined(_LKM) || defined(NON_PO2_BLOCKS)
184 #define dbtob(x, sh) (((sh) >= 0) ? ((x) << (sh)) : ((x) * (-sh)))
185 #define btodb(x, sh) (((sh) >= 0) ? ((x) >> (sh)) : ((x) / (-sh)))
186 #define blocksize(sh) (((sh) >= 0) ? (1 << (sh)) : (-sh))
187 #else
188 #define dbtob(x, sh) ((x) << (sh))
189 #define btodb(x, sh) ((x) >> (sh))
190 #define blocksize(sh) (((sh) >= 0) ? (1 << (sh)) : (0))
191 #endif
192
193 /*
194 * Map a ``block device block'' to a file system block.
195 * This should be device dependent, and should use the bsize
196 * field from the disk label.
197 * For now though just use DEV_BSIZE.
198 */
199 #define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE / DEV_BSIZE))
200
201 /*
202 * dvmamap manages a range of DVMA addresses intended to create double
203 * mappings of physical memory. In a way, `dvmamap' is a submap of the
204 * VM map `phys_map'. The difference is the use of the `resource map'
205 * routines to manage page allocation, allowing DVMA addresses to be
206 * allocated and freed from within interrupt routines.
207 *
208 * Note that `phys_map' can still be used to allocate memory-backed pages
209 * in DVMA space.
210 */
211 #ifdef _KERNEL
212 #ifndef _LOCORE
213 extern vaddr_t dvma_base;
214 extern vaddr_t dvma_end;
215 extern struct map *dvmamap;
216 /*
217 * The dvma resource map is defined in page units, which are numbered 1 to N.
218 * Use these macros to convert to/from virtual addresses.
219 */
220 #define rctov(n) (ctob(((n)-1))+dvma_base)
221 #define vtorc(v) ((btoc((v)-dvma_base))+1)
222
223 extern caddr_t kdvma_mapin __P((caddr_t, int, int));
224 extern caddr_t dvma_malloc __P((size_t, void *, int));
225 extern void dvma_free __P((caddr_t, size_t, void *));
226
227 extern void delay __P((unsigned int));
228 #define DELAY(n) delay(n)
229
230 extern int cputyp;
231 extern int cpumod;
232 extern int mmumod;
233
234 #endif /* _LOCORE */
235 #endif /* _KERNEL */
236
237 /*
238 * Values for the cputyp variable.
239 */
240 #define CPU_SUN4 0
241 #define CPU_SUN4C 1
242 #define CPU_SUN4M 2
243 #define CPU_SUN4U 3
244
245 /*
246 * Shorthand CPU-type macros. Enumerate all eight cases.
247 * Let compiler optimize away code conditional on constants.
248 *
249 * On a sun4 machine, the page size is 8192, while on a sun4c and sun4m
250 * it is 4096. Therefore, in the (SUN4 && (SUN4C || SUN4M)) cases below,
251 * NBPG, PGOFSET and PGSHIFT are defined as variables which are initialized
252 * early in locore.s after the machine type has been detected.
253 *
254 * Note that whenever the macros defined below evaluate to expressions
255 * involving variables, the kernel will perform slighly worse due to the
256 * extra memory references they'll generate.
257 */
258
259 #define CPU_ISSUN4M (0)
260 #define CPU_ISSUN4C (0)
261 #define CPU_ISSUN4 (0)
262 #define CPU_ISSUN4OR4C (0)
263 #define CPU_ISSUN4COR4M (0)
264 #define NBPG 8192 /* bytes/page */
265 #define PGOFSET (NBPG-1) /* byte offset into page */
266 #define PGSHIFT 13 /* log2(NBPG) */
267