forked from M-Labs/artiq
runtime: add an option to reboot after a panic.
This commit is contained in:
parent
80c75ed505
commit
c586035caa
@ -1,6 +1,16 @@
|
|||||||
use irq;
|
use irq;
|
||||||
|
|
||||||
pub unsafe fn run(new_code: &[u8]) -> ! {
|
pub unsafe fn reboot() -> ! {
|
||||||
|
irq::set_ie(false);
|
||||||
|
#[cfg(target_arch="or1k")]
|
||||||
|
asm!(r#"
|
||||||
|
l.j _ftext
|
||||||
|
l.nop
|
||||||
|
"# : : : : "volatile");
|
||||||
|
loop {}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub unsafe fn hotswap(new_code: &[u8]) -> ! {
|
||||||
irq::set_ie(false);
|
irq::set_ie(false);
|
||||||
#[cfg(target_arch="or1k")]
|
#[cfg(target_arch="or1k")]
|
||||||
asm!(r#"
|
asm!(r#"
|
@ -35,7 +35,7 @@ mod ad9154_reg;
|
|||||||
#[cfg(has_ad9154)]
|
#[cfg(has_ad9154)]
|
||||||
pub mod ad9154;
|
pub mod ad9154;
|
||||||
|
|
||||||
pub mod hotswap;
|
pub mod boot;
|
||||||
|
|
||||||
#[cfg(feature = "uart_console")]
|
#[cfg(feature = "uart_console")]
|
||||||
pub use uart_console::Console;
|
pub use uart_console::Console;
|
||||||
|
@ -28,10 +28,3 @@ macro_rules! println {
|
|||||||
($fmt:expr) => (print!(concat!($fmt, "\n")));
|
($fmt:expr) => (print!(concat!($fmt, "\n")));
|
||||||
($fmt:expr, $($arg:tt)*) => (print!(concat!($fmt, "\n"), $($arg)*));
|
($fmt:expr, $($arg:tt)*) => (print!(concat!($fmt, "\n"), $($arg)*));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
|
||||||
#[lang = "panic_fmt"]
|
|
||||||
pub extern fn panic_fmt(args: fmt::Arguments, file: &'static str, line: u32) -> ! {
|
|
||||||
println!("panic at {}:{}: {}", file, line, args);
|
|
||||||
loop {}
|
|
||||||
}
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#![no_std]
|
#![no_std]
|
||||||
#![feature(compiler_builtins_lib, repr_simd, const_fn)]
|
#![feature(compiler_builtins_lib, repr_simd, lang_items, const_fn)]
|
||||||
|
|
||||||
extern crate compiler_builtins;
|
extern crate compiler_builtins;
|
||||||
extern crate cslice;
|
extern crate cslice;
|
||||||
@ -169,6 +169,19 @@ pub extern fn abort() {
|
|||||||
panic!("aborted")
|
panic!("aborted")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
#[lang = "panic_fmt"]
|
||||||
|
pub extern fn panic_fmt(args: core::fmt::Arguments, file: &'static str, line: u32) -> ! {
|
||||||
|
println!("panic at {}:{}: {}", file, line, args);
|
||||||
|
|
||||||
|
if config::read_str("panic_reboot", |r| r == Ok("1")) {
|
||||||
|
println!("rebooting...");
|
||||||
|
unsafe { board::boot::reboot() }
|
||||||
|
} else {
|
||||||
|
loop {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Allow linking with crates that are built as -Cpanic=unwind even if we use -Cpanic=abort.
|
// Allow linking with crates that are built as -Cpanic=unwind even if we use -Cpanic=abort.
|
||||||
// This is never called.
|
// This is never called.
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
|
@ -274,7 +274,7 @@ fn process_host_message(io: &Io,
|
|||||||
host_write(stream, host::Reply::HotswapImminent)?;
|
host_write(stream, host::Reply::HotswapImminent)?;
|
||||||
stream.close()?;
|
stream.close()?;
|
||||||
warn!("hotswapping firmware");
|
warn!("hotswapping firmware");
|
||||||
unsafe { board::hotswap::run(&binary) }
|
unsafe { board::boot::hotswap(&binary) }
|
||||||
}
|
}
|
||||||
|
|
||||||
// artiq_run/artiq_master
|
// artiq_run/artiq_master
|
||||||
|
Loading…
Reference in New Issue
Block a user