2023-02-08 13:07:44 +00:00
|
|
|
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#include "../lib/include/string.h"
|
2023-02-03 20:47:05 +00:00
|
|
|
}
|
2022-09-02 19:09:51 +00:00
|
|
|
|
|
|
|
#include "prekernel/bootstructure.h"
|
|
|
|
|
2023-02-08 13:07:44 +00:00
|
|
|
#include "memory/memory.h"
|
|
|
|
#include "memory/memoryinfo.h"
|
2023-02-03 20:47:05 +00:00
|
|
|
#include "memory/memory.h"
|
2022-09-02 19:09:51 +00:00
|
|
|
#include "memory/VirtualMemoryManager.h"
|
|
|
|
#include "memory/KernelHeap.h"
|
|
|
|
#include "memory/gdt/gdtc.h"
|
2023-02-11 11:22:45 +00:00
|
|
|
#include "memory/TaskStateSegment.h"
|
2022-09-02 19:09:51 +00:00
|
|
|
|
2023-02-08 13:07:44 +00:00
|
|
|
#include "supervisorterminal/superVisorTerminal.h"
|
|
|
|
|
2023-02-03 20:47:05 +00:00
|
|
|
#include "drivers/io/io.h"
|
2023-02-08 13:07:44 +00:00
|
|
|
#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"
|
|
|
|
#include "drivers/ide/ide.h"
|
2023-02-08 13:07:44 +00:00
|
|
|
|
|
|
|
#include "terminal/kterm.h"
|
|
|
|
|
|
|
|
#include "prekernel/multiboot.h"
|
|
|
|
#include "bootinfo.h"
|
|
|
|
|
|
|
|
#include "bootcheck.h"
|
|
|
|
|
2023-02-11 11:22:45 +00:00
|
|
|
#include "interrupts/idt.h"
|
2023-02-08 13:07:44 +00:00
|
|
|
#include "time.h"
|
2022-09-02 19:09:51 +00:00
|
|
|
#include "cpu.h"
|
|
|
|
#include "serial.h"
|
|
|
|
#include "time.h"
|
2023-02-08 13:07:44 +00:00
|
|
|
#include "definitions.h"
|
2023-02-13 21:44:47 +00:00
|
|
|
extern "C" void LoadGlobalDescriptorTable();
|
|
|
|
|
2022-09-02 19:09:51 +00:00
|
|
|
|
2023-02-08 13:07:44 +00:00
|
|
|
/*
|
|
|
|
Copyright © Nigel Barink 2023
|
|
|
|
*/
|
2022-09-02 19:09:51 +00:00
|
|
|
|
|
|
|
extern "C" void kernel_main ()
|
2022-08-22 19:16:34 +00:00
|
|
|
{
|
2022-09-02 19:09:51 +00:00
|
|
|
/*
|
|
|
|
* Show a little banner for cuteness
|
|
|
|
*/
|
|
|
|
printf("|=== BarinkOS ===|\n");
|
|
|
|
startSuperVisorTerminal();
|
|
|
|
}
|
2022-09-01 14:11:35 +00:00
|
|
|
|
2022-09-02 19:09:51 +00:00
|
|
|
extern "C" void early_main()
|
|
|
|
{
|
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
|
|
|
|
2022-09-02 23:00:17 +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");
|
|
|
|
|
2022-08-18 22:44:52 +00:00
|
|
|
// Enable interrupts
|
|
|
|
asm volatile("STI");
|
2023-02-11 11:22:45 +00:00
|
|
|
|
|
|
|
ACPI::initialize();
|
|
|
|
PCI_Enumerate();
|
|
|
|
|
|
|
|
TestIDEController();
|
|
|
|
|
2023-02-08 13:07:44 +00:00
|
|
|
initHeap();
|
2022-08-23 19:35:19 +00:00
|
|
|
|
2023-02-08 13:07:44 +00:00
|
|
|
printf("Enable Protected mode and jump to kernel main\n");
|
2023-02-13 21:44:47 +00:00
|
|
|
|
2022-08-23 19:35:19 +00:00
|
|
|
|
2023-02-08 13:07:44 +00:00
|
|
|
// Set the protected bit of control register 0
|
|
|
|
// this will put the CPU into protected mode
|
|
|
|
// NOTE: This should really be a assembly procedure
|
|
|
|
// We cant directly write to control register 0
|
|
|
|
// therefor we copy the value of control register 0 into eax
|
|
|
|
// once we are done manipulating the value we write the value in
|
|
|
|
// eax back to control register 0
|
2022-08-23 19:35:19 +00:00
|
|
|
|
2022-09-02 19:09:51 +00:00
|
|
|
asm volatile("mov %cr0, %eax ");
|
|
|
|
asm volatile("or $1, %eax");
|
2023-02-08 13:07:44 +00:00
|
|
|
asm volatile("mov %eax, %cr0");
|
2022-08-23 19:35:19 +00:00
|
|
|
|
2022-09-02 19:09:51 +00:00
|
|
|
pit_initialise();
|
2021-12-28 18:47:32 +00:00
|
|
|
|
2022-09-02 19:09:51 +00:00
|
|
|
kernel_main();
|
|
|
|
|
2022-02-26 19:44:16 +00:00
|
|
|
}
|