1 | /* |
2 | * Copyright (c) 2000-2010 Apple Inc. All rights reserved. |
3 | */ |
4 | /*- |
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. |
12 | * |
13 | * Redistribution and use in source and binary forms, with or without |
14 | * modification, are permitted provided that the following conditions |
15 | * are met: |
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. |
28 | * |
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 |
39 | * SUCH DAMAGE. |
40 | * |
41 | * @(#)param.h 8.1 (Berkeley) 4/4/95 |
42 | */ |
43 | |
44 | /* |
45 | * Machine dependent constants for ARM |
46 | */ |
47 | |
48 | #ifndef _ARM_PARAM_H_ |
49 | #define _ARM_PARAM_H_ |
50 | |
51 | #if defined (__arm__) || defined (__arm64__) |
52 | |
53 | #include <arm/_param.h> |
54 | |
55 | /* |
56 | * Round p (pointer or byte index) up to a correctly-aligned value for all |
57 | * data types (int, long, ...). The result is unsigned int and must be |
58 | * cast to any desired pointer type. |
59 | */ |
60 | #define ALIGNBYTES __DARWIN_ALIGNBYTES |
61 | #define ALIGN(p) __DARWIN_ALIGN(p) |
62 | |
63 | #define NBPG 4096 /* bytes/page */ |
64 | #define PGOFSET (NBPG-1) /* byte offset into page */ |
65 | #define PGSHIFT 12 /* LOG2(NBPG) */ |
66 | |
67 | #define DEV_BSIZE 512 |
68 | #define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ |
69 | #define BLKDEV_IOSIZE 2048 |
70 | #define MAXPHYS (64 * 1024) /* max raw I/O transfer size */ |
71 | |
72 | #define CLSIZE 1 |
73 | #define CLSIZELOG2 0 |
74 | |
75 | /* |
76 | * Constants related to network buffer management. |
77 | * MCLBYTES must be no larger than CLBYTES (the software page size), and, |
78 | * on machines that exchange pages of input or output buffers with mbuf |
79 | * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple |
80 | * of the hardware page size. |
81 | */ |
82 | #define MSIZESHIFT 8 /* 256 */ |
83 | #define MSIZE (1 << MSIZESHIFT) /* size of an mbuf */ |
84 | #define MCLSHIFT 11 /* 2048 */ |
85 | #define MCLBYTES (1 << MCLSHIFT) /* size of an mbuf cluster */ |
86 | #define MBIGCLSHIFT 12 /* 4096 */ |
87 | #define MBIGCLBYTES (1 << MBIGCLSHIFT) /* size of a big cluster */ |
88 | #define M16KCLSHIFT 14 /* 16384 */ |
89 | #define M16KCLBYTES (1 << M16KCLSHIFT) /* size of a jumbo cluster */ |
90 | |
91 | #define MCLOFSET (MCLBYTES - 1) |
92 | #ifndef NMBCLUSTERS |
93 | #define NMBCLUSTERS CONFIG_NMBCLUSTERS /* cl map size */ |
94 | #endif |
95 | |
96 | /* |
97 | * Some macros for units conversion |
98 | */ |
99 | /* Core clicks (NeXT_page_size bytes) to segments and vice versa */ |
100 | #define ctos(x) (x) |
101 | #define stoc(x) (x) |
102 | |
103 | /* Core clicks (4096 bytes) to disk blocks */ |
104 | #define ctod(x) ((x)<<(PGSHIFT-DEV_BSHIFT)) |
105 | #define dtoc(x) ((x)>>(PGSHIFT-DEV_BSHIFT)) |
106 | #define dtob(x) ((x)<<DEV_BSHIFT) |
107 | |
108 | /* clicks to bytes */ |
109 | #define ctob(x) ((x)<<PGSHIFT) |
110 | |
111 | /* bytes to clicks */ |
112 | #define btoc(x) (((unsigned)(x)+(NBPG-1))>>PGSHIFT) |
113 | |
114 | #ifdef __APPLE__ |
115 | #define btodb(bytes, devBlockSize) \ |
116 | ((unsigned)(bytes) / devBlockSize) |
117 | #define dbtob(db, devBlockSize) \ |
118 | ((unsigned)(db) * devBlockSize) |
119 | #else |
120 | #define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ |
121 | ((unsigned)(bytes) >> DEV_BSHIFT) |
122 | #define dbtob(db) /* calculates (db * DEV_BSIZE) */ \ |
123 | ((unsigned)(db) << DEV_BSHIFT) |
124 | #endif |
125 | |
126 | /* |
127 | * Map a ``block device block'' to a file system block. |
128 | * This should be device dependent, and will be if we |
129 | * add an entry to cdevsw/bdevsw for that purpose. |
130 | * For now though just use DEV_BSIZE. |
131 | */ |
132 | #define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE)) |
133 | |
134 | /* |
135 | * Macros to decode (and encode) processor status word. |
136 | */ |
137 | #define STATUS_WORD(rpl, ipl) (((ipl) << 8) | (rpl)) |
138 | #define USERMODE(x) (((x) & 3) == 3) |
139 | #define BASEPRI(x) (((x) & (255 << 8)) == 0) |
140 | |
141 | |
142 | #if defined(KERNEL) || defined(STANDALONE) |
143 | #define DELAY(n) delay(n) |
144 | |
145 | #else /* defined(KERNEL) || defined(STANDALONE) */ |
146 | #define DELAY(n) { int N = (n); while (--N > 0); } |
147 | #endif /* defined(KERNEL) || defined(STANDALONE) */ |
148 | |
149 | #endif /* defined (__arm__) || defined (__arm64__) */ |
150 | |
151 | #endif /* _ARM_PARAM_H_ */ |
152 | |