1 | /** @file
|
---|
2 | * GIM - Guest Interface Manager.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2014 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_vmm_gim_h
|
---|
27 | #define ___VBox_vmm_gim_h
|
---|
28 |
|
---|
29 | #include <VBox/cdefs.h>
|
---|
30 | #include <VBox/types.h>
|
---|
31 | #include <VBox/param.h>
|
---|
32 |
|
---|
33 | #include <VBox/vmm/cpum.h>
|
---|
34 |
|
---|
35 | /** The value used to specify that VirtualBox must use the newest
|
---|
36 | * implementation version of the GIM provider. */
|
---|
37 | #define GIM_VERSION_LATEST UINT32_C(0)
|
---|
38 |
|
---|
39 | RT_C_DECLS_BEGIN
|
---|
40 |
|
---|
41 | /** @defgroup grp_gim The Guest Interface Manager API
|
---|
42 | * @{
|
---|
43 | */
|
---|
44 |
|
---|
45 | /**
|
---|
46 | * GIM Provider Identifiers.
|
---|
47 | */
|
---|
48 | typedef enum GIMPROVIDERID
|
---|
49 | {
|
---|
50 | /** None. */
|
---|
51 | GIMPROVIDERID_NONE = 0,
|
---|
52 | /** Minimal. */
|
---|
53 | GIMPROVIDERID_MINIMAL,
|
---|
54 | /** Microsoft Hyper-V. */
|
---|
55 | GIMPROVIDERID_HYPERV,
|
---|
56 | /** Linux KVM Interface. */
|
---|
57 | GIMPROVIDERID_KVM
|
---|
58 | } GIMPROVIDERID;
|
---|
59 | AssertCompileSize(GIMPROVIDERID, sizeof(uint32_t));
|
---|
60 |
|
---|
61 |
|
---|
62 | /**
|
---|
63 | * A GIM MMIO2 region record.
|
---|
64 | */
|
---|
65 | typedef struct GIMMMIO2REGION
|
---|
66 | {
|
---|
67 | /** The region index. */
|
---|
68 | uint8_t iRegion;
|
---|
69 | /** Whether an RC mapping is required. */
|
---|
70 | bool fRCMapping;
|
---|
71 | /** Whether this region has been registered. */
|
---|
72 | bool fRegistered;
|
---|
73 | /** Whether this region is currently mapped. */
|
---|
74 | bool fMapped;
|
---|
75 | /** Alignment padding. */
|
---|
76 | uint8_t au8Alignment0[3];
|
---|
77 | /** Size of the region (must be page aligned). */
|
---|
78 | uint32_t cbRegion;
|
---|
79 | /** Alignment padding. */
|
---|
80 | uint32_t u32Alignment0;
|
---|
81 | /** The host ring-0 address of the first page in the region. */
|
---|
82 | R0PTRTYPE(void *) pvPageR0;
|
---|
83 | /** The host ring-3 address of the first page in the region. */
|
---|
84 | R3PTRTYPE(void *) pvPageR3;
|
---|
85 | /** The ring-context address of the first page in the region. */
|
---|
86 | RCPTRTYPE(void *) pvPageRC;
|
---|
87 | /** The guest-physical address of the first page in the region. */
|
---|
88 | RTGCPHYS GCPhysPage;
|
---|
89 | /** The description of the region. */
|
---|
90 | char szDescription[32];
|
---|
91 | } GIMMMIO2REGION;
|
---|
92 | /** Pointer to a GIM MMIO2 region. */
|
---|
93 | typedef GIMMMIO2REGION *PGIMMMIO2REGION;
|
---|
94 | /** Pointer to a const GIM MMIO2 region. */
|
---|
95 | typedef GIMMMIO2REGION const *PCGIMMMIO2REGION;
|
---|
96 | AssertCompileMemberAlignment(GIMMMIO2REGION, cbRegion, 8);
|
---|
97 | AssertCompileMemberAlignment(GIMMMIO2REGION, pvPageR0, 8);
|
---|
98 |
|
---|
99 |
|
---|
100 | #if 0
|
---|
101 | /**
|
---|
102 | * A GIM Hypercall handler.
|
---|
103 | *
|
---|
104 | * @param pVM Pointer to the VMCPU.
|
---|
105 | * @param pCtx Pointer to the guest-CPU context.
|
---|
106 | */
|
---|
107 | typedef DECLCALLBACK(int) FNGIMHYPERCALL(PVMCPU pVCpu, PCPUMCTX pCtx);
|
---|
108 | /** Pointer to a GIM hypercall handler. */
|
---|
109 | typedef FNGIMHYPERCALL *PFNGIMHYPERCALL;
|
---|
110 |
|
---|
111 | /**
|
---|
112 | * A GIM MSR-read handler.
|
---|
113 | *
|
---|
114 | * @returns VBox status code.
|
---|
115 | * @param pVM Pointer to the VMCPU.
|
---|
116 | * @param idMsr The MSR being read.
|
---|
117 | * @param pRange The range that the MSR belongs to.
|
---|
118 | * @param puValue Where to store the value of the MSR.
|
---|
119 | */
|
---|
120 | typedef DECLCALLBACK(int) FNGIMRDMSR(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue);
|
---|
121 | /** Pointer to a GIM MSR-read handler. */
|
---|
122 | typedef FNGIMRDMSR *PFNGIMRDMSR;
|
---|
123 |
|
---|
124 | /**
|
---|
125 | * A GIM MSR-write handler.
|
---|
126 | *
|
---|
127 | * @returns VBox status code.
|
---|
128 | * @param pVM Pointer to the VMCPU.
|
---|
129 | * @param idMsr The MSR being written.
|
---|
130 | * @param pRange The range that the MSR belongs to.
|
---|
131 | * @param uValue The value to set, ignored bits masked.
|
---|
132 | * @param uRawValue The raw value with the ignored bits not masked.
|
---|
133 | */
|
---|
134 | typedef DECLCALLBACK(int) FNGIMWRMSR(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue);
|
---|
135 | /** Pointer to a GIM MSR-write handler. */
|
---|
136 | typedef FNGIMWRMSR *PFNGIMWRMSR;
|
---|
137 | #endif
|
---|
138 |
|
---|
139 |
|
---|
140 | #ifdef IN_RC
|
---|
141 | /** @defgroup grp_gim_rc The GIM Raw-mode Context API
|
---|
142 | * @ingroup grp_gim
|
---|
143 | * @{
|
---|
144 | */
|
---|
145 | /** @} */
|
---|
146 | #endif /* IN_RC */
|
---|
147 |
|
---|
148 | #ifdef IN_RING0
|
---|
149 | /** @defgroup grp_gim_r0 The GIM Host Context Ring-0 API
|
---|
150 | * @ingroup grp_gim
|
---|
151 | * @{
|
---|
152 | */
|
---|
153 | VMMR0_INT_DECL(int) GIMR0InitVM(PVM pVM);
|
---|
154 | VMMR0_INT_DECL(int) GIMR0TermVM(PVM pVM);
|
---|
155 | VMMR0_INT_DECL(int) GIMR0UpdateParavirtTsc(PVM pVM, uint64_t u64Offset);
|
---|
156 | /** @} */
|
---|
157 | #endif /* IN_RING0 */
|
---|
158 |
|
---|
159 |
|
---|
160 | #ifdef IN_RING3
|
---|
161 | /** @defgroup grp_gim_r3 The GIM Host Context Ring-3 API
|
---|
162 | * @ingroup grp_gim
|
---|
163 | * @{
|
---|
164 | */
|
---|
165 | VMMR3_INT_DECL(int) GIMR3Init(PVM pVM);
|
---|
166 | VMMR3_INT_DECL(int) GIMR3Term(PVM pVM);
|
---|
167 | VMMR3_INT_DECL(void) GIMR3Reset(PVM pVM);
|
---|
168 | VMMR3DECL(void) GIMR3GimDeviceRegister(PVM pVM, PPDMDEVINS pDevIns);
|
---|
169 | VMMR3DECL(PGIMMMIO2REGION) GIMR3GetMmio2Regions(PVM pVM, uint32_t *pcRegions);
|
---|
170 | /** @} */
|
---|
171 | #endif /* IN_RING3 */
|
---|
172 |
|
---|
173 | VMMDECL(bool) GIMIsEnabled(PVM pVM);
|
---|
174 | VMMDECL(GIMPROVIDERID) GIMGetProvider(PVM pVM);
|
---|
175 | VMMDECL(bool) GIMIsParavirtTscEnabled(PVM pVM);
|
---|
176 | VMM_INT_DECL(int) GIMHypercall(PVMCPU pVCpu, PCPUMCTX pCtx);
|
---|
177 | VMM_INT_DECL(int) GIMReadMsr(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue);
|
---|
178 | VMM_INT_DECL(int) GIMWriteMsr(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue);
|
---|
179 |
|
---|
180 | /** @} */
|
---|
181 |
|
---|
182 | RT_C_DECLS_END
|
---|
183 |
|
---|
184 | #endif /* ___VBox_vmm_gim_h */
|
---|
185 |
|
---|