]>
git.saurik.com Git - apple/xnu.git/blob - bsd/arm/param.h
2 * Copyright (c) 2000-2010 Apple Inc. All rights reserved.
5 * Copyright (c) 1990, 1993
6 * The Regents of the University of California. All rights reserved.
7 * (c) UNIX System Laboratories, Inc.
8 * All or some portions of this file are derived from material licensed
9 * to the University of California by American Telephone and Telegraph
10 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
11 * the permission of UNIX System Laboratories, Inc.
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 * 3. All advertising materials mentioning features or use of this software
22 * must display the following acknowledgement:
23 * This product includes software developed by the University of
24 * California, Berkeley and its contributors.
25 * 4. Neither the name of the University nor the names of its contributors
26 * may be used to endorse or promote products derived from this software
27 * without specific prior written permission.
29 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
30 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
33 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
35 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
38 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
41 * @(#)param.h 8.1 (Berkeley) 4/4/95
45 * Machine dependent constants for ARM
51 #include <arm/_param.h>
54 * Round p (pointer or byte index) up to a correctly-aligned value for all
55 * data types (int, long, ...). The result is unsigned int and must be
56 * cast to any desired pointer type.
58 #define ALIGNBYTES __DARWIN_ALIGNBYTES
59 #define ALIGN(p) __DARWIN_ALIGN(p)
61 #define NBPG 4096 /* bytes/page */
62 #define PGOFSET (NBPG-1) /* byte offset into page */
63 #define PGSHIFT 12 /* LOG2(NBPG) */
66 #define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */
67 #define BLKDEV_IOSIZE 2048
68 #define MAXPHYS (64 * 1024) /* max raw I/O transfer size */
74 * Constants related to network buffer management.
75 * MCLBYTES must be no larger than CLBYTES (the software page size), and,
76 * on machines that exchange pages of input or output buffers with mbuf
77 * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
78 * of the hardware page size.
80 #define MSIZESHIFT 8 /* 256 */
81 #define MSIZE (1 << MSIZESHIFT) /* size of an mbuf */
82 #define MCLSHIFT 11 /* 2048 */
83 #define MCLBYTES (1 << MCLSHIFT) /* size of an mbuf cluster */
84 #define MBIGCLSHIFT 12 /* 4096 */
85 #define MBIGCLBYTES (1 << MBIGCLSHIFT) /* size of a big cluster */
86 #define M16KCLSHIFT 14 /* 16384 */
87 #define M16KCLBYTES (1 << M16KCLSHIFT) /* size of a jumbo cluster */
89 #define MCLOFSET (MCLBYTES - 1)
91 #define NMBCLUSTERS CONFIG_NMBCLUSTERS /* cl map size */
95 * Some macros for units conversion
97 /* Core clicks (NeXT_page_size bytes) to segments and vice versa */
101 /* Core clicks (4096 bytes) to disk blocks */
102 #define ctod(x) ((x)<<(PGSHIFT-DEV_BSHIFT))
103 #define dtoc(x) ((x)>>(PGSHIFT-DEV_BSHIFT))
104 #define dtob(x) ((x)<<DEV_BSHIFT)
106 /* clicks to bytes */
107 #define ctob(x) ((x)<<PGSHIFT)
109 /* bytes to clicks */
110 #define btoc(x) (((unsigned)(x)+(NBPG-1))>>PGSHIFT)
113 #define btodb(bytes, devBlockSize) \
114 ((unsigned)(bytes) / devBlockSize)
115 #define dbtob(db, devBlockSize) \
116 ((unsigned)(db) * devBlockSize)
118 #define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \
119 ((unsigned)(bytes) >> DEV_BSHIFT)
120 #define dbtob(db) /* calculates (db * DEV_BSIZE) */ \
121 ((unsigned)(db) << DEV_BSHIFT)
125 * Map a ``block device block'' to a file system block.
126 * This should be device dependent, and will be if we
127 * add an entry to cdevsw/bdevsw for that purpose.
128 * For now though just use DEV_BSIZE.
130 #define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
133 * Macros to decode (and encode) processor status word.
135 #define STATUS_WORD(rpl, ipl) (((ipl) << 8) | (rpl))
136 #define USERMODE(x) (((x) & 3) == 3)
137 #define BASEPRI(x) (((x) & (255 << 8)) == 0)
140 #if defined(KERNEL) || defined(STANDALONE)
141 #define DELAY(n) delay(n)
143 #else /* defined(KERNEL) || defined(STANDALONE) */
144 #define DELAY(n) { int N = (n); while (--N > 0); }
145 #endif /* defined(KERNEL) || defined(STANDALONE) */
147 #endif /* _ARM_PARAM_H_ */