xref: /openbsd-src/sys/arch/powerpc/include/param.h (revision a28daedfc357b214be5c701aa8ba8adb29a7f1c2)
1 /*	$OpenBSD: param.h,v 1.30 2007/11/04 13:43:39 martin 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	2048
66 #define	MAXPHYS		(64 * 1024)	/* max raw I/O transfer size */
67 
68 #define	UPAGES		4
69 #define	USPACE		(UPAGES * NBPG)
70 #define	USPACE_ALIGN	(0)		/* u-area alignment 0-none */
71 
72 /*
73  * Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized
74  * logical pages.
75  */
76 #define	NKMEMPAGES_MIN_DEFAULT	((4 * 1024 * 1024) >> PAGE_SHIFT)
77 #define	NKMEMPAGES_MAX_DEFAULT	((64 * 1024 * 1024) >> PAGE_SHIFT)
78 
79 /*
80  * Constants related to network buffer management.
81  */
82 #define	NMBCLUSTERS	4096		/* map size, max cluster allocation */
83 
84 /*
85  * pages ("clicks") to disk blocks
86  */
87 #define	ctod(x)		((x) << (PGSHIFT - DEV_BSHIFT))
88 #define	dtoc(x)		((x) >> (PGSHIFT - DEV_BSHIFT))
89 
90 /*
91  * bytes to disk blocks
92  */
93 #define	dbtob(x)	((x) << DEV_BSHIFT)
94 #define	btodb(x)	((x) >> DEV_BSHIFT)
95 
96 /*
97  * Segment handling stuff
98  */
99 #define	PPC_SEGMENT_LENGTH	0x10000000
100 #define	PPC_SEGMENT_MASK	0xf0000000
101 
102 /*
103  * Fixed segments
104  */
105 #define	PPC_USER_SR		13
106 #define	PPC_KERNEL_SR	14
107 #define	PPC_KERNEL_SEG0	0xfffff0
108 #define	PPC_KERNEL_SEGMENT	(PPC_KERNEL_SEG0 + PPC_KERNEL_SR)
109 #define	PPC_USER_ADDR	((void *)(PPC_USER_SR << ADDR_SR_SHIFT))
110 
111 /*
112  * Some system constants
113  */
114 #ifndef	NPMAPS
115 #define	NPMAPS		32768	/* Number of pmaps in system */
116 #endif
117 
118 /*
119  * Temporary kludge till we do (ov)bcopy in assembler
120  */
121 #define	ovbcopy	bcopy
122 
123 #endif	/* _POWERPC_PARAM_H_ */
124