This extends test/multiboot2.c to also print the memory map. I created this to support my investigations in #356. I suggest keeping the core discussion there.
However, by using this change, and the following patch to common/protos/multiboot2.c:
diff --git a/common/protos/multiboot2.c b/common/protos/multiboot2.c
index e5f085f6..82618732 100644
--- a/common/protos/multiboot2.c
+++ b/common/protos/multiboot2.c
@@ -25,6 +25,7 @@
#include <lib/misc.h>
#include <drivers/vga_textmode.h>
#include <pxe/pxe.h>
+#include <e9print.h>
#define LIMINE_BRAND "Limine " LIMINE_VERSION
@@ -865,6 +866,9 @@ skip_modeset:;
if ((efi_mmap_size / efi_desc_size) > MEMMAP_MAX) {
panic(false, "multiboot2: too many EFI memory map entries");
}
+ if (efi_mmap_size % efi_desc_size != 0) {
+ panic(false, "multiboot2: invalid EFI memory map size");
+ }
// Create the EFI memory map tag.
uint32_t size = sizeof(struct multiboot_tag_efi_mmap) + efi_mmap_size;
@@ -878,6 +882,20 @@ skip_modeset:;
// Copy over the EFI memory map.
memcpy(mmap_tag->efi_mmap, efi_mmap, efi_mmap_size);
append_tag(info_idx, mmap_tag);
+
+ e9_printf("UEFI memory map: \n");
+ e9_printf(" <#> <phys> <size> <type> <attr>\n");
+ int n_entries = efi_mmap_size / efi_desc_size;
+ e9_printf("number of entries = %d\n", n_entries);
+ e9_printf("tag size = %x\n", size);
+ e9_printf("efi memory map size = %x\n", efi_mmap_size);
+
+ // Limine serial log output is weird. In the serial.txt file, there
+ // are never printed more than
+ for (int i = 0; i < n_entries; i++) {
+ EFI_MEMORY_DESCRIPTOR * e = ((char *) efi_mmap) + i * efi_desc_size;
+ e9_printf(" [%d] %x %x %x %x: \n", i, e->PhysicalStart, e->NumberOfPages * 4096, e->Type, e->Attribute);
+ }
}
#endif
I could find that there is indeed a bug. The first efi mmap output in the following excerpt refers to the output in common/protos/multiboot2.c and the second to test/multiboot2.c:
UPDATE I've just seen you did this in https://github.com/limine-bootloader/limine/commit/a9afcf89a092eae97cb33fc6c278d42d8ef9a58f. We can drop the PR, but I found a bug. It is clearly visible.
This extends
test/multiboot2.c
to also print the memory map. I created this to support my investigations in #356. I suggest keeping the core discussion there.However, by using this change, and the following patch to
common/protos/multiboot2.c
:I could find that there is indeed a bug. The first efi mmap output in the following excerpt refers to the output in
common/protos/multiboot2.c
and the second totest/multiboot2.c
: