From 5332587de658ca391089e67db7143299eec78d77 Mon Sep 17 00:00:00 2001 From: pca006132 Date: Wed, 10 Jun 2020 12:54:50 +0800 Subject: [PATCH] Changed mutability --- experiments/src/main.rs | 11 ++++------- libboard_zynq/src/sdio/adma.rs | 2 +- libboard_zynq/src/sdio/sd_card.rs | 2 +- libcortex_a9/src/cache.rs | 2 +- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/experiments/src/main.rs b/experiments/src/main.rs index c7594ad..32c91b5 100644 --- a/experiments/src/main.rs +++ b/experiments/src/main.rs @@ -93,14 +93,11 @@ pub fn main_core0() { }; const SIZE: usize = 512 * 2 + 1; let mut sd_card = result.unwrap(); + { + let buffer: [u8; SIZE] = [5; SIZE]; + sd_card.write_block(0x0, 2, &buffer).unwrap(); + } let mut buffer: [u8; SIZE] = [0; SIZE]; - for i in 0..buffer.len() { - buffer[i] = (i % 16) as u8; - } - sd_card.write_block(0x0, 2, &mut buffer).unwrap(); - for i in 0..buffer.len() { - buffer[i] = 0; - } sd_card.read_block(0x1, 2, &mut buffer[1..]).unwrap(); for i in 0..buffer.len() { info!("buffer[{}] = {}", i, buffer[i]); diff --git a/libboard_zynq/src/sdio/adma.rs b/libboard_zynq/src/sdio/adma.rs index 9f80b7f..82b4bf3 100644 --- a/libboard_zynq/src/sdio/adma.rs +++ b/libboard_zynq/src/sdio/adma.rs @@ -62,7 +62,7 @@ impl Adma2Desc32 { } } -pub fn setup_adma2_descr32(sdio: &mut SDIO, blk_cnt: u32, buffer: &mut [u8]) { +pub fn setup_adma2_descr32(sdio: &mut SDIO, blk_cnt: u32, buffer: &[u8]) { let descr_table = unsafe { &mut ADMA2_DESCR32_TABLE }; let blk_size = sdio .regs diff --git a/libboard_zynq/src/sdio/sd_card.rs b/libboard_zynq/src/sdio/sd_card.rs index a58f605..0826574 100644 --- a/libboard_zynq/src/sdio/sd_card.rs +++ b/libboard_zynq/src/sdio/sd_card.rs @@ -241,7 +241,7 @@ impl SdCard { &mut self, address: u32, block_cnt: u16, - buffer: &mut [u8], + buffer: &[u8], ) -> Result<(), CmdTransferError> { assert!(buffer.len() >= (block_cnt as usize) * 512); // set block size if not set already diff --git a/libcortex_a9/src/cache.rs b/libcortex_a9/src/cache.rs index f62d88f..c4d26a1 100644 --- a/libcortex_a9/src/cache.rs +++ b/libcortex_a9/src/cache.rs @@ -112,7 +112,7 @@ pub fn dcci(object: &T) { } } -pub fn dcci_slice(slice: &mut [T]) { +pub fn dcci_slice(slice: &[T]) { for addr in slice_cache_line_addrs(slice) { dccimvac(addr); }