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