fn read_words_chunk(&self, offset: u32, words: &mut [u32]) -> Result<(), Error> {
        debug_assert!(
            words.len() <= LCODE_MAX_RW_WORDS,
            "read_words requests cannot exceed {} words",
            LCODE_MAX_RW_WORDS
        );
        let arm_code: [u32; LCODE_ARM_RW_WORDS] = [
            // `ldr   r0, [pc, #32] ; ldr r0,[read_addr]`
            0x_e5_9f_00_20_u32.to_le(),
            // `add   r1, pc, #36   ; adr r1, read_data`
            0x_e2_8f_10_24_u32.to_le(),
            // `ldr   r2, [pc, #28] ; ldr r2,[read_count]`
            0x_e5_9f_20_1c_u32.to_le(),
            // `cmp   r2, #LCODE_RW_MAX_WORDS`
            (0x_e3_52_00_00_u32 + LCODE_MAX_RW_WORDS as u32).to_le(),
            // `movgt r2, #LCODE_MAX_RW_WORDS`
            (0x_c3_a0_20_00_u32 + LCODE_MAX_RW_WORDS as u32).to_le(),
            // read_loop:
            // `subs  r2, r2, #1    ; r2 -= 1`
            0x_e2_52_20_01_u32.to_le(),
            // `bxmi  lr            ; return if (r2 < 0)`
            0x_41_2f_ff_1e_u32.to_le(),
            // `ldr   r3, [r0], #4  ; load and post-inc`
            0x_e4_90_30_04_u32.to_le(),
            // `str   r3, [r1], #4  ; store and post-inc`
            0x_e4_81_30_04_u32.to_le(),
            // `b     read_loop`
            0x_ea_ff_ff_fa_u32.to_le(),
            offset.to_le(),
            (words.len() as u32).to_le(),
        ];
        // read_data (buffer) follows, i.e. values go here.

        // scratch buffer setup: transfers ARM code, including addr and count
        self.fel_write(self.soc_info.get_scratch_addr(), u32_as_u8(&arm_code))
            .context("unable to write ARM code to scratch address")?;
        // execute code, read back the result
        self.fel_execute(self.soc_info.get_scratch_addr())
            .context("unable to execute ARM code")?;
        self.fel_read(
            self.soc_info.get_scratch_addr() + LCODE_ARM_RW_SIZE as u32,
            u32_as_u8_mut(words),
        )
        .context("unable to read generated buffer")?;

        if cfg!(not(target_endian = "little")) {
            for word in words.iter_mut() {
                *word = word.to_le();
            }
        }

        Ok(())
    }
/// Read words chunk from the FEL device memory.
Read words chunk from the FEL device memory.
Read words chunk from the FEL device memory .
fn read_words_chunk(&self, offset: u32, words: &mut [u32]) -> Result<(), Error> {
        debug_assert!(
            words.len() <= LCODE_MAX_RW_WORDS,
            "read_words requests cannot exceed {} words",
            LCODE_MAX_RW_WORDS
        );
        let arm_code: [u32; LCODE_ARM_RW_WORDS] = [
            // `ldr   r0, [pc, #32] ; ldr r0,[read_addr]`
            0x_e5_9f_00_20_u32.to_le(),
            // `add   r1, pc, #36   ; adr r1, read_data`
            0x_e2_8f_10_24_u32.to_le(),
            // `ldr   r2, [pc, #28] ; ldr r2,[read_count]`
            0x_e5_9f_20_1c_u32.to_le(),
            // `cmp   r2, #LCODE_RW_MAX_WORDS`
            (0x_e3_52_00_00_u32 + LCODE_MAX_RW_WORDS as u32).to_le(),
            // `movgt r2, #LCODE_MAX_RW_WORDS`
            (0x_c3_a0_20_00_u32 + LCODE_MAX_RW_WORDS as u32).to_le(),
            // read_loop:
            // `subs  r2, r2, #1    ; r2 -= 1`
            0x_e2_52_20_01_u32.to_le(),
            // `bxmi  lr            ; return if (r2 < 0)`
            0x_41_2f_ff_1e_u32.to_le(),
            // `ldr   r3, [r0], #4  ; load and post-inc`
            0x_e4_90_30_04_u32.to_le(),
            // `str   r3, [r1], #4  ; store and post-inc`
            0x_e4_81_30_04_u32.to_le(),
            // `b     read_loop`
            0x_ea_ff_ff_fa_u32.to_le(),
            offset.to_le(),
            (words.len() as u32).to_le(),
        ];
        // read_data (buffer) follows, i.e. values go here.
        // scratch buffer setup: transfers ARM code, including addr and count
        self.fel_write(self.soc_info.get_scratch_addr(), u32_as_u8(&arm_code))
            .context("unable to write ARM code to scratch address")?;
        // execute code, read back the result
        self.fel_execute(self.soc_info.get_scratch_addr())
            .context("unable to execute ARM code")?;
        self.fel_read(
            self.soc_info.get_scratch_addr() + LCODE_ARM_RW_SIZE as u32,
            u32_as_u8_mut(words),
        )
        .context("unable to read generated buffer")?;
        if cfg!(not(target_endian = "little")) {
            for word in words.iter_mut() {
                *word = word.to_le();
            }
        }
        Ok(())
    }
