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