multiboot2: Improve multiboot2 test case

This commit is contained in:
mintsuki 2022-06-29 15:32:38 +02:00
parent b899d1accd
commit 2b5f1039c2
1 changed files with 19 additions and 27 deletions

View File

@ -69,31 +69,23 @@ void multiboot2_main(uint32_t magic, struct multiboot_info* mb_info_addr) {
e9_printf("\t mmap:"); e9_printf("\t mmap:");
e9_printf("\t\t entry_size=%d", mmap->entry_size); e9_printf("\t\t entry_size=%d", mmap->entry_size);
e9_printf("\t\t entry_version=%d", mmap->entry_version); e9_printf("\t\t entry_version=%d", mmap->entry_version);
e9_printf("\t\t useable_entries:"); e9_printf("\t\t entries:");
struct multiboot_mmap_entry *start = (struct multiboot_mmap_entry *)(mmap->entries); struct multiboot_mmap_entry *m = (struct multiboot_mmap_entry *)(mmap->entries);
struct multiboot_mmap_entry *end = (struct multiboot_mmap_entry *)(mmap->entries + mmap->size);
size_t total_mem = 0; size_t entry_count = mmap->size / sizeof(struct multiboot_mmap_entry);
e9_printf("\t\t entry count: %d", entry_count);
// For now we only print the useable memory map entries since // For now we only print the usable memory map entries since
// printing the whole memory map blows my terminal up. We also // printing the whole memory map blows my terminal up. We also
// iterate through the avaliable memory map entries and add up // iterate through the avaliable memory map entries and add up
// to find the total amount of useable memory. // to find the total amount of usable memory.
for (struct multiboot_mmap_entry* entry = start; entry < end; entry++) { for (size_t i = 0; i < entry_count; i++) {
if (entry->type != MULTIBOOT_MEMORY_AVAILABLE) { e9_printf("\t\t\t addr=%x", m[i].addr);
continue; e9_printf("\t\t\t len=%x", m[i].len);
e9_printf("\t\t\t type=%x", m[i].type);
} }
e9_printf("\t\t\t addr=%x", entry->addr);
e9_printf("\t\t\t len=%x", entry->len);
e9_printf("\t\t\t type=Useable");
total_mem += entry->len;
}
e9_printf("Total usable memory: %x", total_mem);
break; break;
} }
@ -103,12 +95,12 @@ void multiboot2_main(uint32_t magic, struct multiboot_info* mb_info_addr) {
struct multiboot_tag_framebuffer *fb = (struct multiboot_tag_framebuffer *)tag; struct multiboot_tag_framebuffer *fb = (struct multiboot_tag_framebuffer *)tag;
e9_printf("\t framebuffer:"); e9_printf("\t framebuffer:");
e9_printf("\t\t framebuffer_pitch: %x", fb->common.framebuffer_pitch); e9_printf("\t\t framebuffer_pitch: %d", fb->common.framebuffer_pitch);
e9_printf("\t\t framebuffer_width: %x", fb->common.framebuffer_width); e9_printf("\t\t framebuffer_width: %d", fb->common.framebuffer_width);
e9_printf("\t\t framebuffer_height: %x", fb->common.framebuffer_height); e9_printf("\t\t framebuffer_height: %d", fb->common.framebuffer_height);
e9_printf("\t\t framebuffer_bpp: %x", fb->common.framebuffer_bpp); e9_printf("\t\t framebuffer_bpp: %d", fb->common.framebuffer_bpp);
e9_printf("\t\t framebuffer_type: %x", fb->common.framebuffer_type); e9_printf("\t\t framebuffer_type: %d", fb->common.framebuffer_type);
e9_printf("\t\t framebuffer_adddress: %x", fb->common.framebuffer_addr); e9_printf("\t\t framebuffer_address: %x", fb->common.framebuffer_addr);
switch (fb->common.framebuffer_type) { switch (fb->common.framebuffer_type) {
case MULTIBOOT_FRAMEBUFFER_TYPE_RGB: { case MULTIBOOT_FRAMEBUFFER_TYPE_RGB: {