Skip to content

Commit d7df560

Browse files
committed
downcount from u32::MAX instead of u16::MAX
idk why james did it that way
1 parent c2f023e commit d7df560

File tree

1 file changed

+7
-2
lines changed
  • platforms/allwinner-d1/d1-core/src

1 file changed

+7
-2
lines changed

platforms/allwinner-d1/d1-core/src/timer.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,23 @@ impl Timer0 {
1616

1717
let _ = self.get_and_clear_interrupt();
1818

19+
// Start the timer counting down from 0xffff_ffff_ffff_ffff.
20+
1921
// TODO(eliza): if it's zero, handle that lol --- when the IRQ fires
2022
// we need to increment some higher half counter and then reset the
2123
// timer to u32::MAX?
22-
self.start_counter(0xFFFF_FFFF);
24+
self.start_counter(u32::MAX);
2325

2426
Clock::new(core::time::Duration::from_nanos(333), || {
2527
let timer0 = unsafe {
2628
// Safety: we are just reading the current value and will not be
2729
// concurrently mutating the timer.
2830
Self::steal()
2931
};
30-
0xFFFF_FFFF - timer0.current_value() as u64
32+
// Since timer 0 is counting *down*, we have to subtract its current
33+
// value from the intial value to get an increasing timestamp for
34+
// Maitake.
35+
(u32::MAX - timer0.current_value()) as u64
3136
})
3237
.named("CLOCK_D1_TIMER0")
3338
}

0 commit comments

Comments
 (0)