Implemented multiboot check

This commit is contained in:
lucic71 2022-06-28 19:40:51 +03:00
parent 3aa8f7360d
commit 7cefdcb3de
2 changed files with 44 additions and 0 deletions

View File

@ -0,0 +1,20 @@
#ifndef KMAIN_MULTIBOOT_H_
#define KMAIN_MULTIBOOT_H_
#include "kernel/multiboot.h"
#include <stdint.h>
/*
* multiboot_init
* Check whether important information is present in multiboot info structure.
* Also check that the magic number is correct.
*
* @param mb_info - Multiboot info structure
* @param mb_magic - Multiboot magic number
*
*/
void multiboot_init(multiboot_info_t *mb_info, uint32_t mb_magic);
#endif

24
kernel/kernel/multiboot.c Normal file
View File

@ -0,0 +1,24 @@
#include "kernel/multiboot.h"
#include "kmain/multiboot.h"
#include "kernel/log.h"
/*
* multiboot_init:
* ---------------
*
* Check flags field in mb_info and check the magic number.
*
*/
void multiboot_init(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");
if (!(mb_info->flags & MULTIBOOT_INFO_MEMORY))
panic("There is no memory info in multiboot");
}