xref: /csrg-svn/sys/tahoe/include/param.h (revision 48795)
1 /*
2  * Copyright (c) 1982, 1986, 1988 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.8 (Berkeley) 04/28/91
7  */
8 
9 /*
10  * Machine dependent constants for TAHOE.
11  */
12 #define	MACHINE	"tahoe"
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		1024		/* bytes/page */
22 #define	PGOFSET		(NBPG-1)	/* byte offset into page */
23 #define	PGSHIFT		10		/* LOG2(NBPG) */
24 #define	NPTEPG		(NBPG/(sizeof (struct pte)))
25 
26 #define	KERNBASE	0xc0000000	/* start of kernel virtual */
27 #define	KERNTEXTOFF	(KERNBASE + 0x800)	/* start of kernel text */
28 #define	BTOPKERNBASE	((u_long)KERNBASE >> PGSHIFT)
29 
30 #define	DEV_BSIZE	1024
31 #define	DEV_BSHIFT	10		/* log2(DEV_BSIZE) */
32 #define BLKDEV_IOSIZE	1024		/* NBPG for physical controllers */
33 #define	MAXPHYS		(64 * 1024)	/* max raw I/O transfer size */
34 
35 #define	CLSIZE		1
36 #define	CLSIZELOG2	0
37 
38 /* NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE */
39 #define	SSIZE		2		/* initial stack size/NBPG */
40 #define	SINCR		2		/* increment of stack/NBPG */
41 #define	UPAGES		8		/* pages of u-area (2 stack pages) */
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 #define	MAXCKEY	255		/* maximal allowed code key */
68 #define	MAXDKEY	255		/* maximal allowed data key */
69 #define	NCKEY	(MAXCKEY+1)	/* # code keys, including 0 (reserved) */
70 #define	NDKEY	(MAXDKEY+1)	/* # data keys, including 0 (reserved) */
71 
72 /*
73  * Size of kernel malloc arena in CLBYTES-sized logical pages
74  */
75 #ifndef NKMEMCLUSTERS
76 #define	NKMEMCLUSTERS	(512*1024/CLBYTES)
77 #endif
78 
79 /*
80  * Some macros for units conversion
81  */
82 /* Core clicks (1024 bytes) to segments and vice versa */
83 #define	ctos(x)	(x)
84 #define	stoc(x)	(x)
85 
86 /* Core clicks (1024 bytes) to disk blocks */
87 #define	ctod(x)	(x)
88 #define	dtoc(x)	(x)
89 #define	dtob(x)	((x)<<PGSHIFT)
90 
91 /* clicks to bytes */
92 #define	ctob(x)	((x)<<PGSHIFT)
93 
94 /* bytes to clicks */
95 #define	btoc(x)	((((unsigned)(x)+NBPG-1) >> PGSHIFT))
96 
97 #define	btodb(bytes)	 		/* calculates (bytes / DEV_BSIZE) */ \
98 	((unsigned)(bytes) >> DEV_BSHIFT)
99 #define	dbtob(db)			/* calculates (db * DEV_BSIZE) */ \
100 	((unsigned)(db) << DEV_BSHIFT)
101 
102 /*
103  * Map a ``block device block'' to a file system block.
104  * This should be device dependent, and will be if we
105  * add an entry to cdevsw/bdevsw for that purpose.
106  * For now though just use DEV_BSIZE.
107  */
108 #define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
109 
110 /*
111  * Macros to decode processor status word.
112  */
113 #define	USERMODE(ps)	(((ps) & PSL_CURMOD) == PSL_CURMOD)
114 #define	BASEPRI(ps)	(((ps) & PSL_IPL) == 0)
115 
116 #define	DELAY(n)	{ register int N = 3*(n); while (--N > 0); }
117