use std::{fmt::Debug, sync::Arc, time::Duration};
use crate::architecture::xtensa::Xtensa;
use crate::architecture::xtensa::communication_interface::XtensaCommunicationInterface;
use crate::semihosting::{SemihostingCommand, UnknownCommandDetails};
pub trait XtensaDebugSequence: Send + Sync + Debug {
fn on_connect(
&self,
_interface: &mut XtensaCommunicationInterface,
) -> Result<(), crate::Error> {
Ok(())
}
fn on_halt(&self, _interface: &mut XtensaCommunicationInterface) -> Result<(), crate::Error> {
Ok(())
}
fn reset_system_and_halt(
&self,
interface: &mut XtensaCommunicationInterface,
timeout: Duration,
) -> Result<(), crate::Error> {
interface.reset_and_halt(timeout)?;
Ok(())
}
fn on_unknown_semihosting_command(
&self,
_interface: &mut Xtensa,
details: UnknownCommandDetails,
) -> Result<Option<SemihostingCommand>, crate::Error> {
Ok(Some(SemihostingCommand::Unknown(details)))
}
}
#[derive(Debug)]
pub struct DefaultXtensaSequence(pub(crate) ());
impl DefaultXtensaSequence {
pub fn create() -> Arc<dyn XtensaDebugSequence> {
Arc::new(Self(()))
}
}
impl XtensaDebugSequence for DefaultXtensaSequence {}