forked from penberg/manticore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanticore.rs
59 lines (50 loc) · 1.22 KB
/
manticore.rs
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
//!
//! Manticore kernel.
//!
#![feature(lang_items)]
#![feature(alloc_error_handler)]
#![feature(panic_info_message)]
#![no_std]
#[macro_use]
extern crate kernel;
#[cfg(target_arch = "x86_64")]
extern crate pci;
#[cfg(target_arch = "x86_64")]
extern crate virtio;
use core::panic::PanicInfo;
use kernel::print;
extern "C" {
pub fn panic(msg: *const u8);
}
#[cfg(not(test))]
#[panic_handler]
#[no_mangle]
pub extern "C" fn panic_handler(info: &PanicInfo) -> ! {
let (file, line) = match info.location() {
Some(location) => (location.file(), location.line()),
None => ("<unknown>", 0),
};
if let Some(msg) = info.message() {
println!("Panic occurred at {}:{}: {}", file, line, msg);
} else {
println!("Panic occurred at {}:{}", file, line);
}
unsafe {
panic("Halting\0".as_ptr());
}
loop {}
}
#[cfg(not(test))]
#[alloc_error_handler]
#[no_mangle]
pub extern "C" fn oom(_: ::core::alloc::Layout) -> ! {
panic!("out of memory");
}
#[cfg(not(test))]
#[lang = "eh_personality"]
#[no_mangle]
pub extern "C" fn rust_eh_personality() {}
#[cfg(target_arch = "x86_64")]
pub use pci::pci_probe;
#[cfg(target_arch = "x86_64")]
pub use virtio::virtio_register_drivers;