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