mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-10 13:56:48 +00:00
45 lines
1.1 KiB
Rust
45 lines
1.1 KiB
Rust
#![no_std]
|
|
#![no_main]
|
|
#![feature(custom_test_frameworks)]
|
|
// 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)]
|
|
#![reexport_test_harness_main = "test_main"]
|
|
extern crate jinux_frame;
|
|
|
|
use core::panic::PanicInfo;
|
|
use jinux_frame::println;
|
|
|
|
#[no_mangle]
|
|
pub fn jinux_main() -> ! {
|
|
#[cfg(test)]
|
|
test_main();
|
|
jinux_frame::init();
|
|
println!("[kernel] finish init jinux_frame");
|
|
component::init_all(component::parse_metadata!()).unwrap();
|
|
jinux_std::init();
|
|
jinux_std::run_first_process();
|
|
}
|
|
|
|
#[cfg(not(test))]
|
|
#[panic_handler]
|
|
fn panic(info: &PanicInfo) -> ! {
|
|
use jinux_frame::{exit_qemu, QemuExitCode};
|
|
|
|
println!("[panic]:{:#?}", info);
|
|
jinux_frame::panic_handler();
|
|
exit_qemu(QemuExitCode::Failed);
|
|
}
|
|
|
|
#[cfg(test)]
|
|
#[panic_handler]
|
|
fn panic(info: &PanicInfo) -> ! {
|
|
jinux_frame::test_panic_handler(info);
|
|
}
|
|
|
|
#[test_case]
|
|
fn trivial_assertion() {
|
|
assert_eq!(1, 1);
|
|
}
|