On Fri, Jun 26, 2020 at 04:09:57PM +0300, Roman Bolshakov wrote:
On Tue, Jun 23, 2020 at 11:00:24PM -0400, Kevin O'Connor wrote:
Good catch. Could we fix it using the patch below instead though?
--- a/src/hw/timer.c +++ b/src/hw/timer.c @@ -180,7 +180,7 @@ timer_read(void) // Read from PIT. outb(PM_SEL_READBACK | PM_READ_VALUE | PM_READ_COUNTER0, PORT_PIT_MODE); u16 v = inb(PORT_PIT_COUNTER0) | (inb(PORT_PIT_COUNTER0) << 8);
- return timer_adjust_bits(v, 0xffff);
- return timer_adjust_bits(-v, 0xffff);
// Return the TSC value that is 'msecs' time in the future.
I like the approach much more. Initial count value is 0, PIT rearms the timer when 1 is hit, unary negation on unsigned u16 fits perfectly, then timer_adjust_bits recieves 0, 1, 2, ... and timer is rearmed at 0xffff.
Do you want me to send v2 or you plan to apply the fix on your own?
I'm fine with either.