VirtualBox

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

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

The Giant CDDL Dual-License Header Change.

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