summaryrefslogtreecommitdiff
path: root/kernel/main.c
blob: b687369e16b6b0e854865b61345b298a2a14a370 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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();
}