xref: /openbsd/sys/arch/arm/include/param.h (revision 569905a9)
1 /*	$OpenBSD: param.h,v 1.25 2023/12/14 13:26:49 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 /* Constants used to divide the USPACE area */
61 /*
62  * The USPACE area contains :
63  * 1. the user structure for the process
64  * 2. the fp context for FP emulation
65  * 3. the kernel (svc) stack
66  * 4. the undefined instruction stack
67  *
68  * The layout of the area looks like this
69  *
70  * | user area | FP context | undefined stack | kernel stack |
71  *
72  * The size of the user area is known.
73  * The size of the FP context is variable depending of the FP emulator
74  * in use and whether there is hardware FP support. However we can put
75  * an upper limit on it.
76  * The undefined stack needs to be at least 512 bytes. This is a requirement
77  * of the FP emulators
78  * The kernel stack should be at least 4K in size.
79  *
80  * The stack top addresses are used to set the stack pointers. The stack bottom
81  * addresses are the addresses monitored by the diagnostic code for stack
82  * overflows.
83  */
84 
85 #define	FPCONTEXTSIZE			(0x100)
86 #define	USPACE_SVC_STACK_TOP		(USPACE)
87 #define	USPACE_SVC_STACK_BOTTOM		(USPACE_SVC_STACK_TOP - 0x1000)
88 #define	USPACE_UNDEF_STACK_TOP		(USPACE_SVC_STACK_BOTTOM - 0x10)
89 #define	USPACE_UNDEF_STACK_BOTTOM	(sizeof(struct user) + FPCONTEXTSIZE + 10)
90 
91 #ifndef _LOCORE
92 void	delay (unsigned);
93 #define	DELAY(x)	delay(x)
94 #endif
95 
96 #if !defined(_LOCORE)
97 #include <machine/cpu.h>
98 #endif
99 
100 /* ARM-specific macro to align a stack pointer (downwards). */
101 #define	STACKALIGNBYTES		(8 - 1)
102 #define	STACKALIGN(p)		((u_long)(p) &~ STACKALIGNBYTES)
103 
104 #endif /* _KERNEL */
105 
106 #endif /* _ARM_PARAM_H_ */
107