VirtualBox

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

Last change on this file since 82968 was 82968, checked in by vboxsync, 5 years ago

Copyright year updates by scm.

  • 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-2020 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 /** Size of the region (must be page aligned). */
82 uint32_t cbRegion;
83 /** The host ring-0 address of the first page in the region. */
84 R0PTRTYPE(void *) pvPageR0;
85 /** The host ring-3 address of the first page in the region. */
86 R3PTRTYPE(void *) pvPageR3;
87# ifdef VBOX_WITH_RAW_MODE_KEEP
88 /** The ring-context address of the first page in the region. */
89 RCPTRTYPE(void *) pvPageRC;
90 RTRCPTR RCPtrAlignment0;
91# endif
92 /** The guest-physical address of the first page in the region. */
93 RTGCPHYS GCPhysPage;
94 /** The MMIO2 handle. */
95 PGMMMIO2HANDLE hMmio2;
96 /** The description of the region. */
97 char szDescription[32];
98} GIMMMIO2REGION;
99/** Pointer to a GIM MMIO2 region. */
100typedef GIMMMIO2REGION *PGIMMMIO2REGION;
101/** Pointer to a const GIM MMIO2 region. */
102typedef GIMMMIO2REGION const *PCGIMMMIO2REGION;
103AssertCompileMemberAlignment(GIMMMIO2REGION, pvPageR0, 8);
104AssertCompileMemberAlignment(GIMMMIO2REGION, GCPhysPage, 8);
105
106/**
107 * Debug data buffer available callback over the GIM debug connection.
108 *
109 * @param pVM The cross context VM structure.
110 */
111typedef DECLCALLBACK(void) FNGIMDEBUGBUFAVAIL(PVM pVM);
112/** Pointer to GIM debug buffer available callback. */
113typedef FNGIMDEBUGBUFAVAIL *PFNGIMDEBUGBUFAVAIL;
114
115/**
116 * GIM debug setup.
117 *
118 * These are parameters/options filled in by the GIM provider and passed along
119 * to the GIM device.
120 */
121typedef struct GIMDEBUGSETUP
122{
123 /** The callback to invoke when the receive buffer has data. */
124 PFNGIMDEBUGBUFAVAIL pfnDbgRecvBufAvail;
125 /** The size of the receive buffer as specified by the GIM provider. */
126 uint32_t cbDbgRecvBuf;
127} GIMDEBUGSETUP;
128/** Pointer to a GIM debug setup struct. */
129typedef struct GIMDEBUGSETUP *PGIMDEBUGSETUP;
130/** Pointer to a const GIM debug setup struct. */
131typedef struct GIMDEBUGSETUP const *PCGGIMDEBUGSETUP;
132
133/**
134 * GIM debug structure (common to the GIM device and GIM).
135 *
136 * This is used to exchanging data between the GIM provider and the GIM device.
137 */
138typedef struct GIMDEBUG
139{
140 /** The receive buffer. */
141 void *pvDbgRecvBuf;
142 /** The debug I/O stream driver. */
143 PPDMISTREAM pDbgDrvStream;
144 /** Number of bytes pending to be read from the receive buffer. */
145 size_t cbDbgRecvBufRead;
146 /** The flag synchronizing reads of the receive buffer from EMT. */
147 volatile bool fDbgRecvBufRead;
148 /** The receive thread wakeup semaphore. */
149 RTSEMEVENTMULTI hDbgRecvThreadSem;
150} GIMDEBUG;
151/** Pointer to a GIM debug struct. */
152typedef struct GIMDEBUG *PGIMDEBUG;
153/** Pointer to a const GIM debug struct. */
154typedef struct GIMDEBUG const *PCGIMDEBUG;
155
156
157#ifdef IN_RC
158/** @defgroup grp_gim_rc The GIM Raw-mode Context API
159 * @{
160 */
161/** @} */
162#endif /* IN_RC */
163
164#ifdef IN_RING0
165/** @defgroup grp_gim_r0 The GIM Host Context Ring-0 API
166 * @{
167 */
168VMMR0_INT_DECL(int) GIMR0InitVM(PVMCC pVM);
169VMMR0_INT_DECL(int) GIMR0TermVM(PVMCC pVM);
170VMMR0_INT_DECL(int) GIMR0UpdateParavirtTsc(PVMCC pVM, uint64_t u64Offset);
171/** @} */
172#endif /* IN_RING0 */
173
174
175#ifdef IN_RING3
176/** @defgroup grp_gim_r3 The GIM Host Context Ring-3 API
177 * @{
178 */
179VMMR3_INT_DECL(int) GIMR3Init(PVM pVM);
180VMMR3_INT_DECL(int) GIMR3InitCompleted(PVM pVM);
181VMMR3_INT_DECL(void) GIMR3Relocate(PVM pVM, RTGCINTPTR offDelta);
182VMMR3_INT_DECL(int) GIMR3Term(PVM pVM);
183VMMR3_INT_DECL(void) GIMR3Reset(PVM pVM);
184VMMR3DECL(void) GIMR3GimDeviceRegister(PVM pVM, PPDMDEVINS pDevInsR3, PGIMDEBUG pDbg);
185VMMR3DECL(int) GIMR3GetDebugSetup(PVM pVM, PGIMDEBUGSETUP pDbgSetup);
186/** @} */
187#endif /* IN_RING3 */
188
189VMMDECL(bool) GIMIsEnabled(PVM pVM);
190VMMDECL(GIMPROVIDERID) GIMGetProvider(PVM pVM);
191VMMDECL(PGIMMMIO2REGION) GIMGetMmio2Regions(PVMCC pVM, uint32_t *pcRegions);
192VMM_INT_DECL(bool) GIMIsParavirtTscEnabled(PVMCC pVM);
193VMM_INT_DECL(bool) GIMAreHypercallsEnabled(PVMCPUCC pVCpu);
194VMM_INT_DECL(VBOXSTRICTRC) GIMHypercall(PVMCPUCC pVCpu, PCPUMCTX pCtx);
195VMM_INT_DECL(VBOXSTRICTRC) GIMHypercallEx(PVMCPUCC pVCpu, PCPUMCTX pCtx, unsigned uDisOpcode, uint8_t cbInstr);
196VMM_INT_DECL(VBOXSTRICTRC) GIMExecHypercallInstr(PVMCPUCC pVCpu, PCPUMCTX pCtx, uint8_t *pcbInstr);
197VMM_INT_DECL(VBOXSTRICTRC) GIMXcptUD(PVMCPUCC pVCpu, PCPUMCTX pCtx, PDISCPUSTATE pDis, uint8_t *pcbInstr);
198VMM_INT_DECL(bool) GIMShouldTrapXcptUD(PVMCPUCC pVCpu);
199VMM_INT_DECL(VBOXSTRICTRC) GIMReadMsr(PVMCPUCC pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue);
200VMM_INT_DECL(VBOXSTRICTRC) GIMWriteMsr(PVMCPUCC pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue);
201VMM_INT_DECL(int) GIMQueryHypercallOpcodeBytes(PVM pVM, void *pvBuf, size_t cbBuf,
202 size_t *pcbWritten, uint16_t *puDisOpcode);
203/** @} */
204
205RT_C_DECLS_END
206
207#endif /* !VBOX_INCLUDED_vmm_gim_h */
208
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