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