VirtualBox

source: vbox/trunk/include/VBox/vmm/gim.h@ 76561

Last change on this file since 76561 was 76558, checked in by vboxsync, 6 years ago

include/VBox: Use VBOX_INCLUDED_ rather than _vbox_ as header guard prefix, letting scm enforce this (thereby avoiding copy&paste errors like NativeEventQueue.h).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.2 KB
Line 
1/** @file
2 * GIM - Guest Interface Manager.
3 */
4
5/*
6 * Copyright (C) 2014-2019 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#ifndef VBOX_INCLUDED_vmm_gim_h
27#define VBOX_INCLUDED_vmm_gim_h
28#ifndef RT_WITHOUT_PRAGMA_ONCE
29# pragma once
30#endif
31
32#include <VBox/cdefs.h>
33#include <VBox/types.h>
34#include <VBox/param.h>
35
36#include <VBox/vmm/cpum.h>
37#include <VBox/vmm/pdmifs.h>
38
39/** The value used to specify that VirtualBox must use the newest
40 * implementation version of the GIM provider. */
41#define GIM_VERSION_LATEST UINT32_C(0)
42
43RT_C_DECLS_BEGIN
44
45/** @defgroup grp_gim The Guest Interface Manager API
46 * @ingroup grp_vmm
47 * @{
48 */
49
50/**
51 * GIM Provider Identifiers.
52 * @remarks Part of saved state!
53 */
54typedef enum GIMPROVIDERID
55{
56 /** None. */
57 GIMPROVIDERID_NONE = 0,
58 /** Minimal. */
59 GIMPROVIDERID_MINIMAL,
60 /** Microsoft Hyper-V. */
61 GIMPROVIDERID_HYPERV,
62 /** Linux KVM Interface. */
63 GIMPROVIDERID_KVM
64} GIMPROVIDERID;
65AssertCompileSize(GIMPROVIDERID, sizeof(uint32_t));
66
67
68/**
69 * A GIM MMIO2 region record.
70 */
71typedef struct GIMMMIO2REGION
72{
73 /** The region index. */
74 uint8_t iRegion;
75 /** Whether an RC mapping is required. */
76 bool fRCMapping;
77 /** Whether this region has been registered. */
78 bool fRegistered;
79 /** Whether this region is currently mapped. */
80 bool fMapped;
81 /** Alignment padding. */
82 uint8_t au8Alignment0[3];
83 /** Size of the region (must be page aligned). */
84 uint32_t cbRegion;
85 /** Alignment padding. */
86 uint32_t u32Alignment0;
87 /** The host ring-0 address of the first page in the region. */
88 R0PTRTYPE(void *) pvPageR0;
89 /** The host ring-3 address of the first page in the region. */
90 R3PTRTYPE(void *) pvPageR3;
91 /** The ring-context address of the first page in the region. */
92 RCPTRTYPE(void *) pvPageRC;
93 /** The guest-physical address of the first page in the region. */
94 RTGCPHYS GCPhysPage;
95 /** The description of the region. */
96 char szDescription[32];
97} GIMMMIO2REGION;
98/** Pointer to a GIM MMIO2 region. */
99typedef GIMMMIO2REGION *PGIMMMIO2REGION;
100/** Pointer to a const GIM MMIO2 region. */
101typedef GIMMMIO2REGION const *PCGIMMMIO2REGION;
102AssertCompileMemberAlignment(GIMMMIO2REGION, cbRegion, 8);
103AssertCompileMemberAlignment(GIMMMIO2REGION, pvPageR0, 8);
104
105/**
106 * Debug data buffer available callback over the GIM debug connection.
107 *
108 * @param pVM The cross context VM structure.
109 */
110typedef DECLCALLBACK(void) FNGIMDEBUGBUFAVAIL(PVM pVM);
111/** Pointer to GIM debug buffer available callback. */
112typedef FNGIMDEBUGBUFAVAIL *PFNGIMDEBUGBUFAVAIL;
113
114/**
115 * GIM debug setup.
116 *
117 * These are parameters/options filled in by the GIM provider and passed along
118 * to the GIM device.
119 */
120typedef struct GIMDEBUGSETUP
121{
122 /** The callback to invoke when the receive buffer has data. */
123 PFNGIMDEBUGBUFAVAIL pfnDbgRecvBufAvail;
124 /** The size of the receive buffer as specified by the GIM provider. */
125 uint32_t cbDbgRecvBuf;
126} GIMDEBUGSETUP;
127/** Pointer to a GIM debug setup struct. */
128typedef struct GIMDEBUGSETUP *PGIMDEBUGSETUP;
129/** Pointer to a const GIM debug setup struct. */
130typedef struct GIMDEBUGSETUP const *PCGGIMDEBUGSETUP;
131
132/**
133 * GIM debug structure (common to the GIM device and GIM).
134 *
135 * This is used to exchanging data between the GIM provider and the GIM device.
136 */
137typedef struct GIMDEBUG
138{
139 /** The receive buffer. */
140 void *pvDbgRecvBuf;
141 /** The debug I/O stream driver. */
142 PPDMISTREAM pDbgDrvStream;
143 /** Number of bytes pending to be read from the receive buffer. */
144 size_t cbDbgRecvBufRead;
145 /** The flag synchronizing reads of the receive buffer from EMT. */
146 volatile bool fDbgRecvBufRead;
147 /** The receive thread wakeup semaphore. */
148 RTSEMEVENTMULTI hDbgRecvThreadSem;
149} GIMDEBUG;
150/** Pointer to a GIM debug struct. */
151typedef struct GIMDEBUG *PGIMDEBUG;
152/** Pointer to a const GIM debug struct. */
153typedef struct GIMDEBUG const *PCGIMDEBUG;
154
155
156#ifdef IN_RC
157/** @defgroup grp_gim_rc The GIM Raw-mode Context API
158 * @{
159 */
160/** @} */
161#endif /* IN_RC */
162
163#ifdef IN_RING0
164/** @defgroup grp_gim_r0 The GIM Host Context Ring-0 API
165 * @{
166 */
167VMMR0_INT_DECL(int) GIMR0InitVM(PVM pVM);
168VMMR0_INT_DECL(int) GIMR0TermVM(PVM pVM);
169VMMR0_INT_DECL(int) GIMR0UpdateParavirtTsc(PVM pVM, uint64_t u64Offset);
170/** @} */
171#endif /* IN_RING0 */
172
173
174#ifdef IN_RING3
175/** @defgroup grp_gim_r3 The GIM Host Context Ring-3 API
176 * @{
177 */
178VMMR3_INT_DECL(int) GIMR3Init(PVM pVM);
179VMMR3_INT_DECL(int) GIMR3InitCompleted(PVM pVM);
180VMMR3_INT_DECL(void) GIMR3Relocate(PVM pVM, RTGCINTPTR offDelta);
181VMMR3_INT_DECL(int) GIMR3Term(PVM pVM);
182VMMR3_INT_DECL(void) GIMR3Reset(PVM pVM);
183VMMR3DECL(void) GIMR3GimDeviceRegister(PVM pVM, PPDMDEVINS pDevInsR3, PGIMDEBUG pDbg);
184VMMR3DECL(int) GIMR3GetDebugSetup(PVM pVM, PGIMDEBUGSETUP pDbgSetup);
185VMMR3DECL(PGIMMMIO2REGION) GIMR3GetMmio2Regions(PVM pVM, uint32_t *pcRegions);
186/** @} */
187#endif /* IN_RING3 */
188
189VMMDECL(bool) GIMIsEnabled(PVM pVM);
190VMMDECL(GIMPROVIDERID) GIMGetProvider(PVM pVM);
191VMM_INT_DECL(bool) GIMIsParavirtTscEnabled(PVM pVM);
192VMM_INT_DECL(bool) GIMAreHypercallsEnabled(PVMCPU pVCpu);
193VMM_INT_DECL(VBOXSTRICTRC) GIMHypercall(PVMCPU pVCpu, PCPUMCTX pCtx);
194VMM_INT_DECL(VBOXSTRICTRC) GIMHypercallEx(PVMCPU pVCpu, PCPUMCTX pCtx, unsigned uDisOpcode, uint8_t cbInstr);
195VMM_INT_DECL(VBOXSTRICTRC) GIMExecHypercallInstr(PVMCPU pVCpu, PCPUMCTX pCtx, uint8_t *pcbInstr);
196VMM_INT_DECL(VBOXSTRICTRC) GIMXcptUD(PVMCPU pVCpu, PCPUMCTX pCtx, PDISCPUSTATE pDis, uint8_t *pcbInstr);
197VMM_INT_DECL(bool) GIMShouldTrapXcptUD(PVMCPU pVCpu);
198VMM_INT_DECL(VBOXSTRICTRC) GIMReadMsr(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue);
199VMM_INT_DECL(VBOXSTRICTRC) GIMWriteMsr(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue);
200VMM_INT_DECL(int) GIMQueryHypercallOpcodeBytes(PVM pVM, void *pvBuf, size_t cbBuf,
201 size_t *pcbWritten, uint16_t *puDisOpcode);
202/** @} */
203
204RT_C_DECLS_END
205
206#endif
207
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