xref: /openbsd-src/sys/arch/arm/include/param.h (revision d13be5d47e4149db2549a9828e244d59dbc43f15)
1 /*	$OpenBSD: param.h,v 1.16 2011/09/08 03:40:32 guenther Exp $	*/
2 /*	$NetBSD: param.h,v 1.9 2002/03/24 03:37:23 thorpej Exp $	*/
3 
4 /*
5  * Copyright (c) 1994,1995 Mark Brinicombe.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  * 3. All advertising materials mentioning features or use of this software
17  *    must display the following acknowledgement:
18  *	This product includes software developed by the RiscBSD team.
19  * 4. The name "RiscBSD" nor the name of the author may be used to
20  *    endorse or promote products derived from this software without specific
21  *    prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY RISCBSD ``AS IS'' AND ANY EXPRESS OR IMPLIED
24  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26  * IN NO EVENT SHALL RISCBSD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
27  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33  * SUCH DAMAGE.
34  */
35 
36 #ifndef	_ARM_PARAM_H_
37 #define	_ARM_PARAM_H_
38 
39 #define MACHINE_ARCH	"arm"
40 #define _MACHINE_ARCH	arm
41 
42 /*
43  * Machine dependent constants for ARM6+ processors
44  */
45 /* These are defined in the Port File before it includes
46  * this file. */
47 
48 #define	PAGE_SHIFT	12		/* LOG2(NBPG) */
49 #define	PGSHIFT		12		/* LOG2(NBPG) */
50 #define	PAGE_SIZE	(1 << PAGE_SHIFT)	/* bytes/page */
51 #define	NBPG		(1 << PAGE_SHIFT)	/* bytes/page */
52 #define	PAGE_MASK	(PAGE_SIZE - 1)
53 #define PGOFSET		(PAGE_SIZE - 1)
54 #define	NPTEPG		(PAGE_SIZE/(sizeof (pt_entry_t)))
55 
56 #define UPAGES          2               /* pages of u-area */
57 #define USPACE          (UPAGES * PAGE_SIZE) /* total size of u-area */
58 #define	USPACE_ALIGN	(0)		/* u-area alignment 0-none */
59 
60 #ifndef MSGBUFSIZE
61 #define MSGBUFSIZE	PAGE_SIZE	/* default message buffer size */
62 #endif
63 
64 /*
65  * Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized
66  * logical pages.
67  */
68 #define	NKMEMPAGES_MIN_DEFAULT	((4 * 1024 * 1024) >> PAGE_SHIFT)
69 #define	NKMEMPAGES_MAX_DEFAULT	((64 * 1024 * 1024) >> PAGE_SHIFT)
70 
71 /* Constants used to divide the USPACE area */
72 
73 /*
74  * The USPACE area contains :
75  * 1. the user structure for the process
76  * 2. the fp context for FP emulation
77  * 3. the kernel (svc) stack
78  * 4. the undefined instruction stack
79  *
80  * The layout of the area looks like this
81  *
82  * | user area | FP context | undefined stack | kernel stack |
83  *
84  * The size of the user area is known.
85  * The size of the FP context is variable depending of the FP emulator
86  * in use and whether there is hardware FP support. However we can put
87  * an upper limit on it.
88  * The undefined stack needs to be at least 512 bytes. This is a requirement
89  * if the FP emulators
90  * The kernel stack should be at least 4K is size.
91  *
92  * The stack top addresses are used to set the stack pointers. The stack bottom
93  * addresses at the addresses monitored by the diagnostic code for stack overflows
94  *
95  */
96 
97 #define FPCONTEXTSIZE			(0x100)
98 #define USPACE_SVC_STACK_TOP		(USPACE)
99 #define USPACE_SVC_STACK_BOTTOM		(USPACE_SVC_STACK_TOP - 0x1000)
100 #define	USPACE_UNDEF_STACK_TOP		(USPACE_SVC_STACK_BOTTOM - 0x10)
101 #define USPACE_UNDEF_STACK_BOTTOM	(sizeof(struct user) + FPCONTEXTSIZE + 10)
102 
103 #ifdef _KERNEL
104 #ifndef _LOCORE
105 void	delay (unsigned);
106 #define DELAY(x)	delay(x)
107 #endif
108 #endif
109 
110 /*
111  * Machine dependent constants for all ARM processors
112  */
113 
114 /*
115  * For KERNEL code:
116  *	MACHINE must be defined by the individual port.  This is so that
117  *	uname returns the correct thing, etc.
118  *
119  *	MACHINE_ARCH may be defined by individual ports as a temporary
120  *	measure while we're finishing the conversion to ELF.
121  *
122  * For non-KERNEL code:
123  *	If ELF, MACHINE and MACHINE_ARCH are forced to "arm/armeb".
124  */
125 
126 
127 #define	MID_MACHINE	MID_ARM6
128 
129 #define	ALIGNBYTES		_ALIGNBYTES
130 #define	ALIGN(p)		_ALIGN(p)
131 #define	ALIGNED_POINTER(p,t)	_ALIGNED_POINTER(p,t)
132 
133 /* ARM-specific macro to align a stack pointer (downwards). */
134 #define STACKALIGNBYTES		(8 - 1)
135 #define STACKALIGN(p)		((u_long)(p) &~ STACKALIGNBYTES)
136 
137 #define	DEV_BSHIFT	9		/* log2(DEV_BSIZE) */
138 #define	DEV_BSIZE	(1 << DEV_BSHIFT)
139 #define	BLKDEV_IOSIZE	2048
140 
141 #ifndef MAXPHYS
142 #define	MAXPHYS		(64 * 1024)		/* max I/O transfer size */
143 #endif
144 
145 /* pages ("clicks") to disk blocks */
146 #define	ctod(x)	((x) << (PAGE_SHIFT - DEV_BSHIFT))
147 #define	dtoc(x)	((x) >> (PAGE_SHIFT - DEV_BSHIFT))
148 
149 #define	btodb(bytes)	 		/* calculates (bytes / DEV_BSIZE) */ \
150 	((bytes) >> DEV_BSHIFT)
151 #define	dbtob(db)			/* calculates (db * DEV_BSIZE) */ \
152 	((db) << DEV_BSHIFT)
153 
154 /*
155  * Constants related to network buffer management.
156  */
157 #define	NMBCLUSTERS	4096		/* map size, max cluster allocation */
158 
159 #define ovbcopy bcopy
160 
161 #if defined(_KERNEL) && !defined(_LOCORE)
162 #include <sys/param.h>
163 #include <machine/cpu.h>
164 #endif
165 
166 #endif	/* _ARM_PARAM_H_ */
167