xref: /csrg-svn/sys/luna68k/include/param.h (revision 53974)
1*53974Sfujita /*
2*53974Sfujita  * Copyright (c) 1988 University of Utah.
3*53974Sfujita  * Copyright (c) 1992 OMRON Corporation.
4*53974Sfujita  * Copyright (c) 1982, 1986, 1990, 1992 The Regents of the University of California.
5*53974Sfujita  * All rights reserved.
6*53974Sfujita  *
7*53974Sfujita  * This code is derived from software contributed to Berkeley by
8*53974Sfujita  * the Systems Programming Group of the University of Utah Computer
9*53974Sfujita  * Science Department.
10*53974Sfujita  *
11*53974Sfujita  * %sccs.include.redist.c%
12*53974Sfujita  *
13*53974Sfujita  * from: Utah $Hdr: machparam.h 1.11 89/08/14$
14*53974Sfujita  * OMRON: $Id: param.h,v 1.3 92/06/14 06:28:28 moti Exp $
15*53974Sfujita  *
16*53974Sfujita  * from: hp300/include/param.h	7.8 (Berkeley) 6/28/91
17*53974Sfujita  *
18*53974Sfujita  *	@(#)param.h	7.1 (Berkeley) 06/15/92
19*53974Sfujita  */
20*53974Sfujita 
21*53974Sfujita /*
22*53974Sfujita  * Machine dependent constants for LUNA taken from:
23*53974Sfujita  * Param.h for HP9000 series 300.
24*53974Sfujita  */
25*53974Sfujita #define	MACHINE "luna68k"
26*53974Sfujita 
27*53974Sfujita /*
28*53974Sfujita  * Round p (pointer or byte index) up to a correctly-aligned value
29*53974Sfujita  * for all data types (int, long, ...).   The result is u_int and
30*53974Sfujita  * must be cast to any desired pointer type.
31*53974Sfujita  */
32*53974Sfujita #define	ALIGNBYTES	3
33*53974Sfujita #define	ALIGN(p)	(((u_int)(p) + ALIGNBYTES) &~ ALIGNBYTES)
34*53974Sfujita 
35*53974Sfujita #define	NBPG		4096		/* bytes/page */
36*53974Sfujita #define	PGOFSET		(NBPG-1)	/* byte offset into page */
37*53974Sfujita #define	PGSHIFT		12		/* LOG2(NBPG) */
38*53974Sfujita #define	NPTEPG		(NBPG/(sizeof (struct pte)))
39*53974Sfujita 
40*53974Sfujita #define NBSEG	       	0x400000	/* bytes/segment */
41*53974Sfujita #define	SEGOFSET	(NBSEG-1)	/* byte offset into segment */
42*53974Sfujita #define	SEGSHIFT	22		/* LOG2(NBSEG) */
43*53974Sfujita 
44*53974Sfujita #define	KERNBASE	0x00000000	/* start of kernel virtual */
45*53974Sfujita #define	BTOPKERNBASE	((u_long)KERNBASE >> PGSHIFT)
46*53974Sfujita 
47*53974Sfujita #define	DEV_BSIZE	512
48*53974Sfujita #define	DEV_BSHIFT	9		/* log2(DEV_BSIZE) */
49*53974Sfujita #define BLKDEV_IOSIZE	2048
50*53974Sfujita #define	MAXPHYS		(64 * 1024)	/* max raw I/O transfer size */
51*53974Sfujita 
52*53974Sfujita #define	CLSIZE		1
53*53974Sfujita #define	CLSIZELOG2	0
54*53974Sfujita 
55*53974Sfujita /* NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE */
56*53974Sfujita #define	SSIZE		1		/* initial stack size/NBPG */
57*53974Sfujita #define	SINCR		1		/* increment of stack/NBPG */
58*53974Sfujita 
59*53974Sfujita #define	UPAGES		3		/* pages of u-area */
60*53974Sfujita 
61*53974Sfujita /*
62*53974Sfujita  * Constants related to network buffer management.
63*53974Sfujita  * MCLBYTES must be no larger than CLBYTES (the software page size), and,
64*53974Sfujita  * on machines that exchange pages of input or output buffers with mbuf
65*53974Sfujita  * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
66*53974Sfujita  * of the hardware page size.
67*53974Sfujita  */
68*53974Sfujita #define	MSIZE		128		/* size of an mbuf */
69*53974Sfujita #define	MCLBYTES	1024
70*53974Sfujita #define	MCLSHIFT	10
71*53974Sfujita #define	MCLOFSET	(MCLBYTES - 1)
72*53974Sfujita #ifndef NMBCLUSTERS
73*53974Sfujita #ifdef GATEWAY
74*53974Sfujita #define	NMBCLUSTERS	512		/* map size, max cluster allocation */
75*53974Sfujita #else
76*53974Sfujita #define	NMBCLUSTERS	256		/* map size, max cluster allocation */
77*53974Sfujita #endif
78*53974Sfujita #endif
79*53974Sfujita 
80*53974Sfujita /*
81*53974Sfujita  * Size of kernel malloc arena in CLBYTES-sized logical pages
82*53974Sfujita  */
83*53974Sfujita #ifndef NKMEMCLUSTERS
84*53974Sfujita #define	NKMEMCLUSTERS	(2048*1024/CLBYTES)
85*53974Sfujita #endif
86*53974Sfujita 
87*53974Sfujita /* pages ("clicks") (4096 bytes) to disk blocks */
88*53974Sfujita #define	ctod(x)	((x)<<(PGSHIFT-DEV_BSHIFT))
89*53974Sfujita #define	dtoc(x)	((x)>>(PGSHIFT-DEV_BSHIFT))
90*53974Sfujita #define	dtob(x)	((x)<<DEV_BSHIFT)
91*53974Sfujita 
92*53974Sfujita /* pages to bytes */
93*53974Sfujita #define	ctob(x)	((x)<<PGSHIFT)
94*53974Sfujita 
95*53974Sfujita /* bytes to pages */
96*53974Sfujita #define	btoc(x)	(((unsigned)(x)+(NBPG-1))>>PGSHIFT)
97*53974Sfujita 
98*53974Sfujita #define	btodb(bytes)	 		/* calculates (bytes / DEV_BSIZE) */ \
99*53974Sfujita 	((unsigned)(bytes) >> DEV_BSHIFT)
100*53974Sfujita #define	dbtob(db)			/* calculates (db * DEV_BSIZE) */ \
101*53974Sfujita 	((unsigned)(db) << DEV_BSHIFT)
102*53974Sfujita 
103*53974Sfujita /*
104*53974Sfujita  * Map a ``block device block'' to a file system block.
105*53974Sfujita  * This should be device dependent, and should use the bsize
106*53974Sfujita  * field from the disk label.
107*53974Sfujita  * For now though just use DEV_BSIZE.
108*53974Sfujita  */
109*53974Sfujita #define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
110*53974Sfujita 
111*53974Sfujita /*
112*53974Sfujita  * Mach derived conversion macros
113*53974Sfujita  */
114*53974Sfujita #define luna_round_page(x)	((((unsigned)(x)) + NBPG - 1) & ~(NBPG-1))
115*53974Sfujita #define luna_trunc_page(x)	((unsigned)(x) & ~(NBPG-1))
116*53974Sfujita #define luna_btop(x)		((unsigned)(x) >> PGSHIFT)
117*53974Sfujita #define luna_ptob(x)		((unsigned)(x) << PGSHIFT)
118*53974Sfujita 
119*53974Sfujita /*
120*53974Sfujita  * spl functions; all but spl0 are done in-line
121*53974Sfujita  */
122*53974Sfujita #include <machine/psl.h>
123*53974Sfujita 
124*53974Sfujita #define _spl(s) \
125*53974Sfujita ({ \
126*53974Sfujita         register int _spl_r; \
127*53974Sfujita \
128*53974Sfujita         asm __volatile ("clrl %0; movew sr,%0; movew %1,sr" : \
129*53974Sfujita                 "&=d" (_spl_r) : "di" (s)); \
130*53974Sfujita         _spl_r; \
131*53974Sfujita })
132*53974Sfujita 
133*53974Sfujita /* spl0 requires checking for software interrupts */
134*53974Sfujita #define spl1()  _spl(PSL_S|PSL_IPL1)
135*53974Sfujita #define spl2()  _spl(PSL_S|PSL_IPL2)
136*53974Sfujita #define spl3()  _spl(PSL_S|PSL_IPL3)
137*53974Sfujita #define spl4()  _spl(PSL_S|PSL_IPL4)
138*53974Sfujita #define spl5()  _spl(PSL_S|PSL_IPL5)
139*53974Sfujita #define spl6()  _spl(PSL_S|PSL_IPL6)
140*53974Sfujita #define spl7()  _spl(PSL_S|PSL_IPL7)
141*53974Sfujita 
142*53974Sfujita #define splsoftclock()  spl1()
143*53974Sfujita #define splnet()        spl1()
144*53974Sfujita #define splbio()        spl5()
145*53974Sfujita #define splimp()        spl5()
146*53974Sfujita #define spltty()        spl6()
147*53974Sfujita #define splclock()      spl5()
148*53974Sfujita #define splvm()         spl6()
149*53974Sfujita #define splhigh()       spl7()
150*53974Sfujita #define splsched()      spl7()
151*53974Sfujita 
152*53974Sfujita /* watch out for side effects */
153*53974Sfujita #define splx(s)         (s & PSL_IPL ? _spl(s) : spl0())
154*53974Sfujita 
155*53974Sfujita #ifdef KERNEL
156*53974Sfujita #ifndef LOCORE
157*53974Sfujita int	cpuspeed;
158*53974Sfujita #define	DELAY(n)	{ register int N = cpuspeed * (n); while (--N > 0); }
159*53974Sfujita #endif
160*53974Sfujita 
161*53974Sfujita #else
162*53974Sfujita #define	DELAY(n)	{ register int N = (n); while (--N > 0); }
163*53974Sfujita #endif
164