]>
git.saurik.com Git - apple/xnu.git/blob - bsd/ppc/param.h
2 * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
20 * @APPLE_LICENSE_HEADER_END@
22 /* Copyright (c) 1993,1995 NeXT Computer, Inc. All Rights Reserved */
24 * The NEXTSTEP Software License Agreement specifies the terms
25 * and conditions for redistribution.
33 * Round p (pointer or byte index) up to a correctly-aligned value for all
34 * data types (int, long, ...). The result is u_int and must be cast to
35 * any desired pointer type.
38 #define ALIGN(p) (((u_int)(p) + ALIGNBYTES) &~ ALIGNBYTES)
40 #define NBPG 4096 /* bytes/page */
41 #define PGOFSET (NBPG-1) /* byte offset into page */
42 #define PGSHIFT 12 /* LOG2(NBPG) */
44 #define NBSEG 0x40000000 /* bytes/segment (quadrant) */
45 #define SEGOFSET (NBSEG-1) /* byte offset into segment */
46 #define SEGSHIFT 30 /* LOG2(NBSEG) */
49 #define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */
50 #define BLKDEV_IOSIZE 2048
51 #define MAXPHYS (128 * 1024) /* max raw I/O transfer size */
53 #define STACK_GROWTH_UP 0 /* stack grows to lower addresses */
58 #define STACKSIZE 4 /* pages in kernel stack */
59 #define UPAGES 0 /* total pages in u-area */
60 /* red zone is beyond this */
63 * Constants related to network buffer management.
64 * MCLBYTES must be no larger than CLBYTES (the software page size), and,
65 * on machines that exchange pages of input or output buffers with mbuf
66 * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
67 * of the hardware page size.
69 #define MSIZE 256 /* size of an mbuf */
70 #define MCLBYTES 2048 /* large enough for ether MTU */
72 #define MCLOFSET (MCLBYTES - 1)
75 #define NMBCLUSTERS ((1024 * 1024) / MCLBYTES) /* cl map size: 1MB */
77 #define NMBCLUSTERS ((1024 * 1024) / MCLBYTES)
78 /* cl map size was 0.5MB when MSIZE was 128, now it's 1MB*/
82 /* pages ("clicks") (NBPG bytes) to disk blocks */
83 #define ctod(x) ((x)<<(PGSHIFT-DEV_BSHIFT))
84 #define dtoc(x) ((x)>>(PGSHIFT-DEV_BSHIFT))
85 #define dtob(x) ((x)<<DEV_BSHIFT)
88 #define ctob(x) ((x)<<PGSHIFT)
91 #define btoc(x) (((unsigned)(x)+(PGOFSET))>>PGSHIFT)
93 #define btodb(bytes, devBlockSize) \
94 ((unsigned)(bytes) / devBlockSize)
95 #define dbtob(db, devBlockSize) \
96 ((unsigned)(db) * devBlockSize)
98 #define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \
99 ((unsigned)(bytes) >> DEV_BSHIFT)
100 #define dbtob(db) /* calculates (db * DEV_BSIZE) */ \
101 ((unsigned)(db) << DEV_BSHIFT)
105 * Map a ``block device block'' to a file system block.
106 * This should be device dependent, and should use the bsize
107 * field from the disk label.
108 * For now though just use DEV_BSIZE.
110 #define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
112 /* from machdep/ppc/proc_reg.h */
114 #define ENDIAN_MASK(val,size) (1 << (size-1 - val))
116 #error code not ported to little endian targets yet
117 #endif /* __BIG_ENDIAN__ */
120 #define MASK(PART) ENDIAN_MASK(PART ## _BIT, 32)
123 #define MSR_EE_BIT 16
124 #define MSR_PR_BIT 17
125 #define USERMODE(msr) (msr & MASK(MSR_PR) ? TRUE : FALSE)
126 #define BASEPRI(msr) (msr & MASK(MSR_EE) ? TRUE : FALSE)
127 /* end of from proc_reg.h */
129 #if defined(KERNEL) || defined(STANDALONE)
130 #define DELAY(n) delay(n)
132 #define DELAY(n) { register int N = (n); while (--N > 0); }
133 #endif /* defined(KERNEL) || defined(STANDALONE) */
135 #define NPIDS 16 /* maximum number of PIDs per process */
136 #define NIOPIDS 8 /* maximum number of IO space PIDs */
138 #endif /* _PPC_PARAM_H_ */