1
0
Fork 0
mirror of https://github.com/tailix/kernel.git synced 2024-10-30 12:03:52 -04:00

Started parsing multiboot info

This commit is contained in:
Braiden Vasco 2017-11-04 11:07:04 +00:00
parent 84746cb114
commit e0739042f1
4 changed files with 31 additions and 11 deletions

View file

@ -1,8 +1,9 @@
#include "console.h"
#include "multiboot.h"
#include <kernelmq/info.h>
#include <kernelmq/stdlib.h>
#define MULTIBOOT_MAGIC 0x36d76289
// Defined in linker script
extern char _kernel_offset;
extern char _kernel_phys_base;
@ -16,13 +17,14 @@ const struct KernelMQ_Info *init(unsigned long multiboot_magic, unsigned long mu
return 0;
}
// Unaligned address
if (multiboot_info_addr & 7) {
kmemset(&kinfo, 0, sizeof(struct KernelMQ_Info));
console_initialize();
if (!multiboot_parse(&kinfo, multiboot_info_addr)) {
return 0;
}
kmemset(&kinfo, 0, sizeof(struct KernelMQ_Info));
kinfo.kernel_offset = (unsigned long)&_kernel_offset;
kinfo.kernel_phys_base = (unsigned long)&_kernel_phys_base;

View file

@ -1,4 +1,3 @@
#include "console.h"
#include "logger.h"
#include "protected.h"
#include "paging.h"
@ -15,8 +14,6 @@ void main(const struct KernelMQ_Info *const kinfo_ptr)
{
kmemset(&kinfo, 0, sizeof(struct KernelMQ_Info));
console_initialize();
if (!kinfo_ptr) {
logger_fail("No kernel information. Halt.");
return;

View file

@ -1,4 +1,4 @@
#include "kprintf.h"
#include "multiboot.h"
#define MULTIBOOT_TAG_TYPE_END 0
#define MULTIBOOT_TAG_TYPE_CMDLINE 1
@ -68,8 +68,17 @@ static void print_multiboot_tag_module (const struct multiboot_tag_module
static void print_multiboot_tag_basic_meminfo(const struct multiboot_tag_basic_meminfo *tag);
static void print_multiboot_tag_mmap (const struct multiboot_tag_mmap *tag);
void print_multiboot_info(unsigned long addr)
unsigned char multiboot_parse(struct KernelMQ_Info *kinfo, unsigned long addr)
{
if (!kinfo) {
return 0;
}
// Unaligned address
if (addr & 7) {
return 0;
}
for (
struct multiboot_tag *tag = (struct multiboot_tag*)(addr + 8);
tag->type != MULTIBOOT_TAG_TYPE_END;
@ -77,6 +86,8 @@ void print_multiboot_info(unsigned long addr)
) {
print_multiboot_tag(tag);
}
return 1;
}
void print_multiboot_tag(const struct multiboot_tag *const tag)

10
arch/multiboot.h Normal file
View file

@ -0,0 +1,10 @@
#ifndef KERNELMQ_INCLUDED_MULTIBOOT
#define KERNELMQ_INCLUDED_MULTIBOOT 1
#include <kernelmq/info.h>
#define MULTIBOOT_MAGIC 0x36d76289
unsigned char multiboot_parse(struct KernelMQ_Info *kinfo, unsigned long addr);
#endif