xref: /openbsd-src/sys/arch/powerpc/include/param.h (revision b2ea75c1b17e1a9a339660e7ed45cd24946b230e)
1 /*	$OpenBSD: param.h,v 1.17 2001/07/09 02:14:05 mickey 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 #ifdef	_KERNEL
36 #ifndef	_LOCORE
37 #include <machine/cpu.h>
38 #endif	/* _LOCORE */
39 #endif
40 
41 
42 /*
43  * Machine dependent constants for PowerPC (32-bit only currently)
44  */
45 #define	MACHINE		"powerpc"
46 #define	_MACHINE	powerpc
47 #define	MACHINE_ARCH	"powerpc"
48 #define	_MACHINE_ARCH	powerpc
49 
50 #define	MID_MACHINE	0	/* None but has to be defined */
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	PGSHIFT		12
57 #define	NBPG		4096
58 #define	PGOFSET		(NBPG - 1)
59 #define PAGE_SIZE	NBPG
60 #define PAGE_MASK	PGOFSET
61 #define PAGE_SHIFT	PGSHIFT
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 #define	KERNBASE	0x100000
72 
73 /*
74  * Constants related to network buffer management.
75  * MCLBYTES must be no larger than the software page size, and,
76  * on machines that exchange pages of input or output buffers with mbuf
77  * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
78  * of the hardware page size.
79  */
80 #define	MSIZE		256		/* size of an mbuf */
81 #define	MCLSHIFT	11		/* convert bytes to m_buf clusters */
82 #define	MCLBYTES	(1 << MCLSHIFT)	/* size of a m_buf cluster */
83 #define	MCLOFSET	(MCLBYTES - 1)
84 
85 #ifndef NMBCLUSTERS
86 #ifdef GATEWAY
87 #define	NMBCLUSTERS	2048		/* map size, max cluster allocation */
88 #else
89 #define	NMBCLUSTERS	1024		/* map size, max cluster allocation */
90 #endif
91 #endif
92 
93 #define MSGBUFSIZE	(NBPG*2)
94 
95 /*
96  * Size of kernel malloc arena in logical pages.
97  */
98 #ifndef	NKMEMCLUSTERS
99 #define	NKMEMCLUSTERS	(16 * 1024 * 1024 / PAGE_SIZE)
100 #endif
101 
102 /*
103  * pages ("clicks") to disk blocks
104  */
105 #define	ctod(x)		((x) << (PGSHIFT - DEV_BSHIFT))
106 #define	dtoc(x)		((x) >> (PGSHIFT - DEV_BSHIFT))
107 /*
108  * bytes to pages
109  */
110 #define	ctob(x)		((x) << PGSHIFT)
111 #define	btoc(x)		(((x) + PGOFSET) >> PGSHIFT)
112 
113 /*
114  * bytes to disk blocks
115  */
116 #define	dbtob(x)	((x) << DEV_BSHIFT)
117 #define	btodb(x)	((x) >> DEV_BSHIFT)
118 
119 /*
120  * Mach derived conversion macros
121  */
122 #define powerpc_btop(x)	((unsigned)(x) >> PGSHIFT)
123 #define powerpc_ptob(x)	((unsigned)(x) << PGSHIFT)
124 
125 /*
126  * Segment handling stuff
127  */
128 #define	SEGMENT_LENGTH	0x10000000
129 #define	SEGMENT_MASK	0xf0000000
130 
131 /*
132  * Fixed segments
133  */
134 #define	USER_SR		13
135 #define	KERNEL_SR	14
136 #define	KERNEL_SEGMENT	(0xfffff0 + KERNEL_SR)
137 #define	EMPTY_SEGMENT	0xfffff0
138 #define	USER_ADDR	((void *)(USER_SR << ADDR_SR_SHFT))
139 
140 #define	__COMPAT_OLD_TIMEOUTS
141 
142 /*
143  * Some system constants
144  */
145 #ifndef	NPMAPS
146 #define	NPMAPS		32768	/* Number of pmaps in system */
147 #endif
148 
149 /*
150  * Temporary kludge till we do (ov)bcopy in assembler
151  */
152 #define	ovbcopy	bcopy
153