forked from M-Labs/artiq
firmware: remove obsolete watchdog code (#1458)
This commit is contained in:
parent
6af8655cc7
commit
90017da484
|
@ -121,9 +121,6 @@ static mut API: &'static [(&'static str, *const ())] = &[
|
||||||
|
|
||||||
api!(now = csr::rtio::NOW_HI_ADDR as *const _),
|
api!(now = csr::rtio::NOW_HI_ADDR as *const _),
|
||||||
|
|
||||||
api!(watchdog_set = ::watchdog_set),
|
|
||||||
api!(watchdog_clear = ::watchdog_clear),
|
|
||||||
|
|
||||||
api!(rpc_send = ::rpc_send),
|
api!(rpc_send = ::rpc_send),
|
||||||
api!(rpc_send_async = ::rpc_send_async),
|
api!(rpc_send_async = ::rpc_send_async),
|
||||||
api!(rpc_recv = ::rpc_recv),
|
api!(rpc_recv = ::rpc_recv),
|
||||||
|
|
|
@ -200,21 +200,6 @@ fn terminate(exception: &eh_artiq::Exception, backtrace: &mut [usize]) -> ! {
|
||||||
loop {}
|
loop {}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[unwind(allowed)]
|
|
||||||
extern fn watchdog_set(ms: i64) -> i32 {
|
|
||||||
if ms < 0 {
|
|
||||||
raise!("ValueError", "cannot set a watchdog with a negative timeout")
|
|
||||||
}
|
|
||||||
|
|
||||||
send(&WatchdogSetRequest { ms: ms as u64 });
|
|
||||||
recv!(&WatchdogSetReply { id } => id) as i32
|
|
||||||
}
|
|
||||||
|
|
||||||
#[unwind(aborts)]
|
|
||||||
extern fn watchdog_clear(id: i32) {
|
|
||||||
send(&WatchdogClear { id: id as usize })
|
|
||||||
}
|
|
||||||
|
|
||||||
#[unwind(aborts)]
|
#[unwind(aborts)]
|
||||||
extern fn cache_get(key: CSlice<u8>) -> CSlice<'static, i32> {
|
extern fn cache_get(key: CSlice<u8>) -> CSlice<'static, i32> {
|
||||||
send(&CacheGetRequest {
|
send(&CacheGetRequest {
|
||||||
|
|
|
@ -52,10 +52,6 @@ pub enum Message<'a> {
|
||||||
},
|
},
|
||||||
RunAborted,
|
RunAborted,
|
||||||
|
|
||||||
WatchdogSetRequest { ms: u64 },
|
|
||||||
WatchdogSetReply { id: usize },
|
|
||||||
WatchdogClear { id: usize },
|
|
||||||
|
|
||||||
RpcSend {
|
RpcSend {
|
||||||
async: bool,
|
async: bool,
|
||||||
service: u32,
|
service: u32,
|
||||||
|
|
|
@ -105,7 +105,6 @@ pub enum Reply<'a> {
|
||||||
|
|
||||||
RpcRequest { async: bool },
|
RpcRequest { async: bool },
|
||||||
|
|
||||||
WatchdogExpired,
|
|
||||||
ClockFailure,
|
ClockFailure,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,9 +190,6 @@ impl<'a> Reply<'a> {
|
||||||
writer.write_u8(async as u8)?;
|
writer.write_u8(async as u8)?;
|
||||||
},
|
},
|
||||||
|
|
||||||
Reply::WatchdogExpired => {
|
|
||||||
writer.write_u8(14)?;
|
|
||||||
},
|
|
||||||
Reply::ClockFailure => {
|
Reply::ClockFailure => {
|
||||||
writer.write_u8(15)?;
|
writer.write_u8(15)?;
|
||||||
},
|
},
|
||||||
|
|
|
@ -53,7 +53,6 @@ mod mgmt;
|
||||||
mod profiler;
|
mod profiler;
|
||||||
mod kernel;
|
mod kernel;
|
||||||
mod kern_hwreq;
|
mod kern_hwreq;
|
||||||
mod watchdog;
|
|
||||||
mod session;
|
mod session;
|
||||||
#[cfg(any(has_rtio_moninj, has_drtio))]
|
#[cfg(any(has_rtio_moninj, has_drtio))]
|
||||||
mod moninj;
|
mod moninj;
|
||||||
|
|
|
@ -11,7 +11,6 @@ use rtio_clocking;
|
||||||
use rtio_dma::Manager as DmaManager;
|
use rtio_dma::Manager as DmaManager;
|
||||||
use cache::Cache;
|
use cache::Cache;
|
||||||
use kern_hwreq;
|
use kern_hwreq;
|
||||||
use watchdog::WatchdogSet;
|
|
||||||
use board_artiq::drtio_routing;
|
use board_artiq::drtio_routing;
|
||||||
|
|
||||||
use rpc_proto as rpc;
|
use rpc_proto as rpc;
|
||||||
|
@ -28,10 +27,6 @@ pub enum Error<T> {
|
||||||
InvalidPointer(usize),
|
InvalidPointer(usize),
|
||||||
#[fail(display = "RTIO clock failure")]
|
#[fail(display = "RTIO clock failure")]
|
||||||
ClockFailure,
|
ClockFailure,
|
||||||
#[fail(display = "watchdog {} expired", _0)]
|
|
||||||
WatchdogExpired(usize),
|
|
||||||
#[fail(display = "out of watchdogs")]
|
|
||||||
OutOfWatchdogs,
|
|
||||||
#[fail(display = "protocol error: {}", _0)]
|
#[fail(display = "protocol error: {}", _0)]
|
||||||
Protocol(#[cause] host::Error<T>),
|
Protocol(#[cause] host::Error<T>),
|
||||||
#[fail(display = "{}", _0)]
|
#[fail(display = "{}", _0)]
|
||||||
|
@ -91,7 +86,6 @@ enum KernelState {
|
||||||
struct Session<'a> {
|
struct Session<'a> {
|
||||||
congress: &'a mut Congress,
|
congress: &'a mut Congress,
|
||||||
kernel_state: KernelState,
|
kernel_state: KernelState,
|
||||||
watchdog_set: WatchdogSet,
|
|
||||||
log_buffer: String
|
log_buffer: String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +94,6 @@ impl<'a> Session<'a> {
|
||||||
Session {
|
Session {
|
||||||
congress: congress,
|
congress: congress,
|
||||||
kernel_state: KernelState::Absent,
|
kernel_state: KernelState::Absent,
|
||||||
watchdog_set: WatchdogSet::new(),
|
|
||||||
log_buffer: String::new()
|
log_buffer: String::new()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -396,15 +389,6 @@ fn process_kern_message(io: &Io, aux_mutex: &Mutex,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
&kern::WatchdogSetRequest { ms } => {
|
|
||||||
let id = session.watchdog_set.set_ms(ms).map_err(|()| Error::OutOfWatchdogs)?;
|
|
||||||
kern_send(io, &kern::WatchdogSetReply { id: id })
|
|
||||||
}
|
|
||||||
&kern::WatchdogClear { id } => {
|
|
||||||
session.watchdog_set.clear(id);
|
|
||||||
kern_acknowledge()
|
|
||||||
}
|
|
||||||
|
|
||||||
&kern::RpcSend { async, service, tag, data } => {
|
&kern::RpcSend { async, service, tag, data } => {
|
||||||
match stream {
|
match stream {
|
||||||
None => unexpected!("unexpected RPC in flash kernel"),
|
None => unexpected!("unexpected RPC in flash kernel"),
|
||||||
|
@ -522,11 +506,6 @@ fn host_kernel_worker(io: &Io, aux_mutex: &Mutex,
|
||||||
}
|
}
|
||||||
|
|
||||||
if session.kernel_state == KernelState::Running {
|
if session.kernel_state == KernelState::Running {
|
||||||
if let Some(idx) = session.watchdog_set.expired() {
|
|
||||||
host_write(stream, host::Reply::WatchdogExpired)?;
|
|
||||||
return Err(Error::WatchdogExpired(idx))
|
|
||||||
}
|
|
||||||
|
|
||||||
if !rtio_clocking::crg::check() {
|
if !rtio_clocking::crg::check() {
|
||||||
host_write(stream, host::Reply::ClockFailure)?;
|
host_write(stream, host::Reply::ClockFailure)?;
|
||||||
return Err(Error::ClockFailure)
|
return Err(Error::ClockFailure)
|
||||||
|
@ -567,10 +546,6 @@ fn flash_kernel_worker(io: &Io, aux_mutex: &Mutex,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(idx) = session.watchdog_set.expired() {
|
|
||||||
return Err(Error::WatchdogExpired(idx))
|
|
||||||
}
|
|
||||||
|
|
||||||
if !rtio_clocking::crg::check() {
|
if !rtio_clocking::crg::check() {
|
||||||
return Err(Error::ClockFailure)
|
return Err(Error::ClockFailure)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,49 +0,0 @@
|
||||||
use board_misoc::clock;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
|
||||||
struct Watchdog {
|
|
||||||
active: bool,
|
|
||||||
threshold: u64
|
|
||||||
}
|
|
||||||
|
|
||||||
pub const MAX_WATCHDOGS: usize = 16;
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct WatchdogSet {
|
|
||||||
watchdogs: [Watchdog; MAX_WATCHDOGS]
|
|
||||||
}
|
|
||||||
|
|
||||||
impl WatchdogSet {
|
|
||||||
pub fn new() -> WatchdogSet {
|
|
||||||
WatchdogSet {
|
|
||||||
watchdogs: [Watchdog { active: false, threshold: 0 }; MAX_WATCHDOGS]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn set_ms(&mut self, interval: u64) -> Result<usize, ()> {
|
|
||||||
for (index, watchdog) in self.watchdogs.iter_mut().enumerate() {
|
|
||||||
if !watchdog.active {
|
|
||||||
watchdog.active = true;
|
|
||||||
watchdog.threshold = clock::get_ms() + interval;
|
|
||||||
return Ok(index)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Err(())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn clear(&mut self, index: usize) {
|
|
||||||
if index < MAX_WATCHDOGS {
|
|
||||||
self.watchdogs[index].active = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn expired(&self) -> Option<usize> {
|
|
||||||
self.watchdogs
|
|
||||||
.iter()
|
|
||||||
.enumerate()
|
|
||||||
.filter(|(_, wd)| wd.active && clock::get_ms() > wd.threshold)
|
|
||||||
.min_by_key(|(_, wd)| wd.threshold)
|
|
||||||
.map_or(None, |(i, _)| Some(i))
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue