]>
Commit | Line | Data |
---|---|---|
c88c4e4c HJ |
1 | /* |
2 | * Copyright (c) 2009, Microsoft Corporation. | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify it | |
5 | * under the terms and conditions of the GNU General Public License, | |
6 | * version 2, as published by the Free Software Foundation. | |
7 | * | |
8 | * This program is distributed in the hope it will be useful, but WITHOUT | |
9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
11 | * more details. | |
12 | * | |
13 | * You should have received a copy of the GNU General Public License along with | |
14 | * this program; if not, write to the Free Software Foundation, Inc., 59 Temple | |
15 | * Place - Suite 330, Boston, MA 02111-1307 USA. | |
16 | * | |
17 | * Authors: | |
18 | * Haiyang Zhang <[email protected]> | |
19 | * Hank Janssen <[email protected]> | |
20 | */ | |
b3413092 GKH |
21 | #ifndef __HV_UTILS_H_ |
22 | #define __HV_UTILS_H_ | |
c88c4e4c HJ |
23 | |
24 | /* | |
25 | * Common header for Hyper-V ICs | |
26 | */ | |
b3413092 GKH |
27 | #define ICMSGTYPE_NEGOTIATE 0 |
28 | #define ICMSGTYPE_HEARTBEAT 1 | |
29 | #define ICMSGTYPE_KVPEXCHANGE 2 | |
30 | #define ICMSGTYPE_SHUTDOWN 3 | |
31 | #define ICMSGTYPE_TIMESYNC 4 | |
32 | #define ICMSGTYPE_VSS 5 | |
c88c4e4c | 33 | |
b3413092 GKH |
34 | #define ICMSGHDRFLAG_TRANSACTION 1 |
35 | #define ICMSGHDRFLAG_REQUEST 2 | |
36 | #define ICMSGHDRFLAG_RESPONSE 4 | |
c88c4e4c | 37 | |
b3413092 GKH |
38 | #define HV_S_OK 0x00000000 |
39 | #define HV_E_FAIL 0x80004005 | |
40 | #define HV_ERROR_NOT_SUPPORTED 0x80070032 | |
41 | #define HV_ERROR_MACHINE_LOCKED 0x800704F7 | |
c88c4e4c HJ |
42 | |
43 | struct vmbuspipe_hdr { | |
b3413092 GKH |
44 | u32 flags; |
45 | u32 msgsize; | |
c88c4e4c HJ |
46 | } __attribute__((packed)); |
47 | ||
48 | struct ic_version { | |
b3413092 GKH |
49 | u16 major; |
50 | u16 minor; | |
c88c4e4c HJ |
51 | } __attribute__((packed)); |
52 | ||
53 | struct icmsg_hdr { | |
b3413092 GKH |
54 | struct ic_version icverframe; |
55 | u16 icmsgtype; | |
56 | struct ic_version icvermsg; | |
57 | u16 icmsgsize; | |
58 | u32 status; | |
59 | u8 ictransaction_id; | |
60 | u8 icflags; | |
61 | u8 reserved[2]; | |
c88c4e4c HJ |
62 | } __attribute__((packed)); |
63 | ||
64 | struct icmsg_negotiate { | |
b3413092 GKH |
65 | u16 icframe_vercnt; |
66 | u16 icmsg_vercnt; | |
67 | u32 reserved; | |
68 | struct ic_version icversion_data[1]; /* any size array */ | |
c88c4e4c HJ |
69 | } __attribute__((packed)); |
70 | ||
71 | struct shutdown_msg_data { | |
72 | u32 reason_code; | |
73 | u32 timeout_seconds; | |
74 | u32 flags; | |
75 | u8 display_message[2048]; | |
76 | } __attribute__((packed)); | |
77 | ||
9153f7b9 HJ |
78 | struct heartbeat_msg_data { |
79 | u64 seq_num; | |
80 | u32 reserved[8]; | |
81 | } __attribute__((packed)); | |
39c4e9c3 HZ |
82 | |
83 | /* Time Sync IC defs */ | |
25e2831d GKH |
84 | #define ICTIMESYNCFLAG_PROBE 0 |
85 | #define ICTIMESYNCFLAG_SYNC 1 | |
86 | #define ICTIMESYNCFLAG_SAMPLE 2 | |
39c4e9c3 HZ |
87 | |
88 | #ifdef __x86_64__ | |
25e2831d | 89 | #define WLTIMEDELTA 116444736000000000L /* in 100ns unit */ |
39c4e9c3 | 90 | #else |
25e2831d | 91 | #define WLTIMEDELTA 116444736000000000LL |
39c4e9c3 HZ |
92 | #endif |
93 | ||
39c4e9c3 | 94 | struct ictimesync_data{ |
25e2831d GKH |
95 | u64 parenttime; |
96 | u64 childtime; | |
97 | u64 roundtriptime; | |
98 | u8 flags; | |
39c4e9c3 HZ |
99 | } __attribute__((packed)); |
100 | ||
101 | /* Index for each IC struct in array hv_cb_utils[] */ | |
25e2831d GKH |
102 | #define HV_SHUTDOWN_MSG 0 |
103 | #define HV_TIMESYNC_MSG 1 | |
9153f7b9 | 104 | #define HV_HEARTBEAT_MSG 2 |
c88c4e4c HJ |
105 | |
106 | struct hyperv_service_callback { | |
107 | u8 msg_type; | |
108 | char *log_msg; | |
109 | unsigned char data[16]; | |
110 | struct vmbus_channel *channel; | |
111 | void (*callback) (void *context); | |
112 | }; | |
113 | ||
114 | extern void prep_negotiate_resp(struct icmsg_hdr *, | |
b3413092 | 115 | struct icmsg_negotiate *, u8 *); |
c88c4e4c HJ |
116 | extern void chn_cb_negotiate(void *); |
117 | extern struct hyperv_service_callback hv_cb_utils[]; | |
118 | ||
b3413092 | 119 | #endif /* __HV_UTILS_H_ */ |