use crate::common::IrqId;
use crate::sim::handle::Handle;
use crate::sim::memory::GlobalMemory;
use crate::soc::devices::{Clint, Plic, SimOp, Uart};
pub trait Device: Handle + Send + Sync {
fn name(&self) -> &str;
fn address_range(&self) -> (u64, u64);
fn tick(&mut self) -> bool {
false
}
fn quiet_ticks(&self) -> Option<u64> {
Some(0)
}
fn skip_ticks(&mut self, _ticks: u64) {}
fn get_irq_id(&self) -> Option<IrqId> {
None
}
fn as_clint(&self) -> Option<&Clint> {
None
}
fn as_clint_mut(&mut self) -> Option<&mut Clint> {
None
}
fn as_plic_mut(&mut self) -> Option<&mut Plic> {
None
}
fn as_uart_mut(&mut self) -> Option<&mut Uart> {
None
}
fn take_sim_ops(&mut self) -> Vec<SimOp> {
Vec::new()
}
fn drain(&mut self, _memory: &mut GlobalMemory) {}
fn checkpoint(&self) -> Option<serde_json::Value> {
None
}
fn check_restore(&self, _state: &serde_json::Value) -> Result<(), String> {
Ok(())
}
fn restore(&mut self, _state: &serde_json::Value) -> Result<(), String> {
Ok(())
}
}