Implemented multiboot check
This commit is contained in:
parent
3aa8f7360d
commit
7cefdcb3de
|
@ -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
|
|
@ -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");
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue