xref: /csrg-svn/sys/hp300/include/param.h (revision 50140)
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*50140Ssklower  *	@(#)param.h	7.7 (Berkeley) 06/26/91
1541474Smckusick  */
1641474Smckusick 
1741474Smckusick /*
1841474Smckusick  * Machine dependent constants for HP9000 series 300.
1941474Smckusick  */
2041474Smckusick #define	MACHINE "hp300"
2141474Smckusick 
22*50140Ssklower /*
23*50140Ssklower  * Round p (pointer or byte index) up to a correctly-aligned value
24*50140Ssklower  * for all data types (int, long, ...).   The result is u_int and
25*50140Ssklower  * must be cast to any desired pointer type.
26*50140Ssklower  */
27*50140Ssklower #define	ALIGN(p)	(((u_int)(p) + (sizeof(int) - 1)) &~ (sizeof(int) - 1))
28*50140Ssklower 
2941474Smckusick #define	NBPG		4096		/* bytes/page */
3041474Smckusick #define	PGOFSET		(NBPG-1)	/* byte offset into page */
3141474Smckusick #define	PGSHIFT		12		/* LOG2(NBPG) */
3241474Smckusick #define	NPTEPG		(NBPG/(sizeof (struct pte)))
3341474Smckusick 
3441474Smckusick #define NBSEG		(1024*NBPG)	/* bytes/segment */
3541474Smckusick #define	SEGOFSET	(NBSEG-1)	/* byte offset into segment */
3641474Smckusick #define	SEGSHIFT	22		/* LOG2(NBSEG) */
3741474Smckusick 
3841474Smckusick #define	KERNBASE	0x00000000	/* start of kernel virtual */
3941474Smckusick #define	BTOPKERNBASE	((u_long)KERNBASE >> PGSHIFT)
4041474Smckusick 
4141474Smckusick #define	DEV_BSIZE	512
4241474Smckusick #define	DEV_BSHIFT	9		/* log2(DEV_BSIZE) */
4341474Smckusick #define BLKDEV_IOSIZE	2048
4441474Smckusick #define	MAXPHYS		(64 * 1024)	/* max raw I/O transfer size */
4541474Smckusick 
4641474Smckusick #define	CLSIZE		1
4741474Smckusick #define	CLSIZELOG2	0
4841474Smckusick 
4949136Skarels /* NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE */
5041474Smckusick #define	SSIZE		1		/* initial stack size/NBPG */
5141474Smckusick #define	SINCR		1		/* increment of stack/NBPG */
5241474Smckusick 
5341474Smckusick #define	UPAGES		3		/* pages of u-area */
5441474Smckusick 
5541474Smckusick /*
5641474Smckusick  * Constants related to network buffer management.
5741474Smckusick  * MCLBYTES must be no larger than CLBYTES (the software page size), and,
5841474Smckusick  * on machines that exchange pages of input or output buffers with mbuf
5941474Smckusick  * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
6041474Smckusick  * of the hardware page size.
6141474Smckusick  */
6241474Smckusick #define	MSIZE		128		/* size of an mbuf */
6341474Smckusick #define	MCLBYTES	1024
6441474Smckusick #define	MCLSHIFT	10
6541474Smckusick #define	MCLOFSET	(MCLBYTES - 1)
6641474Smckusick #ifndef NMBCLUSTERS
6741474Smckusick #ifdef GATEWAY
6841474Smckusick #define	NMBCLUSTERS	512		/* map size, max cluster allocation */
6941474Smckusick #else
7041474Smckusick #define	NMBCLUSTERS	256		/* map size, max cluster allocation */
7141474Smckusick #endif
7241474Smckusick #endif
7341474Smckusick 
7441474Smckusick /*
7541474Smckusick  * Size of kernel malloc arena in CLBYTES-sized logical pages
7641474Smckusick  */
7741474Smckusick #ifndef NKMEMCLUSTERS
7841474Smckusick #define	NKMEMCLUSTERS	(512*1024/CLBYTES)
7941474Smckusick #endif
8041474Smckusick 
8149427Skarels /* pages ("clicks") (4096 bytes) to disk blocks */
8241474Smckusick #define	ctod(x)	((x)<<(PGSHIFT-DEV_BSHIFT))
8341474Smckusick #define	dtoc(x)	((x)>>(PGSHIFT-DEV_BSHIFT))
8441474Smckusick #define	dtob(x)	((x)<<DEV_BSHIFT)
8541474Smckusick 
8649427Skarels /* pages to bytes */
8741474Smckusick #define	ctob(x)	((x)<<PGSHIFT)
8841474Smckusick 
8949427Skarels /* bytes to pages */
9041474Smckusick #define	btoc(x)	(((unsigned)(x)+(NBPG-1))>>PGSHIFT)
9141474Smckusick 
9241474Smckusick #define	btodb(bytes)	 		/* calculates (bytes / DEV_BSIZE) */ \
9341474Smckusick 	((unsigned)(bytes) >> DEV_BSHIFT)
9441474Smckusick #define	dbtob(db)			/* calculates (db * DEV_BSIZE) */ \
9541474Smckusick 	((unsigned)(db) << DEV_BSHIFT)
9641474Smckusick 
9741474Smckusick /*
9841474Smckusick  * Map a ``block device block'' to a file system block.
9949136Skarels  * This should be device dependent, and should use the bsize
10049136Skarels  * field from the disk label.
10141474Smckusick  * For now though just use DEV_BSIZE.
10241474Smckusick  */
10341474Smckusick #define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
10441474Smckusick 
10541474Smckusick /*
10645755Smckusick  * Mach derived conversion macros
10745755Smckusick  */
10845755Smckusick #define hp300_round_seg(x)	((((unsigned)(x)) + NBSEG - 1) & ~(NBSEG-1))
10945755Smckusick #define hp300_trunc_seg(x)	((unsigned)(x) & ~(NBSEG-1))
11045755Smckusick #define hp300_round_page(x)	((((unsigned)(x)) + NBPG - 1) & ~(NBPG-1))
11145755Smckusick #define hp300_trunc_page(x)	((unsigned)(x) & ~(NBPG-1))
11245755Smckusick #define hp300_btos(x)		((unsigned)(x) >> SEGSHIFT)
11345755Smckusick #define hp300_stob(x)		((unsigned)(x) << SEGSHIFT)
11445755Smckusick #define hp300_btop(x)		((unsigned)(x) >> PGSHIFT)
11545755Smckusick #define hp300_ptob(x)		((unsigned)(x) << PGSHIFT)
11645755Smckusick 
11745755Smckusick /*
11849136Skarels  * spl functions; all but spl0 are done in-line
11941474Smckusick  */
12049136Skarels #include <machine/psl.h>
12141474Smckusick 
12249136Skarels #define _spl(s) \
12349136Skarels ({ \
12449136Skarels         register int _spl_r; \
12549136Skarels \
12649136Skarels         asm __volatile ("clrl %0; movew sr,%0; movew %1,sr" : \
12749136Skarels                 "&=d" (_spl_r) : "di" (s)); \
12849136Skarels         _spl_r; \
12949136Skarels })
13049136Skarels 
13149136Skarels /* spl0 requires checking for software interrupts */
13249136Skarels #define spl1()  _spl(PSL_S|PSL_IPL1)
13349136Skarels #define spl2()  _spl(PSL_S|PSL_IPL2)
13449136Skarels #define spl3()  _spl(PSL_S|PSL_IPL3)
13549136Skarels #define spl4()  _spl(PSL_S|PSL_IPL4)
13649136Skarels #define spl5()  _spl(PSL_S|PSL_IPL5)
13749136Skarels #define spl6()  _spl(PSL_S|PSL_IPL6)
13849136Skarels #define spl7()  _spl(PSL_S|PSL_IPL7)
13949136Skarels 
14049136Skarels #define splsoftclock()  spl1()
14149136Skarels #define splnet()        spl1()
14249136Skarels #define splbio()        spl5()
14349136Skarels #define splimp()        spl5()
14449136Skarels #define spltty()        spl5()
14549136Skarels #define splclock()      spl6()
14649136Skarels #define splvm()         spl6()
14749136Skarels #define splhigh()       spl7()
14849136Skarels #define splsched()      spl7()
14949136Skarels 
15049136Skarels /* watch out for side effects */
15149136Skarels #define splx(s)         (s & PSL_IPL ? _spl(s) : spl0())
15249136Skarels 
15341474Smckusick #ifdef KERNEL
15441474Smckusick #ifndef LOCORE
15541474Smckusick int	cpuspeed;
15641474Smckusick #define	DELAY(n)	{ register int N = cpuspeed * (n); while (--N > 0); }
15741474Smckusick #endif
15841474Smckusick 
15950030Sbostic #else
16041474Smckusick #define	DELAY(n)	{ register int N = (n); while (--N > 0); }
16150030Sbostic #endif
16241474Smckusick 
16341474Smckusick #ifdef HPUXCOMPAT
16441474Smckusick /*
16541474Smckusick  * Constants/macros for HPUX multiple mapping of user address space.
16641474Smckusick  * Pages in the first 256Mb are mapped in at every 256Mb segment.
16741474Smckusick  */
16841474Smckusick #define HPMMMASK	0xF0000000
16941474Smckusick #define ISHPMMADDR(v)	\
17049136Skarels     ((curproc->p_addr->u_pcb.pcb_flags&PCB_HPUXMMAP) && ((unsigned)(v)&HPMMMASK) != HPMMMASK)
17141474Smckusick #define HPMMBASEADDR(v)	((unsigned)(v) & ~HPMMMASK)
17241474Smckusick #endif
173