mirror of
https://github.com/tailix/kernel.git
synced 2024-10-30 12:03:52 -04:00
Rename "arch/x86/init.c" <=> "arch/x86/main.c"
This commit is contained in:
parent
0b1b604291
commit
f92d7fa3ad
3 changed files with 49 additions and 49 deletions
|
@ -1,49 +1,32 @@
|
|||
#include "multiboot.h"
|
||||
#include "console.h"
|
||||
#include "panic.h"
|
||||
#include "pfa.h"
|
||||
#include "protected.h"
|
||||
#include "paging.h"
|
||||
|
||||
#include <kernelmq/info.h>
|
||||
#include <kernelmq/stdlib.h>
|
||||
|
||||
// Defined in linker script
|
||||
extern char _kernel_offset;
|
||||
extern char _kernel_size;
|
||||
extern char _kernel_phys_base;
|
||||
extern char _kernel_virt_base;
|
||||
extern char _kernel_stack_top;
|
||||
#include <kernelmq/module.h>
|
||||
|
||||
static struct KernelMQ_Info kinfo;
|
||||
|
||||
const struct KernelMQ_Info *init(unsigned long multiboot_magic, unsigned long multiboot_info_base)
|
||||
void init(const struct KernelMQ_Info *const kinfo_ptr)
|
||||
{
|
||||
if (multiboot_magic != MULTIBOOT_MAGIC) {
|
||||
return 0;
|
||||
}
|
||||
console_initialize();
|
||||
|
||||
kmemset(&kinfo, 0, sizeof(struct KernelMQ_Info));
|
||||
|
||||
if (!multiboot_parse(&kinfo, multiboot_info_base)) {
|
||||
return 0;
|
||||
}
|
||||
assert(kernelmq_info_validate_and_copy(&kinfo, kinfo_ptr), "Invalid kernel information.");
|
||||
|
||||
kinfo.kernel_offset = (unsigned long)&_kernel_offset;
|
||||
kinfo.kernel_size = (unsigned long)&_kernel_size;
|
||||
pfa_initialize(&kinfo);
|
||||
|
||||
kinfo.kernel_phys_base = (unsigned long)&_kernel_phys_base;
|
||||
kinfo.kernel_virt_base = (unsigned long)&_kernel_virt_base;
|
||||
|
||||
kinfo.kernel_phys_limit = kinfo.kernel_phys_base + kinfo.kernel_size - 1;
|
||||
kinfo.kernel_virt_limit = kinfo.kernel_virt_base + kinfo.kernel_size - 1;
|
||||
|
||||
kinfo.kernel_and_modules_total_size = kinfo.kernel_size + kinfo.modules_total_size;
|
||||
|
||||
kinfo.kernel_stack_top = (unsigned long)&_kernel_stack_top;
|
||||
protected_initialize(&kinfo);
|
||||
|
||||
// Set up a new post-relocate bootstrap pagetable so that
|
||||
// we can map in VM, and we no longer rely on pre-relocated
|
||||
// data.
|
||||
paging_clear();
|
||||
paging_identity();
|
||||
/* kinfo.freepde_start = */ paging_mapkernel(&kinfo);
|
||||
paging_identity(); // Still need 1:1 for lapic and video mem and such.
|
||||
paging_mapkernel(&kinfo);
|
||||
paging_load();
|
||||
|
||||
paging_enable();
|
||||
|
||||
return &kinfo;
|
||||
}
|
||||
|
|
|
@ -1,32 +1,49 @@
|
|||
#include "console.h"
|
||||
#include "panic.h"
|
||||
#include "pfa.h"
|
||||
#include "protected.h"
|
||||
#include "multiboot.h"
|
||||
#include "paging.h"
|
||||
|
||||
#include <kernelmq/info.h>
|
||||
#include <kernelmq/stdlib.h>
|
||||
#include <kernelmq/module.h>
|
||||
|
||||
// Defined in linker script
|
||||
extern char _kernel_offset;
|
||||
extern char _kernel_size;
|
||||
extern char _kernel_phys_base;
|
||||
extern char _kernel_virt_base;
|
||||
extern char _kernel_stack_top;
|
||||
|
||||
static struct KernelMQ_Info kinfo;
|
||||
|
||||
void main(const struct KernelMQ_Info *const kinfo_ptr)
|
||||
const struct KernelMQ_Info *main(unsigned long multiboot_magic, unsigned long multiboot_info_base)
|
||||
{
|
||||
console_initialize();
|
||||
if (multiboot_magic != MULTIBOOT_MAGIC) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
kmemset(&kinfo, 0, sizeof(struct KernelMQ_Info));
|
||||
|
||||
assert(kernelmq_info_validate_and_copy(&kinfo, kinfo_ptr), "Invalid kernel information.");
|
||||
if (!multiboot_parse(&kinfo, multiboot_info_base)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
pfa_initialize(&kinfo);
|
||||
kinfo.kernel_offset = (unsigned long)&_kernel_offset;
|
||||
kinfo.kernel_size = (unsigned long)&_kernel_size;
|
||||
|
||||
protected_initialize(&kinfo);
|
||||
kinfo.kernel_phys_base = (unsigned long)&_kernel_phys_base;
|
||||
kinfo.kernel_virt_base = (unsigned long)&_kernel_virt_base;
|
||||
|
||||
kinfo.kernel_phys_limit = kinfo.kernel_phys_base + kinfo.kernel_size - 1;
|
||||
kinfo.kernel_virt_limit = kinfo.kernel_virt_base + kinfo.kernel_size - 1;
|
||||
|
||||
kinfo.kernel_and_modules_total_size = kinfo.kernel_size + kinfo.modules_total_size;
|
||||
|
||||
kinfo.kernel_stack_top = (unsigned long)&_kernel_stack_top;
|
||||
|
||||
// Set up a new post-relocate bootstrap pagetable so that
|
||||
// we can map in VM, and we no longer rely on pre-relocated
|
||||
// data.
|
||||
paging_clear();
|
||||
paging_identity(); // Still need 1:1 for lapic and video mem and such.
|
||||
paging_mapkernel(&kinfo);
|
||||
paging_identity();
|
||||
/* kinfo.freepde_start = */ paging_mapkernel(&kinfo);
|
||||
paging_load();
|
||||
|
||||
paging_enable();
|
||||
|
||||
return &kinfo;
|
||||
}
|
||||
|
|
|
@ -31,12 +31,12 @@ _start:
|
|||
|
||||
push %ebx // Multiboot information pointer
|
||||
push %eax // Multiboot magic number
|
||||
call init
|
||||
call main
|
||||
|
||||
mov $_kernel_stack_top, %esp // Initialize stack
|
||||
|
||||
push %eax // Kernel information pointer
|
||||
call main
|
||||
call init
|
||||
|
||||
call halt
|
||||
|
||||
|
|
Loading…
Reference in a new issue