Added sanity checks for mb pointers

This commit is contained in:
lucic71 2022-06-28 19:40:51 +03:00
parent 6d0a6b84cb
commit e866816279
2 changed files with 11 additions and 0 deletions

View File

@ -23,6 +23,9 @@ void kmain(multiboot_info_t *mb_info, uint32_t mb_magic) {
if (mb_magic != MULTIBOOT_BOOTLOADER_MAGIC)
panic("Not a multiboot bootloader!");
if (!mb_info)
panic("Invalid multiboot pointer");
print_memory_map(mb_info);
puts("");
print_kernel_map();

View File

@ -1,4 +1,5 @@
#include "kernel/pmm.h"
#include "kernel/multiboot.h"
#include <stdio.h>
#include <stdint.h>
@ -26,6 +27,13 @@ static char *mem_types[] = {
void print_memory_map(multiboot_info_t *mb_info) {
if (!(mb_info->flags & MULTIBOOT_INFO_MEM_MAP)) {
puts("There is no info about memory map");
return;
}
printf("Physical Memory Map:\n");
multiboot_memory_map_t *mmap =