xref: /netbsd-src/sys/arch/mips/include/mips_param.h (revision d0fed6c87ddc40a8bffa6f99e7433ddfc864dd83)
1 /*	$NetBSD: mips_param.h,v 1.2 1997/02/28 02:24:41 jonathan Exp $	*/
2 
3 /*
4  * Round p (pointer or byte index) up to a correctly-aligned value for all
5  * data types (int, long, ...).   The result is u_int and must be cast to
6  * any desired pointer type.
7  */
8 #define	ALIGNBYTES	7
9 #define	ALIGN(p)	(((u_int)(p) + ALIGNBYTES) &~ ALIGNBYTES)
10 #define ALIGNED_POINTER(p,t)	((((u_long)(p)) & (sizeof(t)-1)) == 0)
11 
12 #define	NBPG		4096		/* bytes/page */
13 #define	PGOFSET		(NBPG-1)	/* byte offset into page */
14 #define	PGSHIFT		12		/* LOG2(NBPG) */
15 #define	NPTEPG		(NBPG/4)
16 
17 #define NBSEG		0x400000	/* bytes/segment */
18 #define	SEGOFSET	(NBSEG-1)	/* byte offset into segment */
19 #define	SEGSHIFT	22		/* LOG2(NBSEG) */
20 
21 /*
22  * Size of kernel malloc arena in CLBYTES-sized logical pages
23  */
24 #ifndef NKMEMCLUSTERS
25 #define	NKMEMCLUSTERS	(512*1024/CLBYTES)
26 #endif
27 
28 /* pages ("clicks") (4096 bytes) to disk blocks */
29 #define	ctod(x)		((x) << (PGSHIFT - DEV_BSHIFT))
30 #define	dtoc(x)		((x) >> (PGSHIFT - DEV_BSHIFT))
31 
32 /* pages to bytes */
33 #define	ctob(x)		((x) << PGSHIFT)
34 #define btoc(x)		(((x) + PGOFSET) >> PGSHIFT)
35 
36 /* bytes to disk blocks */
37 #define	btodb(x)	((x) >> DEV_BSHIFT)
38 #define dbtob(x)	((x) << DEV_BSHIFT)
39 
40 /*
41  * Map a ``block device block'' to a file system block.
42  * This should be device dependent, and should use the bsize
43  * field from the disk label.
44  * For now though just use DEV_BSIZE.
45  */
46 #define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
47 
48 /*
49  * Mach derived conversion macros
50  */
51 #define mips_round_page(x)	((((unsigned)(x)) + NBPG - 1) & ~(NBPG-1))
52 #define mips_trunc_page(x)	((unsigned)(x) & ~(NBPG-1))
53 #define mips_btop(x)		((unsigned)(x) >> PGSHIFT)
54 #define mips_ptob(x)		((unsigned)(x) << PGSHIFT)
55 
56 #ifdef _KERNEL
57 #ifndef _LOCORE
58 typedef int spl_t;
59 extern spl_t splx __P((spl_t));
60 extern spl_t splsoftnet __P((void)), splsoftclock __P((void));
61 extern spl_t splhigh __P((void));
62 extern spl_t spl0 __P((void));	/* XXX should not enable TC on 3min */
63 
64 extern void setsoftnet __P((void)), clearsoftnet __P((void));
65 extern void setsoftclock __P((void)), clearsoftclock __P((void));
66 
67 
68 extern int (*Mach_splnet) __P((void)), (*Mach_splbio) __P((void)),
69 	   (*Mach_splimp) __P((void)), (*Mach_spltty) __P((void)),
70 	   (*Mach_splclock) __P((void)), (*Mach_splstatclock) __P((void)),
71 	   (*Mach_splnone) __P((void));
72 #define	splnet()	((*Mach_splnet)())
73 #define	splbio()	((*Mach_splbio)())
74 #define	splimp()	((*Mach_splimp)())
75 #define	spltty()	((*Mach_spltty)())
76 #define	splclock()	((*Mach_splclock)())
77 #define	splstatclock()	((*Mach_splstatclock)())
78 
79 extern void wbflush __P ((void));		/* XXX */
80 extern void delay __P((int n));
81 
82 #endif	/* _LOCORE */
83 #endif	/* _KERNEL */
84