param.h revision 1.2.2.2 1 1.2.2.2 ragge /*-
2 1.2.2.2 ragge * Copyright (c) 1990 The Regents of the University of California.
3 1.2.2.2 ragge * All rights reserved.
4 1.2.2.2 ragge *
5 1.2.2.2 ragge * Modified for VAX 940213/Ragge
6 1.2.2.2 ragge *
7 1.2.2.2 ragge * This code is derived from software contributed to Berkeley by
8 1.2.2.2 ragge * William Jolitz.
9 1.2.2.2 ragge *
10 1.2.2.2 ragge * Redistribution and use in source and binary forms, with or without
11 1.2.2.2 ragge * modification, are permitted provided that the following conditions
12 1.2.2.2 ragge * are met:
13 1.2.2.2 ragge * 1. Redistributions of source code must retain the above copyright
14 1.2.2.2 ragge * notice, this list of conditions and the following disclaimer.
15 1.2.2.2 ragge * 2. Redistributions in binary form must reproduce the above copyright
16 1.2.2.2 ragge * notice, this list of conditions and the following disclaimer in the
17 1.2.2.2 ragge * documentation and/or other materials provided with the distribution.
18 1.2.2.2 ragge * 3. All advertising materials mentioning features or use of this software
19 1.2.2.2 ragge * must display the following acknowledgement:
20 1.2.2.2 ragge * This product includes software developed by the University of
21 1.2.2.2 ragge * California, Berkeley and its contributors.
22 1.2.2.2 ragge * 4. Neither the name of the University nor the names of its contributors
23 1.2.2.2 ragge * may be used to endorse or promote products derived from this software
24 1.2.2.2 ragge * without specific prior written permission.
25 1.2.2.2 ragge *
26 1.2.2.2 ragge * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 1.2.2.2 ragge * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 1.2.2.2 ragge * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 1.2.2.2 ragge * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 1.2.2.2 ragge * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 1.2.2.2 ragge * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 1.2.2.2 ragge * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 1.2.2.2 ragge * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 1.2.2.2 ragge * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 1.2.2.2 ragge * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 1.2.2.2 ragge * SUCH DAMAGE.
37 1.2.2.2 ragge *
38 1.2.2.2 ragge * from: @(#)param.h 5.8 (Berkeley) 6/28/91
39 1.2.2.2 ragge * $Id: param.h,v 1.2.2.2 1994/08/16 23:41:55 ragge Exp $
40 1.2.2.2 ragge */
41 1.2.2.2 ragge
42 1.2.2.2 ragge #ifndef PARAM_H
43 1.2.2.2 ragge #define PARAM_H
44 1.2.2.2 ragge
45 1.2.2.2 ragge #include "psl.h"
46 1.2.2.2 ragge
47 1.2.2.2 ragge /*
48 1.2.2.2 ragge * Machine dependent constants for VAX.
49 1.2.2.2 ragge */
50 1.2.2.2 ragge
51 1.2.2.2 ragge #define MACHINE "vax"
52 1.2.2.2 ragge #define MID_MACHINE MID_VAX
53 1.2.2.2 ragge #define UNIX "vmunix"
54 1.2.2.2 ragge
55 1.2.2.2 ragge /*
56 1.2.2.2 ragge * Round p (pointer or byte index) up to a correctly-aligned value
57 1.2.2.2 ragge * for all data types (int, long, ...). The result is u_int and
58 1.2.2.2 ragge * must be cast to any desired pointer type.
59 1.2.2.2 ragge */
60 1.2.2.2 ragge
61 1.2.2.2 ragge #define ALIGNBYTES (sizeof(int) - 1)
62 1.2.2.2 ragge #define ALIGN(p) (((u_int)(p) + ALIGNBYTES) &~ ALIGNBYTES)
63 1.2.2.2 ragge
64 1.2.2.2 ragge #define PGSHIFT 9 /* LOG2(NBPG) */
65 1.2.2.2 ragge #define NBPG (1<<PGSHIFT) /* (1 << PGSHIFT) bytes/page */
66 1.2.2.2 ragge #define PGOFSET (NBPG-1) /* byte offset into page */
67 1.2.2.2 ragge #define NPTEPG (NBPG/(sizeof (struct pte)))
68 1.2.2.2 ragge
69 1.2.2.2 ragge #define KERNBASE 0x80000000 /* start of kernel virtual */
70 1.2.2.2 ragge #define BTOPKERNBASE ((u_long)KERNBASE >> PGSHIFT)
71 1.2.2.2 ragge
72 1.2.2.2 ragge #define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */
73 1.2.2.2 ragge #define DEV_BSIZE (1 << DEV_BSHIFT)
74 1.2.2.2 ragge
75 1.2.2.2 ragge #define BLKDEV_IOSIZE 2048
76 1.2.2.2 ragge #define MAXPHYS (63 * 1024) /* max raw I/O transfer size */
77 1.2.2.2 ragge
78 1.2.2.2 ragge #define CLSIZELOG2 1
79 1.2.2.2 ragge #define CLSIZE 2
80 1.2.2.2 ragge
81 1.2.2.2 ragge /* NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE */
82 1.2.2.2 ragge #define SSIZE 4 /* initial stack size/NBPG */
83 1.2.2.2 ragge #define SINCR 4 /* increment of stack/NBPG */
84 1.2.2.2 ragge
85 1.2.2.2 ragge #define UPAGES 16 /* pages of u-area */
86 1.2.2.2 ragge
87 1.2.2.2 ragge /*
88 1.2.2.2 ragge * Constants related to network buffer management.
89 1.2.2.2 ragge * MCLBYTES must be no larger than CLBYTES (the software page size), and,
90 1.2.2.2 ragge * on machines that exchange pages of input or output buffers with mbuf
91 1.2.2.2 ragge * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
92 1.2.2.2 ragge * of the hardware page size.
93 1.2.2.2 ragge */
94 1.2.2.2 ragge
95 1.2.2.2 ragge #ifndef MSIZE
96 1.2.2.2 ragge #define MSIZE 128 /* size of an mbuf */
97 1.2.2.2 ragge #endif /* MSIZE */
98 1.2.2.2 ragge
99 1.2.2.2 ragge #ifndef MCLSHIFT
100 1.2.2.2 ragge #define MCLSHIFT 10 /* convert bytes to m_buf clusters */
101 1.2.2.2 ragge #endif /* MCLSHIFT */
102 1.2.2.2 ragge #define MCLBYTES (1 << MCLSHIFT) /* size of an m_buf cluster */
103 1.2.2.2 ragge #define MCLOFSET (MCLBYTES - 1) /* offset within an m_buf cluster */
104 1.2.2.2 ragge
105 1.2.2.2 ragge #ifndef NMBCLUSTERS
106 1.2.2.2 ragge #ifdef GATEWAY
107 1.2.2.2 ragge #define NMBCLUSTERS 512 /* map size, max cluster allocation */
108 1.2.2.2 ragge #else
109 1.2.2.2 ragge #define NMBCLUSTERS 256 /* map size, max cluster allocation */
110 1.2.2.2 ragge #endif /* GATEWAY */
111 1.2.2.2 ragge #endif /* NMBCLUSTERS */
112 1.2.2.2 ragge
113 1.2.2.2 ragge /*
114 1.2.2.2 ragge * Size of kernel malloc arena in CLBYTES-sized logical pages
115 1.2.2.2 ragge */
116 1.2.2.2 ragge
117 1.2.2.2 ragge #ifndef NKMEMCLUSTERS
118 1.2.2.2 ragge #define NKMEMCLUSTERS (512*1024/CLBYTES)
119 1.2.2.2 ragge #endif
120 1.2.2.2 ragge
121 1.2.2.2 ragge /*
122 1.2.2.2 ragge * Some macros for units conversion
123 1.2.2.2 ragge */
124 1.2.2.2 ragge
125 1.2.2.2 ragge /* Core clicks (512 bytes) to segments and vice versa */
126 1.2.2.2 ragge
127 1.2.2.2 ragge #define ctos(x) (x)
128 1.2.2.2 ragge #define stoc(x) (x)
129 1.2.2.2 ragge
130 1.2.2.2 ragge /* Core clicks (512 bytes) to disk blocks */
131 1.2.2.2 ragge
132 1.2.2.2 ragge #define ctod(x) ((x)<<(PGSHIFT-DEV_BSHIFT))
133 1.2.2.2 ragge #define dtoc(x) ((x)>>(PGSHIFT-DEV_BSHIFT))
134 1.2.2.2 ragge #define dtob(x) ((x)<<DEV_BSHIFT)
135 1.2.2.2 ragge
136 1.2.2.2 ragge /* clicks to bytes */
137 1.2.2.2 ragge
138 1.2.2.2 ragge #define ctob(x) ((x)<<PGSHIFT)
139 1.2.2.2 ragge
140 1.2.2.2 ragge /* bytes to clicks */
141 1.2.2.2 ragge
142 1.2.2.2 ragge #define btoc(x) (((unsigned)(x)+(NBPG-1))>>PGSHIFT)
143 1.2.2.2 ragge
144 1.2.2.2 ragge #define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \
145 1.2.2.2 ragge ((unsigned)(bytes) >> DEV_BSHIFT)
146 1.2.2.2 ragge #define dbtob(db) /* calculates (db * DEV_BSIZE) */ \
147 1.2.2.2 ragge ((unsigned)(db) << DEV_BSHIFT)
148 1.2.2.2 ragge
149 1.2.2.2 ragge /*
150 1.2.2.2 ragge * Map a ``block device block'' to a file system block.
151 1.2.2.2 ragge * This should be device dependent, and will be if we
152 1.2.2.2 ragge * add an entry to cdevsw/bdevsw for that purpose.
153 1.2.2.2 ragge * For now though just use DEV_BSIZE.
154 1.2.2.2 ragge */
155 1.2.2.2 ragge
156 1.2.2.2 ragge #define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
157 1.2.2.2 ragge
158 1.2.2.2 ragge /*
159 1.2.2.2 ragge * Mach derived conversion macros
160 1.2.2.2 ragge */
161 1.2.2.2 ragge
162 1.2.2.2 ragge #define vax_round_pdr(x) ((((unsigned)(x)) + NBPDR - 1) & ~(NBPDR-1))
163 1.2.2.2 ragge #define vax_trunc_pdr(x) ((unsigned)(x) & ~(NBPDR-1))
164 1.2.2.2 ragge #define vax_round_page(x) ((((unsigned)(x)) + NBPG - 1) & ~(NBPG-1))
165 1.2.2.2 ragge #define vax_trunc_page(x) ((unsigned)(x) & ~(NBPG-1))
166 1.2.2.2 ragge #define vax_btod(x) ((unsigned)(x) >> PDRSHIFT)
167 1.2.2.2 ragge #define vax_dtob(x) ((unsigned)(x) << PDRSHIFT)
168 1.2.2.2 ragge #define vax_btop(x) ((unsigned)(x) >> PGSHIFT)
169 1.2.2.2 ragge #define vax_ptob(x) ((unsigned)(x) << PGSHIFT)
170 1.2.2.2 ragge
171 1.2.2.2 ragge #define DELAY(x) kern_delay(x)
172 1.2.2.2 ragge
173 1.2.2.2 ragge /*
174 1.2.2.2 ragge #define _spl(s) \
175 1.2.2.2 ragge ({ \
176 1.2.2.2 ragge register int _spl_r; \
177 1.2.2.2 ragge \
178 1.2.2.2 ragge asm __volatile ("mfpr $18,%0; mtpr $%1,$18; " : \
179 1.2.2.2 ragge "&=r" (_spl_r) : "ir" (s)); \
180 1.2.2.2 ragge _spl_r; \
181 1.2.2.2 ragge })
182 1.2.2.2 ragge */
183 1.2.2.2 ragge
184 1.2.2.2 ragge /* spl0 requires checking for software interrupts */
185 1.2.2.2 ragge
186 1.2.2.2 ragge
187 1.2.2.2 ragge #define splsoftclock() _spl(PSL2IPL(PSL_IPL08))
188 1.2.2.2 ragge #define splnet() _spl(PSL2IPL(PSL_IPL0C))
189 1.2.2.2 ragge #define spl4() _spl(PSL2IPL(PSL_IPL14))
190 1.2.2.2 ragge #define spltty() _spl(PSL2IPL(PSL_IPL15))
191 1.2.2.2 ragge #define splbio() _spl(PSL2IPL(PSL_IPL15))
192 1.2.2.2 ragge #define splimp() _spl(PSL2IPL(PSL_IPL16))
193 1.2.2.2 ragge #define splclock() _spl(PSL2IPL(PSL_IPL18))
194 1.2.2.2 ragge #define splhigh() _spl(PSL2IPL(PSL_IPL1F))
195 1.2.2.2 ragge #define splstatclock() splclock()
196 1.2.2.2 ragge /*
197 1.2.2.2 ragge #define splvm() _spl(PSL2IPL(PSL_IPL14))
198 1.2.2.2 ragge #define splsched() _spl(PSL2IPL(PSL_IPL14))
199 1.2.2.2 ragge */
200 1.2.2.2 ragge
201 1.2.2.2 ragge /* watch out for side effects */
202 1.2.2.2 ragge #define splx(s) (s ? _spl(s) : spl0())
203 1.2.2.2 ragge
204 1.2.2.2 ragge #define ovbcopy(x,y,z) bcopy(x,y,z) /* This should work i hope... */
205 1.2.2.2 ragge
206 1.2.2.2 ragge #endif
207