firmware: remove obsolete watchdog code (#1458)

This commit is contained in:
Sebastien Bourdeauducq 2020-10-15 18:38:00 +08:00
parent 6af8655cc7
commit 90017da484
7 changed files with 0 additions and 101 deletions

View File

@ -121,9 +121,6 @@ static mut API: &'static [(&'static str, *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_async = ::rpc_send_async),
api!(rpc_recv = ::rpc_recv),

View File

@ -200,21 +200,6 @@ fn terminate(exception: &eh_artiq::Exception, backtrace: &mut [usize]) -> ! {
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)]
extern fn cache_get(key: CSlice<u8>) -> CSlice<'static, i32> {
send(&CacheGetRequest {

View File

@ -52,10 +52,6 @@ pub enum Message<'a> {
},
RunAborted,
WatchdogSetRequest { ms: u64 },
WatchdogSetReply { id: usize },
WatchdogClear { id: usize },
RpcSend {
async: bool,
service: u32,

View File

@ -105,7 +105,6 @@ pub enum Reply<'a> {
RpcRequest { async: bool },
WatchdogExpired,
ClockFailure,
}
@ -191,9 +190,6 @@ impl<'a> Reply<'a> {
writer.write_u8(async as u8)?;
},
Reply::WatchdogExpired => {
writer.write_u8(14)?;
},
Reply::ClockFailure => {
writer.write_u8(15)?;
},

View File

@ -53,7 +53,6 @@ mod mgmt;
mod profiler;
mod kernel;
mod kern_hwreq;
mod watchdog;
mod session;
#[cfg(any(has_rtio_moninj, has_drtio))]
mod moninj;

View File

@ -11,7 +11,6 @@ use rtio_clocking;
use rtio_dma::Manager as DmaManager;
use cache::Cache;
use kern_hwreq;
use watchdog::WatchdogSet;
use board_artiq::drtio_routing;
use rpc_proto as rpc;
@ -28,10 +27,6 @@ pub enum Error<T> {
InvalidPointer(usize),
#[fail(display = "RTIO clock failure")]
ClockFailure,
#[fail(display = "watchdog {} expired", _0)]
WatchdogExpired(usize),
#[fail(display = "out of watchdogs")]
OutOfWatchdogs,
#[fail(display = "protocol error: {}", _0)]
Protocol(#[cause] host::Error<T>),
#[fail(display = "{}", _0)]
@ -91,7 +86,6 @@ enum KernelState {
struct Session<'a> {
congress: &'a mut Congress,
kernel_state: KernelState,
watchdog_set: WatchdogSet,
log_buffer: String
}
@ -100,7 +94,6 @@ impl<'a> Session<'a> {
Session {
congress: congress,
kernel_state: KernelState::Absent,
watchdog_set: WatchdogSet::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 } => {
match stream {
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 let Some(idx) = session.watchdog_set.expired() {
host_write(stream, host::Reply::WatchdogExpired)?;
return Err(Error::WatchdogExpired(idx))
}
if !rtio_clocking::crg::check() {
host_write(stream, host::Reply::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() {
return Err(Error::ClockFailure)
}

View File

@ -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))
}
}