VirtualBox

source: vbox/trunk/include/VBox/pdm.h@ 3880

Last change on this file since 3880 was 3852, checked in by vboxsync, 18 years ago

Finally splitting up pdm.h. Working on integrating USB into PDM (USBProxy needs CFGM stuff).

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