diff options
Diffstat (limited to 'src/arch/i386')
-rw-r--r-- | src/arch/i386/boot.c | 20 | ||||
-rw-r--r-- | src/arch/i386/boot.s | 1 | ||||
-rw-r--r-- | src/arch/i386/multiboot.h | 31 |
3 files changed, 50 insertions, 2 deletions
diff --git a/src/arch/i386/boot.c b/src/arch/i386/boot.c index 37e1aff..242d070 100644 --- a/src/arch/i386/boot.c +++ b/src/arch/i386/boot.c @@ -1,11 +1,16 @@ #include <arch/generic.h> #include <arch/i386/gdt.h> #include <arch/i386/interrupts/idt.h> +#include <arch/i386/multiboot.h> #include <arch/i386/sysenter.h> #include <arch/i386/tty.h> #include <kernel/main.h> +#include <kernel/panic.h> -void kmain_early() { +void kmain_early(struct multiboot_info *multiboot) { + struct kmain_info info; + + // setup some basic stuff tty_clear(); log_const("gdt..."); gdt_init(); @@ -13,5 +18,16 @@ void kmain_early() { idt_init(); log_const("sysenter..."); sysenter_setup(); - kmain(); + + { // find the init module + struct multiboot_mod *module = &multiboot->mods[0]; + if (multiboot->mods_count < 1) { + log_const("can't find init! "); + panic(); + } + info.init.at = module->start; + info.init.size = module->end - module->start; + } + + kmain(info); } diff --git a/src/arch/i386/boot.s b/src/arch/i386/boot.s index 2578e87..74de9b7 100644 --- a/src/arch/i386/boot.s +++ b/src/arch/i386/boot.s @@ -3,6 +3,7 @@ .type _start, @function _start: mov $stack_top, %esp + push %ebx // address of the Multiboot struct call kmain_early .global halt_cpu diff --git a/src/arch/i386/multiboot.h b/src/arch/i386/multiboot.h new file mode 100644 index 0000000..f030247 --- /dev/null +++ b/src/arch/i386/multiboot.h @@ -0,0 +1,31 @@ +#pragma once +#include <stdint.h> + +// TODO assert that pointers have 4 bytes. + +struct multiboot_mod { + void *start; + void *end; + const char *str; + uint32_t _reserved; +} __attribute__((packed)); + +struct multiboot_info { + uint32_t flag_mem : 1; + uint32_t flag_boot_device : 1; + uint32_t flag_cmdline : 1; + uint32_t flag_mods : 1; + uint32_t _flag_other : 28; // unimplemented + + uint32_t mem_lower; + uint32_t mem_upper; + + uint32_t boot_device; + + const char *cmdline; + + uint32_t mods_count; + struct multiboot_mod *mods; + + // [...] +} __attribute__((packed)); |