mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-20 09:03:28 +00:00
fix double-offset error in oneway counter readback
This commit is contained in:
parent
9336100965
commit
cade3980cc
1 changed files with 6 additions and 4 deletions
|
|
@ -140,11 +140,11 @@ impl OneWayCounter {
|
||||||
let base = self.mapping.as_mut_ptr() as *mut u32;
|
let base = self.mapping.as_mut_ptr() as *mut u32;
|
||||||
|
|
||||||
if offset < ONEWAY_LEN {
|
if offset < ONEWAY_LEN {
|
||||||
let starting_value = self.get(offset * COUNTER_STRIDE_U32).unwrap(); // offset is already checked
|
let starting_value = self.get(offset).unwrap(); // offset is already checked
|
||||||
// this will cause the increment in hardware
|
// this will cause the increment in hardware
|
||||||
unsafe { base.add(offset * COUNTER_STRIDE_U32).write_volatile(0) }
|
unsafe { base.add(offset * COUNTER_STRIDE_U32).write_volatile(0) }
|
||||||
crate::cache_flush();
|
crate::cache_flush();
|
||||||
let ending_value = self.get(offset * COUNTER_STRIDE_U32).unwrap();
|
let ending_value = self.get(offset).unwrap();
|
||||||
// if the increment didn't happen, we may have experienced wear-out on the line
|
// if the increment didn't happen, we may have experienced wear-out on the line
|
||||||
// it's only good for 10k increments
|
// it's only good for 10k increments
|
||||||
if ending_value != starting_value + 1 { Err(OneWayErr::IncFail) } else { Ok(()) }
|
if ending_value != starting_value + 1 { Err(OneWayErr::IncFail) } else { Ok(()) }
|
||||||
|
|
@ -166,11 +166,13 @@ impl OneWayCounter {
|
||||||
|
|
||||||
let offset = T::OFFSET;
|
let offset = T::OFFSET;
|
||||||
if offset < ONEWAY_LEN {
|
if offset < ONEWAY_LEN {
|
||||||
let starting_value = self.get(offset * COUNTER_STRIDE_U32).unwrap(); // offset is already checked
|
let starting_value = self.get(offset).unwrap(); // offset is already checked
|
||||||
// this will cause the increment in hardware
|
// this will cause the increment in hardware
|
||||||
unsafe { base.add(offset * COUNTER_STRIDE_U32).write_volatile(0) }
|
unsafe { base.add(offset * COUNTER_STRIDE_U32).write_volatile(0) }
|
||||||
crate::cache_flush();
|
crate::cache_flush();
|
||||||
let ending_value = self.get(offset * COUNTER_STRIDE_U32).unwrap();
|
let ending_value = self.get(offset).unwrap();
|
||||||
|
// crate::println!("ending: {} starting: {}", ending_value, starting_value);
|
||||||
|
|
||||||
// if the increment didn't happen, we may have experienced wear-out on the line
|
// if the increment didn't happen, we may have experienced wear-out on the line
|
||||||
// it's only good for 10k increments
|
// it's only good for 10k increments
|
||||||
if ending_value != starting_value + 1 { Err(OneWayErr::IncFail) } else { Ok(()) }
|
if ending_value != starting_value + 1 { Err(OneWayErr::IncFail) } else { Ok(()) }
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue