Skip to content

Commit d981f67

Browse files
tylerchrandre-richter
authored andcommitted
Fix two timing issues in delays.rs (#8)
* Fix two timing issues in delays.rs These changes correct the implementations of delays::SysTmr::wait_msec_st and delays::wait_msec to behave correctly and consistently with one another. * Port delay fix from 09_delays to 0B_exception_levels I believe this covers all copies of this bug in the codebase. * Rebuild tutorial kernels with delay fixes
1 parent 83fdecc commit d981f67

File tree

6 files changed

+3
-3
lines changed

6 files changed

+3
-3
lines changed

09_delays/kernel8

-8 Bytes
Binary file not shown.

09_delays/kernel8.img

-12 Bytes
Binary file not shown.

09_delays/src/delays.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ impl SysTmr {
8989
// mean infinite loop
9090
if t > 0 {
9191
loop {
92-
if self.get_system_timer() < (t + n) {
92+
if self.get_system_timer() > (t + n) {
9393
break;
9494
}
9595
}
@@ -108,7 +108,7 @@ pub fn wait_msec(n: u32) {
108108
let frq = CNTFRQ_EL0.get();
109109

110110
// Calculate number of ticks
111-
let tval = (frq as u32 / 1000) * n;
111+
let tval = (u64::from(frq) * u64::from(n) / 1_000_000) as u32;
112112

113113
// Set the compare value register
114114
CNTP_TVAL_EL0.set(tval);

0B_exception_levels/kernel8

-16 Bytes
Binary file not shown.

0B_exception_levels/kernel8.img

-16 Bytes
Binary file not shown.

0B_exception_levels/src/delays.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub fn wait_msec(n: u32) {
3535
let frq = CNTFRQ_EL0.get();
3636

3737
// Calculate number of ticks
38-
let tval = (frq as u32 / 1000) * n;
38+
let tval = (u64::from(frq) * u64::from(n) / 1_000_000) as u32;
3939

4040
// Set the compare value register
4141
CNTP_TVAL_EL0.set(tval);

0 commit comments

Comments
 (0)