xref: /csrg-svn/sys/vax/include/param.h (revision 40721)
123264Smckusick /*
229186Smckusick  * Copyright (c) 1982, 1986 Regents of the University of California.
323264Smckusick  * All rights reserved.  The Berkeley software License Agreement
423264Smckusick  * specifies the terms and conditions for redistribution.
523264Smckusick  *
6*40721Skarels  *	@(#)param.h	7.15 (Berkeley) 04/03/90
723264Smckusick  */
89118Ssam 
99118Ssam /*
1033278Sbostic  * Machine dependent constants for VAX.
119118Ssam  */
1231162Sbostic #define	MACHINE	"vax"
1331162Sbostic 
1433381Skarels #ifndef BYTE_ORDER
1533278Sbostic #include <machine/endian.h>
1633278Sbostic #endif
1733278Sbostic 
1838966Skarels #include <machine/machlimits.h>
1932563Sbostic 
20*40721Skarels /*
21*40721Skarels  * Round p (pointer or byte index) up to a correctly-aligned value
22*40721Skarels  * for all data types (int, long, ...).   The result is u_int and
23*40721Skarels  * must be cast to any desired pointer type.
24*40721Skarels  */
25*40721Skarels #define	ALIGN(p)	(((u_int)(p) + (sizeof(int) - 1)) &~ (sizeof(int) - 1))
26*40721Skarels 
2730407Skarels #define	NBPG		512		/* bytes/page */
2830407Skarels #define	PGOFSET		(NBPG-1)	/* byte offset into page */
2930407Skarels #define	PGSHIFT		9		/* LOG2(NBPG) */
3030407Skarels #define	NPTEPG		(NBPG/(sizeof (struct pte)))
319118Ssam 
3233278Sbostic #define	KERNBASE	0x80000000	/* start of kernel virtual */
3340211Smarc #define	KERNTEXTOFF	KERNBASE	/* start of kernel text */
3433278Sbostic #define	BTOPKERNBASE	((u_long)KERNBASE >> PGSHIFT)
3533278Sbostic 
3630407Skarels #define	DEV_BSIZE	512
3730407Skarels #define	DEV_BSHIFT	9		/* log2(DEV_BSIZE) */
3830407Skarels #define BLKDEV_IOSIZE	2048
3930766Skarels #define	MAXPHYS		(63 * 1024)	/* max raw I/O transfer size */
4030407Skarels 
419118Ssam #define	CLSIZE		2
429118Ssam #define	CLSIZELOG2	1
439118Ssam 
4430407Skarels #define	SSIZE		4		/* initial stack size/NBPG */
4530407Skarels #define	SINCR		4		/* increment of stack/NBPG */
469118Ssam 
4739820Smckusick #define	UPAGES		16		/* pages of u-area */
489118Ssam 
499118Ssam /*
5038966Skarels  * Constants related to network buffer management.
5138966Skarels  * MCLBYTES must be no larger than CLBYTES (the software page size), and,
5238966Skarels  * on machines that exchange pages of input or output buffers with mbuf
5338966Skarels  * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
5438966Skarels  * of the hardware page size.
5538966Skarels  */
5638966Skarels #define	MSIZE		128		/* size of an mbuf */
5738966Skarels #define	MAPPED_MBUFS			/* can do scatter-gather I/O */
5838966Skarels #if CLBYTES > 1024
5938966Skarels #define	MCLBYTES	1024
6038966Skarels #define	MCLSHIFT	10
6138966Skarels #define	MCLOFSET	(MCLBYTES - 1)
6238966Skarels #else
6338966Skarels #define	MCLBYTES	CLBYTES
6438966Skarels #define	MCLSHIFT	CLSHIFT
6538966Skarels #define	MCLOFSET	CLOFSET
6638966Skarels #endif
6738966Skarels #ifdef GATEWAY
6838966Skarels #define	NMBCLUSTERS	512		/* map size, max cluster allocation */
6938966Skarels #else
7038966Skarels #define	NMBCLUSTERS	256		/* map size, max cluster allocation */
7138966Skarels #endif
7238966Skarels 
7338966Skarels /*
749118Ssam  * Some macros for units conversion
759118Ssam  */
769118Ssam /* Core clicks (512 bytes) to segments and vice versa */
779118Ssam #define	ctos(x)	(x)
789118Ssam #define	stoc(x)	(x)
799118Ssam 
809118Ssam /* Core clicks (512 bytes) to disk blocks */
819118Ssam #define	ctod(x)	(x)
829118Ssam #define	dtoc(x)	(x)
8330766Skarels #define	dtob(x)	((x)<<PGSHIFT)
849118Ssam 
859118Ssam /* clicks to bytes */
869118Ssam #define	ctob(x)	((x)<<9)
879118Ssam 
889118Ssam /* bytes to clicks */
899118Ssam #define	btoc(x)	((((unsigned)(x)+511)>>9))
909118Ssam 
9130407Skarels #define	btodb(bytes)	 		/* calculates (bytes / DEV_BSIZE) */ \
9230407Skarels 	((unsigned)(bytes) >> DEV_BSHIFT)
9330407Skarels #define	dbtob(db)			/* calculates (db * DEV_BSIZE) */ \
9430407Skarels 	((unsigned)(db) << DEV_BSHIFT)
9530407Skarels 
969118Ssam /*
9730407Skarels  * Map a ``block device block'' to a file system block.
9830407Skarels  * This should be device dependent, and will be if we
9930407Skarels  * add an entry to cdevsw/bdevsw for that purpose.
10030407Skarels  * For now though just use DEV_BSIZE.
10130407Skarels  */
10230407Skarels #define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
10330407Skarels 
10430407Skarels /*
1059118Ssam  * Macros to decode processor status word.
1069118Ssam  */
1079118Ssam #define	USERMODE(ps)	(((ps) & PSL_CURMOD) == PSL_CURMOD)
1089600Ssam #define	BASEPRI(ps)	(((ps) & PSL_IPL) == 0)
1099118Ssam 
11024887Skarels #ifdef KERNEL
11124887Skarels #ifndef LOCORE
11224887Skarels int	cpuspeed;
11329953Skarels #define	DELAY(n)	{ register int N = cpuspeed * (n); while (--N > 0); }
11424887Skarels #endif
11524887Skarels 
11624887Skarels #else KERNEL
1179118Ssam #define	DELAY(n)	{ register int N = (n); while (--N > 0); }
11824887Skarels #endif KERNEL
119