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