use super::DebugComponentInterface;
use crate::architecture::arm::memory::romtable::CoresightComponent;
use crate::architecture::arm::{ArmDebugInterface, ArmError};
use crate::memory_mapped_bitfield_register;
const REGISTER_OFFSET_ACCESS: u32 = 0xFB0;
pub struct TraceFunnel<'a> {
component: &'a CoresightComponent,
interface: &'a mut dyn ArmDebugInterface,
}
impl<'a> TraceFunnel<'a> {
pub fn new(
interface: &'a mut dyn ArmDebugInterface,
component: &'a CoresightComponent,
) -> Self {
TraceFunnel {
component,
interface,
}
}
pub fn unlock(&mut self) -> Result<(), ArmError> {
self.component
.write_reg(self.interface, REGISTER_OFFSET_ACCESS, 0xC5AC_CE55)?;
Ok(())
}
pub fn enable_port(&mut self, mask: u8) -> Result<(), ArmError> {
let mut control = Control::load(self.component, self.interface)?;
control.set_slave_enable(mask);
control.store(self.component, self.interface)
}
}
memory_mapped_bitfield_register! {
#[derive(Default)]
pub struct Control(u32);
0x00, "CSTF/CTRL",
impl From;
pub u8, min_hold_time, set_min_hold_time: 11, 8;
pub u8, enable_slave_port, set_slave_enable: 7, 0;
}
impl DebugComponentInterface for Control {}