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
This commit is contained in:
Corvin Köhne 2021-09-09 11:37:03 +02:00
parent 5597f56487
commit a8a8e9af57
No known key found for this signature in database
GPG key ID: D854DA56315E026A
2 changed files with 36 additions and 0 deletions

View file

@ -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)
{

View file

@ -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);