mirror of
https://github.com/tailix/kernel.git
synced 2024-10-30 12:03:52 -04:00
Some refactoring
This commit is contained in:
parent
2c8e2ae0ed
commit
20d4f7fb95
4 changed files with 25 additions and 24 deletions
|
@ -24,8 +24,8 @@ stack_top:
|
|||
.type _start, @function
|
||||
_start:
|
||||
mov $stack_top, %esp
|
||||
push %ebx // unsigned long multiboot_info
|
||||
push %eax // unsigned int multiboot_magic
|
||||
push %ebx
|
||||
push %eax
|
||||
call main
|
||||
cli
|
||||
1:
|
||||
|
|
15
arch/main.c
15
arch/main.c
|
@ -4,22 +4,11 @@
|
|||
#include "gdt.h"
|
||||
#include "idt.h"
|
||||
|
||||
void main(unsigned int multiboot_magic, unsigned long multiboot_info)
|
||||
void main(struct KernelMQ_Multiboot_Info multiboot_info)
|
||||
{
|
||||
logger_initialize();
|
||||
|
||||
if (multiboot_magic == KERNELMQ_MULTIBOOT_2_MAGIC) {
|
||||
logger_info("Loaded with Multiboot-compliant bootloader, specification version 2.");
|
||||
print_multiboot_info(multiboot_info);
|
||||
}
|
||||
else if (multiboot_magic == KERNELMQ_MULTIBOOT_1_MAGIC) {
|
||||
logger_fail("Loaded with Multiboot-compliant bootloader, but specification version 1.");
|
||||
return;
|
||||
}
|
||||
else {
|
||||
logger_fail("Loaded with no Multiboot-compliant bootloader.");
|
||||
return;
|
||||
}
|
||||
print_multiboot_info(multiboot_info);
|
||||
|
||||
logger_info("Kernel initialization started.");
|
||||
|
||||
|
|
|
@ -2,21 +2,31 @@
|
|||
|
||||
#include "console.h"
|
||||
|
||||
#define MULTIBOOT_1_MAGIC 0x2BADB002
|
||||
#define MULTIBOOT_2_MAGIC 0x36d76289
|
||||
|
||||
static void itoa(char *buf, int base, int d);
|
||||
static void printf(const char *format, ...);
|
||||
|
||||
void print_multiboot_info(unsigned long addr)
|
||||
void print_multiboot_info(struct KernelMQ_Multiboot_Info info)
|
||||
{
|
||||
struct multiboot_tag *tag;
|
||||
if (info.magic == MULTIBOOT_1_MAGIC) {
|
||||
printf("Old Multiboot specification does not support modules.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (addr & 7)
|
||||
{
|
||||
printf("Unaligned mbi: 0x%x\n", addr);
|
||||
if (info.magic != MULTIBOOT_2_MAGIC) {
|
||||
printf("No Multiboot-compliant bootloader is not supported.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (info.addr & 7) {
|
||||
printf("Unaligned Multiboot information address: 0x%x\n", info.addr);
|
||||
return;
|
||||
}
|
||||
|
||||
for (
|
||||
tag = (struct multiboot_tag *) (addr + 8);
|
||||
struct multiboot_tag *tag = (struct multiboot_tag *) (info.addr + 8);
|
||||
tag->type != MULTIBOOT_TAG_TYPE_END;
|
||||
tag = (struct multiboot_tag *) ((multiboot_uint8_t *) tag + ((tag->size + 7) & ~7)))
|
||||
{
|
||||
|
|
|
@ -5,10 +5,12 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
void print_multiboot_info(unsigned long addr);
|
||||
struct KernelMQ_Multiboot_Info {
|
||||
unsigned long magic;
|
||||
unsigned long addr;
|
||||
};
|
||||
|
||||
#define KERNELMQ_MULTIBOOT_1_MAGIC 0x2BADB002
|
||||
#define KERNELMQ_MULTIBOOT_2_MAGIC 0x36d76289
|
||||
void print_multiboot_info(struct KernelMQ_Multiboot_Info info);
|
||||
|
||||
/*
|
||||
* How many bytes from the start of the file we search for the header.
|
||||
|
|
Loading…
Reference in a new issue