xref: /csrg-svn/sys/i386/include/param.h (revision 53638)
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*53638Sbostic  *	@(#)param.h	5.10 (Berkeley) 05/20/92
1141058Swilliam  */
1241058Swilliam 
1340461Sbill /*
1440461Sbill  * Machine dependent constants for Intel 386.
1540461Sbill  */
1640461Sbill 
1740461Sbill #define MACHINE "i386"
1840461Sbill 
1950141Ssklower /*
2052589Sbostic  * Round p (pointer or byte index) up to a correctly-aligned value for all
2152589Sbostic  * data types (int, long, ...).   The result is u_int and must be cast to
2252589Sbostic  * any desired pointer type.
2350141Ssklower  */
2452589Sbostic #define	ALIGN(p)	(((u_int)(p) + 3) &~ 3)
2550141Ssklower 
2640461Sbill #define	NBPG		4096		/* bytes/page */
2740461Sbill #define	PGOFSET		(NBPG-1)	/* byte offset into page */
2840461Sbill #define	PGSHIFT		12		/* LOG2(NBPG) */
2940461Sbill #define	NPTEPG		(NBPG/(sizeof (struct pte)))
3040461Sbill 
3140461Sbill #define NBPDR		(1024*NBPG)	/* bytes/page dir */
3240461Sbill #define	PDROFSET	(NBPDR-1)	/* byte offset into page dir */
3340461Sbill #define	PDRSHIFT	22		/* LOG2(NBPDR) */
3440461Sbill 
3540461Sbill #define	KERNBASE	0xFE000000	/* start of kernel virtual */
3640461Sbill #define	BTOPKERNBASE	((u_long)KERNBASE >> PGSHIFT)
3740461Sbill 
3840461Sbill #define	DEV_BSIZE	512
3940461Sbill #define	DEV_BSHIFT	9		/* log2(DEV_BSIZE) */
4040461Sbill #define BLKDEV_IOSIZE	2048
4140461Sbill #define	MAXPHYS		(64 * 1024)	/* max raw I/O transfer size */
4240461Sbill 
4340461Sbill #define	CLSIZE		1
4440461Sbill #define	CLSIZELOG2	0
4540461Sbill 
4648796Sbostic /* NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE */
4740461Sbill #define	SSIZE	1		/* initial stack size/NBPG */
4840461Sbill #define	SINCR	1		/* increment of stack/NBPG */
4940461Sbill 
5041058Swilliam #define	UPAGES	2		/* pages of u-area */
5140461Sbill 
5240461Sbill /*
5345964Swilliam  * Constants related to network buffer management.
5445964Swilliam  * MCLBYTES must be no larger than CLBYTES (the software page size), and,
5545964Swilliam  * on machines that exchange pages of input or output buffers with mbuf
5645964Swilliam  * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
5745964Swilliam  * of the hardware page size.
5845964Swilliam  */
5945964Swilliam #define	MSIZE		128		/* size of an mbuf */
6045964Swilliam #define	MCLBYTES	1024
6145964Swilliam #define	MCLSHIFT	10
6245964Swilliam #define	MCLOFSET	(MCLBYTES - 1)
6345964Swilliam #ifndef NMBCLUSTERS
6445964Swilliam #ifdef GATEWAY
6545964Swilliam #define	NMBCLUSTERS	512		/* map size, max cluster allocation */
6645964Swilliam #else
6745964Swilliam #define	NMBCLUSTERS	256		/* map size, max cluster allocation */
6845964Swilliam #endif
6945964Swilliam #endif
7045964Swilliam 
7145964Swilliam /*
7245964Swilliam  * Size of kernel malloc arena in CLBYTES-sized logical pages
7345964Swilliam  */
7445964Swilliam #ifndef NKMEMCLUSTERS
7550267Skarels #define	NKMEMCLUSTERS	(2048*1024/CLBYTES)
7645964Swilliam #endif
7745964Swilliam /*
7840461Sbill  * Some macros for units conversion
7940461Sbill  */
8040461Sbill /* Core clicks (4096 bytes) to segments and vice versa */
8140461Sbill #define	ctos(x)	(x)
8240461Sbill #define	stoc(x)	(x)
8340461Sbill 
8440461Sbill /* Core clicks (4096 bytes) to disk blocks */
8540461Sbill #define	ctod(x)	((x)<<(PGSHIFT-DEV_BSHIFT))
8640461Sbill #define	dtoc(x)	((x)>>(PGSHIFT-DEV_BSHIFT))
8740461Sbill #define	dtob(x)	((x)<<DEV_BSHIFT)
8840461Sbill 
8940461Sbill /* clicks to bytes */
9040461Sbill #define	ctob(x)	((x)<<PGSHIFT)
9140461Sbill 
9240461Sbill /* bytes to clicks */
9340461Sbill #define	btoc(x)	(((unsigned)(x)+(NBPG-1))>>PGSHIFT)
9440461Sbill 
9540461Sbill #define	btodb(bytes)	 		/* calculates (bytes / DEV_BSIZE) */ \
9640461Sbill 	((unsigned)(bytes) >> DEV_BSHIFT)
9740461Sbill #define	dbtob(db)			/* calculates (db * DEV_BSIZE) */ \
9840461Sbill 	((unsigned)(db) << DEV_BSHIFT)
9940461Sbill 
10040461Sbill /*
10140461Sbill  * Map a ``block device block'' to a file system block.
10240461Sbill  * This should be device dependent, and will be if we
10340461Sbill  * add an entry to cdevsw/bdevsw for that purpose.
10440461Sbill  * For now though just use DEV_BSIZE.
10540461Sbill  */
10640461Sbill #define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
10740461Sbill 
10847999Swilliam /*
10947999Swilliam  * Mach derived conversion macros
11047999Swilliam  */
11147999Swilliam #define i386_round_pdr(x)	((((unsigned)(x)) + NBPDR - 1) & ~(NBPDR-1))
11247999Swilliam #define i386_trunc_pdr(x)	((unsigned)(x) & ~(NBPDR-1))
11347999Swilliam #define i386_round_page(x)	((((unsigned)(x)) + NBPG - 1) & ~(NBPG-1))
11447999Swilliam #define i386_trunc_page(x)	((unsigned)(x) & ~(NBPG-1))
11547999Swilliam #define i386_btod(x)		((unsigned)(x) >> PDRSHIFT)
11647999Swilliam #define i386_dtob(x)		((unsigned)(x) << PDRSHIFT)
11747999Swilliam #define i386_btop(x)		((unsigned)(x) >> PGSHIFT)
11847999Swilliam #define i386_ptob(x)		((unsigned)(x) << PGSHIFT)
11947999Swilliam 
120*53638Sbostic #ifndef KERNEL
121*53638Sbostic /* DELAY is in locore.s for the kernel */
12240461Sbill #define	DELAY(n)	{ register int N = (n); while (--N > 0); }
12350031Sbostic #endif
124