-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkernel.c
69 lines (52 loc) · 1.39 KB
/
kernel.c
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <gdt.h>
#include <interrupt_handler.h>
#include <liballoc.h>
#include <linker_symbols.h>
#include <multiboot.h>
#include <paging.h>
#include <stack_protector.h>
#include <stdio.h>
void k_main(multiboot_info_t* multi_data __attribute__ ((unused)), unsigned int magic)
{
if(magic != MULTIBOOT_BOOTLOADER_MAGIC)
{
print("Non Multiboot-compliant boot loader.\nHalting.\n");
return;
}
clear_screen();
//print("Gestalt OS v 0.0.1 beta booting.\n\n");
print("Gestalt OS initial build\n");
print("\nSegmentation:\n");
if(init_gdt())
print("- GDT initialised.\n");
else
{
clear_screen();
print("Error, segmentation initialisation failed.\nHalting.\n");
return;
}
enable_segmentation();
print("- GDT loaded.\n");
if(set_segment_registers(k_text, k_data))
print("- Segment registers updated\n");
else
{
clear_screen();
print("Error: Invalid segment descriptor offsets.\nHalting.\n");
return;
}
print("\nPaging:\n");
if(!setup_paging(multi_data)) {
print("Error: Paging initialization failure.\nHalting.\n");
return;
}
print("Interrupts:\n");
install_ints();
print("- Interrupt system initialised.\n\n");
print("Allocation test:\n");
void* test = malloc(100);
print("- Address returned: %h\n", (unsigned long)test);
free(test);
print("- Memory freed\n");
return;
}