1280364Sandrew/*-
2280364Sandrew * Copyright (c) 1990 The Regents of the University of California.
3280364Sandrew * All rights reserved.
4280364Sandrew *
5280364Sandrew * This code is derived from software contributed to Berkeley by
6280364Sandrew * William Jolitz.
7280364Sandrew *
8280364Sandrew * Redistribution and use in source and binary forms, with or without
9280364Sandrew * modification, are permitted provided that the following conditions
10280364Sandrew * are met:
11280364Sandrew * 1. Redistributions of source code must retain the above copyright
12280364Sandrew *    notice, this list of conditions and the following disclaimer.
13280364Sandrew * 2. Redistributions in binary form must reproduce the above copyright
14280364Sandrew *    notice, this list of conditions and the following disclaimer in the
15280364Sandrew *    documentation and/or other materials provided with the distribution.
16280364Sandrew *
17280364Sandrew * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18280364Sandrew * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19280364Sandrew * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20280364Sandrew * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21280364Sandrew * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22280364Sandrew * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23280364Sandrew * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24280364Sandrew * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25280364Sandrew * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26280364Sandrew * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27280364Sandrew * SUCH DAMAGE.
28280364Sandrew *
29280364Sandrew *	from: @(#)param.h	5.8 (Berkeley) 6/28/91
30280364Sandrew * $FreeBSD$
31280364Sandrew */
32280364Sandrew
33280364Sandrew#ifndef _MACHINE_PARAM_H_
34280364Sandrew#define	_MACHINE_PARAM_H_
35280364Sandrew
36280364Sandrew/*
37280364Sandrew * Machine dependent constants for arm64.
38280364Sandrew */
39280364Sandrew
40280364Sandrew#include <machine/_align.h>
41280364Sandrew
42280364Sandrew#define	STACKALIGNBYTES	(16 - 1)
43280364Sandrew#define	STACKALIGN(p)	((uint64_t)(p) & ~STACKALIGNBYTES)
44280364Sandrew
45296315Sbz#define	__PCI_REROUTE_INTERRUPT
46296315Sbz
47280364Sandrew#ifndef MACHINE
48280364Sandrew#define	MACHINE		"arm64"
49280364Sandrew#endif
50280364Sandrew#ifndef MACHINE_ARCH
51280364Sandrew#define	MACHINE_ARCH	"aarch64"
52280364Sandrew#endif
53280364Sandrew
54280364Sandrew#if defined(SMP) || defined(KLD_MODULE)
55280364Sandrew#ifndef MAXCPU
56286922Szbb#define	MAXCPU		96
57280364Sandrew#endif
58280364Sandrew#else
59280364Sandrew#define	MAXCPU		1
60280364Sandrew#endif /* SMP || KLD_MODULE */
61280364Sandrew
62280364Sandrew#ifndef MAXMEMDOM
63280364Sandrew#define	MAXMEMDOM	1
64280364Sandrew#endif
65280364Sandrew
66280364Sandrew#define	ALIGNBYTES	_ALIGNBYTES
67280364Sandrew#define	ALIGN(p)	_ALIGN(p)
68280364Sandrew/*
69280364Sandrew * ALIGNED_POINTER is a boolean macro that checks whether an address
70280364Sandrew * is valid to fetch data elements of type t from on this architecture.
71280364Sandrew * This does not reflect the optimal alignment, just the possibility
72280364Sandrew * (within reasonable limits).
73280364Sandrew */
74280364Sandrew#define	ALIGNED_POINTER(p, t)	((((u_long)(p)) & (sizeof(t) - 1)) == 0)
75280364Sandrew
76280364Sandrew/*
77280364Sandrew * CACHE_LINE_SIZE is the compile-time maximum cache line size for an
78280364Sandrew * architecture.  It should be used with appropriate caution.
79280364Sandrew */
80280364Sandrew#define	CACHE_LINE_SHIFT	6
81280364Sandrew#define	CACHE_LINE_SIZE		(1 << CACHE_LINE_SHIFT)
82280364Sandrew
83280364Sandrew#define	PAGE_SHIFT	12
84280364Sandrew#define	PAGE_SIZE	(1 << PAGE_SHIFT)	/* Page size */
85280364Sandrew#define	PAGE_MASK	(PAGE_SIZE - 1)
86280364Sandrew
87285213Szbb#define	PAGE_SHIFT_16K	14
88285213Szbb#define	PAGE_SIZE_16K	(1 << PAGE_SHIFT_16K)
89285213Szbb#define	PAGE_MASK_16K	(PAGE_SIZE_16K - 1)
90285213Szbb
91280364Sandrew#define	PAGE_SHIFT_64K	16
92280364Sandrew#define	PAGE_SIZE_64K	(1 << PAGE_SHIFT_64K)
93280364Sandrew#define	PAGE_MASK_64K	(PAGE_SIZE_64K - 1)
94280364Sandrew
95280364Sandrew#define	MAXPAGESIZES	1		/* maximum number of supported page sizes */
96280364Sandrew
97280364Sandrew#ifndef KSTACK_PAGES
98280364Sandrew#define	KSTACK_PAGES	4	/* pages of kernel stack (with pcb) */
99280364Sandrew#endif
100280364Sandrew
101280364Sandrew#define	KSTACK_GUARD_PAGES	1	/* pages of kstack guard; 0 disables */
102280364Sandrew#define	PCPU_PAGES		1
103280364Sandrew
104280364Sandrew/*
105280364Sandrew * Ceiling on size of buffer cache (really only effects write queueing,
106280364Sandrew * the VM page cache is not effected), can be changed via
107280364Sandrew * the kern.maxbcache /boot/loader.conf variable.
108280364Sandrew */
109280364Sandrew#ifndef VM_BCACHE_SIZE_MAX
110280364Sandrew#define	VM_BCACHE_SIZE_MAX      (400 * 1024 * 1024)
111280364Sandrew#endif
112280364Sandrew
113280364Sandrew/*
114280364Sandrew * Mach derived conversion macros
115280364Sandrew */
116280364Sandrew#define	round_page(x)		(((unsigned long)(x) + PAGE_MASK) & ~PAGE_MASK)
117280364Sandrew#define	trunc_page(x)		((unsigned long)(x) & ~PAGE_MASK)
118280364Sandrew
119280364Sandrew#define	atop(x)			((unsigned long)(x) >> PAGE_SHIFT)
120280364Sandrew#define	ptoa(x)			((unsigned long)(x) << PAGE_SHIFT)
121280364Sandrew
122280364Sandrew#define	arm64_btop(x)		((unsigned long)(x) >> PAGE_SHIFT)
123280364Sandrew#define	arm64_ptob(x)		((unsigned long)(x) << PAGE_SHIFT)
124280364Sandrew
125280364Sandrew#define	pgtok(x)		((unsigned long)(x) * (PAGE_SIZE / 1024))
126280364Sandrew
127280364Sandrew#endif /* !_MACHINE_PARAM_H_ */
128