xref: /openbsd-src/sys/arch/arm/include/param.h (revision f6aab3d83b51b91c24247ad2c2573574de475a82)
1 /*	$OpenBSD: param.h,v 1.24 2018/09/14 13:58:20 claudio Exp $	*/
2 
3 /*
4  * Copyright (c) 1994,1995 Mark Brinicombe.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. All advertising materials mentioning features or use of this software
16  *    must display the following acknowledgement:
17  *	This product includes software developed by the RiscBSD team.
18  * 4. The name "RiscBSD" nor the name of the author may be used to
19  *    endorse or promote products derived from this software without specific
20  *    prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY RISCBSD ``AS IS'' AND ANY EXPRESS OR IMPLIED
23  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25  * IN NO EVENT SHALL RISCBSD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
26  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32  * SUCH DAMAGE.
33  */
34 
35 #ifndef	_ARM_PARAM_H_
36 #define	_ARM_PARAM_H_
37 
38 #define	MACHINE_ARCH	"arm"
39 #define	_MACHINE_ARCH	arm
40 #define	MID_MACHINE	MID_ARM6
41 
42 #define	PAGE_SHIFT	12
43 #define	PAGE_SIZE	(1 << PAGE_SHIFT)
44 #define	PAGE_MASK	(PAGE_SIZE - 1)
45 
46 #ifdef _KERNEL
47 
48 #define	NPTEPG		(PAGE_SIZE/(sizeof (pt_entry_t)))
49 
50 #define	NBPG		PAGE_SIZE
51 #define	PGSHIFT		PAGE_SHIFT
52 #define	PGOFSET		PAGE_MASK
53 
54 #define	UPAGES		2			/* pages of u-area */
55 #define	USPACE		(UPAGES * PAGE_SIZE)	/* total size of u-area */
56 #define	USPACE_ALIGN	0			/* u-area alignment 0-none */
57 
58 #define	NMBCLUSTERS	(32 * 1024)		/* max cluster allocation */
59 
60 /*
61  * Maximum size of the kernel malloc arena in PAGE_SIZE-sized
62  * logical pages.
63  */
64 #define	NKMEMPAGES_MAX_DEFAULT	((64 * 1024 * 1024) >> PAGE_SHIFT)
65 
66 /* Constants used to divide the USPACE area */
67 /*
68  * The USPACE area contains :
69  * 1. the user structure for the process
70  * 2. the fp context for FP emulation
71  * 3. the kernel (svc) stack
72  * 4. the undefined instruction stack
73  *
74  * The layout of the area looks like this
75  *
76  * | user area | FP context | undefined stack | kernel stack |
77  *
78  * The size of the user area is known.
79  * The size of the FP context is variable depending of the FP emulator
80  * in use and whether there is hardware FP support. However we can put
81  * an upper limit on it.
82  * The undefined stack needs to be at least 512 bytes. This is a requirement
83  * of the FP emulators
84  * The kernel stack should be at least 4K in size.
85  *
86  * The stack top addresses are used to set the stack pointers. The stack bottom
87  * addresses are the addresses monitored by the diagnostic code for stack
88  * overflows.
89  */
90 
91 #define	FPCONTEXTSIZE			(0x100)
92 #define	USPACE_SVC_STACK_TOP		(USPACE)
93 #define	USPACE_SVC_STACK_BOTTOM		(USPACE_SVC_STACK_TOP - 0x1000)
94 #define	USPACE_UNDEF_STACK_TOP		(USPACE_SVC_STACK_BOTTOM - 0x10)
95 #define	USPACE_UNDEF_STACK_BOTTOM	(sizeof(struct user) + FPCONTEXTSIZE + 10)
96 
97 #ifndef _LOCORE
98 void	delay (unsigned);
99 #define	DELAY(x)	delay(x)
100 #endif
101 
102 #if !defined(_LOCORE)
103 #include <machine/cpu.h>
104 #endif
105 
106 /* ARM-specific macro to align a stack pointer (downwards). */
107 #define	STACKALIGNBYTES		(8 - 1)
108 #define	STACKALIGN(p)		((u_long)(p) &~ STACKALIGNBYTES)
109 
110 #endif /* _KERNEL */
111 
112 #endif /* _ARM_PARAM_H_ */
113