param.h revision 1.12 1 /* $NetBSD: param.h,v 1.12 2003/08/07 16:29:29 agc Exp $ */
2
3 /*-
4 * Copyright (c) 1990 The Regents of the University of California.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to Berkeley by
8 * William Jolitz.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of the University nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * @(#)param.h 5.8 (Berkeley) 6/28/91
35 */
36
37 /*-
38 * Copyright (c) 2002 The NetBSD Foundation, Inc. All rights reserved.
39 *
40 * This code is derived from software contributed to Berkeley by
41 * William Jolitz.
42 *
43 * Redistribution and use in source and binary forms, with or without
44 * modification, are permitted provided that the following conditions
45 * are met:
46 * 1. Redistributions of source code must retain the above copyright
47 * notice, this list of conditions and the following disclaimer.
48 * 2. Redistributions in binary form must reproduce the above copyright
49 * notice, this list of conditions and the following disclaimer in the
50 * documentation and/or other materials provided with the distribution.
51 * 3. All advertising materials mentioning features or use of this software
52 * must display the following acknowledgement:
53 * This product includes software developed by the University of
54 * California, Berkeley and its contributors.
55 * 4. Neither the name of the University nor the names of its contributors
56 * may be used to endorse or promote products derived from this software
57 * without specific prior written permission.
58 *
59 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
60 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
61 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
62 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
63 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
64 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
65 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
66 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
67 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
68 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
69 * SUCH DAMAGE.
70 *
71 * @(#)param.h 5.8 (Berkeley) 6/28/91
72 */
73
74 /*
75 * SuperH dependent constants.
76 */
77
78 #ifndef _SH3_PARAM_H_
79 #define _SH3_PARAM_H_
80
81 #if defined(_KERNEL) && !defined(_LOCORE)
82 #include <sh3/cpu.h>
83 #endif
84
85 /* NetBSD/sh3 is 4KB page */
86 #define PGSHIFT 12
87 #define NBPG (1 << PGSHIFT)
88 #define PGOFSET (NBPG - 1)
89
90 /*
91 * Round p (pointer or byte index) up to a correctly-aligned value
92 * for all data types (int, long, ...). The result is u_int and
93 * must be cast to any desired pointer type.
94 *
95 * ALIGNED_POINTER is a boolean macro that checks whether an address
96 * is valid to fetch data elements of type t from on this architecture.
97 * This does not reflect the optimal alignment, just the possibility
98 * (within reasonable limits).
99 *
100 */
101 #define ALIGNBYTES (sizeof(int) - 1)
102 #define ALIGN(p) (((u_int)(p) + ALIGNBYTES) & ~ALIGNBYTES)
103 #define ALIGNED_POINTER(p, t) ((((u_long)(p)) & (sizeof(t) - 1)) == 0)
104
105 #define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */
106 #define DEV_BSIZE (1 << DEV_BSHIFT)
107 #define BLKDEV_IOSIZE 2048
108 #define MAXPHYS (64 * 1024) /* max raw I/O transfer size */
109
110 /*
111 * u-space.
112 */
113 #define UPAGES 3 /* pages of u-area */
114 #define USPACE (UPAGES * NBPG) /* total size of u-area */
115 #if UPAGES == 1
116 #error "too small u-area"
117 #elif UPAGES == 2
118 #define P1_STACK /* kernel stack is P1-area */
119 #else
120 #undef P1_STACK /* kernel stack is P3-area */
121 #endif
122
123 #ifndef MSGBUFSIZE
124 #define MSGBUFSIZE NBPG /* default message buffer size */
125 #endif
126
127 /*
128 * Constants related to network buffer management.
129 * MCLBYTES must be no larger than NBPG (the software page size), and,
130 * on machines that exchange pages of input or output buffers with mbuf
131 * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
132 * of the hardware page size.
133 */
134 #define MSIZE 256 /* size of an mbuf */
135
136 #ifndef MCLSHIFT
137 #define MCLSHIFT 11 /* convert bytes to m_buf clusters */
138 /* 2K cluster can hold Ether frame */
139 #endif /* MCLSHIFT */
140
141 #define MCLBYTES (1 << MCLSHIFT) /* size of a m_buf cluster */
142
143 #ifndef NMBCLUSTERS
144 #if defined(_KERNEL_OPT)
145 #include "opt_gateway.h"
146 #endif
147
148 #ifdef GATEWAY
149 #define NMBCLUSTERS 512 /* map size, max cluster allocation */
150 #else
151 #define NMBCLUSTERS 256 /* map size, max cluster allocation */
152 #endif
153 #endif
154
155 /*
156 * Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized
157 * logical pages.
158 */
159 #define NKMEMPAGES_MIN_DEFAULT ((6 * 1024 * 1024) >> PAGE_SHIFT)
160 #define NKMEMPAGES_MAX_DEFAULT ((6 * 1024 * 1024) >> PAGE_SHIFT)
161
162 /* pages ("clicks") to disk blocks */
163 #define ctod(x) ((x) << (PGSHIFT - DEV_BSHIFT))
164 #define dtoc(x) ((x) >> (PGSHIFT - DEV_BSHIFT))
165
166 /* bytes to pages */
167 #define ctob(x) ((x) << PGSHIFT)
168 #define btoc(x) (((x) + PGOFSET) >> PGSHIFT)
169
170 /* bytes to disk blocks */
171 #define dbtob(x) ((x) << DEV_BSHIFT)
172 #define btodb(x) ((x) >> DEV_BSHIFT)
173 #endif /* !_SH3_PARAM_H_ */
174