probe_rs/architecture/arm/component/trace_funnel.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
//! Arm trace funnel CoreSight Component
//!
//! # Description
//! This module provides access and control of the trace funnel CoreSight component block.
use super::DebugComponentInterface;
use crate::architecture::arm::memory::romtable::CoresightComponent;
use crate::architecture::arm::{ArmError, ArmProbeInterface};
use crate::memory_mapped_bitfield_register;
const REGISTER_OFFSET_ACCESS: u32 = 0xFB0;
/// Trace funnel unit
pub struct TraceFunnel<'a> {
component: &'a CoresightComponent,
interface: &'a mut dyn ArmProbeInterface,
}
impl<'a> TraceFunnel<'a> {
/// Construct a new TraceFunnel component.
pub fn new(
interface: &'a mut dyn ArmProbeInterface,
component: &'a CoresightComponent,
) -> Self {
TraceFunnel {
component,
interface,
}
}
/// Unlock the funnel and enable it for tracing the target.
pub fn unlock(&mut self) -> Result<(), ArmError> {
self.component
.write_reg(self.interface, REGISTER_OFFSET_ACCESS, 0xC5AC_CE55)?;
Ok(())
}
/// Enable funnel input sources.
///
/// # Note
/// The trace funnel acts as a selector for multiple sources. This function allows you to block
/// or pass specific trace sources selectively.
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! {
/// The control register is described in "DDI0314H CoreSight Components Technical Reference
/// Manual" on page 7-5.
#[derive(Default)]
pub struct Control(u32);
0x00, "CSTF/CTRL",
impl From;
/// The minimum hold time specifics the number of transactions that the arbiter of the funnel
/// will perform on individual active input before muxing to the next port. The arbiter uses a
/// round-robin topology for all enabled funnel inputs.
pub u8, min_hold_time, set_min_hold_time: 11, 8;
/// The slave enable port specifies a bitfield which indicates which trace funnel input ports
/// are enabled.
pub u8, enable_slave_port, set_slave_enable: 7, 0;
}
impl DebugComponentInterface for Control {}