-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathlib.rs
More file actions
77 lines (57 loc) · 1.62 KB
/
lib.rs
File metadata and controls
77 lines (57 loc) · 1.62 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
//! This is the default kernel of the osiris operating system.
//! The kernel is organized as a microkernel.
#![cfg_attr(freestanding, no_std)]
#[macro_use]
mod macros;
#[macro_use]
mod error;
mod faults;
mod idle;
mod mem;
mod print;
mod types;
mod uspace;
mod sched;
mod sync;
mod syscalls;
mod time;
pub mod uapi;
use hal::Machinelike;
pub use hal;
pub use proc_macros::app_main;
/// The kernel initialization function.
///
/// # Safety
///
/// This function must be called only once during the kernel startup.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn kernel_init() -> ! {
// Initialize basic hardware and the logging system.
hal::Machine::init();
hal::Machine::bench_start();
print::print_header();
error!("Hello World!");
// Initialize the memory allocator.
let kaddr_space = mem::init_memory();
kprintln!("Memory initialized.");
sched::init(kaddr_space);
kprintln!("Scheduler initialized.");
idle::init();
kprintln!("Idle thread initialized.");
let (cyc, _ns) = hal::Machine::bench_end();
kprintln!("Kernel init took {} cycles.", cyc);
// Start the init application.
uspace::init_app();
sched::enable();
loop {}
}
pub fn panic(info: &core::panic::PanicInfo) -> ! {
kprintln!("**************************** PANIC ****************************");
kprintln!("");
kprintln!("Message: {}", info.message());
if let Some(location) = info.location() {
kprintln!("Location: {}:{}", location.file(), location.line());
}
kprintln!("**************************** PANIC ****************************");
hal::Machine::panic_handler(info);
}