]> git.saurik.com Git - apple/xnu.git/blob - bsd/ppc/param.h
xnu-344.tar.gz
[apple/xnu.git] / bsd / ppc / param.h
1 /*
2 * Copyright (c) 2000-2002 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 * The NEXTSTEP Software License Agreement specifies the terms
25 * and conditions for redistribution.
26 *
27 */
28
29 #ifndef _PPC_PARAM_H_
30 #define _PPC_PARAM_H_
31
32 /*
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.
36 */
37 #define ALIGNBYTES 3
38 #define ALIGN(p) (((u_int)(p) + ALIGNBYTES) &~ ALIGNBYTES)
39
40 #define NBPG 4096 /* bytes/page */
41 #define PGOFSET (NBPG-1) /* byte offset into page */
42 #define PGSHIFT 12 /* LOG2(NBPG) */
43
44 #define NBSEG 0x40000000 /* bytes/segment (quadrant) */
45 #define SEGOFSET (NBSEG-1) /* byte offset into segment */
46 #define SEGSHIFT 30 /* LOG2(NBSEG) */
47
48 #define DEV_BSIZE 512
49 #define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */
50 #define BLKDEV_IOSIZE 2048
51 #define MAXPHYS (128 * 1024) /* max raw I/O transfer size */
52
53 #define STACK_GROWTH_UP 0 /* stack grows to lower addresses */
54
55 #define CLSIZE 1
56 #define CLSIZELOG2 0
57
58 #define STACKSIZE 4 /* pages in kernel stack */
59 #define UPAGES 0 /* total pages in u-area */
60 /* red zone is beyond this */
61
62 /*
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.
68 */
69 #define MSIZE 256 /* size of an mbuf */
70 #define MCLBYTES 2048 /* large enough for ether MTU */
71 #define MCLSHIFT 11
72 #define MCLOFSET (MCLBYTES - 1)
73 #ifndef NMBCLUSTERS
74 #if GATEWAY
75 #define NMBCLUSTERS ((1024 * 1024) / MCLBYTES) /* cl map size: 1MB */
76 #else
77 #define NMBCLUSTERS ((1024 * 1024) / MCLBYTES)
78 /* cl map size was 0.5MB when MSIZE was 128, now it's 1MB*/
79 #endif
80 #endif
81
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)
86
87 /* pages to bytes */
88 #define ctob(x) ((x)<<PGSHIFT)
89
90 /* bytes to pages */
91 #define btoc(x) (((unsigned)(x)+(PGOFSET))>>PGSHIFT)
92 #ifdef __APPLE__
93 #define btodb(bytes, devBlockSize) \
94 ((unsigned)(bytes) / devBlockSize)
95 #define dbtob(db, devBlockSize) \
96 ((unsigned)(db) * devBlockSize)
97 #else
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)
102 #endif
103
104 /*
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.
109 */
110 #define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
111
112 /* from machdep/ppc/proc_reg.h */
113 #if __BIG_ENDIAN__
114 #define ENDIAN_MASK(val,size) (1 << (size-1 - val))
115 #else
116 #error code not ported to little endian targets yet
117 #endif /* __BIG_ENDIAN__ */
118
119 #ifndef MASK
120 #define MASK(PART) ENDIAN_MASK(PART ## _BIT, 32)
121 #endif
122
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 */
128
129 #if defined(KERNEL) || defined(STANDALONE)
130 #define DELAY(n) delay(n)
131 #else
132 #define DELAY(n) { register int N = (n); while (--N > 0); }
133 #endif /* defined(KERNEL) || defined(STANDALONE) */
134
135 #define NPIDS 16 /* maximum number of PIDs per process */
136 #define NIOPIDS 8 /* maximum number of IO space PIDs */
137
138 #endif /* _PPC_PARAM_H_ */