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