1250199Sgrehan/*- 2322612Ssephe * 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. 27256350Sgrehan * 28256350Sgrehan * $FreeBSD: stable/11/sys/dev/hyperv/include/hyperv.h 324577 2017-10-13 05:02:39Z sephe $ 29250199Sgrehan */ 30250199Sgrehan 31307466Ssephe#ifndef _HYPERV_H_ 32307466Ssephe#define _HYPERV_H_ 33250199Sgrehan 34311376Ssephe#ifdef _KERNEL 35311376Ssephe 36307466Ssephe#include <sys/param.h> 37311376Ssephe#include <sys/systm.h> 38250199Sgrehan 39311373Ssephe#define MSR_HV_TIME_REF_COUNT 0x40000020 40311373Ssephe 41311373Ssephe#define CPUID_HV_MSR_TIME_REFCNT 0x0002 /* MSR_HV_TIME_REF_COUNT */ 42311373Ssephe#define CPUID_HV_MSR_SYNIC 0x0004 /* MSRs for SynIC */ 43311373Ssephe#define CPUID_HV_MSR_SYNTIMER 0x0008 /* MSRs for SynTimer */ 44311373Ssephe#define CPUID_HV_MSR_APIC 0x0010 /* MSR_HV_{EOI,ICR,TPR} */ 45311373Ssephe#define CPUID_HV_MSR_HYPERCALL 0x0020 /* MSR_HV_GUEST_OS_ID 46311373Ssephe * MSR_HV_HYPERCALL */ 47311373Ssephe#define CPUID_HV_MSR_VP_INDEX 0x0040 /* MSR_HV_VP_INDEX */ 48311376Ssephe#define CPUID_HV_MSR_REFERENCE_TSC 0x0200 /* MSR_HV_REFERENCE_TSC */ 49311373Ssephe#define CPUID_HV_MSR_GUEST_IDLE 0x0400 /* MSR_HV_GUEST_IDLE */ 50311373Ssephe 51311373Ssephe#ifndef NANOSEC 52311373Ssephe#define NANOSEC 1000000000ULL 53311373Ssephe#endif 54311373Ssephe#define HYPERV_TIMER_NS_FACTOR 100ULL 55311373Ssephe#define HYPERV_TIMER_FREQ (NANOSEC / HYPERV_TIMER_NS_FACTOR) 56311373Ssephe 57311376Ssephe#endif /* _KERNEL */ 58311376Ssephe 59311376Ssephe#define HYPERV_REFTSC_DEVNAME "hv_tsc" 60311376Ssephe 61311376Ssephe/* 62311376Ssephe * Hyper-V Reference TSC 63311376Ssephe */ 64311376Ssephestruct hyperv_reftsc { 65311376Ssephe volatile uint32_t tsc_seq; 66311376Ssephe volatile uint32_t tsc_rsvd1; 67311376Ssephe volatile uint64_t tsc_scale; 68311376Ssephe volatile int64_t tsc_ofs; 69311376Ssephe} __packed __aligned(PAGE_SIZE); 70311376Ssephe#ifdef CTASSERT 71311376SsepheCTASSERT(sizeof(struct hyperv_reftsc) == PAGE_SIZE); 72311376Ssephe#endif 73311376Ssephe 74311376Ssephe#ifdef _KERNEL 75311376Ssephe 76307448Ssephestruct hyperv_guid { 77311376Ssephe uint8_t hv_guid[16]; 78307448Ssephe} __packed; 79250199Sgrehan 80311376Ssephe#define HYPERV_GUID_STRLEN 40 81297142Ssephe 82314003Ssephetypedef uint64_t (*hyperv_tc64_t)(void); 83301021Ssephe 84314003Ssepheint hyperv_guid2str(const struct hyperv_guid *, char *, 85314003Ssephe size_t); 86311373Ssephe 87314003Ssephe/* 88314003Ssephe * hyperv_tc64 could be NULL, if there were no suitable Hyper-V 89314003Ssephe * specific timecounter. 90314003Ssephe */ 91314003Ssepheextern hyperv_tc64_t hyperv_tc64; 92314003Ssepheextern u_int hyperv_features; /* CPUID_HV_MSR_ */ 93324577Ssepheextern u_int hyperv_ver_major; 94314003Ssephe 95311376Ssephe#endif /* _KERNEL */ 96311376Ssephe 97307466Ssephe#endif /* _HYPERV_H_ */ 98