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