xref: /netbsd-src/sys/arch/vax/include/param.h (revision 3b435a73967be44dfb4a27315acd72bfacde430c)
1 /*      $NetBSD: param.h,v 1.39 1999/10/22 21:14:34 ragge Exp $    */
2 /*-
3  * Copyright (c) 1990 The Regents of the University of California.
4  * All rights reserved.
5  *
6  * This code is derived from software contributed to Berkeley by
7  * William Jolitz.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  * 3. All advertising materials mentioning features or use of this software
18  *    must display the following acknowledgement:
19  *	This product includes software developed by the University of
20  *	California, Berkeley and its contributors.
21  * 4. Neither the name of the University nor the names of its contributors
22  *    may be used to endorse or promote products derived from this software
23  *    without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35  * SUCH DAMAGE.
36  *
37  *	@(#)param.h	5.8 (Berkeley) 6/28/91
38  */
39 
40 #ifndef _VAX_PARAM_H_
41 #define _VAX_PARAM_H_
42 
43 /*
44  * Machine dependent constants for VAX.
45  */
46 
47 #define	_MACHINE	vax
48 #define	MACHINE		"vax"
49 #define	_MACHINE_ARCH	vax
50 #define	MACHINE_ARCH	"vax"
51 #define	MID_MACHINE	MID_VAX
52 
53 /*
54  * Round p (pointer or byte index) up to a correctly-aligned value
55  * for all data types (int, long, ...).   The result is u_int and
56  * must be cast to any desired pointer type.
57  *
58  * ALIGNED_POINTER is a boolean macro that checks whether an address
59  * is valid to fetch data elements of type t from on this architecture.
60  * This does not reflect the optimal alignment, just the possibility
61  * (within reasonable limits).
62  *
63  */
64 
65 #define ALIGNBYTES		(sizeof(int) - 1)
66 #define ALIGN(p)		(((u_int)(p) + ALIGNBYTES) &~ ALIGNBYTES)
67 #define ALIGNED_POINTER(p,t)	((((u_long)(p)) & (sizeof(t)-1)) == 0)
68 
69 #define	PGSHIFT		12			/* LOG2(NBPG) */
70 #define	NBPG		(1 << PGSHIFT)		/* (1 << PGSHIFT) bytes/page */
71 #define	PGOFSET		(NBPG - 1)               /* byte offset into page */
72 
73 #define	VAX_PGSHIFT	9
74 #define	VAX_NBPG	(1 << VAX_PGSHIFT)
75 #define	VAX_PGOFSET	(VAX_NBPG - 1)
76 
77 #define	KERNBASE	0x80000000		/* start of kernel virtual */
78 
79 #define	DEV_BSHIFT	9		               /* log2(DEV_BSIZE) */
80 #define	DEV_BSIZE	(1 << DEV_BSHIFT)
81 
82 #define BLKDEV_IOSIZE	2048
83 #define	MAXPHYS		(63 * 1024)	/* max raw I/O transfer size */
84 #define	MAXBSIZE	0x4000		/* max FS block size - XXX */
85 
86 #define	CLSIZELOG2	0		/* XXX - die */
87 #define	CLSIZE		1		/* XXX - die */
88 
89 #define	UPAGES		2		/* pages of u-area */
90 #define USPACE		(NBPG*UPAGES)
91 #define	REDZONEADDR	(VAX_NBPG*3)	/* Must be > sizeof(struct user) */
92 
93 #ifndef MSGBUFSIZE
94 #define MSGBUFSIZE	NBPG		/* default message buffer size */
95 #endif
96 
97 /*
98  * Constants related to network buffer management.
99  * MCLBYTES must be no larger than NBPG (the software page size), and,
100  * on machines that exchange pages of input or output buffers with mbuf
101  * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
102  * of the hardware page size.
103  */
104 
105 #ifndef	MSIZE
106 #define	MSIZE		128		/* size of an mbuf */
107 #endif	/* MSIZE */
108 
109 #ifndef	MCLSHIFT
110 #define	MCLSHIFT	11		/* convert bytes to m_buf clusters */
111 #endif	/* MCLSHIFT */
112 #define	MCLBYTES	(1 << MCLSHIFT)	/* size of an m_buf cluster */
113 #define	MCLOFSET	(MCLBYTES - 1)	/* offset within an m_buf cluster */
114 
115 #ifndef NMBCLUSTERS
116 
117 #if defined(_KERNEL) && !defined(_LKM)
118 #include "opt_gateway.h"
119 #endif /* _KERNEL && ! _LKM */
120 
121 #ifdef GATEWAY
122 #define	NMBCLUSTERS	512		/* map size, max cluster allocation */
123 #else
124 #define	NMBCLUSTERS	256		/* map size, max cluster allocation */
125 #endif	/* GATEWAY */
126 #endif	/* NMBCLUSTERS */
127 
128 /*
129  * Size of kernel malloc arena in NBPG-sized logical pages
130  */
131 
132 #ifndef NKMEMCLUSTERS
133 #define	NKMEMCLUSTERS	(4096*1024/NBPG)
134 #endif
135 
136 /*
137  * Some macros for units conversion
138  */
139 
140 /* pages ("clicks") to disk blocks */
141 #define	ctod(x)		((x) << (PGSHIFT - DEV_BSHIFT))
142 #define	dtoc(x)		((x) >> (PGSHIFT - DEV_BSHIFT))
143 
144 /* clicks to bytes */
145 #define	ctob(x)		((x) << PGSHIFT)
146 #define	btoc(x)		(((unsigned)(x) + PGOFSET) >> PGSHIFT)
147 #define	btop(x)		(((unsigned)(x)) >> PGSHIFT)
148 
149 /* bytes to disk blocks */
150 #define	btodb(x)	((x) >> DEV_BSHIFT)
151 #define	dbtob(x)	((x) << DEV_BSHIFT)
152 
153 /* MD conversion macros */
154 #define	vax_btoc(x)	(((unsigned)(x) + VAX_PGOFSET) >> VAX_PGSHIFT)
155 #define	vax_btop(x)	(((unsigned)(x)) >> VAX_PGSHIFT)
156 
157 /*
158  * Map a ``block device block'' to a file system block.
159  * This should be device dependent, and will be if we
160  * add an entry to cdevsw/bdevsw for that purpose.
161  * For now though just use DEV_BSIZE.
162  */
163 
164 #define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
165 
166 #ifdef _KERNEL
167 #ifndef lint
168 #define splx(reg)						\
169 ({								\
170 	register int val;					\
171 	__asm __volatile ("mfpr $0x12,%0;mtpr %1,$0x12"		\
172 				: "&=g" (val)			\
173 				: "g" (reg));			\
174 	val;							\
175 })
176 
177 #define	_splraise(reg)						\
178 ({								\
179 	register int val;					\
180 	__asm __volatile ("mfpr $0x12,%0"			\
181 				: "&=g" (val)			\
182 				: );				\
183 	if ((reg) > val) {					\
184 		__asm __volatile ("mtpr %0,$0x12"		\
185 				:				\
186 				: "g" (reg));			\
187 	}							\
188 	val;							\
189 })
190 #endif
191 
192 #define	spl0()		splx(0)		/* IPL0  */
193 #define spllowersoftclock() splx(8)	/* IPL08 */
194 #define splsoftclock()	_splraise(8)	/* IPL08 */
195 #define splsoftnet()	_splraise(0xc)	/* IPL0C */
196 #define	splddb()	_splraise(0xf)	/* IPL0F */
197 #define splbio()	_splraise(0x15)	/* IPL15 */
198 #define splnet()	_splraise(0x15)	/* IPL15 */
199 #define spltty()	_splraise(0x15)	/* IPL15 */
200 #define splimp()	_splraise(0x17)	/* IPL17 */
201 #define splclock()	_splraise(0x18)	/* IPL18 */
202 #define splhigh()	_splraise(0x1f)	/* IPL1F */
203 #define	splstatclock()	splclock()
204 
205 /* These are better to use when playing with VAX buses */
206 #define	spl4()		splx(0x14)
207 #define	spl5()		splx(0x15)
208 #define	spl6()		splx(0x16)
209 #define	spl7()		splx(0x17)
210 
211 #define vmapbuf(p,q)
212 #define vunmapbuf(p,q)
213 
214 /* Prototype needed for delay() */
215 #ifndef	_LOCORE
216 void	delay __P((int));
217 /* inline macros used inside kernel */
218 #include <machine/macros.h>
219 #endif
220 
221 #define	DELAY(x) delay(x)
222 #endif /* _KERNEL */
223 
224 #endif /* _VAX_PARAM_H_ */
225