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