]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
9bccf70c | 2 | * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved. |
1c79356b A |
3 | * |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
ff6e181a A |
6 | * This file contains Original Code and/or Modifications of Original Code |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. Please obtain a copy of the License at | |
10 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
11 | * file. | |
1c79356b | 12 | * |
ff6e181a A |
13 | * The Original Code and all software distributed under the License are |
14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
1c79356b A |
15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
ff6e181a A |
17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
18 | * Please see the License for the specific language governing rights and | |
19 | * limitations under the License. | |
1c79356b A |
20 | * |
21 | * @APPLE_LICENSE_HEADER_END@ | |
22 | */ | |
23 | /*- | |
24 | * Copyright (c) 1990, 1993 | |
25 | * The Regents of the University of California. All rights reserved. | |
26 | * (c) UNIX System Laboratories, Inc. | |
27 | * All or some portions of this file are derived from material licensed | |
28 | * to the University of California by American Telephone and Telegraph | |
29 | * Co. or Unix System Laboratories, Inc. and are reproduced herein with | |
30 | * the permission of UNIX System Laboratories, Inc. | |
31 | * | |
32 | * Redistribution and use in source and binary forms, with or without | |
33 | * modification, are permitted provided that the following conditions | |
34 | * are met: | |
35 | * 1. Redistributions of source code must retain the above copyright | |
36 | * notice, this list of conditions and the following disclaimer. | |
37 | * 2. Redistributions in binary form must reproduce the above copyright | |
38 | * notice, this list of conditions and the following disclaimer in the | |
39 | * documentation and/or other materials provided with the distribution. | |
40 | * 3. All advertising materials mentioning features or use of this software | |
41 | * must display the following acknowledgement: | |
42 | * This product includes software developed by the University of | |
43 | * California, Berkeley and its contributors. | |
44 | * 4. Neither the name of the University nor the names of its contributors | |
45 | * may be used to endorse or promote products derived from this software | |
46 | * without specific prior written permission. | |
47 | * | |
48 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
49 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
50 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
51 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
52 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
53 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
54 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
55 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
56 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
57 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
58 | * SUCH DAMAGE. | |
59 | * | |
60 | * @(#)param.h 8.1 (Berkeley) 4/4/95 | |
61 | */ | |
62 | ||
63 | /* | |
64 | * Machine dependent constants for Intel 386. | |
65 | */ | |
66 | ||
67 | #ifndef _I386_PARAM_H_ | |
68 | #define _I386_PARAM_H_ | |
69 | ||
70 | /* | |
71 | * Round p (pointer or byte index) up to a correctly-aligned value for all | |
91447636 A |
72 | * data types (int, long, ...). The result is unsigned int and must be |
73 | * cast to any desired pointer type. | |
1c79356b A |
74 | */ |
75 | #define ALIGNBYTES 3 | |
91447636 | 76 | #define ALIGN(p) (((unsigned int)(p) + ALIGNBYTES) &~ ALIGNBYTES) |
1c79356b A |
77 | |
78 | #define NBPG 4096 /* bytes/page */ | |
79 | #define PGOFSET (NBPG-1) /* byte offset into page */ | |
80 | #define PGSHIFT 12 /* LOG2(NBPG) */ | |
81 | ||
82 | #define DEV_BSIZE 512 | |
83 | #define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ | |
84 | #define BLKDEV_IOSIZE 2048 | |
85 | #define MAXPHYS (64 * 1024) /* max raw I/O transfer size */ | |
86 | ||
1c79356b A |
87 | #define CLSIZE 1 |
88 | #define CLSIZELOG2 0 | |
89 | ||
90 | /* | |
91 | * Constants related to network buffer management. | |
92 | * MCLBYTES must be no larger than CLBYTES (the software page size), and, | |
93 | * on machines that exchange pages of input or output buffers with mbuf | |
94 | * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple | |
95 | * of the hardware page size. | |
96 | */ | |
0b4e3aa0 | 97 | #define MSIZE 256 /* size of an mbuf */ |
1c79356b A |
98 | #define MCLBYTES 2048 /* large enough for ether MTU */ |
99 | #define MCLSHIFT 11 | |
100 | #define MCLOFSET (MCLBYTES - 1) | |
101 | #ifndef NMBCLUSTERS | |
102 | #ifdef GATEWAY | |
103 | #define NMBCLUSTERS ((1024 * 1024) / MCLBYTES) /* cl map size: 1MB */ | |
104 | #else | |
105 | #define NMBCLUSTERS ((1024 * 512) / MCLBYTES) /* cl map size: 0.5MB */ | |
106 | #endif | |
107 | #endif | |
108 | ||
109 | /* | |
110 | * Some macros for units conversion | |
111 | */ | |
112 | /* Core clicks (NeXT_page_size bytes) to segments and vice versa */ | |
113 | #define ctos(x) (x) | |
114 | #define stoc(x) (x) | |
115 | ||
116 | /* Core clicks (4096 bytes) to disk blocks */ | |
117 | #define ctod(x) ((x)<<(PGSHIFT-DEV_BSHIFT)) | |
118 | #define dtoc(x) ((x)>>(PGSHIFT-DEV_BSHIFT)) | |
119 | #define dtob(x) ((x)<<DEV_BSHIFT) | |
120 | ||
121 | /* clicks to bytes */ | |
122 | #define ctob(x) ((x)<<PGSHIFT) | |
123 | ||
124 | /* bytes to clicks */ | |
125 | #define btoc(x) (((unsigned)(x)+(NBPG-1))>>PGSHIFT) | |
126 | ||
127 | #ifdef __APPLE__ | |
128 | #define btodb(bytes, devBlockSize) \ | |
129 | ((unsigned)(bytes) / devBlockSize) | |
130 | #define dbtob(db, devBlockSize) \ | |
131 | ((unsigned)(db) * devBlockSize) | |
132 | #else | |
133 | #define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ | |
134 | ((unsigned)(bytes) >> DEV_BSHIFT) | |
135 | #define dbtob(db) /* calculates (db * DEV_BSIZE) */ \ | |
136 | ((unsigned)(db) << DEV_BSHIFT) | |
137 | #endif | |
138 | ||
139 | /* | |
140 | * Map a ``block device block'' to a file system block. | |
141 | * This should be device dependent, and will be if we | |
142 | * add an entry to cdevsw/bdevsw for that purpose. | |
143 | * For now though just use DEV_BSIZE. | |
144 | */ | |
145 | #define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE)) | |
146 | ||
147 | /* | |
148 | * Macros to decode (and encode) processor status word. | |
149 | */ | |
150 | #define STATUS_WORD(rpl, ipl) (((ipl) << 8) | (rpl)) | |
151 | #define USERMODE(x) (((x) & 3) == 3) | |
152 | #define BASEPRI(x) (((x) & (255 << 8)) == 0) | |
153 | ||
154 | ||
155 | #if defined(KERNEL) || defined(STANDALONE) | |
156 | #define DELAY(n) delay(n) | |
157 | ||
158 | #else /* defined(KERNEL) || defined(STANDALONE) */ | |
159 | #define DELAY(n) { register int N = (n); while (--N > 0); } | |
160 | #endif /* defined(KERNEL) || defined(STANDALONE) */ | |
161 | ||
162 | #endif /* _I386_PARAM_H_ */ |