2023-02-17 13:42:42 +00:00
|
|
|
/*
|
|
|
|
Copyright © Nigel Barink 2023
|
|
|
|
*/
|
2023-02-03 20:47:05 +00:00
|
|
|
#include "memory/memory.h"
|
2022-09-02 19:09:51 +00:00
|
|
|
#include "memory/KernelHeap.h"
|
|
|
|
#include "memory/gdt/gdtc.h"
|
2023-02-11 11:22:45 +00:00
|
|
|
#include "memory/TaskStateSegment.h"
|
2023-02-08 13:07:44 +00:00
|
|
|
#include "supervisorterminal/superVisorTerminal.h"
|
|
|
|
#include "drivers/vga/VBE.h"
|
2023-02-03 20:47:05 +00:00
|
|
|
#include "drivers/pci/pci.h"
|
2023-02-08 13:07:44 +00:00
|
|
|
#include "drivers/pit/pit.h"
|
2023-02-11 11:22:45 +00:00
|
|
|
#include "drivers/acpi/acpi.h"
|
2023-02-17 15:27:36 +00:00
|
|
|
#include "i386/processor.h"
|
2023-02-08 13:07:44 +00:00
|
|
|
#include "terminal/kterm.h"
|
2023-02-11 11:22:45 +00:00
|
|
|
#include "interrupts/idt.h"
|
2022-09-02 19:09:51 +00:00
|
|
|
#include "serial.h"
|
2023-02-17 20:52:03 +00:00
|
|
|
#include "vfs/VFS.h"
|
2023-02-17 15:27:36 +00:00
|
|
|
|
2023-02-13 21:44:47 +00:00
|
|
|
extern "C" void LoadGlobalDescriptorTable();
|
2023-02-17 13:46:44 +00:00
|
|
|
extern "C" void jump_usermode();
|
2023-02-13 21:44:47 +00:00
|
|
|
|
2023-02-17 13:42:42 +00:00
|
|
|
extern "C" void kernel ()
|
2022-09-02 19:09:51 +00:00
|
|
|
{
|
2023-02-17 13:42:42 +00:00
|
|
|
|
2022-08-17 23:26:49 +00:00
|
|
|
init_serial();
|
2022-09-02 19:09:51 +00:00
|
|
|
kterm_init();
|
2023-02-11 11:22:45 +00:00
|
|
|
|
2023-02-13 21:44:47 +00:00
|
|
|
setup_tss();
|
2022-09-02 19:09:51 +00:00
|
|
|
initGDT();
|
2023-02-11 11:22:45 +00:00
|
|
|
initidt();
|
2023-02-13 21:44:47 +00:00
|
|
|
LoadGlobalDescriptorTable();
|
|
|
|
flush_tss();
|
|
|
|
printf("Memory setup complete!\n");
|
2023-02-17 13:42:42 +00:00
|
|
|
|
2022-08-18 22:44:52 +00:00
|
|
|
// Enable interrupts
|
|
|
|
asm volatile("STI");
|
2023-02-11 11:22:45 +00:00
|
|
|
|
2023-02-17 20:52:03 +00:00
|
|
|
initHeap();
|
2023-02-17 13:42:42 +00:00
|
|
|
pit_initialise();
|
2023-02-17 20:52:03 +00:00
|
|
|
// ACPI::initialize(); // FIXME: improper reading of bios memory
|
2023-02-17 13:42:42 +00:00
|
|
|
PCI::Scan();
|
2023-02-17 15:27:36 +00:00
|
|
|
processor::initialize();
|
2023-02-17 21:01:32 +00:00
|
|
|
processor::enable_protectedMode();
|
2022-08-23 19:35:19 +00:00
|
|
|
|
2023-02-17 21:01:32 +00:00
|
|
|
FileSystem::initialize();
|
2022-08-23 19:35:19 +00:00
|
|
|
|
2023-02-19 21:14:58 +00:00
|
|
|
// Testing my path resolution functions
|
|
|
|
Path test = Path("/boot/myos.bin");
|
|
|
|
FileSystem::ResolvePath(test);
|
|
|
|
|
2022-08-23 19:35:19 +00:00
|
|
|
|
2023-02-17 13:46:44 +00:00
|
|
|
#ifdef USERMODE_RELEASE
|
|
|
|
// Lets jump into user mode
|
|
|
|
jump_usermode();
|
|
|
|
#else
|
|
|
|
startSuperVisorTerminal();
|
|
|
|
#endif
|
2021-12-28 18:47:32 +00:00
|
|
|
|
2023-02-17 13:42:42 +00:00
|
|
|
}
|