Home | History | Annotate | Line # | Download | only in include
mips_param.h revision 1.29.4.1
      1 /*	$NetBSD: mips_param.h,v 1.29.4.1 2012/04/17 00:06:39 yamt Exp $	*/
      2 
      3 #ifdef _KERNEL
      4 #include <machine/cpu.h>
      5 #endif
      6 
      7 /*
      8  * No reason this can't be common
      9  */
     10 #if defined(__MIPSEB__)
     11 # if defined(__mips_n32) || defined(__mips_n64)
     12 #  define	_MACHINE_ARCH	mips64eb
     13 #  define	MACHINE_ARCH	"mips64eb"
     14 #  define	_MACHINE32_ARCH	mipseb
     15 #  define	MACHINE32_ARCH	"mipseb"
     16 # else
     17 #  define	_MACHINE_ARCH	mipseb
     18 #  define	MACHINE_ARCH	"mipseb"
     19 # endif
     20 #elif defined(__MIPSEL__)
     21 # if defined(__mips_n32) || defined(__mips_n64)
     22 #  define	_MACHINE_ARCH	mips64el
     23 #  define	MACHINE_ARCH	"mips64el"
     24 #  define	_MACHINE32_ARCH	mipsel
     25 #  define	MACHINE32_ARCH	"mipsel"
     26 # else
     27 #  define	_MACHINE_ARCH	mipsel
     28 #  define	MACHINE_ARCH	"mipsel"
     29 #endif
     30 #else
     31 #error neither __MIPSEL__ nor __MIPSEB__ are defined.
     32 #endif
     33 
     34 /*
     35  * Userland code should be using uname/sysctl to get MACHINE so simply
     36  * export a generic MACHINE of "mips"
     37  */
     38 #ifndef _KERNEL
     39 #undef MACHINE
     40 #define MACHINE "mips"
     41 #endif
     42 
     43 #define ALIGNBYTES32		(sizeof(double) - 1)
     44 #define ALIGN32(p)		(((uintptr_t)(p) + ALIGNBYTES32) &~ALIGNBYTES32)
     45 
     46 /*
     47  * On mips, UPAGES is fixed by sys/arch/mips/mips/locore code
     48  * to be the number of per-process-wired kernel-stack pages/PTES.
     49  */
     50 
     51 #define	SSIZE		1		/* initial stack size/NBPG */
     52 #define	SINCR		1		/* increment of stack/NBPG */
     53 
     54 #ifdef ENABLE_MIPS_16KB_PAGE
     55 #define	UPAGES		1		/* pages of u-area */
     56 #define	USPACE		(UPAGES*NBPG)	/* size of u-area in bytes */
     57 #elif defined(ENABLE_MIPS_4KB_PAGE) || 1
     58 #define	UPAGES		2		/* pages of u-area */
     59 #define	USPACE		(UPAGES*NBPG)	/* size of u-area in bytes */
     60 #else
     61 #error ENABLE_MIPS_xKB_PAGE not defined
     62 #endif
     63 #define	USPACE_ALIGN	USPACE		/* make sure it starts on a even VA */
     64 
     65 #ifndef MSGBUFSIZE
     66 #define MSGBUFSIZE	NBPG		/* default message buffer size */
     67 #endif
     68 
     69 #ifndef COHERENCY_UNIT
     70 #define COHERENCY_UNIT	32	/* MIPS cachelines are usually 32 bytes */
     71 #endif
     72 
     73 #ifdef ENABLE_MIPS_16KB_PAGE
     74 #define	NBPG		16384		/* bytes/page */
     75 #define	PGSHIFT		14		/* LOG2(NBPG) */
     76 #else
     77 #define	NBPG		4096		/* bytes/page */
     78 #define	PGSHIFT		12		/* LOG2(NBPG) */
     79 #endif
     80 #define	PGOFSET		(NBPG-1)	/* byte offset into page */
     81 #define	NPTEPG		(NBPG/4)
     82 
     83 #define NBSEG		(NBPG*NPTEPG)	/* bytes/segment */
     84 #define	SEGOFSET	(NBSEG-1)	/* byte offset into segment */
     85 #define	SEGSHIFT	(PGSHIFT+(PGSHIFT-2))	/* LOG2(NBSEG) */
     86 
     87 #ifdef _LP64
     88 #define	NSEGPG		(NBPG/8)
     89 #define NBXSEG		(NSEGPG*NBSEG)	/* bytes/xsegment */
     90 #define	XSEGOFSET	(NBSEG-1)	/* byte offset into segment */
     91 #define	XSEGSHIFT	(SEGSHIFT+(PGSHIFT-3))	/* LOG2(NBXSEG) */
     92 #endif
     93 
     94 /*
     95  * Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized
     96  * logical pages.
     97  */
     98 #define	NKMEMPAGES_MIN_DEFAULT	((8 * 1024 * 1024) >> PAGE_SHIFT)
     99 #define	NKMEMPAGES_MAX_DEFAULT	((128 * 1024 * 1024) >> PAGE_SHIFT)
    100 
    101 /*
    102  * Mach derived conversion macros
    103  */
    104 #define mips_round_page(x)	((((uintptr_t)(x)) + NBPG - 1) & ~(NBPG-1))
    105 #define mips_trunc_page(x)	((uintptr_t)(x) & ~(NBPG-1))
    106 #define mips_btop(x)		((paddr_t)(x) >> PGSHIFT)
    107 #define mips_ptob(x)		((paddr_t)(x) << PGSHIFT)
    108 
    109 #ifdef __MIPSEL__
    110 #define	MID_MACHINE	MID_PMAX	/* MID_PMAX (little-endian) */
    111 #endif
    112 #ifdef __MIPSEB__
    113 #define	MID_MACHINE	MID_MIPS	/* MID_MIPS (big-endian) */
    114 #endif
    115 
    116 /*
    117  * Constants related to network buffer management.
    118  * MCLBYTES must be no larger than NBPG (the software page size), and,
    119  * on machines that exchange pages of input or output buffers with mbuf
    120  * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
    121  * of the hardware page size.
    122  */
    123 #ifndef MSIZE
    124 #ifdef _LP64
    125 #define	MSIZE		512		/* size of an mbuf */
    126 #else
    127 #define	MSIZE		256		/* size of an mbuf */
    128 #endif
    129 
    130 #ifndef MCLSHIFT
    131 # define MCLSHIFT	11		/* convert bytes to m_buf clusters */
    132 #endif	/* MCLSHIFT */
    133 
    134 #define	MCLBYTES	(1 << MCLSHIFT)	/* size of a m_buf cluster */
    135 
    136 #endif
    137