xref: /netbsd-src/sys/arch/mips/include/mips_param.h (revision abb0f93cd77b67f080613360c65701f85e5f5cfe)
1 /*	$NetBSD: mips_param.h,v 1.25 2009/08/13 05:15:09 matt Exp $	*/
2 
3 #ifdef _KERNEL
4 #include <machine/cpu.h>
5 #endif
6 
7 /*
8  * On mips, UPAGES is fixed by sys/arch/mips/mips/locore code
9  * to be the number of per-process-wired kernel-stack pages/PTES.
10  */
11 
12 #define	SSIZE		1		/* initial stack size/NBPG */
13 #define	SINCR		1		/* increment of stack/NBPG */
14 
15 #ifdef ENABLE_MIPS_16KB_PAGE
16 #define	UPAGES		1		/* pages of u-area */
17 #define	USPACE		(UPAGES*NBPG)	/* size of u-area in bytes */
18 #elif defined(ENABLE_MIPS_4KB_PAGE) || 1
19 #define	UPAGES		2		/* pages of u-area */
20 #define	USPACE		(UPAGES*NBPG)	/* size of u-area in bytes */
21 #else
22 #error ENABLE_MIPS_xKB_PAGE not defined
23 #endif
24 
25 #ifndef MSGBUFSIZE
26 #define MSGBUFSIZE	NBPG		/* default message buffer size */
27 #endif
28 
29 /*
30  * Round p (pointer or byte index) up to a correctly-aligned value for all
31  * data types (int, long, ...).   The result is u_int and must be cast to
32  * any desired pointer type.
33  *
34  * ALIGNED_POINTER is a boolean macro that checks whether an address
35  * is valid to fetch data elements of type t from on this architecture.
36  * This does not reflect the optimal alignment, just the possibility
37  * (within reasonable limits).
38  *
39  */
40 #define	ALIGNBYTES	7
41 #define	ALIGN(p)	(((uintptr_t)(p) + ALIGNBYTES) & ~ALIGNBYTES)
42 #define ALIGNED_POINTER(p,t)	((((uintptr_t)(p)) & (sizeof(t)-1)) == 0)
43 
44 #ifdef ENABLE_MIPS_16KB_PAGE
45 #define	NBPG		16384		/* bytes/page */
46 #define	PGSHIFT		14		/* LOG2(NBPG) */
47 #else
48 #define	NBPG		4096		/* bytes/page */
49 #define	PGSHIFT		12		/* LOG2(NBPG) */
50 #endif
51 #define	PGOFSET		(NBPG-1)	/* byte offset into page */
52 #define	NPTEPG		(NBPG/4)
53 
54 #define NBSEG		(NBPG*NPTEPG)	/* bytes/segment */
55 #define	SEGOFSET	(NBSEG-1)	/* byte offset into segment */
56 #define	SEGSHIFT	(2*PGSHIFT-2)	/* LOG2(NBSEG) */
57 
58 /*
59  * Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized
60  * logical pages.
61  */
62 #define	NKMEMPAGES_MIN_DEFAULT	((8 * 1024 * 1024) >> PAGE_SHIFT)
63 #define	NKMEMPAGES_MAX_DEFAULT	((128 * 1024 * 1024) >> PAGE_SHIFT)
64 
65 /*
66  * Mach derived conversion macros
67  */
68 #define mips_round_page(x)	((((uintptr_t)(x)) + NBPG - 1) & ~(NBPG-1))
69 #define mips_trunc_page(x)	((uintptr_t)(x) & ~(NBPG-1))
70 #define mips_btop(x)		((paddr_t)(x) >> PGSHIFT)
71 #define mips_ptob(x)		((paddr_t)(x) << PGSHIFT)
72 
73 #ifdef __MIPSEL__
74 #define	MID_MACHINE	135	/* MID_PMAX (little-endian) */
75 #endif
76 #ifdef __MIPSEB__
77 #define	MID_MACHINE	152	/* MID_MIPS (big-endian) */
78 #endif
79 
80