blob: bf754ebfd769102dfcede6b97b1548abf784066e (
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
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
|
#include "acpi.hpp"
#include "gdt.hpp"
#include "idt.hpp"
#include "memory.hpp"
#include "multiboot.hpp"
#include "pic.hpp"
#include "pit.hpp"
#include "tasking.hpp"
#include "vgaterminal.hpp"
static VGATerminal vga;
TextOutput& term = vga;
static volatile bool termBusy = false;
void kernel_main(void)
{
term.write("Clyne's kernel, v2024\n\n");
if (!multiboot_initialize())
for (;;);
idt_register_callback(14, [](auto& regs) {
term.write("Page fault! eip=");
term.write(regs.eip);
term.write('\n');
for (;;);
});
acpi_initialize();
memory_initialize();
gdt_initialize();
pic_initialize();
idt_initialize();
pit_initialize();
asm volatile("sti");
tasking_initialize();
term.write("Tasking enabled.\n");
tasking_spawn([] {
for (;;) {
do pit_delay_ms(1);
while (termBusy);
termBusy = true;
term.write('B');
termBusy = false;
}
}, 256);
tasking_spawn([] {
for (;;) {
do pit_delay_ms(1);
while (termBusy);
termBusy = true;
term.write('C');
termBusy = false;
}
}, 256);
for (;;) {
do pit_delay_ms(1);
while (termBusy);
termBusy = true;
term.write('A');
termBusy = false;
}
}
extern "C"
void memmove(char* dst, char* src, size_t sz) {
while (sz) {
*dst = *src;
++dst;
++src;
--sz;
}
}
|