xref: /csrg-svn/sys/hp300/include/param.h (revision 54794)
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  *
1253928Shibler  * from: Utah $Hdr: machparam.h 1.12 91/01/18$
1341474Smckusick  *
14*54794Smckusick  *	@(#)param.h	7.12 (Berkeley) 07/08/92
1541474Smckusick  */
1641474Smckusick 
1741474Smckusick /*
1841474Smckusick  * Machine dependent constants for HP9000 series 300.
1941474Smckusick  */
2041474Smckusick #define	MACHINE "hp300"
2141474Smckusick 
2250140Ssklower /*
2352588Sbostic  * Round p (pointer or byte index) up to a correctly-aligned value for all
2452588Sbostic  * data types (int, long, ...).   The result is u_int and must be cast to
2552588Sbostic  * any desired pointer type.
2650140Ssklower  */
2753672Sbostic #define	ALIGNBYTES	3
2853672Sbostic #define	ALIGN(p)	(((u_int)(p) + ALIGNBYTES) &~ ALIGNBYTES)
2950140Ssklower 
3041474Smckusick #define	NBPG		4096		/* bytes/page */
3141474Smckusick #define	PGOFSET		(NBPG-1)	/* byte offset into page */
3241474Smckusick #define	PGSHIFT		12		/* LOG2(NBPG) */
3341474Smckusick #define	NPTEPG		(NBPG/(sizeof (struct pte)))
3441474Smckusick 
3553928Shibler #define NBSEG		0x400000	/* bytes/segment */
3641474Smckusick #define	SEGOFSET	(NBSEG-1)	/* byte offset into segment */
3741474Smckusick #define	SEGSHIFT	22		/* LOG2(NBSEG) */
3841474Smckusick 
3941474Smckusick #define	KERNBASE	0x00000000	/* start of kernel virtual */
4041474Smckusick #define	BTOPKERNBASE	((u_long)KERNBASE >> PGSHIFT)
4141474Smckusick 
4241474Smckusick #define	DEV_BSIZE	512
4341474Smckusick #define	DEV_BSHIFT	9		/* log2(DEV_BSIZE) */
4441474Smckusick #define BLKDEV_IOSIZE	2048
4541474Smckusick #define	MAXPHYS		(64 * 1024)	/* max raw I/O transfer size */
4641474Smckusick 
4741474Smckusick #define	CLSIZE		1
4841474Smckusick #define	CLSIZELOG2	0
4941474Smckusick 
5049136Skarels /* NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE */
5141474Smckusick #define	SSIZE		1		/* initial stack size/NBPG */
5241474Smckusick #define	SINCR		1		/* increment of stack/NBPG */
5341474Smckusick 
5441474Smckusick #define	UPAGES		3		/* pages of u-area */
5541474Smckusick 
5641474Smckusick /*
5741474Smckusick  * Constants related to network buffer management.
5841474Smckusick  * MCLBYTES must be no larger than CLBYTES (the software page size), and,
5941474Smckusick  * on machines that exchange pages of input or output buffers with mbuf
6041474Smckusick  * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
6141474Smckusick  * of the hardware page size.
6241474Smckusick  */
6341474Smckusick #define	MSIZE		128		/* size of an mbuf */
6441474Smckusick #define	MCLBYTES	1024
6541474Smckusick #define	MCLSHIFT	10
6641474Smckusick #define	MCLOFSET	(MCLBYTES - 1)
6741474Smckusick #ifndef NMBCLUSTERS
6841474Smckusick #ifdef GATEWAY
6941474Smckusick #define	NMBCLUSTERS	512		/* map size, max cluster allocation */
7041474Smckusick #else
7141474Smckusick #define	NMBCLUSTERS	256		/* map size, max cluster allocation */
7241474Smckusick #endif
7341474Smckusick #endif
7441474Smckusick 
7541474Smckusick /*
7641474Smckusick  * Size of kernel malloc arena in CLBYTES-sized logical pages
7741474Smckusick  */
7841474Smckusick #ifndef NKMEMCLUSTERS
7950266Skarels #define	NKMEMCLUSTERS	(2048*1024/CLBYTES)
8041474Smckusick #endif
8141474Smckusick 
8249427Skarels /* pages ("clicks") (4096 bytes) to disk blocks */
8341474Smckusick #define	ctod(x)	((x)<<(PGSHIFT-DEV_BSHIFT))
8441474Smckusick #define	dtoc(x)	((x)>>(PGSHIFT-DEV_BSHIFT))
8541474Smckusick #define	dtob(x)	((x)<<DEV_BSHIFT)
8641474Smckusick 
8749427Skarels /* pages to bytes */
8841474Smckusick #define	ctob(x)	((x)<<PGSHIFT)
8941474Smckusick 
9049427Skarels /* bytes to pages */
9141474Smckusick #define	btoc(x)	(((unsigned)(x)+(NBPG-1))>>PGSHIFT)
9241474Smckusick 
9341474Smckusick #define	btodb(bytes)	 		/* calculates (bytes / DEV_BSIZE) */ \
9441474Smckusick 	((unsigned)(bytes) >> DEV_BSHIFT)
9541474Smckusick #define	dbtob(db)			/* calculates (db * DEV_BSIZE) */ \
9641474Smckusick 	((unsigned)(db) << DEV_BSHIFT)
9741474Smckusick 
9841474Smckusick /*
9941474Smckusick  * Map a ``block device block'' to a file system block.
10049136Skarels  * This should be device dependent, and should use the bsize
10149136Skarels  * field from the disk label.
10241474Smckusick  * For now though just use DEV_BSIZE.
10341474Smckusick  */
10441474Smckusick #define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
10541474Smckusick 
10641474Smckusick /*
10745755Smckusick  * Mach derived conversion macros
10845755Smckusick  */
10945755Smckusick #define hp300_round_page(x)	((((unsigned)(x)) + NBPG - 1) & ~(NBPG-1))
11045755Smckusick #define hp300_trunc_page(x)	((unsigned)(x) & ~(NBPG-1))
11145755Smckusick #define hp300_btop(x)		((unsigned)(x) >> PGSHIFT)
11245755Smckusick #define hp300_ptob(x)		((unsigned)(x) << PGSHIFT)
11345755Smckusick 
11445755Smckusick /*
11549136Skarels  * spl functions; all but spl0 are done in-line
11641474Smckusick  */
11749136Skarels #include <machine/psl.h>
11841474Smckusick 
11949136Skarels #define _spl(s) \
12049136Skarels ({ \
12149136Skarels         register int _spl_r; \
12249136Skarels \
12349136Skarels         asm __volatile ("clrl %0; movew sr,%0; movew %1,sr" : \
12449136Skarels                 "&=d" (_spl_r) : "di" (s)); \
12549136Skarels         _spl_r; \
12649136Skarels })
12749136Skarels 
12849136Skarels /* spl0 requires checking for software interrupts */
12949136Skarels #define spl1()  _spl(PSL_S|PSL_IPL1)
13049136Skarels #define spl2()  _spl(PSL_S|PSL_IPL2)
13149136Skarels #define spl3()  _spl(PSL_S|PSL_IPL3)
13249136Skarels #define spl4()  _spl(PSL_S|PSL_IPL4)
13349136Skarels #define spl5()  _spl(PSL_S|PSL_IPL5)
13449136Skarels #define spl6()  _spl(PSL_S|PSL_IPL6)
13549136Skarels #define spl7()  _spl(PSL_S|PSL_IPL7)
13649136Skarels 
137*54794Smckusick #define splsoftclock()	spl1()
138*54794Smckusick #define splnet()	spl1()
139*54794Smckusick #define splbio()	spl5()
140*54794Smckusick #define splimp()	spl5()
141*54794Smckusick #define spltty()	spl5()
142*54794Smckusick #define splclock()	spl6()
143*54794Smckusick #define splstatclock()	spl6()
144*54794Smckusick #define splvm()		spl6()
145*54794Smckusick #define splhigh()	spl7()
146*54794Smckusick #define splsched()	spl7()
14749136Skarels 
14849136Skarels /* watch out for side effects */
14949136Skarels #define splx(s)         (s & PSL_IPL ? _spl(s) : spl0())
15049136Skarels 
15141474Smckusick #ifdef KERNEL
15241474Smckusick #ifndef LOCORE
15341474Smckusick int	cpuspeed;
15441474Smckusick #define	DELAY(n)	{ register int N = cpuspeed * (n); while (--N > 0); }
15541474Smckusick #endif
15650030Sbostic #else
15741474Smckusick #define	DELAY(n)	{ register int N = (n); while (--N > 0); }
15850030Sbostic #endif
15941474Smckusick 
16041474Smckusick #ifdef HPUXCOMPAT
16141474Smckusick /*
16241474Smckusick  * Constants/macros for HPUX multiple mapping of user address space.
16341474Smckusick  * Pages in the first 256Mb are mapped in at every 256Mb segment.
16453928Shibler  *
16553928Shibler  * XXX broken in new VM XXX
16641474Smckusick  */
16741474Smckusick #define HPMMMASK	0xF0000000
16853928Shibler #define ISHPMMADDR(v) \
16953928Shibler 	((curproc->p_addr->u_pcb.pcb_flags & PCB_HPUXMMAP) && \
17053928Shibler 	 ((unsigned)(v) & HPMMMASK) != HPMMMASK)
17153928Shibler #define HPMMBASEADDR(v) \
17253928Shibler 	((unsigned)(v) & ~HPMMMASK)
17341474Smckusick #endif
174