Author: sephe
Date: Fri May 27 06:12:43 2016
New Revision: 300827
URL: https://svnweb.freebsd.org/changeset/base/300827

Log:
  hyperv: Move timer related MSRs into hyperv_reg.h
  
  And avoid bit fields for event timer.
  
  MFC after:    1 week
  Sponsored by: Microsoft OSTC
  Differential Revision:        https://reviews.freebsd.org/D6566

Modified:
  head/sys/dev/hyperv/vmbus/hv_et.c
  head/sys/dev/hyperv/vmbus/hv_hv.c
  head/sys/dev/hyperv/vmbus/hyperv_reg.h

Modified: head/sys/dev/hyperv/vmbus/hv_et.c
==============================================================================
--- head/sys/dev/hyperv/vmbus/hv_et.c   Fri May 27 06:05:12 2016        
(r300826)
+++ head/sys/dev/hyperv/vmbus/hv_et.c   Fri May 27 06:12:43 2016        
(r300827)
@@ -37,12 +37,17 @@ __FBSDID("$FreeBSD$");
 #include <sys/time.h>
 #include <sys/timeet.h>
 
-#include "hv_vmbus_priv.h"
+#include <dev/hyperv/vmbus/hv_vmbus_priv.h>
+#include <dev/hyperv/vmbus/hyperv_reg.h>
 
 #define HV_TIMER_FREQUENCY             (10 * 1000 * 1000LL) /* 100ns period */
 #define HV_MAX_DELTA_TICKS             0xffffffffLL
 #define HV_MIN_DELTA_TICKS             1LL
 
+#define MSR_HV_STIMER0_CFG_SINT                \
+       ((((uint64_t)HV_VMBUS_TIMER_SINT) << MSR_HV_STIMER_CFG_SINT_SHIFT) & \
+        MSR_HV_STIMER_CFG_SINT_MASK)
+
 static struct eventtimer *et;
 
 static inline uint64_t
@@ -57,18 +62,15 @@ sbintime2tick(sbintime_t time)
 static int
 hv_et_start(struct eventtimer *et, sbintime_t firsttime, sbintime_t periodtime)
 {
-       union hv_timer_config timer_cfg;
-       uint64_t current;
+       uint64_t current, config;
 
-       timer_cfg.as_uint64 = 0;
-       timer_cfg.auto_enable = 1;
-       timer_cfg.sintx = HV_VMBUS_TIMER_SINT;
+       config = MSR_HV_STIMER_CFG_AUTOEN | MSR_HV_STIMER0_CFG_SINT;
 
-       current = rdmsr(HV_X64_MSR_TIME_REF_COUNT);
+       current = rdmsr(MSR_HV_TIME_REF_COUNT);
        current += sbintime2tick(firsttime);
 
-       wrmsr(HV_X64_MSR_STIMER0_CONFIG, timer_cfg.as_uint64);
-       wrmsr(HV_X64_MSR_STIMER0_COUNT, current);
+       wrmsr(MSR_HV_STIMER0_CONFIG, config);
+       wrmsr(MSR_HV_STIMER0_COUNT, current);
 
        return (0);
 }
@@ -76,8 +78,8 @@ hv_et_start(struct eventtimer *et, sbint
 static int
 hv_et_stop(struct eventtimer *et)
 {
-       wrmsr(HV_X64_MSR_STIMER0_CONFIG, 0);
-       wrmsr(HV_X64_MSR_STIMER0_COUNT, 0);
+       wrmsr(MSR_HV_STIMER0_CONFIG, 0);
+       wrmsr(MSR_HV_STIMER0_COUNT, 0);
 
        return (0);
 }

Modified: head/sys/dev/hyperv/vmbus/hv_hv.c
==============================================================================
--- head/sys/dev/hyperv/vmbus/hv_hv.c   Fri May 27 06:05:12 2016        
(r300826)
+++ head/sys/dev/hyperv/vmbus/hv_hv.c   Fri May 27 06:12:43 2016        
(r300827)
@@ -91,8 +91,7 @@ static struct timecounter hv_timecounter
 static u_int
 hv_get_timecount(struct timecounter *tc)
 {
-       u_int now = rdmsr(HV_X64_MSR_TIME_REF_COUNT);
-       return (now);
+       return rdmsr(MSR_HV_TIME_REF_COUNT);
 }
 
 /**

Modified: head/sys/dev/hyperv/vmbus/hyperv_reg.h
==============================================================================
--- head/sys/dev/hyperv/vmbus/hyperv_reg.h      Fri May 27 06:05:12 2016        
(r300826)
+++ head/sys/dev/hyperv/vmbus/hyperv_reg.h      Fri May 27 06:12:43 2016        
(r300827)
@@ -54,6 +54,8 @@
 
 #define MSR_HV_VP_INDEX                        0x40000002
 
+#define MSR_HV_TIME_REF_COUNT          0x40000020
+
 #define MSR_HV_SCONTROL                        0x40000080
 #define MSR_HV_SCTRL_ENABLE            0x0001ULL
 #define MSR_HV_SCTRL_RSVD_MASK         0xfffffffffffffffeULL
@@ -77,6 +79,16 @@
 #define MSR_HV_SINT_RSVD_MASK          (MSR_HV_SINT_RSVD1_MASK |       \
                                         MSR_HV_SINT_RSVD2_MASK)
 
+#define MSR_HV_STIMER0_CONFIG          0x400000b0
+#define MSR_HV_STIMER_CFG_ENABLE       0x0001ULL
+#define MSR_HV_STIMER_CFG_PERIODIC     0x0002ULL
+#define MSR_HV_STIMER_CFG_LAZY         0x0004ULL
+#define MSR_HV_STIMER_CFG_AUTOEN       0x0008ULL
+#define MSR_HV_STIMER_CFG_SINT_MASK    0x000f0000ULL
+#define MSR_HV_STIMER_CFG_SINT_SHIFT   16
+
+#define MSR_HV_STIMER0_COUNT           0x400000b1
+
 /*
  * CPUID leaves
  */
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to