panic.rs 726 B

1234567891011121314151617181920212223242526272829303132
  1. /*
  2. * Copyright (c) 2006-2025, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2025-10-10 foxglove RT-Thread Panic implementation
  9. */
  10. use crate::print;
  11. pub fn panic_on_atomic_context(s: &str) {
  12. use crate::api::is_irq_context;
  13. if is_irq_context() {
  14. panic!("In irq context {}", s);
  15. }
  16. }
  17. #[panic_handler]
  18. #[inline(never)]
  19. fn panic(info: &core::panic::PanicInfo) -> ! {
  20. print!("{:}", info);
  21. __rust_panic()
  22. }
  23. #[linkage = "weak"]
  24. #[no_mangle]
  25. fn __rust_panic() -> ! {
  26. /* Default weak panic handler: loops forever to halt execution. */
  27. print!("Entered weak panic handler: system will halt.");
  28. loop {}
  29. }