VirtualBox

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

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

VMM,++: Refactoring code to use VMMC & VMMCPUCC. bugref:9217

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