fn read_words_chunk ( & self , offset : u32 , words : & mut [ u32 ] ) -> Result < ( ) , Error > { debug_assert ! ( words len ( ) LCODE_MAX_RW_WORDS " " LCODE_MAX_RW_WORDS ) ; let arm_code : [ u32 ; LCODE_ARM_RW_WORDS ] = [ // `ldr   r0, [pc, #32] ; ldr r0,[read_addr]` 0x_e5_9f_00_20_u32 . to_le ( ) , // `add   r1, pc, #36   ; adr r1, read_data` 0x_e2_8f_10_24_u32 . to_le ( ) , // `ldr   r2, [pc, #28] ; ldr r2,[read_count]` 0x_e5_9f_20_1c_u32 . to_le ( ) , // `cmp   r2, #LCODE_RW_MAX_WORDS` ( 0x_e3_52_00_00_u32 + LCODE_MAX_RW_WORDS as u32 ) . to_le ( ) , // `movgt r2, #LCODE_MAX_RW_WORDS` ( 0x_c3_a0_20_00_u32 + LCODE_MAX_RW_WORDS as u32 ) . to_le ( ) , // read_loop: // `subs  r2, r2, #1    ; r2 -= 1` 0x_e2_52_20_01_u32 . to_le ( ) , // `bxmi  lr            ; return if (r2 < 0)` 0x_41_2f_ff_1e_u32 . to_le ( ) , // `ldr   r3, [r0], #4  ; load and post-inc` 0x_e4_90_30_04_u32 . to_le ( ) , // `str   r3, [r1], #4  ; store and post-inc` 0x_e4_81_30_04_u32 . to_le ( ) , // `b     read_loop` 0x_ea_ff_ff_fa_u32 . to_le ( ) , offset . to_le ( ) , ( words . len ( ) as u32 ) . to_le ( ) , ] ; // read_data (buffer) follows, i.e. values go here. // scratch buffer setup: transfers ARM code, including addr and count self . fel_write ( self . soc_info . get_scratch_addr ( ) , u32_as_u8 ( & arm_code ) ) . context ( " " ) ? ; // execute code, read back the result self . fel_execute ( self . soc_info . get_scratch_addr ( ) ) . context ( " " ) ? ; self . fel_read ( self . soc_info . get_scratch_addr ( ) + LCODE_ARM_RW_SIZE as u32 , u32_as_u8_mut ( words ) , ) . context ( " " ) ? ; if cfg ! ( not ( target_endian " " ) ) { for word in words . iter_mut ( ) { * word = word . to_le ( ) ; } } Ok ( ( ) ) }
Read words chunk from the FEL device memory.
Read words chunk from the FEL device memory .
&self
offset
u32
words
&mut [u32]
&self
offset
u32
words
&mut [u32]