aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrian Cully <bjc@kublai.com>2022-08-08 14:48:55 -0400
committerBrian Cully <bjc@kublai.com>2022-08-08 14:48:55 -0400
commit6afea5e58e47b345adaa0f556184f75599503521 (patch)
tree7105aa3ceb0618abd84b32e902a1be594e832052 /src
parent299d06dad9c4bfc8eef70271204a4f9f7379e5ce (diff)
downloadluchie-6afea5e58e47b345adaa0f556184f75599503521.tar.gz
luchie-6afea5e58e47b345adaa0f556184f75599503521.zip
log in panics if possible.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/main.rs33
1 files changed, 21 insertions, 12 deletions
diff --git a/src/main.rs b/src/main.rs
index 7fd2ba3..707feed 100755
--- a/src/main.rs
+++ b/src/main.rs
@@ -15,7 +15,10 @@ use gd32vf103xx_hal::{
time::Hertz,
timer::Timer,
};
-use riscv::asm::wfi;
+use riscv::{
+ asm::wfi,
+ interrupt,
+};
use riscv_rt::entry;
use led::LED;
@@ -71,28 +74,34 @@ fn main(_hartid: usize) -> ! {
#[export_name="ExceptionHandler"]
fn exception_handler(_frame: &riscv_rt::TrapFrame) -> ! {
- loop { unsafe { wfi() } };
+ spin();
}
#[export_name="DefaultHandler"]
fn default_handler() -> ! {
- loop { unsafe { wfi() } };
+ spin();
}
#[export_name="MachineTimer"]
fn machine_timer() {
- loop { unsafe { wfi() } };
+ spin();
}
#[panic_handler]
fn panic(info: &core::panic::PanicInfo) -> ! {
- if let Some(loc) = info.location() {
- let _file = loc.file();
- let _line = loc.line();
- if let Some(_msg) = info.payload().downcast_ref::<&str>() {
- loop {}
+ interrupt::free(|_cs| {
+ log!("!!! panic ");
+ if let Some(loc) = info.location() {
+ log!("in {}:{} ", loc.file(), loc.line());
}
- loop {}
- }
- loop {}
+ if let Some(msg) = info.payload().downcast_ref::<&str>() {
+ log!("⇒ {} ", msg);
+ }
+ logln!("!!!");
+ });
+ spin();
+}
+
+fn spin() -> ! {
+ loop { unsafe { wfi() } };
}