VirtualBox

source: vbox/trunk/include/VBox/pdmapi.h@ 10661

Last change on this file since 10661 was 10661, checked in by vboxsync, 16 years ago

Reduce the number of world switches caused by cr8 writes by checking if we really need to be notified. (only when
an interrupt is pending and masked by the TRP value)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 14.9 KB
Line 
1/** @file
2 * PDM - Pluggable Device Manager, Core API.
3 *
4 * The 'Core API' has been put in a different header because everyone
5 * is currently including pdm.h. So, pdm.h is for including all of the
6 * PDM stuff, while pdmapi.h is for the core stuff.
7 */
8
9/*
10 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
11 *
12 * This file is part of VirtualBox Open Source Edition (OSE), as
13 * available from http://www.virtualbox.org. This file is free software;
14 * you can redistribute it and/or modify it under the terms of the GNU
15 * General Public License (GPL) as published by the Free Software
16 * Foundation, in version 2 as it comes in the "COPYING" file of the
17 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
18 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
19 *
20 * The contents of this file may alternatively be used under the terms
21 * of the Common Development and Distribution License Version 1.0
22 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
23 * VirtualBox OSE distribution, in which case the provisions of the
24 * CDDL are applicable instead of those of the GPL.
25 *
26 * You may elect to license modified versions of this file under the
27 * terms and conditions of either the GPL or the CDDL or both.
28 *
29 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
30 * Clara, CA 95054 USA or visit http://www.sun.com if you need
31 * additional information or have any questions.
32 */
33
34#ifndef ___VBox_pdmapi_h
35#define ___VBox_pdmapi_h
36
37#include <VBox/types.h>
38
39__BEGIN_DECLS
40
41/** @defgroup grp_pdm The Pluggable Device Manager API
42 * @{
43 */
44
45/**
46 * Gets the pending interrupt.
47 *
48 * @returns VBox status code.
49 * @param pVM VM handle.
50 * @param pu8Interrupt Where to store the interrupt on success.
51 */
52PDMDECL(int) PDMGetInterrupt(PVM pVM, uint8_t *pu8Interrupt);
53
54/**
55 * Sets the pending ISA interrupt.
56 *
57 * @returns VBox status code.
58 * @param pVM VM handle.
59 * @param u8Irq The IRQ line.
60 * @param u8Level The new level. See the PDM_IRQ_LEVEL_* \#defines.
61 */
62PDMDECL(int) PDMIsaSetIrq(PVM pVM, uint8_t u8Irq, uint8_t u8Level);
63
64/**
65 * Sets the pending I/O APIC interrupt.
66 *
67 * @returns VBox status code.
68 * @param pVM VM handle.
69 * @param u8Irq The IRQ line.
70 * @param u8Level The new level. See the PDM_IRQ_LEVEL_* \#defines.
71 */
72PDMDECL(int) PDMIoApicSetIrq(PVM pVM, uint8_t u8Irq, uint8_t u8Level);
73
74/**
75 * Check if the APIC has a pending interrupt/if a TPR change would active one.
76 *
77 * @returns VINF_SUCCESS or VERR_PDM_NO_APIC_INSTANCE.
78 * @param pDevIns Device instance of the APIC.
79 * @param pfPending Pending state (out).
80 */
81PDMDECL(int) PDMApicHasPendingIrq(PVM pVM, bool *pfPending);
82
83/**
84 * Set the APIC base.
85 *
86 * @returns VBox status code.
87 * @param pVM VM handle.
88 * @param u64Base The new base.
89 */
90PDMDECL(int) PDMApicSetBase(PVM pVM, uint64_t u64Base);
91
92/**
93 * Get the APIC base.
94 *
95 * @returns VBox status code.
96 * @param pVM VM handle.
97 * @param pu64Base Where to store the APIC base.
98 */
99PDMDECL(int) PDMApicGetBase(PVM pVM, uint64_t *pu64Base);
100
101/**
102 * Set the TPR (task priority register).
103 *
104 * @returns VBox status code.
105 * @param pVM VM handle.
106 * @param u8TPR The new TPR.
107 */
108PDMDECL(int) PDMApicSetTPR(PVM pVM, uint8_t u8TPR);
109
110/**
111 * Get the TPR (task priority register).
112 *
113 * @returns The current TPR.
114 * @param pVM VM handle.
115 * @param pu8TPR Where to store the TRP.
116 * @param pfPending Pending state (out).
117 */
118PDMDECL(int) PDMApicGetTPR(PVM pVM, uint8_t *pu8TPR, bool *pfPending);
119
120
121#ifdef IN_RING3
122/** @defgroup grp_pdm_r3 The PDM Host Context Ring-3 API
123 * @ingroup grp_pdm
124 * @{
125 */
126
127PDMR3DECL(int) PDMR3InitUVM(PUVM pUVM);
128PDMR3DECL(int) PDMR3LdrLoadVMMR0U(PUVM pUVM);
129
130/**
131 * Initializes the PDM.
132 *
133 * @returns VBox status code.
134 * @param pVM The VM to operate on.
135 */
136PDMR3DECL(int) PDMR3Init(PVM pVM);
137
138/**
139 * This function will notify all the devices and their
140 * attached drivers about the VM now being powered on.
141 *
142 * @param pVM VM Handle.
143 */
144PDMR3DECL(void) PDMR3PowerOn(PVM pVM);
145
146/**
147 * This function will notify all the devices and their
148 * attached drivers about the VM now being reset.
149 *
150 * @param pVM VM Handle.
151 */
152PDMR3DECL(void) PDMR3Reset(PVM pVM);
153
154/**
155 * This function will notify all the devices and their
156 * attached drivers about the VM now being suspended.
157 *
158 * @param pVM VM Handle.
159 */
160PDMR3DECL(void) PDMR3Suspend(PVM pVM);
161
162/**
163 * This function will notify all the devices and their
164 * attached drivers about the VM now being resumed.
165 *
166 * @param pVM VM Handle.
167 */
168PDMR3DECL(void) PDMR3Resume(PVM pVM);
169
170/**
171 * This function will notify all the devices and their
172 * attached drivers about the VM being powered off.
173 *
174 * @param pVM VM Handle.
175 */
176PDMR3DECL(void) PDMR3PowerOff(PVM pVM);
177
178
179/**
180 * Applies relocations to GC modules.
181 *
182 * This must be done very early in the relocation
183 * process so that components can resolve GC symbols during relocation.
184 *
185 * @param pUVM Pointer to the user mode VM structure.
186 * @param offDelta Relocation delta relative to old location.
187 */
188PDMR3DECL(void) PDMR3LdrRelocateU(PUVM pUVM, RTGCINTPTR offDelta);
189
190/**
191 * Applies relocations to data and code managed by this
192 * component. This function will be called at init and
193 * whenever the VMM need to relocate it self inside the GC.
194 *
195 * @param pVM VM handle.
196 * @param offDelta Relocation delta relative to old location.
197 */
198PDMR3DECL(void) PDMR3Relocate(PVM pVM, RTGCINTPTR offDelta);
199
200/**
201 * Terminates the PDM.
202 *
203 * Termination means cleaning up and freeing all resources,
204 * the VM it self is at this point powered off or suspended.
205 *
206 * @returns VBox status code.
207 * @param pVM The VM to operate on.
208 */
209PDMR3DECL(int) PDMR3Term(PVM pVM);
210PDMR3DECL(void) PDMR3TermUVM(PUVM pUVM);
211
212
213/**
214 * Get the address of a symbol in a given HC ring-3 module.
215 *
216 * @returns VBox status code.
217 * @param pVM VM handle.
218 * @param pszModule Module name.
219 * @param pszSymbol Symbol name. If it's value is less than 64k it's treated like a
220 * ordinal value rather than a string pointer.
221 * @param ppvValue Where to store the symbol value.
222 */
223PDMR3DECL(int) PDMR3GetSymbolR3(PVM pVM, const char *pszModule, const char *pszSymbol, void **ppvValue);
224
225/**
226 * Get the address of a symbol in a given HC ring-0 module.
227 *
228 * @returns VBox status code.
229 * @param pVM VM handle.
230 * @param pszModule Module name. If NULL the main R0 module (VMMR0.r0) is assumed.
231 * @param pszSymbol Symbol name. If it's value is less than 64k it's treated like a
232 * ordinal value rather than a string pointer.
233 * @param ppvValue Where to store the symbol value.
234 */
235PDMR3DECL(int) PDMR3GetSymbolR0(PVM pVM, const char *pszModule, const char *pszSymbol, PRTR0PTR ppvValue);
236
237/**
238 * Same as PDMR3GetSymbolR0 except that the module will be attempted loaded if not found.
239 *
240 * @returns VBox status code.
241 * @param pVM VM handle.
242 * @param pszModule Module name. If NULL the main R0 module (VMMR0.r0) is assumed.
243 * @param pszSymbol Symbol name. If it's value is less than 64k it's treated like a
244 * ordinal value rather than a string pointer.
245 * @param ppvValue Where to store the symbol value.
246 */
247PDMR3DECL(int) PDMR3GetSymbolR0Lazy(PVM pVM, const char *pszModule, const char *pszSymbol, PRTR0PTR ppvValue);
248
249/**
250 * Loads a module into the guest context (i.e. into the Hypervisor memory region).
251 *
252 * The external (to PDM) use of this interface is to load VMMGC.gc.
253 *
254 * @returns VBox status code.
255 * @param pVM The VM to load it into.
256 * @param pszFilename Filename of the module binary.
257 * @param pszName Module name. Case sensitive and the length is limited!
258 */
259PDMR3DECL(int) PDMR3LoadGC(PVM pVM, const char *pszFilename, const char *pszName);
260
261/**
262 * Get the address of a symbol in a given GC module.
263 *
264 * @returns VBox status code.
265 * @param pVM VM handle.
266 * @param pszModule Module name. If NULL the main GC module (VMMGC.gc) is assumed.
267 * @param pszSymbol Symbol name. If it's value is less than 64k it's treated like a
268 * ordinal value rather than a string pointer.
269 * @param pGCPtrValue Where to store the symbol value.
270 */
271PDMR3DECL(int) PDMR3GetSymbolGC(PVM pVM, const char *pszModule, const char *pszSymbol, PRTGCPTR32 pGCPtrValue);
272
273/**
274 * Same as PDMR3GetSymbolGC except that the module will be attempted loaded if not found.
275 *
276 * @returns VBox status code.
277 * @param pVM VM handle.
278 * @param pszModule Module name. If NULL the main GC module (VMMGC.gc) is assumed.
279 * @param pszSymbol Symbol name. If it's value is less than 64k it's treated like a
280 * ordinal value rather than a string pointer.
281 * @param pGCPtrValue Where to store the symbol value.
282 */
283PDMR3DECL(int) PDMR3GetSymbolGCLazy(PVM pVM, const char *pszModule, const char *pszSymbol, PRTGCPTR32 pGCPtrValue);
284
285/**
286 * Queries module information from an EIP.
287 *
288 * This is typically used to locate a crash address.
289 *
290 * @returns VBox status code.
291 * @param pVM VM handle
292 * @param uEIP EIP to locate.
293 * @param pszModName Where to store the module name.
294 * @param cchModName Size of the module name buffer.
295 * @param pMod Base address of the module.
296 * @param pszNearSym1 Name of the closes symbol from below.
297 * @param cchNearSym1 Size of the buffer pointed to by pszNearSym1.
298 * @param pNearSym1 The address of pszNearSym1.
299 * @param pszNearSym2 Name of the closes symbol from below.
300 * @param cchNearSym2 Size of the buffer pointed to by pszNearSym2.
301 * @param pNearSym2 The address of pszNearSym2.
302 */
303PDMR3DECL(int) PDMR3QueryModFromEIP(PVM pVM, uint32_t uEIP,
304 char *pszModName, unsigned cchModName, RTGCPTR *pMod,
305 char *pszNearSym1, unsigned cchNearSym1, RTGCPTR *pNearSym1,
306 char *pszNearSym2, unsigned cchNearSym2, RTGCPTR *pNearSym2);
307
308
309/**
310 * Module enumeration callback function.
311 *
312 * @returns VBox status.
313 * Failure will stop the search and return the return code.
314 * Warnings will be ignored and not returned.
315 * @param pVM VM Handle.
316 * @param pszFilename Module filename.
317 * @param pszName Module name. (short and unique)
318 * @param ImageBase Address where to executable image is loaded.
319 * @param cbImage Size of the executable image.
320 * @param fGC Set if guest context, clear if host context.
321 * @param pvArg User argument.
322 */
323typedef DECLCALLBACK(int) FNPDMR3ENUM(PVM pVM, const char *pszFilename, const char *pszName, RTUINTPTR ImageBase, size_t cbImage, bool fGC);
324/** Pointer to a FNPDMR3ENUM() function. */
325typedef FNPDMR3ENUM *PFNPDMR3ENUM;
326
327
328/**
329 * Enumerate all PDM modules.
330 *
331 * @returns VBox status.
332 * @param pVM VM Handle.
333 * @param pfnCallback Function to call back for each of the modules.
334 * @param pvArg User argument.
335 */
336PDMR3DECL(int) PDMR3EnumModules(PVM pVM, PFNPDMR3ENUM pfnCallback, void *pvArg);
337
338
339/**
340 * Queries the base interace of a device instance.
341 *
342 * The caller can use this to query other interfaces the device implements
343 * and use them to talk to the device.
344 *
345 * @returns VBox status code.
346 * @param pVM VM handle.
347 * @param pszDevice Device name.
348 * @param iInstance Device instance.
349 * @param ppBase Where to store the pointer to the base device interface on success.
350 * @remark We're not doing any locking ATM, so don't try call this at times when the
351 * device chain is known to be updated.
352 */
353PDMR3DECL(int) PDMR3QueryDevice(PVM pVM, const char *pszDevice, unsigned iInstance, PPPDMIBASE ppBase);
354
355/**
356 * Queries the base interface of a device LUN.
357 *
358 * This differs from PDMR3QueryLun by that it returns the interface on the
359 * device and not the top level driver.
360 *
361 * @returns VBox status code.
362 * @param pVM VM Handle.
363 * @param pszDevice Device name.
364 * @param iInstance Device instance.
365 * @param iLun The Logical Unit to obtain the interface of.
366 * @param ppBase Where to store the base interface pointer.
367 * @remark We're not doing any locking ATM, so don't try call this at times when the
368 * device chain is known to be updated.
369 */
370PDMR3DECL(int) PDMR3QueryDeviceLun(PVM pVM, const char *pszDevice, unsigned iInstance, unsigned iLun, PPPDMIBASE ppBase);
371
372/**
373 * Query the interface of the top level driver on a LUN.
374 *
375 * @returns VBox status code.
376 * @param pVM VM Handle.
377 * @param pszDevice Device name.
378 * @param iInstance Device instance.
379 * @param iLun The Logical Unit to obtain the interface of.
380 * @param ppBase Where to store the base interface pointer.
381 * @remark We're not doing any locking ATM, so don't try call this at times when the
382 * device chain is known to be updated.
383 */
384PDMR3DECL(int) PDMR3QueryLun(PVM pVM, const char *pszDevice, unsigned iInstance, unsigned iLun, PPPDMIBASE ppBase);
385
386/**
387 * Attaches a preconfigured driver to an existing device instance.
388 *
389 * This is used to change drivers and suchlike at runtime.
390 *
391 * @returns VBox status code.
392 * @param pVM VM Handle.
393 * @param pszDevice Device name.
394 * @param iInstance Device instance.
395 * @param iLun The Logical Unit to obtain the interface of.
396 * @param ppBase Where to store the base interface pointer. Optional.
397 * @thread EMT
398 */
399PDMR3DECL(int) PDMR3DeviceAttach(PVM pVM, const char *pszDevice, unsigned iInstance, unsigned iLun, PPPDMIBASE ppBase);
400
401/**
402 * Detaches a driver chain from an existing device instance.
403 *
404 * This is used to change drivers and suchlike at runtime.
405 *
406 * @returns VBox status code.
407 * @param pVM VM Handle.
408 * @param pszDevice Device name.
409 * @param iInstance Device instance.
410 * @param iLun The Logical Unit to obtain the interface of.
411 * @thread EMT
412 */
413PDMR3DECL(int) PDMR3DeviceDetach(PVM pVM, const char *pszDevice, unsigned iInstance, unsigned iLun);
414
415/**
416 * Executes pending DMA transfers.
417 * Forced Action handler.
418 *
419 * @param pVM VM handle.
420 */
421PDMR3DECL(void) PDMR3DmaRun(PVM pVM);
422
423/**
424 * Call polling function.
425 *
426 * @param pVM VM handle.
427 */
428PDMR3DECL(void) PDMR3Poll(PVM pVM);
429
430/**
431 * Service a VMMCALLHOST_PDM_LOCK call.
432 *
433 * @returns VBox status code.
434 * @param pVM The VM handle.
435 */
436PDMR3DECL(int) PDMR3LockCall(PVM pVM);
437
438/** @} */
439#endif
440
441
442#ifdef IN_GC
443/** @defgroup grp_pdm_gc The PDM Guest Context API
444 * @ingroup grp_pdm
445 * @{
446 */
447/** @} */
448#endif
449
450__END_DECLS
451
452/** @} */
453
454#endif
455
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