1 | /* $Id: gvmm.h 5240 2007-10-11 15:57:00Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * GVMM - The Global VM Manager.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2007 InnoTek Systemberatung GmbH
|
---|
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 as published by the Free Software Foundation,
|
---|
13 | * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
14 | * distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
15 | * be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | */
|
---|
18 |
|
---|
19 | #ifndef ___VBox_gvmm_h
|
---|
20 | #define ___VBox_gvmm_h
|
---|
21 |
|
---|
22 | #include <VBox/cdefs.h>
|
---|
23 | #include <VBox/types.h>
|
---|
24 | #include <VBox/sup.h>
|
---|
25 |
|
---|
26 | __BEGIN_DECLS
|
---|
27 |
|
---|
28 | /** @defgroup grp_GVMM GVMM - The Global VM Manager.
|
---|
29 | * @{
|
---|
30 | */
|
---|
31 |
|
---|
32 | /** @def IN_GVMM_R0
|
---|
33 | * Used to indicate whether we're inside the same link module as the ring 0
|
---|
34 | * part of the Global VM Manager or not.
|
---|
35 | */
|
---|
36 | /** @def GVMMR0DECL
|
---|
37 | * Ring 0 VM export or import declaration.
|
---|
38 | * @param type The return type of the function declaration.
|
---|
39 | */
|
---|
40 | #ifdef IN_GVMM_R0
|
---|
41 | # define GVMMR0DECL(type) DECLEXPORT(type) VBOXCALL
|
---|
42 | #else
|
---|
43 | # define GVMMR0DECL(type) DECLIMPORT(type) VBOXCALL
|
---|
44 | #endif
|
---|
45 |
|
---|
46 | /** @def NIL_GVM_HANDLE
|
---|
47 | * The nil GVM VM handle value (VM::hSelf).
|
---|
48 | */
|
---|
49 | #define NIL_GVM_HANDLE 0
|
---|
50 |
|
---|
51 |
|
---|
52 | /**
|
---|
53 | * The scheduler statistics
|
---|
54 | */
|
---|
55 | typedef struct GVMMSTATSSCHED
|
---|
56 | {
|
---|
57 | /** The number of calls to GVMMR0SchedHalt. */
|
---|
58 | uint64_t cHaltCalls;
|
---|
59 | /** The number of times we did go to sleep in GVMMR0SchedHalt. */
|
---|
60 | uint64_t cHaltBlocking;
|
---|
61 | /** The number of times we timed out in GVMMR0SchedHalt. */
|
---|
62 | uint64_t cHaltTimeouts;
|
---|
63 | /** The number of times we didn't go to sleep in GVMMR0SchedHalt. */
|
---|
64 | uint64_t cHaltNotBlocking;
|
---|
65 | /** The number of wake ups done during GVMMR0SchedHalt. */
|
---|
66 | uint64_t cHaltWakeUps;
|
---|
67 |
|
---|
68 | /** The number of calls to GVMMR0WakeUp. */
|
---|
69 | uint64_t cWakeUpCalls;
|
---|
70 | /** The number of times the EMT thread wasn't actually halted when GVMMR0WakeUp was called. */
|
---|
71 | uint64_t cWakeUpNotHalted;
|
---|
72 | /** The number of wake ups done during GVMMR0WakeUp (not counting the explicit one). */
|
---|
73 | uint64_t cWakeUpWakeUps;
|
---|
74 |
|
---|
75 | /** The number of calls to GVMMR0SchedPoll. */
|
---|
76 | uint64_t cPollCalls;
|
---|
77 | /** The number of times the EMT has halted in a GVMMR0SchedPoll call. */
|
---|
78 | uint64_t cPollHalts;
|
---|
79 | /** The number of wake ups done during GVMMR0SchedPoll. */
|
---|
80 | uint64_t cPollWakeUps;
|
---|
81 | uint64_t u64Alignment; /**< padding */
|
---|
82 | } GVMMSTATSSCHED;
|
---|
83 | /** Pointer to the GVMM scheduler statistics. */
|
---|
84 | typedef GVMMSTATSSCHED *PGVMMSTATSSCHED;
|
---|
85 |
|
---|
86 | /**
|
---|
87 | * The GMM statistics.
|
---|
88 | */
|
---|
89 | typedef struct GVMMSTATS
|
---|
90 | {
|
---|
91 | /** The VM statistics if a VM was specified. */
|
---|
92 | GVMMSTATSSCHED SchedVM;
|
---|
93 | /** The sum statistics of all VMs accessible to the caller. */
|
---|
94 | GVMMSTATSSCHED SchedSum;
|
---|
95 | /** The number of VMs accessible to the caller. */
|
---|
96 | uint32_t cVMs;
|
---|
97 | /** Alignment padding. */
|
---|
98 | uint32_t u32Padding;
|
---|
99 | } GVMMSTATS;
|
---|
100 | /** Pointer to the GVMM statistics. */
|
---|
101 | typedef GVMMSTATS *PGVMMSTATS;
|
---|
102 | /** Const pointer to the GVMM statistics. */
|
---|
103 | typedef const GVMMSTATS *PCGVMMSTATS;
|
---|
104 |
|
---|
105 |
|
---|
106 |
|
---|
107 | GVMMR0DECL(int) GVMMR0Init(void);
|
---|
108 | GVMMR0DECL(void) GVMMR0Term(void);
|
---|
109 | GVMMR0DECL(int) GVMMR0SetConfig(PSUPDRVSESSION pSession, const char *pszName, uint64_t u64Value);
|
---|
110 | GVMMR0DECL(int) GVMMR0QueryConfig(PSUPDRVSESSION pSession, const char *pszName, uint64_t *pu64Value);
|
---|
111 |
|
---|
112 | GVMMR0DECL(int) GVMMR0CreateVM(PSUPDRVSESSION pSession, PVM *ppVM);
|
---|
113 | GVMMR0DECL(int) GVMMR0DisassociateEMTFromVM(PVM pVM);
|
---|
114 | GVMMR0DECL(int) GVMMR0InitVM(PVM pVM);
|
---|
115 | GVMMR0DECL(int) GVMMR0AssociateEMTWithVM(PVM pVM);
|
---|
116 | GVMMR0DECL(int) GVMMR0DestroyVM(PVM pVM);
|
---|
117 | GVMMR0DECL(PGVM) GVMMR0ByHandle(uint32_t hGVM);
|
---|
118 | GVMMR0DECL(PGVM) GVMMR0ByVM(PVM pVM);
|
---|
119 | GVMMR0DECL(int) GVMMR0ByVMAndEMT(PVM pVM, PGVM *ppGVM);
|
---|
120 | GVMMR0DECL(PVM) GVMMR0GetVMByHandle(uint32_t hGVM);
|
---|
121 | GVMMR0DECL(PVM) GVMMR0GetVMByEMT(RTNATIVETHREAD hEMT);
|
---|
122 | GVMMR0DECL(int) GVMMR0SchedHalt(PVM pVM, uint64_t u64ExpireGipTime);
|
---|
123 | GVMMR0DECL(int) GVMMR0SchedWakeUp(PVM pVM);
|
---|
124 | GVMMR0DECL(int) GVMMR0SchedPoll(PVM pVM, bool fYield);
|
---|
125 | GVMMR0DECL(int) GVMMR0QueryStatistics(PGVMMSTATS pStats, PSUPDRVSESSION pSession, PVM pVM);
|
---|
126 | GVMMR0DECL(int) GVMMR0ResetStatistics(PCGVMMSTATS pStats, PSUPDRVSESSION pSession, PVM pVM);
|
---|
127 |
|
---|
128 |
|
---|
129 | /**
|
---|
130 | * Request packet for calling GVMMR0CreateVM.
|
---|
131 | */
|
---|
132 | typedef struct GVMMCREATEVMREQ
|
---|
133 | {
|
---|
134 | /** The request header. */
|
---|
135 | SUPVMMR0REQHDR Hdr;
|
---|
136 | /** The support driver session. (IN) */
|
---|
137 | PSUPDRVSESSION pSession;
|
---|
138 | /** Pointer to the ring-3 mapping of the shared VM structure on return. (OUT) */
|
---|
139 | PVMR3 pVMR3;
|
---|
140 | /** Pointer to the ring-0 mapping of the shared VM structure on return. (OUT) */
|
---|
141 | PVMR0 pVMR0;
|
---|
142 | } GVMMCREATEVMREQ;
|
---|
143 | /** Pointer to a GVMMR0CreateVM request packet. */
|
---|
144 | typedef GVMMCREATEVMREQ *PGVMMCREATEVMREQ;
|
---|
145 |
|
---|
146 | GVMMR0DECL(int) GVMMR0CreateVMReq(PGVMMCREATEVMREQ pReq);
|
---|
147 |
|
---|
148 |
|
---|
149 | /**
|
---|
150 | * Request buffer for GVMMR0QueryStatisticsReq / VMMR0_DO_GVMM_QUERY_STATISTICS.
|
---|
151 | * @see GVMMR0QueryStatistics.
|
---|
152 | */
|
---|
153 | typedef struct GVMMQUERYSTATISTICSSREQ
|
---|
154 | {
|
---|
155 | /** The header. */
|
---|
156 | SUPVMMR0REQHDR Hdr;
|
---|
157 | /** The support driver session. */
|
---|
158 | PSUPDRVSESSION pSession;
|
---|
159 | /** The statistics. */
|
---|
160 | GVMMSTATS Stats;
|
---|
161 | } GVMMQUERYSTATISTICSSREQ;
|
---|
162 | /** Pointer to a GVMMR0QueryStatisticsReq / VMMR0_DO_GVMM_QUERY_STATISTICS request buffer. */
|
---|
163 | typedef GVMMQUERYSTATISTICSSREQ *PGVMMQUERYSTATISTICSSREQ;
|
---|
164 |
|
---|
165 | GVMMR0DECL(int) GVMMR0QueryStatisticsReq(PVM pVM, PGVMMQUERYSTATISTICSSREQ pReq);
|
---|
166 |
|
---|
167 |
|
---|
168 | /**
|
---|
169 | * Request buffer for GVMMR0ResetStatisticsReq / VMMR0_DO_GVMM_RESET_STATISTICS.
|
---|
170 | * @see GVMMR0ResetStatistics.
|
---|
171 | */
|
---|
172 | typedef struct GVMMRESETSTATISTICSSREQ
|
---|
173 | {
|
---|
174 | /** The header. */
|
---|
175 | SUPVMMR0REQHDR Hdr;
|
---|
176 | /** The support driver session. */
|
---|
177 | PSUPDRVSESSION pSession;
|
---|
178 | /** The statistics to reset.
|
---|
179 | * Any non-zero entry will be reset (if permitted). */
|
---|
180 | GVMMSTATS Stats;
|
---|
181 | } GVMMRESETSTATISTICSSREQ;
|
---|
182 | /** Pointer to a GVMMR0ResetStatisticsReq / VMMR0_DO_GVMM_RESET_STATISTICS request buffer. */
|
---|
183 | typedef GVMMRESETSTATISTICSSREQ *PGVMMRESETSTATISTICSSREQ;
|
---|
184 |
|
---|
185 | GVMMR0DECL(int) GVMMR0ResetStatisticsReq(PVM pVM, PGVMMRESETSTATISTICSSREQ pReq);
|
---|
186 |
|
---|
187 |
|
---|
188 | /** @} */
|
---|
189 |
|
---|
190 | __END_DECLS
|
---|
191 |
|
---|
192 | #endif
|
---|
193 |
|
---|