1/* 2 * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved. 3 * 4 * @APPLE_LICENSE_HEADER_START@ 5 * 6 * The contents of this file constitute Original Code as defined in and 7 * are subject to the Apple Public Source License Version 1.1 (the 8 * "License"). You may not use this file except in compliance with the 9 * License. Please obtain a copy of the License at 10 * http://www.apple.com/publicsource and read it before using this file. 11 * 12 * This Original Code and all software distributed under the License are 13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER 14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the 17 * License for the specific language governing rights and limitations 18 * under the License. 19 * 20 * @APPLE_LICENSE_HEADER_END@ 21 */ 22/* Copyright (c) 1993,1995 NeXT Computer, Inc. All Rights Reserved */ 23 24#ifndef _PPC_PARAM_H_ 25#define _PPC_PARAM_H_ 26 27/* 28 * Round p (pointer or byte index) up to a correctly-aligned value for all 29 * data types (int, long, ...). The result is unsigned int and must be 30 * cast to any desired pointer type. 31 */ 32#define ALIGNBYTES 3 33#define ALIGN(p) (((unsigned int)(p) + ALIGNBYTES) &~ ALIGNBYTES) 34 35#define NBPG 4096 /* bytes/page */ 36#define PGOFSET (NBPG-1) /* byte offset into page */ 37#define PGSHIFT 12 /* LOG2(NBPG) */ 38 39#define NBSEG 0x40000000 /* bytes/segment (quadrant) */ 40#define SEGOFSET (NBSEG-1) /* byte offset into segment */ 41#define SEGSHIFT 30 /* LOG2(NBSEG) */ 42 43#define DEV_BSIZE 512 44#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ 45#define BLKDEV_IOSIZE 2048 46#define MAXPHYS (128 * 1024) /* max raw I/O transfer size */ 47 48#define STACK_GROWTH_UP 0 /* stack grows to lower addresses */ 49 50#define CLSIZE 1 51#define CLSIZELOG2 0 52 53#define STACKSIZE 4 /* pages in kernel stack */ 54#define UPAGES 0 /* total pages in u-area */ 55 /* red zone is beyond this */ 56 57/* 58 * Constants related to network buffer management. 59 * MCLBYTES must be no larger than CLBYTES (the software page size), and, 60 * on machines that exchange pages of input or output buffers with mbuf 61 * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple 62 * of the hardware page size. 63 */ 64#define MSIZE 256 /* size of an mbuf */ 65#define MCLBYTES 2048 /* large enough for ether MTU */ 66#define MCLSHIFT 11 67#define MCLOFSET (MCLBYTES - 1) 68#ifndef NMBCLUSTERS 69#if GATEWAY 70#define NMBCLUSTERS ((1024 * 1024) / MCLBYTES) /* cl map size: 1MB */ 71#else 72#define NMBCLUSTERS ((1024 * 1024) / MCLBYTES) 73 /* cl map size was 0.5MB when MSIZE was 128, now it's 1MB*/ 74#endif 75#endif 76 77/* pages ("clicks") (NBPG bytes) to disk blocks */ 78#define ctod(x) ((x)<<(PGSHIFT-DEV_BSHIFT)) 79#define dtoc(x) ((x)>>(PGSHIFT-DEV_BSHIFT)) 80#define dtob(x) ((x)<<DEV_BSHIFT) 81 82/* pages to bytes */ 83#define ctob(x) ((x)<<PGSHIFT) 84 85/* bytes to pages */ 86#define btoc(x) (((unsigned)(x)+(PGOFSET))>>PGSHIFT) 87#ifdef __APPLE__ 88#define btodb(bytes, devBlockSize) \ 89 ((unsigned)(bytes) / devBlockSize) 90#define dbtob(db, devBlockSize) \ 91 ((unsigned)(db) * devBlockSize) 92#else 93#define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ 94 ((unsigned)(bytes) >> DEV_BSHIFT) 95#define dbtob(db) /* calculates (db * DEV_BSIZE) */ \ 96 ((unsigned)(db) << DEV_BSHIFT) 97#endif 98 99/* 100 * Map a ``block device block'' to a file system block. 101 * This should be device dependent, and should use the bsize 102 * field from the disk label. 103 * For now though just use DEV_BSIZE. 104 */ 105#define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE)) 106 107/* from machdep/ppc/proc_reg.h */ 108#ifdef __BIG_ENDIAN__ 109#define ENDIAN_MASK(val,size) (1 << (size-1 - val)) 110#else 111#error code not ported to little endian targets yet 112#endif /* __BIG_ENDIAN__ */ 113 114#ifndef MASK 115#define MASK(PART) ENDIAN_MASK(PART ## _BIT, 32) 116#endif 117 118#define MSR_EE_BIT 16 119#define MSR_PR_BIT 17 120#define USERMODE(msr) (msr & MASK(MSR_PR) ? TRUE : FALSE) 121#define BASEPRI(msr) (msr & MASK(MSR_EE) ? TRUE : FALSE) 122/* end of from proc_reg.h */ 123 124#if defined(KERNEL) || defined(STANDALONE) 125#define DELAY(n) delay(n) 126#else 127#define DELAY(n) { register int N = (n); while (--N > 0); } 128#endif /* defined(KERNEL) || defined(STANDALONE) */ 129 130#define NPIDS 16 /* maximum number of PIDs per process */ 131#define NIOPIDS 8 /* maximum number of IO space PIDs */ 132 133#endif /* _PPC_PARAM_H_ */ 134

