Skip to content

Commit f47c9ec

Browse files
committed
probe: Print SAU config if in secure debug mode
1 parent 4498ba2 commit f47c9ec

File tree

2 files changed

+98
-0
lines changed

2 files changed

+98
-0
lines changed

cmd/probe/src/lib.rs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,52 @@ fn probecmd(context: &mut humility::ExecutionContext) -> Result<()> {
406406
);
407407
}
408408
}
409+
410+
409411
if part.has_tz() {
412+
// Temporarily force banked register accesses to Secure versions
413+
let mut dscsr = DSCSR::read(core)?;
414+
dscsr.set_sbrsel(true);
415+
dscsr.set_sbrselen(true);
416+
dscsr.write(core)?;
417+
418+
let sau_type = SAU_TYPE::read(core)?;
419+
print("SAU_TYPE", format!("0x{:x}", sau_type.0));
420+
421+
if sau_type.sregion() > 0 {
422+
let sau_ctrl = SAU_CTRL::read(core)?;
423+
humility::msg!(
424+
"{:>12} => 0x{:8}",
425+
"SAU_CTRL",
426+
format!("{:x}", sau_ctrl.0)
427+
);
428+
}
429+
430+
for rnr in 0..sau_type.sregion() {
431+
let mut sau_rnr = SAU_RNR(0);
432+
sau_rnr.set_region(rnr);
433+
sau_rnr.write(core)?;
434+
435+
let sau_rbar = SAU_RBAR::read(core)?;
436+
humility::msg!(
437+
"{:>12} => 0x{:8}",
438+
format!("SAU_RBAR{}", rnr),
439+
format!("{:x}", sau_rbar.0)
440+
);
441+
442+
let sau_rlar = SAU_RLAR::read(core)?;
443+
humility::msg!(
444+
"{:>12} => 0x{:8}",
445+
format!("SAU_RLAR{}", rnr),
446+
format!("{:x}", sau_rlar.0)
447+
);
448+
}
449+
450+
// Switch back to using current security domain versions of banked
451+
// registers
452+
dscsr.set_sbrselen(false);
453+
dscsr.write(core)?;
454+
410455
let sfsr = SFSR::read(core)?;
411456
if sfsr.has_fault() {
412457
humility::msg!(

humility-arch-cortex/src/debug.rs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,16 @@ register!(DHCSR, 0xe000_edf0,
428428
pub halted, _: 17;
429429
);
430430

431+
register!(DSCSR, 0xe000ee08,
432+
#[derive(Copy, Clone)]
433+
pub struct DSCSR(u32);
434+
impl Debug;
435+
pub cdskey, set_cdskey: 17;
436+
pub cds, set_cds: 16;
437+
pub sbrsel, set_sbrsel: 1;
438+
pub sbrselen, set_sbrselen: 0;
439+
);
440+
431441
register!(DEMCR, 0xe000_edfc,
432442
#[derive(Copy, Clone)]
433443
pub struct DEMCR(u32);
@@ -481,6 +491,49 @@ register!(MVFR0, 0xe000_ef40,
481491
pub simd_registers, _: 3, 0;
482492
);
483493

494+
register!(SAU_TYPE, 0xe000edd4,
495+
#[derive(Copy, Clone)]
496+
#[allow(non_camel_case_types)]
497+
pub struct SAU_TYPE(u32);
498+
impl Debug;
499+
pub sregion, _: 7, 0;
500+
);
501+
502+
register!(SAU_RNR, 0xe000edd8,
503+
#[derive(Copy, Clone)]
504+
#[allow(non_camel_case_types)]
505+
pub struct SAU_RNR(u32);
506+
impl Debug;
507+
pub region, set_region: 7, 0;
508+
);
509+
510+
register!(SAU_CTRL, 0xe000edd0,
511+
#[derive(Copy, Clone)]
512+
#[allow(non_camel_case_types)]
513+
pub struct SAU_CTRL(u32);
514+
impl Debug;
515+
pub allns, _: 1;
516+
pub enable, _: 0;
517+
);
518+
519+
register!(SAU_RBAR, 0xe000eddc,
520+
#[derive(Copy, Clone)]
521+
#[allow(non_camel_case_types)]
522+
pub struct SAU_RBAR(u32);
523+
impl Debug;
524+
pub baddr, _: 31, 5;
525+
);
526+
527+
register!(SAU_RLAR, 0xe000ede0,
528+
#[derive(Copy, Clone)]
529+
#[allow(non_camel_case_types)]
530+
pub struct SAU_RLAR(u32);
531+
impl Debug;
532+
pub laddr, _: 31, 5;
533+
pub nsc, _: 1;
534+
pub enable, _: 0;
535+
);
536+
484537
register!(STM32F4_DBGMCU_IDCODE, 0xe004_2000,
485538
#[derive(Copy, Clone)]
486539
#[allow(non_camel_case_types)]

0 commit comments

Comments
 (0)