BarinkOS/source/kernel/kernel.cpp
Nigel b07b4f0d38 Moving certain aspects into their own static library
Problem:
	As our kernel grows we need more complex datastructures and functions these would come from
	the standard C/C++ library with normal programs.
	The kernel is a freestanding programme and has no access to standard libraries.

Solution:
	We build a mini version of the standard C/C++ library which will contain the
	datastructures and functions we want. This library can then be statically linked
	into our kernel binary.

	Making it a statically linked library also gives more structure to the project.
	Keeping these random functions and datastructures in the kernel just clutters the
	kernel source code with less relevant source code.
2023-02-19 23:38:32 +01:00

59 lines
1.2 KiB
C++

/*
Copyright © Nigel Barink 2023
*/
#include "memory/memory.h"
#include "memory/KernelHeap.h"
#include "memory/gdt/gdtc.h"
#include "memory/TaskStateSegment.h"
#include "supervisorterminal/superVisorTerminal.h"
#include "drivers/vga/VBE.h"
#include "drivers/pci/pci.h"
#include "drivers/pit/pit.h"
#include "drivers/acpi/acpi.h"
#include "i386/processor.h"
#include "terminal/kterm.h"
#include "interrupts/idt.h"
#include "serial.h"
#include "vfs/VFS.h"
extern "C" void LoadGlobalDescriptorTable();
extern "C" void jump_usermode();
extern "C" void kernel ()
{
init_serial();
kterm_init();
setup_tss();
initGDT();
initidt();
LoadGlobalDescriptorTable();
flush_tss();
printf("Memory setup complete!\n");
// Enable interrupts
asm volatile("STI");
initHeap();
pit_initialise();
// ACPI::initialize(); // FIXME: improper reading of bios memory
PCI::Scan();
processor::initialize();
processor::enable_protectedMode();
FileSystem::initialize();
// Testing my path resolution functions
Path test = Path("/boot/myos.bin");
FileSystem::ResolvePath(test);
#ifdef USERMODE_RELEASE
// Lets jump into user mode
jump_usermode();
#else
startSuperVisorTerminal();
#endif
}