xref: /freebsd/usr.sbin/bhyve/amd64/e820.h (revision 608da65de9552d5678c1000776ed69da04a45983)
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 int e820_init(struct vmctx *const ctx);
45 int e820_finalize(void);
46