xref: /netbsd-src/sys/arch/mips/include/mips_param.h (revision 95d875fb90b1458e4f1de6950286ddcd6644bc61)
1 /*	$NetBSD: mips_param.h,v 1.15 1999/12/04 21:20:48 ragge Exp $	*/
2 
3 /*
4  * On mips, UPAGES is fixed by sys/arch/mips/mips/locore code
5  * to be the number of per-process-wired kernel-stack pages/PTES.
6  */
7 
8 #define	SSIZE		1		/* initial stack size/NBPG */
9 #define	SINCR		1		/* increment of stack/NBPG */
10 
11 #define	UPAGES		2		/* pages of u-area */
12 #define USPACE          (UPAGES*NBPG)   /* size of u-area in bytes */
13 
14 #ifndef MSGBUFSIZE
15 #define MSGBUFSIZE	NBPG		/* default message buffer size */
16 #endif
17 
18 /*
19  * Round p (pointer or byte index) up to a correctly-aligned value for all
20  * data types (int, long, ...).   The result is u_int and must be cast to
21  * any desired pointer type.
22  *
23  * ALIGNED_POINTER is a boolean macro that checks whether an address
24  * is valid to fetch data elements of type t from on this architecture.
25  * This does not reflect the optimal alignment, just the possibility
26  * (within reasonable limits).
27  *
28  */
29 #define	ALIGNBYTES	7
30 #define	ALIGN(p)	(((u_int)(p) + ALIGNBYTES) & ~ALIGNBYTES)
31 #define ALIGNED_POINTER(p,t)	((((u_long)(p)) & (sizeof(t)-1)) == 0)
32 
33 #ifdef MIPS_16K_PAGE			/* enable kernel support for 16k pages  */
34 #define	NBPG		(1024*16)	/* bytes/page */
35 #define	PGOFSET		(NBPG-1)	/* byte offset into page */
36 #define	PGSHIFT		14		/* LOG2(NBPG) */
37 #else
38 #define	NBPG		4096		/* bytes/page */
39 #define	PGOFSET		(NBPG-1)	/* byte offset into page */
40 #define	PGSHIFT		12		/* LOG2(NBPG) */
41 #endif
42 #define	NPTEPG		(NBPG/4)
43 
44 #define NBSEG		0x400000	/* bytes/segment */
45 #define	SEGOFSET	(NBSEG-1)	/* byte offset into segment */
46 #define	SEGSHIFT	22		/* LOG2(NBSEG) */
47 
48 /*
49  * Size of kernel malloc arena in NBPG-sized logical pages
50  */
51 #ifndef NKMEMCLUSTERS
52 #define	NKMEMCLUSTERS	(6 * 1024 * 1024 / NBPG)
53 #endif
54 
55 /* pages ("clicks") (4096 bytes) to disk blocks */
56 #define	ctod(x)		((x) << (PGSHIFT - DEV_BSHIFT))
57 #define	dtoc(x)		((x) >> (PGSHIFT - DEV_BSHIFT))
58 
59 /* pages to bytes */
60 #define	ctob(x)		((x) << PGSHIFT)
61 #define btoc(x)		(((x) + PGOFSET) >> PGSHIFT)
62 
63 /* bytes to disk blocks */
64 #define	btodb(x)	((x) >> DEV_BSHIFT)
65 #define dbtob(x)	((x) << DEV_BSHIFT)
66 
67 /*
68  * Map a ``block device block'' to a file system block.
69  * This should be device dependent, and should use the bsize
70  * field from the disk label.
71  * For now though just use DEV_BSIZE.
72  */
73 #define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
74 
75 /*
76  * Mach derived conversion macros
77  */
78 #define mips_round_page(x)	((((unsigned)(x)) + NBPG - 1) & ~(NBPG-1))
79 #define mips_trunc_page(x)	((unsigned)(x) & ~(NBPG-1))
80 #define mips_btop(x)		((unsigned)(x) >> PGSHIFT)
81 #define mips_ptob(x)		((unsigned)(x) << PGSHIFT)
82