VirtualBox

source: vbox/trunk/include/VBox/pdmdev.h@ 12562

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

pdmdev.h: Dumped the devhlp version (MMIO changes are incompatible).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 137.2 KB
Line 
1/** @file
2 * PDM - Pluggable Device Manager, Devices.
3 */
4
5/*
6 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
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 (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 *
25 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
26 * Clara, CA 95054 USA or visit http://www.sun.com if you need
27 * additional information or have any questions.
28 */
29
30#ifndef ___VBox_pdmdev_h
31#define ___VBox_pdmdev_h
32
33#include <VBox/pdmqueue.h>
34#include <VBox/pdmcritsect.h>
35#include <VBox/pdmthread.h>
36#include <VBox/pdmifs.h>
37#include <VBox/pdmins.h>
38#include <VBox/iom.h>
39#include <VBox/tm.h>
40#include <VBox/ssm.h>
41#include <VBox/cfgm.h>
42#include <VBox/dbgf.h>
43#include <VBox/mm.h>
44#include <VBox/err.h>
45#include <VBox/pci.h>
46#include <iprt/stdarg.h>
47
48__BEGIN_DECLS
49
50/** @defgroup grp_pdm_device Devices
51 * @ingroup grp_pdm
52 * @{
53 */
54
55/**
56 * Construct a device instance for a VM.
57 *
58 * @returns VBox status.
59 * @param pDevIns The device instance data.
60 * If the registration structure is needed, pDevIns->pDevReg points to it.
61 * @param iInstance Instance number. Use this to figure out which registers and such to use.
62 * The instance number is also found in pDevIns->iInstance, but since it's
63 * likely to be freqently used PDM passes it as parameter.
64 * @param pCfgHandle Configuration node handle for the device. Use this to obtain the configuration
65 * of the device instance. It's also found in pDevIns->pCfgHandle, but since it's
66 * primary usage will in this function it's passed as a parameter.
67 */
68typedef DECLCALLBACK(int) FNPDMDEVCONSTRUCT(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfgHandle);
69/** Pointer to a FNPDMDEVCONSTRUCT() function. */
70typedef FNPDMDEVCONSTRUCT *PFNPDMDEVCONSTRUCT;
71
72/**
73 * Destruct a device instance.
74 *
75 * Most VM resources are freed by the VM. This callback is provided so that any non-VM
76 * resources can be freed correctly.
77 *
78 * @returns VBox status.
79 * @param pDevIns The device instance data.
80 */
81typedef DECLCALLBACK(int) FNPDMDEVDESTRUCT(PPDMDEVINS pDevIns);
82/** Pointer to a FNPDMDEVDESTRUCT() function. */
83typedef FNPDMDEVDESTRUCT *PFNPDMDEVDESTRUCT;
84
85/**
86 * Device relocation callback.
87 *
88 * When this callback is called the device instance data, and if the
89 * device have a GC component, is being relocated, or/and the selectors
90 * have been changed. The device must use the chance to perform the
91 * necessary pointer relocations and data updates.
92 *
93 * Before the GC code is executed the first time, this function will be
94 * called with a 0 delta so GC pointer calculations can be one in one place.
95 *
96 * @param pDevIns Pointer to the device instance.
97 * @param offDelta The relocation delta relative to the old location.
98 *
99 * @remark A relocation CANNOT fail.
100 */
101typedef DECLCALLBACK(void) FNPDMDEVRELOCATE(PPDMDEVINS pDevIns, RTGCINTPTR offDelta);
102/** Pointer to a FNPDMDEVRELOCATE() function. */
103typedef FNPDMDEVRELOCATE *PFNPDMDEVRELOCATE;
104
105
106/**
107 * Device I/O Control interface.
108 *
109 * This is used by external components, such as the COM interface, to
110 * communicate with devices using a class wide interface or a device
111 * specific interface.
112 *
113 * @returns VBox status code.
114 * @param pDevIns Pointer to the device instance.
115 * @param uFunction Function to perform.
116 * @param pvIn Pointer to input data.
117 * @param cbIn Size of input data.
118 * @param pvOut Pointer to output data.
119 * @param cbOut Size of output data.
120 * @param pcbOut Where to store the actual size of the output data.
121 */
122typedef DECLCALLBACK(int) FNPDMDEVIOCTL(PPDMDEVINS pDevIns, RTUINT uFunction,
123 void *pvIn, RTUINT cbIn,
124 void *pvOut, RTUINT cbOut, PRTUINT pcbOut);
125/** Pointer to a FNPDMDEVIOCTL() function. */
126typedef FNPDMDEVIOCTL *PFNPDMDEVIOCTL;
127
128/**
129 * Power On notification.
130 *
131 * @returns VBox status.
132 * @param pDevIns The device instance data.
133 */
134typedef DECLCALLBACK(void) FNPDMDEVPOWERON(PPDMDEVINS pDevIns);
135/** Pointer to a FNPDMDEVPOWERON() function. */
136typedef FNPDMDEVPOWERON *PFNPDMDEVPOWERON;
137
138/**
139 * Reset notification.
140 *
141 * @returns VBox status.
142 * @param pDevIns The device instance data.
143 */
144typedef DECLCALLBACK(void) FNPDMDEVRESET(PPDMDEVINS pDevIns);
145/** Pointer to a FNPDMDEVRESET() function. */
146typedef FNPDMDEVRESET *PFNPDMDEVRESET;
147
148/**
149 * Suspend notification.
150 *
151 * @returns VBox status.
152 * @param pDevIns The device instance data.
153 */
154typedef DECLCALLBACK(void) FNPDMDEVSUSPEND(PPDMDEVINS pDevIns);
155/** Pointer to a FNPDMDEVSUSPEND() function. */
156typedef FNPDMDEVSUSPEND *PFNPDMDEVSUSPEND;
157
158/**
159 * Resume notification.
160 *
161 * @returns VBox status.
162 * @param pDevIns The device instance data.
163 */
164typedef DECLCALLBACK(void) FNPDMDEVRESUME(PPDMDEVINS pDevIns);
165/** Pointer to a FNPDMDEVRESUME() function. */
166typedef FNPDMDEVRESUME *PFNPDMDEVRESUME;
167
168/**
169 * Power Off notification.
170 *
171 * @param pDevIns The device instance data.
172 */
173typedef DECLCALLBACK(void) FNPDMDEVPOWEROFF(PPDMDEVINS pDevIns);
174/** Pointer to a FNPDMDEVPOWEROFF() function. */
175typedef FNPDMDEVPOWEROFF *PFNPDMDEVPOWEROFF;
176
177/**
178 * Attach command.
179 *
180 * This is called to let the device attach to a driver for a specified LUN
181 * at runtime. This is not called during VM construction, the device
182 * constructor have to attach to all the available drivers.
183 *
184 * This is like plugging in the keyboard or mouse after turning on the PC.
185 *
186 * @returns VBox status code.
187 * @param pDevIns The device instance.
188 * @param iLUN The logical unit which is being detached.
189 */
190typedef DECLCALLBACK(int) FNPDMDEVATTACH(PPDMDEVINS pDevIns, unsigned iLUN);
191/** Pointer to a FNPDMDEVATTACH() function. */
192typedef FNPDMDEVATTACH *PFNPDMDEVATTACH;
193
194/**
195 * Detach notification.
196 *
197 * This is called when a driver is detaching itself from a LUN of the device.
198 * The device should adjust it's state to reflect this.
199 *
200 * This is like unplugging the network cable to use it for the laptop or
201 * something while the PC is still running.
202 *
203 * @param pDevIns The device instance.
204 * @param iLUN The logical unit which is being detached.
205 */
206typedef DECLCALLBACK(void) FNPDMDEVDETACH(PPDMDEVINS pDevIns, unsigned iLUN);
207/** Pointer to a FNPDMDEVDETACH() function. */
208typedef FNPDMDEVDETACH *PFNPDMDEVDETACH;
209
210/**
211 * Query the base interface of a logical unit.
212 *
213 * @returns VBOX status code.
214 * @param pDevIns The device instance.
215 * @param iLUN The logicial unit to query.
216 * @param ppBase Where to store the pointer to the base interface of the LUN.
217 */
218typedef DECLCALLBACK(int) FNPDMDEVQUERYINTERFACE(PPDMDEVINS pDevIns, unsigned iLUN, PPDMIBASE *ppBase);
219/** Pointer to a FNPDMDEVQUERYINTERFACE() function. */
220typedef FNPDMDEVQUERYINTERFACE *PFNPDMDEVQUERYINTERFACE;
221
222/**
223 * Init complete notification.
224 * This can be done to do communication with other devices and other
225 * initialization which requires everything to be in place.
226 *
227 * @returns VBOX status code.
228 * @param pDevIns The device instance.
229 */
230typedef DECLCALLBACK(int) FNPDMDEVINITCOMPLETE(PPDMDEVINS pDevIns);
231/** Pointer to a FNPDMDEVINITCOMPLETE() function. */
232typedef FNPDMDEVINITCOMPLETE *PFNPDMDEVINITCOMPLETE;
233
234
235
236/** PDM Device Registration Structure,
237 * This structure is used when registering a device from
238 * VBoxInitDevices() in HC Ring-3. PDM will continue use till
239 * the VM is terminated.
240 */
241typedef struct PDMDEVREG
242{
243 /** Structure version. PDM_DEVREG_VERSION defines the current version. */
244 uint32_t u32Version;
245 /** Device name. */
246 char szDeviceName[32];
247 /** Name of guest context module (no path).
248 * Only evalutated if PDM_DEVREG_FLAGS_GC is set. */
249 char szGCMod[32];
250 /** Name of guest context module (no path).
251 * Only evalutated if PDM_DEVREG_FLAGS_GC is set. */
252 char szR0Mod[32];
253 /** The description of the device. The UTF-8 string pointed to shall, like this structure,
254 * remain unchanged from registration till VM destruction. */
255 const char *pszDescription;
256
257 /** Flags, combination of the PDM_DEVREG_FLAGS_* \#defines. */
258 RTUINT fFlags;
259 /** Device class(es), combination of the PDM_DEVREG_CLASS_* \#defines. */
260 RTUINT fClass;
261 /** Maximum number of instances (per VM). */
262 RTUINT cMaxInstances;
263 /** Size of the instance data. */
264 RTUINT cbInstance;
265
266 /** Construct instance - required. */
267 PFNPDMDEVCONSTRUCT pfnConstruct;
268 /** Destruct instance - optional. */
269 PFNPDMDEVDESTRUCT pfnDestruct;
270 /** Relocation command - optional. */
271 PFNPDMDEVRELOCATE pfnRelocate;
272 /** I/O Control interface - optional. */
273 PFNPDMDEVIOCTL pfnIOCtl;
274 /** Power on notification - optional. */
275 PFNPDMDEVPOWERON pfnPowerOn;
276 /** Reset notification - optional. */
277 PFNPDMDEVRESET pfnReset;
278 /** Suspend notification - optional. */
279 PFNPDMDEVSUSPEND pfnSuspend;
280 /** Resume notification - optional. */
281 PFNPDMDEVRESUME pfnResume;
282 /** Attach command - optional. */
283 PFNPDMDEVATTACH pfnAttach;
284 /** Detach notification - optional. */
285 PFNPDMDEVDETACH pfnDetach;
286 /** Query a LUN base interface - optional. */
287 PFNPDMDEVQUERYINTERFACE pfnQueryInterface;
288 /** Init complete notification - optional. */
289 PFNPDMDEVINITCOMPLETE pfnInitComplete;
290 /** Power off notification - optional. */
291 PFNPDMDEVPOWEROFF pfnPowerOff;
292} PDMDEVREG;
293/** Pointer to a PDM Device Structure. */
294typedef PDMDEVREG *PPDMDEVREG;
295/** Const pointer to a PDM Device Structure. */
296typedef PDMDEVREG const *PCPDMDEVREG;
297
298/** Current DEVREG version number. */
299#define PDM_DEVREG_VERSION 0xc0010000
300
301/** PDM Device Flags.
302 * @{ */
303/** This flag is used to indicate that the device has a GC component. */
304#define PDM_DEVREG_FLAGS_GC 0x00000001
305/** This flag is used to indicate that the device has a R0 component. */
306#define PDM_DEVREG_FLAGS_R0 0x00010000
307
308/** @def PDM_DEVREG_FLAGS_HOST_BITS_DEFAULT
309 * The bit count for the current host. */
310#if HC_ARCH_BITS == 32
311# define PDM_DEVREG_FLAGS_HOST_BITS_DEFAULT 0x00000002
312#elif HC_ARCH_BITS == 64
313# define PDM_DEVREG_FLAGS_HOST_BITS_DEFAULT 0x00000004
314#else
315# error Unsupported HC_ARCH_BITS value.
316#endif
317/** The host bit count mask. */
318#define PDM_DEVREG_FLAGS_HOST_BITS_MASK 0x00000006
319
320/** The device support only 32-bit guests. */
321#define PDM_DEVREG_FLAGS_GUEST_BITS_32 0x00000008
322/** The device support only 64-bit guests. */
323#define PDM_DEVREG_FLAGS_GUEST_BITS_64 0x00000010
324/** The device support both 32-bit & 64-bit guests. */
325#define PDM_DEVREG_FLAGS_GUEST_BITS_32_64 0x00000018
326/** @def PDM_DEVREG_FLAGS_GUEST_BITS_DEFAULT
327 * The guest bit count for the current compilation. */
328#if GC_ARCH_BITS == 32
329# define PDM_DEVREG_FLAGS_GUEST_BITS_DEFAULT PDM_DEVREG_FLAGS_GUEST_BITS_32
330#elif GC_ARCH_BITS == 64
331# define PDM_DEVREG_FLAGS_GUEST_BITS_DEFAULT PDM_DEVREG_FLAGS_GUEST_BITS_32_64
332#else
333# error Unsupported GC_ARCH_BITS value.
334#endif
335/** The guest bit count mask. */
336#define PDM_DEVREG_FLAGS_GUEST_BITS_MASK 0x00000018
337
338/** Indicates that the devices support PAE36 on a 32-bit guest. */
339#define PDM_DEVREG_FLAGS_PAE36 0x00000020
340/** @} */
341
342
343/** PDM Device Classes.
344 * The order is important, lower bit earlier instantiation.
345 * @{ */
346/** Architecture device. */
347#define PDM_DEVREG_CLASS_ARCH RT_BIT(0)
348/** Architecture BIOS device. */
349#define PDM_DEVREG_CLASS_ARCH_BIOS RT_BIT(1)
350/** PCI bus brigde. */
351#define PDM_DEVREG_CLASS_BUS_PCI RT_BIT(2)
352/** ISA bus brigde. */
353#define PDM_DEVREG_CLASS_BUS_ISA RT_BIT(3)
354/** Input device (mouse, keyboard, joystick,..). */
355#define PDM_DEVREG_CLASS_INPUT RT_BIT(4)
356/** Interrupt controller (PIC). */
357#define PDM_DEVREG_CLASS_PIC RT_BIT(5)
358/** Interval controoler (PIT). */
359#define PDM_DEVREG_CLASS_PIT RT_BIT(6)
360/** RTC/CMOS. */
361#define PDM_DEVREG_CLASS_RTC RT_BIT(7)
362/** DMA controller. */
363#define PDM_DEVREG_CLASS_DMA RT_BIT(8)
364/** VMM Device. */
365#define PDM_DEVREG_CLASS_VMM_DEV RT_BIT(9)
366/** Graphics device, like VGA. */
367#define PDM_DEVREG_CLASS_GRAPHICS RT_BIT(10)
368/** Storage controller device. */
369#define PDM_DEVREG_CLASS_STORAGE RT_BIT(11)
370/** Network interface controller. */
371#define PDM_DEVREG_CLASS_NETWORK RT_BIT(12)
372/** Audio. */
373#define PDM_DEVREG_CLASS_AUDIO RT_BIT(13)
374/** USB HIC. */
375#define PDM_DEVREG_CLASS_BUS_USB RT_BIT(14)
376/** ACPI. */
377#define PDM_DEVREG_CLASS_ACPI RT_BIT(15)
378/** Serial controller device. */
379#define PDM_DEVREG_CLASS_SERIAL RT_BIT(16)
380/** Parallel controller device */
381#define PDM_DEVREG_CLASS_PARALLEL RT_BIT(17)
382/** Misc devices (always last). */
383#define PDM_DEVREG_CLASS_MISC RT_BIT(31)
384/** @} */
385
386
387/** @name IRQ Level for use with the *SetIrq APIs.
388 * @{
389 */
390/** Assert the IRQ (can assume value 1). */
391#define PDM_IRQ_LEVEL_HIGH RT_BIT(0)
392/** Deassert the IRQ (can assume value 0). */
393#define PDM_IRQ_LEVEL_LOW 0
394/** flip-flop - assert and then deassert it again immediately. */
395#define PDM_IRQ_LEVEL_FLIP_FLOP (RT_BIT(1) | PDM_IRQ_LEVEL_HIGH)
396/** @} */
397
398
399/**
400 * PCI Bus registration structure.
401 * All the callbacks, except the PCIBIOS hack, are working on PCI devices.
402 */
403typedef struct PDMPCIBUSREG
404{
405 /** Structure version number. PDM_PCIBUSREG_VERSION defines the current version. */
406 uint32_t u32Version;
407
408 /**
409 * Registers the device with the default PCI bus.
410 *
411 * @returns VBox status code.
412 * @param pDevIns Device instance of the PCI Bus.
413 * @param pPciDev The PCI device structure.
414 * Any PCI enabled device must keep this in it's instance data!
415 * Fill in the PCI data config before registration, please.
416 * @param pszName Pointer to device name (permanent, readonly). For debugging, not unique.
417 * @param iDev The device number ((dev << 3) | function) the device should have on the bus.
418 * If negative, the pci bus device will assign one.
419 */
420 DECLR3CALLBACKMEMBER(int, pfnRegisterR3,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, const char *pszName, int iDev));
421
422 /**
423 * Registers a I/O region (memory mapped or I/O ports) for a PCI device.
424 *
425 * @returns VBox status code.
426 * @param pDevIns Device instance of the PCI Bus.
427 * @param pPciDev The PCI device structure.
428 * @param iRegion The region number.
429 * @param cbRegion Size of the region.
430 * @param iType PCI_ADDRESS_SPACE_MEM, PCI_ADDRESS_SPACE_IO or PCI_ADDRESS_SPACE_MEM_PREFETCH.
431 * @param pfnCallback Callback for doing the mapping.
432 */
433 DECLR3CALLBACKMEMBER(int, pfnIORegionRegisterR3,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, int iRegion, uint32_t cbRegion, PCIADDRESSSPACE enmType, PFNPCIIOREGIONMAP pfnCallback));
434
435 /**
436 * Register PCI configuration space read/write callbacks.
437 *
438 * @param pDevIns Device instance of the PCI Bus.
439 * @param pPciDev The PCI device structure.
440 * @param pfnRead Pointer to the user defined PCI config read function.
441 * @param ppfnReadOld Pointer to function pointer which will receive the old (default)
442 * PCI config read function. This way, user can decide when (and if)
443 * to call default PCI config read function. Can be NULL.
444 * @param pfnWrite Pointer to the user defined PCI config write function.
445 * @param pfnWriteOld Pointer to function pointer which will receive the old (default)
446 * PCI config write function. This way, user can decide when (and if)
447 * to call default PCI config write function. Can be NULL.
448 * @thread EMT
449 */
450 DECLR3CALLBACKMEMBER(void, pfnSetConfigCallbacksR3,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, PFNPCICONFIGREAD pfnRead, PPFNPCICONFIGREAD ppfnReadOld,
451 PFNPCICONFIGWRITE pfnWrite, PPFNPCICONFIGWRITE ppfnWriteOld));
452
453 /**
454 * Set the IRQ for a PCI device.
455 *
456 * @param pDevIns Device instance of the PCI Bus.
457 * @param pPciDev The PCI device structure.
458 * @param iIrq IRQ number to set.
459 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
460 */
461 DECLR3CALLBACKMEMBER(void, pfnSetIrqR3,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, int iIrq, int iLevel));
462
463 /**
464 * Saves a state of the PCI device.
465 *
466 * @returns VBox status code.
467 * @param pDevIns Device instance of the PCI Bus.
468 * @param pPciDev Pointer to PCI device.
469 * @param pSSMHandle The handle to save the state to.
470 */
471 DECLR3CALLBACKMEMBER(int, pfnSaveExecR3,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, PSSMHANDLE pSSMHandle));
472
473 /**
474 * Loads a saved PCI device state.
475 *
476 * @returns VBox status code.
477 * @param pDevIns Device instance of the PCI Bus.
478 * @param pPciDev Pointer to PCI device.
479 * @param pSSMHandle The handle to the saved state.
480 */
481 DECLR3CALLBACKMEMBER(int, pfnLoadExecR3,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, PSSMHANDLE pSSMHandle));
482
483 /**
484 * Called to perform the job of the bios.
485 * This is only called for the first PCI Bus - it is expected to
486 * service all the PCI buses.
487 *
488 * @returns VBox status.
489 * @param pDevIns Device instance of the first bus.
490 */
491 DECLR3CALLBACKMEMBER(int, pfnFakePCIBIOSR3,(PPDMDEVINS pDevIns));
492
493 /** The name of the SetIrq RC entry point. */
494 const char *pszSetIrqRC;
495
496 /** The name of the SetIrq R0 entry point. */
497 const char *pszSetIrqR0;
498
499} PDMPCIBUSREG;
500/** Pointer to a PCI bus registration structure. */
501typedef PDMPCIBUSREG *PPDMPCIBUSREG;
502
503/** Current PDMPCIBUSREG version number. */
504#define PDM_PCIBUSREG_VERSION 0xd0020000
505
506/**
507 * PCI Bus RC helpers.
508 */
509typedef struct PDMPCIHLPRC
510{
511 /** Structure version. PDM_PCIHLPRC_VERSION defines the current version. */
512 uint32_t u32Version;
513
514 /**
515 * Set an ISA IRQ.
516 *
517 * @param pDevIns PCI device instance.
518 * @param iIrq IRQ number to set.
519 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
520 * @thread EMT only.
521 */
522 DECLRCCALLBACKMEMBER(void, pfnIsaSetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
523
524 /**
525 * Set an I/O-APIC IRQ.
526 *
527 * @param pDevIns PCI device instance.
528 * @param iIrq IRQ number to set.
529 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
530 * @thread EMT only.
531 */
532 DECLRCCALLBACKMEMBER(void, pfnIoApicSetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
533
534 /**
535 * Acquires the PDM lock.
536 *
537 * @returns VINF_SUCCESS on success.
538 * @returns rc if we failed to acquire the lock.
539 * @param pDevIns The PCI device instance.
540 * @param rc What to return if we fail to acquire the lock.
541 */
542 DECLRCCALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
543
544 /**
545 * Releases the PDM lock.
546 *
547 * @param pDevIns The PCI device instance.
548 */
549 DECLRCCALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
550
551 /** Just a safety precaution. */
552 uint32_t u32TheEnd;
553} PDMPCIHLPRC;
554/** Pointer to PCI helpers. */
555typedef RCPTRTYPE(PDMPCIHLPRC *) PPDMPCIHLPRC;
556/** Pointer to const PCI helpers. */
557typedef RCPTRTYPE(const PDMPCIHLPRC *) PCPDMPCIHLPRC;
558
559/** Current PDMPCIHLPR3 version number. */
560#define PDM_PCIHLPRC_VERSION 0xe1010000
561
562
563/**
564 * PCI Bus R0 helpers.
565 */
566typedef struct PDMPCIHLPR0
567{
568 /** Structure version. PDM_PCIHLPR0_VERSION defines the current version. */
569 uint32_t u32Version;
570
571 /**
572 * Set an ISA IRQ.
573 *
574 * @param pDevIns PCI device instance.
575 * @param iIrq IRQ number to set.
576 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
577 * @thread EMT only.
578 */
579 DECLR0CALLBACKMEMBER(void, pfnIsaSetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
580
581 /**
582 * Set an I/O-APIC IRQ.
583 *
584 * @param pDevIns PCI device instance.
585 * @param iIrq IRQ number to set.
586 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
587 * @thread EMT only.
588 */
589 DECLR0CALLBACKMEMBER(void, pfnIoApicSetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
590
591 /**
592 * Acquires the PDM lock.
593 *
594 * @returns VINF_SUCCESS on success.
595 * @returns rc if we failed to acquire the lock.
596 * @param pDevIns The PCI device instance.
597 * @param rc What to return if we fail to acquire the lock.
598 */
599 DECLR0CALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
600
601 /**
602 * Releases the PDM lock.
603 *
604 * @param pDevIns The PCI device instance.
605 */
606 DECLR0CALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
607
608 /** Just a safety precaution. */
609 uint32_t u32TheEnd;
610} PDMPCIHLPR0;
611/** Pointer to PCI helpers. */
612typedef R0PTRTYPE(PDMPCIHLPR0 *) PPDMPCIHLPR0;
613/** Pointer to const PCI helpers. */
614typedef R0PTRTYPE(const PDMPCIHLPR0 *) PCPDMPCIHLPR0;
615
616/** Current PDMPCIHLPR0 version number. */
617#define PDM_PCIHLPR0_VERSION 0xe1010000
618
619/**
620 * PCI device helpers.
621 */
622typedef struct PDMPCIHLPR3
623{
624 /** Structure version. PDM_PCIHLPR3_VERSION defines the current version. */
625 uint32_t u32Version;
626
627 /**
628 * Set an ISA IRQ.
629 *
630 * @param pDevIns The PCI device instance.
631 * @param iIrq IRQ number to set.
632 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
633 * @thread EMT only.
634 */
635 DECLR3CALLBACKMEMBER(void, pfnIsaSetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
636
637 /**
638 * Set an I/O-APIC IRQ.
639 *
640 * @param pDevIns The PCI device instance.
641 * @param iIrq IRQ number to set.
642 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
643 * @thread EMT only.
644 */
645 DECLR3CALLBACKMEMBER(void, pfnIoApicSetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
646
647 /**
648 * Checks if the given address is an MMIO2 base address or not.
649 *
650 * @returns true/false accordingly.
651 * @param pDevIns The PCI device instance.
652 * @param pOwner The owner of the memory, optional.
653 * @param GCPhys The address to check.
654 */
655 DECLR3CALLBACKMEMBER(bool, pfnIsMMIO2Base,(PPDMDEVINS pDevIns, PPDMDEVINS pOwner, RTGCPHYS GCPhys));
656
657 /**
658 * Gets the address of the RC PCI Bus helpers.
659 *
660 * This should be called at both construction and relocation time
661 * to obtain the correct address of the RC helpers.
662 *
663 * @returns RC pointer to the PCI Bus helpers.
664 * @param pDevIns Device instance of the PCI Bus.
665 * @thread EMT only.
666 */
667 DECLR3CALLBACKMEMBER(PCPDMPCIHLPRC, pfnGetRCHelpers,(PPDMDEVINS pDevIns));
668
669 /**
670 * Gets the address of the R0 PCI Bus helpers.
671 *
672 * This should be called at both construction and relocation time
673 * to obtain the correct address of the R0 helpers.
674 *
675 * @returns R0 pointer to the PCI Bus helpers.
676 * @param pDevIns Device instance of the PCI Bus.
677 * @thread EMT only.
678 */
679 DECLR3CALLBACKMEMBER(PCPDMPCIHLPR0, pfnGetR0Helpers,(PPDMDEVINS pDevIns));
680
681 /**
682 * Acquires the PDM lock.
683 *
684 * @returns VINF_SUCCESS on success.
685 * @returns Fatal error on failure.
686 * @param pDevIns The PCI device instance.
687 * @param rc Dummy for making the interface identical to the RC and R0 versions.
688 */
689 DECLR3CALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
690
691 /**
692 * Releases the PDM lock.
693 *
694 * @param pDevIns The PCI device instance.
695 */
696 DECLR3CALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
697
698 /** Just a safety precaution. */
699 uint32_t u32TheEnd;
700} PDMPCIHLPR3;
701/** Pointer to PCI helpers. */
702typedef R3PTRTYPE(PDMPCIHLPR3 *) PPDMPCIHLPR3;
703/** Pointer to const PCI helpers. */
704typedef R3PTRTYPE(const PDMPCIHLPR3 *) PCPDMPCIHLPR3;
705
706/** Current PDMPCIHLPR3 version number. */
707#define PDM_PCIHLPR3_VERSION 0xf1020000
708
709
710/**
711 * Programmable Interrupt Controller registration structure.
712 */
713typedef struct PDMPICREG
714{
715 /** Structure version number. PDM_PICREG_VERSION defines the current version. */
716 uint32_t u32Version;
717
718 /**
719 * Set the an IRQ.
720 *
721 * @param pDevIns Device instance of the PIC.
722 * @param iIrq IRQ number to set.
723 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
724 */
725 DECLR3CALLBACKMEMBER(void, pfnSetIrqR3,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
726
727 /**
728 * Get a pending interrupt.
729 *
730 * @returns Pending interrupt number.
731 * @param pDevIns Device instance of the PIC.
732 */
733 DECLR3CALLBACKMEMBER(int, pfnGetInterruptR3,(PPDMDEVINS pDevIns));
734
735 /** The name of the RC SetIrq entry point. */
736 const char *pszSetIrqRC;
737 /** The name of the RC GetInterrupt entry point. */
738 const char *pszGetInterruptRC;
739
740 /** The name of the R0 SetIrq entry point. */
741 const char *pszSetIrqR0;
742 /** The name of the R0 GetInterrupt entry point. */
743 const char *pszGetInterruptR0;
744} PDMPICREG;
745/** Pointer to a PIC registration structure. */
746typedef PDMPICREG *PPDMPICREG;
747
748/** Current PDMPICREG version number. */
749#define PDM_PICREG_VERSION 0xe0020000
750
751/**
752 * PIC RC helpers.
753 */
754typedef struct PDMPICHLPRC
755{
756 /** Structure version. PDM_PICHLPRC_VERSION defines the current version. */
757 uint32_t u32Version;
758
759 /**
760 * Set the interrupt force action flag.
761 *
762 * @param pDevIns Device instance of the PIC.
763 */
764 DECLRCCALLBACKMEMBER(void, pfnSetInterruptFF,(PPDMDEVINS pDevIns));
765
766 /**
767 * Clear the interrupt force action flag.
768 *
769 * @param pDevIns Device instance of the PIC.
770 */
771 DECLRCCALLBACKMEMBER(void, pfnClearInterruptFF,(PPDMDEVINS pDevIns));
772
773 /**
774 * Acquires the PDM lock.
775 *
776 * @returns VINF_SUCCESS on success.
777 * @returns rc if we failed to acquire the lock.
778 * @param pDevIns The PIC device instance.
779 * @param rc What to return if we fail to acquire the lock.
780 */
781 DECLRCCALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
782
783 /**
784 * Releases the PDM lock.
785 *
786 * @param pDevIns The PIC device instance.
787 */
788 DECLRCCALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
789
790 /** Just a safety precaution. */
791 uint32_t u32TheEnd;
792} PDMPICHLPRC;
793
794/** Pointer to PIC RC helpers. */
795typedef RCPTRTYPE(PDMPICHLPRC *) PPDMPICHLPRC;
796/** Pointer to const PIC RC helpers. */
797typedef RCPTRTYPE(const PDMPICHLPRC *) PCPDMPICHLPRC;
798
799/** Current PDMPICHLPRC version number. */
800#define PDM_PICHLPRC_VERSION 0xfc010000
801
802
803/**
804 * PIC R0 helpers.
805 */
806typedef struct PDMPICHLPR0
807{
808 /** Structure version. PDM_PICHLPR0_VERSION defines the current version. */
809 uint32_t u32Version;
810
811 /**
812 * Set the interrupt force action flag.
813 *
814 * @param pDevIns Device instance of the PIC.
815 */
816 DECLR0CALLBACKMEMBER(void, pfnSetInterruptFF,(PPDMDEVINS pDevIns));
817
818 /**
819 * Clear the interrupt force action flag.
820 *
821 * @param pDevIns Device instance of the PIC.
822 */
823 DECLR0CALLBACKMEMBER(void, pfnClearInterruptFF,(PPDMDEVINS pDevIns));
824
825 /**
826 * Acquires the PDM lock.
827 *
828 * @returns VINF_SUCCESS on success.
829 * @returns rc if we failed to acquire the lock.
830 * @param pDevIns The PIC device instance.
831 * @param rc What to return if we fail to acquire the lock.
832 */
833 DECLR0CALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
834
835 /**
836 * Releases the PDM lock.
837 *
838 * @param pDevIns The PCI device instance.
839 */
840 DECLR0CALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
841
842 /** Just a safety precaution. */
843 uint32_t u32TheEnd;
844} PDMPICHLPR0;
845
846/** Pointer to PIC R0 helpers. */
847typedef R0PTRTYPE(PDMPICHLPR0 *) PPDMPICHLPR0;
848/** Pointer to const PIC R0 helpers. */
849typedef R0PTRTYPE(const PDMPICHLPR0 *) PCPDMPICHLPR0;
850
851/** Current PDMPICHLPR0 version number. */
852#define PDM_PICHLPR0_VERSION 0xfc010000
853
854/**
855 * PIC R3 helpers.
856 */
857typedef struct PDMPICHLPR3
858{
859 /** Structure version. PDM_PICHLP_VERSION defines the current version. */
860 uint32_t u32Version;
861
862 /**
863 * Set the interrupt force action flag.
864 *
865 * @param pDevIns Device instance of the PIC.
866 */
867 DECLR3CALLBACKMEMBER(void, pfnSetInterruptFF,(PPDMDEVINS pDevIns));
868
869 /**
870 * Clear the interrupt force action flag.
871 *
872 * @param pDevIns Device instance of the PIC.
873 */
874 DECLR3CALLBACKMEMBER(void, pfnClearInterruptFF,(PPDMDEVINS pDevIns));
875
876 /**
877 * Acquires the PDM lock.
878 *
879 * @returns VINF_SUCCESS on success.
880 * @returns Fatal error on failure.
881 * @param pDevIns The PIC device instance.
882 * @param rc Dummy for making the interface identical to the RC and R0 versions.
883 */
884 DECLR3CALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
885
886 /**
887 * Releases the PDM lock.
888 *
889 * @param pDevIns The PIC device instance.
890 */
891 DECLR3CALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
892
893 /**
894 * Gets the address of the RC PIC helpers.
895 *
896 * This should be called at both construction and relocation time
897 * to obtain the correct address of the RC helpers.
898 *
899 * @returns RC pointer to the PIC helpers.
900 * @param pDevIns Device instance of the PIC.
901 */
902 DECLR3CALLBACKMEMBER(PCPDMPICHLPRC, pfnGetRCHelpers,(PPDMDEVINS pDevIns));
903
904 /**
905 * Gets the address of the R0 PIC helpers.
906 *
907 * This should be called at both construction and relocation time
908 * to obtain the correct address of the R0 helpers.
909 *
910 * @returns R0 pointer to the PIC helpers.
911 * @param pDevIns Device instance of the PIC.
912 */
913 DECLR3CALLBACKMEMBER(PCPDMPICHLPR0, pfnGetR0Helpers,(PPDMDEVINS pDevIns));
914
915 /** Just a safety precaution. */
916 uint32_t u32TheEnd;
917} PDMPICHLPR3;
918
919/** Pointer to PIC R3 helpers. */
920typedef R3PTRTYPE(PDMPICHLPR3 *) PPDMPICHLPR3;
921/** Pointer to const PIC R3 helpers. */
922typedef R3PTRTYPE(const PDMPICHLPR3 *) PCPDMPICHLPR3;
923
924/** Current PDMPICHLPR3 version number. */
925#define PDM_PICHLPR3_VERSION 0xf0010000
926
927
928
929/**
930 * Advanced Programmable Interrupt Controller registration structure.
931 */
932typedef struct PDMAPICREG
933{
934 /** Structure version number. PDM_APICREG_VERSION defines the current version. */
935 uint32_t u32Version;
936
937 /**
938 * Get a pending interrupt.
939 *
940 * @returns Pending interrupt number.
941 * @param pDevIns Device instance of the APIC.
942 */
943 DECLR3CALLBACKMEMBER(int, pfnGetInterruptR3,(PPDMDEVINS pDevIns));
944
945 /**
946 * Check if the APIC has a pending interrupt/if a TPR change would active one
947 *
948 * @returns Pending interrupt yes/no
949 * @param pDevIns Device instance of the APIC.
950 */
951 DECLR3CALLBACKMEMBER(bool, pfnHasPendingIrqR3,(PPDMDEVINS pDevIns));
952
953 /**
954 * Set the APIC base.
955 *
956 * @param pDevIns Device instance of the APIC.
957 * @param u64Base The new base.
958 */
959 DECLR3CALLBACKMEMBER(void, pfnSetBaseR3,(PPDMDEVINS pDevIns, uint64_t u64Base));
960
961 /**
962 * Get the APIC base.
963 *
964 * @returns Current base.
965 * @param pDevIns Device instance of the APIC.
966 */
967 DECLR3CALLBACKMEMBER(uint64_t, pfnGetBaseR3,(PPDMDEVINS pDevIns));
968
969 /**
970 * Set the TPR (task priority register).
971 *
972 * @param pDevIns Device instance of the APIC.
973 * @param u8TPR The new TPR.
974 */
975 DECLR3CALLBACKMEMBER(void, pfnSetTPRR3,(PPDMDEVINS pDevIns, uint8_t u8TPR));
976
977 /**
978 * Get the TPR (task priority register).
979 *
980 * @returns The current TPR.
981 * @param pDevIns Device instance of the APIC.
982 * @param pfPending Pending interrupt state (out).
983 */
984 DECLR3CALLBACKMEMBER(uint8_t, pfnGetTPRR3,(PPDMDEVINS pDevIns));
985
986 /**
987 * Private interface between the IOAPIC and APIC.
988 *
989 * This is a low-level, APIC/IOAPIC implementation specific interface
990 * which is registered with PDM only because it makes life so much
991 * simpler right now (GC bits). This is a bad bad hack! The correct
992 * way of doing this would involve some way of querying GC interfaces
993 * and relocating them. Perhaps doing some kind of device init in GC...
994 *
995 * @returns The current TPR.
996 * @param pDevIns Device instance of the APIC.
997 * @param u8Dest See APIC implementation.
998 * @param u8DestMode See APIC implementation.
999 * @param u8DeliveryMode See APIC implementation.
1000 * @param iVector See APIC implementation.
1001 * @param u8Polarity See APIC implementation.
1002 * @param u8TriggerMode See APIC implementation.
1003 */
1004 DECLR3CALLBACKMEMBER(void, pfnBusDeliverR3,(PPDMDEVINS pDevIns, uint8_t u8Dest, uint8_t u8DestMode, uint8_t u8DeliveryMode,
1005 uint8_t iVector, uint8_t u8Polarity, uint8_t u8TriggerMode));
1006
1007 /** The name of the RC GetInterrupt entry point. */
1008 const char *pszGetInterruptRC;
1009 /** The name of the RC HasPendingIrq entry point. */
1010 const char *pszHasPendingIrqRC;
1011 /** The name of the RC SetBase entry point. */
1012 const char *pszSetBaseRC;
1013 /** The name of the RC GetBase entry point. */
1014 const char *pszGetBaseRC;
1015 /** The name of the RC SetTPR entry point. */
1016 const char *pszSetTPRRC;
1017 /** The name of the RC GetTPR entry point. */
1018 const char *pszGetTPRRC;
1019 /** The name of the RC BusDeliver entry point. */
1020 const char *pszBusDeliverRC;
1021
1022 /** The name of the R0 GetInterrupt entry point. */
1023 const char *pszGetInterruptR0;
1024 /** The name of the R0 HasPendingIrq entry point. */
1025 const char *pszHasPendingIrqR0;
1026 /** The name of the R0 SetBase entry point. */
1027 const char *pszSetBaseR0;
1028 /** The name of the R0 GetBase entry point. */
1029 const char *pszGetBaseR0;
1030 /** The name of the R0 SetTPR entry point. */
1031 const char *pszSetTPRR0;
1032 /** The name of the R0 GetTPR entry point. */
1033 const char *pszGetTPRR0;
1034 /** The name of the R0 BusDeliver entry point. */
1035 const char *pszBusDeliverR0;
1036
1037} PDMAPICREG;
1038/** Pointer to an APIC registration structure. */
1039typedef PDMAPICREG *PPDMAPICREG;
1040
1041/** Current PDMAPICREG version number. */
1042#define PDM_APICREG_VERSION 0x70010000
1043
1044
1045/**
1046 * APIC RC helpers.
1047 */
1048typedef struct PDMAPICHLPRC
1049{
1050 /** Structure version. PDM_APICHLPRC_VERSION defines the current version. */
1051 uint32_t u32Version;
1052
1053 /**
1054 * Set the interrupt force action flag.
1055 *
1056 * @param pDevIns Device instance of the APIC.
1057 */
1058 DECLRCCALLBACKMEMBER(void, pfnSetInterruptFF,(PPDMDEVINS pDevIns));
1059
1060 /**
1061 * Clear the interrupt force action flag.
1062 *
1063 * @param pDevIns Device instance of the APIC.
1064 */
1065 DECLRCCALLBACKMEMBER(void, pfnClearInterruptFF,(PPDMDEVINS pDevIns));
1066
1067 /**
1068 * Sets or clears the APIC bit in the CPUID feature masks.
1069 *
1070 * @param pDevIns Device instance of the APIC.
1071 * @param fEnabled If true the bit is set, else cleared.
1072 */
1073 DECLRCCALLBACKMEMBER(void, pfnChangeFeature,(PPDMDEVINS pDevIns, bool fEnabled));
1074
1075 /**
1076 * Acquires the PDM lock.
1077 *
1078 * @returns VINF_SUCCESS on success.
1079 * @returns rc if we failed to acquire the lock.
1080 * @param pDevIns The APIC device instance.
1081 * @param rc What to return if we fail to acquire the lock.
1082 */
1083 DECLRCCALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
1084
1085 /**
1086 * Releases the PDM lock.
1087 *
1088 * @param pDevIns The APIC device instance.
1089 */
1090 DECLRCCALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
1091
1092 /** Just a safety precaution. */
1093 uint32_t u32TheEnd;
1094} PDMAPICHLPRC;
1095/** Pointer to APIC GC helpers. */
1096typedef RCPTRTYPE(PDMAPICHLPRC *) PPDMAPICHLPRC;
1097/** Pointer to const APIC helpers. */
1098typedef RCPTRTYPE(const PDMAPICHLPRC *) PCPDMAPICHLPRC;
1099
1100/** Current PDMAPICHLPRC version number. */
1101#define PDM_APICHLPRC_VERSION 0x60010000
1102
1103
1104/**
1105 * APIC R0 helpers.
1106 */
1107typedef struct PDMAPICHLPR0
1108{
1109 /** Structure version. PDM_APICHLPR0_VERSION defines the current version. */
1110 uint32_t u32Version;
1111
1112 /**
1113 * Set the interrupt force action flag.
1114 *
1115 * @param pDevIns Device instance of the APIC.
1116 */
1117 DECLR0CALLBACKMEMBER(void, pfnSetInterruptFF,(PPDMDEVINS pDevIns));
1118
1119 /**
1120 * Clear the interrupt force action flag.
1121 *
1122 * @param pDevIns Device instance of the APIC.
1123 */
1124 DECLR0CALLBACKMEMBER(void, pfnClearInterruptFF,(PPDMDEVINS pDevIns));
1125
1126 /**
1127 * Sets or clears the APIC bit in the CPUID feature masks.
1128 *
1129 * @param pDevIns Device instance of the APIC.
1130 * @param fEnabled If true the bit is set, else cleared.
1131 */
1132 DECLR0CALLBACKMEMBER(void, pfnChangeFeature,(PPDMDEVINS pDevIns, bool fEnabled));
1133
1134 /**
1135 * Acquires the PDM lock.
1136 *
1137 * @returns VINF_SUCCESS on success.
1138 * @returns rc if we failed to acquire the lock.
1139 * @param pDevIns The APIC device instance.
1140 * @param rc What to return if we fail to acquire the lock.
1141 */
1142 DECLR0CALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
1143
1144 /**
1145 * Releases the PDM lock.
1146 *
1147 * @param pDevIns The APIC device instance.
1148 */
1149 DECLR0CALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
1150
1151 /** Just a safety precaution. */
1152 uint32_t u32TheEnd;
1153} PDMAPICHLPR0;
1154/** Pointer to APIC GC helpers. */
1155typedef RCPTRTYPE(PDMAPICHLPR0 *) PPDMAPICHLPR0;
1156/** Pointer to const APIC helpers. */
1157typedef R0PTRTYPE(const PDMAPICHLPR0 *) PCPDMAPICHLPR0;
1158
1159/** Current PDMAPICHLPR0 version number. */
1160#define PDM_APICHLPR0_VERSION 0x60010000
1161
1162/**
1163 * APIC R3 helpers.
1164 */
1165typedef struct PDMAPICHLPR3
1166{
1167 /** Structure version. PDM_APICHLPR3_VERSION defines the current version. */
1168 uint32_t u32Version;
1169
1170 /**
1171 * Set the interrupt force action flag.
1172 *
1173 * @param pDevIns Device instance of the APIC.
1174 */
1175 DECLR3CALLBACKMEMBER(void, pfnSetInterruptFF,(PPDMDEVINS pDevIns));
1176
1177 /**
1178 * Clear the interrupt force action flag.
1179 *
1180 * @param pDevIns Device instance of the APIC.
1181 */
1182 DECLR3CALLBACKMEMBER(void, pfnClearInterruptFF,(PPDMDEVINS pDevIns));
1183
1184 /**
1185 * Sets or clears the APIC bit in the CPUID feature masks.
1186 *
1187 * @param pDevIns Device instance of the APIC.
1188 * @param fEnabled If true the bit is set, else cleared.
1189 */
1190 DECLR3CALLBACKMEMBER(void, pfnChangeFeature,(PPDMDEVINS pDevIns, bool fEnabled));
1191
1192 /**
1193 * Acquires the PDM lock.
1194 *
1195 * @returns VINF_SUCCESS on success.
1196 * @returns Fatal error on failure.
1197 * @param pDevIns The APIC device instance.
1198 * @param rc Dummy for making the interface identical to the GC and R0 versions.
1199 */
1200 DECLR3CALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
1201
1202 /**
1203 * Releases the PDM lock.
1204 *
1205 * @param pDevIns The APIC device instance.
1206 */
1207 DECLR3CALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
1208
1209 /**
1210 * Gets the address of the RC APIC helpers.
1211 *
1212 * This should be called at both construction and relocation time
1213 * to obtain the correct address of the RC helpers.
1214 *
1215 * @returns GC pointer to the APIC helpers.
1216 * @param pDevIns Device instance of the APIC.
1217 */
1218 DECLR3CALLBACKMEMBER(PCPDMAPICHLPRC, pfnGetRCHelpers,(PPDMDEVINS pDevIns));
1219
1220 /**
1221 * Gets the address of the R0 APIC helpers.
1222 *
1223 * This should be called at both construction and relocation time
1224 * to obtain the correct address of the R0 helpers.
1225 *
1226 * @returns R0 pointer to the APIC helpers.
1227 * @param pDevIns Device instance of the APIC.
1228 */
1229 DECLR3CALLBACKMEMBER(PCPDMAPICHLPR0, pfnGetR0Helpers,(PPDMDEVINS pDevIns));
1230
1231 /** Just a safety precaution. */
1232 uint32_t u32TheEnd;
1233} PDMAPICHLPR3;
1234/** Pointer to APIC helpers. */
1235typedef R3PTRTYPE(PDMAPICHLPR3 *) PPDMAPICHLPR3;
1236/** Pointer to const APIC helpers. */
1237typedef R3PTRTYPE(const PDMAPICHLPR3 *) PCPDMAPICHLPR3;
1238
1239/** Current PDMAPICHLP version number. */
1240#define PDM_APICHLPR3_VERSION 0xfd010000
1241
1242
1243/**
1244 * I/O APIC registration structure.
1245 */
1246typedef struct PDMIOAPICREG
1247{
1248 /** Struct version+magic number (PDM_IOAPICREG_VERSION). */
1249 uint32_t u32Version;
1250
1251 /**
1252 * Set the an IRQ.
1253 *
1254 * @param pDevIns Device instance of the I/O APIC.
1255 * @param iIrq IRQ number to set.
1256 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
1257 */
1258 DECLR3CALLBACKMEMBER(void, pfnSetIrqR3,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
1259
1260 /** The name of the GC SetIrq entry point. */
1261 const char *pszSetIrqRC;
1262
1263 /** The name of the R0 SetIrq entry point. */
1264 const char *pszSetIrqR0;
1265} PDMIOAPICREG;
1266/** Pointer to an APIC registration structure. */
1267typedef PDMIOAPICREG *PPDMIOAPICREG;
1268
1269/** Current PDMAPICREG version number. */
1270#define PDM_IOAPICREG_VERSION 0x50010000
1271
1272
1273/**
1274 * IOAPIC RC helpers.
1275 */
1276typedef struct PDMIOAPICHLPRC
1277{
1278 /** Structure version. PDM_IOAPICHLPRC_VERSION defines the current version. */
1279 uint32_t u32Version;
1280
1281 /**
1282 * Private interface between the IOAPIC and APIC.
1283 *
1284 * See comments about this hack on PDMAPICREG::pfnBusDeliverR3.
1285 *
1286 * @returns The current TPR.
1287 * @param pDevIns Device instance of the IOAPIC.
1288 * @param u8Dest See APIC implementation.
1289 * @param u8DestMode See APIC implementation.
1290 * @param u8DeliveryMode See APIC implementation.
1291 * @param iVector See APIC implementation.
1292 * @param u8Polarity See APIC implementation.
1293 * @param u8TriggerMode See APIC implementation.
1294 */
1295 DECLRCCALLBACKMEMBER(void, pfnApicBusDeliver,(PPDMDEVINS pDevIns, uint8_t u8Dest, uint8_t u8DestMode, uint8_t u8DeliveryMode,
1296 uint8_t iVector, uint8_t u8Polarity, uint8_t u8TriggerMode));
1297
1298 /**
1299 * Acquires the PDM lock.
1300 *
1301 * @returns VINF_SUCCESS on success.
1302 * @returns rc if we failed to acquire the lock.
1303 * @param pDevIns The IOAPIC device instance.
1304 * @param rc What to return if we fail to acquire the lock.
1305 */
1306 DECLRCCALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
1307
1308 /**
1309 * Releases the PDM lock.
1310 *
1311 * @param pDevIns The IOAPIC device instance.
1312 */
1313 DECLRCCALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
1314
1315 /** Just a safety precaution. */
1316 uint32_t u32TheEnd;
1317} PDMIOAPICHLPRC;
1318/** Pointer to IOAPIC RC helpers. */
1319typedef RCPTRTYPE(PDMIOAPICHLPRC *) PPDMIOAPICHLPRC;
1320/** Pointer to const IOAPIC helpers. */
1321typedef RCPTRTYPE(const PDMIOAPICHLPRC *) PCPDMIOAPICHLPRC;
1322
1323/** Current PDMIOAPICHLPRC version number. */
1324#define PDM_IOAPICHLPRC_VERSION 0xfe010000
1325
1326
1327/**
1328 * IOAPIC R0 helpers.
1329 */
1330typedef struct PDMIOAPICHLPR0
1331{
1332 /** Structure version. PDM_IOAPICHLPR0_VERSION defines the current version. */
1333 uint32_t u32Version;
1334
1335 /**
1336 * Private interface between the IOAPIC and APIC.
1337 *
1338 * See comments about this hack on PDMAPICREG::pfnBusDeliverR3.
1339 *
1340 * @returns The current TPR.
1341 * @param pDevIns Device instance of the IOAPIC.
1342 * @param u8Dest See APIC implementation.
1343 * @param u8DestMode See APIC implementation.
1344 * @param u8DeliveryMode See APIC implementation.
1345 * @param iVector See APIC implementation.
1346 * @param u8Polarity See APIC implementation.
1347 * @param u8TriggerMode See APIC implementation.
1348 */
1349 DECLR0CALLBACKMEMBER(void, pfnApicBusDeliver,(PPDMDEVINS pDevIns, uint8_t u8Dest, uint8_t u8DestMode, uint8_t u8DeliveryMode,
1350 uint8_t iVector, uint8_t u8Polarity, uint8_t u8TriggerMode));
1351
1352 /**
1353 * Acquires the PDM lock.
1354 *
1355 * @returns VINF_SUCCESS on success.
1356 * @returns rc if we failed to acquire the lock.
1357 * @param pDevIns The IOAPIC device instance.
1358 * @param rc What to return if we fail to acquire the lock.
1359 */
1360 DECLR0CALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
1361
1362 /**
1363 * Releases the PDM lock.
1364 *
1365 * @param pDevIns The IOAPIC device instance.
1366 */
1367 DECLR0CALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
1368
1369 /** Just a safety precaution. */
1370 uint32_t u32TheEnd;
1371} PDMIOAPICHLPR0;
1372/** Pointer to IOAPIC R0 helpers. */
1373typedef R0PTRTYPE(PDMIOAPICHLPR0 *) PPDMIOAPICHLPR0;
1374/** Pointer to const IOAPIC helpers. */
1375typedef R0PTRTYPE(const PDMIOAPICHLPR0 *) PCPDMIOAPICHLPR0;
1376
1377/** Current PDMIOAPICHLPR0 version number. */
1378#define PDM_IOAPICHLPR0_VERSION 0xfe010000
1379
1380/**
1381 * IOAPIC R3 helpers.
1382 */
1383typedef struct PDMIOAPICHLPR3
1384{
1385 /** Structure version. PDM_IOAPICHLPR3_VERSION defines the current version. */
1386 uint32_t u32Version;
1387
1388 /**
1389 * Private interface between the IOAPIC and APIC.
1390 *
1391 * See comments about this hack on PDMAPICREG::pfnBusDeliverR3.
1392 *
1393 * @returns The current TPR.
1394 * @param pDevIns Device instance of the IOAPIC.
1395 * @param u8Dest See APIC implementation.
1396 * @param u8DestMode See APIC implementation.
1397 * @param u8DeliveryMode See APIC implementation.
1398 * @param iVector See APIC implementation.
1399 * @param u8Polarity See APIC implementation.
1400 * @param u8TriggerMode See APIC implementation.
1401 */
1402 DECLR3CALLBACKMEMBER(void, pfnApicBusDeliver,(PPDMDEVINS pDevIns, uint8_t u8Dest, uint8_t u8DestMode, uint8_t u8DeliveryMode,
1403 uint8_t iVector, uint8_t u8Polarity, uint8_t u8TriggerMode));
1404
1405 /**
1406 * Acquires the PDM lock.
1407 *
1408 * @returns VINF_SUCCESS on success.
1409 * @returns Fatal error on failure.
1410 * @param pDevIns The IOAPIC device instance.
1411 * @param rc Dummy for making the interface identical to the GC and R0 versions.
1412 */
1413 DECLR3CALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
1414
1415 /**
1416 * Releases the PDM lock.
1417 *
1418 * @param pDevIns The IOAPIC device instance.
1419 */
1420 DECLR3CALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
1421
1422 /**
1423 * Gets the address of the RC IOAPIC helpers.
1424 *
1425 * This should be called at both construction and relocation time
1426 * to obtain the correct address of the RC helpers.
1427 *
1428 * @returns RC pointer to the IOAPIC helpers.
1429 * @param pDevIns Device instance of the IOAPIC.
1430 */
1431 DECLR3CALLBACKMEMBER(PCPDMIOAPICHLPRC, pfnGetRCHelpers,(PPDMDEVINS pDevIns));
1432
1433 /**
1434 * Gets the address of the R0 IOAPIC helpers.
1435 *
1436 * This should be called at both construction and relocation time
1437 * to obtain the correct address of the R0 helpers.
1438 *
1439 * @returns R0 pointer to the IOAPIC helpers.
1440 * @param pDevIns Device instance of the IOAPIC.
1441 */
1442 DECLR3CALLBACKMEMBER(PCPDMIOAPICHLPR0, pfnGetR0Helpers,(PPDMDEVINS pDevIns));
1443
1444 /** Just a safety precaution. */
1445 uint32_t u32TheEnd;
1446} PDMIOAPICHLPR3;
1447/** Pointer to IOAPIC R3 helpers. */
1448typedef R3PTRTYPE(PDMIOAPICHLPR3 *) PPDMIOAPICHLPR3;
1449/** Pointer to const IOAPIC helpers. */
1450typedef R3PTRTYPE(const PDMIOAPICHLPR3 *) PCPDMIOAPICHLPR3;
1451
1452/** Current PDMIOAPICHLPR3 version number. */
1453#define PDM_IOAPICHLPR3_VERSION 0xff010000
1454
1455
1456
1457#ifdef IN_RING3
1458
1459/**
1460 * DMA Transfer Handler.
1461 *
1462 * @returns Number of bytes transferred.
1463 * @param pDevIns Device instance of the DMA.
1464 * @param pvUser User pointer.
1465 * @param uChannel Channel number.
1466 * @param off DMA position.
1467 * @param cb Block size.
1468 */
1469typedef DECLCALLBACK(uint32_t) FNDMATRANSFERHANDLER(PPDMDEVINS pDevIns, void *pvUser, unsigned uChannel, uint32_t off, uint32_t cb);
1470/** Pointer to a FNDMATRANSFERHANDLER(). */
1471typedef FNDMATRANSFERHANDLER *PFNDMATRANSFERHANDLER;
1472
1473/**
1474 * DMA Controller registration structure.
1475 */
1476typedef struct PDMDMAREG
1477{
1478 /** Structure version number. PDM_DMACREG_VERSION defines the current version. */
1479 uint32_t u32Version;
1480
1481 /**
1482 * Execute pending transfers.
1483 *
1484 * @returns A more work indiciator. I.e. 'true' if there is more to be done, and 'false' if all is done.
1485 * @param pDevIns Device instance of the DMAC.
1486 */
1487 DECLR3CALLBACKMEMBER(bool, pfnRun,(PPDMDEVINS pDevIns));
1488
1489 /**
1490 * Register transfer function for DMA channel.
1491 *
1492 * @param pDevIns Device instance of the DMAC.
1493 * @param uChannel Channel number.
1494 * @param pfnTransferHandler Device specific transfer function.
1495 * @param pvUSer User pointer to be passed to the callback.
1496 */
1497 DECLR3CALLBACKMEMBER(void, pfnRegister,(PPDMDEVINS pDevIns, unsigned uChannel, PFNDMATRANSFERHANDLER pfnTransferHandler, void *pvUser));
1498
1499 /**
1500 * Read memory
1501 *
1502 * @returns Number of bytes read.
1503 * @param pDevIns Device instance of the DMAC.
1504 * @param pvBuffer Pointer to target buffer.
1505 * @param off DMA position.
1506 * @param cbBlock Block size.
1507 */
1508 DECLR3CALLBACKMEMBER(uint32_t, pfnReadMemory,(PPDMDEVINS pDevIns, unsigned uChannel, void *pvBuffer, uint32_t off, uint32_t cbBlock));
1509
1510 /**
1511 * Write memory
1512 *
1513 * @returns Number of bytes written.
1514 * @param pDevIns Device instance of the DMAC.
1515 * @param pvBuffer Memory to write.
1516 * @param off DMA position.
1517 * @param cbBlock Block size.
1518 */
1519 DECLR3CALLBACKMEMBER(uint32_t, pfnWriteMemory,(PPDMDEVINS pDevIns, unsigned uChannel, const void *pvBuffer, uint32_t off, uint32_t cbBlock));
1520
1521 /**
1522 * Set the DREQ line.
1523 *
1524 * @param pDevIns Device instance of the DMAC.
1525 * @param uChannel Channel number.
1526 * @param uLevel Level of the line.
1527 */
1528 DECLR3CALLBACKMEMBER(void, pfnSetDREQ,(PPDMDEVINS pDevIns, unsigned uChannel, unsigned uLevel));
1529
1530 /**
1531 * Get channel mode
1532 *
1533 * @returns Channel mode.
1534 * @param pDevIns Device instance of the DMAC.
1535 * @param uChannel Channel number.
1536 */
1537 DECLR3CALLBACKMEMBER(uint8_t, pfnGetChannelMode,(PPDMDEVINS pDevIns, unsigned uChannel));
1538
1539} PDMDMACREG;
1540/** Pointer to a DMAC registration structure. */
1541typedef PDMDMACREG *PPDMDMACREG;
1542
1543/** Current PDMDMACREG version number. */
1544#define PDM_DMACREG_VERSION 0xf5010000
1545
1546
1547/**
1548 * DMA Controller device helpers.
1549 */
1550typedef struct PDMDMACHLP
1551{
1552 /** Structure version. PDM_DMACHLP_VERSION defines the current version. */
1553 uint32_t u32Version;
1554
1555 /* to-be-defined */
1556
1557} PDMDMACHLP;
1558/** Pointer to DMAC helpers. */
1559typedef PDMDMACHLP *PPDMDMACHLP;
1560/** Pointer to const DMAC helpers. */
1561typedef const PDMDMACHLP *PCPDMDMACHLP;
1562
1563/** Current PDMDMACHLP version number. */
1564#define PDM_DMACHLP_VERSION 0xf6010000
1565
1566#endif /* IN_RING3 */
1567
1568
1569
1570/**
1571 * RTC registration structure.
1572 */
1573typedef struct PDMRTCREG
1574{
1575 /** Structure version number. PDM_RTCREG_VERSION defines the current version. */
1576 uint32_t u32Version;
1577 uint32_t u32Alignment; /**< structure size alignment. */
1578
1579 /**
1580 * Write to a CMOS register and update the checksum if necessary.
1581 *
1582 * @returns VBox status code.
1583 * @param pDevIns Device instance of the RTC.
1584 * @param iReg The CMOS register index.
1585 * @param u8Value The CMOS register value.
1586 */
1587 DECLR3CALLBACKMEMBER(int, pfnWrite,(PPDMDEVINS pDevIns, unsigned iReg, uint8_t u8Value));
1588
1589 /**
1590 * Read a CMOS register.
1591 *
1592 * @returns VBox status code.
1593 * @param pDevIns Device instance of the RTC.
1594 * @param iReg The CMOS register index.
1595 * @param pu8Value Where to store the CMOS register value.
1596 */
1597 DECLR3CALLBACKMEMBER(int, pfnRead,(PPDMDEVINS pDevIns, unsigned iReg, uint8_t *pu8Value));
1598
1599} PDMRTCREG;
1600/** Pointer to a RTC registration structure. */
1601typedef PDMRTCREG *PPDMRTCREG;
1602/** Pointer to a const RTC registration structure. */
1603typedef const PDMRTCREG *PCPDMRTCREG;
1604
1605/** Current PDMRTCREG version number. */
1606#define PDM_RTCREG_VERSION 0xfa010000
1607
1608
1609/**
1610 * RTC device helpers.
1611 */
1612typedef struct PDMRTCHLP
1613{
1614 /** Structure version. PDM_RTCHLP_VERSION defines the current version. */
1615 uint32_t u32Version;
1616
1617 /* to-be-defined */
1618
1619} PDMRTCHLP;
1620/** Pointer to RTC helpers. */
1621typedef PDMRTCHLP *PPDMRTCHLP;
1622/** Pointer to const RTC helpers. */
1623typedef const PDMRTCHLP *PCPDMRTCHLP;
1624
1625/** Current PDMRTCHLP version number. */
1626#define PDM_RTCHLP_VERSION 0xf6010000
1627
1628
1629
1630#ifdef IN_RING3
1631
1632/**
1633 * PDM Device API.
1634 */
1635typedef struct PDMDEVHLP
1636{
1637 /** Structure version. PDM_DEVHLP_VERSION defines the current version. */
1638 uint32_t u32Version;
1639
1640 /**
1641 * Register a number of I/O ports with a device.
1642 *
1643 * These callbacks are of course for the host context (HC).
1644 * Register HC handlers before guest context (GC) handlers! There must be a
1645 * HC handler for every GC handler!
1646 *
1647 * @returns VBox status.
1648 * @param pDevIns The device instance to register the ports with.
1649 * @param Port First port number in the range.
1650 * @param cPorts Number of ports to register.
1651 * @param pvUser User argument.
1652 * @param pfnOut Pointer to function which is gonna handle OUT operations.
1653 * @param pfnIn Pointer to function which is gonna handle IN operations.
1654 * @param pfnOutStr Pointer to function which is gonna handle string OUT operations.
1655 * @param pfnInStr Pointer to function which is gonna handle string IN operations.
1656 * @param pszDesc Pointer to description string. This must not be freed.
1657 */
1658 DECLR3CALLBACKMEMBER(int, pfnIOPortRegister,(PPDMDEVINS pDevIns, RTIOPORT Port, RTUINT cPorts, RTHCPTR pvUser,
1659 PFNIOMIOPORTOUT pfnOut, PFNIOMIOPORTIN pfnIn,
1660 PFNIOMIOPORTOUTSTRING pfnOutStr, PFNIOMIOPORTINSTRING pfnInStr, const char *pszDesc));
1661
1662 /**
1663 * Register a number of I/O ports with a device for GC.
1664 *
1665 * These callbacks are for the host context (GC).
1666 * Register host context (HC) handlers before guest context handlers! There must be a
1667 * HC handler for every GC handler!
1668 *
1669 * @returns VBox status.
1670 * @param pDevIns The device instance to register the ports with and which GC module
1671 * to resolve the names against.
1672 * @param Port First port number in the range.
1673 * @param cPorts Number of ports to register.
1674 * @param pvUser User argument.
1675 * @param pszOut Name of the GC function which is gonna handle OUT operations.
1676 * @param pszIn Name of the GC function which is gonna handle IN operations.
1677 * @param pszOutStr Name of the GC function which is gonna handle string OUT operations.
1678 * @param pszInStr Name of the GC function which is gonna handle string IN operations.
1679 * @param pszDesc Pointer to description string. This must not be freed.
1680 */
1681 DECLR3CALLBACKMEMBER(int, pfnIOPortRegisterGC,(PPDMDEVINS pDevIns, RTIOPORT Port, RTUINT cPorts, RTRCPTR pvUser,
1682 const char *pszOut, const char *pszIn,
1683 const char *pszOutStr, const char *pszInStr, const char *pszDesc));
1684
1685 /**
1686 * Register a number of I/O ports with a device.
1687 *
1688 * These callbacks are of course for the ring-0 host context (R0).
1689 * Register R3 (HC) handlers before R0 (R0) handlers! There must be a R3 (HC) handler for every R0 handler!
1690 *
1691 * @returns VBox status.
1692 * @param pDevIns The device instance to register the ports with.
1693 * @param Port First port number in the range.
1694 * @param cPorts Number of ports to register.
1695 * @param pvUser User argument. (if pointer, then it must be in locked memory!)
1696 * @param pszOut Name of the R0 function which is gonna handle OUT operations.
1697 * @param pszIn Name of the R0 function which is gonna handle IN operations.
1698 * @param pszOutStr Name of the R0 function which is gonna handle string OUT operations.
1699 * @param pszInStr Name of the R0 function which is gonna handle string IN operations.
1700 * @param pszDesc Pointer to description string. This must not be freed.
1701 */
1702 DECLR3CALLBACKMEMBER(int, pfnIOPortRegisterR0,(PPDMDEVINS pDevIns, RTIOPORT Port, RTUINT cPorts, RTR0PTR pvUser,
1703 const char *pszOut, const char *pszIn,
1704 const char *pszOutStr, const char *pszInStr, const char *pszDesc));
1705
1706 /**
1707 * Deregister I/O ports.
1708 *
1709 * This naturally affects both guest context (GC), ring-0 (R0) and ring-3 (R3/HC) handlers.
1710 *
1711 * @returns VBox status.
1712 * @param pDevIns The device instance owning the ports.
1713 * @param Port First port number in the range.
1714 * @param cPorts Number of ports to deregister.
1715 */
1716 DECLR3CALLBACKMEMBER(int, pfnIOPortDeregister,(PPDMDEVINS pDevIns, RTIOPORT Port, RTUINT cPorts));
1717
1718 /**
1719 * Register a Memory Mapped I/O (MMIO) region.
1720 *
1721 * These callbacks are of course for the host context (HC).
1722 * Register HC handlers before guest context (GC) handlers! There must be a
1723 * HC handler for every GC handler!
1724 *
1725 * @returns VBox status.
1726 * @param pDevIns The device instance to register the MMIO with.
1727 * @param GCPhysStart First physical address in the range.
1728 * @param enmCtx CPU id or IOMMMIOCTX_GLOBAL if it's a global
1729 * registration (applies to all CPUs).
1730 * @param cbRange The size of the range (in bytes).
1731 * @param pvUser User argument.
1732 * @param pfnWrite Pointer to function which is gonna handle Write operations.
1733 * @param pfnRead Pointer to function which is gonna handle Read operations.
1734 * @param pfnFill Pointer to function which is gonna handle Fill/memset operations. (optional)
1735 * @param pszDesc Pointer to description string. This must not be freed.
1736 */
1737 DECLR3CALLBACKMEMBER(int, pfnMMIORegister,(PPDMDEVINS pDevIns, IOMMMIOCTX enmCtx, RTGCPHYS GCPhysStart, RTUINT cbRange, RTHCPTR pvUser,
1738 PFNIOMMMIOWRITE pfnWrite, PFNIOMMMIOREAD pfnRead, PFNIOMMMIOFILL pfnFill,
1739 const char *pszDesc));
1740
1741 /**
1742 * Register a Memory Mapped I/O (MMIO) region for GC.
1743 *
1744 * These callbacks are for the guest context (GC).
1745 * Register host context (HC) handlers before guest context handlers! There must be a
1746 * HC handler for every GC handler!
1747 *
1748 * @returns VBox status.
1749 * @param pDevIns The device instance to register the MMIO with.
1750 * @param enmCtx CPU id or IOMMMIOCTX_GLOBAL if it's a global
1751 * registration (applies to all CPUs).
1752 * @param GCPhysStart First physical address in the range.
1753 * @param cbRange The size of the range (in bytes).
1754 * @param pvUser User argument.
1755 * @param pszWrite Name of the GC function which is gonna handle Write operations.
1756 * @param pszRead Name of the GC function which is gonna handle Read operations.
1757 * @param pszFill Name of the GC function which is gonna handle Fill/memset operations. (optional)
1758 * @param pszDesc Obsolete. NULL is fine.
1759 * @todo Remove pszDesc in the next major revision of PDMDEVHLP.
1760 */
1761 DECLR3CALLBACKMEMBER(int, pfnMMIORegisterGC,(PPDMDEVINS pDevIns, IOMMMIOCTX enmCtx, RTGCPHYS GCPhysStart, RTUINT cbRange, RTGCPTR pvUser,
1762 const char *pszWrite, const char *pszRead, const char *pszFill,
1763 const char *pszDesc));
1764
1765 /**
1766 * Register a Memory Mapped I/O (MMIO) region for R0.
1767 *
1768 * These callbacks are for the ring-0 host context (R0).
1769 * Register R3 (HC) handlers before R0 handlers! There must be a R3 handler for every R0 handler!
1770 *
1771 * @returns VBox status.
1772 * @param pDevIns The device instance to register the MMIO with.
1773 * @param enmCtx CPU id or IOMMMIOCTX_GLOBAL if it's a global
1774 * registration (applies to all CPUs).
1775 * @param GCPhysStart First physical address in the range.
1776 * @param cbRange The size of the range (in bytes).
1777 * @param pvUser User argument. (if pointer, then it must be in locked memory!)
1778 * @param pszWrite Name of the GC function which is gonna handle Write operations.
1779 * @param pszRead Name of the GC function which is gonna handle Read operations.
1780 * @param pszFill Name of the GC function which is gonna handle Fill/memset operations. (optional)
1781 * @param pszDesc Obsolete. NULL is fine.
1782 * @todo Remove pszDesc in the next major revision of PDMDEVHLP.
1783 */
1784 DECLR3CALLBACKMEMBER(int, pfnMMIORegisterR0,(PPDMDEVINS pDevIns, IOMMMIOCTX enmCtx, RTGCPHYS GCPhysStart, RTUINT cbRange, RTR0PTR pvUser,
1785 const char *pszWrite, const char *pszRead, const char *pszFill,
1786 const char *pszDesc));
1787
1788 /**
1789 * Deregister a Memory Mapped I/O (MMIO) region.
1790 *
1791 * This naturally affects both guest context (GC), ring-0 (R0) and ring-3 (R3/HC) handlers.
1792 *
1793 * @returns VBox status.
1794 * @param pDevIns The device instance owning the MMIO region(s).
1795 * @param enmCtx CPU id or IOMMMIOCTX_GLOBAL if it's a global registration (applies to all CPUs)
1796 * @param GCPhysStart First physical address in the range.
1797 * @param cbRange The size of the range (in bytes).
1798 */
1799 DECLR3CALLBACKMEMBER(int, pfnMMIODeregister,(PPDMDEVINS pDevIns, IOMMMIOCTX enmCtx, RTGCPHYS GCPhysStart, RTUINT cbRange));
1800
1801 /**
1802 * Register a ROM (BIOS) region.
1803 *
1804 * It goes without saying that this is read-only memory. The memory region must be
1805 * in unassigned memory. I.e. from the top of the address space or on the PC in
1806 * the 0xa0000-0xfffff range.
1807 *
1808 * @returns VBox status.
1809 * @param pDevIns The device instance owning the ROM region.
1810 * @param GCPhysStart First physical address in the range.
1811 * Must be page aligned!
1812 * @param cbRange The size of the range (in bytes).
1813 * Must be page aligned!
1814 * @param pvBinary Pointer to the binary data backing the ROM image.
1815 * This must be cbRange bytes big.
1816 * It will be copied and doesn't have to stick around if fShadow is clear.
1817 * @param fShadow Whether to emulate ROM shadowing. This involves leaving
1818 * the ROM writable for a while during the POST and refreshing
1819 * it at reset. When this flag is set, the memory pointed to by
1820 * pvBinary has to stick around for the lifespan of the VM.
1821 * @param pszDesc Pointer to description string. This must not be freed.
1822 *
1823 * @remark There is no way to remove the rom, automatically on device cleanup or
1824 * manually from the device yet. At present I doubt we need such features...
1825 */
1826 DECLR3CALLBACKMEMBER(int, pfnROMRegister,(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, const void *pvBinary, bool fShadow, const char *pszDesc));
1827
1828 /**
1829 * Register a save state data unit.
1830 *
1831 * @returns VBox status.
1832 * @param pDevIns Device instance.
1833 * @param pszName Data unit name.
1834 * @param u32Instance The instance identifier of the data unit.
1835 * This must together with the name be unique.
1836 * @param u32Version Data layout version number.
1837 * @param cbGuess The approximate amount of data in the unit.
1838 * Only for progress indicators.
1839 * @param pfnSavePrep Prepare save callback, optional.
1840 * @param pfnSaveExec Execute save callback, optional.
1841 * @param pfnSaveDone Done save callback, optional.
1842 * @param pfnLoadPrep Prepare load callback, optional.
1843 * @param pfnLoadExec Execute load callback, optional.
1844 * @param pfnLoadDone Done load callback, optional.
1845 */
1846 DECLR3CALLBACKMEMBER(int, pfnSSMRegister,(PPDMDEVINS pDevIns, const char *pszName, uint32_t u32Instance, uint32_t u32Version, size_t cbGuess,
1847 PFNSSMDEVSAVEPREP pfnSavePrep, PFNSSMDEVSAVEEXEC pfnSaveExec, PFNSSMDEVSAVEDONE pfnSaveDone,
1848 PFNSSMDEVLOADPREP pfnLoadPrep, PFNSSMDEVLOADEXEC pfnLoadExec, PFNSSMDEVLOADDONE pfnLoadDone));
1849
1850 /**
1851 * Creates a timer.
1852 *
1853 * @returns VBox status.
1854 * @param pDevIns Device instance.
1855 * @param enmClock The clock to use on this timer.
1856 * @param pfnCallback Callback function.
1857 * @param pszDesc Pointer to description string which must stay around
1858 * until the timer is fully destroyed (i.e. a bit after TMTimerDestroy()).
1859 * @param ppTimer Where to store the timer on success.
1860 */
1861 DECLR3CALLBACKMEMBER(int, pfnTMTimerCreate,(PPDMDEVINS pDevIns, TMCLOCK enmClock, PFNTMTIMERDEV pfnCallback, const char *pszDesc, PPTMTIMERR3 ppTimer));
1862
1863 /**
1864 * Creates an external timer.
1865 *
1866 * @returns timer pointer
1867 * @param pDevIns Device instance.
1868 * @param enmClock The clock to use on this timer.
1869 * @param pfnCallback Callback function.
1870 * @param pvUser User pointer
1871 * @param pszDesc Pointer to description string which must stay around
1872 * until the timer is fully destroyed (i.e. a bit after TMTimerDestroy()).
1873 */
1874 DECLR3CALLBACKMEMBER(PTMTIMERR3, pfnTMTimerCreateExternal,(PPDMDEVINS pDevIns, TMCLOCK enmClock, PFNTMTIMEREXT pfnCallback, void *pvUser, const char *pszDesc));
1875
1876 /**
1877 * Registers the device with the default PCI bus.
1878 *
1879 * @returns VBox status code.
1880 * @param pDevIns Device instance.
1881 * @param pPciDev The PCI device structure.
1882 * Any PCI enabled device must keep this in it's instance data!
1883 * Fill in the PCI data config before registration, please.
1884 * @remark This is the simple interface, a Ex interface will be created if
1885 * more features are needed later.
1886 */
1887 DECLR3CALLBACKMEMBER(int, pfnPCIRegister,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev));
1888
1889 /**
1890 * Registers a I/O region (memory mapped or I/O ports) for a PCI device.
1891 *
1892 * @returns VBox status code.
1893 * @param pDevIns Device instance.
1894 * @param iRegion The region number.
1895 * @param cbRegion Size of the region.
1896 * @param enmType PCI_ADDRESS_SPACE_MEM, PCI_ADDRESS_SPACE_IO or PCI_ADDRESS_SPACE_MEM_PREFETCH.
1897 * @param pfnCallback Callback for doing the mapping.
1898 */
1899 DECLR3CALLBACKMEMBER(int, pfnPCIIORegionRegister,(PPDMDEVINS pDevIns, int iRegion, uint32_t cbRegion, PCIADDRESSSPACE enmType, PFNPCIIOREGIONMAP pfnCallback));
1900
1901 /**
1902 * Register PCI configuration space read/write callbacks.
1903 *
1904 * @param pDevIns Device instance.
1905 * @param pPciDev The PCI device structure.
1906 * If NULL the default PCI device for this device instance is used.
1907 * @param pfnRead Pointer to the user defined PCI config read function.
1908 * @param ppfnReadOld Pointer to function pointer which will receive the old (default)
1909 * PCI config read function. This way, user can decide when (and if)
1910 * to call default PCI config read function. Can be NULL.
1911 * @param pfnWrite Pointer to the user defined PCI config write function.
1912 * @param pfnWriteOld Pointer to function pointer which will receive the old (default)
1913 * PCI config write function. This way, user can decide when (and if)
1914 * to call default PCI config write function. Can be NULL.
1915 * @thread EMT
1916 */
1917 DECLR3CALLBACKMEMBER(void, pfnPCISetConfigCallbacks,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, PFNPCICONFIGREAD pfnRead, PPFNPCICONFIGREAD ppfnReadOld,
1918 PFNPCICONFIGWRITE pfnWrite, PPFNPCICONFIGWRITE ppfnWriteOld));
1919
1920 /**
1921 * Set the IRQ for a PCI device.
1922 *
1923 * @param pDevIns Device instance.
1924 * @param iIrq IRQ number to set.
1925 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
1926 * @thread Any thread, but will involve the emulation thread.
1927 */
1928 DECLR3CALLBACKMEMBER(void, pfnPCISetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
1929
1930 /**
1931 * Set the IRQ for a PCI device, but don't wait for EMT to process
1932 * the request when not called from EMT.
1933 *
1934 * @param pDevIns Device instance.
1935 * @param iIrq IRQ number to set.
1936 * @param iLevel IRQ level.
1937 * @thread Any thread, but will involve the emulation thread.
1938 */
1939 DECLR3CALLBACKMEMBER(void, pfnPCISetIrqNoWait,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
1940
1941 /**
1942 * Set ISA IRQ for a device.
1943 *
1944 * @param pDevIns Device instance.
1945 * @param iIrq IRQ number to set.
1946 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
1947 * @thread Any thread, but will involve the emulation thread.
1948 */
1949 DECLR3CALLBACKMEMBER(void, pfnISASetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
1950
1951 /**
1952 * Set the ISA IRQ for a device, but don't wait for EMT to process
1953 * the request when not called from EMT.
1954 *
1955 * @param pDevIns Device instance.
1956 * @param iIrq IRQ number to set.
1957 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
1958 * @thread Any thread, but will involve the emulation thread.
1959 */
1960 DECLR3CALLBACKMEMBER(void, pfnISASetIrqNoWait,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
1961
1962 /**
1963 * Attaches a driver (chain) to the device.
1964 *
1965 * The first call for a LUN this will serve as a registartion of the LUN. The pBaseInterface and
1966 * the pszDesc string will be registered with that LUN and kept around for PDMR3QueryDeviceLun().
1967 *
1968 * @returns VBox status code.
1969 * @param pDevIns Device instance.
1970 * @param iLun The logical unit to attach.
1971 * @param pBaseInterface Pointer to the base interface for that LUN. (device side / down)
1972 * @param ppBaseInterface Where to store the pointer to the base interface. (driver side / up)
1973 * @param pszDesc Pointer to a string describing the LUN. This string must remain valid
1974 * for the live of the device instance.
1975 */
1976 DECLR3CALLBACKMEMBER(int, pfnDriverAttach,(PPDMDEVINS pDevIns, RTUINT iLun, PPDMIBASE pBaseInterface, PPDMIBASE *ppBaseInterface, const char *pszDesc));
1977
1978 /**
1979 * Allocate memory which is associated with current VM instance
1980 * and automatically freed on it's destruction.
1981 *
1982 * @returns Pointer to allocated memory. The memory is *NOT* zero-ed.
1983 * @param pDevIns Device instance.
1984 * @param cb Number of bytes to allocate.
1985 */
1986 DECLR3CALLBACKMEMBER(void *, pfnMMHeapAlloc,(PPDMDEVINS pDevIns, size_t cb));
1987
1988 /**
1989 * Allocate memory which is associated with current VM instance
1990 * and automatically freed on it's destruction. The memory is ZEROed.
1991 *
1992 * @returns Pointer to allocated memory. The memory is *NOT* zero-ed.
1993 * @param pDevIns Device instance.
1994 * @param cb Number of bytes to allocate.
1995 */
1996 DECLR3CALLBACKMEMBER(void *, pfnMMHeapAllocZ,(PPDMDEVINS pDevIns, size_t cb));
1997
1998 /**
1999 * Free memory allocated with pfnMMHeapAlloc() and pfnMMHeapAllocZ().
2000 *
2001 * @param pDevIns Device instance.
2002 * @param pv Pointer to the memory to free.
2003 */
2004 DECLR3CALLBACKMEMBER(void, pfnMMHeapFree,(PPDMDEVINS pDevIns, void *pv));
2005
2006 /**
2007 * Set the VM error message
2008 *
2009 * @returns rc.
2010 * @param pDevIns Device instance.
2011 * @param rc VBox status code.
2012 * @param RT_SRC_POS_DECL Use RT_SRC_POS.
2013 * @param pszFormat Error message format string.
2014 * @param ... Error message arguments.
2015 */
2016 DECLR3CALLBACKMEMBER(int, pfnVMSetError,(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...));
2017
2018 /**
2019 * Set the VM error message
2020 *
2021 * @returns rc.
2022 * @param pDevIns Device instance.
2023 * @param rc VBox status code.
2024 * @param RT_SRC_POS_DECL Use RT_SRC_POS.
2025 * @param pszFormat Error message format string.
2026 * @param va Error message arguments.
2027 */
2028 DECLR3CALLBACKMEMBER(int, pfnVMSetErrorV,(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va));
2029
2030 /**
2031 * Set the VM runtime error message
2032 *
2033 * @returns VBox status code.
2034 * @param pDevIns Device instance.
2035 * @param fFatal Whether it is a fatal error or not.
2036 * @param pszErrorID Error ID string.
2037 * @param pszFormat Error message format string.
2038 * @param ... Error message arguments.
2039 */
2040 DECLR3CALLBACKMEMBER(int, pfnVMSetRuntimeError,(PPDMDEVINS pDevIns, bool fFatal, const char *pszErrorID, const char *pszFormat, ...));
2041
2042 /**
2043 * Set the VM runtime error message
2044 *
2045 * @returns VBox status code.
2046 * @param pDevIns Device instance.
2047 * @param fFatal Whether it is a fatal error or not.
2048 * @param pszErrorID Error ID string.
2049 * @param pszFormat Error message format string.
2050 * @param va Error message arguments.
2051 */
2052 DECLR3CALLBACKMEMBER(int, pfnVMSetRuntimeErrorV,(PPDMDEVINS pDevIns, bool fFatal, const char *pszErrorID, const char *pszFormat, va_list va));
2053
2054 /**
2055 * Assert that the current thread is the emulation thread.
2056 *
2057 * @returns True if correct.
2058 * @returns False if wrong.
2059 * @param pDevIns Device instance.
2060 * @param pszFile Filename of the assertion location.
2061 * @param iLine The linenumber of the assertion location.
2062 * @param pszFunction Function of the assertion location.
2063 */
2064 DECLR3CALLBACKMEMBER(bool, pfnAssertEMT,(PPDMDEVINS pDevIns, const char *pszFile, unsigned iLine, const char *pszFunction));
2065
2066 /**
2067 * Assert that the current thread is NOT the emulation thread.
2068 *
2069 * @returns True if correct.
2070 * @returns False if wrong.
2071 * @param pDevIns Device instance.
2072 * @param pszFile Filename of the assertion location.
2073 * @param iLine The linenumber of the assertion location.
2074 * @param pszFunction Function of the assertion location.
2075 */
2076 DECLR3CALLBACKMEMBER(bool, pfnAssertOther,(PPDMDEVINS pDevIns, const char *pszFile, unsigned iLine, const char *pszFunction));
2077
2078 /**
2079 * Stops the VM and enters the debugger to look at the guest state.
2080 *
2081 * Use the PDMDeviceDBGFStop() inline function with the RT_SRC_POS macro instead of
2082 * invoking this function directly.
2083 *
2084 * @returns VBox status code which must be passed up to the VMM.
2085 * @param pDevIns Device instance.
2086 * @param pszFile Filename of the assertion location.
2087 * @param iLine The linenumber of the assertion location.
2088 * @param pszFunction Function of the assertion location.
2089 * @param pszFormat Message. (optional)
2090 * @param args Message parameters.
2091 */
2092 DECLR3CALLBACKMEMBER(int, pfnDBGFStopV,(PPDMDEVINS pDevIns, const char *pszFile, unsigned iLine, const char *pszFunction, const char *pszFormat, va_list args));
2093
2094 /**
2095 * Register a info handler with DBGF,
2096 *
2097 * @returns VBox status code.
2098 * @param pDevIns Device instance.
2099 * @param pszName The identifier of the info.
2100 * @param pszDesc The description of the info and any arguments the handler may take.
2101 * @param pfnHandler The handler function to be called to display the info.
2102 */
2103 DECLR3CALLBACKMEMBER(int, pfnDBGFInfoRegister,(PPDMDEVINS pDevIns, const char *pszName, const char *pszDesc, PFNDBGFHANDLERDEV pfnHandler));
2104
2105 /**
2106 * Registers a statistics sample if statistics are enabled.
2107 *
2108 * @param pDevIns Device instance of the DMA.
2109 * @param pvSample Pointer to the sample.
2110 * @param enmType Sample type. This indicates what pvSample is pointing at.
2111 * @param pszName Sample name. The name is on this form "/<component>/<sample>".
2112 * Further nesting is possible.
2113 * @param enmUnit Sample unit.
2114 * @param pszDesc Sample description.
2115 */
2116 DECLR3CALLBACKMEMBER(void, pfnSTAMRegister,(PPDMDEVINS pDevIns, void *pvSample, STAMTYPE enmType, const char *pszName, STAMUNIT enmUnit, const char *pszDesc));
2117
2118 /**
2119 * Same as pfnSTAMRegister except that the name is specified in a
2120 * RTStrPrintf like fashion.
2121 *
2122 * @returns VBox status.
2123 * @param pDevIns Device instance of the DMA.
2124 * @param pvSample Pointer to the sample.
2125 * @param enmType Sample type. This indicates what pvSample is pointing at.
2126 * @param enmVisibility Visibility type specifying whether unused statistics should be visible or not.
2127 * @param enmUnit Sample unit.
2128 * @param pszDesc Sample description.
2129 * @param pszName The sample name format string.
2130 * @param ... Arguments to the format string.
2131 */
2132 DECLR3CALLBACKMEMBER(void, pfnSTAMRegisterF,(PPDMDEVINS pDevIns, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility,
2133 STAMUNIT enmUnit, const char *pszDesc, const char *pszName, ...));
2134
2135 /**
2136 * Same as pfnSTAMRegister except that the name is specified in a
2137 * RTStrPrintfV like fashion.
2138 *
2139 * @returns VBox status.
2140 * @param pDevIns Device instance of the DMA.
2141 * @param pvSample Pointer to the sample.
2142 * @param enmType Sample type. This indicates what pvSample is pointing at.
2143 * @param enmVisibility Visibility type specifying whether unused statistics should be visible or not.
2144 * @param enmUnit Sample unit.
2145 * @param pszDesc Sample description.
2146 * @param pszName The sample name format string.
2147 * @param args Arguments to the format string.
2148 */
2149 DECLR3CALLBACKMEMBER(void, pfnSTAMRegisterV,(PPDMDEVINS pDevIns, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility,
2150 STAMUNIT enmUnit, const char *pszDesc, const char *pszName, va_list args));
2151
2152 /**
2153 * Register the RTC device.
2154 *
2155 * @returns VBox status code.
2156 * @param pDevIns Device instance.
2157 * @param pRtcReg Pointer to a RTC registration structure.
2158 * @param ppRtcHlp Where to store the pointer to the helper functions.
2159 */
2160 DECLR3CALLBACKMEMBER(int, pfnRTCRegister,(PPDMDEVINS pDevIns, PCPDMRTCREG pRtcReg, PCPDMRTCHLP *ppRtcHlp));
2161
2162 /**
2163 * Create a queue.
2164 *
2165 * @returns VBox status code.
2166 * @param pDevIns The device instance.
2167 * @param cbItem The size of a queue item.
2168 * @param cItems The number of items in the queue.
2169 * @param cMilliesInterval The number of milliseconds between polling the queue.
2170 * If 0 then the emulation thread will be notified whenever an item arrives.
2171 * @param pfnCallback The consumer function.
2172 * @param fGCEnabled Set if the queue should work in GC too.
2173 * @param ppQueue Where to store the queue handle on success.
2174 * @thread The emulation thread.
2175 */
2176 DECLR3CALLBACKMEMBER(int, pfnPDMQueueCreate,(PPDMDEVINS pDevIns, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval,
2177 PFNPDMQUEUEDEV pfnCallback, bool fGCEnabled, PPDMQUEUE *ppQueue));
2178
2179 /**
2180 * Initializes a PDM critical section.
2181 *
2182 * The PDM critical sections are derived from the IPRT critical sections, but
2183 * works in GC as well.
2184 *
2185 * @returns VBox status code.
2186 * @param pDevIns Device instance.
2187 * @param pCritSect Pointer to the critical section.
2188 * @param pszName The name of the critical section (for statistics).
2189 */
2190 DECLR3CALLBACKMEMBER(int, pfnCritSectInit,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, const char *pszName));
2191
2192 /**
2193 * Get the real world UTC time adjusted for VM lag, user offset and warpdrive.
2194 *
2195 * @returns pTime.
2196 * @param pDevIns Device instance.
2197 * @param pTime Where to store the time.
2198 */
2199 DECLR3CALLBACKMEMBER(PRTTIMESPEC, pfnUTCNow,(PPDMDEVINS pDevIns, PRTTIMESPEC pTime));
2200
2201 /**
2202 * Creates a PDM thread.
2203 *
2204 * This differs from the RTThreadCreate() API in that PDM takes care of suspending,
2205 * resuming, and destroying the thread as the VM state changes.
2206 *
2207 * @returns VBox status code.
2208 * @param pDevIns The device instance.
2209 * @param ppThread Where to store the thread 'handle'.
2210 * @param pvUser The user argument to the thread function.
2211 * @param pfnThread The thread function.
2212 * @param pfnWakeup The wakup callback. This is called on the EMT thread when
2213 * a state change is pending.
2214 * @param cbStack See RTThreadCreate.
2215 * @param enmType See RTThreadCreate.
2216 * @param pszName See RTThreadCreate.
2217 */
2218 DECLR3CALLBACKMEMBER(int, pfnPDMThreadCreate,(PPDMDEVINS pDevIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADDEV pfnThread,
2219 PFNPDMTHREADWAKEUPDEV pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName));
2220
2221 /**
2222 * Convert a guest virtual address to a guest physical address.
2223 *
2224 * @returns VBox status code.
2225 * @param pDevIns Device instance.
2226 * @param GCPtr Guest virtual address.
2227 * @param pGCPhys Where to store the GC physical address corresponding to GCPtr.
2228 * @thread The emulation thread.
2229 * @remark Careful with page boundraries.
2230 */
2231 DECLR3CALLBACKMEMBER(int, pfnPhysGCPtr2GCPhys, (PPDMDEVINS pDevIns, RTGCPTR GCPtr, PRTGCPHYS pGCPhys));
2232
2233 /**
2234 * Gets the VM state.
2235 *
2236 * @returns VM state.
2237 * @param pDevIns The device instance.
2238 * @thread Any thread (just keep in mind that it's volatile info).
2239 */
2240 DECLR3CALLBACKMEMBER(VMSTATE, pfnVMState, (PPDMDEVINS pDevIns));
2241
2242 /** Space reserved for future members.
2243 * @{ */
2244 DECLR3CALLBACKMEMBER(void, pfnReserved4,(void));
2245 DECLR3CALLBACKMEMBER(void, pfnReserved5,(void));
2246 DECLR3CALLBACKMEMBER(void, pfnReserved6,(void));
2247 DECLR3CALLBACKMEMBER(void, pfnReserved7,(void));
2248 DECLR3CALLBACKMEMBER(void, pfnReserved8,(void));
2249 DECLR3CALLBACKMEMBER(void, pfnReserved9,(void));
2250 DECLR3CALLBACKMEMBER(void, pfnReserved10,(void));
2251 /** @} */
2252
2253
2254 /** API available to trusted devices only.
2255 *
2256 * These APIs are providing unrestricted access to the guest and the VM,
2257 * or they are interacting intimately with PDM.
2258 *
2259 * @{
2260 */
2261 /**
2262 * Gets the VM handle. Restricted API.
2263 *
2264 * @returns VM Handle.
2265 * @param pDevIns Device instance.
2266 */
2267 DECLR3CALLBACKMEMBER(PVM, pfnGetVM,(PPDMDEVINS pDevIns));
2268
2269 /**
2270 * Register the PCI Bus.
2271 *
2272 * @returns VBox status code.
2273 * @param pDevIns Device instance.
2274 * @param pPciBusReg Pointer to PCI bus registration structure.
2275 * @param ppPciHlpR3 Where to store the pointer to the PCI Bus helpers.
2276 */
2277 DECLR3CALLBACKMEMBER(int, pfnPCIBusRegister,(PPDMDEVINS pDevIns, PPDMPCIBUSREG pPciBusReg, PCPDMPCIHLPR3 *ppPciHlpR3));
2278
2279 /**
2280 * Register the PIC device.
2281 *
2282 * @returns VBox status code.
2283 * @param pDevIns Device instance.
2284 * @param pPicReg Pointer to a PIC registration structure.
2285 * @param ppPicHlpR3 Where to store the pointer to the PIC HC helpers.
2286 */
2287 DECLR3CALLBACKMEMBER(int, pfnPICRegister,(PPDMDEVINS pDevIns, PPDMPICREG pPicReg, PCPDMPICHLPR3 *ppPicHlpR3));
2288
2289 /**
2290 * Register the APIC device.
2291 *
2292 * @returns VBox status code.
2293 * @param pDevIns Device instance.
2294 * @param pApicReg Pointer to a APIC registration structure.
2295 * @param ppApicHlpR3 Where to store the pointer to the APIC helpers.
2296 */
2297 DECLR3CALLBACKMEMBER(int, pfnAPICRegister,(PPDMDEVINS pDevIns, PPDMAPICREG pApicReg, PCPDMAPICHLPR3 *ppApicHlpR3));
2298
2299 /**
2300 * Register the I/O APIC device.
2301 *
2302 * @returns VBox status code.
2303 * @param pDevIns Device instance.
2304 * @param pIoApicReg Pointer to a I/O APIC registration structure.
2305 * @param ppIoApicHlpR3 Where to store the pointer to the IOAPIC helpers.
2306 */
2307 DECLR3CALLBACKMEMBER(int, pfnIOAPICRegister,(PPDMDEVINS pDevIns, PPDMIOAPICREG pIoApicReg, PCPDMIOAPICHLPR3 *ppIoApicHlpR3));
2308
2309 /**
2310 * Register the DMA device.
2311 *
2312 * @returns VBox status code.
2313 * @param pDevIns Device instance.
2314 * @param pDmacReg Pointer to a DMAC registration structure.
2315 * @param ppDmacHlp Where to store the pointer to the DMA helpers.
2316 */
2317 DECLR3CALLBACKMEMBER(int, pfnDMACRegister,(PPDMDEVINS pDevIns, PPDMDMACREG pDmacReg, PCPDMDMACHLP *ppDmacHlp));
2318
2319 /**
2320 * Read physical memory.
2321 *
2322 * @param pDevIns Device instance.
2323 * @param GCPhys Physical address start reading from.
2324 * @param pvBuf Where to put the read bits.
2325 * @param cbRead How many bytes to read.
2326 * @thread Any thread, but the call may involve the emulation thread.
2327 */
2328 DECLR3CALLBACKMEMBER(void, pfnPhysRead,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead));
2329
2330 /**
2331 * Write to physical memory.
2332 *
2333 * @param pDevIns Device instance.
2334 * @param GCPhys Physical address to write to.
2335 * @param pvBuf What to write.
2336 * @param cbWrite How many bytes to write.
2337 * @thread Any thread, but the call may involve the emulation thread.
2338 */
2339 DECLR3CALLBACKMEMBER(void, pfnPhysWrite,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite));
2340
2341 /**
2342 * Read guest physical memory by virtual address.
2343 *
2344 * @param pDevIns Device instance.
2345 * @param pvDst Where to put the read bits.
2346 * @param GCVirtSrc Guest virtual address to start reading from.
2347 * @param cb How many bytes to read.
2348 * @thread The emulation thread.
2349 */
2350 DECLR3CALLBACKMEMBER(int, pfnPhysReadGCVirt,(PPDMDEVINS pDevIns, void *pvDst, RTGCPTR GCVirtSrc, size_t cb));
2351
2352 /**
2353 * Write to guest physical memory by virtual address.
2354 *
2355 * @param pDevIns Device instance.
2356 * @param GCVirtDst Guest virtual address to write to.
2357 * @param pvSrc What to write.
2358 * @param cb How many bytes to write.
2359 * @thread The emulation thread.
2360 */
2361 DECLR3CALLBACKMEMBER(int, pfnPhysWriteGCVirt,(PPDMDEVINS pDevIns, RTGCPTR GCVirtDst, const void *pvSrc, size_t cb));
2362
2363 /**
2364 * Reserve physical address space for ROM and MMIO ranges.
2365 *
2366 * @returns VBox status code.
2367 * @param pDevIns Device instance.
2368 * @param GCPhys Start physical address.
2369 * @param cbRange The size of the range.
2370 * @param pszDesc Description string.
2371 * @thread The emulation thread.
2372 */
2373 DECLR3CALLBACKMEMBER(int, pfnPhysReserve,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTUINT cbRange, const char *pszDesc));
2374
2375 /**
2376 * Convert a guest physical address to a host virtual address. (OBSOLETE)
2377 *
2378 * @returns VBox status code.
2379 * @param pDevIns Device instance.
2380 * @param GCPhys Start physical address.
2381 * @param cbRange The size of the range. Use 0 if you don't care about the range.
2382 * @param ppvHC Where to store the HC pointer corresponding to GCPhys.
2383 * @thread The emulation thread.
2384 *
2385 * @remark Careful with page boundraries.
2386 * @remark Do not use the mapping after you return to the caller! (it could get invalidated/changed)
2387 */
2388 DECLR3CALLBACKMEMBER(int, pfnObsoletePhys2HCVirt,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTUINT cbRange, PRTHCPTR ppvHC));
2389
2390 /**
2391 * Convert a guest virtual address to a host virtual address. (OBSOLETE)
2392 *
2393 * @returns VBox status code.
2394 * @param pDevIns Device instance.
2395 * @param GCPtr Guest virtual address.
2396 * @param pHCPtr Where to store the HC pointer corresponding to GCPtr.
2397 * @thread The emulation thread.
2398 *
2399 * @remark Careful with page boundraries.
2400 * @remark Do not use the mapping after you return to the caller! (it could get invalidated/changed)
2401 */
2402 DECLR3CALLBACKMEMBER(int, pfnObsoletePhysGCPtr2HCPtr,(PPDMDEVINS pDevIns, RTGCPTR GCPtr, PRTHCPTR pHCPtr));
2403
2404 /**
2405 * Checks if the Gate A20 is enabled or not.
2406 *
2407 * @returns true if A20 is enabled.
2408 * @returns false if A20 is disabled.
2409 * @param pDevIns Device instance.
2410 * @thread The emulation thread.
2411 */
2412 DECLR3CALLBACKMEMBER(bool, pfnA20IsEnabled,(PPDMDEVINS pDevIns));
2413
2414 /**
2415 * Enables or disables the Gate A20.
2416 *
2417 * @param pDevIns Device instance.
2418 * @param fEnable Set this flag to enable the Gate A20; clear it to disable.
2419 * @thread The emulation thread.
2420 */
2421 DECLR3CALLBACKMEMBER(void, pfnA20Set,(PPDMDEVINS pDevIns, bool fEnable));
2422
2423 /**
2424 * Resets the VM.
2425 *
2426 * @returns The appropriate VBox status code to pass around on reset.
2427 * @param pDevIns Device instance.
2428 * @thread The emulation thread.
2429 */
2430 DECLR3CALLBACKMEMBER(int, pfnVMReset,(PPDMDEVINS pDevIns));
2431
2432 /**
2433 * Suspends the VM.
2434 *
2435 * @returns The appropriate VBox status code to pass around on suspend.
2436 * @param pDevIns Device instance.
2437 * @thread The emulation thread.
2438 */
2439 DECLR3CALLBACKMEMBER(int, pfnVMSuspend,(PPDMDEVINS pDevIns));
2440
2441 /**
2442 * Power off the VM.
2443 *
2444 * @returns The appropriate VBox status code to pass around on power off.
2445 * @param pDevIns Device instance.
2446 * @thread The emulation thread.
2447 */
2448 DECLR3CALLBACKMEMBER(int, pfnVMPowerOff,(PPDMDEVINS pDevIns));
2449
2450 /**
2451 * Acquire global VM lock
2452 *
2453 * @returns VBox status code
2454 * @param pDevIns Device instance.
2455 */
2456 DECLR3CALLBACKMEMBER(int , pfnLockVM,(PPDMDEVINS pDevIns));
2457
2458 /**
2459 * Release global VM lock
2460 *
2461 * @returns VBox status code
2462 * @param pDevIns Device instance.
2463 */
2464 DECLR3CALLBACKMEMBER(int, pfnUnlockVM,(PPDMDEVINS pDevIns));
2465
2466 /**
2467 * Check that the current thread owns the global VM lock.
2468 *
2469 * @returns boolean
2470 * @param pDevIns Device instance.
2471 * @param pszFile Filename of the assertion location.
2472 * @param iLine Linenumber of the assertion location.
2473 * @param pszFunction Function of the assertion location.
2474 */
2475 DECLR3CALLBACKMEMBER(bool, pfnAssertVMLock,(PPDMDEVINS pDevIns, const char *pszFile, unsigned iLine, const char *pszFunction));
2476
2477 /**
2478 * Register transfer function for DMA channel.
2479 *
2480 * @returns VBox status code.
2481 * @param pDevIns Device instance.
2482 * @param uChannel Channel number.
2483 * @param pfnTransferHandler Device specific transfer callback function.
2484 * @param pvUser User pointer to pass to the callback.
2485 * @thread EMT
2486 */
2487 DECLR3CALLBACKMEMBER(int, pfnDMARegister,(PPDMDEVINS pDevIns, unsigned uChannel, PFNDMATRANSFERHANDLER pfnTransferHandler, void *pvUser));
2488
2489 /**
2490 * Read memory.
2491 *
2492 * @returns VBox status code.
2493 * @param pDevIns Device instance.
2494 * @param uChannel Channel number.
2495 * @param pvBuffer Pointer to target buffer.
2496 * @param off DMA position.
2497 * @param cbBlock Block size.
2498 * @param pcbRead Where to store the number of bytes which was read. optional.
2499 * @thread EMT
2500 */
2501 DECLR3CALLBACKMEMBER(int, pfnDMAReadMemory,(PPDMDEVINS pDevIns, unsigned uChannel, void *pvBuffer, uint32_t off, uint32_t cbBlock, uint32_t *pcbRead));
2502
2503 /**
2504 * Write memory.
2505 *
2506 * @returns VBox status code.
2507 * @param pDevIns Device instance.
2508 * @param uChannel Channel number.
2509 * @param pvBuffer Memory to write.
2510 * @param off DMA position.
2511 * @param cbBlock Block size.
2512 * @param pcbWritten Where to store the number of bytes which was written. optional.
2513 * @thread EMT
2514 */
2515 DECLR3CALLBACKMEMBER(int, pfnDMAWriteMemory,(PPDMDEVINS pDevIns, unsigned uChannel, const void *pvBuffer, uint32_t off, uint32_t cbBlock, uint32_t *pcbWritten));
2516
2517 /**
2518 * Set the DREQ line.
2519 *
2520 * @returns VBox status code.
2521 * @param pDevIns Device instance.
2522 * @param uChannel Channel number.
2523 * @param uLevel Level of the line.
2524 * @thread EMT
2525 */
2526 DECLR3CALLBACKMEMBER(int, pfnDMASetDREQ,(PPDMDEVINS pDevIns, unsigned uChannel, unsigned uLevel));
2527
2528 /**
2529 * Get channel mode.
2530 *
2531 * @returns Channel mode. See specs.
2532 * @param pDevIns Device instance.
2533 * @param uChannel Channel number.
2534 * @thread EMT
2535 */
2536 DECLR3CALLBACKMEMBER(uint8_t, pfnDMAGetChannelMode,(PPDMDEVINS pDevIns, unsigned uChannel));
2537
2538 /**
2539 * Schedule DMA execution.
2540 *
2541 * @param pDevIns Device instance.
2542 * @thread Any thread.
2543 */
2544 DECLR3CALLBACKMEMBER(void, pfnDMASchedule,(PPDMDEVINS pDevIns));
2545
2546 /**
2547 * Write CMOS value and update the checksum(s).
2548 *
2549 * @returns VBox status code.
2550 * @param pDevIns Device instance.
2551 * @param iReg The CMOS register index.
2552 * @param u8Value The CMOS register value.
2553 * @thread EMT
2554 */
2555 DECLR3CALLBACKMEMBER(int, pfnCMOSWrite,(PPDMDEVINS pDevIns, unsigned iReg, uint8_t u8Value));
2556
2557 /**
2558 * Read CMOS value.
2559 *
2560 * @returns VBox status code.
2561 * @param pDevIns Device instance.
2562 * @param iReg The CMOS register index.
2563 * @param pu8Value Where to store the CMOS register value.
2564 * @thread EMT
2565 */
2566 DECLR3CALLBACKMEMBER(int, pfnCMOSRead,(PPDMDEVINS pDevIns, unsigned iReg, uint8_t *pu8Value));
2567
2568 /**
2569 * Query CPUID.
2570 *
2571 * @param pDevIns Device instance.
2572 * @param iLeaf The CPUID leaf to get.
2573 * @param pEax Where to store the EAX value.
2574 * @param pEbx Where to store the EBX value.
2575 * @param pEcx Where to store the ECX value.
2576 * @param pEdx Where to store the EDX value.
2577 */
2578 DECLR3CALLBACKMEMBER(void, pfnGetCpuId,(PPDMDEVINS pDevIns, uint32_t iLeaf, uint32_t *pEax, uint32_t *pEbx, uint32_t *pEcx, uint32_t *pEdx));
2579
2580 /**
2581 * Write protects a shadow ROM mapping.
2582 *
2583 * This is intented for use by the system BIOS or by the device that
2584 * employs a shadow ROM BIOS, so that the shadow ROM mapping can be
2585 * write protected once the POST is over.
2586 *
2587 * @param pDevIns Device instance.
2588 * @param GCPhysStart Where the shadow ROM mapping starts.
2589 * @param cbRange The size of the shadow ROM mapping.
2590 */
2591 DECLR3CALLBACKMEMBER(int, pfnROMProtectShadow,(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange));
2592
2593 /**
2594 * Allocate and register a MMIO2 region.
2595 *
2596 * As mentioned elsewhere, MMIO2 is just RAM spelled differently. It's
2597 * RAM associated with a device. It is also non-shared memory with a
2598 * permanent ring-3 mapping and page backing (presently).
2599 *
2600 * @returns VBox status.
2601 * @param pDevIns The device instance.
2602 * @param iRegion The region number. Use the PCI region number as
2603 * this must be known to the PCI bus device too. If it's not associated
2604 * with the PCI device, then any number up to UINT8_MAX is fine.
2605 * @param cb The size (in bytes) of the region.
2606 * @param fFlags Reserved for future use, must be zero.
2607 * @param ppv Where to store the address of the ring-3 mapping of the memory.
2608 * @param pszDesc Pointer to description string. This must not be freed.
2609 * @thread EMT.
2610 */
2611 DECLR3CALLBACKMEMBER(int, pfnMMIO2Register,(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS cb, uint32_t fFlags, void **ppv, const char *pszDesc));
2612
2613 /**
2614 * Deregisters and frees a MMIO2 region.
2615 *
2616 * Any physical (and virtual) access handlers registered for the region must
2617 * be deregistered before calling this function.
2618 *
2619 * @returns VBox status code.
2620 * @param pDevIns The device instance.
2621 * @param iRegion The region number used during registration.
2622 * @thread EMT.
2623 */
2624 DECLR3CALLBACKMEMBER(int, pfnMMIO2Deregister,(PPDMDEVINS pDevIns, uint32_t iRegion));
2625
2626 /**
2627 * Maps a MMIO2 region into the physical memory space.
2628 *
2629 * A MMIO2 range may overlap with base memory if a lot of RAM
2630 * is configured for the VM, in which case we'll drop the base
2631 * memory pages. Presently we will make no attempt to preserve
2632 * anything that happens to be present in the base memory that
2633 * is replaced, this is of course incorrectly but it's too much
2634 * effort.
2635 *
2636 * @returns VBox status code.
2637 * @param pDevIns The device instance.
2638 * @param iRegion The region number used during registration.
2639 * @param GCPhys The physical address to map it at.
2640 * @thread EMT.
2641 */
2642 DECLR3CALLBACKMEMBER(int, pfnMMIO2Map,(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS GCPhys));
2643
2644 /**
2645 * Unmaps a MMIO2 region previously mapped using pfnMMIO2Map.
2646 *
2647 * @returns VBox status code.
2648 * @param pDevIns The device instance.
2649 * @param iRegion The region number used during registration.
2650 * @param GCPhys The physical address it's currently mapped at.
2651 * @thread EMT.
2652 */
2653 DECLR3CALLBACKMEMBER(int, pfnMMIO2Unmap,(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS GCPhys));
2654
2655 /**
2656 * Maps a portion of an MMIO2 region into the hypervisor region.
2657 *
2658 * Callers of this API must never deregister the MMIO2 region before the
2659 * VM is powered off.
2660 *
2661 * @return VBox status code.
2662 * @param pDevIns The device owning the MMIO2 memory.
2663 * @param iRegion The region.
2664 * @param off The offset into the region. Will be rounded down to closest page boundrary.
2665 * @param cb The number of bytes to map. Will be rounded up to the closest page boundrary.
2666 * @param pszDesc Mapping description.
2667 * @param pRCPtr Where to store the RC address.
2668 */
2669 DECLR3CALLBACKMEMBER(int, pfnMMHyperMapMMIO2,(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS off, RTGCPHYS cb,
2670 const char *pszDesc, PRTRCPTR pRCPtr));
2671
2672 /** @} */
2673
2674 /** Just a safety precaution. (PDM_DEVHLP_VERSION) */
2675 uint32_t u32TheEnd;
2676} PDMDEVHLP;
2677#endif /* !IN_RING3 */
2678/** Pointer PDM Device API. */
2679typedef R3PTRTYPE(struct PDMDEVHLP *) PPDMDEVHLP;
2680/** Pointer PDM Device API. */
2681typedef R3PTRTYPE(const struct PDMDEVHLP *) PCPDMDEVHLP;
2682
2683/** Current PDMDEVHLP version number. */
2684#define PDM_DEVHLP_VERSION 0xf2060000
2685
2686
2687/**
2688 * PDM Device API - GC Variant.
2689 */
2690typedef struct PDMDEVHLPGC
2691{
2692 /** Structure version. PDM_DEVHLPGC_VERSION defines the current version. */
2693 uint32_t u32Version;
2694
2695 /**
2696 * Set the IRQ for a PCI device.
2697 *
2698 * @param pDevIns Device instance.
2699 * @param iIrq IRQ number to set.
2700 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
2701 * @thread Any thread, but will involve the emulation thread.
2702 */
2703 DECLRCCALLBACKMEMBER(void, pfnPCISetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
2704
2705 /**
2706 * Set ISA IRQ for a device.
2707 *
2708 * @param pDevIns Device instance.
2709 * @param iIrq IRQ number to set.
2710 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
2711 * @thread Any thread, but will involve the emulation thread.
2712 */
2713 DECLRCCALLBACKMEMBER(void, pfnISASetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
2714
2715 /**
2716 * Read physical memory.
2717 *
2718 * @param pDevIns Device instance.
2719 * @param GCPhys Physical address start reading from.
2720 * @param pvBuf Where to put the read bits.
2721 * @param cbRead How many bytes to read.
2722 */
2723 DECLRCCALLBACKMEMBER(void, pfnPhysRead,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead));
2724
2725 /**
2726 * Write to physical memory.
2727 *
2728 * @param pDevIns Device instance.
2729 * @param GCPhys Physical address to write to.
2730 * @param pvBuf What to write.
2731 * @param cbWrite How many bytes to write.
2732 */
2733 DECLRCCALLBACKMEMBER(void, pfnPhysWrite,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite));
2734
2735 /**
2736 * Checks if the Gate A20 is enabled or not.
2737 *
2738 * @returns true if A20 is enabled.
2739 * @returns false if A20 is disabled.
2740 * @param pDevIns Device instance.
2741 * @thread The emulation thread.
2742 */
2743 DECLRCCALLBACKMEMBER(bool, pfnA20IsEnabled,(PPDMDEVINS pDevIns));
2744
2745 /**
2746 * Set the VM error message
2747 *
2748 * @returns rc.
2749 * @param pDrvIns Driver instance.
2750 * @param rc VBox status code.
2751 * @param RT_SRC_POS_DECL Use RT_SRC_POS.
2752 * @param pszFormat Error message format string.
2753 * @param ... Error message arguments.
2754 */
2755 DECLRCCALLBACKMEMBER(int, pfnVMSetError,(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...));
2756
2757 /**
2758 * Set the VM error message
2759 *
2760 * @returns rc.
2761 * @param pDrvIns Driver instance.
2762 * @param rc VBox status code.
2763 * @param RT_SRC_POS_DECL Use RT_SRC_POS.
2764 * @param pszFormat Error message format string.
2765 * @param va Error message arguments.
2766 */
2767 DECLRCCALLBACKMEMBER(int, pfnVMSetErrorV,(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va));
2768
2769 /**
2770 * Set the VM runtime error message
2771 *
2772 * @returns VBox status code.
2773 * @param pDevIns Device instance.
2774 * @param fFatal Whether it is a fatal error or not.
2775 * @param pszErrorID Error ID string.
2776 * @param pszFormat Error message format string.
2777 * @param ... Error message arguments.
2778 */
2779 DECLRCCALLBACKMEMBER(int, pfnVMSetRuntimeError,(PPDMDEVINS pDevIns, bool fFatal, const char *pszErrorID, const char *pszFormat, ...));
2780
2781 /**
2782 * Set the VM runtime error message
2783 *
2784 * @returns VBox status code.
2785 * @param pDevIns Device instance.
2786 * @param fFatal Whether it is a fatal error or not.
2787 * @param pszErrorID Error ID string.
2788 * @param pszFormat Error message format string.
2789 * @param va Error message arguments.
2790 */
2791 DECLRCCALLBACKMEMBER(int, pfnVMSetRuntimeErrorV,(PPDMDEVINS pDevIns, bool fFatal, const char *pszErrorID, const char *pszFormat, va_list va));
2792
2793 /**
2794 * Set parameters for pending MMIO patch operation
2795 *
2796 * @returns VBox status code.
2797 * @param pDevIns Device instance.
2798 * @param GCPhys MMIO physical address
2799 * @param pCachedData GC pointer to cached data
2800 */
2801 DECLRCCALLBACKMEMBER(int, pfnPATMSetMMIOPatchInfo,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTGCPTR pCachedData));
2802
2803 /** Just a safety precaution. */
2804 uint32_t u32TheEnd;
2805} PDMDEVHLPGC;
2806/** Pointer PDM Device GC API. */
2807typedef RCPTRTYPE(struct PDMDEVHLPGC *) PPDMDEVHLPGC;
2808/** Pointer PDM Device GC API. */
2809typedef RCPTRTYPE(const struct PDMDEVHLPGC *) PCPDMDEVHLPGC;
2810
2811/** Current PDMDEVHLP version number. */
2812#define PDM_DEVHLPGC_VERSION 0xfb010000
2813
2814
2815/**
2816 * PDM Device API - R0 Variant.
2817 */
2818typedef struct PDMDEVHLPR0
2819{
2820 /** Structure version. PDM_DEVHLPR0_VERSION defines the current version. */
2821 uint32_t u32Version;
2822
2823 /**
2824 * Set the IRQ for a PCI device.
2825 *
2826 * @param pDevIns Device instance.
2827 * @param iIrq IRQ number to set.
2828 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
2829 * @thread Any thread, but will involve the emulation thread.
2830 */
2831 DECLR0CALLBACKMEMBER(void, pfnPCISetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
2832
2833 /**
2834 * Set ISA IRQ for a device.
2835 *
2836 * @param pDevIns Device instance.
2837 * @param iIrq IRQ number to set.
2838 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
2839 * @thread Any thread, but will involve the emulation thread.
2840 */
2841 DECLR0CALLBACKMEMBER(void, pfnISASetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
2842
2843 /**
2844 * Read physical memory.
2845 *
2846 * @param pDevIns Device instance.
2847 * @param GCPhys Physical address start reading from.
2848 * @param pvBuf Where to put the read bits.
2849 * @param cbRead How many bytes to read.
2850 */
2851 DECLR0CALLBACKMEMBER(void, pfnPhysRead,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead));
2852
2853 /**
2854 * Write to physical memory.
2855 *
2856 * @param pDevIns Device instance.
2857 * @param GCPhys Physical address to write to.
2858 * @param pvBuf What to write.
2859 * @param cbWrite How many bytes to write.
2860 */
2861 DECLR0CALLBACKMEMBER(void, pfnPhysWrite,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite));
2862
2863 /**
2864 * Checks if the Gate A20 is enabled or not.
2865 *
2866 * @returns true if A20 is enabled.
2867 * @returns false if A20 is disabled.
2868 * @param pDevIns Device instance.
2869 * @thread The emulation thread.
2870 */
2871 DECLR0CALLBACKMEMBER(bool, pfnA20IsEnabled,(PPDMDEVINS pDevIns));
2872
2873 /**
2874 * Set the VM error message
2875 *
2876 * @returns rc.
2877 * @param pDrvIns Driver instance.
2878 * @param rc VBox status code.
2879 * @param RT_SRC_POS_DECL Use RT_SRC_POS.
2880 * @param pszFormat Error message format string.
2881 * @param ... Error message arguments.
2882 */
2883 DECLR0CALLBACKMEMBER(int, pfnVMSetError,(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...));
2884
2885 /**
2886 * Set the VM error message
2887 *
2888 * @returns rc.
2889 * @param pDrvIns Driver instance.
2890 * @param rc VBox status code.
2891 * @param RT_SRC_POS_DECL Use RT_SRC_POS.
2892 * @param pszFormat Error message format string.
2893 * @param va Error message arguments.
2894 */
2895 DECLR0CALLBACKMEMBER(int, pfnVMSetErrorV,(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va));
2896
2897 /**
2898 * Set the VM runtime error message
2899 *
2900 * @returns VBox status code.
2901 * @param pDevIns Device instance.
2902 * @param fFatal Whether it is a fatal error or not.
2903 * @param pszErrorID Error ID string.
2904 * @param pszFormat Error message format string.
2905 * @param ... Error message arguments.
2906 */
2907 DECLR0CALLBACKMEMBER(int, pfnVMSetRuntimeError,(PPDMDEVINS pDevIns, bool fFatal, const char *pszErrorID, const char *pszFormat, ...));
2908
2909 /**
2910 * Set the VM runtime error message
2911 *
2912 * @returns VBox status code.
2913 * @param pDevIns Device instance.
2914 * @param fFatal Whether it is a fatal error or not.
2915 * @param pszErrorID Error ID string.
2916 * @param pszFormat Error message format string.
2917 * @param va Error message arguments.
2918 */
2919 DECLR0CALLBACKMEMBER(int, pfnVMSetRuntimeErrorV,(PPDMDEVINS pDevIns, bool fFatal, const char *pszErrorID, const char *pszFormat, va_list va));
2920
2921 /**
2922 * Set parameters for pending MMIO patch operation
2923 *
2924 * @returns rc.
2925 * @param pDevIns Device instance.
2926 * @param GCPhys MMIO physical address
2927 * @param pCachedData GC pointer to cached data
2928 */
2929 DECLR0CALLBACKMEMBER(int, pfnPATMSetMMIOPatchInfo,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTGCPTR pCachedData));
2930
2931 /** Just a safety precaution. */
2932 uint32_t u32TheEnd;
2933} PDMDEVHLPR0;
2934/** Pointer PDM Device R0 API. */
2935typedef R0PTRTYPE(struct PDMDEVHLPR0 *) PPDMDEVHLPR0;
2936/** Pointer PDM Device GC API. */
2937typedef R0PTRTYPE(const struct PDMDEVHLPR0 *) PCPDMDEVHLPR0;
2938
2939/** Current PDMDEVHLP version number. */
2940#define PDM_DEVHLPR0_VERSION 0xfb010000
2941
2942
2943
2944/**
2945 * PDM Device Instance.
2946 */
2947typedef struct PDMDEVINS
2948{
2949 /** Structure version. PDM_DEVINS_VERSION defines the current version. */
2950 uint32_t u32Version;
2951 /** Device instance number. */
2952 RTUINT iInstance;
2953 /** The base interface of the device.
2954 * The device constructor initializes this if it has any
2955 * device level interfaces to export. To obtain this interface
2956 * call PDMR3QueryDevice(). */
2957 PDMIBASE IBase;
2958
2959 /** Internal data. */
2960 union
2961 {
2962#ifdef PDMDEVINSINT_DECLARED
2963 PDMDEVINSINT s;
2964#endif
2965 uint8_t padding[HC_ARCH_BITS == 32 ? 48 : 96];
2966 } Internal;
2967
2968 /** Pointer the HC PDM Device API. */
2969 R3PTRTYPE(PCPDMDEVHLP) pDevHlp;
2970 /** Pointer the R0 PDM Device API. */
2971 R0PTRTYPE(PCPDMDEVHLPR0) pDevHlpR0;
2972 /** Pointer to device registration structure. */
2973 R3PTRTYPE(PCPDMDEVREG) pDevReg;
2974 /** Configuration handle. */
2975 R3PTRTYPE(PCFGMNODE) pCfgHandle;
2976 /** Pointer to device instance data. */
2977 R3PTRTYPE(void *) pvInstanceDataR3;
2978 /** Pointer to device instance data. */
2979 R0PTRTYPE(void *) pvInstanceDataR0;
2980 /** Pointer the GC PDM Device API. */
2981 RCPTRTYPE(PCPDMDEVHLPGC) pDevHlpGC;
2982 /** Pointer to device instance data. */
2983 RCPTRTYPE(void *) pvInstanceDataGC;
2984 /* padding to make achInstanceData aligned at 32 byte boundrary. */
2985 uint32_t au32Padding[HC_ARCH_BITS == 32 ? 1 : 6];
2986 /** Device instance data. The size of this area is defined
2987 * in the PDMDEVREG::cbInstanceData field. */
2988 char achInstanceData[8];
2989} PDMDEVINS;
2990
2991/** Current DEVREG version number. */
2992#define PDM_DEVINS_VERSION 0xf3010000
2993
2994/** Converts a pointer to the PDMDEVINS::IBase to a pointer to PDMDEVINS. */
2995#define PDMIBASE_2_PDMDEV(pInterface) ( (PPDMDEVINS)((char *)(pInterface) - RT_OFFSETOF(PDMDEVINS, IBase)) )
2996
2997
2998/** @def PDMDEV_ASSERT_EMT
2999 * Assert that the current thread is the emulation thread.
3000 */
3001#ifdef VBOX_STRICT
3002# define PDMDEV_ASSERT_EMT(pDevIns) pDevIns->pDevHlp->pfnAssertEMT(pDevIns, __FILE__, __LINE__, __FUNCTION__)
3003#else
3004# define PDMDEV_ASSERT_EMT(pDevIns) do { } while (0)
3005#endif
3006
3007/** @def PDMDEV_ASSERT_OTHER
3008 * Assert that the current thread is NOT the emulation thread.
3009 */
3010#ifdef VBOX_STRICT
3011# define PDMDEV_ASSERT_OTHER(pDevIns) pDevIns->pDevHlp->pfnAssertOther(pDevIns, __FILE__, __LINE__, __FUNCTION__)
3012#else
3013# define PDMDEV_ASSERT_OTHER(pDevIns) do { } while (0)
3014#endif
3015
3016/** @def PDMDEV_ASSERT_VMLOCK_OWNER
3017 * Assert that the current thread is owner of the VM lock.
3018 */
3019#ifdef VBOX_STRICT
3020# define PDMDEV_ASSERT_VMLOCK_OWNER(pDevIns) pDevIns->pDevHlp->pfnAssertVMLock(pDevIns, __FILE__, __LINE__, __FUNCTION__)
3021#else
3022# define PDMDEV_ASSERT_VMLOCK_OWNER(pDevIns) do { } while (0)
3023#endif
3024
3025/** @def PDMDEV_SET_ERROR
3026 * Set the VM error. See PDMDevHlpVMSetError() for printf like message formatting.
3027 */
3028#define PDMDEV_SET_ERROR(pDevIns, rc, pszError) \
3029 PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS, "%s", pszError)
3030
3031/** @def PDMDEV_SET_RUNTIME_ERROR
3032 * Set the VM runtime error. See PDMDevHlpVMSetRuntimeError() for printf like message formatting.
3033 */
3034#define PDMDEV_SET_RUNTIME_ERROR(pDevIns, fFatal, pszErrorID, pszError) \
3035 PDMDevHlpVMSetRuntimeError(pDevIns, fFatal, pszErrorID, "%s", pszError)
3036
3037/** @def PDMDEVINS_2_RCPTR
3038 * Converts a PDM Device instance pointer a RC PDM Device instance pointer.
3039 */
3040#define PDMDEVINS_2_RCPTR(pDevIns) ( (RCPTRTYPE(PPDMDEVINS))((RTGCUINTPTR)(pDevIns)->pvInstanceDataGC - RT_OFFSETOF(PDMDEVINS, achInstanceData)) )
3041
3042/** @def PDMDEVINS_2_R3PTR
3043 * Converts a PDM Device instance pointer a R3 PDM Device instance pointer.
3044 */
3045#define PDMDEVINS_2_R3PTR(pDevIns) ( (R3PTRTYPE(PPDMDEVINS))((RTHCUINTPTR)(pDevIns)->pvInstanceDataR3 - RT_OFFSETOF(PDMDEVINS, achInstanceData)) )
3046
3047/** @def PDMDEVINS_2_R0PTR
3048 * Converts a PDM Device instance pointer a R0 PDM Device instance pointer.
3049 */
3050#define PDMDEVINS_2_R0PTR(pDevIns) ( (R0PTRTYPE(PPDMDEVINS))((RTR0UINTPTR)(pDevIns)->pvInstanceDataR0 - RT_OFFSETOF(PDMDEVINS, achInstanceData)) )
3051
3052
3053/**
3054 * VBOX_STRICT wrapper for pDevHlp->pfnDBGFStopV.
3055 *
3056 * @returns VBox status code which must be passed up to the VMM.
3057 * @param pDevIns Device instance.
3058 * @param RT_SRC_POS_DECL Use RT_SRC_POS.
3059 * @param pszFormat Message. (optional)
3060 * @param ... Message parameters.
3061 */
3062DECLINLINE(int) PDMDeviceDBGFStop(PPDMDEVINS pDevIns, RT_SRC_POS_DECL, const char *pszFormat, ...)
3063{
3064#ifdef VBOX_STRICT
3065# ifdef IN_RING3
3066 int rc;
3067 va_list args;
3068 va_start(args, pszFormat);
3069 rc = pDevIns->pDevHlp->pfnDBGFStopV(pDevIns, RT_SRC_POS_ARGS, pszFormat, args);
3070 va_end(args);
3071 return rc;
3072# else
3073 return VINF_EM_DBG_STOP;
3074# endif
3075#else
3076 return VINF_SUCCESS;
3077#endif
3078}
3079
3080
3081#ifdef IN_RING3
3082/**
3083 * @copydoc PDMDEVHLP::pfnIOPortRegister
3084 */
3085DECLINLINE(int) PDMDevHlpIOPortRegister(PPDMDEVINS pDevIns, RTIOPORT Port, RTUINT cPorts, RTHCPTR pvUser,
3086 PFNIOMIOPORTOUT pfnOut, PFNIOMIOPORTIN pfnIn,
3087 PFNIOMIOPORTOUTSTRING pfnOutStr, PFNIOMIOPORTINSTRING pfnInStr, const char *pszDesc)
3088{
3089 return pDevIns->pDevHlp->pfnIOPortRegister(pDevIns, Port, cPorts, pvUser, pfnOut, pfnIn, pfnOutStr, pfnInStr, pszDesc);
3090}
3091
3092/**
3093 * @copydoc PDMDEVHLP::pfnIOPortRegisterGC
3094 */
3095DECLINLINE(int) PDMDevHlpIOPortRegisterGC(PPDMDEVINS pDevIns, RTIOPORT Port, RTUINT cPorts, RTRCPTR pvUser,
3096 const char *pszOut, const char *pszIn, const char *pszOutStr,
3097 const char *pszInStr, const char *pszDesc)
3098{
3099 return pDevIns->pDevHlp->pfnIOPortRegisterGC(pDevIns, Port, cPorts, pvUser, pszOut, pszIn, pszOutStr, pszInStr, pszDesc);
3100}
3101
3102/**
3103 * @copydoc PDMDEVHLP::pfnIOPortRegisterR0
3104 */
3105DECLINLINE(int) PDMDevHlpIOPortRegisterR0(PPDMDEVINS pDevIns, RTIOPORT Port, RTUINT cPorts, RTR0PTR pvUser,
3106 const char *pszOut, const char *pszIn, const char *pszOutStr,
3107 const char *pszInStr, const char *pszDesc)
3108{
3109 return pDevIns->pDevHlp->pfnIOPortRegisterR0(pDevIns, Port, cPorts, pvUser, pszOut, pszIn, pszOutStr, pszInStr, pszDesc);
3110}
3111
3112/**
3113 * @copydoc PDMDEVHLP::pfnMMIORegister
3114 */
3115DECLINLINE(int) PDMDevHlpMMIORegister(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, RTHCPTR pvUser,
3116 PFNIOMMMIOWRITE pfnWrite, PFNIOMMMIOREAD pfnRead, PFNIOMMMIOFILL pfnFill,
3117 const char *pszDesc)
3118{
3119 return pDevIns->pDevHlp->pfnMMIORegister(pDevIns, IOMMMIOCTX_GLOBAL, GCPhysStart, cbRange, pvUser, pfnWrite, pfnRead, pfnFill, pszDesc);
3120}
3121
3122/**
3123 * @copydoc PDMDEVHLP::pfnMMIORegisterGC
3124 */
3125DECLINLINE(int) PDMDevHlpMMIORegisterGC(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, RTGCPTR pvUser,
3126 const char *pszWrite, const char *pszRead, const char *pszFill)
3127{
3128 return pDevIns->pDevHlp->pfnMMIORegisterGC(pDevIns, IOMMMIOCTX_GLOBAL, GCPhysStart, cbRange, pvUser, pszWrite, pszRead, pszFill, NULL);
3129}
3130
3131/**
3132 * @copydoc PDMDEVHLP::pfnMMIORegisterR0
3133 */
3134DECLINLINE(int) PDMDevHlpMMIORegisterR0(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, RTR0PTR pvUser,
3135 const char *pszWrite, const char *pszRead, const char *pszFill)
3136{
3137 return pDevIns->pDevHlp->pfnMMIORegisterR0(pDevIns, IOMMMIOCTX_GLOBAL, GCPhysStart, cbRange, pvUser, pszWrite, pszRead, pszFill, NULL);
3138}
3139
3140/**
3141 * @copydoc PDMDEVHLP::pfnMMIORegisterPerCPU
3142 */
3143DECLINLINE(int) PDMDevHlpMMIORegisterPerCPU(PPDMDEVINS pDevIns, int idCPU, RTGCPHYS GCPhysStart, RTUINT cbRange, RTHCPTR pvUser,
3144 PFNIOMMMIOWRITE pfnWrite, PFNIOMMMIOREAD pfnRead, PFNIOMMMIOFILL pfnFill,
3145 const char *pszDesc)
3146{
3147 return pDevIns->pDevHlp->pfnMMIORegister(pDevIns, (IOMMMIOCTX)(IOMMMIOCTX_CPU_BASE + idCPU), GCPhysStart, cbRange, pvUser, pfnWrite, pfnRead, pfnFill, pszDesc);
3148}
3149
3150/**
3151 * @copydoc PDMDEVHLP::pfnMMIORegisterPerCPUGC
3152 */
3153DECLINLINE(int) PDMDevHlpMMIORegisterPerCPUGC(PPDMDEVINS pDevIns, int idCPU, RTGCPHYS GCPhysStart, RTUINT cbRange, RTGCPTR pvUser,
3154 const char *pszWrite, const char *pszRead, const char *pszFill)
3155{
3156 return pDevIns->pDevHlp->pfnMMIORegisterGC(pDevIns, (IOMMMIOCTX)(IOMMMIOCTX_CPU_BASE + idCPU), GCPhysStart, cbRange, pvUser, pszWrite, pszRead, pszFill, NULL);
3157}
3158
3159/**
3160 * @copydoc PDMDEVHLP::pfnMMIORegisterPerCPUR0
3161 */
3162DECLINLINE(int) PDMDevHlpMMIORegisterPerCPUR0(PPDMDEVINS pDevIns, int idCPU, RTGCPHYS GCPhysStart, RTUINT cbRange, RTR0PTR pvUser,
3163 const char *pszWrite, const char *pszRead, const char *pszFill)
3164{
3165 return pDevIns->pDevHlp->pfnMMIORegisterR0(pDevIns, (IOMMMIOCTX)(IOMMMIOCTX_CPU_BASE + idCPU), GCPhysStart, cbRange, pvUser, pszWrite, pszRead, pszFill, NULL);
3166}
3167
3168/**
3169 * @copydoc PDMDEVHLP::pfnROMRegister
3170 */
3171DECLINLINE(int) PDMDevHlpROMRegister(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, const void *pvBinary, bool fShadow, const char *pszDesc)
3172{
3173 return pDevIns->pDevHlp->pfnROMRegister(pDevIns, GCPhysStart, cbRange, pvBinary, fShadow, pszDesc);
3174}
3175/**
3176 * @copydoc PDMDEVHLP::pfnROMProtectShadow
3177 */
3178DECLINLINE(int) PDMDevHlpROMProtectShadow(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange)
3179{
3180 return pDevIns->pDevHlp->pfnROMProtectShadow(pDevIns, GCPhysStart, cbRange);
3181}
3182
3183/**
3184 * @copydoc PDMDEVHLP::pfnMMIO2Register
3185 */
3186DECLINLINE(int) PDMDevHlpMMIO2Register(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS cb, uint32_t fFlags, void **ppv, const char *pszDesc)
3187{
3188 return pDevIns->pDevHlp->pfnMMIO2Register(pDevIns, iRegion, cb, fFlags, ppv, pszDesc);
3189}
3190
3191/**
3192 * @copydoc PDMDEVHLP::pfnMMIO2Deregister
3193 */
3194DECLINLINE(int) PDMDevHlpMMIO2Deregister(PPDMDEVINS pDevIns, uint32_t iRegion)
3195{
3196 return pDevIns->pDevHlp->pfnMMIO2Deregister(pDevIns, iRegion);
3197}
3198
3199/**
3200 * @copydoc PDMDEVHLP::pfnMMIO2Map
3201 */
3202DECLINLINE(int) PDMDevHlpMMIO2Map(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS GCPhys)
3203{
3204 return pDevIns->pDevHlp->pfnMMIO2Map(pDevIns, iRegion, GCPhys);
3205}
3206
3207/**
3208 * @copydoc PDMDEVHLP::pfnMMIO2Unmap
3209 */
3210DECLINLINE(int) PDMDevHlpMMIO2Unmap(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS GCPhys)
3211{
3212 return pDevIns->pDevHlp->pfnMMIO2Unmap(pDevIns, iRegion, GCPhys);
3213}
3214
3215/**
3216 * @copydoc PDMDEVHLP::pfnMMHyperMapMMIO2
3217 */
3218DECLINLINE(int) PDMDevHlpMMHyperMapMMIO2(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS off, RTGCPHYS cb,
3219 const char *pszDesc, PRTRCPTR pRCPtr)
3220{
3221 return pDevIns->pDevHlp->pfnMMHyperMapMMIO2(pDevIns, iRegion, off, cb, pszDesc, pRCPtr);
3222}
3223
3224/**
3225 * @copydoc PDMDEVHLP::pfnSSMRegister
3226 */
3227DECLINLINE(int) PDMDevHlpSSMRegister(PPDMDEVINS pDevIns, const char *pszName, uint32_t u32Instance, uint32_t u32Version, size_t cbGuess,
3228 PFNSSMDEVSAVEPREP pfnSavePrep, PFNSSMDEVSAVEEXEC pfnSaveExec, PFNSSMDEVSAVEDONE pfnSaveDone,
3229 PFNSSMDEVLOADPREP pfnLoadPrep, PFNSSMDEVLOADEXEC pfnLoadExec, PFNSSMDEVLOADDONE pfnLoadDone)
3230{
3231 return pDevIns->pDevHlp->pfnSSMRegister(pDevIns, pszName, u32Instance, u32Version, cbGuess,
3232 pfnSavePrep, pfnSaveExec, pfnSaveDone,
3233 pfnLoadPrep, pfnLoadExec, pfnLoadDone);
3234}
3235
3236/**
3237 * @copydoc PDMDEVHLP::pfnTMTimerCreate
3238 */
3239DECLINLINE(int) PDMDevHlpTMTimerCreate(PPDMDEVINS pDevIns, TMCLOCK enmClock, PFNTMTIMERDEV pfnCallback, const char *pszDesc, PPTMTIMERR3 ppTimer)
3240{
3241 return pDevIns->pDevHlp->pfnTMTimerCreate(pDevIns, enmClock, pfnCallback, pszDesc, ppTimer);
3242}
3243
3244/**
3245 * @copydoc PDMDEVHLP::pfnPCIRegister
3246 */
3247DECLINLINE(int) PDMDevHlpPCIRegister(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev)
3248{
3249 return pDevIns->pDevHlp->pfnPCIRegister(pDevIns, pPciDev);
3250}
3251
3252/**
3253 * @copydoc PDMDEVHLP::pfnPCIIORegionRegister
3254 */
3255DECLINLINE(int) PDMDevHlpPCIIORegionRegister(PPDMDEVINS pDevIns, int iRegion, uint32_t cbRegion, PCIADDRESSSPACE enmType, PFNPCIIOREGIONMAP pfnCallback)
3256{
3257 return pDevIns->pDevHlp->pfnPCIIORegionRegister(pDevIns, iRegion, cbRegion, enmType, pfnCallback);
3258}
3259
3260/**
3261 * @copydoc PDMDEVHLP::pfnPCISetConfigCallbacks
3262 */
3263DECLINLINE(void) PDMDevHlpPCISetConfigCallbacks(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, PFNPCICONFIGREAD pfnRead, PPFNPCICONFIGREAD ppfnReadOld,
3264 PFNPCICONFIGWRITE pfnWrite, PPFNPCICONFIGWRITE ppfnWriteOld)
3265{
3266 pDevIns->pDevHlp->pfnPCISetConfigCallbacks(pDevIns, pPciDev, pfnRead, ppfnReadOld, pfnWrite, ppfnWriteOld);
3267}
3268
3269/**
3270 * @copydoc PDMDEVHLP::pfnDriverAttach
3271 */
3272DECLINLINE(int) PDMDevHlpDriverAttach(PPDMDEVINS pDevIns, RTUINT iLun, PPDMIBASE pBaseInterface, PPDMIBASE *ppBaseInterface, const char *pszDesc)
3273{
3274 return pDevIns->pDevHlp->pfnDriverAttach(pDevIns, iLun, pBaseInterface, ppBaseInterface, pszDesc);
3275}
3276
3277/**
3278 * @copydoc PDMDEVHLP::pfnMMHeapAlloc
3279 */
3280DECLINLINE(void *) PDMDevHlpMMHeapAlloc(PPDMDEVINS pDevIns, size_t cb)
3281{
3282 return pDevIns->pDevHlp->pfnMMHeapAlloc(pDevIns, cb);
3283}
3284
3285/**
3286 * @copydoc PDMDEVHLP::pfnMMHeapAllocZ
3287 */
3288DECLINLINE(void *) PDMDevHlpMMHeapAllocZ(PPDMDEVINS pDevIns, size_t cb)
3289{
3290 return pDevIns->pDevHlp->pfnMMHeapAllocZ(pDevIns, cb);
3291}
3292
3293/**
3294 * @copydoc PDMDEVHLP::pfnMMHeapFree
3295 */
3296DECLINLINE(void) PDMDevHlpMMHeapFree(PPDMDEVINS pDevIns, void *pv)
3297{
3298 pDevIns->pDevHlp->pfnMMHeapFree(pDevIns, pv);
3299}
3300
3301/**
3302 * @copydoc PDMDEVHLP::pfnDBGFInfoRegister
3303 */
3304DECLINLINE(int) PDMDevHlpDBGFInfoRegister(PPDMDEVINS pDevIns, const char *pszName, const char *pszDesc, PFNDBGFHANDLERDEV pfnHandler)
3305{
3306 return pDevIns->pDevHlp->pfnDBGFInfoRegister(pDevIns, pszName, pszDesc, pfnHandler);
3307}
3308
3309/**
3310 * @copydoc PDMDEVHLP::pfnSTAMRegister
3311 */
3312DECLINLINE(void) PDMDevHlpSTAMRegister(PPDMDEVINS pDevIns, void *pvSample, STAMTYPE enmType, const char *pszName, STAMUNIT enmUnit, const char *pszDesc)
3313{
3314 pDevIns->pDevHlp->pfnSTAMRegister(pDevIns, pvSample, enmType, pszName, enmUnit, pszDesc);
3315}
3316
3317/**
3318 * @copydoc PDMDEVHLP::pfnSTAMRegisterF
3319 */
3320DECLINLINE(void) PDMDevHlpSTAMRegisterF(PPDMDEVINS pDevIns, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility, STAMUNIT enmUnit,
3321 const char *pszDesc, const char *pszName, ...)
3322{
3323 va_list va;
3324 va_start(va, pszName);
3325 pDevIns->pDevHlp->pfnSTAMRegisterV(pDevIns, pvSample, enmType, enmVisibility, enmUnit, pszDesc, pszName, va);
3326 va_end(va);
3327}
3328
3329/**
3330 * @copydoc PDMDEVHLP::pfnPDMQueueCreate
3331 */
3332DECLINLINE(int) PDMDevHlpPDMQueueCreate(PPDMDEVINS pDevIns, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval,
3333 PFNPDMQUEUEDEV pfnCallback, bool fGCEnabled, PPDMQUEUE *ppQueue)
3334{
3335 return pDevIns->pDevHlp->pfnPDMQueueCreate(pDevIns, cbItem, cItems, cMilliesInterval, pfnCallback, fGCEnabled, ppQueue);
3336}
3337
3338/**
3339 * @copydoc PDMDEVHLP::pfnCritSectInit
3340 */
3341DECLINLINE(int) PDMDevHlpCritSectInit(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, const char *pszName)
3342{
3343 return pDevIns->pDevHlp->pfnCritSectInit(pDevIns, pCritSect, pszName);
3344}
3345
3346/**
3347 * @copydoc PDMDEVHLP::pfnUTCNow
3348 */
3349DECLINLINE(PRTTIMESPEC) PDMDevHlpUTCNow(PPDMDEVINS pDevIns, PRTTIMESPEC pTime)
3350{
3351 return pDevIns->pDevHlp->pfnUTCNow(pDevIns, pTime);
3352}
3353
3354/**
3355 * @copydoc PDMDEVHLP::pfnGetVM
3356 */
3357DECLINLINE(PVM) PDMDevHlpGetVM(PPDMDEVINS pDevIns)
3358{
3359 return pDevIns->pDevHlp->pfnGetVM(pDevIns);
3360}
3361
3362/**
3363 * @copydoc PDMDEVHLP::pfnPhysReadGCVirt
3364 */
3365DECLINLINE(int) PDMDevHlpPhysReadGCVirt(PPDMDEVINS pDevIns, void *pvDst, RTGCPTR GCVirtSrc, size_t cb)
3366{
3367 return pDevIns->pDevHlp->pfnPhysReadGCVirt(pDevIns, pvDst, GCVirtSrc, cb);
3368}
3369
3370/**
3371 * @copydoc PDMDEVHLP::pfnPhysWriteGCVirt
3372 */
3373DECLINLINE(int) PDMDevHlpPhysWriteGCVirt(PPDMDEVINS pDevIns, RTGCPTR GCVirtDst, const void *pvSrc, size_t cb)
3374{
3375 return pDevIns->pDevHlp->pfnPhysWriteGCVirt(pDevIns, GCVirtDst, pvSrc, cb);
3376}
3377
3378/**
3379 * @copydoc PDMDEVHLP::pfnPhysReserve
3380 */
3381DECLINLINE(int) PDMDevHlpPhysReserve(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTUINT cbRange, const char *pszDesc)
3382{
3383 return pDevIns->pDevHlp->pfnPhysReserve(pDevIns, GCPhys, cbRange, pszDesc);
3384}
3385
3386/**
3387 * @copydoc PDMDEVHLP::pfnPhysGCPtr2GCPhys
3388 */
3389DECLINLINE(int) PDMDevHlpPhysGCPtr2GCPhys(PPDMDEVINS pDevIns, RTGCPTR GCPtr, PRTGCPHYS pGCPhys)
3390{
3391 return pDevIns->pDevHlp->pfnPhysGCPtr2GCPhys(pDevIns, GCPtr, pGCPhys);
3392}
3393
3394/**
3395 * @copydoc PDMDEVHLP::pfnVMState
3396 */
3397DECLINLINE(VMSTATE) PDMDevHlpVMState(PPDMDEVINS pDevIns)
3398{
3399 return pDevIns->pDevHlp->pfnVMState(pDevIns);
3400}
3401
3402/**
3403 * @copydoc PDMDEVHLP::pfnA20Set
3404 */
3405DECLINLINE(void) PDMDevHlpA20Set(PPDMDEVINS pDevIns, bool fEnable)
3406{
3407 pDevIns->pDevHlp->pfnA20Set(pDevIns, fEnable);
3408}
3409
3410/**
3411 * @copydoc PDMDEVHLP::pfnVMReset
3412 */
3413DECLINLINE(int) PDMDevHlpVMReset(PPDMDEVINS pDevIns)
3414{
3415 return pDevIns->pDevHlp->pfnVMReset(pDevIns);
3416}
3417
3418/**
3419 * @copydoc PDMDEVHLP::pfnVMSuspend
3420 */
3421DECLINLINE(int) PDMDevHlpVMSuspend(PPDMDEVINS pDevIns)
3422{
3423 return pDevIns->pDevHlp->pfnVMSuspend(pDevIns);
3424}
3425
3426/**
3427 * @copydoc PDMDEVHLP::pfnVMPowerOff
3428 */
3429DECLINLINE(int) PDMDevHlpVMPowerOff(PPDMDEVINS pDevIns)
3430{
3431 return pDevIns->pDevHlp->pfnVMPowerOff(pDevIns);
3432}
3433
3434/**
3435 * @copydoc PDMDEVHLP::pfnDMARegister
3436 */
3437DECLINLINE(int) PDMDevHlpDMARegister(PPDMDEVINS pDevIns, unsigned uChannel, PFNDMATRANSFERHANDLER pfnTransferHandler, void *pvUser)
3438{
3439 return pDevIns->pDevHlp->pfnDMARegister(pDevIns, uChannel, pfnTransferHandler, pvUser);
3440}
3441
3442/**
3443 * @copydoc PDMDEVHLP::pfnDMAReadMemory
3444 */
3445DECLINLINE(int) PDMDevHlpDMAReadMemory(PPDMDEVINS pDevIns, unsigned uChannel, void *pvBuffer, uint32_t off, uint32_t cbBlock, uint32_t *pcbRead)
3446{
3447 return pDevIns->pDevHlp->pfnDMAReadMemory(pDevIns, uChannel, pvBuffer, off, cbBlock, pcbRead);
3448}
3449
3450/**
3451 * @copydoc PDMDEVHLP::pfnDMAWriteMemory
3452 */
3453DECLINLINE(int) PDMDevHlpDMAWriteMemory(PPDMDEVINS pDevIns, unsigned uChannel, const void *pvBuffer, uint32_t off, uint32_t cbBlock, uint32_t *pcbWritten)
3454{
3455 return pDevIns->pDevHlp->pfnDMAWriteMemory(pDevIns, uChannel, pvBuffer, off, cbBlock, pcbWritten);
3456}
3457
3458/**
3459 * @copydoc PDMDEVHLP::pfnDMASetDREQ
3460 */
3461DECLINLINE(int) PDMDevHlpDMASetDREQ(PPDMDEVINS pDevIns, unsigned uChannel, unsigned uLevel)
3462{
3463 return pDevIns->pDevHlp->pfnDMASetDREQ(pDevIns, uChannel, uLevel);
3464}
3465
3466/**
3467 * @copydoc PDMDEVHLP::pfnDMAGetChannelMode
3468 */
3469DECLINLINE(uint8_t) PDMDevHlpDMAGetChannelMode(PPDMDEVINS pDevIns, unsigned uChannel)
3470{
3471 return pDevIns->pDevHlp->pfnDMAGetChannelMode(pDevIns, uChannel);
3472}
3473
3474/**
3475 * @copydoc PDMDEVHLP::pfnDMASchedule
3476 */
3477DECLINLINE(void) PDMDevHlpDMASchedule(PPDMDEVINS pDevIns)
3478{
3479 pDevIns->pDevHlp->pfnDMASchedule(pDevIns);
3480}
3481
3482/**
3483 * @copydoc PDMDEVHLP::pfnCMOSWrite
3484 */
3485DECLINLINE(int) PDMDevHlpCMOSWrite(PPDMDEVINS pDevIns, unsigned iReg, uint8_t u8Value)
3486{
3487 return pDevIns->pDevHlp->pfnCMOSWrite(pDevIns, iReg, u8Value);
3488}
3489
3490/**
3491 * @copydoc PDMDEVHLP::pfnCMOSRead
3492 */
3493DECLINLINE(int) PDMDevHlpCMOSRead(PPDMDEVINS pDevIns, unsigned iReg, uint8_t *pu8Value)
3494{
3495 return pDevIns->pDevHlp->pfnCMOSRead(pDevIns, iReg, pu8Value);
3496}
3497
3498/**
3499 * @copydoc PDMDEVHLP::pfnGetCpuId
3500 */
3501DECLINLINE(void) PDMDevHlpGetCpuId(PPDMDEVINS pDevIns, uint32_t iLeaf, uint32_t *pEax, uint32_t *pEbx, uint32_t *pEcx, uint32_t *pEdx)
3502{
3503 pDevIns->pDevHlp->pfnGetCpuId(pDevIns, iLeaf, pEax, pEbx, pEcx, pEdx);
3504}
3505
3506/**
3507 * @copydoc PDMDEVHLP::pfnPDMThreadCreate
3508 */
3509DECLINLINE(int) PDMDevHlpPDMThreadCreate(PPDMDEVINS pDevIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADDEV pfnThread,
3510 PFNPDMTHREADWAKEUPDEV pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName)
3511{
3512 return pDevIns->pDevHlp->pfnPDMThreadCreate(pDevIns, ppThread, pvUser, pfnThread, pfnWakeup, cbStack, enmType, pszName);
3513}
3514#endif /* IN_RING3 */
3515
3516
3517/**
3518 * @copydoc PDMDEVHLP::pfnPCISetIrq
3519 */
3520DECLINLINE(void) PDMDevHlpPCISetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel)
3521{
3522#ifdef IN_GC
3523 pDevIns->pDevHlpGC->pfnPCISetIrq(pDevIns, iIrq, iLevel);
3524#elif defined(IN_RING0)
3525 pDevIns->pDevHlpR0->pfnPCISetIrq(pDevIns, iIrq, iLevel);
3526#else
3527 pDevIns->pDevHlp->pfnPCISetIrq(pDevIns, iIrq, iLevel);
3528#endif
3529}
3530
3531/**
3532 * @copydoc PDMDEVHLP::pfnPCISetIrqNoWait
3533 */
3534DECLINLINE(void) PDMDevHlpPCISetIrqNoWait(PPDMDEVINS pDevIns, int iIrq, int iLevel)
3535{
3536#ifdef IN_GC
3537 pDevIns->pDevHlpGC->pfnPCISetIrq(pDevIns, iIrq, iLevel);
3538#elif defined(IN_RING0)
3539 pDevIns->pDevHlpR0->pfnPCISetIrq(pDevIns, iIrq, iLevel);
3540#else
3541 pDevIns->pDevHlp->pfnPCISetIrqNoWait(pDevIns, iIrq, iLevel);
3542#endif
3543}
3544
3545/**
3546 * @copydoc PDMDEVHLP::pfnISASetIrq
3547 */
3548DECLINLINE(void) PDMDevHlpISASetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel)
3549{
3550#ifdef IN_GC
3551 pDevIns->pDevHlpGC->pfnISASetIrq(pDevIns, iIrq, iLevel);
3552#elif defined(IN_RING0)
3553 pDevIns->pDevHlpR0->pfnISASetIrq(pDevIns, iIrq, iLevel);
3554#else
3555 pDevIns->pDevHlp->pfnISASetIrq(pDevIns, iIrq, iLevel);
3556#endif
3557}
3558
3559/**
3560 * @copydoc PDMDEVHLP::pfnISASetIrqNoWait
3561 */
3562DECLINLINE(void) PDMDevHlpISASetIrqNoWait(PPDMDEVINS pDevIns, int iIrq, int iLevel)
3563{
3564#ifdef IN_GC
3565 pDevIns->pDevHlpGC->pfnISASetIrq(pDevIns, iIrq, iLevel);
3566#elif defined(IN_RING0)
3567 pDevIns->pDevHlpR0->pfnISASetIrq(pDevIns, iIrq, iLevel);
3568#else
3569 pDevIns->pDevHlp->pfnISASetIrqNoWait(pDevIns, iIrq, iLevel);
3570#endif
3571}
3572
3573/**
3574 * @copydoc PDMDEVHLP::pfnPhysRead
3575 */
3576DECLINLINE(void) PDMDevHlpPhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)
3577{
3578#ifdef IN_GC
3579 pDevIns->pDevHlpGC->pfnPhysRead(pDevIns, GCPhys, pvBuf, cbRead);
3580#elif defined(IN_RING0)
3581 pDevIns->pDevHlpR0->pfnPhysRead(pDevIns, GCPhys, pvBuf, cbRead);
3582#else
3583 pDevIns->pDevHlp->pfnPhysRead(pDevIns, GCPhys, pvBuf, cbRead);
3584#endif
3585}
3586
3587/**
3588 * @copydoc PDMDEVHLP::pfnPhysWrite
3589 */
3590DECLINLINE(void) PDMDevHlpPhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)
3591{
3592#ifdef IN_GC
3593 pDevIns->pDevHlpGC->pfnPhysWrite(pDevIns, GCPhys, pvBuf, cbWrite);
3594#elif defined(IN_RING0)
3595 pDevIns->pDevHlpR0->pfnPhysWrite(pDevIns, GCPhys, pvBuf, cbWrite);
3596#else
3597 pDevIns->pDevHlp->pfnPhysWrite(pDevIns, GCPhys, pvBuf, cbWrite);
3598#endif
3599}
3600
3601/**
3602 * @copydoc PDMDEVHLP::pfnA20IsEnabled
3603 */
3604DECLINLINE(bool) PDMDevHlpA20IsEnabled(PPDMDEVINS pDevIns)
3605{
3606#ifdef IN_GC
3607 return pDevIns->pDevHlpGC->pfnA20IsEnabled(pDevIns);
3608#elif defined(IN_RING0)
3609 return pDevIns->pDevHlpR0->pfnA20IsEnabled(pDevIns);
3610#else
3611 return pDevIns->pDevHlp->pfnA20IsEnabled(pDevIns);
3612#endif
3613}
3614
3615/**
3616 * @copydoc PDMDEVHLP::pfnVMSetError
3617 */
3618DECLINLINE(int) PDMDevHlpVMSetError(PPDMDEVINS pDevIns, const int rc, RT_SRC_POS_DECL, const char *pszFormat, ...)
3619{
3620 va_list va;
3621 va_start(va, pszFormat);
3622#ifdef IN_GC
3623 pDevIns->pDevHlpGC->pfnVMSetErrorV(pDevIns, rc, RT_SRC_POS_ARGS, pszFormat, va);
3624#elif defined(IN_RING0)
3625 pDevIns->pDevHlpR0->pfnVMSetErrorV(pDevIns, rc, RT_SRC_POS_ARGS, pszFormat, va);
3626#else
3627 pDevIns->pDevHlp->pfnVMSetErrorV(pDevIns, rc, RT_SRC_POS_ARGS, pszFormat, va);
3628#endif
3629 va_end(va);
3630 return rc;
3631}
3632
3633/**
3634 * @copydoc PDMDEVHLP::pfnVMSetRuntimeError
3635 */
3636DECLINLINE(int) PDMDevHlpVMSetRuntimeError(PPDMDEVINS pDevIns, bool fFatal, const char *pszErrorID, const char *pszFormat, ...)
3637{
3638 va_list va;
3639 int rc;
3640 va_start(va, pszFormat);
3641#ifdef IN_GC
3642 rc = pDevIns->pDevHlpGC->pfnVMSetRuntimeErrorV(pDevIns, fFatal, pszErrorID, pszFormat, va);
3643#elif defined(IN_RING0)
3644 rc = pDevIns->pDevHlpR0->pfnVMSetRuntimeErrorV(pDevIns, fFatal, pszErrorID, pszFormat, va);
3645#else
3646 rc = pDevIns->pDevHlp->pfnVMSetRuntimeErrorV(pDevIns, fFatal, pszErrorID, pszFormat, va);
3647#endif
3648 va_end(va);
3649 return rc;
3650}
3651
3652
3653
3654/** Pointer to callbacks provided to the VBoxDeviceRegister() call. */
3655typedef struct PDMDEVREGCB *PPDMDEVREGCB;
3656
3657/**
3658 * Callbacks for VBoxDeviceRegister().
3659 */
3660typedef struct PDMDEVREGCB
3661{
3662 /** Interface version.
3663 * This is set to PDM_DEVREG_CB_VERSION. */
3664 uint32_t u32Version;
3665
3666 /**
3667 * Registers a device with the current VM instance.
3668 *
3669 * @returns VBox status code.
3670 * @param pCallbacks Pointer to the callback table.
3671 * @param pDevReg Pointer to the device registration record.
3672 * This data must be permanent and readonly.
3673 */
3674 DECLR3CALLBACKMEMBER(int, pfnRegister,(PPDMDEVREGCB pCallbacks, PCPDMDEVREG pDevReg));
3675
3676 /**
3677 * Allocate memory which is associated with current VM instance
3678 * and automatically freed on it's destruction.
3679 *
3680 * @returns Pointer to allocated memory. The memory is *NOT* zero-ed.
3681 * @param pCallbacks Pointer to the callback table.
3682 * @param cb Number of bytes to allocate.
3683 */
3684 DECLR3CALLBACKMEMBER(void *, pfnMMHeapAlloc,(PPDMDEVREGCB pCallbacks, size_t cb));
3685} PDMDEVREGCB;
3686
3687/** Current version of the PDMDEVREGCB structure. */
3688#define PDM_DEVREG_CB_VERSION 0xf4010000
3689
3690
3691/**
3692 * The VBoxDevicesRegister callback function.
3693 *
3694 * PDM will invoke this function after loading a device module and letting
3695 * the module decide which devices to register and how to handle conflicts.
3696 *
3697 * @returns VBox status code.
3698 * @param pCallbacks Pointer to the callback table.
3699 * @param u32Version VBox version number.
3700 */
3701typedef DECLCALLBACK(int) FNPDMVBOXDEVICESREGISTER(PPDMDEVREGCB pCallbacks, uint32_t u32Version);
3702
3703/** @} */
3704
3705__END_DECLS
3706
3707#endif
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