xref: /csrg-svn/sys/sparc/include/param.h (revision 59208)
155121Storek /*
255121Storek  * Copyright (c) 1992 The Regents of the University of California.
355121Storek  * All rights reserved.
455121Storek  *
555121Storek  * This software was developed by the Computer Systems Engineering group
655121Storek  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
755121Storek  * contributed to Berkeley.
855121Storek  *
955501Sbostic  * All advertising materials mentioning features or use of this software
1055501Sbostic  * must display the following acknowledgement:
1155501Sbostic  *	This product includes software developed by the University of
12*59208Storek  *	California, Lawrence Berkeley Laboratory.
1355501Sbostic  *
1455121Storek  * %sccs.include.redist.c%
1555121Storek  *
16*59208Storek  *	@(#)param.h	7.4 (Berkeley) 04/20/93
1755121Storek  *
18*59208Storek  * from: $Header: param.h,v 1.14 93/04/07 01:34:00 torek Exp $ (LBL)
1955121Storek  */
2055121Storek 
2155121Storek /*
2255121Storek  * Machine dependent constants for Sun-4c (SPARCstation)
2355121Storek  */
2455121Storek #define	MACHINE	"sparc"
2555121Storek 
2655121Storek #ifdef KERNEL				/* XXX */
2756538Sbostic #include <machine/cpu.h>		/* XXX */
2855121Storek #endif					/* XXX */
2955121Storek 
3055121Storek /*
3155121Storek  * Round p (pointer or byte index) up to a correctly-aligned value for
3255121Storek  * the machine's strictest data type.  The result is u_int and must be
3355121Storek  * cast to any desired pointer type.
3455121Storek  */
3555121Storek #define	ALIGNBYTES	7
3655121Storek #define	ALIGN(p)	(((u_int)(p) + ALIGNBYTES) & ~ALIGNBYTES)
3755121Storek 
3855121Storek #define	NBPG		4096		/* bytes/page */
3955121Storek #define	PGOFSET		(NBPG-1)	/* byte offset into page */
4055121Storek #define	PGSHIFT		12		/* log2(NBPG) */
4155121Storek 
4255121Storek #define	KERNBASE	0xf8000000	/* start of kernel virtual space */
4355121Storek #define	KERNTEXTOFF	0xf8004000	/* start of kernel text */
4455121Storek #define	BTOPKERNBASE	((u_long)KERNBASE >> PG_SHIFT)
4555121Storek 
4655121Storek #define	DEV_BSIZE	512
4755121Storek #define	DEV_BSHIFT	9		/* log2(DEV_BSIZE) */
4855121Storek #define	BLKDEV_IOSIZE	2048
4955121Storek #define	MAXPHYS		(64 * 1024)
5055121Storek 
5155121Storek #define	CLSIZE		1
5255121Storek #define	CLSIZELOG2	0
5355121Storek 
5455121Storek /* NOTE: SSIZE and UPAGES must be multiples of CLSIZE */
5555121Storek #define	SSIZE		1		/* initial stack size/NBPG */
5655121Storek #define	UPAGES		2		/* pages of u-area */
5755121Storek 
5855121Storek /*
5955121Storek  * Constants related to network buffer management.
6055121Storek  * MCLBYTES must be no larger than CLBYTES (the software page size), and,
6155121Storek  * on machines that exchange pages of input or output buffers with mbuf
6255121Storek  * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
6355121Storek  * of the hardware page size.
6455121Storek  */
6555121Storek #define	MSIZE		128		/* size of an mbuf */
6655121Storek #define	MCLBYTES	2048		/* enough for whole Ethernet packet */
6755121Storek #define	MCLSHIFT	11		/* log2(MCLBYTES) */
6855121Storek #define	MCLOFSET	(MCLBYTES - 1)
6955121Storek 
7055121Storek #ifndef NMBCLUSTERS
7155121Storek #ifdef GATEWAY
7255121Storek #define	NMBCLUSTERS	512		/* map size, max cluster allocation */
7355121Storek #else
7455121Storek #define	NMBCLUSTERS	256		/* map size, max cluster allocation */
7555121Storek #endif
7655121Storek #endif
7755121Storek 
7855121Storek /*
7955121Storek  * Size of kernel malloc arena in CLBYTES-sized logical pages.
8055121Storek  */
8155121Storek #ifndef	NKMEMCLUSTERS
82*59208Storek #define	NKMEMCLUSTERS	(6 * 1024 * 1024 / CLBYTES)
8355121Storek #endif
8455121Storek 
8555121Storek /* pages ("clicks") (4096 bytes) to disk blocks */
8655121Storek #define	ctod(x)	((x) << (PGSHIFT - DEV_BSHIFT))
8755121Storek #define	dtoc(x)	((x) >> (PGSHIFT - DEV_BSHIFT))
8855121Storek #define	dtob(x)	((x) << DEV_BSHIFT)
8955121Storek 
9055121Storek /* pages to bytes */
9155121Storek #define	ctob(x)	((x) << PGSHIFT)
9255121Storek 
9355121Storek /* bytes to pages */
9455121Storek #define	btoc(x)	(((unsigned)(x) + PGOFSET) >> PGSHIFT)
9555121Storek 
9655121Storek #define	btodb(bytes)		/* calculates (bytes / DEV_BSIZE) */ \
9755121Storek 	((unsigned)(bytes) >> DEV_BSHIFT)
9855121Storek #define	dbtob(db)		/* calculates (db * DEV_BSIZE) */ \
9955121Storek 	((unsigned)(db) << DEV_BSHIFT)
10055121Storek 
10155121Storek /*
10255121Storek  * Map a ``block device block'' to a file system block.
10355121Storek  * This should be device dependent, and should use the bsize
10455121Storek  * field from the disk label.
10555121Storek  * For now though just use DEV_BSIZE.
10655121Storek  */
10755121Storek #define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE / DEV_BSIZE))
10855121Storek 
10955121Storek #ifdef KERNEL
11055121Storek #ifndef LOCORE
111*59208Storek int cpuspeed;		/* XXX for sysctl(hw.cpuspeed) only; should remove */
11255121Storek #define	DELAY(n)	delay(n)
11355121Storek #endif
11455121Storek #else
11555121Storek #define	DELAY(n)	{ register volatile int N = (n); while (--N > 0); }
11655121Storek #endif
117