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