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