xref: /freebsd/sys/arm64/include/param.h (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
1 /*-
2  * Copyright (c) 1990 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * This code is derived from software contributed to Berkeley by
6  * William Jolitz.
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  *
17  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  */
29 
30 #ifdef __arm__
31 #include <arm/param.h>
32 #else /* !__arm__ */
33 
34 #ifndef _MACHINE_PARAM_H_
35 #define	_MACHINE_PARAM_H_
36 
37 /*
38  * Machine dependent constants for arm64.
39  */
40 
41 #include <machine/_align.h>
42 
43 #define	STACKALIGNBYTES	(16 - 1)
44 #define	STACKALIGN(p)	((uint64_t)(p) & ~STACKALIGNBYTES)
45 
46 #define	__PCI_REROUTE_INTERRUPT
47 
48 #ifndef MACHINE
49 #define	MACHINE		"arm64"
50 #endif
51 #ifndef MACHINE_ARCH
52 #define	MACHINE_ARCH	"aarch64"
53 #endif
54 #ifndef MACHINE_ARCH32
55 #define	MACHINE_ARCH32	"armv7"
56 #endif
57 
58 #ifdef SMP
59 #ifndef MAXCPU
60 #define	MAXCPU		1024
61 #endif
62 #else
63 #define	MAXCPU		1
64 #endif
65 
66 #ifndef MAXMEMDOM
67 #define	MAXMEMDOM	8
68 #endif
69 
70 #define	ALIGNBYTES	_ALIGNBYTES
71 #define	ALIGN(p)	_ALIGN(p)
72 /*
73  * ALIGNED_POINTER is a boolean macro that checks whether an address
74  * is valid to fetch data elements of type t from on this architecture.
75  * This does not reflect the optimal alignment, just the possibility
76  * (within reasonable limits).
77  */
78 #define	ALIGNED_POINTER(p, t)	((((u_long)(p)) & (sizeof(t) - 1)) == 0)
79 
80 /*
81  * CACHE_LINE_SIZE is the compile-time maximum cache line size for an
82  * architecture.  It should be used with appropriate caution.
83  */
84 #define	CACHE_LINE_SHIFT	7
85 #define	CACHE_LINE_SIZE		(1 << CACHE_LINE_SHIFT)
86 
87 #define	PAGE_SHIFT_4K	12
88 #define	PAGE_SIZE_4K	(1 << PAGE_SHIFT_4K)
89 
90 #define	PAGE_SHIFT_16K	14
91 #define	PAGE_SIZE_16K	(1 << PAGE_SHIFT_16K)
92 
93 #define	PAGE_SHIFT_64K	16
94 #define	PAGE_SIZE_64K	(1 << PAGE_SHIFT_64K)
95 
96 #define	PAGE_SHIFT	PAGE_SHIFT_4K
97 #define	PAGE_SIZE	(1 << PAGE_SHIFT)
98 #define	PAGE_MASK	(PAGE_SIZE - 1)
99 
100 #define	MAXPAGESIZES	4		/* maximum number of supported page sizes */
101 
102 #ifndef KSTACK_PAGES
103 #if defined(KASAN) || defined(KMSAN)
104 #define	KSTACK_PAGES	6
105 #else
106 #define	KSTACK_PAGES	4	/* pages of kernel stack (with pcb) */
107 #endif
108 #endif
109 
110 #define	KSTACK_GUARD_PAGES	1	/* pages of kstack guard; 0 disables */
111 #define	PCPU_PAGES		1
112 
113 #ifdef PERTHREAD_SSP
114 #define	NO_PERTHREAD_SSP	__nostackprotector
115 #else
116 #define	NO_PERTHREAD_SSP
117 #endif
118 
119 /*
120  * Mach derived conversion macros
121  */
122 #define	round_page(x)		(((unsigned long)(x) + PAGE_MASK) & ~PAGE_MASK)
123 #define	trunc_page(x)		((unsigned long)(x) & ~PAGE_MASK)
124 
125 #define	atop(x)			((unsigned long)(x) >> PAGE_SHIFT)
126 #define	ptoa(x)			((unsigned long)(x) << PAGE_SHIFT)
127 
128 #define	arm64_btop(x)		((unsigned long)(x) >> PAGE_SHIFT)
129 #define	arm64_ptob(x)		((unsigned long)(x) << PAGE_SHIFT)
130 
131 #define	pgtok(x)		((unsigned long)(x) * (PAGE_SIZE / 1024))
132 
133 #endif /* !_MACHINE_PARAM_H_ */
134 
135 #endif /* !__arm__ */
136