xref: /csrg-svn/sys/i386/include/param.h (revision 50031)
141058Swilliam /*-
241058Swilliam  * Copyright (c) 1990 The Regents of the University of California.
341058Swilliam  * All rights reserved.
441058Swilliam  *
541058Swilliam  * This code is derived from software contributed to Berkeley by
641058Swilliam  * William Jolitz.
741058Swilliam  *
846006Swilliam  * %sccs.include.redist.c%
941058Swilliam  *
10*50031Sbostic  *	@(#)param.h	5.6 (Berkeley) 06/08/91
1141058Swilliam  */
1241058Swilliam 
1340461Sbill /*
1440461Sbill  * Machine dependent constants for Intel 386.
1540461Sbill  */
1640461Sbill 
1740461Sbill #define MACHINE "i386"
1840461Sbill 
1940461Sbill #define	NBPG		4096		/* bytes/page */
2040461Sbill #define	PGOFSET		(NBPG-1)	/* byte offset into page */
2140461Sbill #define	PGSHIFT		12		/* LOG2(NBPG) */
2240461Sbill #define	NPTEPG		(NBPG/(sizeof (struct pte)))
2340461Sbill 
2440461Sbill #define NBPDR		(1024*NBPG)	/* bytes/page dir */
2540461Sbill #define	PDROFSET	(NBPDR-1)	/* byte offset into page dir */
2640461Sbill #define	PDRSHIFT	22		/* LOG2(NBPDR) */
2740461Sbill 
2840461Sbill #define	KERNBASE	0xFE000000	/* start of kernel virtual */
2940461Sbill #define	BTOPKERNBASE	((u_long)KERNBASE >> PGSHIFT)
3040461Sbill 
3140461Sbill #define	DEV_BSIZE	512
3240461Sbill #define	DEV_BSHIFT	9		/* log2(DEV_BSIZE) */
3340461Sbill #define BLKDEV_IOSIZE	2048
3440461Sbill #define	MAXPHYS		(64 * 1024)	/* max raw I/O transfer size */
3540461Sbill 
3640461Sbill #define	CLSIZE		1
3740461Sbill #define	CLSIZELOG2	0
3840461Sbill 
3948796Sbostic /* NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE */
4040461Sbill #define	SSIZE	1		/* initial stack size/NBPG */
4140461Sbill #define	SINCR	1		/* increment of stack/NBPG */
4240461Sbill 
4341058Swilliam #define	UPAGES	2		/* pages of u-area */
4440461Sbill 
4540461Sbill /*
4645964Swilliam  * Constants related to network buffer management.
4745964Swilliam  * MCLBYTES must be no larger than CLBYTES (the software page size), and,
4845964Swilliam  * on machines that exchange pages of input or output buffers with mbuf
4945964Swilliam  * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
5045964Swilliam  * of the hardware page size.
5145964Swilliam  */
5245964Swilliam #define	MSIZE		128		/* size of an mbuf */
5345964Swilliam #define	MCLBYTES	1024
5445964Swilliam #define	MCLSHIFT	10
5545964Swilliam #define	MCLOFSET	(MCLBYTES - 1)
5645964Swilliam #ifndef NMBCLUSTERS
5745964Swilliam #ifdef GATEWAY
5845964Swilliam #define	NMBCLUSTERS	512		/* map size, max cluster allocation */
5945964Swilliam #else
6045964Swilliam #define	NMBCLUSTERS	256		/* map size, max cluster allocation */
6145964Swilliam #endif
6245964Swilliam #endif
6345964Swilliam 
6445964Swilliam /*
6545964Swilliam  * Size of kernel malloc arena in CLBYTES-sized logical pages
6645964Swilliam  */
6745964Swilliam #ifndef NKMEMCLUSTERS
6845964Swilliam #define	NKMEMCLUSTERS	(512*1024/CLBYTES)
6945964Swilliam #endif
7045964Swilliam /*
7140461Sbill  * Some macros for units conversion
7240461Sbill  */
7340461Sbill /* Core clicks (4096 bytes) to segments and vice versa */
7440461Sbill #define	ctos(x)	(x)
7540461Sbill #define	stoc(x)	(x)
7640461Sbill 
7740461Sbill /* Core clicks (4096 bytes) to disk blocks */
7840461Sbill #define	ctod(x)	((x)<<(PGSHIFT-DEV_BSHIFT))
7940461Sbill #define	dtoc(x)	((x)>>(PGSHIFT-DEV_BSHIFT))
8040461Sbill #define	dtob(x)	((x)<<DEV_BSHIFT)
8140461Sbill 
8240461Sbill /* clicks to bytes */
8340461Sbill #define	ctob(x)	((x)<<PGSHIFT)
8440461Sbill 
8540461Sbill /* bytes to clicks */
8640461Sbill #define	btoc(x)	(((unsigned)(x)+(NBPG-1))>>PGSHIFT)
8740461Sbill 
8840461Sbill #define	btodb(bytes)	 		/* calculates (bytes / DEV_BSIZE) */ \
8940461Sbill 	((unsigned)(bytes) >> DEV_BSHIFT)
9040461Sbill #define	dbtob(db)			/* calculates (db * DEV_BSIZE) */ \
9140461Sbill 	((unsigned)(db) << DEV_BSHIFT)
9240461Sbill 
9340461Sbill /*
9440461Sbill  * Map a ``block device block'' to a file system block.
9540461Sbill  * This should be device dependent, and will be if we
9640461Sbill  * add an entry to cdevsw/bdevsw for that purpose.
9740461Sbill  * For now though just use DEV_BSIZE.
9840461Sbill  */
9940461Sbill #define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
10040461Sbill 
10147999Swilliam /*
10247999Swilliam  * Mach derived conversion macros
10347999Swilliam  */
10447999Swilliam #define i386_round_pdr(x)	((((unsigned)(x)) + NBPDR - 1) & ~(NBPDR-1))
10547999Swilliam #define i386_trunc_pdr(x)	((unsigned)(x) & ~(NBPDR-1))
10647999Swilliam #define i386_round_page(x)	((((unsigned)(x)) + NBPG - 1) & ~(NBPG-1))
10747999Swilliam #define i386_trunc_page(x)	((unsigned)(x) & ~(NBPG-1))
10847999Swilliam #define i386_btod(x)		((unsigned)(x) >> PDRSHIFT)
10947999Swilliam #define i386_dtob(x)		((unsigned)(x) << PDRSHIFT)
11047999Swilliam #define i386_btop(x)		((unsigned)(x) >> PGSHIFT)
11147999Swilliam #define i386_ptob(x)		((unsigned)(x) << PGSHIFT)
11247999Swilliam 
11340461Sbill #ifdef KERNEL
11440461Sbill #ifndef LOCORE
11540461Sbill int	cpuspeed;
11640461Sbill #endif
11740461Sbill #define	DELAY(n)	{ register int N = cpuspeed * (n); while (--N > 0); }
11840461Sbill 
119*50031Sbostic #else
12040461Sbill #define	DELAY(n)	{ register int N = (n); while (--N > 0); }
121*50031Sbostic #endif
122