PiegOS/kernel/main.cpp

53 lines
917 B
C++
Raw Normal View History

2015-07-21 17:25:36 +04:00
//To load GDT
2015-07-20 16:34:46 +04:00
#include "GDT/gdt.hpp"
2015-07-22 13:22:53 +04:00
#include "./Helpers/memPrint.hpp"
2015-07-21 17:25:36 +04:00
2015-07-19 11:52:01 +04:00
2015-07-23 08:47:32 +04:00
//----- Global Definition -----
memPrint VideoRam; //Used to print data on screen
//-----------------------------
2015-07-19 11:20:21 +04:00
2015-07-22 19:45:08 +04:00
2015-07-23 08:47:32 +04:00
//----- PiegOS kernel main -----
int main(){
2015-07-22 19:45:08 +04:00
2015-07-23 08:47:32 +04:00
//Welcome
VideoRam.print("Welcome to PiegOS");
2015-07-22 13:22:53 +04:00
2015-07-21 16:53:10 +04:00
//Infinite loop
while(1);
//Exit code
return 0;
}
//----- PiegOS kernel boot -----
//Mangling the _boot function
extern "C" void _boot(){
2015-07-21 14:23:57 +04:00
//Create Gdt instance
Gdt gdt;
//Load Gdt into memory
2015-07-22 19:45:08 +04:00
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)
2015-07-21 16:53:10 +04:00
main();
2015-07-19 11:20:21 +04:00
}
2015-07-21 16:53:10 +04:00