Home | History | Annotate | Line # | Download | only in include
mips_param.h revision 1.29.4.2
      1  1.29.4.2      yamt /*	$NetBSD: mips_param.h,v 1.29.4.2 2014/05/22 11:39:57 yamt Exp $	*/
      2      1.16    simonb 
      3  1.29.4.2      yamt /*-
      4  1.29.4.2      yamt  * Copyright (c) 2013 The NetBSD Foundation, Inc.
      5  1.29.4.2      yamt  * All rights reserved.
      6  1.29.4.2      yamt  *
      7  1.29.4.2      yamt  * Redistribution and use in source and binary forms, with or without
      8  1.29.4.2      yamt  * modification, are permitted provided that the following conditions
      9  1.29.4.2      yamt  * are met:
     10  1.29.4.2      yamt  * 1. Redistributions of source code must retain the above copyright
     11  1.29.4.2      yamt  *    notice, this list of conditions and the following disclaimer.
     12  1.29.4.2      yamt  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.29.4.2      yamt  *    notice, this list of conditions and the following disclaimer in the
     14  1.29.4.2      yamt  *    documentation and/or other materials provided with the distribution.
     15  1.29.4.2      yamt  *
     16  1.29.4.2      yamt  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     17  1.29.4.2      yamt  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     18  1.29.4.2      yamt  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     19  1.29.4.2      yamt  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     20  1.29.4.2      yamt  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     21  1.29.4.2      yamt  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     22  1.29.4.2      yamt  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     23  1.29.4.2      yamt  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     24  1.29.4.2      yamt  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     25  1.29.4.2      yamt  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     26  1.29.4.2      yamt  * POSSIBILITY OF SUCH DAMAGE.
     27  1.29.4.2      yamt  */
     28      1.18   mycroft #ifdef _KERNEL
     29      1.16    simonb #include <machine/cpu.h>
     30      1.18   mycroft #endif
     31       1.5  jonathan 
     32       1.5  jonathan /*
     33      1.26      matt  * No reason this can't be common
     34      1.26      matt  */
     35      1.26      matt #if defined(__MIPSEB__)
     36      1.26      matt # if defined(__mips_n32) || defined(__mips_n64)
     37      1.26      matt #  define	_MACHINE_ARCH	mips64eb
     38      1.26      matt #  define	MACHINE_ARCH	"mips64eb"
     39      1.26      matt #  define	_MACHINE32_ARCH	mipseb
     40      1.26      matt #  define	MACHINE32_ARCH	"mipseb"
     41      1.26      matt # else
     42      1.26      matt #  define	_MACHINE_ARCH	mipseb
     43      1.26      matt #  define	MACHINE_ARCH	"mipseb"
     44      1.26      matt # endif
     45      1.26      matt #elif defined(__MIPSEL__)
     46      1.26      matt # if defined(__mips_n32) || defined(__mips_n64)
     47      1.26      matt #  define	_MACHINE_ARCH	mips64el
     48      1.26      matt #  define	MACHINE_ARCH	"mips64el"
     49      1.26      matt #  define	_MACHINE32_ARCH	mipsel
     50      1.26      matt #  define	MACHINE32_ARCH	"mipsel"
     51      1.26      matt # else
     52      1.26      matt #  define	_MACHINE_ARCH	mipsel
     53      1.26      matt #  define	MACHINE_ARCH	"mipsel"
     54      1.26      matt #endif
     55      1.26      matt #else
     56      1.26      matt #error neither __MIPSEL__ nor __MIPSEB__ are defined.
     57      1.26      matt #endif
     58      1.26      matt 
     59      1.26      matt /*
     60      1.29      matt  * Userland code should be using uname/sysctl to get MACHINE so simply
     61      1.29      matt  * export a generic MACHINE of "mips"
     62      1.29      matt  */
     63      1.29      matt #ifndef _KERNEL
     64      1.29      matt #undef MACHINE
     65      1.29      matt #define MACHINE "mips"
     66      1.29      matt #endif
     67      1.29      matt 
     68  1.29.4.1      yamt #define ALIGNBYTES32		(sizeof(double) - 1)
     69  1.29.4.1      yamt #define ALIGN32(p)		(((uintptr_t)(p) + ALIGNBYTES32) &~ALIGNBYTES32)
     70  1.29.4.1      yamt 
     71      1.29      matt /*
     72       1.5  jonathan  * On mips, UPAGES is fixed by sys/arch/mips/mips/locore code
     73       1.5  jonathan  * to be the number of per-process-wired kernel-stack pages/PTES.
     74       1.5  jonathan  */
     75       1.5  jonathan 
     76       1.6  jonathan #define	SSIZE		1		/* initial stack size/NBPG */
     77       1.6  jonathan #define	SINCR		1		/* increment of stack/NBPG */
     78       1.6  jonathan 
     79      1.24      matt #ifdef ENABLE_MIPS_16KB_PAGE
     80      1.24      matt #define	UPAGES		1		/* pages of u-area */
     81      1.24      matt #define	USPACE		(UPAGES*NBPG)	/* size of u-area in bytes */
     82      1.24      matt #elif defined(ENABLE_MIPS_4KB_PAGE) || 1
     83       1.5  jonathan #define	UPAGES		2		/* pages of u-area */
     84      1.21   tsutsui #define	USPACE		(UPAGES*NBPG)	/* size of u-area in bytes */
     85      1.24      matt #else
     86      1.24      matt #error ENABLE_MIPS_xKB_PAGE not defined
     87      1.24      matt #endif
     88      1.28      matt #define	USPACE_ALIGN	USPACE		/* make sure it starts on a even VA */
     89       1.5  jonathan 
     90       1.7       leo #ifndef MSGBUFSIZE
     91       1.7       leo #define MSGBUFSIZE	NBPG		/* default message buffer size */
     92       1.7       leo #endif
     93       1.1  jonathan 
     94      1.28      matt #ifndef COHERENCY_UNIT
     95      1.28      matt #define COHERENCY_UNIT	32	/* MIPS cachelines are usually 32 bytes */
     96      1.28      matt #endif
     97      1.28      matt 
     98      1.24      matt #ifdef ENABLE_MIPS_16KB_PAGE
     99      1.24      matt #define	NBPG		16384		/* bytes/page */
    100      1.24      matt #define	PGSHIFT		14		/* LOG2(NBPG) */
    101      1.24      matt #else
    102       1.1  jonathan #define	NBPG		4096		/* bytes/page */
    103      1.24      matt #define	PGSHIFT		12		/* LOG2(NBPG) */
    104      1.24      matt #endif
    105       1.1  jonathan #define	PGOFSET		(NBPG-1)	/* byte offset into page */
    106       1.1  jonathan #define	NPTEPG		(NBPG/4)
    107       1.1  jonathan 
    108      1.24      matt #define NBSEG		(NBPG*NPTEPG)	/* bytes/segment */
    109       1.1  jonathan #define	SEGOFSET	(NBSEG-1)	/* byte offset into segment */
    110      1.28      matt #define	SEGSHIFT	(PGSHIFT+(PGSHIFT-2))	/* LOG2(NBSEG) */
    111      1.28      matt 
    112      1.28      matt #ifdef _LP64
    113      1.28      matt #define	NSEGPG		(NBPG/8)
    114      1.28      matt #define NBXSEG		(NSEGPG*NBSEG)	/* bytes/xsegment */
    115      1.28      matt #define	XSEGOFSET	(NBSEG-1)	/* byte offset into segment */
    116      1.28      matt #define	XSEGSHIFT	(SEGSHIFT+(PGSHIFT-3))	/* LOG2(NBXSEG) */
    117      1.28      matt #endif
    118       1.1  jonathan 
    119       1.1  jonathan /*
    120      1.17   thorpej  * Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized
    121      1.17   thorpej  * logical pages.
    122      1.13    simonb  */
    123      1.17   thorpej #define	NKMEMPAGES_MIN_DEFAULT	((8 * 1024 * 1024) >> PAGE_SHIFT)
    124      1.17   thorpej #define	NKMEMPAGES_MAX_DEFAULT	((128 * 1024 * 1024) >> PAGE_SHIFT)
    125       1.1  jonathan 
    126       1.1  jonathan /*
    127       1.1  jonathan  * Mach derived conversion macros
    128       1.1  jonathan  */
    129      1.22      matt #define mips_round_page(x)	((((uintptr_t)(x)) + NBPG - 1) & ~(NBPG-1))
    130      1.22      matt #define mips_trunc_page(x)	((uintptr_t)(x) & ~(NBPG-1))
    131      1.20      soda #define mips_btop(x)		((paddr_t)(x) >> PGSHIFT)
    132      1.20      soda #define mips_ptob(x)		((paddr_t)(x) << PGSHIFT)
    133      1.25      matt 
    134      1.25      matt #ifdef __MIPSEL__
    135      1.26      matt #define	MID_MACHINE	MID_PMAX	/* MID_PMAX (little-endian) */
    136      1.25      matt #endif
    137      1.25      matt #ifdef __MIPSEB__
    138      1.26      matt #define	MID_MACHINE	MID_MIPS	/* MID_MIPS (big-endian) */
    139      1.25      matt #endif
    140      1.25      matt 
    141      1.26      matt /*
    142      1.26      matt  * Constants related to network buffer management.
    143      1.26      matt  * MCLBYTES must be no larger than NBPG (the software page size), and,
    144      1.26      matt  * on machines that exchange pages of input or output buffers with mbuf
    145      1.26      matt  * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
    146      1.26      matt  * of the hardware page size.
    147      1.26      matt  */
    148      1.26      matt #ifndef MSIZE
    149      1.26      matt #ifdef _LP64
    150      1.26      matt #define	MSIZE		512		/* size of an mbuf */
    151      1.26      matt #else
    152      1.26      matt #define	MSIZE		256		/* size of an mbuf */
    153      1.26      matt #endif
    154      1.26      matt 
    155      1.26      matt #ifndef MCLSHIFT
    156      1.26      matt # define MCLSHIFT	11		/* convert bytes to m_buf clusters */
    157      1.26      matt #endif	/* MCLSHIFT */
    158      1.26      matt 
    159      1.26      matt #define	MCLBYTES	(1 << MCLSHIFT)	/* size of a m_buf cluster */
    160      1.26      matt 
    161      1.26      matt #endif
    162