[PATCH 1/6] vmd: store i8253 modes in register representation

ssnf <[email protected]>
Newsgroups gmane.os.openbsd.tech
Message-ID <[email protected]>
TIMER_* constants contain the mode bits in their PIT control-word
representation.

i8253_channel[].mode currently stores those bits shifted down, but
later comparisons are made directly with the TIMER_* constants.

Store the mode in the same representation as the TIMER_* constants
and stop shifting it when constructing read-back status.
---
 usr.sbin/vmd/i8253.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/usr.sbin/vmd/i8253.c b/usr.sbin/vmd/i8253.c
index 00b0945da33..2e6c605b12d 100644
--- a/usr.sbin/vmd/i8253.c
+++ b/usr.sbin/vmd/i8253.c
@@ -270,7 +270,7 @@ vcpu_exit_i8253(struct vm_run_params *vrp)
 				    sel, (rw & TIMER_16BIT));
 			}
 			i8253_channel[sel].last_w = 0;
-			i8253_channel[sel].mode = (out_data & 0xe) >> 1;
+			i8253_channel[sel].mode = out_data & 0xe;
 
 			goto ret;
 		} else {
@@ -308,7 +308,7 @@ vcpu_exit_i8253(struct vm_run_params *vrp)
 		} else {
 			if (i8253_channel[sel].rbs) {
 				i8253_channel[sel].rbs = 0;
-				data = i8253_channel[sel].mode << 1;
+				data = i8253_channel[sel].mode;
 				data |= TIMER_16BIT;
 				set_return_data(vei, data);
 				goto ret;
-- 
2.51.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.