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