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