VirtualBox

source: vbox/trunk/include/VBox/hwaccm.h@ 7471

Last change on this file since 7471 was 7471, checked in by vboxsync, 17 years ago

Rewrote VT-x & AMD-V mode changes. Requires the MP apis in our runtime to function properly. (only tested Windows)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.6 KB
Line 
1/** @file
2 * HWACCM - Intel/AMD VM Hardware Support Manager
3 */
4
5/*
6 * Copyright (C) 2006-2007 innotek GmbH
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_hwaccm_h
27#define ___VBox_hwaccm_h
28
29#include <VBox/cdefs.h>
30#include <VBox/types.h>
31#include <VBox/pgm.h>
32#include <iprt/mp.h>
33
34
35/** @defgroup grp_hwaccm The VM Hardware Manager API
36 * @{
37 */
38
39/**
40 * HWACCM state
41 */
42typedef enum HWACCMSTATE
43{
44 /* Not yet set */
45 HWACCMSTATE_UNINITIALIZED = 0,
46 /* Enabled */
47 HWACCMSTATE_ENABLED,
48 /* Disabled */
49 HWACCMSTATE_DISABLED,
50 /** The usual 32-bit hack. */
51 HWACCMSTATE_32BIT_HACK = 0x7fffffff
52} HWACCMSTATE;
53
54__BEGIN_DECLS
55
56/**
57 * Query HWACCM state (enabled/disabled)
58 *
59 * @returns 0 - disabled, 1 - enabled
60 * @param pVM The VM to operate on.
61 */
62#define HWACCMIsEnabled(a) (a->fHWACCMEnabled)
63
64#ifdef IN_RING0
65/** @defgroup grp_hwaccm_r0 The VM Hardware Manager API
66 * @ingroup grp_hwaccm
67 * @{
68 */
69
70/**
71 * Does global Ring-0 HWACCM initialization.
72 *
73 * @returns VBox status code.
74 */
75HWACCMR0DECL(int) HWACCMR0Init();
76
77/**
78 * Does global Ring-0 HWACCM termination.
79 *
80 * @returns VBox status code.
81 */
82HWACCMR0DECL(int) HWACCMR0Term();
83
84/**
85 * Does Ring-0 per VM HWACCM initialization.
86 *
87 * This is mainly to check that the Host CPU mode is compatible
88 * with VMX or SVM.
89 *
90 * @returns VBox status code.
91 * @param pVM The VM to operate on.
92 */
93HWACCMR0DECL(int) HWACCMR0InitVM(PVM pVM);
94
95/**
96 * Sets up HWACCM on all cpus.
97 *
98 * @returns VBox status code.
99 * @param pVM The VM to operate on.
100 * @param enmNewHwAccmState New hwaccm state
101 *
102 */
103HWACCMR0DECL(int) HWACCMR0EnableAllCpus(PVM pVM, HWACCMSTATE enmNewHwAccmState);
104
105/** @} */
106#endif
107
108
109#ifdef IN_RING3
110/** @defgroup grp_hwaccm_r3 The VM Hardware Manager API
111 * @ingroup grp_hwaccm
112 * @{
113 */
114
115/**
116 * Checks if internal events are pending
117 *
118 * @returns boolean
119 * @param pVM The VM to operate on.
120 */
121HWACCMR3DECL(bool) HWACCMR3IsEventPending(PVM pVM);
122
123/**
124 * Initializes the HWACCM.
125 *
126 * @returns VBox status code.
127 * @param pVM The VM to operate on.
128 */
129HWACCMR3DECL(int) HWACCMR3Init(PVM pVM);
130
131/**
132 * Initialize VT-x or AMD-V
133 *
134 * @returns VBox status code.
135 * @param pVM The VM handle.
136 */
137HWACCMR3DECL(int) HWACCMR3InitFinalizeR0(PVM pVM);
138
139/**
140 * Applies relocations to data and code managed by this
141 * component. This function will be called at init and
142 * whenever the VMM need to relocate it self inside the GC.
143 *
144 * The HWACCM will update the addresses used by the switcher.
145 *
146 * @param pVM The VM.
147 */
148HWACCMR3DECL(void) HWACCMR3Relocate(PVM pVM);
149
150/**
151 * Terminates the VMXM.
152 *
153 * Termination means cleaning up and freeing all resources,
154 * the VM it self is at this point powered off or suspended.
155 *
156 * @returns VBox status code.
157 * @param pVM The VM to operate on.
158 */
159HWACCMR3DECL(int) HWACCMR3Term(PVM pVM);
160
161/**
162 * VMXM reset callback.
163 *
164 * @param pVM The VM which is reset.
165 */
166HWACCMR3DECL(void) HWACCMR3Reset(PVM pVM);
167
168
169/**
170 * Checks if we can currently use hardware accelerated raw mode.
171 *
172 * @returns boolean
173 * @param pVM The VM to operate on.
174 * @param pCtx Partial VM execution context
175 */
176HWACCMR3DECL(bool) HWACCMR3CanExecuteGuest(PVM pVM, PCPUMCTX pCtx);
177
178
179/**
180 * Checks if we are currently using hardware accelerated raw mode.
181 *
182 * @returns boolean
183 * @param pVM The VM to operate on.
184 */
185HWACCMR3DECL(bool) HWACCMR3IsActive(PVM pVM);
186
187/**
188 * Checks hardware accelerated raw mode is allowed.
189 *
190 * @returns boolean
191 * @param pVM The VM to operate on.
192 */
193HWACCMR3DECL(bool) HWACCMR3IsAllowed(PVM pVM);
194
195/**
196 * Notification callback which is called whenever there is a chance that a CR3
197 * value might have changed.
198 * This is called by PGM.
199 *
200 * @param pVM The VM to operate on.
201 * @param enmShadowMode New paging mode.
202 */
203HWACCMR3DECL(void) HWACCMR3PagingModeChanged(PVM pVM, PGMMODE enmShadowMode);
204
205/** @} */
206#endif
207
208#ifdef IN_RING0
209/** @addtogroup grp_hwaccm_r0
210 * @{
211 */
212
213/**
214 * Sets up a VT-x or AMD-V session
215 *
216 * @returns VBox status code.
217 * @param pVM The VM to operate on.
218 */
219HWACCMR0DECL(int) HWACCMR0SetupVM(PVM pVM);
220
221
222/**
223 * Runs guest code in a VMX/SVM VM.
224 *
225 * @returns VBox status code.
226 * @param pVM The VM to operate on.
227 */
228HWACCMR0DECL(int) HWACCMR0RunGuestCode(PVM pVM);
229
230/**
231 * Enters the VT-x or AMD-V session
232 *
233 * @returns VBox status code.
234 * @param pVM The VM to operate on.
235 */
236HWACCMR0DECL(int) HWACCMR0Enter(PVM pVM);
237
238
239/**
240 * Leaves the VT-x or AMD-V session
241 *
242 * @returns VBox status code.
243 * @param pVM The VM to operate on.
244 */
245HWACCMR0DECL(int) HWACCMR0Leave(PVM pVM);
246
247
248/** @} */
249#endif
250
251
252/** @} */
253__END_DECLS
254
255
256#endif
257
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette