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