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