VirtualBox

source: vbox/trunk/include/iprt/nt/vid.h@ 71755

Last change on this file since 71755 was 71136, checked in by vboxsync, 7 years ago

SUPDrv,VMM/NEM/win: Abstracted kernel I/O control work in SUPDrv, currently only implemented & needed on windows. Made first I/O control call to VID from ring-0. bugref:9044

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.2 KB
Line 
1/** @file
2 * Virtualization Infrastructure Driver (VID) API.
3 */
4
5/*
6 * Copyright (C) 2018 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26
27#ifndef ___iprt_nt_vid_h
28#define ___iprt_nt_vid_h
29
30#include "hyperv.h"
31
32
33/**
34 * Output from VidMessageSlotMap.
35 */
36typedef struct VID_MAPPED_MESSAGE_SLOT
37{
38 /** The message block mapping. */
39 struct _HV_MESSAGE *pMsgBlock;
40 /** Copy of input iCpu. */
41 uint32_t iCpu;
42 /** Explicit padding. */
43 uint32_t uParentAdvisory;
44} VID_MAPPED_MESSAGE_SLOT;
45/** Pointer to VidMessageSlotMap output structure. */
46typedef VID_MAPPED_MESSAGE_SLOT *PVID_MAPPED_MESSAGE_SLOT;
47
48
49/** @name VID_MESSAGE_MAPPING_HEADER::enmVidMsgType values (wild guess).
50 * @{ */
51/** Type mask, strips flags. */
52#define VID_MESSAGE_TYPE_MASK UINT32_C(0x00ffffff)
53/** No return message necessary. */
54#define VID_MESSAGE_TYPE_FLAG_NO_RETURN UINT32_C(0x01000000)
55/** Observed message values. */
56typedef enum
57{
58 /** Invalid zero value. */
59 VidMessageInvalid = 0,
60 /** Guessing this means a message from the hypervisor. */
61 VidMessageHypervisorMessage = 0x00000c | VID_MESSAGE_TYPE_FLAG_NO_RETURN,
62 /** Guessing this means stop request completed. Message length is 1 byte. */
63 VidMessageStopRequestComplete = 0x00000d | VID_MESSAGE_TYPE_FLAG_NO_RETURN,
64} VID_MESSAGE_TYPE;
65AssertCompileSize(VID_MESSAGE_TYPE, 4);
66/** @} */
67
68/**
69 * Header of the message mapping returned by VidMessageSlotMap.
70 */
71typedef struct VID_MESSAGE_MAPPING_HEADER
72{
73 /** Current guess is that this is VID_MESSAGE_TYPE. */
74 VID_MESSAGE_TYPE enmVidMsgType;
75 /** The message size or so it seems (0x100). */
76 uint32_t cbMessage;
77 /** So far these have been zero. */
78 uint32_t aZeroPPadding[2+4];
79} VID_MESSAGE_MAPPING_HEADER;
80AssertCompileSize(VID_MESSAGE_MAPPING_HEADER, 32);
81
82/**
83 * VID processor status (VidGetVirtualProcessorRunningStatus).
84 *
85 * @note This is used internally in VID.SYS, in 17101 it's at offset 8 in their
86 * 'pVCpu' structure.
87 */
88typedef enum
89{
90 VidProcessorStatusStopped = 0,
91 VidProcessorStatusRunning,
92 VidProcessorStatusSuspended,
93 VidProcessorStatusUndefined = 0xffff
94} VID_PROCESSOR_STATUS;
95AssertCompileSize(VID_PROCESSOR_STATUS, 4);
96
97
98/** I/O control input for VidMessageSlotHandleAndGetNext. */
99typedef struct VID_IOCTL_INPUT_MESSAGE_SLOT_HANDLE_AND_GET_NEXT
100{
101 HV_VP_INDEX iCpu;
102 uint32_t fFlags; /**< VID_MSHAGN_F_GET_XXX*/
103 uint32_t cMillies;
104} VID_IOCTL_INPUT_MESSAGE_SLOT_HANDLE_AND_GET_NEXT;
105/** Pointer to input for VidMessageSlotHandleAndGetNext. */
106typedef VID_IOCTL_INPUT_MESSAGE_SLOT_HANDLE_AND_GET_NEXT *PVID_IOCTL_INPUT_MESSAGE_SLOT_HANDLE_AND_GET_NEXT;
107/** Pointer to const input for VidMessageSlotHandleAndGetNext. */
108typedef VID_IOCTL_INPUT_MESSAGE_SLOT_HANDLE_AND_GET_NEXT const *PCVID_IOCTL_INPUT_MESSAGE_SLOT_HANDLE_AND_GET_NEXT;
109
110/** @name VID_MSHAGN_F_GET_XXX - Flags for VidMessageSlotHandleAndGetNext
111 * @{ */
112/** This will try get the next message, waiting if necessary.
113 * It is subject to NtAlertThread processing when it starts waiting. */
114#define VID_MSHAGN_F_GET_NEXT_MESSAGE RT_BIT_32(0)
115/** ACK the message as handled and resume execution/whatever.
116 * This is executed before VID_MSHAGN_F_GET_NEXT_MESSAGE and should not be
117 * subject to NtAlertThread side effects. */
118#define VID_MSHAGN_F_HANDLE_MESSAGE RT_BIT_32(1)
119/** @} */
120
121
122#ifdef IN_RING3
123RT_C_DECLS_BEGIN
124
125/** Calling convention. */
126#ifndef WINAPI
127# define VIDAPI __stdcall
128#else
129# define VIDAPI WINAPI
130#endif
131
132/** Partition handle. */
133#ifndef WINAPI
134typedef void *VID_PARTITION_HANDLE;
135#else
136typedef HANDLE VID_PARTITION_HANDLE;
137#endif
138
139/**
140 * Gets the partition ID.
141 *
142 * The partition ID is the numeric identifier used when making hypercalls to the
143 * hypervisor.
144 */
145DECLIMPORT(BOOL) VIDAPI VidGetHvPartitionId(VID_PARTITION_HANDLE hPartition, HV_PARTITION_ID *pidPartition);
146
147/**
148 * Starts asynchronous execution of a virtual CPU.
149 */
150DECLIMPORT(BOOL) VIDAPI VidStartVirtualProcessor(VID_PARTITION_HANDLE hPartition, HV_VP_INDEX iCpu);
151
152/**
153 * Stops the asynchronous execution of a virtual CPU.
154 *
155 * @retval ERROR_VID_STOP_PENDING if busy with intercept, check messages.
156 */
157DECLIMPORT(BOOL) VIDAPI VidStopVirtualProcessor(VID_PARTITION_HANDLE hPartition, HV_VP_INDEX iCpu);
158
159/**
160 * WHvCreateVirtualProcessor boils down to a call to VidMessageSlotMap and
161 * some internal WinHvPlatform state fiddling.
162 *
163 * Looks like it maps memory and returns the pointer to it.
164 * VidMessageSlotHandleAndGetNext is later used to wait for the next message and
165 * put (??) it into that memory mapping.
166 *
167 * @returns Success indicator (details in LastStatusValue and LastErrorValue).
168 *
169 * @param hPartition The partition handle.
170 * @param pOutput Where to return the pointer to the message memory
171 * mapping. The CPU index is also returned here.
172 * @param iCpu The CPU to wait-and-get messages for.
173 */
174DECLIMPORT(BOOL) VIDAPI VidMessageSlotMap(VID_PARTITION_HANDLE hPartition, PVID_MAPPED_MESSAGE_SLOT pOutput, HV_VP_INDEX iCpu);
175
176/**
177 * This is used by WHvRunVirtualProcessor to wait for the next exit msg.
178 *
179 * The message appears in the memory mapping returned by VidMessageSlotMap.
180 *
181 * @returns Success indicator (details only in LastErrorValue - LastStatusValue
182 * is not set).
183 * @retval STATUS_TIMEOUT for STATUS_TIMEOUT as well as STATUS_USER_APC and
184 * STATUS_ALERTED.
185 *
186 * @param hPartition The partition handle.
187 * @param iCpu The CPU to wait-and-get messages for.
188 * @param fFlags Flags. At least one of the two flags must be set:
189 * - VID_MSHAGN_F_GET_NEXT_MESSAGE (bit 0)
190 * - VID_MSHAGN_F_HANDLE_MESSAGE (bit 1)
191 * @param cMillies The timeout, presumably in milliseconds.
192 *
193 * @todo Would be awfully nice if someone at Microsoft could hit at the
194 * flags here.
195 * @note
196 */
197DECLIMPORT(BOOL) VIDAPI VidMessageSlotHandleAndGetNext(VID_PARTITION_HANDLE hPartition, HV_VP_INDEX iCpu,
198 uint32_t fFlags, uint32_t cMillies);
199/**
200 * Gets the processor running status.
201 *
202 * This is probably only available in special builds, as one of the early I/O
203 * control dispatching routines will not let it thru. Lower down routines does
204 * implement it, so it's possible to patch it into working. This works for
205 * build 17101: eb vid+12180 0f 84 98 00 00 00
206 *
207 * @retval STATUS_NOT_IMPLEMENTED
208 */
209DECLIMPORT(BOOL) VIDAPI VidGetVirtualProcessorRunningStatus(VID_PARTITION_HANDLE hPartition, HV_VP_INDEX iCpu,
210 VID_PROCESSOR_STATUS *penmStatus);
211
212
213DECLIMPORT(BOOL) VIDAPI VidGetVirtualProcessorState(VID_PARTITION_HANDLE hPartition, HV_VP_INDEX iCpu,
214 HV_REGISTER_NAME const *paRegNames, uint32_t cRegisters,
215 HV_REGISTER_VALUE *paRegValues);
216
217DECLIMPORT(BOOL) VIDAPI VidSetVirtualProcessorState(VID_PARTITION_HANDLE hPartition, HV_VP_INDEX iCpu,
218 HV_REGISTER_NAME const *paRegNames, uint32_t cRegisters,
219 HV_REGISTER_VALUE const *paRegValues);
220
221RT_C_DECLS_END
222#endif /* IN_RING3 */
223
224#endif
225
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette