VirtualBox

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

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

return docs.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 14.8 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 */
117PDMDECL(int) PDMApicGetTPR(PVM pVM, uint8_t *pu8TPR);
118
119
120#ifdef IN_RING3
121/** @defgroup grp_pdm_r3 The PDM Host Context Ring-3 API
122 * @ingroup grp_pdm
123 * @{
124 */
125
126PDMR3DECL(int) PDMR3InitUVM(PUVM pUVM);
127PDMR3DECL(int) PDMR3LdrLoadVMMR0U(PUVM pUVM);
128
129/**
130 * Initializes the PDM.
131 *
132 * @returns VBox status code.
133 * @param pVM The VM to operate on.
134 */
135PDMR3DECL(int) PDMR3Init(PVM pVM);
136
137/**
138 * This function will notify all the devices and their
139 * attached drivers about the VM now being powered on.
140 *
141 * @param pVM VM Handle.
142 */
143PDMR3DECL(void) PDMR3PowerOn(PVM pVM);
144
145/**
146 * This function will notify all the devices and their
147 * attached drivers about the VM now being reset.
148 *
149 * @param pVM VM Handle.
150 */
151PDMR3DECL(void) PDMR3Reset(PVM pVM);
152
153/**
154 * This function will notify all the devices and their
155 * attached drivers about the VM now being suspended.
156 *
157 * @param pVM VM Handle.
158 */
159PDMR3DECL(void) PDMR3Suspend(PVM pVM);
160
161/**
162 * This function will notify all the devices and their
163 * attached drivers about the VM now being resumed.
164 *
165 * @param pVM VM Handle.
166 */
167PDMR3DECL(void) PDMR3Resume(PVM pVM);
168
169/**
170 * This function will notify all the devices and their
171 * attached drivers about the VM being powered off.
172 *
173 * @param pVM VM Handle.
174 */
175PDMR3DECL(void) PDMR3PowerOff(PVM pVM);
176
177
178/**
179 * Applies relocations to GC modules.
180 *
181 * This must be done very early in the relocation
182 * process so that components can resolve GC symbols during relocation.
183 *
184 * @param pUVM Pointer to the user mode VM structure.
185 * @param offDelta Relocation delta relative to old location.
186 */
187PDMR3DECL(void) PDMR3LdrRelocateU(PUVM pUVM, RTGCINTPTR offDelta);
188
189/**
190 * Applies relocations to data and code managed by this
191 * component. This function will be called at init and
192 * whenever the VMM need to relocate it self inside the GC.
193 *
194 * @param pVM VM handle.
195 * @param offDelta Relocation delta relative to old location.
196 */
197PDMR3DECL(void) PDMR3Relocate(PVM pVM, RTGCINTPTR offDelta);
198
199/**
200 * Terminates the PDM.
201 *
202 * Termination means cleaning up and freeing all resources,
203 * the VM it self is at this point powered off or suspended.
204 *
205 * @returns VBox status code.
206 * @param pVM The VM to operate on.
207 */
208PDMR3DECL(int) PDMR3Term(PVM pVM);
209PDMR3DECL(void) PDMR3TermUVM(PUVM pUVM);
210
211
212/**
213 * Get the address of a symbol in a given HC ring-3 module.
214 *
215 * @returns VBox status code.
216 * @param pVM VM handle.
217 * @param pszModule Module name.
218 * @param pszSymbol Symbol name. If it's value is less than 64k it's treated like a
219 * ordinal value rather than a string pointer.
220 * @param ppvValue Where to store the symbol value.
221 */
222PDMR3DECL(int) PDMR3GetSymbolR3(PVM pVM, const char *pszModule, const char *pszSymbol, void **ppvValue);
223
224/**
225 * Get the address of a symbol in a given HC ring-0 module.
226 *
227 * @returns VBox status code.
228 * @param pVM VM handle.
229 * @param pszModule Module name. If NULL the main R0 module (VMMR0.r0) is assumed.
230 * @param pszSymbol Symbol name. If it's value is less than 64k it's treated like a
231 * ordinal value rather than a string pointer.
232 * @param ppvValue Where to store the symbol value.
233 */
234PDMR3DECL(int) PDMR3GetSymbolR0(PVM pVM, const char *pszModule, const char *pszSymbol, PRTR0PTR ppvValue);
235
236/**
237 * Same as PDMR3GetSymbolR0 except that the module will be attempted loaded if not found.
238 *
239 * @returns VBox status code.
240 * @param pVM VM handle.
241 * @param pszModule Module name. If NULL the main R0 module (VMMR0.r0) is assumed.
242 * @param pszSymbol Symbol name. If it's value is less than 64k it's treated like a
243 * ordinal value rather than a string pointer.
244 * @param ppvValue Where to store the symbol value.
245 */
246PDMR3DECL(int) PDMR3GetSymbolR0Lazy(PVM pVM, const char *pszModule, const char *pszSymbol, PRTR0PTR ppvValue);
247
248/**
249 * Loads a module into the guest context (i.e. into the Hypervisor memory region).
250 *
251 * The external (to PDM) use of this interface is to load VMMGC.gc.
252 *
253 * @returns VBox status code.
254 * @param pVM The VM to load it into.
255 * @param pszFilename Filename of the module binary.
256 * @param pszName Module name. Case sensitive and the length is limited!
257 */
258PDMR3DECL(int) PDMR3LoadGC(PVM pVM, const char *pszFilename, const char *pszName);
259
260/**
261 * Get the address of a symbol in a given GC module.
262 *
263 * @returns VBox status code.
264 * @param pVM VM handle.
265 * @param pszModule Module name. If NULL the main GC module (VMMGC.gc) is assumed.
266 * @param pszSymbol Symbol name. If it's value is less than 64k it's treated like a
267 * ordinal value rather than a string pointer.
268 * @param pGCPtrValue Where to store the symbol value.
269 */
270PDMR3DECL(int) PDMR3GetSymbolGC(PVM pVM, const char *pszModule, const char *pszSymbol, PRTGCPTR32 pGCPtrValue);
271
272/**
273 * Same as PDMR3GetSymbolGC except that the module will be attempted loaded if not found.
274 *
275 * @returns VBox status code.
276 * @param pVM VM handle.
277 * @param pszModule Module name. If NULL the main GC module (VMMGC.gc) is assumed.
278 * @param pszSymbol Symbol name. If it's value is less than 64k it's treated like a
279 * ordinal value rather than a string pointer.
280 * @param pGCPtrValue Where to store the symbol value.
281 */
282PDMR3DECL(int) PDMR3GetSymbolGCLazy(PVM pVM, const char *pszModule, const char *pszSymbol, PRTGCPTR32 pGCPtrValue);
283
284/**
285 * Queries module information from an EIP.
286 *
287 * This is typically used to locate a crash address.
288 *
289 * @returns VBox status code.
290 * @param pVM VM handle
291 * @param uEIP EIP to locate.
292 * @param pszModName Where to store the module name.
293 * @param cchModName Size of the module name buffer.
294 * @param pMod Base address of the module.
295 * @param pszNearSym1 Name of the closes symbol from below.
296 * @param cchNearSym1 Size of the buffer pointed to by pszNearSym1.
297 * @param pNearSym1 The address of pszNearSym1.
298 * @param pszNearSym2 Name of the closes symbol from below.
299 * @param cchNearSym2 Size of the buffer pointed to by pszNearSym2.
300 * @param pNearSym2 The address of pszNearSym2.
301 */
302PDMR3DECL(int) PDMR3QueryModFromEIP(PVM pVM, uint32_t uEIP,
303 char *pszModName, unsigned cchModName, RTGCPTR *pMod,
304 char *pszNearSym1, unsigned cchNearSym1, RTGCPTR *pNearSym1,
305 char *pszNearSym2, unsigned cchNearSym2, RTGCPTR *pNearSym2);
306
307
308/**
309 * Module enumeration callback function.
310 *
311 * @returns VBox status.
312 * Failure will stop the search and return the return code.
313 * Warnings will be ignored and not returned.
314 * @param pVM VM Handle.
315 * @param pszFilename Module filename.
316 * @param pszName Module name. (short and unique)
317 * @param ImageBase Address where to executable image is loaded.
318 * @param cbImage Size of the executable image.
319 * @param fGC Set if guest context, clear if host context.
320 * @param pvArg User argument.
321 */
322typedef DECLCALLBACK(int) FNPDMR3ENUM(PVM pVM, const char *pszFilename, const char *pszName, RTUINTPTR ImageBase, size_t cbImage, bool fGC);
323/** Pointer to a FNPDMR3ENUM() function. */
324typedef FNPDMR3ENUM *PFNPDMR3ENUM;
325
326
327/**
328 * Enumerate all PDM modules.
329 *
330 * @returns VBox status.
331 * @param pVM VM Handle.
332 * @param pfnCallback Function to call back for each of the modules.
333 * @param pvArg User argument.
334 */
335PDMR3DECL(int) PDMR3EnumModules(PVM pVM, PFNPDMR3ENUM pfnCallback, void *pvArg);
336
337
338/**
339 * Queries the base interace of a device instance.
340 *
341 * The caller can use this to query other interfaces the device implements
342 * and use them to talk to the device.
343 *
344 * @returns VBox status code.
345 * @param pVM VM handle.
346 * @param pszDevice Device name.
347 * @param iInstance Device instance.
348 * @param ppBase Where to store the pointer to the base device interface on success.
349 * @remark We're not doing any locking ATM, so don't try call this at times when the
350 * device chain is known to be updated.
351 */
352PDMR3DECL(int) PDMR3QueryDevice(PVM pVM, const char *pszDevice, unsigned iInstance, PPPDMIBASE ppBase);
353
354/**
355 * Queries the base interface of a device LUN.
356 *
357 * This differs from PDMR3QueryLun by that it returns the interface on the
358 * device and not the top level driver.
359 *
360 * @returns VBox status code.
361 * @param pVM VM Handle.
362 * @param pszDevice Device name.
363 * @param iInstance Device instance.
364 * @param iLun The Logical Unit to obtain the interface of.
365 * @param ppBase Where to store the base interface pointer.
366 * @remark We're not doing any locking ATM, so don't try call this at times when the
367 * device chain is known to be updated.
368 */
369PDMR3DECL(int) PDMR3QueryDeviceLun(PVM pVM, const char *pszDevice, unsigned iInstance, unsigned iLun, PPPDMIBASE ppBase);
370
371/**
372 * Query the interface of the top level driver on a LUN.
373 *
374 * @returns VBox status code.
375 * @param pVM VM Handle.
376 * @param pszDevice Device name.
377 * @param iInstance Device instance.
378 * @param iLun The Logical Unit to obtain the interface of.
379 * @param ppBase Where to store the base interface pointer.
380 * @remark We're not doing any locking ATM, so don't try call this at times when the
381 * device chain is known to be updated.
382 */
383PDMR3DECL(int) PDMR3QueryLun(PVM pVM, const char *pszDevice, unsigned iInstance, unsigned iLun, PPPDMIBASE ppBase);
384
385/**
386 * Attaches a preconfigured driver to an existing device instance.
387 *
388 * This is used to change drivers and suchlike at runtime.
389 *
390 * @returns VBox status code.
391 * @param pVM VM Handle.
392 * @param pszDevice Device name.
393 * @param iInstance Device instance.
394 * @param iLun The Logical Unit to obtain the interface of.
395 * @param ppBase Where to store the base interface pointer. Optional.
396 * @thread EMT
397 */
398PDMR3DECL(int) PDMR3DeviceAttach(PVM pVM, const char *pszDevice, unsigned iInstance, unsigned iLun, PPPDMIBASE ppBase);
399
400/**
401 * Detaches a driver chain from an existing device instance.
402 *
403 * This is used to change drivers and suchlike at runtime.
404 *
405 * @returns VBox status code.
406 * @param pVM VM Handle.
407 * @param pszDevice Device name.
408 * @param iInstance Device instance.
409 * @param iLun The Logical Unit to obtain the interface of.
410 * @thread EMT
411 */
412PDMR3DECL(int) PDMR3DeviceDetach(PVM pVM, const char *pszDevice, unsigned iInstance, unsigned iLun);
413
414/**
415 * Executes pending DMA transfers.
416 * Forced Action handler.
417 *
418 * @param pVM VM handle.
419 */
420PDMR3DECL(void) PDMR3DmaRun(PVM pVM);
421
422/**
423 * Call polling function.
424 *
425 * @param pVM VM handle.
426 */
427PDMR3DECL(void) PDMR3Poll(PVM pVM);
428
429/**
430 * Service a VMMCALLHOST_PDM_LOCK call.
431 *
432 * @returns VBox status code.
433 * @param pVM The VM handle.
434 */
435PDMR3DECL(int) PDMR3LockCall(PVM pVM);
436
437/** @} */
438#endif
439
440
441#ifdef IN_GC
442/** @defgroup grp_pdm_gc The PDM Guest Context API
443 * @ingroup grp_pdm
444 * @{
445 */
446/** @} */
447#endif
448
449__END_DECLS
450
451/** @} */
452
453#endif
454
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