diff options
Diffstat (limited to 'components/rust/core/src/panic.rs')
| -rw-r--r-- | components/rust/core/src/panic.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/components/rust/core/src/panic.rs b/components/rust/core/src/panic.rs new file mode 100644 index 0000000000..371f86fdb6 --- /dev/null +++ b/components/rust/core/src/panic.rs @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2006-2025, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2025-10-10 foxglove RT-Thread Panic implementation + */ +use crate::print; + +pub fn panic_on_atomic_context(s: &str) { + use crate::api::is_irq_context; + if is_irq_context() { + panic!("In irq context {}", s); + } +} + +#[panic_handler] +#[inline(never)] +fn panic(info: &core::panic::PanicInfo) -> ! { + print!("{:}", info); + __rust_panic() +} + +#[linkage = "weak"] +#[unsafe(no_mangle)] +fn __rust_panic() -> ! { + /* Default weak panic handler: loops forever to halt execution. */ + print!("Entered weak panic handler: system will halt."); + loop {} +} |
