xref: /openbsd-src/sys/arch/powerpc/include/param.h (revision 8500990981f885cbe5e6a4958549cacc238b5ae6)
1 /*	$OpenBSD: param.h,v 1.22 2002/11/21 03:59:16 drahn Exp $	*/
2 /*	$NetBSD: param.h,v 1.1 1996/09/30 16:34:28 ws Exp $	*/
3 
4 /*-
5  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
6  * Copyright (C) 1995, 1996 TooLs GmbH.
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  * 3. All advertising materials mentioning features or use of this software
18  *    must display the following acknowledgement:
19  *	This product includes software developed by TooLs GmbH.
20  * 4. The name of TooLs GmbH may not be used to endorse or promote products
21  *    derived from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
24  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26  * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
29  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
31  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
32  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  */
34 
35 #ifndef	_POWERPC_PARAM_H_
36 #define	_POWERPC_PARAM_H_
37 
38 #ifdef	_KERNEL
39 #ifndef	_LOCORE
40 #include <machine/cpu.h>
41 #endif	/* _LOCORE */
42 #endif
43 
44 /*
45  * Machine dependent constants for PowerPC (32-bit only currently)
46  */
47 #define	MACHINE_ARCH	"powerpc"
48 #define	_MACHINE_ARCH	powerpc
49 
50 #define	MID_MACHINE	MID_POWERPC
51 
52 #define	ALIGNBYTES	(sizeof(double) - 1)
53 #define	ALIGN(p)	(((u_int)(p) + ALIGNBYTES) & ~ALIGNBYTES)
54 #define ALIGNED_POINTER(p,t)	((((u_long)(p)) & (sizeof(t)-1)) == 0)
55 
56 #define	PAGE_SHIFT	12
57 #define	PAGE_SIZE	4096
58 #define	PAGE_MASK	(PAGE_SIZE - 1)
59 #define	PGSHIFT		PAGE_SHIFT
60 #define	NBPG		PAGE_SIZE
61 #define	PGOFSET		PAGE_MASK
62 
63 #define	DEV_BSHIFT	9		/* log2(DEV_BSIZE) */
64 #define	DEV_BSIZE	(1 << DEV_BSHIFT)
65 #define	BLKDEV_IOSIZE	NBPG
66 #define	MAXPHYS		(64 * 1024)	/* max raw I/O transfer size */
67 
68 #define	UPAGES		4
69 #define	USPACE		(UPAGES * NBPG)
70 
71 /*
72  * Constants related to network buffer management.
73  * MCLBYTES must be no larger than the software page size, and,
74  * on machines that exchange pages of input or output buffers with mbuf
75  * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
76  * of the hardware page size.
77  */
78 #define	MSIZE		256		/* size of an mbuf */
79 #define	MCLSHIFT	11		/* convert bytes to m_buf clusters */
80 #define	MCLBYTES	(1 << MCLSHIFT)	/* size of a m_buf cluster */
81 #define	MCLOFSET	(MCLBYTES - 1)
82 
83 #ifndef NMBCLUSTERS
84 #ifdef GATEWAY
85 #define	NMBCLUSTERS	2048		/* map size, max cluster allocation */
86 #else
87 #define	NMBCLUSTERS	1024		/* map size, max cluster allocation */
88 #endif
89 #endif
90 
91 /*
92  * pages ("clicks") to disk blocks
93  */
94 #define	ctod(x)		((x) << (PGSHIFT - DEV_BSHIFT))
95 #define	dtoc(x)		((x) >> (PGSHIFT - DEV_BSHIFT))
96 /*
97  * bytes to pages
98  */
99 #define	ctob(x)		((x) << PGSHIFT)
100 #define	btoc(x)		(((x) + PGOFSET) >> PGSHIFT)
101 
102 /*
103  * bytes to disk blocks
104  */
105 #define	dbtob(x)	((x) << DEV_BSHIFT)
106 #define	btodb(x)	((x) >> DEV_BSHIFT)
107 
108 /*
109  * Mach derived conversion macros
110  */
111 #define powerpc_btop(x)	((unsigned)(x) >> PGSHIFT)
112 #define powerpc_ptob(x)	((unsigned)(x) << PGSHIFT)
113 
114 /*
115  * Segment handling stuff
116  */
117 #define	SEGMENT_LENGTH	0x10000000
118 #define	SEGMENT_MASK	0xf0000000
119 
120 /*
121  * Fixed segments
122  */
123 #define	USER_SR		13
124 #define	KERNEL_SR	14
125 #define	KERNEL_SEG0	0xfffff0
126 #define	KERNEL_SEGMENT	(KERNEL_SEG0 + KERNEL_SR)
127 #define	USER_ADDR	((void *)(USER_SR << ADDR_SR_SHIFT))
128 
129 /*
130  * Some system constants
131  */
132 #ifndef	NPMAPS
133 #define	NPMAPS		32768	/* Number of pmaps in system */
134 #endif
135 
136 /*
137  * Temporary kludge till we do (ov)bcopy in assembler
138  */
139 #define	ovbcopy	bcopy
140 
141 #endif	/* _POWERPC_PARAM_H_ */
142