git: a8a8e9af574c - main - bhyve: add E820 dump function
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 26 Apr 2023 07:59:36 UTC
The branch main has been updated by corvink: URL: https://cgit.FreeBSD.org/src/commit/?id=a8a8e9af574c63fbecf4719e3bf184795dc98c51 commit a8a8e9af574c63fbecf4719e3bf184795dc98c51 Author: Corvin Köhne <corvink@FreeBSD.org> AuthorDate: 2021-09-09 09:37:03 +0000 Commit: Corvin Köhne <corvink@FreeBSD.org> CommitDate: 2023-04-26 07:58:35 +0000 bhyve: add E820 dump function For debugging purposes it is helpful to dump the E820 table. Reviewed by: markj MFC after: 1 week Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D39549 --- usr.sbin/bhyve/e820.c | 35 +++++++++++++++++++++++++++++++++++ usr.sbin/bhyve/e820.h | 1 + 2 files changed, 36 insertions(+) diff --git a/usr.sbin/bhyve/e820.c b/usr.sbin/bhyve/e820.c index 922381d032ce..6c43e6eda3a5 100644 --- a/usr.sbin/bhyve/e820.c +++ b/usr.sbin/bhyve/e820.c @@ -70,6 +70,41 @@ e820_element_alloc(uint64_t base, uint64_t end, enum e820_memory_type type) return (element); } +static const char * +e820_get_type_name(const enum e820_memory_type type) +{ + switch (type) { + case E820_TYPE_MEMORY: + return ("RAM"); + case E820_TYPE_RESERVED: + return ("Reserved"); + case E820_TYPE_ACPI: + return ("ACPI"); + case E820_TYPE_NVS: + return ("NVS"); + default: + return ("Unknown"); + } +} + +void +e820_dump_table(void) +{ + struct e820_element *element; + uint64_t i; + + fprintf(stderr, "E820 map:\n"); + + i = 0; + TAILQ_FOREACH(element, &e820_table, chain) { + fprintf(stderr, " (%4lu) [%16lx, %16lx] %s\n", i, + element->base, element->end, + e820_get_type_name(element->type)); + + ++i; + } +} + struct qemu_fwcfg_item * e820_get_fwcfg_item(void) { diff --git a/usr.sbin/bhyve/e820.h b/usr.sbin/bhyve/e820.h index 8b8e23422e1f..8703a55115cd 100644 --- a/usr.sbin/bhyve/e820.h +++ b/usr.sbin/bhyve/e820.h @@ -40,5 +40,6 @@ struct e820_entry { uint64_t e820_alloc(const uint64_t address, const uint64_t length, const uint64_t alignment, const enum e820_memory_type type, const enum e820_allocation_strategy strategy); +void e820_dump_table(void); struct qemu_fwcfg_item *e820_get_fwcfg_item(void); int e820_init(struct vmctx *const ctx);