vmd(8): compute i8254 read-back command latch from singular timestamp

The intent of the i8254 read-back command is (most likely) to permit
simultaneously latching two or three counters at once along with their
statuses.

To simulate this, we should compute olatch from one timestamp per
read-back command, not one timestamp per counter.

Improved with a tweak by dv@.

Link: https://marc.info/?l=openbsd-tech&m=166213670605453&w=2

ok dv@ mlarkin@
This commit is contained in:
cheloha 2022-09-02 21:33:51 +00:00
parent 3ad05d8a96
commit f53d796ad2
1 changed files with 2 additions and 2 deletions

View File

@ -1,4 +1,4 @@
/* $OpenBSD: i8253.c,v 1.34 2021/06/16 16:55:02 dv Exp $ */
/* $OpenBSD: i8253.c,v 1.35 2022/09/02 21:33:51 cheloha Exp $ */
/*
* Copyright (c) 2016 Mike Larkin <mlarkin@openbsd.org>
*
@ -137,9 +137,9 @@ i8253_do_readback(uint32_t data)
/* !TIMER_RB_COUNT == enable counter readback */
if (data & ~TIMER_RB_COUNT) {
clock_gettime(CLOCK_MONOTONIC, &now);
for (i = 0; i < 3; i++) {
if (data & readback_channel[i]) {
clock_gettime(CLOCK_MONOTONIC, &now);
timespecsub(&now, &i8253_channel[i].ts, &delta);
ns = delta.tv_sec * 1000000000 + delta.tv_nsec;
ticks = ns / NS_PER_TICK;