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