-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathlib.rs
More file actions
87 lines (65 loc) · 1.88 KB
/
Copy pathlib.rs
File metadata and controls
87 lines (65 loc) · 1.88 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
//! 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 error;
mod faults;
mod idle;
mod irq;
mod mem;
#[macro_use]
mod print;
mod types;
mod uspace;
mod sched;
mod sync;
mod syscalls;
mod time;
#[cfg(any(feature = "metrics", metrics))]
pub mod metrics;
// Public, for now.
pub mod drivers;
pub mod uapi;
pub use hal_cortex_m::*;
// Add new hals here. No cfg needed.
pub use hal::Machinelike;
pub use hal_api::error::*;
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::init_irqs(irq::register_irq_safe);
hal::Machine::bench_start();
print::print_header();
// Initialize the memory allocator.
let kaddr_space = mem::init_memory();
kprint!("Memory initialized.\n");
drivers::init();
kprint!("Drivers initialized.\n");
sched::init(kaddr_space);
kprint!("Scheduler initialized.\n");
idle::init();
kprint!("Idle thread initialized.\n");
let (cyc, _ns) = hal::Machine::bench_end();
kprint!("Kernel init took {} cycles.\n", cyc);
// Start the init application.
uspace::init_app();
sched::enable();
loop {}
}
pub fn panic(info: &core::panic::PanicInfo) -> ! {
kprint!("**************************** PANIC ****************************\n");
kprint!("\n");
kprint!("Message: {}\n", info.message());
if let Some(location) = info.location() {
kprint!("Location: {}:{}\n", location.file(), location.line());
}
kprint!("**************************** PANIC ****************************\n");
hal::Machine::panic_handler(info);
}