-
Notifications
You must be signed in to change notification settings - Fork 0
/
kern.c
45 lines (35 loc) · 1.36 KB
/
kern.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
#include "exception.h"
#include "irq.h"
#include "syscall.h"
#include "task.h"
#include "task_queue.h"
#include "timer.h"
#include "uart.h"
#include "user/init_task.h"
#define SVC(code) asm volatile("svc %0" : : "I"(code))
static const uint64_t SVC_EXCEPTION_INFO = 0x54000000;
const char *train =
" oooOOOOOOOOOOO \r\n"
" o ____ :::::::::::::::::: :::::::::::::::::: __|-----|__ \r\n"
" Y_,_|[]| --++++++ |[][][][][][][][]| |[][][][][][][][]| | [] [] | \r\n"
" {|_|_|__|;|______|;|________________|;|________________|;|_________|; \r\n"
" /oo--OO oo oo oo oo oo oo oo oo oo oo oo oo \r\n"
"+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\r\n";
// return back to user mode
extern void kern_exit();
int kmain() {
uart_config_and_enable(UART_CONSOLE, 115200, false, true, false);
uart_init();
uart_puts(UART_CONSOLE, train);
uart_puts(UART_CONSOLE, "Booting...\r\n");
irq_init();
timer_init();
tasks_init();
task_queues_init();
struct TaskDescriptor *task = task_create(NULL, 0, init_task);
// schedule initial task
task_schedule(task);
// fake exception to start first task
handle_exception(SVC_EXCEPTION_INFO | SYSCALL_INIT);
return 0;
}