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
14enum 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
21enum 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
32struct e820_entry {
33	uint64_t base;
34	uint64_t length;
35	uint32_t type;
36} __packed;
37
38#define E820_ALIGNMENT_NONE 1
39
40uint64_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);
43void e820_dump_table(void);
44int e820_init(struct vmctx *const ctx);
45int e820_finalize(void);
46