1 | /* $Id: gvmm.h 28800 2010-04-27 08:22:32Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * GVMM - The Global VM Manager. (VMM)
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2007 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * The contents of this file may alternatively be used under the terms
|
---|
18 | * of the Common Development and Distribution License Version 1.0
|
---|
19 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
20 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
21 | * CDDL are applicable instead of those of the GPL.
|
---|
22 | *
|
---|
23 | * You may elect to license modified versions of this file under the
|
---|
24 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
25 | */
|
---|
26 |
|
---|
27 | #ifndef ___VBox_gvmm_h
|
---|
28 | #define ___VBox_gvmm_h
|
---|
29 |
|
---|
30 | #include <VBox/cdefs.h>
|
---|
31 | #include <VBox/types.h>
|
---|
32 | #include <VBox/sup.h>
|
---|
33 |
|
---|
34 | RT_C_DECLS_BEGIN
|
---|
35 |
|
---|
36 | /** @defgroup grp_GVMM GVMM - The Global VM Manager.
|
---|
37 | * @{
|
---|
38 | */
|
---|
39 |
|
---|
40 | /** @def IN_GVMM_R0
|
---|
41 | * Used to indicate whether we're inside the same link module as the ring 0
|
---|
42 | * part of the Global VM Manager or not.
|
---|
43 | */
|
---|
44 | #ifdef DOXYGEN_RUNNING
|
---|
45 | # define IN_GVMM_R0
|
---|
46 | #endif
|
---|
47 | /** @def GVMMR0DECL
|
---|
48 | * Ring 0 VM export or import declaration.
|
---|
49 | * @param type The return type of the function declaration.
|
---|
50 | */
|
---|
51 | #ifdef IN_GVMM_R0
|
---|
52 | # define GVMMR0DECL(type) DECLEXPORT(type) VBOXCALL
|
---|
53 | #else
|
---|
54 | # define GVMMR0DECL(type) DECLIMPORT(type) VBOXCALL
|
---|
55 | #endif
|
---|
56 |
|
---|
57 | /** @def NIL_GVM_HANDLE
|
---|
58 | * The nil GVM VM handle value (VM::hSelf).
|
---|
59 | */
|
---|
60 | #define NIL_GVM_HANDLE 0
|
---|
61 |
|
---|
62 |
|
---|
63 | /**
|
---|
64 | * The scheduler statistics
|
---|
65 | */
|
---|
66 | typedef struct GVMMSTATSSCHED
|
---|
67 | {
|
---|
68 | /** The number of calls to GVMMR0SchedHalt. */
|
---|
69 | uint64_t cHaltCalls;
|
---|
70 | /** The number of times we did go to sleep in GVMMR0SchedHalt. */
|
---|
71 | uint64_t cHaltBlocking;
|
---|
72 | /** The number of times we timed out in GVMMR0SchedHalt. */
|
---|
73 | uint64_t cHaltTimeouts;
|
---|
74 | /** The number of times we didn't go to sleep in GVMMR0SchedHalt. */
|
---|
75 | uint64_t cHaltNotBlocking;
|
---|
76 | /** The number of wake ups done during GVMMR0SchedHalt. */
|
---|
77 | uint64_t cHaltWakeUps;
|
---|
78 |
|
---|
79 | /** The number of calls to GVMMR0WakeUp. */
|
---|
80 | uint64_t cWakeUpCalls;
|
---|
81 | /** The number of times the EMT thread wasn't actually halted when GVMMR0WakeUp
|
---|
82 | * was called. */
|
---|
83 | uint64_t cWakeUpNotHalted;
|
---|
84 | /** The number of wake ups done during GVMMR0WakeUp (not counting the explicit
|
---|
85 | * one). */
|
---|
86 | uint64_t cWakeUpWakeUps;
|
---|
87 |
|
---|
88 | /** The number of calls to GVMMR0Poke. */
|
---|
89 | uint64_t cPokeCalls;
|
---|
90 | /** The number of times the EMT thread wasn't actually busy when
|
---|
91 | * GVMMR0Poke was called. */
|
---|
92 | uint64_t cPokeNotBusy;
|
---|
93 |
|
---|
94 | /** The number of calls to GVMMR0SchedPoll. */
|
---|
95 | uint64_t cPollCalls;
|
---|
96 | /** The number of times the EMT has halted in a GVMMR0SchedPoll call. */
|
---|
97 | uint64_t cPollHalts;
|
---|
98 | /** The number of wake ups done during GVMMR0SchedPoll. */
|
---|
99 | uint64_t cPollWakeUps;
|
---|
100 |
|
---|
101 | uint64_t u64Alignment; /**< padding */
|
---|
102 | } GVMMSTATSSCHED;
|
---|
103 | /** Pointer to the GVMM scheduler statistics. */
|
---|
104 | typedef GVMMSTATSSCHED *PGVMMSTATSSCHED;
|
---|
105 |
|
---|
106 | /**
|
---|
107 | * The GMM statistics.
|
---|
108 | */
|
---|
109 | typedef struct GVMMSTATS
|
---|
110 | {
|
---|
111 | /** The VM statistics if a VM was specified. */
|
---|
112 | GVMMSTATSSCHED SchedVM;
|
---|
113 | /** The sum statistics of all VMs accessible to the caller. */
|
---|
114 | GVMMSTATSSCHED SchedSum;
|
---|
115 | /** The number of VMs accessible to the caller. */
|
---|
116 | uint32_t cVMs;
|
---|
117 | /** The number of emulation threads in those VMs. */
|
---|
118 | uint32_t cEMTs;
|
---|
119 | } GVMMSTATS;
|
---|
120 | /** Pointer to the GVMM statistics. */
|
---|
121 | typedef GVMMSTATS *PGVMMSTATS;
|
---|
122 | /** Const pointer to the GVMM statistics. */
|
---|
123 | typedef const GVMMSTATS *PCGVMMSTATS;
|
---|
124 |
|
---|
125 |
|
---|
126 |
|
---|
127 | GVMMR0DECL(int) GVMMR0Init(void);
|
---|
128 | GVMMR0DECL(void) GVMMR0Term(void);
|
---|
129 | GVMMR0DECL(int) GVMMR0SetConfig(PSUPDRVSESSION pSession, const char *pszName, uint64_t u64Value);
|
---|
130 | GVMMR0DECL(int) GVMMR0QueryConfig(PSUPDRVSESSION pSession, const char *pszName, uint64_t *pu64Value);
|
---|
131 |
|
---|
132 | GVMMR0DECL(int) GVMMR0CreateVM(PSUPDRVSESSION pSession, uint32_t cCpus, PVM *ppVM);
|
---|
133 | GVMMR0DECL(int) GVMMR0InitVM(PVM pVM);
|
---|
134 | GVMMR0DECL(void) GVMMR0DoneInitVM(PVM pVM);
|
---|
135 | GVMMR0DECL(bool) GVMMR0DoingTermVM(PVM pVM, PGVM pGVM);
|
---|
136 | GVMMR0DECL(int) GVMMR0DestroyVM(PVM pVM);
|
---|
137 | GVMMR0DECL(int) GVMMR0RegisterVCpu(PVM pVM, VMCPUID idCpu);
|
---|
138 | GVMMR0DECL(PGVM) GVMMR0ByHandle(uint32_t hGVM);
|
---|
139 | GVMMR0DECL(PGVM) GVMMR0ByVM(PVM pVM);
|
---|
140 | GVMMR0DECL(int) GVMMR0ByVMAndEMT(PVM pVM, VMCPUID idCpu, PGVM *ppGVM);
|
---|
141 | GVMMR0DECL(PVM) GVMMR0GetVMByHandle(uint32_t hGVM);
|
---|
142 | GVMMR0DECL(PVM) GVMMR0GetVMByEMT(RTNATIVETHREAD hEMT);
|
---|
143 | GVMMR0DECL(int) GVMMR0SchedHalt(PVM pVM, VMCPUID idCpu, uint64_t u64ExpireGipTime);
|
---|
144 | GVMMR0DECL(int) GVMMR0SchedWakeUp(PVM pVM, VMCPUID idCpu);
|
---|
145 | GVMMR0DECL(int) GVMMR0SchedWakeUpEx(PVM pVM, VMCPUID idCpu, bool fTakeUsedLock);
|
---|
146 | GVMMR0DECL(int) GVMMR0SchedPoke(PVM pVM, VMCPUID idCpu);
|
---|
147 | GVMMR0DECL(int) GVMMR0SchedPokeEx(PVM pVM, VMCPUID idCpu, bool fTakeUsedLock);
|
---|
148 | GVMMR0DECL(int) GVMMR0SchedWakeUpAndPokeCpus(PVM pVM, PCVMCPUSET pSleepSet, PCVMCPUSET pPokeSet);
|
---|
149 | GVMMR0DECL(int) GVMMR0SchedPoll(PVM pVM, VMCPUID idCpu, bool fYield);
|
---|
150 | GVMMR0DECL(int) GVMMR0QueryStatistics(PGVMMSTATS pStats, PSUPDRVSESSION pSession, PVM pVM);
|
---|
151 | GVMMR0DECL(int) GVMMR0ResetStatistics(PCGVMMSTATS pStats, PSUPDRVSESSION pSession, PVM pVM);
|
---|
152 |
|
---|
153 |
|
---|
154 | /**
|
---|
155 | * Request packet for calling GVMMR0CreateVM.
|
---|
156 | */
|
---|
157 | typedef struct GVMMCREATEVMREQ
|
---|
158 | {
|
---|
159 | /** The request header. */
|
---|
160 | SUPVMMR0REQHDR Hdr;
|
---|
161 | /** The support driver session. (IN) */
|
---|
162 | PSUPDRVSESSION pSession;
|
---|
163 | /** Number of virtual CPUs for the new VM. (IN) */
|
---|
164 | uint32_t cCpus;
|
---|
165 | /** Pointer to the ring-3 mapping of the shared VM structure on return. (OUT) */
|
---|
166 | PVMR3 pVMR3;
|
---|
167 | /** Pointer to the ring-0 mapping of the shared VM structure on return. (OUT) */
|
---|
168 | PVMR0 pVMR0;
|
---|
169 | } GVMMCREATEVMREQ;
|
---|
170 | /** Pointer to a GVMMR0CreateVM request packet. */
|
---|
171 | typedef GVMMCREATEVMREQ *PGVMMCREATEVMREQ;
|
---|
172 |
|
---|
173 | GVMMR0DECL(int) GVMMR0CreateVMReq(PGVMMCREATEVMREQ pReq);
|
---|
174 |
|
---|
175 |
|
---|
176 | /**
|
---|
177 | * Request buffer for GVMMR0SchedWakeUpAndPokeCpusReq / VMMR0_DO_GVMM_SCHED_WAKE_UP_AND_POKE_CPUS.
|
---|
178 | * @see GVMMR0SchedWakeUpAndPokeCpus.
|
---|
179 | */
|
---|
180 | typedef struct GVMMSCHEDWAKEUPANDPOKECPUSREQ /* nice and unreadable... */
|
---|
181 | {
|
---|
182 | /** The header. */
|
---|
183 | SUPVMMR0REQHDR Hdr;
|
---|
184 | /** The sleeper set. */
|
---|
185 | VMCPUSET SleepSet;
|
---|
186 | /** The set of virtual CPUs to poke. */
|
---|
187 | VMCPUSET PokeSet;
|
---|
188 | } GVMMSCHEDWAKEUPANDPOKECPUSREQ;
|
---|
189 | /** Pointer to a GVMMR0QueryStatisticsReq / VMMR0_DO_GVMM_QUERY_STATISTICS request buffer. */
|
---|
190 | typedef GVMMSCHEDWAKEUPANDPOKECPUSREQ *PGVMMSCHEDWAKEUPANDPOKECPUSREQ;
|
---|
191 |
|
---|
192 | GVMMR0DECL(int) GVMMR0SchedWakeUpAndPokeCpusReq(PVM pVM, PGVMMSCHEDWAKEUPANDPOKECPUSREQ pReq);
|
---|
193 |
|
---|
194 |
|
---|
195 | /**
|
---|
196 | * Request buffer for GVMMR0QueryStatisticsReq / VMMR0_DO_GVMM_QUERY_STATISTICS.
|
---|
197 | * @see GVMMR0QueryStatistics.
|
---|
198 | */
|
---|
199 | typedef struct GVMMQUERYSTATISTICSSREQ
|
---|
200 | {
|
---|
201 | /** The header. */
|
---|
202 | SUPVMMR0REQHDR Hdr;
|
---|
203 | /** The support driver session. */
|
---|
204 | PSUPDRVSESSION pSession;
|
---|
205 | /** The statistics. */
|
---|
206 | GVMMSTATS Stats;
|
---|
207 | } GVMMQUERYSTATISTICSSREQ;
|
---|
208 | /** Pointer to a GVMMR0QueryStatisticsReq / VMMR0_DO_GVMM_QUERY_STATISTICS request buffer. */
|
---|
209 | typedef GVMMQUERYSTATISTICSSREQ *PGVMMQUERYSTATISTICSSREQ;
|
---|
210 |
|
---|
211 | GVMMR0DECL(int) GVMMR0QueryStatisticsReq(PVM pVM, PGVMMQUERYSTATISTICSSREQ pReq);
|
---|
212 |
|
---|
213 |
|
---|
214 | /**
|
---|
215 | * Request buffer for GVMMR0ResetStatisticsReq / VMMR0_DO_GVMM_RESET_STATISTICS.
|
---|
216 | * @see GVMMR0ResetStatistics.
|
---|
217 | */
|
---|
218 | typedef struct GVMMRESETSTATISTICSSREQ
|
---|
219 | {
|
---|
220 | /** The header. */
|
---|
221 | SUPVMMR0REQHDR Hdr;
|
---|
222 | /** The support driver session. */
|
---|
223 | PSUPDRVSESSION pSession;
|
---|
224 | /** The statistics to reset.
|
---|
225 | * Any non-zero entry will be reset (if permitted). */
|
---|
226 | GVMMSTATS Stats;
|
---|
227 | } GVMMRESETSTATISTICSSREQ;
|
---|
228 | /** Pointer to a GVMMR0ResetStatisticsReq / VMMR0_DO_GVMM_RESET_STATISTICS request buffer. */
|
---|
229 | typedef GVMMRESETSTATISTICSSREQ *PGVMMRESETSTATISTICSSREQ;
|
---|
230 |
|
---|
231 | GVMMR0DECL(int) GVMMR0ResetStatisticsReq(PVM pVM, PGVMMRESETSTATISTICSSREQ pReq);
|
---|
232 |
|
---|
233 |
|
---|
234 | /** @} */
|
---|
235 |
|
---|
236 | RT_C_DECLS_END
|
---|
237 |
|
---|
238 | #endif
|
---|
239 |
|
---|