57 lines
1.1 KiB
C++
57 lines
1.1 KiB
C++
#include "startup.h"
|
|
|
|
#include "../arch/acpi.h"
|
|
#include "../arch/apic.h"
|
|
#include "../arch/core.h"
|
|
#include "../arch/idt.h"
|
|
#include "../arch/pic.h"
|
|
#include "../compiler/libc.h"
|
|
#include "../debug/output.h"
|
|
#include "../interrupt/handlers.h"
|
|
#include "../memory/pageframealloc.h"
|
|
extern "C" [[noreturn]] void kernel_init() {
|
|
// Setup and load Interrupt Description Table (IDT)
|
|
initInterruptHandlers();
|
|
|
|
// Initialize PICs
|
|
PIC::initialize();
|
|
|
|
PageFrameAllocator::init();
|
|
|
|
// Call global constructors
|
|
CSU::initializer();
|
|
|
|
//Select 5th Segment in GDT. 5<<3 == 0x28
|
|
asm volatile ("mov $0x28, %ax");
|
|
asm("ltr %ax");
|
|
|
|
// Initialize ACPI
|
|
if (!ACPI::init()) {
|
|
DBG_VERBOSE << "No ACPI!";
|
|
Core::die();
|
|
}
|
|
|
|
// Initialize APIC (using ACPI)
|
|
if (!APIC::init()) {
|
|
DBG_VERBOSE << "APIC Initialization failed";
|
|
Core::die();
|
|
}
|
|
|
|
// Initialize the Bootstrap Processor
|
|
Core::init();
|
|
|
|
// Go to main function
|
|
main();
|
|
|
|
// Exit CPU
|
|
DBG_VERBOSE << "CPU core " << Core::getID() << " (BSP) shutdown." << endl;
|
|
Core::exit();
|
|
// Call global destructors
|
|
CSU::finalizer();
|
|
|
|
// wait forever
|
|
while (true) {
|
|
Core::die();
|
|
}
|
|
}
|