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