asterinas/kernel/main.rs

45 lines
1.1 KiB
Rust
Raw Normal View History

2022-08-16 02:41:25 +00:00
#![no_std]
#![no_main]
#![feature(custom_test_frameworks)]
2023-03-06 06:19:23 +00:00
// The no_mangle macro need to remove the `forbid(unsafe_code)` macro. The bootloader needs the _start function
// to be no mangle so that it can jump into the entry point.
// #![forbid(unsafe_code)]
#![test_runner(jinux_frame::test_runner)]
2022-09-01 06:25:26 +00:00
#![reexport_test_harness_main = "test_main"]
extern crate jinux_frame;
2022-08-16 02:41:25 +00:00
use core::panic::PanicInfo;
use jinux_frame::println;
2022-08-16 02:41:25 +00:00
2023-03-06 06:19:23 +00:00
#[no_mangle]
pub fn jinux_main() -> ! {
2022-09-01 06:25:26 +00:00
#[cfg(test)]
test_main();
2023-03-06 06:19:23 +00:00
jinux_frame::init();
println!("[kernel] finish init jinux_frame");
2023-02-27 10:41:52 +00:00
component::init_all(component::parse_metadata!()).unwrap();
jinux_std::init();
jinux_std::run_first_process();
2022-08-16 02:41:25 +00:00
}
2023-05-24 10:03:41 +00:00
2022-09-01 06:25:26 +00:00
#[cfg(not(test))]
2022-08-16 02:41:25 +00:00
#[panic_handler]
2022-09-01 06:25:26 +00:00
fn panic(info: &PanicInfo) -> ! {
2023-07-05 06:08:58 +00:00
use jinux_frame::{exit_qemu, QemuExitCode};
2022-09-01 06:25:26 +00:00
println!("[panic]:{:?}", info);
jinux_frame::panic_handler();
2023-07-05 06:08:58 +00:00
exit_qemu(QemuExitCode::Failed);
2022-08-16 02:41:25 +00:00
}
2022-09-01 06:25:26 +00:00
#[cfg(test)]
#[panic_handler]
fn panic(info: &PanicInfo) -> ! {
jinux_frame::test_panic_handler(info);
2022-09-01 06:25:26 +00:00
}
#[test_case]
fn trivial_assertion() {
assert_eq!(1, 1);
}