summaryrefslogtreecommitdiff
path: root/kernel/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/main.c')
-rw-r--r--kernel/main.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/kernel/main.c b/kernel/main.c
new file mode 100644
index 0000000..b687369
--- /dev/null
+++ b/kernel/main.c
@@ -0,0 +1,41 @@
+//To load GDT
+#include "GDT/gdt.h"
+#include "./Helpers/memprint.h"
+
+
+//----- PiegOS kernel main -----
+int main(){
+
+ //Welcome
+ memprint_print("Welcome to PiegOS");
+
+ //Infinite loop
+ while(1);
+
+ //Exit code
+ return 0;
+}
+
+
+//----- PiegOS kernel boot function -----
+void _boot(){
+
+ //Load GDT
+ 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();
+}
+