VirtualBox

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

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

Fixed init problems wrt. VM ownership by implementing the UVM structure (U = user mode) and moving problematic ring-3 stuff over there (emt+reqs, r3heap, stam, loader[VMMR0.r0]). Big change, but it works fine here... :-)

  • 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) PDMR3InitUVM(PUVM pUVM);
114PDMR3DECL(int) PDMR3LdrLoadVMMR0U(PUVM pUVM);
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 pUVM Pointer to the user mode VM structure.
172 * @param offDelta Relocation delta relative to old location.
173 */
174PDMR3DECL(void) PDMR3LdrRelocateU(PUVM pUVM, 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);
196PDMR3DECL(void) PDMR3TermUVM(PUVM pUVM);
197
198
199/**
200 * Get the address of a symbol in a given HC ring-3 module.
201 *
202 * @returns VBox status code.
203 * @param pVM VM handle.
204 * @param pszModule Module name.
205 * @param pszSymbol Symbol name. If it's value is less than 64k it's treated like a
206 * ordinal value rather than a string pointer.
207 * @param ppvValue Where to store the symbol value.
208 */
209PDMR3DECL(int) PDMR3GetSymbolR3(PVM pVM, const char *pszModule, const char *pszSymbol, void **ppvValue);
210
211/**
212 * Get the address of a symbol in a given HC ring-0 module.
213 *
214 * @returns VBox status code.
215 * @param pVM VM handle.
216 * @param pszModule Module name. If NULL the main R0 module (VMMR0.r0) is assumed.
217 * @param pszSymbol Symbol name. If it's value is less than 64k it's treated like a
218 * ordinal value rather than a string pointer.
219 * @param ppvValue Where to store the symbol value.
220 */
221PDMR3DECL(int) PDMR3GetSymbolR0(PVM pVM, const char *pszModule, const char *pszSymbol, PRTR0PTR ppvValue);
222
223/**
224 * Same as PDMR3GetSymbolR0 except that the module will be attempted loaded if not found.
225 *
226 * @returns VBox status code.
227 * @param pVM VM handle.
228 * @param pszModule Module name. If NULL the main R0 module (VMMR0.r0) is assumed.
229 * @param pszSymbol Symbol name. If it's value is less than 64k it's treated like a
230 * ordinal value rather than a string pointer.
231 * @param ppvValue Where to store the symbol value.
232 */
233PDMR3DECL(int) PDMR3GetSymbolR0Lazy(PVM pVM, const char *pszModule, const char *pszSymbol, PRTR0PTR ppvValue);
234
235/**
236 * Loads a module into the guest context (i.e. into the Hypervisor memory region).
237 *
238 * The external (to PDM) use of this interface is to load VMMGC.gc.
239 *
240 * @returns VBox status code.
241 * @param pVM The VM to load it into.
242 * @param pszFilename Filename of the module binary.
243 * @param pszName Module name. Case sensitive and the length is limited!
244 */
245PDMR3DECL(int) PDMR3LoadGC(PVM pVM, const char *pszFilename, const char *pszName);
246
247/**
248 * Get the address of a symbol in a given GC module.
249 *
250 * @returns VBox status code.
251 * @param pVM VM handle.
252 * @param pszModule Module name. If NULL the main GC module (VMMGC.gc) is assumed.
253 * @param pszSymbol Symbol name. If it's value is less than 64k it's treated like a
254 * ordinal value rather than a string pointer.
255 * @param pGCPtrValue Where to store the symbol value.
256 */
257PDMR3DECL(int) PDMR3GetSymbolGC(PVM pVM, const char *pszModule, const char *pszSymbol, PRTGCPTR pGCPtrValue);
258
259/**
260 * Same as PDMR3GetSymbolGC except that the module will be attempted loaded if not found.
261 *
262 * @returns VBox status code.
263 * @param pVM VM handle.
264 * @param pszModule Module name. If NULL the main GC module (VMMGC.gc) is assumed.
265 * @param pszSymbol Symbol name. If it's value is less than 64k it's treated like a
266 * ordinal value rather than a string pointer.
267 * @param pGCPtrValue Where to store the symbol value.
268 */
269PDMR3DECL(int) PDMR3GetSymbolGCLazy(PVM pVM, const char *pszModule, const char *pszSymbol, PRTGCPTR pGCPtrValue);
270
271/**
272 * Queries module information from an EIP.
273 *
274 * This is typically used to locate a crash address.
275 *
276 * @returns VBox status code.
277 * @param pVM VM handle
278 * @param uEIP EIP to locate.
279 * @param pszModName Where to store the module name.
280 * @param cchModName Size of the module name buffer.
281 * @param pMod Base address of the module.
282 * @param pszNearSym1 Name of the closes symbol from below.
283 * @param cchNearSym1 Size of the buffer pointed to by pszNearSym1.
284 * @param pNearSym1 The address of pszNearSym1.
285 * @param pszNearSym2 Name of the closes symbol from below.
286 * @param cchNearSym2 Size of the buffer pointed to by pszNearSym2.
287 * @param pNearSym2 The address of pszNearSym2.
288 */
289PDMR3DECL(int) PDMR3QueryModFromEIP(PVM pVM, uint32_t uEIP,
290 char *pszModName, unsigned cchModName, RTGCPTR *pMod,
291 char *pszNearSym1, unsigned cchNearSym1, RTGCPTR *pNearSym1,
292 char *pszNearSym2, unsigned cchNearSym2, RTGCPTR *pNearSym2);
293
294
295/**
296 * Module enumeration callback function.
297 *
298 * @returns VBox status.
299 * Failure will stop the search and return the return code.
300 * Warnings will be ignored and not returned.
301 * @param pVM VM Handle.
302 * @param pszFilename Module filename.
303 * @param pszName Module name. (short and unique)
304 * @param ImageBase Address where to executable image is loaded.
305 * @param cbImage Size of the executable image.
306 * @param fGC Set if guest context, clear if host context.
307 * @param pvArg User argument.
308 */
309typedef DECLCALLBACK(int) FNPDMR3ENUM(PVM pVM, const char *pszFilename, const char *pszName, RTUINTPTR ImageBase, size_t cbImage, bool fGC);
310/** Pointer to a FNPDMR3ENUM() function. */
311typedef FNPDMR3ENUM *PFNPDMR3ENUM;
312
313
314/**
315 * Enumerate all PDM modules.
316 *
317 * @returns VBox status.
318 * @param pVM VM Handle.
319 * @param pfnCallback Function to call back for each of the modules.
320 * @param pvArg User argument.
321 */
322PDMR3DECL(int) PDMR3EnumModules(PVM pVM, PFNPDMR3ENUM pfnCallback, void *pvArg);
323
324
325/**
326 * Queries the base interace of a device instance.
327 *
328 * The caller can use this to query other interfaces the device implements
329 * and use them to talk to the device.
330 *
331 * @returns VBox status code.
332 * @param pVM VM handle.
333 * @param pszDevice Device name.
334 * @param iInstance Device instance.
335 * @param ppBase Where to store the pointer to the base device interface on success.
336 * @remark We're not doing any locking ATM, so don't try call this at times when the
337 * device chain is known to be updated.
338 */
339PDMR3DECL(int) PDMR3QueryDevice(PVM pVM, const char *pszDevice, unsigned iInstance, PPPDMIBASE ppBase);
340
341/**
342 * Queries the base interface of a device LUN.
343 *
344 * This differs from PDMR3QueryLun by that it returns the interface on the
345 * device and not the top level driver.
346 *
347 * @returns VBox status code.
348 * @param pVM VM Handle.
349 * @param pszDevice Device name.
350 * @param iInstance Device instance.
351 * @param iLun The Logical Unit to obtain the interface of.
352 * @param ppBase Where to store the base interface pointer.
353 * @remark We're not doing any locking ATM, so don't try call this at times when the
354 * device chain is known to be updated.
355 */
356PDMR3DECL(int) PDMR3QueryDeviceLun(PVM pVM, const char *pszDevice, unsigned iInstance, unsigned iLun, PPPDMIBASE ppBase);
357
358/**
359 * Query the interface of the top level driver on a LUN.
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) PDMR3QueryLun(PVM pVM, const char *pszDevice, unsigned iInstance, unsigned iLun, PPPDMIBASE ppBase);
371
372/**
373 * Attaches a preconfigured driver to an existing device instance.
374 *
375 * This is used to change drivers and suchlike at runtime.
376 *
377 * @returns VBox status code.
378 * @param pVM VM Handle.
379 * @param pszDevice Device name.
380 * @param iInstance Device instance.
381 * @param iLun The Logical Unit to obtain the interface of.
382 * @param ppBase Where to store the base interface pointer. Optional.
383 * @thread EMT
384 */
385PDMR3DECL(int) PDMR3DeviceAttach(PVM pVM, const char *pszDevice, unsigned iInstance, unsigned iLun, PPPDMIBASE ppBase);
386
387/**
388 * Detaches a driver chain from an existing device instance.
389 *
390 * This is used to change drivers and suchlike at runtime.
391 *
392 * @returns VBox status code.
393 * @param pVM VM Handle.
394 * @param pszDevice Device name.
395 * @param iInstance Device instance.
396 * @param iLun The Logical Unit to obtain the interface of.
397 * @thread EMT
398 */
399PDMR3DECL(int) PDMR3DeviceDetach(PVM pVM, const char *pszDevice, unsigned iInstance, unsigned iLun);
400
401/**
402 * Executes pending DMA transfers.
403 * Forced Action handler.
404 *
405 * @param pVM VM handle.
406 */
407PDMR3DECL(void) PDMR3DmaRun(PVM pVM);
408
409/**
410 * Call polling function.
411 *
412 * @param pVM VM handle.
413 */
414PDMR3DECL(void) PDMR3Poll(PVM pVM);
415
416/**
417 * Service a VMMCALLHOST_PDM_LOCK call.
418 *
419 * @returns VBox status code.
420 * @param pVM The VM handle.
421 */
422PDMR3DECL(int) PDMR3LockCall(PVM pVM);
423
424/** @} */
425#endif
426
427
428#ifdef IN_GC
429/** @defgroup grp_pdm_gc The PDM Guest Context API
430 * @ingroup grp_pdm
431 * @{
432 */
433/** @} */
434#endif
435
436__END_DECLS
437
438/** @} */
439
440#endif
441
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