From 4aebafd7172abc54d001cd851749da4c8287ea46 Mon Sep 17 00:00:00 2001 From: Braiden Vasco Date: Sat, 4 Nov 2017 10:38:28 +0000 Subject: [PATCH] Pass kernel information to "main" --- arch/init.c | 4 +++- arch/main.c | 16 +++++++++++++++- arch/start.s | 1 + 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/arch/init.c b/arch/init.c index 0ba10d6..61bc0c8 100644 --- a/arch/init.c +++ b/arch/init.c @@ -10,7 +10,7 @@ extern char _kernel_virt_base; static struct KernelMQ_Info kinfo; -void init(struct KernelMQ_Multiboot_Info multiboot_info) +const struct KernelMQ_Info *init(struct KernelMQ_Multiboot_Info multiboot_info) { kmemset(&kinfo, 0, sizeof(struct KernelMQ_Info)); @@ -18,4 +18,6 @@ void init(struct KernelMQ_Multiboot_Info multiboot_info) kinfo.kernel_phys_base = (unsigned long)&_kernel_phys_base; kinfo.kernel_virt_base = (unsigned long)&_kernel_virt_base; + + return &kinfo; } diff --git a/arch/main.c b/arch/main.c index d595453..dfe19f9 100644 --- a/arch/main.c +++ b/arch/main.c @@ -4,12 +4,26 @@ #include "paging.h" #include "timer.h" +#include +#include + +static struct KernelMQ_Info kinfo; + static void on_timer(); -void main() +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; + } + + kinfo = *kinfo_ptr; + protected_initialize(); // paging_initialize(); diff --git a/arch/start.s b/arch/start.s index 1b5e959..5811c3c 100644 --- a/arch/start.s +++ b/arch/start.s @@ -35,6 +35,7 @@ _start: mov $stack_top, %esp // Initialize stack + push %eax // Kernel information pointer call main halt: