1 1.23.60.2 yamt /* $NetBSD: mips_param.h,v 1.23.60.2 2010/03/11 15:02:38 yamt 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.60.2 yamt * No reason this can't be common 9 1.23.60.2 yamt */ 10 1.23.60.2 yamt #if defined(__MIPSEB__) 11 1.23.60.2 yamt # if defined(__mips_n32) || defined(__mips_n64) 12 1.23.60.2 yamt # define _MACHINE_ARCH mips64eb 13 1.23.60.2 yamt # define MACHINE_ARCH "mips64eb" 14 1.23.60.2 yamt # define _MACHINE32_ARCH mipseb 15 1.23.60.2 yamt # define MACHINE32_ARCH "mipseb" 16 1.23.60.2 yamt # else 17 1.23.60.2 yamt # define _MACHINE_ARCH mipseb 18 1.23.60.2 yamt # define MACHINE_ARCH "mipseb" 19 1.23.60.2 yamt # endif 20 1.23.60.2 yamt #elif defined(__MIPSEL__) 21 1.23.60.2 yamt # if defined(__mips_n32) || defined(__mips_n64) 22 1.23.60.2 yamt # define _MACHINE_ARCH mips64el 23 1.23.60.2 yamt # define MACHINE_ARCH "mips64el" 24 1.23.60.2 yamt # define _MACHINE32_ARCH mipsel 25 1.23.60.2 yamt # define MACHINE32_ARCH "mipsel" 26 1.23.60.2 yamt # else 27 1.23.60.2 yamt # define _MACHINE_ARCH mipsel 28 1.23.60.2 yamt # define MACHINE_ARCH "mipsel" 29 1.23.60.2 yamt #endif 30 1.23.60.2 yamt #else 31 1.23.60.2 yamt #error neither __MIPSEL__ nor __MIPSEB__ are defined. 32 1.23.60.2 yamt #endif 33 1.23.60.2 yamt 34 1.23.60.2 yamt /* 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.60.1 yamt #ifdef ENABLE_MIPS_16KB_PAGE 43 1.23.60.1 yamt #define UPAGES 1 /* pages of u-area */ 44 1.23.60.1 yamt #define USPACE (UPAGES*NBPG) /* size of u-area in bytes */ 45 1.23.60.1 yamt #elif defined(ENABLE_MIPS_4KB_PAGE) || 1 46 1.5 jonathan #define UPAGES 2 /* pages of u-area */ 47 1.21 tsutsui #define USPACE (UPAGES*NBPG) /* size of u-area in bytes */ 48 1.23.60.1 yamt #else 49 1.23.60.1 yamt #error ENABLE_MIPS_xKB_PAGE not defined 50 1.23.60.1 yamt #endif 51 1.5 jonathan 52 1.7 leo #ifndef MSGBUFSIZE 53 1.7 leo #define MSGBUFSIZE NBPG /* default message buffer size */ 54 1.7 leo #endif 55 1.1 jonathan 56 1.1 jonathan /* 57 1.1 jonathan * Round p (pointer or byte index) up to a correctly-aligned value for all 58 1.1 jonathan * data types (int, long, ...). The result is u_int and must be cast to 59 1.1 jonathan * any desired pointer type. 60 1.10 jonathan * 61 1.10 jonathan * ALIGNED_POINTER is a boolean macro that checks whether an address 62 1.10 jonathan * is valid to fetch data elements of type t from on this architecture. 63 1.10 jonathan * This does not reflect the optimal alignment, just the possibility 64 1.13 simonb * (within reasonable limits). 65 1.10 jonathan * 66 1.1 jonathan */ 67 1.1 jonathan #define ALIGNBYTES 7 68 1.22 matt #define ALIGN(p) (((uintptr_t)(p) + ALIGNBYTES) & ~ALIGNBYTES) 69 1.22 matt #define ALIGNED_POINTER(p,t) ((((uintptr_t)(p)) & (sizeof(t)-1)) == 0) 70 1.1 jonathan 71 1.23.60.1 yamt #ifdef ENABLE_MIPS_16KB_PAGE 72 1.23.60.1 yamt #define NBPG 16384 /* bytes/page */ 73 1.23.60.1 yamt #define PGSHIFT 14 /* LOG2(NBPG) */ 74 1.23.60.1 yamt #else 75 1.1 jonathan #define NBPG 4096 /* bytes/page */ 76 1.1 jonathan #define PGSHIFT 12 /* LOG2(NBPG) */ 77 1.23.60.1 yamt #endif 78 1.23.60.1 yamt #define PGOFSET (NBPG-1) /* byte offset into page */ 79 1.1 jonathan #define NPTEPG (NBPG/4) 80 1.1 jonathan 81 1.23.60.1 yamt #define NBSEG (NBPG*NPTEPG) /* bytes/segment */ 82 1.1 jonathan #define SEGOFSET (NBSEG-1) /* byte offset into segment */ 83 1.23.60.1 yamt #define SEGSHIFT (2*PGSHIFT-2) /* LOG2(NBSEG) */ 84 1.1 jonathan 85 1.1 jonathan /* 86 1.17 thorpej * Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized 87 1.17 thorpej * logical pages. 88 1.13 simonb */ 89 1.17 thorpej #define NKMEMPAGES_MIN_DEFAULT ((8 * 1024 * 1024) >> PAGE_SHIFT) 90 1.17 thorpej #define NKMEMPAGES_MAX_DEFAULT ((128 * 1024 * 1024) >> PAGE_SHIFT) 91 1.1 jonathan 92 1.1 jonathan /* 93 1.1 jonathan * Mach derived conversion macros 94 1.1 jonathan */ 95 1.22 matt #define mips_round_page(x) ((((uintptr_t)(x)) + NBPG - 1) & ~(NBPG-1)) 96 1.22 matt #define mips_trunc_page(x) ((uintptr_t)(x) & ~(NBPG-1)) 97 1.20 soda #define mips_btop(x) ((paddr_t)(x) >> PGSHIFT) 98 1.20 soda #define mips_ptob(x) ((paddr_t)(x) << PGSHIFT) 99 1.23.60.1 yamt 100 1.23.60.1 yamt #ifdef __MIPSEL__ 101 1.23.60.2 yamt #define MID_MACHINE MID_PMAX /* MID_PMAX (little-endian) */ 102 1.23.60.1 yamt #endif 103 1.23.60.1 yamt #ifdef __MIPSEB__ 104 1.23.60.2 yamt #define MID_MACHINE MID_MIPS /* MID_MIPS (big-endian) */ 105 1.23.60.2 yamt #endif 106 1.23.60.2 yamt 107 1.23.60.2 yamt /* 108 1.23.60.2 yamt * Constants related to network buffer management. 109 1.23.60.2 yamt * MCLBYTES must be no larger than NBPG (the software page size), and, 110 1.23.60.2 yamt * on machines that exchange pages of input or output buffers with mbuf 111 1.23.60.2 yamt * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple 112 1.23.60.2 yamt * of the hardware page size. 113 1.23.60.2 yamt */ 114 1.23.60.2 yamt #ifndef MSIZE 115 1.23.60.2 yamt #ifdef _LP64 116 1.23.60.2 yamt #define MSIZE 512 /* size of an mbuf */ 117 1.23.60.2 yamt #else 118 1.23.60.2 yamt #define MSIZE 256 /* size of an mbuf */ 119 1.23.60.1 yamt #endif 120 1.23.60.1 yamt 121 1.23.60.2 yamt #ifndef MCLSHIFT 122 1.23.60.2 yamt # define MCLSHIFT 11 /* convert bytes to m_buf clusters */ 123 1.23.60.2 yamt #endif /* MCLSHIFT */ 124 1.23.60.2 yamt 125 1.23.60.2 yamt #define MCLBYTES (1 << MCLSHIFT) /* size of a m_buf cluster */ 126 1.23.60.2 yamt 127 1.23.60.2 yamt #endif 128