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