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