68 lines
1.9 KiB
C
68 lines
1.9 KiB
C
#include "sys/amd64/loader/multiboot.h"
|
|
#include "sys/amd64/asm/asm_irq.h"
|
|
#include "sys/amd64/hw/rs232.h"
|
|
#include "sys/amd64/smp/smp.h"
|
|
#include "sys/amd64/syscall.h"
|
|
#include "sys/amd64/mm/phys.h"
|
|
#include "sys/amd64/hw/acpi.h"
|
|
#include "sys/amd64/hw/apic.h"
|
|
#include "sys/amd64/hw/gdt.h"
|
|
#include "sys/amd64/hw/idt.h"
|
|
#include "sys/amd64/hw/ps2.h"
|
|
#include "sys/amd64/hw/rtc.h"
|
|
#include "sys/amd64/cpuid.h"
|
|
#include "sys/amd64/mm/mm.h"
|
|
#include "sys/amd64/cpu.h"
|
|
#include "sys/amd64/fpu.h"
|
|
#include "sys/config.h"
|
|
#include "sys/string.h"
|
|
#include "sys/assert.h"
|
|
#include "sys/panic.h"
|
|
#include "sys/debug.h"
|
|
#include "sys/sched.h"
|
|
#include "sys/time.h"
|
|
|
|
static multiboot_info_t *multiboot_info;
|
|
|
|
void kernel_main(struct amd64_loader_data *data) {
|
|
cpuid_init();
|
|
data = (struct amd64_loader_data *) MM_VIRTUALIZE(data);
|
|
multiboot_info = (multiboot_info_t *) MM_VIRTUALIZE(data->multiboot_info_ptr);
|
|
|
|
if (data->symtab_ptr) {
|
|
kinfo("Kernel symbol table at %p\n", MM_VIRTUALIZE(data->symtab_ptr));
|
|
debug_symbol_table_set(MM_VIRTUALIZE(data->symtab_ptr), MM_VIRTUALIZE(data->strtab_ptr), data->symtab_size, data->strtab_size);
|
|
}
|
|
|
|
// Parse kernel command line
|
|
kernel_set_cmdline(data->cmdline);
|
|
|
|
// Reinitialize RS232 properly
|
|
rs232_init(RS232_COM1);
|
|
|
|
amd64_phys_memory_map((multiboot_memory_map_t *) MM_VIRTUALIZE(multiboot_info->mmap_addr),
|
|
multiboot_info->mmap_length);
|
|
|
|
amd64_gdt_init();
|
|
amd64_idt_init(0);
|
|
amd64_mm_init(data);
|
|
|
|
amd64_acpi_init();
|
|
|
|
// Print kernel version now
|
|
kinfo("yggdrasil " KERNEL_VERSION_STR "\n");
|
|
|
|
amd64_apic_init();
|
|
|
|
syscall_init();
|
|
|
|
sched_init();
|
|
if (data->initrd_ptr) {
|
|
extern void sched_user_init(uintptr_t base);
|
|
sched_user_init(MM_VIRTUALIZE(data->initrd_ptr));
|
|
}
|
|
sched_enter();
|
|
|
|
panic("This code should not run\n");
|
|
}
|