param.h revision 1.13 1 /* $NetBSD: param.h,v 1.13 2019/11/24 04:08:36 rin Exp $ */
2
3 /*-
4 * Copyright (c) 2014 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Matt Thomas of 3am Software Foundry.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 #ifndef _AARCH64_PARAM_H_
33 #define _AARCH64_PARAM_H_
34
35 #ifdef __aarch64__
36
37 #ifdef _KERNEL_OPT
38 #include "opt_cputypes.h"
39 #endif
40
41 /*
42 * Machine dependent constants for all ARM processors
43 */
44
45 /*
46 * For KERNEL code:
47 * MACHINE must be defined by the individual port. This is so that
48 * uname returns the correct thing, etc.
49 *
50 * MACHINE_ARCH may be defined by individual ports as a temporary
51 * measure while we're finishing the conversion to ELF.
52 *
53 * For non-KERNEL code:
54 * If ELF, MACHINE and MACHINE_ARCH are forced to "arm/armeb".
55 */
56
57 #if defined(_KERNEL)
58 # ifndef MACHINE_ARCH /* XXX For now */
59 # ifdef __AARCH64EB__
60 # define _MACHINE_ARCH aarch64eb
61 # define MACHINE_ARCH "aarch64eb"
62 # define _MACHINE32_ARCH earmv7hfeb
63 # define MACHINE32_ARCH "earmv7hfeb"
64 # else
65 # define _MACHINE_ARCH aarch64
66 # define MACHINE_ARCH "aarch64"
67 # define _MACHINE32_ARCH earmv7hf
68 # define MACHINE32_ARCH "earmv7hf"
69 # endif /* __AARCH64EB__ */
70 # endif /* MACHINE_ARCH */
71 #else
72 # undef _MACHINE
73 # undef MACHINE
74 # undef _MACHINE_ARCH
75 # undef MACHINE_ARCH
76 # undef _MACHINE32_ARCH
77 # undef MACHINE32_ARCH
78 # define _MACHINE aarch64
79 # define MACHINE "aarch64"
80 # ifdef __AARCH64EB__
81 # define _MACHINE_ARCH aarch64eb
82 # define MACHINE_ARCH "aarch64eb"
83 # define _MACHINE32_ARCH earmv7hfeb
84 # define MACHINE32_ARCH "earmv7hfeb"
85 # else
86 # define _MACHINE_ARCH aarch64
87 # define MACHINE_ARCH "aarch64"
88 # define _MACHINE32_ARCH earmv7hf
89 # define MACHINE32_ARCH "earmv7hf"
90 # endif /* __AARCH64EB__ */
91 #endif /* !_KERNEL */
92
93 #define MID_MACHINE MID_AARCH64
94
95 /* AARCH64-specific macro to align a stack pointer (downwards). */
96 #define STACK_ALIGNBYTES (16 - 1)
97
98 #define ALIGNBYTES32 (8 - 1)
99 #define ALIGN32(p) \
100 (((uintptr_t)(p) + ALIGNBYTES32) & ~ALIGNBYTES32)
101
102 #define NKMEMPAGES_MIN_DEFAULT ((128UL * 1024 * 1024) >> PAGE_SHIFT)
103 #define NKMEMPAGES_MAX_UNLIMITED 1
104
105 #ifdef AARCH64_PAGE_SHIFT
106 #if (1 << AARCH64_PAGE_SHIFT) & ~0x141000
107 #error AARCH64_PAGE_SHIFT contains an unsupported value.
108 #endif
109 #define PGSHIFT AARCH64_PAGE_SHIFT
110 #else
111 #define PGSHIFT 12
112 #endif
113 #define NBPG (1 << PGSHIFT)
114 #define PGOFSET (NBPG - 1)
115
116 /*
117 * Constants related to network buffer management.
118 * MCLBYTES must be no larger than NBPG (the software page size), and
119 * NBPG % MCLBYTES must be zero.
120 */
121 #if PGSHIFT > 12
122 #define MSIZE 256 /* size of an mbuf */
123 #else
124 #define MSIZE 512 /* size of an mbuf */
125 #endif
126
127 #ifndef MCLSHIFT
128 #define MCLSHIFT 11 /* convert bytes to m_buf clusters */
129 /* 2K cluster can hold Ether frame */
130 #endif /* MCLSHIFT */
131
132 #define MCLBYTES (1 << MCLSHIFT) /* size of a m_buf cluster */
133
134
135 #ifndef MSGBUFSIZE
136 #define MSGBUFSIZE 65536 /* default message buffer size */
137 #endif
138
139 #define COHERENCY_UNIT 128
140 #define CACHE_LINE_SIZE 128
141
142 #define MAXCPUS 256
143
144 #ifdef _KERNEL
145
146 #ifndef __HIDE_DELAY
147 void delay(unsigned int);
148 #define DELAY(x) delay(x)
149 #endif
150 /*
151 * Compatibility /dev/zero mapping.
152 */
153 #ifdef COMPAT_16
154 #define COMPAT_ZERODEV(x) (x == makedev(0, _DEV_ZERO_oARM))
155 #endif
156
157 #endif /* _KERNEL */
158
159 #define aarch64_btop(x) ((unsigned long)(x) >> PGSHIFT)
160 #define aarch64_ptob(x) ((unsigned long)(x) << PGSHIFT)
161 #define aarch64_trunc_page(x) ((unsigned long)(x) & ~PGSHIFT)
162 #define aarch64_round_page(x) ((((unsigned long)(x)) + PGOFSET) & ~PGOFSET)
163
164 /* compatibility for arm */
165 #define arm_btop(x) aarch64_btop(x)
166 #define arm_ptob(x) aarch64_ptob(x)
167 #define arm_trunc_page(x) aarch64_trunc_page(x)
168 #define arm_round_page(x) aarch64_round_page(x)
169
170 #elif defined(__arm__)
171
172 #include <arm/param.h>
173
174 #endif /* __aarch64__/__arm__ */
175
176 #endif /* _AARCH64_PARAM_H_ */
177