diff --git a/arch/Makefile b/arch/Makefile index 3ecf37c..5ea92a7 100644 --- a/arch/Makefile +++ b/arch/Makefile @@ -10,7 +10,6 @@ OBJS += console.c.o OBJS += kprintf.c.o OBJS += multiboot.c.o -OBJS += memory.c.o OBJS += kmalloc.c.o OBJS += paging.c.o diff --git a/arch/init.c b/arch/init.c index 78802e1..bf55049 100644 --- a/arch/init.c +++ b/arch/init.c @@ -1,14 +1,27 @@ #include "console.h" #include "logger.h" +#include "kprintf.h" #include "multiboot.h" -#include "memory.h" #include +#include + +// Defined in linker script +extern char _kernel_offset; +extern char _kernel_phys_base; +extern char _kernel_virt_base; static struct KernelMQ_Info kinfo; void init(struct KernelMQ_Multiboot_Info multiboot_info) { + kmemset(&kinfo, 0, sizeof(struct KernelMQ_Info)); + + kinfo.kernel_offset = (unsigned long)&_kernel_offset; + + kinfo.kernel_phys_base = (unsigned long)&_kernel_phys_base; + kinfo.kernel_virt_base = (unsigned long)&_kernel_virt_base; + console_initialize(); logger_info("Multiboot info:"); @@ -17,5 +30,10 @@ void init(struct KernelMQ_Multiboot_Info multiboot_info) logger_info("Virtual memory info:"); - print_memory_info(); + kprintf( + "0x%x (phys base) + 0x%x (offset) = 0x%x (virt base)\n", + kinfo.kernel_phys_base, + kinfo.kernel_offset, + kinfo.kernel_virt_base + ); } diff --git a/arch/linker.ld b/arch/linker.ld index 681e3fb..f2e1f45 100644 --- a/arch/linker.ld +++ b/arch/linker.ld @@ -1,10 +1,10 @@ OUTPUT_ARCH("i386") ENTRY(_start) -_memory_offset = 0xC0000000; /* 3 GB */ +_kernel_offset = 0xC0000000; /* 3 GB */ -_memory_phys_base = 4M; -_memory_virt_base = (_memory_phys_base + _memory_offset); +_kernel_phys_base = 4M; +_kernel_virt_base = (_kernel_phys_base + _kernel_offset); SECTIONS { diff --git a/arch/memory.c b/arch/memory.c deleted file mode 100644 index 11c3059..0000000 --- a/arch/memory.c +++ /dev/null @@ -1,22 +0,0 @@ -#include "memory.h" - -#include "kprintf.h" - -// Defined in linker script -extern char _memory_offset; -extern char _memory_phys_base; -extern char _memory_virt_base; - -const unsigned int memory_offset = (unsigned int)&_memory_offset; -const unsigned int memory_phys_base = (unsigned int)&_memory_phys_base; -const unsigned int memory_virt_base = (unsigned int)&_memory_virt_base; - -void print_memory_info() -{ - kprintf( - "0x%x (phys base) + 0x%x (offset) = 0x%x (virt base)\n", - memory_phys_base, - memory_offset, - memory_virt_base - ); -} diff --git a/arch/memory.h b/arch/memory.h deleted file mode 100644 index cfddab5..0000000 --- a/arch/memory.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef KERNELMQ_INCLUDED_MEMORY -#define KERNELMQ_INCLUDED_MEMORY 1 - -extern const unsigned int memory_offset; -extern const unsigned int memory_phys_base; -extern const unsigned int memory_virt_base; - -void print_memory_info(); - -#endif