VirtualBox

source: vbox/trunk/include/VBox/gvmm.h@ 32718

Last change on this file since 32718 was 32489, checked in by vboxsync, 14 years ago

VMM: More work on the periodic preemption timer (no actual timers yet).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 8.3 KB
Line 
1/* $Id: gvmm.h 32489 2010-09-14 15:50:31Z 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
34RT_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 */
66typedef 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. */
104typedef GVMMSTATSSCHED *PGVMMSTATSSCHED;
105
106/**
107 * The GMM statistics.
108 */
109typedef 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. */
121typedef GVMMSTATS *PGVMMSTATS;
122/** Const pointer to the GVMM statistics. */
123typedef const GVMMSTATS *PCGVMMSTATS;
124
125
126
127GVMMR0DECL(int) GVMMR0Init(void);
128GVMMR0DECL(void) GVMMR0Term(void);
129GVMMR0DECL(int) GVMMR0SetConfig(PSUPDRVSESSION pSession, const char *pszName, uint64_t u64Value);
130GVMMR0DECL(int) GVMMR0QueryConfig(PSUPDRVSESSION pSession, const char *pszName, uint64_t *pu64Value);
131
132GVMMR0DECL(int) GVMMR0CreateVM(PSUPDRVSESSION pSession, uint32_t cCpus, PVM *ppVM);
133GVMMR0DECL(int) GVMMR0InitVM(PVM pVM);
134GVMMR0DECL(void) GVMMR0DoneInitVM(PVM pVM);
135GVMMR0DECL(bool) GVMMR0DoingTermVM(PVM pVM, PGVM pGVM);
136GVMMR0DECL(int) GVMMR0DestroyVM(PVM pVM);
137GVMMR0DECL(int) GVMMR0RegisterVCpu(PVM pVM, VMCPUID idCpu);
138GVMMR0DECL(PGVM) GVMMR0ByHandle(uint32_t hGVM);
139GVMMR0DECL(int) GVMMR0ByVM(PVM pVM, PGVM *ppGVM);
140GVMMR0DECL(int) GVMMR0ByVMAndEMT(PVM pVM, VMCPUID idCpu, PGVM *ppGVM);
141GVMMR0DECL(PVM) GVMMR0GetVMByHandle(uint32_t hGVM);
142GVMMR0DECL(PVM) GVMMR0GetVMByEMT(RTNATIVETHREAD hEMT);
143GVMMR0DECL(int) GVMMR0SchedHalt(PVM pVM, VMCPUID idCpu, uint64_t u64ExpireGipTime);
144GVMMR0DECL(int) GVMMR0SchedWakeUp(PVM pVM, VMCPUID idCpu);
145GVMMR0DECL(int) GVMMR0SchedWakeUpEx(PVM pVM, VMCPUID idCpu, bool fTakeUsedLock);
146GVMMR0DECL(int) GVMMR0SchedPoke(PVM pVM, VMCPUID idCpu);
147GVMMR0DECL(int) GVMMR0SchedPokeEx(PVM pVM, VMCPUID idCpu, bool fTakeUsedLock);
148GVMMR0DECL(int) GVMMR0SchedWakeUpAndPokeCpus(PVM pVM, PCVMCPUSET pSleepSet, PCVMCPUSET pPokeSet);
149GVMMR0DECL(int) GVMMR0SchedPoll(PVM pVM, VMCPUID idCpu, bool fYield);
150GVMMR0DECL(void) GVMMR0SchedUpdatePeriodicPreemptionTimer(PVM pVM, RTCPUID idHostCpu, uint32_t uHz);
151GVMMR0DECL(int) GVMMR0QueryStatistics(PGVMMSTATS pStats, PSUPDRVSESSION pSession, PVM pVM);
152GVMMR0DECL(int) GVMMR0ResetStatistics(PCGVMMSTATS pStats, PSUPDRVSESSION pSession, PVM pVM);
153
154
155/**
156 * Request packet for calling GVMMR0CreateVM.
157 */
158typedef struct GVMMCREATEVMREQ
159{
160 /** The request header. */
161 SUPVMMR0REQHDR Hdr;
162 /** The support driver session. (IN) */
163 PSUPDRVSESSION pSession;
164 /** Number of virtual CPUs for the new VM. (IN) */
165 uint32_t cCpus;
166 /** Pointer to the ring-3 mapping of the shared VM structure on return. (OUT) */
167 PVMR3 pVMR3;
168 /** Pointer to the ring-0 mapping of the shared VM structure on return. (OUT) */
169 PVMR0 pVMR0;
170} GVMMCREATEVMREQ;
171/** Pointer to a GVMMR0CreateVM request packet. */
172typedef GVMMCREATEVMREQ *PGVMMCREATEVMREQ;
173
174GVMMR0DECL(int) GVMMR0CreateVMReq(PGVMMCREATEVMREQ pReq);
175
176
177/**
178 * Request buffer for GVMMR0SchedWakeUpAndPokeCpusReq / VMMR0_DO_GVMM_SCHED_WAKE_UP_AND_POKE_CPUS.
179 * @see GVMMR0SchedWakeUpAndPokeCpus.
180 */
181typedef struct GVMMSCHEDWAKEUPANDPOKECPUSREQ /* nice and unreadable... */
182{
183 /** The header. */
184 SUPVMMR0REQHDR Hdr;
185 /** The sleeper set. */
186 VMCPUSET SleepSet;
187 /** The set of virtual CPUs to poke. */
188 VMCPUSET PokeSet;
189} GVMMSCHEDWAKEUPANDPOKECPUSREQ;
190/** Pointer to a GVMMR0QueryStatisticsReq / VMMR0_DO_GVMM_QUERY_STATISTICS request buffer. */
191typedef GVMMSCHEDWAKEUPANDPOKECPUSREQ *PGVMMSCHEDWAKEUPANDPOKECPUSREQ;
192
193GVMMR0DECL(int) GVMMR0SchedWakeUpAndPokeCpusReq(PVM pVM, PGVMMSCHEDWAKEUPANDPOKECPUSREQ pReq);
194
195
196/**
197 * Request buffer for GVMMR0QueryStatisticsReq / VMMR0_DO_GVMM_QUERY_STATISTICS.
198 * @see GVMMR0QueryStatistics.
199 */
200typedef struct GVMMQUERYSTATISTICSSREQ
201{
202 /** The header. */
203 SUPVMMR0REQHDR Hdr;
204 /** The support driver session. */
205 PSUPDRVSESSION pSession;
206 /** The statistics. */
207 GVMMSTATS Stats;
208} GVMMQUERYSTATISTICSSREQ;
209/** Pointer to a GVMMR0QueryStatisticsReq / VMMR0_DO_GVMM_QUERY_STATISTICS request buffer. */
210typedef GVMMQUERYSTATISTICSSREQ *PGVMMQUERYSTATISTICSSREQ;
211
212GVMMR0DECL(int) GVMMR0QueryStatisticsReq(PVM pVM, PGVMMQUERYSTATISTICSSREQ pReq);
213
214
215/**
216 * Request buffer for GVMMR0ResetStatisticsReq / VMMR0_DO_GVMM_RESET_STATISTICS.
217 * @see GVMMR0ResetStatistics.
218 */
219typedef struct GVMMRESETSTATISTICSSREQ
220{
221 /** The header. */
222 SUPVMMR0REQHDR Hdr;
223 /** The support driver session. */
224 PSUPDRVSESSION pSession;
225 /** The statistics to reset.
226 * Any non-zero entry will be reset (if permitted). */
227 GVMMSTATS Stats;
228} GVMMRESETSTATISTICSSREQ;
229/** Pointer to a GVMMR0ResetStatisticsReq / VMMR0_DO_GVMM_RESET_STATISTICS request buffer. */
230typedef GVMMRESETSTATISTICSSREQ *PGVMMRESETSTATISTICSSREQ;
231
232GVMMR0DECL(int) GVMMR0ResetStatisticsReq(PVM pVM, PGVMMRESETSTATISTICSSREQ pReq);
233
234
235/** @} */
236
237RT_C_DECLS_END
238
239#endif
240
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