Use correct sequence of MMIO timer reads

As discussed in #2
pull/4/head
Andre Richter 6 years ago
parent 0bd363f375
commit 969704d498
No known key found for this signature in database
GPG Key ID: 2116C1AB102F615E

Binary file not shown.

@ -69,16 +69,15 @@ impl SysTmr {
pub fn get_system_timer(&self) -> u64 {
// Since it is MMIO, we must emit two separate 32 bit reads
let mut hi = self.SYSTMR_HI.get();
let mut lo = self.SYSTMR_LO.get();
// We have to repeat if high word changed during read. It
// looks a bit odd, but clippy insists that this is idiomatic
// Rust!
let lo = if hi != self.SYSTMR_HI.get() {
// We have to repeat if high word changed during read. This
// will emit a clippy warning that needs be ignored, or you
// lose an MMIO read.
if hi != self.SYSTMR_HI.get() {
hi = self.SYSTMR_HI.get();
self.SYSTMR_LO.get()
} else {
self.SYSTMR_LO.get()
};
lo = self.SYSTMR_LO.get();
}
// Compose long int value
(u64::from(hi) << 32) | u64::from(lo)

@ -69,16 +69,15 @@ impl SysTmr {
pub fn get_system_timer(&self) -> u64 {
// Since it is MMIO, we must emit two separate 32 bit reads
let mut hi = self.SYSTMR_HI.get();
let mut lo = self.SYSTMR_LO.get();
// We have to repeat if high word changed during read. It
// looks a bit odd, but clippy insists that this is idiomatic
// Rust!
let lo = if hi != self.SYSTMR_HI.get() {
// We have to repeat if high word changed during read. This
// will emit a clippy warning that needs be ignored, or you
// lose an MMIO read.
if hi != self.SYSTMR_HI.get() {
hi = self.SYSTMR_HI.get();
self.SYSTMR_LO.get()
} else {
self.SYSTMR_LO.get()
};
lo = self.SYSTMR_LO.get();
}
// Compose long int value
(u64::from(hi) << 32) | u64::from(lo)

Loading…
Cancel
Save