blob: bc5bae8e31cf2c66a26ac5b2ed43bcf0b1743991 (
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
|
#include <stdbool.h>
#include <smp.h>
#include <klog.h>
#include <printf.h>
#include <paging.h>
#include <video.h>
#include <acpi.h>
#include <panic.h>
#include <addr.h>
#include <stdbool.h>
#include <int.h>
#include <io.h>
#include <cpuid.h>
#include <heap.h>
#include <random.h>
#include <timer.h>
#include <libc.h>
#include <smp.h>
//testing headers
#include <smp_racetest.h>
void kmain() {
printf("Kernal started on core %i\n", get_coreid());
racetest();
PANIC(KERNEL_PANIC_KERNEL_RETURNED);
}
static bool smp_unlocked = false;
void smp_kinit() {
asm(".wait_for_release:\n"
"mov al, [%0]\n"
"test al, al\n"
"jz .wait_for_release\n"
::"m"(smp_unlocked));
smp_load_idt();
kmain();
}
//TODO move to global constructors
void kernel_init() {
size_t pmap_size;
get_mem_capabilities();
pmap_size = map_complete_physical();
init_klog();
init_pmap(pmap_size);
printf("\nKernal started on core 1!\n");
find_root_sdp();
debug_acpi();
init_interrupts_bsp();
randinit();
clear_screen();
debug_pzone();
smp_prepare();
//the rest of this needs to get done before the cores start executing
init_pmap_smp();
smp_unlocked = true;
fix_stack();
unmap_lowmem();
kmain();
}
|