constants.h
Go to the documentation of this file.
1 /*
2  * Bareflank Hypervisor
3  *
4  * Copyright (C) 2015 Assured Information Security, Inc.
5  * Author: Rian Quinn <quinnr@ainfosec.com>
6  * Author: Brendan Kerrigan <kerriganb@ainfosec.com>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 #ifndef CONSTANTS_H
24 #define CONSTANTS_H
25 
26 #include <types.h>
27 
28 #ifdef CROSS_COMPILED
29 
30 #if defined(__GNUC__) || defined(__clang__)
31 #if __has_include("user_constants.h")
32 #include "user_constants.h"
33 #endif
34 #endif
35 
36 #endif
37 
38 /*
39  * Hypervisor Version
40  *
41  * Uses http://semver.org
42  */
43 #define BAREFLANK_VERSION_MAJOR 1ULL
44 #define BAREFLANK_VERSION_MINOR 1ULL
45 #define BAREFLANK_VERSION_PATCH 0ULL
46 
47 /*
48  * User Version
49  *
50  * Uses http://semver.org
51  */
52 #ifndef USER_VERSION_MAJOR
53 #define USER_VERSION_MAJOR 0ULL
54 #endif
55 
56 #ifndef USER_VERSION_MINOR
57 #define USER_VERSION_MINOR 0ULL
58 #endif
59 
60 #ifndef USER_VERSION_PATCH
61 #define USER_VERSION_PATCH 0ULL
62 #endif
63 
64 /*
65  * Cache Line Shift
66  *
67  * The memory manager at the moment keeps track of blocks using a cache line
68  * for performance reasons. If the cache line size is different, this value
69  * might need to be tweaked. Note that this defines the shift that will be
70  * used by MAX_CACHE_LINE_SIZE
71  *
72  * Note: defined in bits
73  */
74 #ifndef MAX_CACHE_LINE_SHIFT
75 #define MAX_CACHE_LINE_SHIFT (6ULL)
76 #endif
77 
78 /*
79  * Cache Line Size
80  *
81  * The memory manager at the moment keeps track of blocks using a cache line
82  * for performance reasons. If the cache line size is different, this value
83  * might need to be tweaked.
84  *
85  * Note: defined in bytes
86  */
87 #ifndef MAX_CACHE_LINE_SIZE
88 #define MAX_CACHE_LINE_SIZE (1 << MAX_CACHE_LINE_SHIFT)
89 #endif
90 
91 /*
92  * Max Page Shift
93  *
94  * Defines the maximum page size that is supported by the VMM (not the max
95  * size supported by hardware, which is likely different). For now, this is
96  * set to a value that is likely supported by most hardware. All pages must
97  * be translated to this value, as the VMM only supports one page size.
98  *
99  * Note: defined in bits
100  */
101 #ifndef MAX_PAGE_SHIFT
102 #define MAX_PAGE_SHIFT (12ULL)
103 #endif
104 
105 /*
106  * Max Page Size
107  *
108  * Defines the maximum page size that is supported by the VMM (not the max
109  * size supported by hardware, which is likely different). For now, this is
110  * set to a value that is likely supported by most hardware. All pages must
111  * be translated to this value, as the VMM only supports one page size.
112  *
113  * Note: defined in bytes
114  */
115 #ifndef MAX_PAGE_SIZE
116 #define MAX_PAGE_SIZE (1ULL << MAX_PAGE_SHIFT)
117 #endif
118 
119 /*
120  * Max Heap Pool
121  *
122  * This defines the internal memory that the hypervisor allocates to use
123  * during setup by new/delete. Note that things like the debug_ring and
124  * anything that uses a std::container uses this heap so it does need to
125  * have some size to it. Pages do not come from this pool.
126  *
127  * Note: defined in bytes (defaults to 8MB)
128  */
129 #ifndef MAX_HEAP_POOL
130 #define MAX_HEAP_POOL (256ULL * MAX_PAGE_SIZE * sizeof(uintptr_t))
131 #endif
132 
133 /*
134  * Max Page Pool
135  *
136  * This defines the internal memory that the hypervisor allocates to use
137  * for allocating pages.
138  *
139  * Note: defined in bytes (defaults to 32MB)
140  */
141 #ifndef MAX_PAGE_POOL
142 #define MAX_PAGE_POOL (32 * 256ULL * MAX_PAGE_SIZE)
143 #endif
144 
145 /*
146  * Max Memory Map Pool
147  *
148  * This defines the virtual memory that the hypervisor will use for mapping
149  * memory
150  *
151  * Note: defined in bytes (defaults to 8MB)
152  */
153 #ifndef MAX_MEM_MAP_POOL
154 #define MAX_MEM_MAP_POOL (256ULL * MAX_PAGE_SIZE * sizeof(uintptr_t))
155 #endif
156 
157 /*
158  * Memory Map Pool Start
159  *
160  * This defines the starting location of the virtual memory that is used
161  * for memory mapping.
162  *
163  * Note: defined in bytes (defaults to 2MB)
164  */
165 #ifndef MEM_MAP_POOL_START
166 #define MEM_MAP_POOL_START 0x200000ULL
167 #endif
168 
169 /*
170  * Max Supported Modules
171  *
172  * The maximum number of modules supported by the VMM. Note that the ELF loader
173  * has it's own version of this that likely will need to be changed if this
174  * value changes.
175  */
176 #ifndef MAX_NUM_MODULES
177 #define MAX_NUM_MODULES (75LL)
178 #endif
179 
191 #ifndef DEBUG_RING_SHIFT
192 #define DEBUG_RING_SHIFT (15)
193 #endif
194 
206 #define DEBUG_RING_SIZE (1 << DEBUG_RING_SHIFT)
207 
224 #ifndef STACK_SIZE
225 #define STACK_SIZE (1ULL << 15)
226 #endif
227 
240 #ifndef THREAD_LOCAL_STORAGE_SIZE
241 #define THREAD_LOCAL_STORAGE_SIZE (0x1000ULL)
242 #endif
243 
253 #ifndef STACK_RESERVED
254 #define STACK_RESERVED (0x20)
255 #endif
256 
262 #ifndef VMCALL_IN_BUFFER_SIZE
263 #define VMCALL_IN_BUFFER_SIZE (32 * MAX_PAGE_SIZE)
264 #endif
265 
271 #ifndef VMCALL_OUT_BUFFER_SIZE
272 #define VMCALL_OUT_BUFFER_SIZE (32 * MAX_PAGE_SIZE)
273 #endif
274 
288 #ifndef DEFAULT_COM_PORT
289 #define DEFAULT_COM_PORT 0x3F8U
290 #endif
291 
297 #ifndef DEFAULT_BAUD_RATE
298 #define DEFAULT_BAUD_RATE baud_rate_9600
299 #endif
300 
306 #ifndef DEFAULT_DATA_BITS
307 #define DEFAULT_DATA_BITS char_length_8
308 #endif
309 
315 #ifndef DEFAULT_STOP_BITS
316 #define DEFAULT_STOP_BITS stop_bits_1
317 #endif
318 
324 #ifndef DEFAULT_PARITY_BITS
325 #define DEFAULT_PARITY_BITS parity_none
326 #endif
327 
335 #ifndef SECONDARY_ENABLE_IF_VERBOSE
336 #define SECONDARY_ENABLE_IF_VERBOSE true
337 #endif
338 
339 #endif