1
1
use core:: result:: Result ;
2
2
// use cortex_m_semihosting::{heprint,heprintln};
3
3
use crate :: { drivers:: clocks:: Clocks , typestates:: init_state} ;
4
+ use core:: ptr:: copy_nonoverlapping;
4
5
5
6
#[ derive( Copy , Clone , PartialEq ) ]
6
7
pub enum KeyType {
@@ -333,6 +334,7 @@ impl Pfr<init_state::Enabled> {
333
334
/// returns previous versions of the CFPA page (not seen on scratch, ping, or pong pages).
334
335
/// This method always returns the most recently updated Cfpa from ping or pong pages.
335
336
pub fn read_latest_cfpa ( & mut self ) -> Result < Cfpa , u32 > {
337
+ use core:: ptr:: copy_nonoverlapping;
336
338
let mut cfpa_bytes = [ 0u32 ; 128 ] ;
337
339
338
340
let ping_ptr = ( 0x0009_DE00 + 512 ) as * const u32 ;
@@ -347,8 +349,8 @@ impl Pfr<init_state::Enabled> {
347
349
pong_ptr
348
350
} ;
349
351
350
- for i in 0 .. 128 {
351
- cfpa_bytes [ i ] = unsafe { * cfpa_ptr. offset ( i as isize ) } ;
352
+ unsafe {
353
+ copy_nonoverlapping ( cfpa_ptr, cfpa_bytes . as_mut_ptr ( ) , 128 ) ;
352
354
}
353
355
354
356
let cfpa: & Cfpa = unsafe { core:: mem:: transmute ( cfpa_bytes. as_ptr ( ) ) } ;
@@ -360,8 +362,8 @@ impl Pfr<init_state::Enabled> {
360
362
let mut cfpa_bytes = [ 0u32 ; 128 ] ;
361
363
362
364
const CFPA_PTR : * const u32 = ( 0x0009_DE00 + 512 ) as * const u32 ;
363
- for i in 0 .. 128 {
364
- cfpa_bytes [ i ] = unsafe { * CFPA_PTR . offset ( i as isize ) } ;
365
+ unsafe {
366
+ copy_nonoverlapping ( CFPA_PTR , cfpa_bytes . as_mut_ptr ( ) , 128 ) ;
365
367
}
366
368
367
369
let cfpa: & Cfpa = unsafe { core:: mem:: transmute ( cfpa_bytes. as_ptr ( ) ) } ;
@@ -373,8 +375,8 @@ impl Pfr<init_state::Enabled> {
373
375
let mut cfpa_bytes = [ 0u32 ; 128 ] ;
374
376
375
377
const CFPA_PTR : * const u32 = ( 0x0009_DE00 + 512 + 512 ) as * const u32 ;
376
- for i in 0 .. 128 {
377
- cfpa_bytes [ i ] = unsafe { * CFPA_PTR . offset ( i as isize ) } ;
378
+ unsafe {
379
+ copy_nonoverlapping ( CFPA_PTR , cfpa_bytes . as_mut_ptr ( ) , 128 ) ;
378
380
}
379
381
380
382
let cfpa: & Cfpa = unsafe { core:: mem:: transmute ( cfpa_bytes. as_ptr ( ) ) } ;
0 commit comments