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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
#include <arch/x86_64/syscalls/syscalls.hpp>
#include <arch/x86_64/syscalls/sockets.hpp>
#include <arch/x86_64/interrupts/idt.hpp>
#include <arch/x86_64/interrupts/irq.hpp>
#include <arch/x86_64/interrupts/pic.hpp>
#include <arch/x86_64/interrupts/pit.hpp>
#include <arch/x86_64/scheduling.hpp>
#include <arch/x86_64/cpu/lapic.hpp>
#include <arch/x86_64/cpu/gdt.hpp>
#include <arch/x86_64/cpu/smp.hpp>
#include <arch/x86_64/cpu/sse.hpp>
#include <generic/mm/paging.hpp>
#include <generic/vfs/ustar.hpp>
#include <drivers/kvmtimer.hpp>
#include <generic/vfs/vfs.hpp>
#include <generic/mm/heap.hpp>
#include <generic/mm/pmm.hpp>
#include <drivers/serial.hpp>
#include <drivers/cmos.hpp>
#include <drivers/acpi.hpp>
#include <etc/assembly.hpp>
#include <drivers/tsc.hpp>
#include <etc/logging.hpp>
#include <uacpi/event.h>
#include <etc/etc.hpp>
#include <limine.h>
#include <generic/locks/spinlock.hpp>
std::uint16_t KERNEL_GOOD_TIMER = 0;
static uacpi_interrupt_ret handle_power_button(uacpi_handle ctx) {
Log::Display(LEVEL_MESSAGE_OK,"Got uacpi power_button !\n");
return UACPI_INTERRUPT_HANDLED;
}
extern "C" void main() {
Other::ConstructorsInit();
asm volatile("cli");
drivers::serial serial(DEFAULT_SERIAL_PORT);
Log::Init();
__wrmsr(0xC0000101,0);
memory::pmm::_physical::init();
Log::Display(LEVEL_MESSAGE_OK,"PMM Initializied\n");
memory::heap::init();
Log::Display(LEVEL_MESSAGE_OK,"Heap initializied\n");
memory::paging::init();
Log::Display(LEVEL_MESSAGE_OK,"Paging initializied\n");
arch::x86_64::cpu::gdt::init();
Log::Display(LEVEL_MESSAGE_OK,"GDT initializied\n");
arch::x86_64::interrupts::idt::init();
Log::Display(LEVEL_MESSAGE_OK,"IDT initializied\n");
arch::x86_64::interrupts::pic::init();
Log::Display(LEVEL_MESSAGE_OK,"PIC initializied\n");
drivers::kvmclock::init();
drivers::acpi::init();
Log::Display(LEVEL_MESSAGE_OK,"ACPI initializied\n");
vfs::vfs::init();
Log::Display(LEVEL_MESSAGE_OK,"VFS initializied\n");
Log::Display(LEVEL_MESSAGE_INFO,"Loading initrd\n");
vfs::ustar::copy();
Log::Display(LEVEL_MESSAGE_OK,"USTAR parsed\n");
arch::x86_64::cpu::sse::init();
Log::Display(LEVEL_MESSAGE_OK,"SSE initializied\n");
arch::x86_64::cpu::mp::init();
arch::x86_64::cpu::mp::sync(0);
Log::Display(LEVEL_MESSAGE_OK,"SMP initializied\n");
arch::x86_64::scheduling::init();
Log::Display(LEVEL_MESSAGE_OK,"Scheduling initializied\n");
arch::x86_64::syscall::init();
Log::Display(LEVEL_MESSAGE_OK,"Syscalls initializied\n");
sockets::init();
Log::Display(LEVEL_MESSAGE_OK,"Sockets initializied\n");
uacpi_status ret = uacpi_install_fixed_event_handler(
UACPI_FIXED_EVENT_POWER_BUTTON,
handle_power_button, UACPI_NULL
);
char* argv[] = {0};
char* envp[] = {"TERM=linux",0};
arch::x86_64::process_t* init = arch::x86_64::scheduling::create();
arch::x86_64::scheduling::loadelf(init,"/usr/bin/init",argv,envp,0);
arch::x86_64::scheduling::wakeup(init);
Log::Display(LEVEL_MESSAGE_INFO,"Trying to sync cpus...\n");
arch::x86_64::cpu::mp::sync(1);
Log::Display(LEVEL_MESSAGE_FAIL,"\e[1;1H\e[2J");
asm volatile("sti");
while(1) {
asm volatile("hlt");
}
}
|