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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
use super::DebugRegister;
use crate::architecture::arm::memory::romtable::CoresightComponent;
use crate::architecture::arm::{ArmError, ArmProbeInterface};
use bitfield::bitfield;
const REGISTER_OFFSET_ACCESS: u32 = 0xFB0;
pub struct TraceFunnel<'a> {
component: &'a CoresightComponent,
interface: &'a mut dyn ArmProbeInterface,
}
impl<'a> TraceFunnel<'a> {
pub fn new(
interface: &'a mut dyn ArmProbeInterface,
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)
}
}
bitfield! {
#[derive(Clone, Default)]
pub struct Control(u32);
impl Debug;
pub u8, min_hold_time, set_min_hold_time: 11, 8;
pub u8, enable_slave_port, set_slave_enable: 7, 0;
}
impl DebugRegister for Control {
const ADDRESS: u32 = 0x00;
const NAME: &'static str = "CSTF/CTRL";
}
impl From<u32> for Control {
fn from(raw: u32) -> Control {
Control(raw)
}
}
impl From<Control> for u32 {
fn from(control: Control) -> u32 {
control.0
}
}