Skip to content

Commit 693b4b0

Browse files
committed
--wip-- [skip ci]
1 parent 86981f3 commit 693b4b0

File tree

47 files changed

+1681
-1581
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1681
-1581
lines changed

Cargo.lock

Lines changed: 45 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

probe-rs-tools/src/bin/probe-rs/cmd/info.rs

Lines changed: 26 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use jep106::JEP106Code;
55
use probe_rs::{
66
architecture::{
77
arm::{
8+
ap::ApClass,
89
armv6m::Demcr,
910
component::Scs,
1011
dp::{DebugPortId, DebugPortVersion, MinDpSupport, DLPIDR, DPIDR, TARGETID},
@@ -13,8 +14,7 @@ use probe_rs::{
1314
Component, ComponentId, CoresightComponent, PeripheralType,
1415
},
1516
sequences::DefaultArmSequence,
16-
ApInformation, ArmProbeInterface, DpAddress, FullyQualifiedApAddress,
17-
MemoryApInformation, Register,
17+
ArmProbeInterface, DpAddress, FullyQualifiedApAddress, Register,
1818
},
1919
riscv::communication_interface::RiscvCommunicationInterface,
2020
xtensa::communication_interface::{
@@ -296,49 +296,37 @@ fn show_arm_info(interface: &mut dyn ArmProbeInterface, dp: DpAddress) -> Result
296296
if access_ports.is_empty() {
297297
println!("No access ports found on this chip.");
298298
} else {
299-
for ap in access_ports {
300-
let ap_information = interface.ap_information(&ap)?;
301-
302-
match ap_information {
303-
ApInformation::MemoryAp(MemoryApInformation {
304-
debug_base_address,
305-
address,
306-
device_enabled,
307-
..
308-
}) => {
309-
let mut ap_nodes = Tree::new(format!("{} MemoryAP", address.ap_v1()?));
310-
311-
if *device_enabled {
312-
match handle_memory_ap(&ap, *debug_base_address, interface) {
313-
Ok(component_tree) => ap_nodes.push(component_tree),
314-
Err(e) => ap_nodes.push(format!("Error during access: {e}")),
315-
};
316-
} else {
317-
ap_nodes.push("Access disabled".to_string());
318-
}
319-
320-
tree.push(ap_nodes);
321-
}
322-
323-
ApInformation::Other { address, idr } => {
324-
let jep = idr.DESIGNER;
299+
for ap_address in access_ports {
300+
use probe_rs::architecture::arm::ap::IDR;
301+
let idr: IDR = interface
302+
.read_raw_ap_register(&ap_address, IDR::ADDRESS)?
303+
.try_into()?;
304+
305+
if idr.CLASS == ApClass::MemAp {
306+
let mut ap_nodes = Tree::new(format!("{} MemoryAP", ap_address.ap_v1()?));
307+
match handle_memory_ap(interface, &ap_address) {
308+
Ok(component_tree) => ap_nodes.push(component_tree),
309+
Err(e) => ap_nodes.push(format!("Error during access: {e}")),
310+
};
311+
tree.push(ap_nodes);
312+
} else {
313+
let jep = idr.DESIGNER;
325314

326-
let ap_type = if idr.DESIGNER == JEP_ARM {
327-
format!("{:?}", idr.TYPE)
328-
} else {
329-
format!("{:#x}", idr.TYPE as u8)
330-
};
315+
let ap_type = if idr.DESIGNER == JEP_ARM {
316+
format!("{:?}", idr.TYPE)
317+
} else {
318+
format!("{:#x}", idr.TYPE as u8)
319+
};
331320

332-
tree.push(format!(
321+
tree.push(format!(
333322
"{} Unknown AP (Designer: {}, Class: {:?}, Type: {}, Variant: {:#x}, Revision: {:#x})",
334-
address.ap_v1()?,
323+
ap_address.ap_v1()?,
335324
jep.get().unwrap_or("<unknown>"),
336325
idr.CLASS,
337326
ap_type,
338327
idr.VARIANT,
339328
idr.REVISION
340329
));
341-
}
342330
}
343331
}
344332

@@ -350,12 +338,12 @@ fn show_arm_info(interface: &mut dyn ArmProbeInterface, dp: DpAddress) -> Result
350338
}
351339

352340
fn handle_memory_ap(
353-
access_port: &FullyQualifiedApAddress,
354-
base_address: u64,
355341
interface: &mut dyn ArmProbeInterface,
342+
access_port: &FullyQualifiedApAddress,
356343
) -> Result<Tree<String>, anyhow::Error> {
357344
let component = {
358345
let mut memory = interface.memory_interface(access_port)?;
346+
let base_address = memory.base_address()?;
359347
let mut demcr = Demcr(memory.read_word_32(Demcr::get_mmio_address())?);
360348
demcr.set_dwtena(true);
361349
memory.write_word_32(Demcr::get_mmio_address(), demcr.into())?;

probe-rs/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ clap = { version = "4", features = ["derive"] }
106106
itm = { version = "0.9.0-rc.1", default-features = false }
107107
pretty_assertions = "1"
108108
test-case = "3"
109+
test-log = { version = "0.2.16", features = [ "trace" ] }
109110
termtree = "0.4"
110111
insta = { version = "1.38", default-features = false, features = ["yaml"] }
111112

probe-rs/src/architecture/arm/ap/generic_ap.rs

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
//! Generic access port
22
3-
use super::{AccessPortType, ApRegister, Register};
4-
use crate::architecture::arm::{
5-
communication_interface::RegisterParseError, FullyQualifiedApAddress,
6-
};
3+
use crate::architecture::arm::communication_interface::RegisterParseError;
74

85
/// Describes the class of an access port defined in the [`ARM Debug Interface v5.2`](https://developer.arm.com/documentation/ihi0031/f/?lang=en) specification.
96
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
@@ -39,14 +36,14 @@ pub enum ApType {
3936
JtagComAp = 0x0,
4037
/// A AMBA based AHB3 AP (see E1.5).
4138
AmbaAhb3 = 0x1,
42-
/// A AMBA based AHB2 and AHB3 AP (see E1.8).
43-
AmbaAhb2Ahb3 = 0x2,
39+
/// A AMBA based APB2 and APB3 AP (see E1.8).
40+
AmbaApb2Apb3 = 0x2,
4441
/// A AMBA based AXI3 and AXI4 AP (see E1.2).
4542
AmbaAxi3Axi4 = 0x4,
4643
/// A AMBA based AHB5 AP (see E1.6).
4744
AmbaAhb5 = 0x5,
48-
/// A AMBA based AHB4 AP (see E1.3).
49-
AmbaAhb4 = 0x6,
45+
/// A AMBA based APB4 and APB5 AP (see E1.3).
46+
AmbaApb4Apb5 = 0x6,
5047
/// A AMBA based AXI5 AP (see E1.4).
5148
AmbaAxi5 = 0x7,
5249
/// A AMBA based protected AHB5 AP (see E1.7).
@@ -59,25 +56,18 @@ impl ApType {
5956
match value {
6057
0x0 => Some(ApType::JtagComAp),
6158
0x1 => Some(ApType::AmbaAhb3),
62-
0x2 => Some(ApType::AmbaAhb2Ahb3),
59+
0x2 => Some(ApType::AmbaApb2Apb3),
6360
0x4 => Some(ApType::AmbaAxi3Axi4),
6461
0x5 => Some(ApType::AmbaAhb5),
65-
0x6 => Some(ApType::AmbaAhb4),
62+
0x6 => Some(ApType::AmbaApb4Apb5),
6663
0x7 => Some(ApType::AmbaAxi5),
6764
0x8 => Some(ApType::AmbaAhb5Hprot),
6865
_ => None,
6966
}
7067
}
7168
}
7269

73-
define_ap!(
74-
/// A generic access port which implements just the register every access port has to implement
75-
/// to be compliant with the ADI 5.2 specification.
76-
GenericAp
77-
);
78-
7970
define_ap_register!(
80-
type: GenericAp,
8171
/// Identification Register
8272
///
8373
/// The identification register is used to identify

0 commit comments

Comments
 (0)