xref: /illumos-gate/usr/src/cmd/bhyve/e820.h (revision 32640292339b07090f10ce34d455f98711077343)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 2021 Beckhoff Automation GmbH & Co. KG
5  * Author: Corvin Köhne <c.koehne@beckhoff.com>
6  */
7 
8 #pragma once
9 
10 #include <vmmapi.h>
11 
12 #include "qemu_fwcfg.h"
13 
14 enum e820_memory_type {
15 	E820_TYPE_MEMORY = 1,
16 	E820_TYPE_RESERVED = 2,
17 	E820_TYPE_ACPI = 3,
18 	E820_TYPE_NVS = 4
19 };
20 
21 enum e820_allocation_strategy {
22 	/* allocate any address */
23 	E820_ALLOCATE_ANY,
24 	/* allocate lowest address larger than address */
25 	E820_ALLOCATE_LOWEST,
26 	/* allocate highest address lower than address */
27 	E820_ALLOCATE_HIGHEST,
28 	/* allocate a specific address */
29 	E820_ALLOCATE_SPECIFIC
30 };
31 
32 struct e820_entry {
33 	uint64_t base;
34 	uint64_t length;
35 	uint32_t type;
36 } __packed;
37 
38 #define E820_ALIGNMENT_NONE 1
39 
40 uint64_t e820_alloc(const uint64_t address, const uint64_t length,
41     const uint64_t alignment, const enum e820_memory_type type,
42     const enum e820_allocation_strategy strategy);
43 void e820_dump_table(void);
44 struct qemu_fwcfg_item *e820_get_fwcfg_item(void);
45 int e820_init(struct vmctx *const ctx);
46