xref: /original-bsd/sys/vax/include/param.h (revision 4da674f5)
1 /*
2  * Copyright (c) 1982, 1986 Regents of the University of California.
3  * All rights reserved.  The Berkeley software License Agreement
4  * specifies the terms and conditions for redistribution.
5  *
6  *	@(#)param.h	7.17 (Berkeley) 12/16/90
7  */
8 
9 /*
10  * Machine dependent constants for VAX.
11  */
12 #define	MACHINE	"vax"
13 
14 /*
15  * Round p (pointer or byte index) up to a correctly-aligned value
16  * for all data types (int, long, ...).   The result is u_int and
17  * must be cast to any desired pointer type.
18  */
19 #define	ALIGN(p)	(((u_int)(p) + (sizeof(int) - 1)) &~ (sizeof(int) - 1))
20 
21 #define	NBPG		512		/* bytes/page */
22 #define	PGOFSET		(NBPG-1)	/* byte offset into page */
23 #define	PGSHIFT		9		/* LOG2(NBPG) */
24 #define	NPTEPG		(NBPG/(sizeof (struct pte)))
25 
26 #define	KERNBASE	0x80000000	/* start of kernel virtual */
27 #define	KERNTEXTOFF	KERNBASE	/* start of kernel text */
28 #define	BTOPKERNBASE	((u_long)KERNBASE >> PGSHIFT)
29 
30 #define	DEV_BSIZE	512
31 #define	DEV_BSHIFT	9		/* log2(DEV_BSIZE) */
32 #define BLKDEV_IOSIZE	2048
33 #define	MAXPHYS		(63 * 1024)	/* max raw I/O transfer size */
34 
35 #define	CLSIZE		2
36 #define	CLSIZELOG2	1
37 
38 #define	SSIZE		4		/* initial stack size/NBPG */
39 #define	SINCR		4		/* increment of stack/NBPG */
40 
41 #define	UPAGES		16		/* pages of u-area */
42 
43 /*
44  * Constants related to network buffer management.
45  * MCLBYTES must be no larger than CLBYTES (the software page size), and,
46  * on machines that exchange pages of input or output buffers with mbuf
47  * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
48  * of the hardware page size.
49  */
50 #define	MSIZE		128		/* size of an mbuf */
51 #define	MAPPED_MBUFS			/* can do scatter-gather I/O */
52 #if CLBYTES > 1024
53 #define	MCLBYTES	1024
54 #define	MCLSHIFT	10
55 #define	MCLOFSET	(MCLBYTES - 1)
56 #else
57 #define	MCLBYTES	CLBYTES
58 #define	MCLSHIFT	CLSHIFT
59 #define	MCLOFSET	CLOFSET
60 #endif
61 #ifdef GATEWAY
62 #define	NMBCLUSTERS	512		/* map size, max cluster allocation */
63 #else
64 #define	NMBCLUSTERS	256		/* map size, max cluster allocation */
65 #endif
66 
67 /*
68  * Size of kernel malloc arena in CLBYTES-sized logical pages
69  */
70 #ifndef NKMEMCLUSTERS
71 #define	NKMEMCLUSTERS	(512*1024/CLBYTES)
72 #endif
73 
74 /*
75  * Some macros for units conversion
76  */
77 /* Core clicks (512 bytes) to segments and vice versa */
78 #define	ctos(x)	(x)
79 #define	stoc(x)	(x)
80 
81 /* Core clicks (512 bytes) to disk blocks */
82 #define	ctod(x)	(x)
83 #define	dtoc(x)	(x)
84 #define	dtob(x)	((x)<<PGSHIFT)
85 
86 /* clicks to bytes */
87 #define	ctob(x)	((x)<<9)
88 
89 /* bytes to clicks */
90 #define	btoc(x)	((((unsigned)(x)+511)>>9))
91 
92 #define	btodb(bytes)	 		/* calculates (bytes / DEV_BSIZE) */ \
93 	((unsigned)(bytes) >> DEV_BSHIFT)
94 #define	dbtob(db)			/* calculates (db * DEV_BSIZE) */ \
95 	((unsigned)(db) << DEV_BSHIFT)
96 
97 /*
98  * Map a ``block device block'' to a file system block.
99  * This should be device dependent, and will be if we
100  * add an entry to cdevsw/bdevsw for that purpose.
101  * For now though just use DEV_BSIZE.
102  */
103 #define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
104 
105 /*
106  * Macros to decode processor status word.
107  */
108 #define	USERMODE(ps)	(((ps) & PSL_CURMOD) == PSL_CURMOD)
109 #define	BASEPRI(ps)	(((ps) & PSL_IPL) == 0)
110 
111 #ifdef KERNEL
112 #ifndef LOCORE
113 int	cpuspeed;
114 #define	DELAY(n)	{ register int N = cpuspeed * (n); while (--N > 0); }
115 #endif
116 
117 #else KERNEL
118 #define	DELAY(n)	{ register int N = (n); while (--N > 0); }
119 #endif KERNEL
120