1#![no_std]
8#![no_main]
9#![feature(custom_test_frameworks)]
10#![test_runner(test_runner)]
11#![reexport_test_harness_main = "test_main"]
12
13extern crate alloc;
14
15mod arch;
16mod config;
17mod device;
18mod fs;
19mod ipc;
20mod kernel;
21mod mm;
22mod security;
23mod sync;
24mod test;
25mod uapi;
26mod util;
27mod vfs;
28#[macro_use]
29mod log;
30mod net;
31
32use crate::arch::lib::sbi::shutdown;
33use core::arch::{asm, global_asm};
34use core::panic::PanicInfo;
35#[cfg(test)]
36use test::test_runner;
37#[cfg(target_arch = "riscv64")]
38global_asm!(include_str!("./arch/riscv/boot/entry.S"));
39
40#[unsafe(no_mangle)]
50pub extern "C" fn rust_main(_hartid: usize) -> ! {
51 arch::boot::main(_hartid);
52 unreachable!("Unreachable in rust_main()");
53}
54
55#[panic_handler]
56fn panic(info: &PanicInfo) -> ! {
57 if let Some(location) = info.location() {
58 earlyprintln!(
59 "Panicked at {}:{} {}",
60 location.file(),
61 location.line(),
62 info.message()
63 );
64 } else {
65 earlyprintln!("Panicked: {}", info.message());
66 }
67
68 #[cfg(target_arch = "loongarch64")]
70 {
71 loop {
72 unsafe { asm!("idle 0") }
73 }
74 }
75
76 #[cfg(not(target_arch = "loongarch64"))]
78 shutdown(true)
79}