52 lines
917 B
C++
52 lines
917 B
C++
//To load GDT
|
|
#include "GDT/gdt.hpp"
|
|
#include "./Helpers/memPrint.hpp"
|
|
|
|
|
|
//----- Global Definition -----
|
|
memPrint VideoRam; //Used to print data on screen
|
|
//-----------------------------
|
|
|
|
|
|
|
|
//----- PiegOS kernel main -----
|
|
int main(){
|
|
|
|
//Welcome
|
|
VideoRam.print("Welcome to PiegOS");
|
|
|
|
//Infinite loop
|
|
while(1);
|
|
|
|
//Exit code
|
|
return 0;
|
|
}
|
|
|
|
|
|
|
|
//----- PiegOS kernel boot -----
|
|
//Mangling the _boot function
|
|
extern "C" void _boot(){
|
|
|
|
//Create Gdt instance
|
|
Gdt gdt;
|
|
|
|
//Load Gdt into memory
|
|
gdt.loadGdt();
|
|
|
|
//Init all segments and stack
|
|
__asm__("\
|
|
movw $0x10, %ax; \n \
|
|
movw %ax, %ds; \n \
|
|
movw %ax, %es \n \
|
|
ljmp $0x08, $updateDS;\
|
|
updateDS: \n\
|
|
movw $0x18, %ax \n \
|
|
movw %ax, %ss \n \
|
|
movl $0x00B00000, %esp \n\
|
|
");
|
|
|
|
//Call main function after stack pointer changing (due to C++ optimisation)
|
|
main();
|
|
}
|
|
|