From 885e877b43dd5cb85d6afdf5085b87ae4b6c0a4e Mon Sep 17 00:00:00 2001 From: bunnie Date: Fri, 15 Sep 2023 15:09:20 +0800 Subject: [PATCH] add features for mdma test to control RAM src/dest regions The MDMA controller seems broken on the FPGA board, but is working in RTL. Add a feature flag that allows us to toggle between modes. --- libs/xous-pl230/Cargo.toml | 1 + libs/xous-pl230/src/pl230_tests/units.rs | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/libs/xous-pl230/Cargo.toml b/libs/xous-pl230/Cargo.toml index fec58b3b1..3b8796641 100644 --- a/libs/xous-pl230/Cargo.toml +++ b/libs/xous-pl230/Cargo.toml @@ -23,6 +23,7 @@ precursor = [] hosted = [] renode = [] pio = ["xous-pio"] +dma-mainram = [] tests = ["pio"] default = ["tests", "pio"] \ No newline at end of file diff --git a/libs/xous-pl230/src/pl230_tests/units.rs b/libs/xous-pl230/src/pl230_tests/units.rs index 2d797903d..f5c09bae2 100644 --- a/libs/xous-pl230/src/pl230_tests/units.rs +++ b/libs/xous-pl230/src/pl230_tests/units.rs @@ -36,8 +36,16 @@ pub fn basic_tests (pl230: &mut Pl230) -> bool { const DMA_LEN: usize = 16; // setup the PL230 to do a simple transfer between two memory regions + // dma_mainram feature will cause us to DMA between main memory regions. This works under RTL sims. + #[cfg(feature="dma_mainram")] let mut region_a = [0u32; DMA_LEN]; + #[cfg(feature="dma_mainram")] let region_b = [0u32; DMA_LEN]; + // The alternate is to DMA between IFRAM regions. This works under FPGA and RTL sim. + #[cfg(not(feature="dma_mainram"))] + let region_a = unsafe{core::slice::from_raw_parts_mut((utralib::HW_IFRAM0_MEM + 4096) as *mut u32, DMA_LEN)}; + #[cfg(not(feature="dma_mainram"))] + let region_b = unsafe{core::slice::from_raw_parts_mut(utralib::HW_IFRAM1_MEM as *mut u32, DMA_LEN)}; let mut state = 0x1111_1111; for d in region_a.iter_mut() { *d = state; @@ -89,16 +97,31 @@ pub fn basic_tests (pl230: &mut Pl230) -> bool { "nop", ); } + // manual flushing, as a sanity check of cache flush if needed + /* + { + let flush_ptr = 0x6100_0000 as *mut u32; + let mut dummy: u32 = 0; + // read a bunch of data to ensure the cache is flushed + for i in 0..131072 { + dummy += unsafe{flush_ptr.add(i).read_volatile()}; + } + report_api("dummy: ", dummy); + } */ + let mut passing = true; + let mut errs = 0; for (i, (src, dst)) in region_a.iter().zip(region_b.iter()).enumerate() { if *src != *dst { report_api("error in iter ", i as u32); report_api("src: ", *src); report_api("dst: ", *dst); passing = false; + errs += 1; } } report_api("basic dma result (1=pass)", if passing { 1 } else { 0 }); + report_api("errs: ", errs); passing }