param.h revision 1.11 1 /* $NetBSD: param.h,v 1.11 2019/01/19 09:11:55 skrll 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 # else
63 # define _MACHINE_ARCH aarch64
64 # define MACHINE_ARCH "aarch64"
65 # endif /* __AARCH64EB__ */
66 # endif /* MACHINE_ARCH */
67 #else
68 # undef _MACHINE
69 # undef MACHINE
70 # undef _MACHINE_ARCH
71 # undef MACHINE_ARCH
72 # define _MACHINE aarch64
73 # define MACHINE "aarch64"
74 # ifdef __AARCH64EB__
75 # define _MACHINE_ARCH aarch64eb
76 # define MACHINE_ARCH "aarch64eb"
77 # else
78 # define _MACHINE_ARCH aarch64
79 # define MACHINE_ARCH "aarch64"
80 # endif /* __AARCH64EB__ */
81 #endif /* !_KERNEL */
82
83 #define MID_MACHINE MID_AARCH64
84
85 /* AARCH64-specific macro to align a stack pointer (downwards). */
86 #define STACK_ALIGNBYTES (16 - 1)
87
88 #define ALIGNBYTES32 (8 - 1)
89 #define ALIGN32(p) \
90 (((uintptr_t)(p) + ALIGNBYTES32) & ~ALIGNBYTES32)
91
92 #define NKMEMPAGES_MIN_DEFAULT ((128UL * 1024 * 1024) >> PAGE_SHIFT)
93 #define NKMEMPAGES_MAX_UNLIMITED 1
94
95 #ifdef AARCH64_PAGE_SHIFT
96 #if (1 << AARCH64_PAGE_SHIFT) & ~0x141000
97 #error AARCH64_PAGE_SHIFT contains an unsupported value.
98 #endif
99 #define PGSHIFT AARCH64_PAGE_SHIFT
100 #else
101 #define PGSHIFT 12
102 #endif
103 #define NBPG (1 << PGSHIFT)
104 #define PGOFSET (NBPG - 1)
105
106 /*
107 * Constants related to network buffer management.
108 * MCLBYTES must be no larger than NBPG (the software page size), and
109 * NBPG % MCLBYTES must be zero.
110 */
111 #if PGSHIFT > 12
112 #define MSIZE 256 /* size of an mbuf */
113 #else
114 #define MSIZE 512 /* size of an mbuf */
115 #endif
116
117 #ifndef MCLSHIFT
118 #define MCLSHIFT 11 /* convert bytes to m_buf clusters */
119 /* 2K cluster can hold Ether frame */
120 #endif /* MCLSHIFT */
121
122 #define MCLBYTES (1 << MCLSHIFT) /* size of a m_buf cluster */
123
124
125 #ifndef MSGBUFSIZE
126 #define MSGBUFSIZE 65536 /* default message buffer size */
127 #endif
128
129 #define COHERENCY_UNIT 128
130 #define CACHE_LINE_SIZE 128
131
132 #ifdef _KERNEL
133
134 #ifndef __HIDE_DELAY
135 void delay(unsigned int);
136 #define DELAY(x) delay(x)
137 #endif
138 /*
139 * Compatibility /dev/zero mapping.
140 */
141 #ifdef COMPAT_16
142 #define COMPAT_ZERODEV(x) (x == makedev(0, _DEV_ZERO_oARM))
143 #endif
144
145 #endif /* _KERNEL */
146
147 #define aarch64_btop(x) ((unsigned long)(x) >> PGSHIFT)
148 #define aarch64_ptob(x) ((unsigned long)(x) << PGSHIFT)
149 #define aarch64_trunc_page(x) ((unsigned long)(x) & ~PGSHIFT)
150 #define aarch64_round_page(x) ((((unsigned long)(x)) + PGOFSET) & ~PGOFSET)
151
152 /* compatibility for arm */
153 #define arm_btop(x) aarch64_btop(x)
154 #define arm_ptob(x) aarch64_ptob(x)
155 #define arm_trunc_page(x) aarch64_trunc_page(x)
156 #define arm_round_page(x) aarch64_round_page(x)
157
158 #elif defined(__arm__)
159
160 #include <arm/param.h>
161
162 #endif /* __aarch64__/__arm__ */
163
164 #endif /* _AARCH64_PARAM_H_ */
165