xref: /csrg-svn/sys/luna68k/include/param.h (revision 55583)
153974Sfujita /*
253974Sfujita  * Copyright (c) 1988 University of Utah.
353974Sfujita  * Copyright (c) 1992 OMRON Corporation.
453974Sfujita  * Copyright (c) 1982, 1986, 1990, 1992 The Regents of the University of California.
553974Sfujita  * All rights reserved.
653974Sfujita  *
753974Sfujita  * This code is derived from software contributed to Berkeley by
853974Sfujita  * the Systems Programming Group of the University of Utah Computer
953974Sfujita  * Science Department.
1053974Sfujita  *
1153974Sfujita  * %sccs.include.redist.c%
1253974Sfujita  *
1353974Sfujita  * from: Utah $Hdr: machparam.h 1.11 89/08/14$
1453974Sfujita  * OMRON: $Id: param.h,v 1.3 92/06/14 06:28:28 moti Exp $
1553974Sfujita  *
16*55583Sfujita  * from: hp300/include/param.h	7.12 (Berkeley) 7/8/92
1753974Sfujita  *
18*55583Sfujita  *	@(#)param.h	7.2 (Berkeley) 07/23/92
1953974Sfujita  */
2053974Sfujita 
2153974Sfujita /*
2253974Sfujita  * Machine dependent constants for LUNA taken from:
2353974Sfujita  * Param.h for HP9000 series 300.
2453974Sfujita  */
2553974Sfujita #define	MACHINE "luna68k"
2653974Sfujita 
2753974Sfujita /*
2853974Sfujita  * Round p (pointer or byte index) up to a correctly-aligned value
2953974Sfujita  * for all data types (int, long, ...).   The result is u_int and
3053974Sfujita  * must be cast to any desired pointer type.
3153974Sfujita  */
3253974Sfujita #define	ALIGNBYTES	3
3353974Sfujita #define	ALIGN(p)	(((u_int)(p) + ALIGNBYTES) &~ ALIGNBYTES)
3453974Sfujita 
3553974Sfujita #define	NBPG		4096		/* bytes/page */
3653974Sfujita #define	PGOFSET		(NBPG-1)	/* byte offset into page */
3753974Sfujita #define	PGSHIFT		12		/* LOG2(NBPG) */
3853974Sfujita #define	NPTEPG		(NBPG/(sizeof (struct pte)))
3953974Sfujita 
4053974Sfujita #define NBSEG	       	0x400000	/* bytes/segment */
4153974Sfujita #define	SEGOFSET	(NBSEG-1)	/* byte offset into segment */
4253974Sfujita #define	SEGSHIFT	22		/* LOG2(NBSEG) */
4353974Sfujita 
4453974Sfujita #define	KERNBASE	0x00000000	/* start of kernel virtual */
4553974Sfujita #define	BTOPKERNBASE	((u_long)KERNBASE >> PGSHIFT)
4653974Sfujita 
4753974Sfujita #define	DEV_BSIZE	512
4853974Sfujita #define	DEV_BSHIFT	9		/* log2(DEV_BSIZE) */
4953974Sfujita #define BLKDEV_IOSIZE	2048
5053974Sfujita #define	MAXPHYS		(64 * 1024)	/* max raw I/O transfer size */
5153974Sfujita 
5253974Sfujita #define	CLSIZE		1
5353974Sfujita #define	CLSIZELOG2	0
5453974Sfujita 
5553974Sfujita /* NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE */
5653974Sfujita #define	SSIZE		1		/* initial stack size/NBPG */
5753974Sfujita #define	SINCR		1		/* increment of stack/NBPG */
5853974Sfujita 
5953974Sfujita #define	UPAGES		3		/* pages of u-area */
6053974Sfujita 
6153974Sfujita /*
6253974Sfujita  * Constants related to network buffer management.
6353974Sfujita  * MCLBYTES must be no larger than CLBYTES (the software page size), and,
6453974Sfujita  * on machines that exchange pages of input or output buffers with mbuf
6553974Sfujita  * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
6653974Sfujita  * of the hardware page size.
6753974Sfujita  */
6853974Sfujita #define	MSIZE		128		/* size of an mbuf */
6953974Sfujita #define	MCLBYTES	1024
7053974Sfujita #define	MCLSHIFT	10
7153974Sfujita #define	MCLOFSET	(MCLBYTES - 1)
7253974Sfujita #ifndef NMBCLUSTERS
7353974Sfujita #ifdef GATEWAY
7453974Sfujita #define	NMBCLUSTERS	512		/* map size, max cluster allocation */
7553974Sfujita #else
7653974Sfujita #define	NMBCLUSTERS	256		/* map size, max cluster allocation */
7753974Sfujita #endif
7853974Sfujita #endif
7953974Sfujita 
8053974Sfujita /*
8153974Sfujita  * Size of kernel malloc arena in CLBYTES-sized logical pages
8253974Sfujita  */
8353974Sfujita #ifndef NKMEMCLUSTERS
8453974Sfujita #define	NKMEMCLUSTERS	(2048*1024/CLBYTES)
8553974Sfujita #endif
8653974Sfujita 
8753974Sfujita /* pages ("clicks") (4096 bytes) to disk blocks */
8853974Sfujita #define	ctod(x)	((x)<<(PGSHIFT-DEV_BSHIFT))
8953974Sfujita #define	dtoc(x)	((x)>>(PGSHIFT-DEV_BSHIFT))
9053974Sfujita #define	dtob(x)	((x)<<DEV_BSHIFT)
9153974Sfujita 
9253974Sfujita /* pages to bytes */
9353974Sfujita #define	ctob(x)	((x)<<PGSHIFT)
9453974Sfujita 
9553974Sfujita /* bytes to pages */
9653974Sfujita #define	btoc(x)	(((unsigned)(x)+(NBPG-1))>>PGSHIFT)
9753974Sfujita 
9853974Sfujita #define	btodb(bytes)	 		/* calculates (bytes / DEV_BSIZE) */ \
9953974Sfujita 	((unsigned)(bytes) >> DEV_BSHIFT)
10053974Sfujita #define	dbtob(db)			/* calculates (db * DEV_BSIZE) */ \
10153974Sfujita 	((unsigned)(db) << DEV_BSHIFT)
10253974Sfujita 
10353974Sfujita /*
10453974Sfujita  * Map a ``block device block'' to a file system block.
10553974Sfujita  * This should be device dependent, and should use the bsize
10653974Sfujita  * field from the disk label.
10753974Sfujita  * For now though just use DEV_BSIZE.
10853974Sfujita  */
10953974Sfujita #define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
11053974Sfujita 
11153974Sfujita /*
11253974Sfujita  * Mach derived conversion macros
11353974Sfujita  */
11453974Sfujita #define luna_round_page(x)	((((unsigned)(x)) + NBPG - 1) & ~(NBPG-1))
11553974Sfujita #define luna_trunc_page(x)	((unsigned)(x) & ~(NBPG-1))
11653974Sfujita #define luna_btop(x)		((unsigned)(x) >> PGSHIFT)
11753974Sfujita #define luna_ptob(x)		((unsigned)(x) << PGSHIFT)
11853974Sfujita 
11953974Sfujita /*
12053974Sfujita  * spl functions; all but spl0 are done in-line
12153974Sfujita  */
12253974Sfujita #include <machine/psl.h>
12353974Sfujita 
12453974Sfujita #define _spl(s) \
12553974Sfujita ({ \
12653974Sfujita         register int _spl_r; \
12753974Sfujita \
12853974Sfujita         asm __volatile ("clrl %0; movew sr,%0; movew %1,sr" : \
12953974Sfujita                 "&=d" (_spl_r) : "di" (s)); \
13053974Sfujita         _spl_r; \
13153974Sfujita })
13253974Sfujita 
13353974Sfujita /* spl0 requires checking for software interrupts */
13453974Sfujita #define spl1()  _spl(PSL_S|PSL_IPL1)
13553974Sfujita #define spl2()  _spl(PSL_S|PSL_IPL2)
13653974Sfujita #define spl3()  _spl(PSL_S|PSL_IPL3)
13753974Sfujita #define spl4()  _spl(PSL_S|PSL_IPL4)
13853974Sfujita #define spl5()  _spl(PSL_S|PSL_IPL5)
13953974Sfujita #define spl6()  _spl(PSL_S|PSL_IPL6)
14053974Sfujita #define spl7()  _spl(PSL_S|PSL_IPL7)
14153974Sfujita 
142*55583Sfujita #define splsoftclock()	spl1()
143*55583Sfujita #define splnet()	spl1()
144*55583Sfujita #define splbio()	spl5()
145*55583Sfujita #define splimp()	spl5()
146*55583Sfujita #define spltty()	spl6()
147*55583Sfujita #define splclock()	spl5()
148*55583Sfujita #define splstatclock()	spl5()
149*55583Sfujita #define splvm()		spl6()
150*55583Sfujita #define splhigh()	spl7()
151*55583Sfujita #define splsched()	spl7()
15253974Sfujita 
15353974Sfujita /* watch out for side effects */
15453974Sfujita #define splx(s)         (s & PSL_IPL ? _spl(s) : spl0())
15553974Sfujita 
15653974Sfujita #ifdef KERNEL
15753974Sfujita #ifndef LOCORE
15853974Sfujita int	cpuspeed;
15953974Sfujita #define	DELAY(n)	{ register int N = cpuspeed * (n); while (--N > 0); }
16053974Sfujita #endif
16153974Sfujita 
16253974Sfujita #else
16353974Sfujita #define	DELAY(n)	{ register int N = (n); while (--N > 0); }
16453974Sfujita #endif
165