vmparam.h revision 1.7 1 /* $NetBSD: vmparam.h,v 1.7 2018/10/12 01:28:58 ryo 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_VMPARAM_H_
33 #define _AARCH64_VMPARAM_H_
34
35 #ifdef __aarch64__
36
37 #define __USE_TOPDOWN_VM
38
39 /*
40 * Default pager_map of 16MB is small and we have plenty of VA to burn.
41 */
42 #define PAGER_MAP_DEFAULT_SIZE (512 * 1024 * 1024)
43
44 /*
45 * AARCH64 supports 3 page sizes: 4KB, 16KB, 64KB. Each page table can
46 * even have its own page size.
47 */
48
49 #ifdef AARCH64_PAGE_SHIFT
50 #if (1 << AARCH64_PAGE_SHIFT) & ~0x141000
51 #error AARCH64_PAGE_SHIFT contains an unsupported value.
52 #endif
53 #define PAGE_SHIFT AARCH64_PAGE_SHIFT
54 #else
55 #define PAGE_SHIFT 12
56 #endif
57 #define PAGE_SIZE (1 << PAGE_SHIFT)
58 #define PAGE_MASK (PAGE_SIZE - 1)
59
60 #if PAGE_SHIFT <= 14
61 #define USPACE 32768
62 #else
63 #define USPACE 65536
64 #endif
65 #define UPAGES (USPACE >> PAGE_SHIFT)
66
67 /*
68 * USRSTACK is the top (end) of the user stack. The user VA space is a
69 * 48-bit address space starting at 0. Place the stack at its top end.
70 */
71 #define USRSTACK VM_MAXUSER_ADDRESS
72
73 #ifndef MAXTSIZ
74 #define MAXTSIZ (1L << 30) /* max text size (1GB) */
75 #endif
76
77 #ifndef MAXDSIZ
78 #define MAXDSIZ (1L << 36) /* max data size (64GB) */
79 #endif
80
81 #ifndef MAXSSIZ
82 #define MAXSSIZ (1L << 26) /* max stack size (64MB) */
83 #endif
84
85 #ifndef DFLDSIZ
86 #define DFLDSIZ (1L << 32) /* default data size (4GB) */
87 #endif
88
89 #ifndef DFLSSIZ
90 #define DFLSSIZ (1L << 23) /* default stack size (8MB) */
91 #endif
92
93 #define USRSTACK32 VM_MAXUSER_ADDRESS32
94
95 #ifndef MAXTSIZ32
96 #define MAXTSIZ32 (1L << 26) /* 32bit max text size (64MB) */
97 #endif
98
99 #ifndef MAXDSIZ32
100 #define MAXDSIZ32 (3U*1024*1024*1024) /* max data size */
101 #endif
102
103 #ifndef MAXSSIZ32
104 #define MAXSSIZ32 (64*1024*1024) /* max stack size */
105 #endif
106
107 #ifndef DFLDSIZ32
108 #define DFLDSIZ32 (1L << 27) /* 32bit default data size (128MB) */
109 #endif
110
111 #ifndef DFLSSIZ32
112 #define DFLSSIZ32 (1L << 21) /* 32bit default stack size (2MB) */
113 #endif
114
115 #define VM_MIN_ADDRESS ((vaddr_t) 0x0)
116 #define VM_MAXUSER_ADDRESS ((vaddr_t) (1L << 48) - PAGE_SIZE)
117 #define VM_MAX_ADDRESS VM_MAXUSER_ADDRESS
118
119 #define VM_MAXUSER_ADDRESS32 ((vaddr_t) 0xfffff000)
120
121 /*
122 * Give ourselves 64GB of mappable kernel space. That leaves the rest
123 * to be user for directly mapped (block addressable) addresses.
124 */
125 #define VM_MIN_KERNEL_ADDRESS ((vaddr_t) 0xffffffc000000000L)
126 #define VM_MAX_KERNEL_ADDRESS ((vaddr_t) 0xffffffffffe00000L)
127
128 /*
129 * last 254MB of kernel vm area (0xfffffffff0000000-0xffffffffffe00000)
130 * may be used for devmap. address must be aligned 2MB (L2_SIZE)
131 * see also aarch64/pmap.c:pmap_devmap_*
132 */
133 #define VM_KERNEL_IO_ADDRESS 0xfffffffff0000000L
134 #define VM_KERNEL_IO_SIZE (VM_MAX_KERNEL_ADDRESS - VM_KERNEL_IO_ADDRESS)
135
136 /* virtual sizes (bytes) for various kernel submaps */
137 #define USRIOSIZE (PAGE_SIZE / 8)
138 #define VM_PHYS_SIZE (USRIOSIZE * PAGE_SIZE)
139
140 #define VM_DEFAULT_ADDRESS32_TOPDOWN(da, sz) \
141 trunc_page(USRSTACK32 - MAXSSIZ32 - (sz) - user_stack_guard_size)
142 #define VM_DEFAULT_ADDRESS32_BOTTOMUP(da, sz) \
143 round_page((vaddr_t)(da) + (vsize_t)MAXDSIZ32)
144
145 /*
146 * Since we have the address space, we map all of physical memory (RAM)
147 * using block page table entries.
148 */
149 #define AARCH64_KSEG_MASK ((vaddr_t) 0xffff000000000000L)
150 #define AARCH64_KSEG_SIZE (1UL << 39) /* 512GB */
151 #define AARCH64_KSEG_START AARCH64_KSEG_MASK
152 #define AARCH64_KSEG_END (AARCH64_KSEG_START + AARCH64_KSEG_SIZE)
153 #define AARCH64_KMEMORY_BASE AARCH64_KSEG_MASK
154 #define AARCH64_KVA_P(va) (((vaddr_t) (va) & AARCH64_KSEG_MASK) != 0)
155 #define AARCH64_PA_TO_KVA(pa) ((vaddr_t) ((pa) | AARCH64_KSEG_START))
156 #define AARCH64_KVA_TO_PA(va) ((paddr_t) ((va) & ~AARCH64_KSEG_MASK))
157
158 /* */
159 #define VM_PHYSSEG_MAX 64 /* XXX */
160 #define VM_PHYSSEG_STRAT VM_PSTRAT_BSEARCH
161
162 #define VM_NFREELIST 3
163 #define VM_FREELIST_DEFAULT 0
164 #define VM_FREELIST_FIRST4GB 1
165 #define VM_FREELIST_HIGHMEM 2
166
167 #elif defined(__arm__)
168
169 #include <arm/vmparam.h>
170
171 #endif /* __aarch64__/__arm__ */
172
173 #endif /* _AARCH64_VMPARAM_H_ */
174