xref: /csrg-svn/sys/hp300/include/param.h (revision 50030)
141474Smckusick /*
241474Smckusick  * Copyright (c) 1988 University of Utah.
341474Smckusick  * Copyright (c) 1982, 1986, 1990 The Regents of the University of California.
441474Smckusick  * All rights reserved.
541474Smckusick  *
641474Smckusick  * This code is derived from software contributed to Berkeley by
741474Smckusick  * the Systems Programming Group of the University of Utah Computer
841474Smckusick  * Science Department.
941474Smckusick  *
1041474Smckusick  * %sccs.include.redist.c%
1141474Smckusick  *
1241474Smckusick  * from: Utah $Hdr: machparam.h 1.11 89/08/14$
1341474Smckusick  *
14*50030Sbostic  *	@(#)param.h	7.6 (Berkeley) 06/08/91
1541474Smckusick  */
1641474Smckusick 
1741474Smckusick /*
1841474Smckusick  * Machine dependent constants for HP9000 series 300.
1941474Smckusick  */
2041474Smckusick #define	MACHINE "hp300"
2141474Smckusick 
2241474Smckusick #define	NBPG		4096		/* bytes/page */
2341474Smckusick #define	PGOFSET		(NBPG-1)	/* byte offset into page */
2441474Smckusick #define	PGSHIFT		12		/* LOG2(NBPG) */
2541474Smckusick #define	NPTEPG		(NBPG/(sizeof (struct pte)))
2641474Smckusick 
2741474Smckusick #define NBSEG		(1024*NBPG)	/* bytes/segment */
2841474Smckusick #define	SEGOFSET	(NBSEG-1)	/* byte offset into segment */
2941474Smckusick #define	SEGSHIFT	22		/* LOG2(NBSEG) */
3041474Smckusick 
3141474Smckusick #define	KERNBASE	0x00000000	/* start of kernel virtual */
3241474Smckusick #define	BTOPKERNBASE	((u_long)KERNBASE >> PGSHIFT)
3341474Smckusick 
3441474Smckusick #define	DEV_BSIZE	512
3541474Smckusick #define	DEV_BSHIFT	9		/* log2(DEV_BSIZE) */
3641474Smckusick #define BLKDEV_IOSIZE	2048
3741474Smckusick #define	MAXPHYS		(64 * 1024)	/* max raw I/O transfer size */
3841474Smckusick 
3941474Smckusick #define	CLSIZE		1
4041474Smckusick #define	CLSIZELOG2	0
4141474Smckusick 
4249136Skarels /* NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE */
4341474Smckusick #define	SSIZE		1		/* initial stack size/NBPG */
4441474Smckusick #define	SINCR		1		/* increment of stack/NBPG */
4541474Smckusick 
4641474Smckusick #define	UPAGES		3		/* pages of u-area */
4741474Smckusick 
4841474Smckusick /*
4941474Smckusick  * Constants related to network buffer management.
5041474Smckusick  * MCLBYTES must be no larger than CLBYTES (the software page size), and,
5141474Smckusick  * on machines that exchange pages of input or output buffers with mbuf
5241474Smckusick  * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
5341474Smckusick  * of the hardware page size.
5441474Smckusick  */
5541474Smckusick #define	MSIZE		128		/* size of an mbuf */
5641474Smckusick #define	MCLBYTES	1024
5741474Smckusick #define	MCLSHIFT	10
5841474Smckusick #define	MCLOFSET	(MCLBYTES - 1)
5941474Smckusick #ifndef NMBCLUSTERS
6041474Smckusick #ifdef GATEWAY
6141474Smckusick #define	NMBCLUSTERS	512		/* map size, max cluster allocation */
6241474Smckusick #else
6341474Smckusick #define	NMBCLUSTERS	256		/* map size, max cluster allocation */
6441474Smckusick #endif
6541474Smckusick #endif
6641474Smckusick 
6741474Smckusick /*
6841474Smckusick  * Size of kernel malloc arena in CLBYTES-sized logical pages
6941474Smckusick  */
7041474Smckusick #ifndef NKMEMCLUSTERS
7141474Smckusick #define	NKMEMCLUSTERS	(512*1024/CLBYTES)
7241474Smckusick #endif
7341474Smckusick 
7449427Skarels /* pages ("clicks") (4096 bytes) to disk blocks */
7541474Smckusick #define	ctod(x)	((x)<<(PGSHIFT-DEV_BSHIFT))
7641474Smckusick #define	dtoc(x)	((x)>>(PGSHIFT-DEV_BSHIFT))
7741474Smckusick #define	dtob(x)	((x)<<DEV_BSHIFT)
7841474Smckusick 
7949427Skarels /* pages to bytes */
8041474Smckusick #define	ctob(x)	((x)<<PGSHIFT)
8141474Smckusick 
8249427Skarels /* bytes to pages */
8341474Smckusick #define	btoc(x)	(((unsigned)(x)+(NBPG-1))>>PGSHIFT)
8441474Smckusick 
8541474Smckusick #define	btodb(bytes)	 		/* calculates (bytes / DEV_BSIZE) */ \
8641474Smckusick 	((unsigned)(bytes) >> DEV_BSHIFT)
8741474Smckusick #define	dbtob(db)			/* calculates (db * DEV_BSIZE) */ \
8841474Smckusick 	((unsigned)(db) << DEV_BSHIFT)
8941474Smckusick 
9041474Smckusick /*
9141474Smckusick  * Map a ``block device block'' to a file system block.
9249136Skarels  * This should be device dependent, and should use the bsize
9349136Skarels  * field from the disk label.
9441474Smckusick  * For now though just use DEV_BSIZE.
9541474Smckusick  */
9641474Smckusick #define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
9741474Smckusick 
9841474Smckusick /*
9945755Smckusick  * Mach derived conversion macros
10045755Smckusick  */
10145755Smckusick #define hp300_round_seg(x)	((((unsigned)(x)) + NBSEG - 1) & ~(NBSEG-1))
10245755Smckusick #define hp300_trunc_seg(x)	((unsigned)(x) & ~(NBSEG-1))
10345755Smckusick #define hp300_round_page(x)	((((unsigned)(x)) + NBPG - 1) & ~(NBPG-1))
10445755Smckusick #define hp300_trunc_page(x)	((unsigned)(x) & ~(NBPG-1))
10545755Smckusick #define hp300_btos(x)		((unsigned)(x) >> SEGSHIFT)
10645755Smckusick #define hp300_stob(x)		((unsigned)(x) << SEGSHIFT)
10745755Smckusick #define hp300_btop(x)		((unsigned)(x) >> PGSHIFT)
10845755Smckusick #define hp300_ptob(x)		((unsigned)(x) << PGSHIFT)
10945755Smckusick 
11045755Smckusick /*
11149136Skarels  * spl functions; all but spl0 are done in-line
11241474Smckusick  */
11349136Skarels #include <machine/psl.h>
11441474Smckusick 
11549136Skarels #define _spl(s) \
11649136Skarels ({ \
11749136Skarels         register int _spl_r; \
11849136Skarels \
11949136Skarels         asm __volatile ("clrl %0; movew sr,%0; movew %1,sr" : \
12049136Skarels                 "&=d" (_spl_r) : "di" (s)); \
12149136Skarels         _spl_r; \
12249136Skarels })
12349136Skarels 
12449136Skarels /* spl0 requires checking for software interrupts */
12549136Skarels #define spl1()  _spl(PSL_S|PSL_IPL1)
12649136Skarels #define spl2()  _spl(PSL_S|PSL_IPL2)
12749136Skarels #define spl3()  _spl(PSL_S|PSL_IPL3)
12849136Skarels #define spl4()  _spl(PSL_S|PSL_IPL4)
12949136Skarels #define spl5()  _spl(PSL_S|PSL_IPL5)
13049136Skarels #define spl6()  _spl(PSL_S|PSL_IPL6)
13149136Skarels #define spl7()  _spl(PSL_S|PSL_IPL7)
13249136Skarels 
13349136Skarels #define splsoftclock()  spl1()
13449136Skarels #define splnet()        spl1()
13549136Skarels #define splbio()        spl5()
13649136Skarels #define splimp()        spl5()
13749136Skarels #define spltty()        spl5()
13849136Skarels #define splclock()      spl6()
13949136Skarels #define splvm()         spl6()
14049136Skarels #define splhigh()       spl7()
14149136Skarels #define splsched()      spl7()
14249136Skarels 
14349136Skarels /* watch out for side effects */
14449136Skarels #define splx(s)         (s & PSL_IPL ? _spl(s) : spl0())
14549136Skarels 
14641474Smckusick #ifdef KERNEL
14741474Smckusick #ifndef LOCORE
14841474Smckusick int	cpuspeed;
14941474Smckusick #define	DELAY(n)	{ register int N = cpuspeed * (n); while (--N > 0); }
15041474Smckusick #endif
15141474Smckusick 
152*50030Sbostic #else
15341474Smckusick #define	DELAY(n)	{ register int N = (n); while (--N > 0); }
154*50030Sbostic #endif
15541474Smckusick 
15641474Smckusick #ifdef HPUXCOMPAT
15741474Smckusick /*
15841474Smckusick  * Constants/macros for HPUX multiple mapping of user address space.
15941474Smckusick  * Pages in the first 256Mb are mapped in at every 256Mb segment.
16041474Smckusick  */
16141474Smckusick #define HPMMMASK	0xF0000000
16241474Smckusick #define ISHPMMADDR(v)	\
16349136Skarels     ((curproc->p_addr->u_pcb.pcb_flags&PCB_HPUXMMAP) && ((unsigned)(v)&HPMMMASK) != HPMMMASK)
16441474Smckusick #define HPMMBASEADDR(v)	((unsigned)(v) & ~HPMMMASK)
16541474Smckusick #endif
166