diff options
author | Sepherosa Ziehau <sephe@FreeBSD.org> | 2016-05-27 06:12:43 +0000 |
---|---|---|
committer | Sepherosa Ziehau <sephe@FreeBSD.org> | 2016-05-27 06:12:43 +0000 |
commit | a4574fd680053a3c639b8f7efef374f621e0a2ce (patch) | |
tree | 34a0e0ce4046a2684674968abe32d20996860771 | |
parent | bccdea450b37005ada49d974baff95be1d8821c7 (diff) | |
download | src-a4574fd680053a3c639b8f7efef374f621e0a2ce.tar.gz src-a4574fd680053a3c639b8f7efef374f621e0a2ce.zip |
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
Notes
Notes:
svn path=/head/; revision=300827
-rw-r--r-- | sys/dev/hyperv/vmbus/hv_et.c | 24 | ||||
-rw-r--r-- | sys/dev/hyperv/vmbus/hv_hv.c | 3 | ||||
-rw-r--r-- | sys/dev/hyperv/vmbus/hyperv_reg.h | 12 |
3 files changed, 26 insertions, 13 deletions
diff --git a/sys/dev/hyperv/vmbus/hv_et.c b/sys/dev/hyperv/vmbus/hv_et.c index 440b514291f9..cf9e80f9a720 100644 --- a/sys/dev/hyperv/vmbus/hv_et.c +++ b/sys/dev/hyperv/vmbus/hv_et.c @@ -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, sbintime_t firsttime, sbintime_t periodtime) 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); } diff --git a/sys/dev/hyperv/vmbus/hv_hv.c b/sys/dev/hyperv/vmbus/hv_hv.c index 832d81f76393..2ca0293143db 100644 --- a/sys/dev/hyperv/vmbus/hv_hv.c +++ b/sys/dev/hyperv/vmbus/hv_hv.c @@ -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); } /** diff --git a/sys/dev/hyperv/vmbus/hyperv_reg.h b/sys/dev/hyperv/vmbus/hyperv_reg.h index 198150cf1499..c97f9d64dea0 100644 --- a/sys/dev/hyperv/vmbus/hyperv_reg.h +++ b/sys/dev/hyperv/vmbus/hyperv_reg.h @@ -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 */ |