mirror of
https://github.com/tailix/kernel.git
synced 2025-04-14 17:33:13 -04:00
Some refactoring
This commit is contained in:
parent
4aebafd717
commit
84746cb114
3 changed files with 14 additions and 36 deletions
15
arch/init.c
15
arch/init.c
|
@ -1,8 +1,8 @@
|
|||
#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;
|
||||
|
@ -10,8 +10,17 @@ extern char _kernel_virt_base;
|
|||
|
||||
static struct KernelMQ_Info kinfo;
|
||||
|
||||
const struct KernelMQ_Info *init(struct KernelMQ_Multiboot_Info multiboot_info)
|
||||
const struct KernelMQ_Info *init(unsigned long multiboot_magic, unsigned long multiboot_info_addr)
|
||||
{
|
||||
if (multiboot_magic != MULTIBOOT_MAGIC) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Unaligned address
|
||||
if (multiboot_info_addr & 7) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
kmemset(&kinfo, 0, sizeof(struct KernelMQ_Info));
|
||||
|
||||
kinfo.kernel_offset = (unsigned long)&_kernel_offset;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
#include "multiboot.h"
|
||||
|
||||
#include "kprintf.h"
|
||||
|
||||
#define MULTIBOOT_1_MAGIC 0x2BADB002
|
||||
#define MULTIBOOT_2_MAGIC 0x36d76289
|
||||
|
||||
#define MULTIBOOT_TAG_TYPE_END 0
|
||||
#define MULTIBOOT_TAG_TYPE_CMDLINE 1
|
||||
#define MULTIBOOT_TAG_TYPE_MODULE 3
|
||||
|
@ -73,25 +68,10 @@ 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(struct KernelMQ_Multiboot_Info info)
|
||||
void print_multiboot_info(unsigned long addr)
|
||||
{
|
||||
if (info.magic == MULTIBOOT_1_MAGIC) {
|
||||
kprintf("Old Multiboot specification does not support modules.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (info.magic != MULTIBOOT_2_MAGIC) {
|
||||
kprintf("No Multiboot-compliant bootloader is not supported.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (info.addr & 7) {
|
||||
kprintf("Unaligned Multiboot information address: 0x%x\n", info.addr);
|
||||
return;
|
||||
}
|
||||
|
||||
for (
|
||||
struct multiboot_tag *tag = (struct multiboot_tag*)(info.addr + sizeof(struct KernelMQ_Multiboot_Info));
|
||||
struct multiboot_tag *tag = (struct multiboot_tag*)(addr + 8);
|
||||
tag->type != MULTIBOOT_TAG_TYPE_END;
|
||||
tag = (struct multiboot_tag*)((unsigned char*)tag + ((tag->size + 7) & ~7))
|
||||
) {
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
#ifndef KERNELMQ_INCLUDED_MULTIBOOT
|
||||
#define KERNELMQ_INCLUDED_MULTIBOOT 1
|
||||
|
||||
struct KernelMQ_Multiboot_Info {
|
||||
unsigned long magic;
|
||||
unsigned long addr;
|
||||
};
|
||||
|
||||
void print_multiboot_info(struct KernelMQ_Multiboot_Info info);
|
||||
|
||||
#endif
|
Loading…
Add table
Reference in a new issue