param.h revision 1.47.6.3 1 1.47.6.3 nathanw /* $NetBSD: param.h,v 1.47.6.3 2002/04/01 07:43:29 nathanw Exp $ */
2 1.47.6.2 nathanw /*-
3 1.47.6.2 nathanw * Copyright (c) 1990 The Regents of the University of California.
4 1.47.6.2 nathanw * All rights reserved.
5 1.47.6.2 nathanw *
6 1.47.6.2 nathanw * This code is derived from software contributed to Berkeley by
7 1.47.6.2 nathanw * William Jolitz.
8 1.47.6.2 nathanw *
9 1.47.6.2 nathanw * Redistribution and use in source and binary forms, with or without
10 1.47.6.2 nathanw * modification, are permitted provided that the following conditions
11 1.47.6.2 nathanw * are met:
12 1.47.6.2 nathanw * 1. Redistributions of source code must retain the above copyright
13 1.47.6.2 nathanw * notice, this list of conditions and the following disclaimer.
14 1.47.6.2 nathanw * 2. Redistributions in binary form must reproduce the above copyright
15 1.47.6.2 nathanw * notice, this list of conditions and the following disclaimer in the
16 1.47.6.2 nathanw * documentation and/or other materials provided with the distribution.
17 1.47.6.2 nathanw * 3. All advertising materials mentioning features or use of this software
18 1.47.6.2 nathanw * must display the following acknowledgement:
19 1.47.6.2 nathanw * This product includes software developed by the University of
20 1.47.6.2 nathanw * California, Berkeley and its contributors.
21 1.47.6.2 nathanw * 4. Neither the name of the University nor the names of its contributors
22 1.47.6.2 nathanw * may be used to endorse or promote products derived from this software
23 1.47.6.2 nathanw * without specific prior written permission.
24 1.47.6.2 nathanw *
25 1.47.6.2 nathanw * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26 1.47.6.2 nathanw * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 1.47.6.2 nathanw * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 1.47.6.2 nathanw * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 1.47.6.2 nathanw * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 1.47.6.2 nathanw * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 1.47.6.2 nathanw * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 1.47.6.2 nathanw * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 1.47.6.2 nathanw * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 1.47.6.2 nathanw * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 1.47.6.2 nathanw * SUCH DAMAGE.
36 1.47.6.2 nathanw *
37 1.47.6.2 nathanw * @(#)param.h 5.8 (Berkeley) 6/28/91
38 1.47.6.2 nathanw */
39 1.47.6.2 nathanw
40 1.47.6.2 nathanw #ifndef _VAX_PARAM_H_
41 1.47.6.2 nathanw #define _VAX_PARAM_H_
42 1.47.6.2 nathanw
43 1.47.6.2 nathanw /*
44 1.47.6.2 nathanw * Machine dependent constants for VAX.
45 1.47.6.2 nathanw */
46 1.47.6.2 nathanw
47 1.47.6.2 nathanw #define _MACHINE vax
48 1.47.6.2 nathanw #define MACHINE "vax"
49 1.47.6.2 nathanw #define _MACHINE_ARCH vax
50 1.47.6.2 nathanw #define MACHINE_ARCH "vax"
51 1.47.6.2 nathanw #define MID_MACHINE MID_VAX
52 1.47.6.2 nathanw
53 1.47.6.2 nathanw /*
54 1.47.6.2 nathanw * Round p (pointer or byte index) up to a correctly-aligned value
55 1.47.6.2 nathanw * for all data types (int, long, ...). The result is u_int and
56 1.47.6.2 nathanw * must be cast to any desired pointer type.
57 1.47.6.2 nathanw *
58 1.47.6.2 nathanw * ALIGNED_POINTER is a boolean macro that checks whether an address
59 1.47.6.2 nathanw * is valid to fetch data elements of type t from on this architecture.
60 1.47.6.2 nathanw * This does not reflect the optimal alignment, just the possibility
61 1.47.6.2 nathanw * (within reasonable limits).
62 1.47.6.2 nathanw *
63 1.47.6.2 nathanw */
64 1.47.6.2 nathanw
65 1.47.6.2 nathanw #define ALIGNBYTES (sizeof(int) - 1)
66 1.47.6.2 nathanw #define ALIGN(p) (((u_int)(p) + ALIGNBYTES) &~ ALIGNBYTES)
67 1.47.6.2 nathanw #define ALIGNED_POINTER(p,t) ((((u_long)(p)) & (sizeof(t)-1)) == 0)
68 1.47.6.2 nathanw
69 1.47.6.2 nathanw #define PGSHIFT 12 /* LOG2(NBPG) */
70 1.47.6.2 nathanw #define NBPG (1 << PGSHIFT) /* (1 << PGSHIFT) bytes/page */
71 1.47.6.2 nathanw #define PGOFSET (NBPG - 1) /* byte offset into page */
72 1.47.6.2 nathanw
73 1.47.6.2 nathanw #define VAX_PGSHIFT 9
74 1.47.6.2 nathanw #define VAX_NBPG (1 << VAX_PGSHIFT)
75 1.47.6.2 nathanw #define VAX_PGOFSET (VAX_NBPG - 1)
76 1.47.6.2 nathanw #define VAX_NPTEPG (VAX_NBPG / 4)
77 1.47.6.2 nathanw
78 1.47.6.2 nathanw #define KERNBASE 0x80000000 /* start of kernel virtual */
79 1.47.6.2 nathanw
80 1.47.6.2 nathanw #define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */
81 1.47.6.2 nathanw #define DEV_BSIZE (1 << DEV_BSHIFT)
82 1.47.6.2 nathanw
83 1.47.6.2 nathanw #define BLKDEV_IOSIZE 2048
84 1.47.6.2 nathanw #define MAXPHYS (64 * 1024) /* max raw I/O transfer size */
85 1.47.6.2 nathanw #define MAXBSIZE 0x4000 /* max FS block size - XXX */
86 1.47.6.2 nathanw
87 1.47.6.2 nathanw #define UPAGES 2 /* pages of u-area */
88 1.47.6.2 nathanw #define USPACE (NBPG*UPAGES)
89 1.47.6.2 nathanw #define REDZONEADDR (VAX_NBPG*3) /* Must be > sizeof(struct user) */
90 1.47.6.2 nathanw
91 1.47.6.2 nathanw #ifndef MSGBUFSIZE
92 1.47.6.2 nathanw #define MSGBUFSIZE NBPG /* default message buffer size */
93 1.47.6.2 nathanw #endif
94 1.47.6.2 nathanw
95 1.47.6.2 nathanw /*
96 1.47.6.3 nathanw * KVA is very tight on vax, reduce the amount of KVA used by pipe
97 1.47.6.3 nathanw * "direct" write code to reasonably low value.
98 1.47.6.3 nathanw */
99 1.47.6.3 nathanw #ifndef PIPE_DIRECT_CHUNK
100 1.47.6.3 nathanw #define PIPE_DIRECT_CHUNK 65536
101 1.47.6.3 nathanw #endif
102 1.47.6.3 nathanw
103 1.47.6.3 nathanw /*
104 1.47.6.2 nathanw * Constants related to network buffer management.
105 1.47.6.2 nathanw * MCLBYTES must be no larger than NBPG (the software page size), and,
106 1.47.6.2 nathanw * on machines that exchange pages of input or output buffers with mbuf
107 1.47.6.2 nathanw * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
108 1.47.6.2 nathanw * of the hardware page size.
109 1.47.6.2 nathanw */
110 1.47.6.2 nathanw #define MSIZE 256 /* size of an mbuf */
111 1.47.6.2 nathanw
112 1.47.6.2 nathanw #ifndef MCLSHIFT
113 1.47.6.2 nathanw #define MCLSHIFT 11 /* convert bytes to m_buf clusters */
114 1.47.6.2 nathanw /* 2K cluster can hold Ether frame */
115 1.47.6.2 nathanw #endif /* MCLSHIFT */
116 1.47.6.2 nathanw
117 1.47.6.2 nathanw #define MCLBYTES (1 << MCLSHIFT) /* size of a m_buf cluster */
118 1.47.6.2 nathanw
119 1.47.6.2 nathanw #ifndef NMBCLUSTERS
120 1.47.6.2 nathanw #if defined(_KERNEL_OPT)
121 1.47.6.2 nathanw #include "opt_gateway.h"
122 1.47.6.2 nathanw #endif
123 1.47.6.2 nathanw
124 1.47.6.2 nathanw #ifdef GATEWAY
125 1.47.6.2 nathanw #define NMBCLUSTERS 512 /* map size, max cluster allocation */
126 1.47.6.2 nathanw #else
127 1.47.6.2 nathanw #define NMBCLUSTERS 256 /* map size, max cluster allocation */
128 1.47.6.2 nathanw #endif
129 1.47.6.2 nathanw #endif
130 1.47.6.2 nathanw
131 1.47.6.2 nathanw /*
132 1.47.6.2 nathanw * Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized
133 1.47.6.2 nathanw * logical pages.
134 1.47.6.2 nathanw */
135 1.47.6.2 nathanw #define NKMEMPAGES_MIN_DEFAULT ((4 * 1024 * 1024) >> PAGE_SHIFT)
136 1.47.6.2 nathanw #define NKMEMPAGES_MAX_DEFAULT ((4 * 1024 * 1024) >> PAGE_SHIFT)
137 1.47.6.2 nathanw
138 1.47.6.2 nathanw /*
139 1.47.6.2 nathanw * Some macros for units conversion
140 1.47.6.2 nathanw */
141 1.47.6.2 nathanw
142 1.47.6.2 nathanw /* pages ("clicks") to disk blocks */
143 1.47.6.2 nathanw #define ctod(x) ((x) << (PGSHIFT - DEV_BSHIFT))
144 1.47.6.2 nathanw #define dtoc(x) ((x) >> (PGSHIFT - DEV_BSHIFT))
145 1.47.6.2 nathanw
146 1.47.6.2 nathanw /* clicks to bytes */
147 1.47.6.2 nathanw #define ctob(x) ((x) << PGSHIFT)
148 1.47.6.2 nathanw #define btoc(x) (((unsigned)(x) + PGOFSET) >> PGSHIFT)
149 1.47.6.2 nathanw #define btop(x) (((unsigned)(x)) >> PGSHIFT)
150 1.47.6.2 nathanw
151 1.47.6.2 nathanw /* bytes to disk blocks */
152 1.47.6.2 nathanw #define btodb(x) ((x) >> DEV_BSHIFT)
153 1.47.6.2 nathanw #define dbtob(x) ((x) << DEV_BSHIFT)
154 1.47.6.2 nathanw
155 1.47.6.2 nathanw /* MD conversion macros */
156 1.47.6.2 nathanw #define vax_btoc(x) (((unsigned)(x) + VAX_PGOFSET) >> VAX_PGSHIFT)
157 1.47.6.2 nathanw #define vax_btop(x) (((unsigned)(x)) >> VAX_PGSHIFT)
158 1.47.6.2 nathanw
159 1.47.6.2 nathanw /*
160 1.47.6.2 nathanw * Map a ``block device block'' to a file system block.
161 1.47.6.2 nathanw * This should be device dependent, and will be if we
162 1.47.6.2 nathanw * add an entry to cdevsw/bdevsw for that purpose.
163 1.47.6.2 nathanw * For now though just use DEV_BSIZE.
164 1.47.6.2 nathanw */
165 1.47.6.2 nathanw
166 1.47.6.2 nathanw #define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
167 1.47.6.2 nathanw
168 1.47.6.2 nathanw #ifdef _KERNEL
169 1.47.6.2 nathanw #include <machine/intr.h>
170 1.47.6.2 nathanw
171 1.47.6.2 nathanw /* Prototype needed for delay() */
172 1.47.6.2 nathanw #ifndef _LOCORE
173 1.47.6.2 nathanw void delay __P((int));
174 1.47.6.2 nathanw /* inline macros used inside kernel */
175 1.47.6.2 nathanw #include <machine/macros.h>
176 1.47.6.2 nathanw #endif
177 1.47.6.2 nathanw
178 1.47.6.2 nathanw #define DELAY(x) delay(x)
179 1.47.6.2 nathanw #endif /* _KERNEL */
180 1.47.6.2 nathanw
181 1.47.6.2 nathanw #endif /* _VAX_PARAM_H_ */
182