-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathkernel.c
More file actions
125 lines (91 loc) · 2.86 KB
/
Copy pathkernel.c
File metadata and controls
125 lines (91 loc) · 2.86 KB
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
118
119
120
121
122
123
124
125
#include "console/kio.h"
#include "console/serial/uart.h"
#include "graph/graphics.h"
#include "hw/hw.h"
#include "memory/talloc.h"
#include "pci.h"
#include "memory/mmu.h"
#include "exceptions/exception_handler.h"
#include "exceptions/irq.h"
#include "process/scheduler.h"
#include "filesystem/disk.h"
#include "kernel_processes/boot/bootprocess.h"
#include "usb/usb.h"
#include "networking/processes/net_proc.h"
#include "memory/page_allocator.h"
#include "networking/network.h"
#include "filesystem/filesystem.h"
#include "filesystem/modules/module_loader.h"
#include "audio/audio.h"
#include "mailbox/mailbox.h"
#include "math/vector.h"
#include "process/debug.h"
#include "theme/theme.h"
#include "tests/test_runner.h"
#include "pci/pcie.h"
#include "dtb.h"
#include "filesystem/tmp/tmp_fs.h"
#include "std/memory.h"
#include "utils/utils.h"
#include "tools/tools.h"
#include "process/environment/environment.h"
extern void trace();
extern char __bss_start[];
extern char __bss_end[];
void kernel_main(uint64_t board_type, uint64_t dtb_pa) {
memset(__bss_start, 0, (size_t)((uintptr_t)__bss_end - (uintptr_t)__bss_start));
BOARD_TYPE = (uint8_t)board_type;
dtb_set_pa(dtb_pa);
if (dtb_get_header()) USE_DTB = 1;
detect_hardware();
hw_high_va();
pre_talloc();
mmu_init();
if (BOARD_TYPE == 2) mailbox_init();
set_exception_vectors();
init_main_process();
// if (BOARD_TYPE == 1) disable_visual();
load_module(&console_module);
print_hardware();
irq_init();
kprintf("Interrupts initialized");
enable_interrupt();
load_module(&disk_module);
init_filesystem();
load_module(&theme_mod);
// if (!system_config.headless)
load_module(&graphics_module);
bool can_init_usb = true;
#if !QEMU
if (BOARD_TYPE == 2){
if (!init_hostbridge()) can_init_usb = false;
if (RPI_BOARD >= 5)
pci_setup_rp1();
}
#endif
bool usb_available = can_init_usb ? load_module(&usb_module) : false;
bool network_available = false;
bool audio_available = false;
if (BOARD_TYPE == 1){
if (system_config.use_net)
network_available = load_module(&net_module);
audio_available = load_module(&audio_module);
}
kprint("Kernel initialization finished");
kprint("Starting processes");
if (BOARD_TYPE == 1 && audio_available) init_audio_mixer();
debug_load();
#if TEST
if (!run_tests()) panic("Test run failed",0);
#endif
if (usb_available) init_usb_process();
if (network_available && system_config.use_net) launch_net_process();
init_bootprocess();
load_module(&tmp_mod);
load_module(&tool_module);
load_module(&scheduler_module);
load_module(&environment_module);
load_util_mods();
start_scheduler();
panic("Kernel did not activate any process", 0);
}