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)]
|
2022-11-22 08:42:26 +00:00
|
|
|
#![test_runner(jinux_frame::test_runner)]
|
2022-09-01 06:25:26 +00:00
|
|
|
#![reexport_test_harness_main = "test_main"]
|
2022-11-22 08:42:26 +00:00
|
|
|
extern crate jinux_frame;
|
2022-08-16 02:41:25 +00:00
|
|
|
|
|
|
|
|
use core::panic::PanicInfo;
|
2022-11-22 08:42:26 +00:00
|
|
|
use jinux_frame::println;
|
2022-08-16 02:41:25 +00:00
|
|
|
|
2023-03-06 06:19:23 +00:00
|
|
|
#[no_mangle]
|
2023-07-19 02:08:59 +00:00
|
|
|
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();
|
2022-11-22 08:42:26 +00:00
|
|
|
println!("[kernel] finish init jinux_frame");
|
2023-02-27 10:41:52 +00:00
|
|
|
component::init_all(component::parse_metadata!()).unwrap();
|
2023-07-19 02:08:59 +00:00
|
|
|
jinux_std::init();
|
2022-11-22 08:42:26 +00:00
|
|
|
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);
|
2022-12-26 12:33:27 +00:00
|
|
|
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) -> ! {
|
2022-11-22 08:42:26 +00:00
|
|
|
jinux_frame::test_panic_handler(info);
|
2022-09-01 06:25:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test_case]
|
|
|
|
|
fn trivial_assertion() {
|
|
|
|
|
assert_eq!(1, 1);
|
|
|
|
|
}
|