1250199Sgrehan/*- 2324461Ssephe * Copyright (c) 2009-2012,2016-2017 Microsoft Corp. 3250199Sgrehan * Copyright (c) 2012 NetApp Inc. 4250199Sgrehan * Copyright (c) 2012 Citrix Inc. 5250199Sgrehan * All rights reserved. 6250199Sgrehan * 7250199Sgrehan * Redistribution and use in source and binary forms, with or without 8250199Sgrehan * modification, are permitted provided that the following conditions 9250199Sgrehan * are met: 10250199Sgrehan * 1. Redistributions of source code must retain the above copyright 11250199Sgrehan * notice unmodified, this list of conditions, and the following 12250199Sgrehan * disclaimer. 13250199Sgrehan * 2. Redistributions in binary form must reproduce the above copyright 14250199Sgrehan * notice, this list of conditions and the following disclaimer in the 15250199Sgrehan * documentation and/or other materials provided with the distribution. 16250199Sgrehan * 17250199Sgrehan * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18250199Sgrehan * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19250199Sgrehan * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20250199Sgrehan * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21250199Sgrehan * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22250199Sgrehan * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23250199Sgrehan * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24250199Sgrehan * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25250199Sgrehan * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26250199Sgrehan * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27256352Sgrehan * 28256352Sgrehan * $FreeBSD: stable/10/sys/dev/hyperv/include/hyperv.h 324573 2017-10-13 02:16:35Z sephe $ 29250199Sgrehan */ 30250199Sgrehan 31307133Ssephe#ifndef _HYPERV_H_ 32307133Ssephe#define _HYPERV_H_ 33250199Sgrehan 34311223Ssephe#ifdef _KERNEL 35311223Ssephe 36307133Ssephe#include <sys/param.h> 37311223Ssephe#include <sys/systm.h> 38250199Sgrehan 39310801Ssephe#define MSR_HV_TIME_REF_COUNT 0x40000020 40310801Ssephe 41310801Ssephe#define CPUID_HV_MSR_TIME_REFCNT 0x0002 /* MSR_HV_TIME_REF_COUNT */ 42310801Ssephe#define CPUID_HV_MSR_SYNIC 0x0004 /* MSRs for SynIC */ 43310801Ssephe#define CPUID_HV_MSR_SYNTIMER 0x0008 /* MSRs for SynTimer */ 44310801Ssephe#define CPUID_HV_MSR_APIC 0x0010 /* MSR_HV_{EOI,ICR,TPR} */ 45310801Ssephe#define CPUID_HV_MSR_HYPERCALL 0x0020 /* MSR_HV_GUEST_OS_ID 46310801Ssephe * MSR_HV_HYPERCALL */ 47310801Ssephe#define CPUID_HV_MSR_VP_INDEX 0x0040 /* MSR_HV_VP_INDEX */ 48311223Ssephe#define CPUID_HV_MSR_REFERENCE_TSC 0x0200 /* MSR_HV_REFERENCE_TSC */ 49310801Ssephe#define CPUID_HV_MSR_GUEST_IDLE 0x0400 /* MSR_HV_GUEST_IDLE */ 50310801Ssephe 51310801Ssephe#ifndef NANOSEC 52310801Ssephe#define NANOSEC 1000000000ULL 53310801Ssephe#endif 54310801Ssephe#define HYPERV_TIMER_NS_FACTOR 100ULL 55310801Ssephe#define HYPERV_TIMER_FREQ (NANOSEC / HYPERV_TIMER_NS_FACTOR) 56310801Ssephe 57311223Ssephe#endif /* _KERNEL */ 58311223Ssephe 59311223Ssephe#define HYPERV_REFTSC_DEVNAME "hv_tsc" 60311223Ssephe 61311223Ssephe/* 62311223Ssephe * Hyper-V Reference TSC 63311223Ssephe */ 64311223Ssephestruct hyperv_reftsc { 65311223Ssephe volatile uint32_t tsc_seq; 66311223Ssephe volatile uint32_t tsc_rsvd1; 67311223Ssephe volatile uint64_t tsc_scale; 68311223Ssephe volatile int64_t tsc_ofs; 69311223Ssephe} __packed __aligned(PAGE_SIZE); 70311223Ssephe#ifdef CTASSERT 71311223SsepheCTASSERT(sizeof(struct hyperv_reftsc) == PAGE_SIZE); 72311223Ssephe#endif 73311223Ssephe 74311223Ssephe#ifdef _KERNEL 75311223Ssephe 76307026Ssephestruct hyperv_guid { 77311223Ssephe uint8_t hv_guid[16]; 78307026Ssephe} __packed; 79250199Sgrehan 80311223Ssephe#define HYPERV_GUID_STRLEN 40 81301946Ssephe 82314018Ssephetypedef uint64_t (*hyperv_tc64_t)(void); 83302166Ssephe 84314018Ssepheint hyperv_guid2str(const struct hyperv_guid *, char *, 85314018Ssephe size_t); 86310801Ssephe 87314018Ssephe/* 88314018Ssephe * hyperv_tc64 could be NULL, if there were no suitable Hyper-V 89314018Ssephe * specific timecounter. 90314018Ssephe */ 91314018Ssepheextern hyperv_tc64_t hyperv_tc64; 92314018Ssepheextern u_int hyperv_features; /* CPUID_HV_MSR_ */ 93324573Ssepheextern u_int hyperv_ver_major; 94314018Ssephe 95311223Ssephe#endif /* _KERNEL */ 96311223Ssephe 97307133Ssephe#endif /* _HYPERV_H_ */ 98