Home | History | Annotate | Line # | Download | only in include
mips_param.h revision 1.23.78.10
      1  1.23.78.10      matt /*	$NetBSD: mips_param.h,v 1.23.78.10 2011/12/27 01:56:33 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.23.78.2      matt  * No reason this can't be common
      9   1.23.78.2      matt  */
     10   1.23.78.2      matt #if defined(__MIPSEB__)
     11   1.23.78.2      matt # if defined(__mips_n32) || defined(__mips_n64)
     12   1.23.78.2      matt #  define	_MACHINE_ARCH	mips64eb
     13   1.23.78.2      matt #  define	MACHINE_ARCH	"mips64eb"
     14   1.23.78.4      matt #  define	_MACHINE32_ARCH	mipseb
     15   1.23.78.4      matt #  define	MACHINE32_ARCH	"mipseb"
     16   1.23.78.2      matt # else
     17   1.23.78.2      matt #  define	_MACHINE_ARCH	mipseb
     18   1.23.78.2      matt #  define	MACHINE_ARCH	"mipseb"
     19   1.23.78.2      matt # endif
     20   1.23.78.2      matt #elif defined(__MIPSEL__)
     21   1.23.78.2      matt # if defined(__mips_n32) || defined(__mips_n64)
     22   1.23.78.2      matt #  define	_MACHINE_ARCH	mips64el
     23   1.23.78.2      matt #  define	MACHINE_ARCH	"mips64el"
     24   1.23.78.4      matt #  define	_MACHINE32_ARCH	mipsel
     25   1.23.78.4      matt #  define	MACHINE32_ARCH	"mipsel"
     26   1.23.78.2      matt # else
     27   1.23.78.2      matt #  define	_MACHINE_ARCH	mipsel
     28   1.23.78.2      matt #  define	MACHINE_ARCH	"mipsel"
     29   1.23.78.2      matt #endif
     30   1.23.78.2      matt #else
     31   1.23.78.2      matt #error neither __MIPSEL__ nor __MIPSEB__ are defined.
     32   1.23.78.2      matt #endif
     33   1.23.78.2      matt 
     34   1.23.78.2      matt /*
     35         1.5  jonathan  * On mips, UPAGES is fixed by sys/arch/mips/mips/locore code
     36         1.5  jonathan  * to be the number of per-process-wired kernel-stack pages/PTES.
     37         1.5  jonathan  */
     38         1.5  jonathan 
     39         1.6  jonathan #define	SSIZE		1		/* initial stack size/NBPG */
     40         1.6  jonathan #define	SINCR		1		/* increment of stack/NBPG */
     41         1.6  jonathan 
     42  1.23.78.10      matt #if defined(_KERNEL) && !defined(_MODULE)
     43   1.23.78.9      matt #ifdef PAGE_SHIFT
     44   1.23.78.9      matt #if MIPS_PAGE_SHIFT != PAGE_SHIFT
     45   1.23.78.9      matt #error MIPS_PAGE_SHIFT != PAGE_SHIFT
     46   1.23.78.9      matt #endif
     47   1.23.78.9      matt #elif defined(MIPS_PAGE_SHIFT)
     48   1.23.78.9      matt #define	PAGE_SHIFT	MIPS_PAGE_SHIFT
     49   1.23.78.9      matt #else
     50   1.23.78.9      matt #define	PAGE_SHIFT	12
     51   1.23.78.9      matt #endif
     52  1.23.78.10      matt #endif /* _KERNEL && !_MODULE */
     53   1.23.78.9      matt 
     54   1.23.78.9      matt #if PAGE_SHIFT & 1
     55   1.23.78.7      matt #define	UPAGES		1		/* pages of u-area */
     56   1.23.78.9      matt #else
     57         1.5  jonathan #define	UPAGES		2		/* pages of u-area */
     58   1.23.78.5      matt #define	USPACE_ALIGN	USPACE		/* make sure it starts on a even VA */
     59   1.23.78.7      matt #endif
     60         1.5  jonathan 
     61   1.23.78.9      matt #define	USPACE		(UPAGES*NBPG)	/* size of u-area in bytes */
     62   1.23.78.9      matt 
     63         1.7       leo #ifndef MSGBUFSIZE
     64         1.7       leo #define MSGBUFSIZE	NBPG		/* default message buffer size */
     65         1.7       leo #endif
     66         1.1  jonathan 
     67   1.23.78.8      matt #ifndef COHERENCY_UNIT
     68   1.23.78.8      matt #define COHERENCY_UNIT	32	/* MIPS cachelines are usually 32 bytes */
     69   1.23.78.8      matt #endif
     70   1.23.78.8      matt 
     71         1.1  jonathan /*
     72         1.1  jonathan  * Round p (pointer or byte index) up to a correctly-aligned value for all
     73         1.1  jonathan  * data types (int, long, ...).   The result is u_int and must be cast to
     74         1.1  jonathan  * any desired pointer type.
     75        1.10  jonathan  *
     76        1.10  jonathan  * ALIGNED_POINTER is a boolean macro that checks whether an address
     77        1.10  jonathan  * is valid to fetch data elements of type t from on this architecture.
     78        1.10  jonathan  * This does not reflect the optimal alignment, just the possibility
     79        1.13    simonb  * (within reasonable limits).
     80        1.10  jonathan  *
     81         1.1  jonathan  */
     82         1.1  jonathan #define	ALIGNBYTES	7
     83        1.22      matt #define	ALIGN(p)	(((uintptr_t)(p) + ALIGNBYTES) & ~ALIGNBYTES)
     84        1.22      matt #define ALIGNED_POINTER(p,t)	((((uintptr_t)(p)) & (sizeof(t)-1)) == 0)
     85         1.1  jonathan 
     86   1.23.78.9      matt #define	PGSHIFT		PAGE_SHIFT	/* LOG2(NBPG) */
     87   1.23.78.7      matt #define	NBPG		(1 << PGSHIFT)	/* bytes/page */
     88   1.23.78.7      matt #define	PGOFSET		(NBPG-1)	/* byte offset into page */
     89         1.1  jonathan #define	NPTEPG		(NBPG/4)
     90         1.1  jonathan 
     91   1.23.78.3      matt #define NBSEG		(NBPG*NPTEPG)	/* bytes/segment */
     92         1.1  jonathan #define	SEGOFSET	(NBSEG-1)	/* byte offset into segment */
     93   1.23.78.6      matt #define	SEGSHIFT	(PGSHIFT+(PGSHIFT-2))	/* LOG2(NBSEG) */
     94   1.23.78.6      matt 
     95   1.23.78.6      matt #ifdef _LP64
     96   1.23.78.6      matt #define	NSEGPG		(NBPG/8)
     97   1.23.78.6      matt #define NBXSEG		(NSEGPG*NBSEG)	/* bytes/xsegment */
     98   1.23.78.6      matt #define	XSEGOFSET	(NBSEG-1)	/* byte offset into segment */
     99   1.23.78.6      matt #define	XSEGSHIFT	(SEGSHIFT+(PGSHIFT-3))	/* LOG2(NBXSEG) */
    100   1.23.78.6      matt #endif
    101         1.1  jonathan 
    102         1.1  jonathan /*
    103        1.17   thorpej  * Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized
    104        1.17   thorpej  * logical pages.
    105        1.13    simonb  */
    106        1.17   thorpej #define	NKMEMPAGES_MIN_DEFAULT	((8 * 1024 * 1024) >> PAGE_SHIFT)
    107        1.17   thorpej #define	NKMEMPAGES_MAX_DEFAULT	((128 * 1024 * 1024) >> PAGE_SHIFT)
    108         1.1  jonathan 
    109         1.1  jonathan /*
    110         1.1  jonathan  * Mach derived conversion macros
    111         1.1  jonathan  */
    112        1.22      matt #define mips_round_page(x)	((((uintptr_t)(x)) + NBPG - 1) & ~(NBPG-1))
    113        1.22      matt #define mips_trunc_page(x)	((uintptr_t)(x) & ~(NBPG-1))
    114        1.20      soda #define mips_btop(x)		((paddr_t)(x) >> PGSHIFT)
    115        1.20      soda #define mips_ptob(x)		((paddr_t)(x) << PGSHIFT)
    116   1.23.78.1      matt 
    117   1.23.78.1      matt /*
    118   1.23.78.1      matt  * Constants related to network buffer management.
    119   1.23.78.1      matt  * MCLBYTES must be no larger than NBPG (the software page size), and,
    120   1.23.78.1      matt  * on machines that exchange pages of input or output buffers with mbuf
    121   1.23.78.1      matt  * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
    122   1.23.78.1      matt  * of the hardware page size.
    123   1.23.78.1      matt  */
    124   1.23.78.1      matt #ifndef MSIZE
    125   1.23.78.1      matt #ifdef _LP64
    126   1.23.78.1      matt #define	MSIZE		512		/* size of an mbuf */
    127   1.23.78.1      matt #else
    128   1.23.78.1      matt #define	MSIZE		256		/* size of an mbuf */
    129   1.23.78.1      matt #endif
    130   1.23.78.1      matt 
    131   1.23.78.1      matt #ifndef MCLSHIFT
    132   1.23.78.1      matt # define MCLSHIFT	11		/* convert bytes to m_buf clusters */
    133   1.23.78.1      matt #endif	/* MCLSHIFT */
    134   1.23.78.1      matt 
    135   1.23.78.1      matt #define	MCLBYTES	(1 << MCLSHIFT)	/* size of a m_buf cluster */
    136   1.23.78.1      matt 
    137   1.23.78.1      matt #ifndef NMBCLUSTERS
    138   1.23.78.1      matt #if defined(_KERNEL_OPT)
    139   1.23.78.1      matt #include "opt_gateway.h"
    140   1.23.78.1      matt #endif
    141   1.23.78.1      matt 
    142   1.23.78.1      matt #ifdef GATEWAY
    143   1.23.78.1      matt #define	NMBCLUSTERS	2048		/* map size, max cluster allocation */
    144   1.23.78.1      matt #else
    145   1.23.78.1      matt #define	NMBCLUSTERS	1024		/* map size, max cluster allocation */
    146   1.23.78.1      matt #endif
    147   1.23.78.1      matt #endif
    148   1.23.78.1      matt #endif
    149