1 /* $NetBSD: mips_param.h,v 1.28 2011/02/20 07:45:47 matt 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 * On mips, UPAGES is fixed by sys/arch/mips/mips/locore code 36 * to be the number of per-process-wired kernel-stack pages/PTES. 37 */ 38 39 #define SSIZE 1 /* initial stack size/NBPG */ 40 #define SINCR 1 /* increment of stack/NBPG */ 41 42 #ifdef ENABLE_MIPS_16KB_PAGE 43 #define UPAGES 1 /* pages of u-area */ 44 #define USPACE (UPAGES*NBPG) /* size of u-area in bytes */ 45 #elif defined(ENABLE_MIPS_4KB_PAGE) || 1 46 #define UPAGES 2 /* pages of u-area */ 47 #define USPACE (UPAGES*NBPG) /* size of u-area in bytes */ 48 #else 49 #error ENABLE_MIPS_xKB_PAGE not defined 50 #endif 51 #define USPACE_ALIGN USPACE /* make sure it starts on a even VA */ 52 53 #ifndef MSGBUFSIZE 54 #define MSGBUFSIZE NBPG /* default message buffer size */ 55 #endif 56 57 #ifndef COHERENCY_UNIT 58 #define COHERENCY_UNIT 32 /* MIPS cachelines are usually 32 bytes */ 59 #endif 60 61 /* 62 * Round p (pointer or byte index) up to a correctly-aligned value for all 63 * data types (int, long, ...). The result is u_int and must be cast to 64 * any desired pointer type. 65 * 66 * ALIGNED_POINTER is a boolean macro that checks whether an address 67 * is valid to fetch data elements of type t from on this architecture. 68 * This does not reflect the optimal alignment, just the possibility 69 * (within reasonable limits). 70 * 71 */ 72 #define ALIGNBYTES 7 73 #define ALIGN(p) (((uintptr_t)(p) + ALIGNBYTES) & ~ALIGNBYTES) 74 #define ALIGNED_POINTER(p,t) ((((uintptr_t)(p)) & (sizeof(t)-1)) == 0) 75 76 #ifdef ENABLE_MIPS_16KB_PAGE 77 #define NBPG 16384 /* bytes/page */ 78 #define PGSHIFT 14 /* LOG2(NBPG) */ 79 #else 80 #define NBPG 4096 /* bytes/page */ 81 #define PGSHIFT 12 /* LOG2(NBPG) */ 82 #endif 83 #define PGOFSET (NBPG-1) /* byte offset into page */ 84 #define NPTEPG (NBPG/4) 85 86 #define NBSEG (NBPG*NPTEPG) /* bytes/segment */ 87 #define SEGOFSET (NBSEG-1) /* byte offset into segment */ 88 #define SEGSHIFT (PGSHIFT+(PGSHIFT-2)) /* LOG2(NBSEG) */ 89 90 #ifdef _LP64 91 #define NSEGPG (NBPG/8) 92 #define NBXSEG (NSEGPG*NBSEG) /* bytes/xsegment */ 93 #define XSEGOFSET (NBSEG-1) /* byte offset into segment */ 94 #define XSEGSHIFT (SEGSHIFT+(PGSHIFT-3)) /* LOG2(NBXSEG) */ 95 #endif 96 97 /* 98 * Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized 99 * logical pages. 100 */ 101 #define NKMEMPAGES_MIN_DEFAULT ((8 * 1024 * 1024) >> PAGE_SHIFT) 102 #define NKMEMPAGES_MAX_DEFAULT ((128 * 1024 * 1024) >> PAGE_SHIFT) 103 104 /* 105 * Mach derived conversion macros 106 */ 107 #define mips_round_page(x) ((((uintptr_t)(x)) + NBPG - 1) & ~(NBPG-1)) 108 #define mips_trunc_page(x) ((uintptr_t)(x) & ~(NBPG-1)) 109 #define mips_btop(x) ((paddr_t)(x) >> PGSHIFT) 110 #define mips_ptob(x) ((paddr_t)(x) << PGSHIFT) 111 112 #ifdef __MIPSEL__ 113 #define MID_MACHINE MID_PMAX /* MID_PMAX (little-endian) */ 114 #endif 115 #ifdef __MIPSEB__ 116 #define MID_MACHINE MID_MIPS /* MID_MIPS (big-endian) */ 117 #endif 118 119 /* 120 * Constants related to network buffer management. 121 * MCLBYTES must be no larger than NBPG (the software page size), and, 122 * on machines that exchange pages of input or output buffers with mbuf 123 * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple 124 * of the hardware page size. 125 */ 126 #ifndef MSIZE 127 #ifdef _LP64 128 #define MSIZE 512 /* size of an mbuf */ 129 #else 130 #define MSIZE 256 /* size of an mbuf */ 131 #endif 132 133 #ifndef MCLSHIFT 134 # define MCLSHIFT 11 /* convert bytes to m_buf clusters */ 135 #endif /* MCLSHIFT */ 136 137 #define MCLBYTES (1 << MCLSHIFT) /* size of a m_buf cluster */ 138 139 #endif 140