param.h revision 1.10.8.2 1 1.10.8.2 nathanw /* $NetBSD: param.h,v 1.10.8.2 2002/02/28 04:10:34 nathanw Exp $ */
2 1.10.8.2 nathanw
3 1.10.8.2 nathanw /*
4 1.10.8.2 nathanw * Copyright (c) 1988 University of Utah.
5 1.10.8.2 nathanw * Copyright (c) 1982, 1986, 1990 The Regents of the University of California.
6 1.10.8.2 nathanw * All rights reserved.
7 1.10.8.2 nathanw *
8 1.10.8.2 nathanw * This code is derived from software contributed to Berkeley by
9 1.10.8.2 nathanw * the Systems Programming Group of the University of Utah Computer
10 1.10.8.2 nathanw * Science Department.
11 1.10.8.2 nathanw *
12 1.10.8.2 nathanw * Redistribution and use in source and binary forms, with or without
13 1.10.8.2 nathanw * modification, are permitted provided that the following conditions
14 1.10.8.2 nathanw * are met:
15 1.10.8.2 nathanw * 1. Redistributions of source code must retain the above copyright
16 1.10.8.2 nathanw * notice, this list of conditions and the following disclaimer.
17 1.10.8.2 nathanw * 2. Redistributions in binary form must reproduce the above copyright
18 1.10.8.2 nathanw * notice, this list of conditions and the following disclaimer in the
19 1.10.8.2 nathanw * documentation and/or other materials provided with the distribution.
20 1.10.8.2 nathanw * 3. All advertising materials mentioning features or use of this software
21 1.10.8.2 nathanw * must display the following acknowledgement:
22 1.10.8.2 nathanw * This product includes software developed by the University of
23 1.10.8.2 nathanw * California, Berkeley and its contributors.
24 1.10.8.2 nathanw * 4. Neither the name of the University nor the names of its contributors
25 1.10.8.2 nathanw * may be used to endorse or promote products derived from this software
26 1.10.8.2 nathanw * without specific prior written permission.
27 1.10.8.2 nathanw *
28 1.10.8.2 nathanw * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
29 1.10.8.2 nathanw * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 1.10.8.2 nathanw * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31 1.10.8.2 nathanw * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
32 1.10.8.2 nathanw * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33 1.10.8.2 nathanw * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34 1.10.8.2 nathanw * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35 1.10.8.2 nathanw * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36 1.10.8.2 nathanw * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37 1.10.8.2 nathanw * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 1.10.8.2 nathanw * SUCH DAMAGE.
39 1.10.8.2 nathanw *
40 1.10.8.2 nathanw * from: Utah $Hdr: machparam.h 1.16 92/12/20$
41 1.10.8.2 nathanw *
42 1.10.8.2 nathanw * @(#)param.h 8.1 (Berkeley) 6/10/93
43 1.10.8.2 nathanw */
44 1.10.8.2 nathanw #ifndef _M68K_PARAM_H_
45 1.10.8.2 nathanw #define _M68K_PARAM_H_
46 1.10.8.2 nathanw
47 1.10.8.2 nathanw /*
48 1.10.8.2 nathanw * Machine independent constants for m68k
49 1.10.8.2 nathanw */
50 1.10.8.2 nathanw #ifndef MACHINE_ARCH
51 1.10.8.2 nathanw #define _MACHINE_ARCH m68k
52 1.10.8.2 nathanw #define MACHINE_ARCH "m68k"
53 1.10.8.2 nathanw #endif
54 1.10.8.2 nathanw #ifndef MID_MACHINE
55 1.10.8.2 nathanw #define MID_MACHINE MID_M68K
56 1.10.8.2 nathanw #endif
57 1.10.8.2 nathanw
58 1.10.8.2 nathanw /*
59 1.10.8.2 nathanw * Round p (pointer or byte index) up to a correctly-aligned value for all
60 1.10.8.2 nathanw * data types (int, long, ...). The result is u_int and must be cast to
61 1.10.8.2 nathanw * any desired pointer type.
62 1.10.8.2 nathanw *
63 1.10.8.2 nathanw * ALIGNED_POINTER is a boolean macro that checks whether an address
64 1.10.8.2 nathanw * is valid to fetch data elements of type t from on this architecture.
65 1.10.8.2 nathanw * This does not reflect the optimal alignment, just the possibility
66 1.10.8.2 nathanw * (within reasonable limits).
67 1.10.8.2 nathanw *
68 1.10.8.2 nathanw */
69 1.10.8.2 nathanw #define ALIGNBYTES (sizeof(int) - 1)
70 1.10.8.2 nathanw #define ALIGN(p) (((u_int)(p) + ALIGNBYTES) &~ ALIGNBYTES)
71 1.10.8.2 nathanw #define ALIGNED_POINTER(p,t) ((((u_long)(p)) & (sizeof(t)-1)) == 0)
72 1.10.8.2 nathanw
73 1.10.8.2 nathanw #define NBPG (1 << PGSHIFT) /* bytes/page */
74 1.10.8.2 nathanw #define PGOFSET (NBPG-1) /* byte offset into page */
75 1.10.8.2 nathanw
76 1.10.8.2 nathanw #define BTOPKERNBASE ((u_long)KERNBASE >> PGSHIFT)
77 1.10.8.2 nathanw
78 1.10.8.2 nathanw #define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */
79 1.10.8.2 nathanw #define DEV_BSIZE (1 << DEV_BSHIFT)
80 1.10.8.2 nathanw #define BLKDEV_IOSIZE 2048
81 1.10.8.2 nathanw #define MAXPHYS (64 * 1024) /* max raw I/O transfer size */
82 1.10.8.2 nathanw
83 1.10.8.2 nathanw #define SSIZE 1 /* initial stack size/NBPG */
84 1.10.8.2 nathanw #define SINCR 1 /* increment of stack/NBPG */
85 1.10.8.2 nathanw
86 1.10.8.2 nathanw #define USPACE (UPAGES * NBPG)
87 1.10.8.2 nathanw
88 1.10.8.2 nathanw #ifndef MSGBUFSIZE
89 1.10.8.2 nathanw #define MSGBUFSIZE NBPG /* default message buffer size */
90 1.10.8.2 nathanw #endif
91 1.10.8.2 nathanw
92 1.10.8.2 nathanw /*
93 1.10.8.2 nathanw * Constants related to network buffer management.
94 1.10.8.2 nathanw * MCLBYTES must be no larger than NBPG (the software page size), and,
95 1.10.8.2 nathanw * on machines that exchange pages of input or output buffers with mbuf
96 1.10.8.2 nathanw * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
97 1.10.8.2 nathanw * of the hardware page size.
98 1.10.8.2 nathanw */
99 1.10.8.2 nathanw #define MSIZE 256 /* size of an mbuf */
100 1.10.8.2 nathanw
101 1.10.8.2 nathanw #ifndef MCLSHIFT
102 1.10.8.2 nathanw #define MCLSHIFT 11 /* convert bytes to m_buf clusters */
103 1.10.8.2 nathanw /* 2K cluster can hold Ether frame */
104 1.10.8.2 nathanw #endif /* MCLSHIFT */
105 1.10.8.2 nathanw
106 1.10.8.2 nathanw #define MCLBYTES (1 << MCLSHIFT) /* size of a m_buf cluster */
107 1.10.8.2 nathanw
108 1.10.8.2 nathanw #ifndef NMBCLUSTERS
109 1.10.8.2 nathanw #if defined(_KERNEL_OPT)
110 1.10.8.2 nathanw #include "opt_gateway.h"
111 1.10.8.2 nathanw #endif
112 1.10.8.2 nathanw
113 1.10.8.2 nathanw #ifdef GATEWAY
114 1.10.8.2 nathanw # define NMBCLUSTERS 512 /* map size, max cluster allocation */
115 1.10.8.2 nathanw #else
116 1.10.8.2 nathanw # define NMBCLUSTERS 256 /* map size, max cluster allocation */
117 1.10.8.2 nathanw #endif
118 1.10.8.2 nathanw #endif
119 1.10.8.2 nathanw
120 1.10.8.2 nathanw /* pages ("clicks") to disk blocks */
121 1.10.8.2 nathanw #define ctod(x) ((x) << (PGSHIFT - DEV_BSHIFT))
122 1.10.8.2 nathanw #define dtoc(x) ((x) >> (PGSHIFT - DEV_BSHIFT))
123 1.10.8.2 nathanw
124 1.10.8.2 nathanw /* pages to bytes */
125 1.10.8.2 nathanw #define ctob(x) ((x) << PGSHIFT)
126 1.10.8.2 nathanw #define btoc(x) (((x) + PGOFSET) >> PGSHIFT)
127 1.10.8.2 nathanw
128 1.10.8.2 nathanw /* bytes to disk blocks */
129 1.10.8.2 nathanw #define btodb(x) ((x) >> DEV_BSHIFT)
130 1.10.8.2 nathanw #define dbtob(x) ((x) << DEV_BSHIFT)
131 1.10.8.2 nathanw
132 1.10.8.2 nathanw /*
133 1.10.8.2 nathanw * Map a ``block device block'' to a file system block.
134 1.10.8.2 nathanw * This should be device dependent, and should use the bsize
135 1.10.8.2 nathanw * field from the disk label.
136 1.10.8.2 nathanw * For now though just use DEV_BSIZE.
137 1.10.8.2 nathanw */
138 1.10.8.2 nathanw #define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
139 1.10.8.2 nathanw
140 1.10.8.2 nathanw /*
141 1.10.8.2 nathanw * Mach-derived conversion macros
142 1.10.8.2 nathanw */
143 1.10.8.2 nathanw #define m68k_round_seg(x) ((((unsigned)(x)) + SEGOFSET) & ~SEGOFSET)
144 1.10.8.2 nathanw #define m68k_trunc_seg(x) ((unsigned)(x) & ~SEGOFSET)
145 1.10.8.2 nathanw #define m68k_seg_offset(x) ((unsigned)(x) & SEGOFSET)
146 1.10.8.2 nathanw #define m68k_round_page(x) ((((unsigned)(x)) + PGOFSET) & ~PGOFSET)
147 1.10.8.2 nathanw #define m68k_trunc_page(x) ((unsigned)(x) & ~PGOFSET)
148 1.10.8.2 nathanw #define m68k_page_offset(x) ((unsigned)(x) & PGOFSET)
149 1.10.8.2 nathanw #define m68k_btop(x) ((unsigned)(x) >> PGSHIFT)
150 1.10.8.2 nathanw #define m68k_ptob(x) ((unsigned)(x) << PGSHIFT)
151 1.10.8.2 nathanw
152 1.10.8.2 nathanw #endif /* !_M68K_PARAM_H_ */
153