1303067Ssephe/*-
2303067Ssephe * Copyright (c) 2016 Microsoft Corp.
3303067Ssephe * All rights reserved.
4303067Ssephe *
5303067Ssephe * Redistribution and use in source and binary forms, with or without
6303067Ssephe * modification, are permitted provided that the following conditions
7303067Ssephe * are met:
8303067Ssephe * 1. Redistributions of source code must retain the above copyright
9303067Ssephe *    notice unmodified, this list of conditions, and the following
10303067Ssephe *    disclaimer.
11303067Ssephe * 2. Redistributions in binary form must reproduce the above copyright
12303067Ssephe *    notice, this list of conditions and the following disclaimer in the
13303067Ssephe *    documentation and/or other materials provided with the distribution.
14303067Ssephe *
15303067Ssephe * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16303067Ssephe * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17303067Ssephe * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18303067Ssephe * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19303067Ssephe * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20303067Ssephe * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21303067Ssephe * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22303067Ssephe * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23303067Ssephe * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24303067Ssephe * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25303067Ssephe *
26303067Ssephe * $FreeBSD: stable/11/sys/dev/hyperv/utilities/hv_utilreg.h 308635 2016-11-14 06:37:04Z sephe $
27303067Ssephe */
28303067Ssephe
29303067Ssephe#ifndef _HV_UTILREG_H_
30303067Ssephe#define _HV_UTILREG_H_
31303067Ssephe
32308635Ssephe/*
33308635Ssephe * Some Hyper-V status codes.
34308635Ssephe */
35308635Ssephe#define HV_S_OK				0x00000000
36308635Ssephe#define HV_E_FAIL			0x80004005
37308635Ssephe#define HV_S_CONT			0x80070103
38308635Ssephe#define HV_ERROR_NOT_SUPPORTED		0x80070032
39308635Ssephe#define HV_ERROR_MACHINE_LOCKED		0x800704F7
40308635Ssephe#define HV_ERROR_DEVICE_NOT_CONNECTED	0x8007048F
41308635Ssephe#define HV_INVALIDARG			0x80070057
42308635Ssephe#define HV_GUID_NOTFOUND		0x80041002
43303067Ssephe
44303067Ssephe/*
45303067Ssephe * Common defines for Hyper-V ICs
46303067Ssephe */
47303067Ssephe#define HV_ICMSGTYPE_NEGOTIATE		0
48303067Ssephe#define HV_ICMSGTYPE_HEARTBEAT		1
49303067Ssephe#define HV_ICMSGTYPE_KVPEXCHANGE	2
50303067Ssephe#define HV_ICMSGTYPE_SHUTDOWN		3
51303067Ssephe#define HV_ICMSGTYPE_TIMESYNC		4
52303067Ssephe#define HV_ICMSGTYPE_VSS		5
53303067Ssephe
54303067Ssephe#define HV_ICMSGHDRFLAG_TRANSACTION	1
55303067Ssephe#define HV_ICMSGHDRFLAG_REQUEST		2
56303067Ssephe#define HV_ICMSGHDRFLAG_RESPONSE	4
57303067Ssephe
58303067Ssephetypedef struct hv_vmbus_pipe_hdr {
59303067Ssephe	uint32_t flags;
60303067Ssephe	uint32_t msgsize;
61303067Ssephe} __packed hv_vmbus_pipe_hdr;
62303067Ssephe
63303067Ssephetypedef struct hv_vmbus_ic_version {
64303067Ssephe	uint16_t major;
65303067Ssephe	uint16_t minor;
66303067Ssephe} __packed hv_vmbus_ic_version;
67303067Ssephe
68303067Ssephetypedef struct hv_vmbus_icmsg_hdr {
69303067Ssephe	hv_vmbus_ic_version	icverframe;
70303067Ssephe	uint16_t		icmsgtype;
71303067Ssephe	hv_vmbus_ic_version	icvermsg;
72303067Ssephe	uint16_t		icmsgsize;
73303067Ssephe	uint32_t		status;
74303067Ssephe	uint8_t			ictransaction_id;
75303067Ssephe	uint8_t			icflags;
76303067Ssephe	uint8_t			reserved[2];
77303067Ssephe} __packed hv_vmbus_icmsg_hdr;
78303067Ssephe
79303067Ssephetypedef struct hv_vmbus_icmsg_negotiate {
80303067Ssephe	uint16_t		icframe_vercnt;
81303067Ssephe	uint16_t		icmsg_vercnt;
82303067Ssephe	uint32_t		reserved;
83303067Ssephe	hv_vmbus_ic_version	icversion_data[1]; /* any size array */
84303067Ssephe} __packed hv_vmbus_icmsg_negotiate;
85303067Ssephe
86303067Ssephe#endif	/* !_HV_UTILREG_H_ */
87