xref: /csrg-svn/sys/pmax/include/param.h (revision 63217)
152131Smckusick /*
252131Smckusick  * Copyright (c) 1988 University of Utah.
3*63217Sbostic  * Copyright (c) 1992, 1993
4*63217Sbostic  *	The Regents of the University of California.  All rights reserved.
552131Smckusick  *
652131Smckusick  * This code is derived from software contributed to Berkeley by
752131Smckusick  * the Systems Programming Group of the University of Utah Computer
852131Smckusick  * Science Department and Ralph Campbell.
952131Smckusick  *
1052131Smckusick  * %sccs.include.redist.c%
1152131Smckusick  *
1252131Smckusick  * from: Utah $Hdr: machparam.h 1.11 89/08/14$
1352131Smckusick  *
14*63217Sbostic  *	@(#)param.h	8.1 (Berkeley) 06/10/93
1552131Smckusick  */
1652131Smckusick 
1752131Smckusick /*
1852131Smckusick  * Machine dependent constants for DEC Station 3100.
1952131Smckusick  */
2052131Smckusick #define	MACHINE	"mips"
2152131Smckusick 
2252941Sralph /*
2352941Sralph  * Round p (pointer or byte index) up to a correctly-aligned value for all
2452941Sralph  * data types (int, long, ...).   The result is u_int and must be cast to
2552941Sralph  * any desired pointer type.
2652941Sralph  */
2756673Sbostic #define	ALIGNBYTES	7
2853674Sbostic #define	ALIGN(p)	(((u_int)(p) + ALIGNBYTES) &~ ALIGNBYTES)
2952941Sralph 
3052131Smckusick #define	NBPG		4096		/* bytes/page */
3152131Smckusick #define	PGOFSET		(NBPG-1)	/* byte offset into page */
3252131Smckusick #define	PGSHIFT		12		/* LOG2(NBPG) */
3352131Smckusick #define	NPTEPG		(NBPG/4)
3452131Smckusick 
3559845Sralph #define NBSEG		0x400000	/* bytes/segment */
3659845Sralph #define	SEGOFSET	(NBSEG-1)	/* byte offset into segment */
3759845Sralph #define	SEGSHIFT	22		/* LOG2(NBSEG) */
3859845Sralph 
3952131Smckusick #define	KERNBASE	0x80000000	/* start of kernel virtual */
4052131Smckusick #define	BTOPKERNBASE	((u_long)KERNBASE >> PGSHIFT)
4152131Smckusick 
4252131Smckusick #define	DEV_BSIZE	512
4352131Smckusick #define	DEV_BSHIFT	9		/* log2(DEV_BSIZE) */
4452131Smckusick #define BLKDEV_IOSIZE	2048
4559845Sralph #define	MAXPHYS		(64 * 1024)	/* max raw I/O transfer size */
4652131Smckusick 
4752131Smckusick #define	CLSIZE		1
4852131Smckusick #define	CLSIZELOG2	0
4952131Smckusick 
5052131Smckusick /* NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE */
5152131Smckusick #define	SSIZE		1		/* initial stack size/NBPG */
5252131Smckusick #define	SINCR		1		/* increment of stack/NBPG */
5352131Smckusick 
5452131Smckusick #define	UPAGES		2		/* pages of u-area */
5553716Smckusick #define	UADDR		0xffffd000	/* address of u */
5652131Smckusick #define	UVPN		(UADDR>>PGSHIFT)/* virtual page number of u */
5752131Smckusick #define	KERNELSTACK	(UADDR+UPAGES*NBPG)	/* top of kernel stack */
5852131Smckusick 
5952131Smckusick /*
6052131Smckusick  * Constants related to network buffer management.
6152131Smckusick  * MCLBYTES must be no larger than CLBYTES (the software page size), and,
6252131Smckusick  * on machines that exchange pages of input or output buffers with mbuf
6352131Smckusick  * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
6452131Smckusick  * of the hardware page size.
6552131Smckusick  */
6652131Smckusick #define	MSIZE		128		/* size of an mbuf */
6752131Smckusick #define	MCLBYTES	1024
6852131Smckusick #define	MCLSHIFT	10
6952131Smckusick #define	MCLOFSET	(MCLBYTES - 1)
7052131Smckusick #ifndef NMBCLUSTERS
7152131Smckusick #ifdef GATEWAY
7252131Smckusick #define	NMBCLUSTERS	512		/* map size, max cluster allocation */
7352131Smckusick #else
7452131Smckusick #define	NMBCLUSTERS	256		/* map size, max cluster allocation */
7552131Smckusick #endif
7652131Smckusick #endif
7752131Smckusick 
7852131Smckusick /*
7952131Smckusick  * Size of kernel malloc arena in CLBYTES-sized logical pages
8052131Smckusick  */
8152131Smckusick #ifndef NKMEMCLUSTERS
8252131Smckusick #define	NKMEMCLUSTERS	(512*1024/CLBYTES)
8352131Smckusick #endif
8452131Smckusick 
8552131Smckusick /* pages ("clicks") (4096 bytes) to disk blocks */
8652131Smckusick #define	ctod(x)	((x)<<(PGSHIFT-DEV_BSHIFT))
8752131Smckusick #define	dtoc(x)	((x)>>(PGSHIFT-DEV_BSHIFT))
8852131Smckusick #define	dtob(x)	((x)<<DEV_BSHIFT)
8952131Smckusick 
9052131Smckusick /* pages to bytes */
9152131Smckusick #define	ctob(x)	((x)<<PGSHIFT)
9252131Smckusick 
9352131Smckusick /* bytes to pages */
9452131Smckusick #define	btoc(x)	(((unsigned)(x)+(NBPG-1))>>PGSHIFT)
9552131Smckusick 
9652131Smckusick #define	btodb(bytes)	 		/* calculates (bytes / DEV_BSIZE) */ \
9752131Smckusick 	((unsigned)(bytes) >> DEV_BSHIFT)
9852131Smckusick #define	dbtob(db)			/* calculates (db * DEV_BSIZE) */ \
9952131Smckusick 	((unsigned)(db) << DEV_BSHIFT)
10052131Smckusick 
10152131Smckusick /*
10252131Smckusick  * Map a ``block device block'' to a file system block.
10352131Smckusick  * This should be device dependent, and should use the bsize
10452131Smckusick  * field from the disk label.
10552131Smckusick  * For now though just use DEV_BSIZE.
10652131Smckusick  */
10752131Smckusick #define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
10852131Smckusick 
10952131Smckusick /*
11052131Smckusick  * Mach derived conversion macros
11152131Smckusick  */
11252131Smckusick #define pmax_round_page(x)	((((unsigned)(x)) + NBPG - 1) & ~(NBPG-1))
11352131Smckusick #define pmax_trunc_page(x)	((unsigned)(x) & ~(NBPG-1))
11452131Smckusick #define pmax_btop(x)		((unsigned)(x) >> PGSHIFT)
11552131Smckusick #define pmax_ptob(x)		((unsigned)(x) << PGSHIFT)
11652131Smckusick 
11752131Smckusick #ifdef KERNEL
11852131Smckusick #ifndef LOCORE
11956821Sralph extern int (*Mach_splnet)(), (*Mach_splbio)(), (*Mach_splimp)(),
12056821Sralph 	   (*Mach_spltty)(), (*Mach_splclock)(), (*Mach_splstatclock)();
12156821Sralph #define	splnet()	((*Mach_splnet)())
12256821Sralph #define	splbio()	((*Mach_splbio)())
12356821Sralph #define	splimp()	((*Mach_splimp)())
12456821Sralph #define	spltty()	((*Mach_spltty)())
12556821Sralph #define	splclock()	((*Mach_splclock)())
12656821Sralph #define	splstatclock()	((*Mach_splstatclock)())
12752131Smckusick extern	int cpuspeed;
12852131Smckusick #define	DELAY(n)	{ register int N = cpuspeed * (n); while (--N > 0); }
12952131Smckusick #endif
13052131Smckusick 
13152131Smckusick #else /* !KERNEL */
13252131Smckusick #define	DELAY(n)	{ register int N = (n); while (--N > 0); }
13352131Smckusick #endif /* !KERNEL */
134