VirtualBox

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

Last change on this file since 26158 was 26158, checked in by vboxsync, 15 years ago

TMR3UTCNow -> TMR3UtcNow + DevHlp.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 161.7 KB
Line 
1/** @file
2 * PDM - Pluggable Device Manager, Devices. (VMM)
3 */
4
5/*
6 * Copyright (C) 2006-2010 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/pdmcommon.h>
39#include <VBox/iom.h>
40#include <VBox/tm.h>
41#include <VBox/ssm.h>
42#include <VBox/cfgm.h>
43#include <VBox/dbgf.h>
44#include <VBox/err.h>
45#include <VBox/pci.h>
46#include <iprt/stdarg.h>
47
48RT_C_DECLS_BEGIN
49
50/** @defgroup grp_pdm_device The PDM Devices API
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 * This is called when the instance data has been relocated in raw-mode context
89 * (RC). It is also called when the RC hypervisor selects changes. The device
90 * must fixup all necessary pointers and re-query all interfaces to other RC
91 * devices and drivers.
92 *
93 * Before the RC code is executed the first time, this function will be called
94 * with a 0 delta so RC 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 * Device I/O Control interface.
107 *
108 * This is used by external components, such as the COM interface, to
109 * communicate with devices using a class wide interface or a device
110 * specific interface.
111 *
112 * @returns VBox status code.
113 * @param pDevIns Pointer to the device instance.
114 * @param uFunction Function to perform.
115 * @param pvIn Pointer to input data.
116 * @param cbIn Size of input data.
117 * @param pvOut Pointer to output data.
118 * @param cbOut Size of output data.
119 * @param pcbOut Where to store the actual size of the output data.
120 */
121typedef DECLCALLBACK(int) FNPDMDEVIOCTL(PPDMDEVINS pDevIns, RTUINT uFunction,
122 void *pvIn, RTUINT cbIn,
123 void *pvOut, RTUINT cbOut, PRTUINT pcbOut);
124/** Pointer to a FNPDMDEVIOCTL() function. */
125typedef FNPDMDEVIOCTL *PFNPDMDEVIOCTL;
126
127/**
128 * Power On notification.
129 *
130 * @returns VBox status.
131 * @param pDevIns The device instance data.
132 */
133typedef DECLCALLBACK(void) FNPDMDEVPOWERON(PPDMDEVINS pDevIns);
134/** Pointer to a FNPDMDEVPOWERON() function. */
135typedef FNPDMDEVPOWERON *PFNPDMDEVPOWERON;
136
137/**
138 * Reset notification.
139 *
140 * @returns VBox status.
141 * @param pDevIns The device instance data.
142 */
143typedef DECLCALLBACK(void) FNPDMDEVRESET(PPDMDEVINS pDevIns);
144/** Pointer to a FNPDMDEVRESET() function. */
145typedef FNPDMDEVRESET *PFNPDMDEVRESET;
146
147/**
148 * Suspend notification.
149 *
150 * @returns VBox status.
151 * @param pDevIns The device instance data.
152 * @thread EMT(0)
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 * @thread EMT(0)
173 */
174typedef DECLCALLBACK(void) FNPDMDEVPOWEROFF(PPDMDEVINS pDevIns);
175/** Pointer to a FNPDMDEVPOWEROFF() function. */
176typedef FNPDMDEVPOWEROFF *PFNPDMDEVPOWEROFF;
177
178/**
179 * Attach command.
180 *
181 * This is called to let the device attach to a driver for a specified LUN
182 * at runtime. This is not called during VM construction, the device
183 * constructor have to attach to all the available drivers.
184 *
185 * This is like plugging in the keyboard or mouse after turning on the PC.
186 *
187 * @returns VBox status code.
188 * @param pDevIns The device instance.
189 * @param iLUN The logical unit which is being detached.
190 * @param fFlags Flags, combination of the PDM_TACH_FLAGS_* \#defines.
191 */
192typedef DECLCALLBACK(int) FNPDMDEVATTACH(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags);
193/** Pointer to a FNPDMDEVATTACH() function. */
194typedef FNPDMDEVATTACH *PFNPDMDEVATTACH;
195
196/**
197 * Detach notification.
198 *
199 * This is called when a driver is detaching itself from a LUN of the device.
200 * The device should adjust it's state to reflect this.
201 *
202 * This is like unplugging the network cable to use it for the laptop or
203 * something while the PC is still running.
204 *
205 * @param pDevIns The device instance.
206 * @param iLUN The logical unit which is being detached.
207 * @param fFlags Flags, combination of the PDMDEVATT_FLAGS_* \#defines.
208 */
209typedef DECLCALLBACK(void) FNPDMDEVDETACH(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags);
210/** Pointer to a FNPDMDEVDETACH() function. */
211typedef FNPDMDEVDETACH *PFNPDMDEVDETACH;
212
213/**
214 * Query the base interface of a logical unit.
215 *
216 * @returns VBOX status code.
217 * @param pDevIns The device instance.
218 * @param iLUN The logicial unit to query.
219 * @param ppBase Where to store the pointer to the base interface of the LUN.
220 */
221typedef DECLCALLBACK(int) FNPDMDEVQUERYINTERFACE(PPDMDEVINS pDevIns, unsigned iLUN, PPDMIBASE *ppBase);
222/** Pointer to a FNPDMDEVQUERYINTERFACE() function. */
223typedef FNPDMDEVQUERYINTERFACE *PFNPDMDEVQUERYINTERFACE;
224
225/**
226 * Init complete notification.
227 * This can be done to do communication with other devices and other
228 * initialization which requires everything to be in place.
229 *
230 * @returns VBOX status code.
231 * @param pDevIns The device instance.
232 */
233typedef DECLCALLBACK(int) FNPDMDEVINITCOMPLETE(PPDMDEVINS pDevIns);
234/** Pointer to a FNPDMDEVINITCOMPLETE() function. */
235typedef FNPDMDEVINITCOMPLETE *PFNPDMDEVINITCOMPLETE;
236
237
238
239/**
240 * PDM Device Registration Structure.
241 *
242 * This structure is used when registering a device from VBoxInitDevices() in HC
243 * Ring-3. PDM will continue use till the VM is terminated.
244 */
245typedef struct PDMDEVREG
246{
247 /** Structure version. PDM_DEVREG_VERSION defines the current version. */
248 uint32_t u32Version;
249 /** Device name. */
250 char szDeviceName[32];
251 /** Name of the raw-mode context module (no path).
252 * Only evalutated if PDM_DEVREG_FLAGS_RC is set. */
253 char szRCMod[32];
254 /** Name of the ring-0 module (no path).
255 * Only evalutated if PDM_DEVREG_FLAGS_R0 is set. */
256 char szR0Mod[32];
257 /** The description of the device. The UTF-8 string pointed to shall, like this structure,
258 * remain unchanged from registration till VM destruction. */
259 const char *pszDescription;
260
261 /** Flags, combination of the PDM_DEVREG_FLAGS_* \#defines. */
262 uint32_t fFlags;
263 /** Device class(es), combination of the PDM_DEVREG_CLASS_* \#defines. */
264 uint32_t fClass;
265 /** Maximum number of instances (per VM). */
266 uint32_t cMaxInstances;
267 /** Size of the instance data. */
268 uint32_t cbInstance;
269
270 /** Construct instance - required. */
271 PFNPDMDEVCONSTRUCT pfnConstruct;
272 /** Destruct instance - optional. */
273 PFNPDMDEVDESTRUCT pfnDestruct;
274 /** Relocation command - optional. */
275 PFNPDMDEVRELOCATE pfnRelocate;
276 /** I/O Control interface - optional. */
277 PFNPDMDEVIOCTL pfnIOCtl;
278 /** Power on notification - optional. */
279 PFNPDMDEVPOWERON pfnPowerOn;
280 /** Reset notification - optional. */
281 PFNPDMDEVRESET pfnReset;
282 /** Suspend notification - optional. */
283 PFNPDMDEVSUSPEND pfnSuspend;
284 /** Resume notification - optional. */
285 PFNPDMDEVRESUME pfnResume;
286 /** Attach command - optional. */
287 PFNPDMDEVATTACH pfnAttach;
288 /** Detach notification - optional. */
289 PFNPDMDEVDETACH pfnDetach;
290 /** Query a LUN base interface - optional. */
291 PFNPDMDEVQUERYINTERFACE pfnQueryInterface;
292 /** Init complete notification - optional. */
293 PFNPDMDEVINITCOMPLETE pfnInitComplete;
294 /** Power off notification - optional. */
295 PFNPDMDEVPOWEROFF pfnPowerOff;
296 /** @todo */
297 PFNRT pfnSoftReset;
298 /** Initialization safty marker. */
299 uint32_t u32VersionEnd;
300} PDMDEVREG;
301/** Pointer to a PDM Device Structure. */
302typedef PDMDEVREG *PPDMDEVREG;
303/** Const pointer to a PDM Device Structure. */
304typedef PDMDEVREG const *PCPDMDEVREG;
305
306/** Current DEVREG version number. */
307#define PDM_DEVREG_VERSION PDM_VERSION_MAKE(0xffff, 1, 0)
308
309/** PDM Device Flags.
310 * @{ */
311/** This flag is used to indicate that the device has a RC component. */
312#define PDM_DEVREG_FLAGS_RC 0x00000001
313/** This flag is used to indicate that the device has a R0 component. */
314#define PDM_DEVREG_FLAGS_R0 0x00000002
315
316/** @def PDM_DEVREG_FLAGS_HOST_BITS_DEFAULT
317 * The bit count for the current host. */
318#if HC_ARCH_BITS == 32
319# define PDM_DEVREG_FLAGS_HOST_BITS_DEFAULT 0x00000010
320#elif HC_ARCH_BITS == 64
321# define PDM_DEVREG_FLAGS_HOST_BITS_DEFAULT 0x00000020
322#else
323# error Unsupported HC_ARCH_BITS value.
324#endif
325/** The host bit count mask. */
326#define PDM_DEVREG_FLAGS_HOST_BITS_MASK 0x00000030
327
328/** The device support only 32-bit guests. */
329#define PDM_DEVREG_FLAGS_GUEST_BITS_32 0x00000100
330/** The device support only 64-bit guests. */
331#define PDM_DEVREG_FLAGS_GUEST_BITS_64 0x00000200
332/** The device support both 32-bit & 64-bit guests. */
333#define PDM_DEVREG_FLAGS_GUEST_BITS_32_64 0x00000300
334/** @def PDM_DEVREG_FLAGS_GUEST_BITS_DEFAULT
335 * The guest bit count for the current compilation. */
336#if GC_ARCH_BITS == 32
337# define PDM_DEVREG_FLAGS_GUEST_BITS_DEFAULT PDM_DEVREG_FLAGS_GUEST_BITS_32
338#elif GC_ARCH_BITS == 64
339# define PDM_DEVREG_FLAGS_GUEST_BITS_DEFAULT PDM_DEVREG_FLAGS_GUEST_BITS_32_64
340#else
341# error Unsupported GC_ARCH_BITS value.
342#endif
343/** The guest bit count mask. */
344#define PDM_DEVREG_FLAGS_GUEST_BITS_MASK 0x00000300
345
346/** A convenience. */
347#define PDM_DEVREG_FLAGS_DEFAULT_BITS (PDM_DEVREG_FLAGS_GUEST_BITS_DEFAULT | PDM_DEVREG_FLAGS_HOST_BITS_DEFAULT)
348
349/** Indicates that the devices support PAE36 on a 32-bit guest. */
350#define PDM_DEVREG_FLAGS_PAE36 0x00001000
351
352/** Indicates that the device needs to be notified before the drivers when suspending. */
353#define PDM_DEVREG_FLAGS_FIRST_SUSPEND_NOTIFICATION 0x00002000
354
355/** Indicates that the device needs to be notified before the drivers when powering off. */
356#define PDM_DEVREG_FLAGS_FIRST_POWEROFF_NOTIFICATION 0x00004000
357/** @} */
358
359
360/** PDM Device Classes.
361 * The order is important, lower bit earlier instantiation.
362 * @{ */
363/** Architecture device. */
364#define PDM_DEVREG_CLASS_ARCH RT_BIT(0)
365/** Architecture BIOS device. */
366#define PDM_DEVREG_CLASS_ARCH_BIOS RT_BIT(1)
367/** PCI bus brigde. */
368#define PDM_DEVREG_CLASS_BUS_PCI RT_BIT(2)
369/** ISA bus brigde. */
370#define PDM_DEVREG_CLASS_BUS_ISA RT_BIT(3)
371/** Input device (mouse, keyboard, joystick, HID, ...). */
372#define PDM_DEVREG_CLASS_INPUT RT_BIT(4)
373/** Interrupt controller (PIC). */
374#define PDM_DEVREG_CLASS_PIC RT_BIT(5)
375/** Interval controoler (PIT). */
376#define PDM_DEVREG_CLASS_PIT RT_BIT(6)
377/** RTC/CMOS. */
378#define PDM_DEVREG_CLASS_RTC RT_BIT(7)
379/** DMA controller. */
380#define PDM_DEVREG_CLASS_DMA RT_BIT(8)
381/** VMM Device. */
382#define PDM_DEVREG_CLASS_VMM_DEV RT_BIT(9)
383/** Graphics device, like VGA. */
384#define PDM_DEVREG_CLASS_GRAPHICS RT_BIT(10)
385/** Storage controller device. */
386#define PDM_DEVREG_CLASS_STORAGE RT_BIT(11)
387/** Network interface controller. */
388#define PDM_DEVREG_CLASS_NETWORK RT_BIT(12)
389/** Audio. */
390#define PDM_DEVREG_CLASS_AUDIO RT_BIT(13)
391/** USB HIC. */
392#define PDM_DEVREG_CLASS_BUS_USB RT_BIT(14)
393/** ACPI. */
394#define PDM_DEVREG_CLASS_ACPI RT_BIT(15)
395/** Serial controller device. */
396#define PDM_DEVREG_CLASS_SERIAL RT_BIT(16)
397/** Parallel controller device */
398#define PDM_DEVREG_CLASS_PARALLEL RT_BIT(17)
399/** Misc devices (always last). */
400#define PDM_DEVREG_CLASS_MISC RT_BIT(31)
401/** @} */
402
403
404/** @name IRQ Level for use with the *SetIrq APIs.
405 * @{
406 */
407/** Assert the IRQ (can assume value 1). */
408#define PDM_IRQ_LEVEL_HIGH RT_BIT(0)
409/** Deassert the IRQ (can assume value 0). */
410#define PDM_IRQ_LEVEL_LOW 0
411/** flip-flop - assert and then deassert it again immediately. */
412#define PDM_IRQ_LEVEL_FLIP_FLOP (RT_BIT(1) | PDM_IRQ_LEVEL_HIGH)
413/** @} */
414
415
416/**
417 * PCI Bus registration structure.
418 * All the callbacks, except the PCIBIOS hack, are working on PCI devices.
419 */
420typedef struct PDMPCIBUSREG
421{
422 /** Structure version number. PDM_PCIBUSREG_VERSION defines the current version. */
423 uint32_t u32Version;
424
425 /**
426 * Registers the device with the default PCI bus.
427 *
428 * @returns VBox status code.
429 * @param pDevIns Device instance of the PCI Bus.
430 * @param pPciDev The PCI device structure.
431 * Any PCI enabled device must keep this in it's instance data!
432 * Fill in the PCI data config before registration, please.
433 * @param pszName Pointer to device name (permanent, readonly). For debugging, not unique.
434 * @param iDev The device number ((dev << 3) | function) the device should have on the bus.
435 * If negative, the pci bus device will assign one.
436 */
437 DECLR3CALLBACKMEMBER(int, pfnRegisterR3,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, const char *pszName, int iDev));
438
439 /**
440 * Registers a I/O region (memory mapped or I/O ports) for a PCI device.
441 *
442 * @returns VBox status code.
443 * @param pDevIns Device instance of the PCI Bus.
444 * @param pPciDev The PCI device structure.
445 * @param iRegion The region number.
446 * @param cbRegion Size of the region.
447 * @param iType PCI_ADDRESS_SPACE_MEM, PCI_ADDRESS_SPACE_IO or PCI_ADDRESS_SPACE_MEM_PREFETCH.
448 * @param pfnCallback Callback for doing the mapping.
449 */
450 DECLR3CALLBACKMEMBER(int, pfnIORegionRegisterR3,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, int iRegion, uint32_t cbRegion, PCIADDRESSSPACE enmType, PFNPCIIOREGIONMAP pfnCallback));
451
452 /**
453 * Register PCI configuration space read/write callbacks.
454 *
455 * @param pDevIns Device instance of the PCI Bus.
456 * @param pPciDev The PCI device structure.
457 * @param pfnRead Pointer to the user defined PCI config read function.
458 * @param ppfnReadOld Pointer to function pointer which will receive the old (default)
459 * PCI config read function. This way, user can decide when (and if)
460 * to call default PCI config read function. Can be NULL.
461 * @param pfnWrite Pointer to the user defined PCI config write function.
462 * @param pfnWriteOld Pointer to function pointer which will receive the old (default)
463 * PCI config write function. This way, user can decide when (and if)
464 * to call default PCI config write function. Can be NULL.
465 * @thread EMT
466 */
467 DECLR3CALLBACKMEMBER(void, pfnSetConfigCallbacksR3,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, PFNPCICONFIGREAD pfnRead, PPFNPCICONFIGREAD ppfnReadOld,
468 PFNPCICONFIGWRITE pfnWrite, PPFNPCICONFIGWRITE ppfnWriteOld));
469
470 /**
471 * Set the IRQ for a PCI device.
472 *
473 * @param pDevIns Device instance of the PCI Bus.
474 * @param pPciDev The PCI device structure.
475 * @param iIrq IRQ number to set.
476 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
477 */
478 DECLR3CALLBACKMEMBER(void, pfnSetIrqR3,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, int iIrq, int iLevel));
479
480 /**
481 * Saves a state of the PCI device.
482 *
483 * @returns VBox status code.
484 * @param pDevIns Device instance of the PCI Bus.
485 * @param pPciDev Pointer to PCI device.
486 * @param pSSMHandle The handle to save the state to.
487 */
488 DECLR3CALLBACKMEMBER(int, pfnSaveExecR3,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, PSSMHANDLE pSSMHandle));
489
490 /**
491 * Loads a saved PCI device state.
492 *
493 * @returns VBox status code.
494 * @param pDevIns Device instance of the PCI Bus.
495 * @param pPciDev Pointer to PCI device.
496 * @param pSSMHandle The handle to the saved state.
497 */
498 DECLR3CALLBACKMEMBER(int, pfnLoadExecR3,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, PSSMHANDLE pSSMHandle));
499
500 /**
501 * Called to perform the job of the bios.
502 * This is only called for the first PCI Bus - it is expected to
503 * service all the PCI buses.
504 *
505 * @returns VBox status.
506 * @param pDevIns Device instance of the first bus.
507 */
508 DECLR3CALLBACKMEMBER(int, pfnFakePCIBIOSR3,(PPDMDEVINS pDevIns));
509
510 /** The name of the SetIrq RC entry point. */
511 const char *pszSetIrqRC;
512
513 /** The name of the SetIrq R0 entry point. */
514 const char *pszSetIrqR0;
515
516} PDMPCIBUSREG;
517/** Pointer to a PCI bus registration structure. */
518typedef PDMPCIBUSREG *PPDMPCIBUSREG;
519
520/** Current PDMPCIBUSREG version number. */
521#define PDM_PCIBUSREG_VERSION PDM_VERSION_MAKE(0xfffe, 1, 0)
522
523/**
524 * PCI Bus RC helpers.
525 */
526typedef struct PDMPCIHLPRC
527{
528 /** Structure version. PDM_PCIHLPRC_VERSION defines the current version. */
529 uint32_t u32Version;
530
531 /**
532 * Set an ISA IRQ.
533 *
534 * @param pDevIns PCI device instance.
535 * @param iIrq IRQ number to set.
536 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
537 * @thread EMT only.
538 */
539 DECLRCCALLBACKMEMBER(void, pfnIsaSetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
540
541 /**
542 * Set an I/O-APIC IRQ.
543 *
544 * @param pDevIns PCI device instance.
545 * @param iIrq IRQ number to set.
546 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
547 * @thread EMT only.
548 */
549 DECLRCCALLBACKMEMBER(void, pfnIoApicSetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
550
551 /**
552 * Acquires the PDM lock.
553 *
554 * @returns VINF_SUCCESS on success.
555 * @returns rc if we failed to acquire the lock.
556 * @param pDevIns The PCI device instance.
557 * @param rc What to return if we fail to acquire the lock.
558 */
559 DECLRCCALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
560
561 /**
562 * Releases the PDM lock.
563 *
564 * @param pDevIns The PCI device instance.
565 */
566 DECLRCCALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
567
568 /** Just a safety precaution. */
569 uint32_t u32TheEnd;
570} PDMPCIHLPRC;
571/** Pointer to PCI helpers. */
572typedef RCPTRTYPE(PDMPCIHLPRC *) PPDMPCIHLPRC;
573/** Pointer to const PCI helpers. */
574typedef RCPTRTYPE(const PDMPCIHLPRC *) PCPDMPCIHLPRC;
575
576/** Current PDMPCIHLPR3 version number. */
577#define PDM_PCIHLPRC_VERSION PDM_VERSION_MAKE(0xfffd, 1, 0)
578
579
580/**
581 * PCI Bus R0 helpers.
582 */
583typedef struct PDMPCIHLPR0
584{
585 /** Structure version. PDM_PCIHLPR0_VERSION defines the current version. */
586 uint32_t u32Version;
587
588 /**
589 * Set an ISA IRQ.
590 *
591 * @param pDevIns PCI device instance.
592 * @param iIrq IRQ number to set.
593 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
594 * @thread EMT only.
595 */
596 DECLR0CALLBACKMEMBER(void, pfnIsaSetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
597
598 /**
599 * Set an I/O-APIC IRQ.
600 *
601 * @param pDevIns PCI device instance.
602 * @param iIrq IRQ number to set.
603 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
604 * @thread EMT only.
605 */
606 DECLR0CALLBACKMEMBER(void, pfnIoApicSetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
607
608 /**
609 * Acquires the PDM lock.
610 *
611 * @returns VINF_SUCCESS on success.
612 * @returns rc if we failed to acquire the lock.
613 * @param pDevIns The PCI device instance.
614 * @param rc What to return if we fail to acquire the lock.
615 */
616 DECLR0CALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
617
618 /**
619 * Releases the PDM lock.
620 *
621 * @param pDevIns The PCI device instance.
622 */
623 DECLR0CALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
624
625 /** Just a safety precaution. */
626 uint32_t u32TheEnd;
627} PDMPCIHLPR0;
628/** Pointer to PCI helpers. */
629typedef R0PTRTYPE(PDMPCIHLPR0 *) PPDMPCIHLPR0;
630/** Pointer to const PCI helpers. */
631typedef R0PTRTYPE(const PDMPCIHLPR0 *) PCPDMPCIHLPR0;
632
633/** Current PDMPCIHLPR0 version number. */
634#define PDM_PCIHLPR0_VERSION PDM_VERSION_MAKE(0xfffc, 1, 0)
635
636/**
637 * PCI device helpers.
638 */
639typedef struct PDMPCIHLPR3
640{
641 /** Structure version. PDM_PCIHLPR3_VERSION defines the current version. */
642 uint32_t u32Version;
643
644 /**
645 * Set an ISA IRQ.
646 *
647 * @param pDevIns The PCI device instance.
648 * @param iIrq IRQ number to set.
649 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
650 * @thread EMT only.
651 */
652 DECLR3CALLBACKMEMBER(void, pfnIsaSetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
653
654 /**
655 * Set an I/O-APIC IRQ.
656 *
657 * @param pDevIns The PCI device instance.
658 * @param iIrq IRQ number to set.
659 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
660 * @thread EMT only.
661 */
662 DECLR3CALLBACKMEMBER(void, pfnIoApicSetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
663
664 /**
665 * Checks if the given address is an MMIO2 base address or not.
666 *
667 * @returns true/false accordingly.
668 * @param pDevIns The PCI device instance.
669 * @param pOwner The owner of the memory, optional.
670 * @param GCPhys The address to check.
671 */
672 DECLR3CALLBACKMEMBER(bool, pfnIsMMIO2Base,(PPDMDEVINS pDevIns, PPDMDEVINS pOwner, RTGCPHYS GCPhys));
673
674 /**
675 * Gets the address of the RC PCI Bus helpers.
676 *
677 * This should be called at both construction and relocation time
678 * to obtain the correct address of the RC helpers.
679 *
680 * @returns RC pointer to the PCI Bus helpers.
681 * @param pDevIns Device instance of the PCI Bus.
682 * @thread EMT only.
683 */
684 DECLR3CALLBACKMEMBER(PCPDMPCIHLPRC, pfnGetRCHelpers,(PPDMDEVINS pDevIns));
685
686 /**
687 * Gets the address of the R0 PCI Bus helpers.
688 *
689 * This should be called at both construction and relocation time
690 * to obtain the correct address of the R0 helpers.
691 *
692 * @returns R0 pointer to the PCI Bus helpers.
693 * @param pDevIns Device instance of the PCI Bus.
694 * @thread EMT only.
695 */
696 DECLR3CALLBACKMEMBER(PCPDMPCIHLPR0, pfnGetR0Helpers,(PPDMDEVINS pDevIns));
697
698 /**
699 * Acquires the PDM lock.
700 *
701 * @returns VINF_SUCCESS on success.
702 * @returns Fatal error on failure.
703 * @param pDevIns The PCI device instance.
704 * @param rc Dummy for making the interface identical to the RC and R0 versions.
705 */
706 DECLR3CALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
707
708 /**
709 * Releases the PDM lock.
710 *
711 * @param pDevIns The PCI device instance.
712 */
713 DECLR3CALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
714
715 /** Just a safety precaution. */
716 uint32_t u32TheEnd;
717} PDMPCIHLPR3;
718/** Pointer to PCI helpers. */
719typedef R3PTRTYPE(PDMPCIHLPR3 *) PPDMPCIHLPR3;
720/** Pointer to const PCI helpers. */
721typedef R3PTRTYPE(const PDMPCIHLPR3 *) PCPDMPCIHLPR3;
722
723/** Current PDMPCIHLPR3 version number. */
724#define PDM_PCIHLPR3_VERSION PDM_VERSION_MAKE(0xfffb, 1, 0)
725
726
727/**
728 * Programmable Interrupt Controller registration structure.
729 */
730typedef struct PDMPICREG
731{
732 /** Structure version number. PDM_PICREG_VERSION defines the current version. */
733 uint32_t u32Version;
734
735 /**
736 * Set the an IRQ.
737 *
738 * @param pDevIns Device instance of the PIC.
739 * @param iIrq IRQ number to set.
740 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
741 */
742 DECLR3CALLBACKMEMBER(void, pfnSetIrqR3,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
743
744 /**
745 * Get a pending interrupt.
746 *
747 * @returns Pending interrupt number.
748 * @param pDevIns Device instance of the PIC.
749 */
750 DECLR3CALLBACKMEMBER(int, pfnGetInterruptR3,(PPDMDEVINS pDevIns));
751
752 /** The name of the RC SetIrq entry point. */
753 const char *pszSetIrqRC;
754 /** The name of the RC GetInterrupt entry point. */
755 const char *pszGetInterruptRC;
756
757 /** The name of the R0 SetIrq entry point. */
758 const char *pszSetIrqR0;
759 /** The name of the R0 GetInterrupt entry point. */
760 const char *pszGetInterruptR0;
761} PDMPICREG;
762/** Pointer to a PIC registration structure. */
763typedef PDMPICREG *PPDMPICREG;
764
765/** Current PDMPICREG version number. */
766#define PDM_PICREG_VERSION PDM_VERSION_MAKE(0xfffa, 1, 0)
767
768/**
769 * PIC RC helpers.
770 */
771typedef struct PDMPICHLPRC
772{
773 /** Structure version. PDM_PICHLPRC_VERSION defines the current version. */
774 uint32_t u32Version;
775
776 /**
777 * Set the interrupt force action flag.
778 *
779 * @param pDevIns Device instance of the PIC.
780 */
781 DECLRCCALLBACKMEMBER(void, pfnSetInterruptFF,(PPDMDEVINS pDevIns));
782
783 /**
784 * Clear the interrupt force action flag.
785 *
786 * @param pDevIns Device instance of the PIC.
787 */
788 DECLRCCALLBACKMEMBER(void, pfnClearInterruptFF,(PPDMDEVINS pDevIns));
789
790 /**
791 * Acquires the PDM lock.
792 *
793 * @returns VINF_SUCCESS on success.
794 * @returns rc if we failed to acquire the lock.
795 * @param pDevIns The PIC device instance.
796 * @param rc What to return if we fail to acquire the lock.
797 */
798 DECLRCCALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
799
800 /**
801 * Releases the PDM lock.
802 *
803 * @param pDevIns The PIC device instance.
804 */
805 DECLRCCALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
806
807 /** Just a safety precaution. */
808 uint32_t u32TheEnd;
809} PDMPICHLPRC;
810
811/** Pointer to PIC RC helpers. */
812typedef RCPTRTYPE(PDMPICHLPRC *) PPDMPICHLPRC;
813/** Pointer to const PIC RC helpers. */
814typedef RCPTRTYPE(const PDMPICHLPRC *) PCPDMPICHLPRC;
815
816/** Current PDMPICHLPRC version number. */
817#define PDM_PICHLPRC_VERSION PDM_VERSION_MAKE(0xfff9, 1, 0)
818
819
820/**
821 * PIC R0 helpers.
822 */
823typedef struct PDMPICHLPR0
824{
825 /** Structure version. PDM_PICHLPR0_VERSION defines the current version. */
826 uint32_t u32Version;
827
828 /**
829 * Set the interrupt force action flag.
830 *
831 * @param pDevIns Device instance of the PIC.
832 */
833 DECLR0CALLBACKMEMBER(void, pfnSetInterruptFF,(PPDMDEVINS pDevIns));
834
835 /**
836 * Clear the interrupt force action flag.
837 *
838 * @param pDevIns Device instance of the PIC.
839 */
840 DECLR0CALLBACKMEMBER(void, pfnClearInterruptFF,(PPDMDEVINS pDevIns));
841
842 /**
843 * Acquires the PDM lock.
844 *
845 * @returns VINF_SUCCESS on success.
846 * @returns rc if we failed to acquire the lock.
847 * @param pDevIns The PIC device instance.
848 * @param rc What to return if we fail to acquire the lock.
849 */
850 DECLR0CALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
851
852 /**
853 * Releases the PDM lock.
854 *
855 * @param pDevIns The PCI device instance.
856 */
857 DECLR0CALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
858
859 /** Just a safety precaution. */
860 uint32_t u32TheEnd;
861} PDMPICHLPR0;
862
863/** Pointer to PIC R0 helpers. */
864typedef R0PTRTYPE(PDMPICHLPR0 *) PPDMPICHLPR0;
865/** Pointer to const PIC R0 helpers. */
866typedef R0PTRTYPE(const PDMPICHLPR0 *) PCPDMPICHLPR0;
867
868/** Current PDMPICHLPR0 version number. */
869#define PDM_PICHLPR0_VERSION PDM_VERSION_MAKE(0xfff8, 1, 0)
870
871/**
872 * PIC R3 helpers.
873 */
874typedef struct PDMPICHLPR3
875{
876 /** Structure version. PDM_PICHLP_VERSION defines the current version. */
877 uint32_t u32Version;
878
879 /**
880 * Set the interrupt force action flag.
881 *
882 * @param pDevIns Device instance of the PIC.
883 */
884 DECLR3CALLBACKMEMBER(void, pfnSetInterruptFF,(PPDMDEVINS pDevIns));
885
886 /**
887 * Clear the interrupt force action flag.
888 *
889 * @param pDevIns Device instance of the PIC.
890 */
891 DECLR3CALLBACKMEMBER(void, pfnClearInterruptFF,(PPDMDEVINS pDevIns));
892
893 /**
894 * Acquires the PDM lock.
895 *
896 * @returns VINF_SUCCESS on success.
897 * @returns Fatal error on failure.
898 * @param pDevIns The PIC device instance.
899 * @param rc Dummy for making the interface identical to the RC and R0 versions.
900 */
901 DECLR3CALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
902
903 /**
904 * Releases the PDM lock.
905 *
906 * @param pDevIns The PIC device instance.
907 */
908 DECLR3CALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
909
910 /**
911 * Gets the address of the RC PIC helpers.
912 *
913 * This should be called at both construction and relocation time
914 * to obtain the correct address of the RC helpers.
915 *
916 * @returns RC pointer to the PIC helpers.
917 * @param pDevIns Device instance of the PIC.
918 */
919 DECLR3CALLBACKMEMBER(PCPDMPICHLPRC, pfnGetRCHelpers,(PPDMDEVINS pDevIns));
920
921 /**
922 * Gets the address of the R0 PIC helpers.
923 *
924 * This should be called at both construction and relocation time
925 * to obtain the correct address of the R0 helpers.
926 *
927 * @returns R0 pointer to the PIC helpers.
928 * @param pDevIns Device instance of the PIC.
929 */
930 DECLR3CALLBACKMEMBER(PCPDMPICHLPR0, pfnGetR0Helpers,(PPDMDEVINS pDevIns));
931
932 /** Just a safety precaution. */
933 uint32_t u32TheEnd;
934} PDMPICHLPR3;
935
936/** Pointer to PIC R3 helpers. */
937typedef R3PTRTYPE(PDMPICHLPR3 *) PPDMPICHLPR3;
938/** Pointer to const PIC R3 helpers. */
939typedef R3PTRTYPE(const PDMPICHLPR3 *) PCPDMPICHLPR3;
940
941/** Current PDMPICHLPR3 version number. */
942#define PDM_PICHLPR3_VERSION PDM_VERSION_MAKE(0xfff7, 1, 0)
943
944
945
946/**
947 * Advanced Programmable Interrupt Controller registration structure.
948 */
949typedef struct PDMAPICREG
950{
951 /** Structure version number. PDM_APICREG_VERSION defines the current version. */
952 uint32_t u32Version;
953
954 /**
955 * Get a pending interrupt.
956 *
957 * @returns Pending interrupt number.
958 * @param pDevIns Device instance of the APIC.
959 */
960 DECLR3CALLBACKMEMBER(int, pfnGetInterruptR3,(PPDMDEVINS pDevIns));
961
962 /**
963 * Check if the APIC has a pending interrupt/if a TPR change would active one
964 *
965 * @returns Pending interrupt yes/no
966 * @param pDevIns Device instance of the APIC.
967 */
968 DECLR3CALLBACKMEMBER(bool, pfnHasPendingIrqR3,(PPDMDEVINS pDevIns));
969
970 /**
971 * Set the APIC base.
972 *
973 * @param pDevIns Device instance of the APIC.
974 * @param u64Base The new base.
975 */
976 DECLR3CALLBACKMEMBER(void, pfnSetBaseR3,(PPDMDEVINS pDevIns, uint64_t u64Base));
977
978 /**
979 * Get the APIC base.
980 *
981 * @returns Current base.
982 * @param pDevIns Device instance of the APIC.
983 */
984 DECLR3CALLBACKMEMBER(uint64_t, pfnGetBaseR3,(PPDMDEVINS pDevIns));
985
986 /**
987 * Set the TPR (task priority register).
988 *
989 * @param pDevIns Device instance of the APIC.
990 * @param idCpu VCPU id
991 * @param u8TPR The new TPR.
992 */
993 DECLR3CALLBACKMEMBER(void, pfnSetTPRR3,(PPDMDEVINS pDevIns, VMCPUID idCpu, uint8_t u8TPR));
994
995 /**
996 * Get the TPR (task priority register).
997 *
998 * @returns The current TPR.
999 * @param pDevIns Device instance of the APIC.
1000 * @param idCpu VCPU id
1001 */
1002 DECLR3CALLBACKMEMBER(uint8_t, pfnGetTPRR3,(PPDMDEVINS pDevIns, VMCPUID idCpu));
1003
1004 /**
1005 * Write MSR in APIC range.
1006 *
1007 * @returns VBox status code.
1008 * @param pDevIns Device instance of the APIC.
1009 * @param idCpu Target CPU.
1010 * @param u32Reg MSR to write.
1011 * @param u64Value Value to write.
1012 */
1013 DECLR3CALLBACKMEMBER(int, pfnWriteMSRR3, (PPDMDEVINS pDevIns, VMCPUID idCpu, uint32_t u32Reg, uint64_t u64Value));
1014
1015 /**
1016 * Read MSR in APIC range.
1017 *
1018 * @returns VBox status code.
1019 * @param pDevIns Device instance of the APIC.
1020 * @param idCpu Target CPU.
1021 * @param u32Reg MSR to read.
1022 * @param pu64Value Value read.
1023 */
1024 DECLR3CALLBACKMEMBER(int, pfnReadMSRR3, (PPDMDEVINS pDevIns, VMCPUID idCpu, uint32_t u32Reg, uint64_t *pu64Value));
1025
1026 /**
1027 * Private interface between the IOAPIC and APIC.
1028 *
1029 * This is a low-level, APIC/IOAPIC implementation specific interface
1030 * which is registered with PDM only because it makes life so much
1031 * simpler right now (GC bits). This is a bad bad hack! The correct
1032 * way of doing this would involve some way of querying GC interfaces
1033 * and relocating them. Perhaps doing some kind of device init in GC...
1034 *
1035 * @returns status code.
1036 * @param pDevIns Device instance of the APIC.
1037 * @param u8Dest See APIC implementation.
1038 * @param u8DestMode See APIC implementation.
1039 * @param u8DeliveryMode See APIC implementation.
1040 * @param iVector See APIC implementation.
1041 * @param u8Polarity See APIC implementation.
1042 * @param u8TriggerMode See APIC implementation.
1043 */
1044 DECLR3CALLBACKMEMBER(int, pfnBusDeliverR3,(PPDMDEVINS pDevIns, uint8_t u8Dest, uint8_t u8DestMode, uint8_t u8DeliveryMode,
1045 uint8_t iVector, uint8_t u8Polarity, uint8_t u8TriggerMode));
1046
1047 /**
1048 * Deliver a signal to CPU's local interrupt pins (LINT0/LINT1). Used for
1049 * virtual wire mode when interrupts from the PIC are passed through LAPIC.
1050 *
1051 * @returns status code.
1052 * @param pDevIns Device instance of the APIC.
1053 * @param u8Pin Local pin number (0 or 1 for current CPUs).
1054 */
1055 DECLR3CALLBACKMEMBER(int, pfnLocalInterruptR3,(PPDMDEVINS pDevIns, uint8_t u8Pin, uint8_t u8Level));
1056
1057 /** The name of the RC GetInterrupt entry point. */
1058 const char *pszGetInterruptRC;
1059 /** The name of the RC HasPendingIrq entry point. */
1060 const char *pszHasPendingIrqRC;
1061 /** The name of the RC SetBase entry point. */
1062 const char *pszSetBaseRC;
1063 /** The name of the RC GetBase entry point. */
1064 const char *pszGetBaseRC;
1065 /** The name of the RC SetTPR entry point. */
1066 const char *pszSetTPRRC;
1067 /** The name of the RC GetTPR entry point. */
1068 const char *pszGetTPRRC;
1069 /** The name of the RC WriteMSR entry point. */
1070 const char *pszWriteMSRRC;
1071 /** The name of the RC ReadMSR entry point. */
1072 const char *pszReadMSRRC;
1073 /** The name of the RC BusDeliver entry point. */
1074 const char *pszBusDeliverRC;
1075 /** The name of the RC LocalInterrupt entry point. */
1076 const char *pszLocalInterruptRC;
1077
1078 /** The name of the R0 GetInterrupt entry point. */
1079 const char *pszGetInterruptR0;
1080 /** The name of the R0 HasPendingIrq entry point. */
1081 const char *pszHasPendingIrqR0;
1082 /** The name of the R0 SetBase entry point. */
1083 const char *pszSetBaseR0;
1084 /** The name of the R0 GetBase entry point. */
1085 const char *pszGetBaseR0;
1086 /** The name of the R0 SetTPR entry point. */
1087 const char *pszSetTPRR0;
1088 /** The name of the R0 GetTPR entry point. */
1089 const char *pszGetTPRR0;
1090 /** The name of the R0 WriteMSR entry point. */
1091 const char *pszWriteMSRR0;
1092 /** The name of the R0 ReadMSR entry point. */
1093 const char *pszReadMSRR0;
1094 /** The name of the R0 BusDeliver entry point. */
1095 const char *pszBusDeliverR0;
1096 /** The name of the R0 LocalInterrupt entry point. */
1097 const char *pszLocalInterruptR0;
1098
1099} PDMAPICREG;
1100/** Pointer to an APIC registration structure. */
1101typedef PDMAPICREG *PPDMAPICREG;
1102
1103/** Current PDMAPICREG version number. */
1104#define PDM_APICREG_VERSION PDM_VERSION_MAKE(0xfff6, 1, 0)
1105
1106
1107/**
1108 * APIC version argument for pfnChangeFeature.
1109 */
1110typedef enum PDMAPICVERSION
1111{
1112 /** Invalid 0 entry. */
1113 PDMAPICVERSION_INVALID = 0,
1114 /** No APIC. */
1115 PDMAPICVERSION_NONE,
1116 /** Standard APIC (X86_CPUID_FEATURE_EDX_APIC). */
1117 PDMAPICVERSION_APIC,
1118 /** Intel X2APIC (X86_CPUID_FEATURE_ECX_X2APIC). */
1119 PDMAPICVERSION_X2APIC,
1120 /** The usual 32-bit paranoia. */
1121 PDMAPICVERSION_32BIT_HACK = 0x7fffffff
1122} PDMAPICVERSION;
1123
1124/**
1125 * APIC irq argument for SetInterruptFF.
1126 */
1127typedef enum PDMAPICIRQ
1128{
1129 /** Invalid 0 entry. */
1130 PDMAPICIRQ_INVALID = 0,
1131 /** Normal hardware interrupt. */
1132 PDMAPICIRQ_HARDWARE,
1133 /** NMI. */
1134 PDMAPICIRQ_NMI,
1135 /** SMI. */
1136 PDMAPICIRQ_SMI,
1137 /** ExtINT (HW interrupt via PIC). */
1138 PDMAPICIRQ_EXTINT,
1139 /** The usual 32-bit paranoia. */
1140 PDMAPICIRQ_32BIT_HACK = 0x7fffffff
1141} PDMAPICIRQ;
1142
1143
1144/**
1145 * APIC RC helpers.
1146 */
1147typedef struct PDMAPICHLPRC
1148{
1149 /** Structure version. PDM_APICHLPRC_VERSION defines the current version. */
1150 uint32_t u32Version;
1151
1152 /**
1153 * Set the interrupt force action flag.
1154 *
1155 * @param pDevIns Device instance of the APIC.
1156 * @param enmType IRQ type.
1157 * @param idCpu Virtual CPU to set flag upon.
1158 */
1159 DECLRCCALLBACKMEMBER(void, pfnSetInterruptFF,(PPDMDEVINS pDevIns, PDMAPICIRQ enmType, VMCPUID idCpu));
1160
1161 /**
1162 * Clear the interrupt force action flag.
1163 *
1164 * @param pDevIns Device instance of the APIC.
1165 * @param enmType IRQ type.
1166 * @param idCpu Virtual CPU to clear flag upon.
1167 */
1168 DECLRCCALLBACKMEMBER(void, pfnClearInterruptFF,(PPDMDEVINS pDevIns, PDMAPICIRQ enmType, VMCPUID idCpu));
1169
1170 /**
1171 * Modifies APIC-related bits in the CPUID feature mask.
1172 *
1173 * @param pDevIns Device instance of the APIC.
1174 * @param enmVersion Supported APIC version.
1175 */
1176 DECLRCCALLBACKMEMBER(void, pfnChangeFeature,(PPDMDEVINS pDevIns, PDMAPICVERSION enmVersion));
1177
1178 /**
1179 * Acquires the PDM lock.
1180 *
1181 * @returns VINF_SUCCESS on success.
1182 * @returns rc if we failed to acquire the lock.
1183 * @param pDevIns The APIC device instance.
1184 * @param rc What to return if we fail to acquire the lock.
1185 */
1186 DECLRCCALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
1187
1188 /**
1189 * Releases the PDM lock.
1190 *
1191 * @param pDevIns The APIC device instance.
1192 */
1193 DECLRCCALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
1194
1195 /**
1196 * Get the virtual CPU id corresponding to the current EMT.
1197 *
1198 * @param pDevIns The APIC device instance.
1199 */
1200 DECLRCCALLBACKMEMBER(VMCPUID, pfnGetCpuId,(PPDMDEVINS pDevIns));
1201
1202 /** Just a safety precaution. */
1203 uint32_t u32TheEnd;
1204} PDMAPICHLPRC;
1205/** Pointer to APIC GC helpers. */
1206typedef RCPTRTYPE(PDMAPICHLPRC *) PPDMAPICHLPRC;
1207/** Pointer to const APIC helpers. */
1208typedef RCPTRTYPE(const PDMAPICHLPRC *) PCPDMAPICHLPRC;
1209
1210/** Current PDMAPICHLPRC version number. */
1211#define PDM_APICHLPRC_VERSION PDM_VERSION_MAKE(0xfff5, 1, 0)
1212
1213
1214/**
1215 * APIC R0 helpers.
1216 */
1217typedef struct PDMAPICHLPR0
1218{
1219 /** Structure version. PDM_APICHLPR0_VERSION defines the current version. */
1220 uint32_t u32Version;
1221
1222 /**
1223 * Set the interrupt force action flag.
1224 *
1225 * @param pDevIns Device instance of the APIC.
1226 * @param enmType IRQ type.
1227 * @param idCpu Virtual CPU to set flag upon.
1228 */
1229 DECLR0CALLBACKMEMBER(void, pfnSetInterruptFF,(PPDMDEVINS pDevIns, PDMAPICIRQ enmType, VMCPUID idCpu));
1230
1231 /**
1232 * Clear the interrupt force action flag.
1233 *
1234 * @param pDevIns Device instance of the APIC.
1235 * @param enmType IRQ type.
1236 * @param idCpu Virtual CPU to clear flag upon.
1237 */
1238 DECLR0CALLBACKMEMBER(void, pfnClearInterruptFF,(PPDMDEVINS pDevIns, PDMAPICIRQ enmType, VMCPUID idCpu));
1239
1240 /**
1241 * Modifies APIC-related bits in the CPUID feature mask.
1242 *
1243 * @param pDevIns Device instance of the APIC.
1244 * @param enmVersion Supported APIC version.
1245 */
1246 DECLR0CALLBACKMEMBER(void, pfnChangeFeature,(PPDMDEVINS pDevIns, PDMAPICVERSION enmVersion));
1247
1248 /**
1249 * Acquires the PDM lock.
1250 *
1251 * @returns VINF_SUCCESS on success.
1252 * @returns rc if we failed to acquire the lock.
1253 * @param pDevIns The APIC device instance.
1254 * @param rc What to return if we fail to acquire the lock.
1255 */
1256 DECLR0CALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
1257
1258 /**
1259 * Releases the PDM lock.
1260 *
1261 * @param pDevIns The APIC device instance.
1262 */
1263 DECLR0CALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
1264
1265 /**
1266 * Get the virtual CPU id corresponding to the current EMT.
1267 *
1268 * @param pDevIns The APIC device instance.
1269 */
1270 DECLR0CALLBACKMEMBER(VMCPUID, pfnGetCpuId,(PPDMDEVINS pDevIns));
1271
1272 /** Just a safety precaution. */
1273 uint32_t u32TheEnd;
1274} PDMAPICHLPR0;
1275/** Pointer to APIC GC helpers. */
1276typedef RCPTRTYPE(PDMAPICHLPR0 *) PPDMAPICHLPR0;
1277/** Pointer to const APIC helpers. */
1278typedef R0PTRTYPE(const PDMAPICHLPR0 *) PCPDMAPICHLPR0;
1279
1280/** Current PDMAPICHLPR0 version number. */
1281#define PDM_APICHLPR0_VERSION PDM_VERSION_MAKE(0xfff4, 1, 0)
1282
1283/**
1284 * APIC R3 helpers.
1285 */
1286typedef struct PDMAPICHLPR3
1287{
1288 /** Structure version. PDM_APICHLPR3_VERSION defines the current version. */
1289 uint32_t u32Version;
1290
1291 /**
1292 * Set the interrupt force action flag.
1293 *
1294 * @param pDevIns Device instance of the APIC.
1295 * @param enmType IRQ type.
1296 * @param idCpu Virtual CPU to set flag upon.
1297 */
1298 DECLR3CALLBACKMEMBER(void, pfnSetInterruptFF,(PPDMDEVINS pDevIns, PDMAPICIRQ enmType, VMCPUID idCpu));
1299
1300 /**
1301 * Clear the interrupt force action flag.
1302 *
1303 * @param pDevIns Device instance of the APIC.
1304 * @param enmType IRQ type.
1305 * @param idCpu Virtual CPU to clear flag upon.
1306 */
1307 DECLR3CALLBACKMEMBER(void, pfnClearInterruptFF,(PPDMDEVINS pDevIns, PDMAPICIRQ enmType, VMCPUID idCpu));
1308
1309 /**
1310 * Modifies APIC-related bits in the CPUID feature mask.
1311 *
1312 * @param pDevIns Device instance of the APIC.
1313 * @param enmVersion Supported APIC version.
1314 */
1315 DECLR3CALLBACKMEMBER(void, pfnChangeFeature,(PPDMDEVINS pDevIns, PDMAPICVERSION enmVersion));
1316
1317 /**
1318 * Get the virtual CPU id corresponding to the current EMT.
1319 *
1320 * @param pDevIns The APIC device instance.
1321 */
1322 DECLR3CALLBACKMEMBER(VMCPUID, pfnGetCpuId,(PPDMDEVINS pDevIns));
1323
1324 /**
1325 * Sends SIPI to given virtual CPU.
1326 *
1327 * @param pDevIns The APIC device instance.
1328 * @param idCpu Virtual CPU to perform SIPI on
1329 * @param iVector SIPI vector
1330 */
1331 DECLR3CALLBACKMEMBER(void, pfnSendSipi,(PPDMDEVINS pDevIns, VMCPUID idCpu, uint32_t uVector));
1332
1333 /**
1334 * Sends init IPI to given virtual CPU, should result in reset and
1335 * halting till SIPI.
1336 *
1337 * @param pDevIns The APIC device instance.
1338 * @param idCpu Virtual CPU to perform SIPI on
1339 */
1340 DECLR3CALLBACKMEMBER(void, pfnSendInitIpi,(PPDMDEVINS pDevIns, VMCPUID idCpu));
1341
1342 /**
1343 * Gets the address of the RC APIC helpers.
1344 *
1345 * This should be called at both construction and relocation time
1346 * to obtain the correct address of the RC helpers.
1347 *
1348 * @returns GC pointer to the APIC helpers.
1349 * @param pDevIns Device instance of the APIC.
1350 */
1351 DECLR3CALLBACKMEMBER(PCPDMAPICHLPRC, pfnGetRCHelpers,(PPDMDEVINS pDevIns));
1352
1353 /**
1354 * Gets the address of the R0 APIC helpers.
1355 *
1356 * This should be called at both construction and relocation time
1357 * to obtain the correct address of the R0 helpers.
1358 *
1359 * @returns R0 pointer to the APIC helpers.
1360 * @param pDevIns Device instance of the APIC.
1361 */
1362 DECLR3CALLBACKMEMBER(PCPDMAPICHLPR0, pfnGetR0Helpers,(PPDMDEVINS pDevIns));
1363
1364 /**
1365 * Get the critical section used to synchronize the PICs, PCI and stuff.
1366 *
1367 * @returns Ring-3 pointer to the critical section.
1368 * @param pDevIns The APIC device instance.
1369 */
1370 DECLR3CALLBACKMEMBER(R3PTRTYPE(PPDMCRITSECT), pfnGetR3CritSect,(PPDMDEVINS pDevIns));
1371
1372 /**
1373 * Get the critical section used to synchronize the PICs, PCI and stuff.
1374 *
1375 * @returns Raw-mode context pointer to the critical section.
1376 * @param pDevIns The APIC device instance.
1377 */
1378 DECLR3CALLBACKMEMBER(RCPTRTYPE(PPDMCRITSECT), pfnGetRCCritSect,(PPDMDEVINS pDevIns));
1379
1380 /**
1381 * Get the critical section used to synchronize the PICs, PCI and stuff.
1382 *
1383 * @returns Ring-0 pointer to the critical section.
1384 * @param pDevIns The APIC device instance.
1385 */
1386 DECLR3CALLBACKMEMBER(R0PTRTYPE(PPDMCRITSECT), pfnGetR0CritSect,(PPDMDEVINS pDevIns));
1387
1388 /** Just a safety precaution. */
1389 uint32_t u32TheEnd;
1390} PDMAPICHLPR3;
1391/** Pointer to APIC helpers. */
1392typedef R3PTRTYPE(PDMAPICHLPR3 *) PPDMAPICHLPR3;
1393/** Pointer to const APIC helpers. */
1394typedef R3PTRTYPE(const PDMAPICHLPR3 *) PCPDMAPICHLPR3;
1395
1396/** Current PDMAPICHLP version number. */
1397#define PDM_APICHLPR3_VERSION PDM_VERSION_MAKE(0xfff3, 1, 0)
1398
1399
1400/**
1401 * I/O APIC registration structure.
1402 */
1403typedef struct PDMIOAPICREG
1404{
1405 /** Struct version+magic number (PDM_IOAPICREG_VERSION). */
1406 uint32_t u32Version;
1407
1408 /**
1409 * Set the an IRQ.
1410 *
1411 * @param pDevIns Device instance of the I/O APIC.
1412 * @param iIrq IRQ number to set.
1413 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
1414 */
1415 DECLR3CALLBACKMEMBER(void, pfnSetIrqR3,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
1416
1417 /** The name of the GC SetIrq entry point. */
1418 const char *pszSetIrqRC;
1419
1420 /** The name of the R0 SetIrq entry point. */
1421 const char *pszSetIrqR0;
1422} PDMIOAPICREG;
1423/** Pointer to an APIC registration structure. */
1424typedef PDMIOAPICREG *PPDMIOAPICREG;
1425
1426/** Current PDMAPICREG version number. */
1427#define PDM_IOAPICREG_VERSION PDM_VERSION_MAKE(0xfff2, 1, 0)
1428
1429
1430/**
1431 * IOAPIC RC helpers.
1432 */
1433typedef struct PDMIOAPICHLPRC
1434{
1435 /** Structure version. PDM_IOAPICHLPRC_VERSION defines the current version. */
1436 uint32_t u32Version;
1437
1438 /**
1439 * Private interface between the IOAPIC and APIC.
1440 *
1441 * See comments about this hack on PDMAPICREG::pfnBusDeliverR3.
1442 *
1443 * @returns status code.
1444 * @param pDevIns Device instance of the IOAPIC.
1445 * @param u8Dest See APIC implementation.
1446 * @param u8DestMode See APIC implementation.
1447 * @param u8DeliveryMode See APIC implementation.
1448 * @param iVector See APIC implementation.
1449 * @param u8Polarity See APIC implementation.
1450 * @param u8TriggerMode See APIC implementation.
1451 */
1452 DECLRCCALLBACKMEMBER(int, pfnApicBusDeliver,(PPDMDEVINS pDevIns, uint8_t u8Dest, uint8_t u8DestMode, uint8_t u8DeliveryMode,
1453 uint8_t iVector, uint8_t u8Polarity, uint8_t u8TriggerMode));
1454
1455 /**
1456 * Acquires the PDM lock.
1457 *
1458 * @returns VINF_SUCCESS on success.
1459 * @returns rc if we failed to acquire the lock.
1460 * @param pDevIns The IOAPIC device instance.
1461 * @param rc What to return if we fail to acquire the lock.
1462 */
1463 DECLRCCALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
1464
1465 /**
1466 * Releases the PDM lock.
1467 *
1468 * @param pDevIns The IOAPIC device instance.
1469 */
1470 DECLRCCALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
1471
1472 /** Just a safety precaution. */
1473 uint32_t u32TheEnd;
1474} PDMIOAPICHLPRC;
1475/** Pointer to IOAPIC RC helpers. */
1476typedef RCPTRTYPE(PDMIOAPICHLPRC *) PPDMIOAPICHLPRC;
1477/** Pointer to const IOAPIC helpers. */
1478typedef RCPTRTYPE(const PDMIOAPICHLPRC *) PCPDMIOAPICHLPRC;
1479
1480/** Current PDMIOAPICHLPRC version number. */
1481#define PDM_IOAPICHLPRC_VERSION PDM_VERSION_MAKE(0xfff1, 1, 0)
1482
1483
1484/**
1485 * IOAPIC R0 helpers.
1486 */
1487typedef struct PDMIOAPICHLPR0
1488{
1489 /** Structure version. PDM_IOAPICHLPR0_VERSION defines the current version. */
1490 uint32_t u32Version;
1491
1492 /**
1493 * Private interface between the IOAPIC and APIC.
1494 *
1495 * See comments about this hack on PDMAPICREG::pfnBusDeliverR3.
1496 *
1497 * @returns status code.
1498 * @param pDevIns Device instance of the IOAPIC.
1499 * @param u8Dest See APIC implementation.
1500 * @param u8DestMode See APIC implementation.
1501 * @param u8DeliveryMode See APIC implementation.
1502 * @param iVector See APIC implementation.
1503 * @param u8Polarity See APIC implementation.
1504 * @param u8TriggerMode See APIC implementation.
1505 */
1506 DECLR0CALLBACKMEMBER(int, pfnApicBusDeliver,(PPDMDEVINS pDevIns, uint8_t u8Dest, uint8_t u8DestMode, uint8_t u8DeliveryMode,
1507 uint8_t iVector, uint8_t u8Polarity, uint8_t u8TriggerMode));
1508
1509 /**
1510 * Acquires the PDM lock.
1511 *
1512 * @returns VINF_SUCCESS on success.
1513 * @returns rc if we failed to acquire the lock.
1514 * @param pDevIns The IOAPIC device instance.
1515 * @param rc What to return if we fail to acquire the lock.
1516 */
1517 DECLR0CALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
1518
1519 /**
1520 * Releases the PDM lock.
1521 *
1522 * @param pDevIns The IOAPIC device instance.
1523 */
1524 DECLR0CALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
1525
1526 /** Just a safety precaution. */
1527 uint32_t u32TheEnd;
1528} PDMIOAPICHLPR0;
1529/** Pointer to IOAPIC R0 helpers. */
1530typedef R0PTRTYPE(PDMIOAPICHLPR0 *) PPDMIOAPICHLPR0;
1531/** Pointer to const IOAPIC helpers. */
1532typedef R0PTRTYPE(const PDMIOAPICHLPR0 *) PCPDMIOAPICHLPR0;
1533
1534/** Current PDMIOAPICHLPR0 version number. */
1535#define PDM_IOAPICHLPR0_VERSION PDM_VERSION_MAKE(0xfff0, 1, 0)
1536
1537/**
1538 * IOAPIC R3 helpers.
1539 */
1540typedef struct PDMIOAPICHLPR3
1541{
1542 /** Structure version. PDM_IOAPICHLPR3_VERSION defines the current version. */
1543 uint32_t u32Version;
1544
1545 /**
1546 * Private interface between the IOAPIC and APIC.
1547 *
1548 * See comments about this hack on PDMAPICREG::pfnBusDeliverR3.
1549 *
1550 * @returns status code
1551 * @param pDevIns Device instance of the IOAPIC.
1552 * @param u8Dest See APIC implementation.
1553 * @param u8DestMode See APIC implementation.
1554 * @param u8DeliveryMode See APIC implementation.
1555 * @param iVector See APIC implementation.
1556 * @param u8Polarity See APIC implementation.
1557 * @param u8TriggerMode See APIC implementation.
1558 */
1559 DECLR3CALLBACKMEMBER(int, pfnApicBusDeliver,(PPDMDEVINS pDevIns, uint8_t u8Dest, uint8_t u8DestMode, uint8_t u8DeliveryMode,
1560 uint8_t iVector, uint8_t u8Polarity, uint8_t u8TriggerMode));
1561
1562 /**
1563 * Acquires the PDM lock.
1564 *
1565 * @returns VINF_SUCCESS on success.
1566 * @returns Fatal error on failure.
1567 * @param pDevIns The IOAPIC device instance.
1568 * @param rc Dummy for making the interface identical to the GC and R0 versions.
1569 */
1570 DECLR3CALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
1571
1572 /**
1573 * Releases the PDM lock.
1574 *
1575 * @param pDevIns The IOAPIC device instance.
1576 */
1577 DECLR3CALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
1578
1579 /**
1580 * Gets the address of the RC IOAPIC helpers.
1581 *
1582 * This should be called at both construction and relocation time
1583 * to obtain the correct address of the RC helpers.
1584 *
1585 * @returns RC pointer to the IOAPIC helpers.
1586 * @param pDevIns Device instance of the IOAPIC.
1587 */
1588 DECLR3CALLBACKMEMBER(PCPDMIOAPICHLPRC, pfnGetRCHelpers,(PPDMDEVINS pDevIns));
1589
1590 /**
1591 * Gets the address of the R0 IOAPIC helpers.
1592 *
1593 * This should be called at both construction and relocation time
1594 * to obtain the correct address of the R0 helpers.
1595 *
1596 * @returns R0 pointer to the IOAPIC helpers.
1597 * @param pDevIns Device instance of the IOAPIC.
1598 */
1599 DECLR3CALLBACKMEMBER(PCPDMIOAPICHLPR0, pfnGetR0Helpers,(PPDMDEVINS pDevIns));
1600
1601 /** Just a safety precaution. */
1602 uint32_t u32TheEnd;
1603} PDMIOAPICHLPR3;
1604/** Pointer to IOAPIC R3 helpers. */
1605typedef R3PTRTYPE(PDMIOAPICHLPR3 *) PPDMIOAPICHLPR3;
1606/** Pointer to const IOAPIC helpers. */
1607typedef R3PTRTYPE(const PDMIOAPICHLPR3 *) PCPDMIOAPICHLPR3;
1608
1609/** Current PDMIOAPICHLPR3 version number. */
1610#define PDM_IOAPICHLPR3_VERSION PDM_VERSION_MAKE(0xffef, 1, 0)
1611
1612
1613/**
1614 * HPET registration structure.
1615 */
1616typedef struct PDMHPETREG
1617{
1618 /** Struct version+magic number (PDM_HPETREG_VERSION). */
1619 uint32_t u32Version;
1620
1621} PDMHPETREG;
1622/** Pointer to an HPET registration structure. */
1623typedef PDMHPETREG *PPDMHPETREG;
1624
1625/** Current PDMHPETREG version number. */
1626#define PDM_HPETREG_VERSION 0x1f010000
1627
1628/**
1629 * HPET RC helpers.
1630 */
1631typedef struct PDMHPETHLPRC
1632{
1633 /** Structure version. PDM_HPETHLPRC_VERSION defines the current version. */
1634 uint32_t u32Version;
1635
1636 /**
1637 * Acquires the PDM lock.
1638 *
1639 * @returns VINF_SUCCESS on success.
1640 * @returns rc if we failed to acquire the lock.
1641 * @param pDevIns The HPET device instance.
1642 * @param rc What to return if we fail to acquire the lock.
1643 */
1644 DECLRCCALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
1645
1646 /**
1647 * Releases the PDM lock.
1648 *
1649 * @param pDevIns The HPET device instance.
1650 */
1651 DECLRCCALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
1652
1653 /** Just a safety precaution. */
1654 uint32_t u32TheEnd;
1655} PDMHPETHLPRC;
1656
1657/** Pointer to HPET RC helpers. */
1658typedef RCPTRTYPE(PDMHPETHLPRC *) PPDMHPETHLPRC;
1659/** Pointer to const HPET RC helpers. */
1660typedef RCPTRTYPE(const PDMHPETHLPRC *) PCPDMHPETHLPRC;
1661
1662/** Current PDMHPETHLPRC version number. */
1663#define PDM_HPETHLPRC_VERSION PDM_VERSION_MAKE(0xffee, 1, 0)
1664
1665
1666/**
1667 * HPET R0 helpers.
1668 */
1669typedef struct PDMHPETHLPR0
1670{
1671 /** Structure version. PDM_HPETHLPR0_VERSION defines the current version. */
1672 uint32_t u32Version;
1673
1674 /**
1675 * Acquires the PDM lock.
1676 *
1677 * @returns VINF_SUCCESS on success.
1678 * @returns rc if we failed to acquire the lock.
1679 * @param pDevIns The HPET device instance.
1680 * @param rc What to return if we fail to acquire the lock.
1681 */
1682 DECLR0CALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
1683
1684 /**
1685 * Releases the PDM lock.
1686 *
1687 * @param pDevIns The HPET device instance.
1688 */
1689 DECLR0CALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
1690
1691 /** Just a safety precaution. */
1692 uint32_t u32TheEnd;
1693} PDMHPETHLPR0;
1694
1695/** Pointer to HPET R0 helpers. */
1696typedef R0PTRTYPE(PDMHPETHLPR0 *) PPDMHPETHLPR0;
1697/** Pointer to const HPET R0 helpers. */
1698typedef R0PTRTYPE(const PDMHPETHLPR0 *) PCPDMHPETHLPR0;
1699
1700/** Current PDMHPETHLPR0 version number. */
1701#define PDM_HPETHLPR0_VERSION PDM_VERSION_MAKE(0xffed, 1, 0)
1702
1703/**
1704 * HPET R3 helpers.
1705 */
1706typedef struct PDMHPETHLPR3
1707{
1708 /** Structure version. PDM_HPETHLP_VERSION defines the current version. */
1709 uint32_t u32Version;
1710
1711 /**
1712 * Set the interrupt force action flag.
1713 *
1714 * @returns VINF_SUCCESS on success.
1715 * @returns rc if we failed to set legacy mode.
1716 * @param pDevIns Device instance of the HPET.
1717 * @param fActivate Activate or deactivate legacy mode.
1718 */
1719 DECLR3CALLBACKMEMBER(int, pfnSetLegacyMode,(PPDMDEVINS pDevIns, bool fActivate));
1720
1721 /**
1722 * Acquires the PDM lock.
1723 *
1724 * @returns VINF_SUCCESS on success.
1725 * @returns rc if we failed to acquire the lock.
1726 * @param pDevIns The HPET device instance.
1727 * @param rc What to return if we fail to acquire the lock.
1728 */
1729 DECLR3CALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
1730
1731 /**
1732 * Releases the PDM lock.
1733 *
1734 * @param pDevIns The HPET device instance.
1735 */
1736 DECLR3CALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
1737
1738 /**
1739 * Gets the address of the RC HPET helpers.
1740 *
1741 * This should be called at both construction and relocation time
1742 * to obtain the correct address of the RC helpers.
1743 *
1744 * @returns RC pointer to the HPET helpers.
1745 * @param pDevIns Device instance of the HPET.
1746 */
1747 DECLR3CALLBACKMEMBER(PCPDMHPETHLPRC, pfnGetRCHelpers,(PPDMDEVINS pDevIns));
1748
1749 /**
1750 * Gets the address of the R0 HPET helpers.
1751 *
1752 * This should be called at both construction and relocation time
1753 * to obtain the correct address of the R0 helpers.
1754 *
1755 * @returns R0 pointer to the HPET helpers.
1756 * @param pDevIns Device instance of the HPET.
1757 */
1758 DECLR3CALLBACKMEMBER(PCPDMHPETHLPR0, pfnGetR0Helpers,(PPDMDEVINS pDevIns));
1759
1760 /** Just a safety precaution. */
1761 uint32_t u32TheEnd;
1762} PDMHPETHLPR3;
1763
1764/** Pointer to HPET R3 helpers. */
1765typedef R3PTRTYPE(PDMHPETHLPR3 *) PPDMHPETHLPR3;
1766/** Pointer to const HPET R3 helpers. */
1767typedef R3PTRTYPE(const PDMHPETHLPR3 *) PCPDMHPETHLPR3;
1768
1769/** Current PDMHPETHLPR3 version number. */
1770#define PDM_HPETHLPR3_VERSION PDM_VERSION_MAKE(0xffec, 1, 0)
1771
1772
1773
1774#ifdef IN_RING3
1775
1776/**
1777 * DMA Transfer Handler.
1778 *
1779 * @returns Number of bytes transferred.
1780 * @param pDevIns Device instance of the DMA.
1781 * @param pvUser User pointer.
1782 * @param uChannel Channel number.
1783 * @param off DMA position.
1784 * @param cb Block size.
1785 */
1786typedef DECLCALLBACK(uint32_t) FNDMATRANSFERHANDLER(PPDMDEVINS pDevIns, void *pvUser, unsigned uChannel, uint32_t off, uint32_t cb);
1787/** Pointer to a FNDMATRANSFERHANDLER(). */
1788typedef FNDMATRANSFERHANDLER *PFNDMATRANSFERHANDLER;
1789
1790/**
1791 * DMA Controller registration structure.
1792 */
1793typedef struct PDMDMAREG
1794{
1795 /** Structure version number. PDM_DMACREG_VERSION defines the current version. */
1796 uint32_t u32Version;
1797
1798 /**
1799 * Execute pending transfers.
1800 *
1801 * @returns A more work indiciator. I.e. 'true' if there is more to be done, and 'false' if all is done.
1802 * @param pDevIns Device instance of the DMAC.
1803 */
1804 DECLR3CALLBACKMEMBER(bool, pfnRun,(PPDMDEVINS pDevIns));
1805
1806 /**
1807 * Register transfer function for DMA channel.
1808 *
1809 * @param pDevIns Device instance of the DMAC.
1810 * @param uChannel Channel number.
1811 * @param pfnTransferHandler Device specific transfer function.
1812 * @param pvUSer User pointer to be passed to the callback.
1813 */
1814 DECLR3CALLBACKMEMBER(void, pfnRegister,(PPDMDEVINS pDevIns, unsigned uChannel, PFNDMATRANSFERHANDLER pfnTransferHandler, void *pvUser));
1815
1816 /**
1817 * Read memory
1818 *
1819 * @returns Number of bytes read.
1820 * @param pDevIns Device instance of the DMAC.
1821 * @param pvBuffer Pointer to target buffer.
1822 * @param off DMA position.
1823 * @param cbBlock Block size.
1824 */
1825 DECLR3CALLBACKMEMBER(uint32_t, pfnReadMemory,(PPDMDEVINS pDevIns, unsigned uChannel, void *pvBuffer, uint32_t off, uint32_t cbBlock));
1826
1827 /**
1828 * Write memory
1829 *
1830 * @returns Number of bytes written.
1831 * @param pDevIns Device instance of the DMAC.
1832 * @param pvBuffer Memory to write.
1833 * @param off DMA position.
1834 * @param cbBlock Block size.
1835 */
1836 DECLR3CALLBACKMEMBER(uint32_t, pfnWriteMemory,(PPDMDEVINS pDevIns, unsigned uChannel, const void *pvBuffer, uint32_t off, uint32_t cbBlock));
1837
1838 /**
1839 * Set the DREQ line.
1840 *
1841 * @param pDevIns Device instance of the DMAC.
1842 * @param uChannel Channel number.
1843 * @param uLevel Level of the line.
1844 */
1845 DECLR3CALLBACKMEMBER(void, pfnSetDREQ,(PPDMDEVINS pDevIns, unsigned uChannel, unsigned uLevel));
1846
1847 /**
1848 * Get channel mode
1849 *
1850 * @returns Channel mode.
1851 * @param pDevIns Device instance of the DMAC.
1852 * @param uChannel Channel number.
1853 */
1854 DECLR3CALLBACKMEMBER(uint8_t, pfnGetChannelMode,(PPDMDEVINS pDevIns, unsigned uChannel));
1855
1856} PDMDMACREG;
1857/** Pointer to a DMAC registration structure. */
1858typedef PDMDMACREG *PPDMDMACREG;
1859
1860/** Current PDMDMACREG version number. */
1861#define PDM_DMACREG_VERSION PDM_VERSION_MAKE(0xffeb, 1, 0)
1862
1863
1864/**
1865 * DMA Controller device helpers.
1866 */
1867typedef struct PDMDMACHLP
1868{
1869 /** Structure version. PDM_DMACHLP_VERSION defines the current version. */
1870 uint32_t u32Version;
1871
1872 /* to-be-defined */
1873
1874} PDMDMACHLP;
1875/** Pointer to DMAC helpers. */
1876typedef PDMDMACHLP *PPDMDMACHLP;
1877/** Pointer to const DMAC helpers. */
1878typedef const PDMDMACHLP *PCPDMDMACHLP;
1879
1880/** Current PDMDMACHLP version number. */
1881#define PDM_DMACHLP_VERSION PDM_VERSION_MAKE(0xffea, 1, 0)
1882
1883#endif /* IN_RING3 */
1884
1885
1886
1887/**
1888 * RTC registration structure.
1889 */
1890typedef struct PDMRTCREG
1891{
1892 /** Structure version number. PDM_RTCREG_VERSION defines the current version. */
1893 uint32_t u32Version;
1894 uint32_t u32Alignment; /**< structure size alignment. */
1895
1896 /**
1897 * Write to a CMOS register and update the checksum if necessary.
1898 *
1899 * @returns VBox status code.
1900 * @param pDevIns Device instance of the RTC.
1901 * @param iReg The CMOS register index.
1902 * @param u8Value The CMOS register value.
1903 */
1904 DECLR3CALLBACKMEMBER(int, pfnWrite,(PPDMDEVINS pDevIns, unsigned iReg, uint8_t u8Value));
1905
1906 /**
1907 * Read a CMOS register.
1908 *
1909 * @returns VBox status code.
1910 * @param pDevIns Device instance of the RTC.
1911 * @param iReg The CMOS register index.
1912 * @param pu8Value Where to store the CMOS register value.
1913 */
1914 DECLR3CALLBACKMEMBER(int, pfnRead,(PPDMDEVINS pDevIns, unsigned iReg, uint8_t *pu8Value));
1915
1916} PDMRTCREG;
1917/** Pointer to a RTC registration structure. */
1918typedef PDMRTCREG *PPDMRTCREG;
1919/** Pointer to a const RTC registration structure. */
1920typedef const PDMRTCREG *PCPDMRTCREG;
1921
1922/** Current PDMRTCREG version number. */
1923#define PDM_RTCREG_VERSION PDM_VERSION_MAKE(0xffe9, 1, 0)
1924
1925
1926/**
1927 * RTC device helpers.
1928 */
1929typedef struct PDMRTCHLP
1930{
1931 /** Structure version. PDM_RTCHLP_VERSION defines the current version. */
1932 uint32_t u32Version;
1933
1934 /* to-be-defined */
1935
1936} PDMRTCHLP;
1937/** Pointer to RTC helpers. */
1938typedef PDMRTCHLP *PPDMRTCHLP;
1939/** Pointer to const RTC helpers. */
1940typedef const PDMRTCHLP *PCPDMRTCHLP;
1941
1942/** Current PDMRTCHLP version number. */
1943#define PDM_RTCHLP_VERSION PDM_VERSION_MAKE(0xffe8, 1, 0)
1944
1945
1946
1947#ifdef IN_RING3
1948
1949/**
1950 * PDM Device API.
1951 */
1952typedef struct PDMDEVHLPR3
1953{
1954 /** Structure version. PDM_DEVHLP_VERSION defines the current version. */
1955 uint32_t u32Version;
1956
1957 /**
1958 * Register a number of I/O ports with a device.
1959 *
1960 * These callbacks are of course for the host context (HC).
1961 * Register HC handlers before guest context (GC) handlers! There must be a
1962 * HC handler for every GC handler!
1963 *
1964 * @returns VBox status.
1965 * @param pDevIns The device instance to register the ports with.
1966 * @param Port First port number in the range.
1967 * @param cPorts Number of ports to register.
1968 * @param pvUser User argument.
1969 * @param pfnOut Pointer to function which is gonna handle OUT operations.
1970 * @param pfnIn Pointer to function which is gonna handle IN operations.
1971 * @param pfnOutStr Pointer to function which is gonna handle string OUT operations.
1972 * @param pfnInStr Pointer to function which is gonna handle string IN operations.
1973 * @param pszDesc Pointer to description string. This must not be freed.
1974 */
1975 DECLR3CALLBACKMEMBER(int, pfnIOPortRegister,(PPDMDEVINS pDevIns, RTIOPORT Port, RTUINT cPorts, RTHCPTR pvUser,
1976 PFNIOMIOPORTOUT pfnOut, PFNIOMIOPORTIN pfnIn,
1977 PFNIOMIOPORTOUTSTRING pfnOutStr, PFNIOMIOPORTINSTRING pfnInStr, const char *pszDesc));
1978
1979 /**
1980 * Register a number of I/O ports with a device for RC.
1981 *
1982 * These callbacks are for the raw-mode context (RC). Register ring-3 context
1983 * (R3) handlers before raw-mode context handlers! There must be a R3 handler
1984 * for every RC handler!
1985 *
1986 * @returns VBox status.
1987 * @param pDevIns The device instance to register the ports with
1988 * and which RC module to resolve the names
1989 * against.
1990 * @param Port First port number in the range.
1991 * @param cPorts Number of ports to register.
1992 * @param pvUser User argument.
1993 * @param pszOut Name of the RC function which is gonna handle OUT operations.
1994 * @param pszIn Name of the RC function which is gonna handle IN operations.
1995 * @param pszOutStr Name of the RC function which is gonna handle string OUT operations.
1996 * @param pszInStr Name of the RC function which is gonna handle string IN operations.
1997 * @param pszDesc Pointer to description string. This must not be freed.
1998 */
1999 DECLR3CALLBACKMEMBER(int, pfnIOPortRegisterRC,(PPDMDEVINS pDevIns, RTIOPORT Port, RTUINT cPorts, RTRCPTR pvUser,
2000 const char *pszOut, const char *pszIn,
2001 const char *pszOutStr, const char *pszInStr, const char *pszDesc));
2002
2003 /**
2004 * Register a number of I/O ports with a device.
2005 *
2006 * These callbacks are of course for the ring-0 host context (R0).
2007 * Register R3 (HC) handlers before R0 (R0) handlers! There must be a R3 (HC) handler for every R0 handler!
2008 *
2009 * @returns VBox status.
2010 * @param pDevIns The device instance to register the ports with.
2011 * @param Port First port number in the range.
2012 * @param cPorts Number of ports to register.
2013 * @param pvUser User argument. (if pointer, then it must be in locked memory!)
2014 * @param pszOut Name of the R0 function which is gonna handle OUT operations.
2015 * @param pszIn Name of the R0 function which is gonna handle IN operations.
2016 * @param pszOutStr Name of the R0 function which is gonna handle string OUT operations.
2017 * @param pszInStr Name of the R0 function which is gonna handle string IN operations.
2018 * @param pszDesc Pointer to description string. This must not be freed.
2019 */
2020 DECLR3CALLBACKMEMBER(int, pfnIOPortRegisterR0,(PPDMDEVINS pDevIns, RTIOPORT Port, RTUINT cPorts, RTR0PTR pvUser,
2021 const char *pszOut, const char *pszIn,
2022 const char *pszOutStr, const char *pszInStr, const char *pszDesc));
2023
2024 /**
2025 * Deregister I/O ports.
2026 *
2027 * This naturally affects both guest context (GC), ring-0 (R0) and ring-3 (R3/HC) handlers.
2028 *
2029 * @returns VBox status.
2030 * @param pDevIns The device instance owning the ports.
2031 * @param Port First port number in the range.
2032 * @param cPorts Number of ports to deregister.
2033 */
2034 DECLR3CALLBACKMEMBER(int, pfnIOPortDeregister,(PPDMDEVINS pDevIns, RTIOPORT Port, RTUINT cPorts));
2035
2036 /**
2037 * Register a Memory Mapped I/O (MMIO) region.
2038 *
2039 * These callbacks are of course for the ring-3 context (R3). Register HC
2040 * handlers before raw-mode context (RC) and ring-0 context (R0) handlers! There
2041 * must be a R3 handler for every RC and R0 handler!
2042 *
2043 * @returns VBox status.
2044 * @param pDevIns The device instance to register the MMIO with.
2045 * @param GCPhysStart First physical address in the range.
2046 * @param cbRange The size of the range (in bytes).
2047 * @param pvUser User argument.
2048 * @param pfnWrite Pointer to function which is gonna handle Write operations.
2049 * @param pfnRead Pointer to function which is gonna handle Read operations.
2050 * @param pfnFill Pointer to function which is gonna handle Fill/memset operations. (optional)
2051 * @param pszDesc Pointer to description string. This must not be freed.
2052 */
2053 DECLR3CALLBACKMEMBER(int, pfnMMIORegister,(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, RTHCPTR pvUser,
2054 PFNIOMMMIOWRITE pfnWrite, PFNIOMMMIOREAD pfnRead, PFNIOMMMIOFILL pfnFill,
2055 const char *pszDesc));
2056
2057 /**
2058 * Register a Memory Mapped I/O (MMIO) region for GC.
2059 *
2060 * These callbacks are for the raw-mode context (RC). Register ring-3 context
2061 * (R3) handlers before guest context handlers! There must be a R3 handler for
2062 * every RC handler!
2063 *
2064 * @returns VBox status.
2065 * @param pDevIns The device instance to register the MMIO with.
2066 * @param GCPhysStart First physical address in the range.
2067 * @param cbRange The size of the range (in bytes).
2068 * @param pvUser User argument.
2069 * @param pszWrite Name of the RC function which is gonna handle Write operations.
2070 * @param pszRead Name of the RC function which is gonna handle Read operations.
2071 * @param pszFill Name of the RC function which is gonna handle Fill/memset operations. (optional)
2072 * @param pszDesc Obsolete. NULL is fine.
2073 * @todo Remove pszDesc in the next major revision of PDMDEVHLPR3.
2074 */
2075 DECLR3CALLBACKMEMBER(int, pfnMMIORegisterRC,(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, RTGCPTR pvUser,
2076 const char *pszWrite, const char *pszRead, const char *pszFill,
2077 const char *pszDesc));
2078
2079 /**
2080 * Register a Memory Mapped I/O (MMIO) region for R0.
2081 *
2082 * These callbacks are for the ring-0 host context (R0). Register ring-3
2083 * constext (R3) handlers before R0 handlers! There must be a R3 handler for
2084 * every R0 handler!
2085 *
2086 * @returns VBox status.
2087 * @param pDevIns The device instance to register the MMIO with.
2088 * @param GCPhysStart First physical address in the range.
2089 * @param cbRange The size of the range (in bytes).
2090 * @param pvUser User argument. (if pointer, then it must be in locked memory!)
2091 * @param pszWrite Name of the RC function which is gonna handle Write operations.
2092 * @param pszRead Name of the RC function which is gonna handle Read operations.
2093 * @param pszFill Name of the RC function which is gonna handle Fill/memset operations. (optional)
2094 * @param pszDesc Obsolete. NULL is fine.
2095 * @todo Remove pszDesc in the next major revision of PDMDEVHLPR3.
2096 */
2097 DECLR3CALLBACKMEMBER(int, pfnMMIORegisterR0,(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, RTR0PTR pvUser,
2098 const char *pszWrite, const char *pszRead, const char *pszFill,
2099 const char *pszDesc));
2100
2101 /**
2102 * Deregister a Memory Mapped I/O (MMIO) region.
2103 *
2104 * This naturally affects both guest context (GC), ring-0 (R0) and ring-3 (R3/HC) handlers.
2105 *
2106 * @returns VBox status.
2107 * @param pDevIns The device instance owning the MMIO region(s).
2108 * @param GCPhysStart First physical address in the range.
2109 * @param cbRange The size of the range (in bytes).
2110 */
2111 DECLR3CALLBACKMEMBER(int, pfnMMIODeregister,(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange));
2112
2113 /**
2114 * Allocate and register a MMIO2 region.
2115 *
2116 * As mentioned elsewhere, MMIO2 is just RAM spelled differently. It's
2117 * RAM associated with a device. It is also non-shared memory with a
2118 * permanent ring-3 mapping and page backing (presently).
2119 *
2120 * @returns VBox status.
2121 * @param pDevIns The device instance.
2122 * @param iRegion The region number. Use the PCI region number as
2123 * this must be known to the PCI bus device too. If
2124 * it's not associated with the PCI device, then
2125 * any number up to UINT8_MAX is fine.
2126 * @param cb The size (in bytes) of the region.
2127 * @param fFlags Reserved for future use, must be zero.
2128 * @param ppv Where to store the address of the ring-3 mapping
2129 * of the memory.
2130 * @param pszDesc Pointer to description string. This must not be
2131 * freed.
2132 * @thread EMT.
2133 */
2134 DECLR3CALLBACKMEMBER(int, pfnMMIO2Register,(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS cb, uint32_t fFlags, void **ppv, const char *pszDesc));
2135
2136 /**
2137 * Deregisters and frees a MMIO2 region.
2138 *
2139 * Any physical (and virtual) access handlers registered for the region must
2140 * be deregistered before calling this function.
2141 *
2142 * @returns VBox status code.
2143 * @param pDevIns The device instance.
2144 * @param iRegion The region number used during registration.
2145 * @thread EMT.
2146 */
2147 DECLR3CALLBACKMEMBER(int, pfnMMIO2Deregister,(PPDMDEVINS pDevIns, uint32_t iRegion));
2148
2149 /**
2150 * Maps a MMIO2 region into the physical memory space.
2151 *
2152 * A MMIO2 range may overlap with base memory if a lot of RAM
2153 * is configured for the VM, in which case we'll drop the base
2154 * memory pages. Presently we will make no attempt to preserve
2155 * anything that happens to be present in the base memory that
2156 * is replaced, this is of course incorrectly but it's too much
2157 * effort.
2158 *
2159 * @returns VBox status code.
2160 * @param pDevIns The device instance.
2161 * @param iRegion The region number used during registration.
2162 * @param GCPhys The physical address to map it at.
2163 * @thread EMT.
2164 */
2165 DECLR3CALLBACKMEMBER(int, pfnMMIO2Map,(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS GCPhys));
2166
2167 /**
2168 * Unmaps a MMIO2 region previously mapped using pfnMMIO2Map.
2169 *
2170 * @returns VBox status code.
2171 * @param pDevIns The device instance.
2172 * @param iRegion The region number used during registration.
2173 * @param GCPhys The physical address it's currently mapped at.
2174 * @thread EMT.
2175 */
2176 DECLR3CALLBACKMEMBER(int, pfnMMIO2Unmap,(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS GCPhys));
2177
2178 /**
2179 * Maps a portion of an MMIO2 region into the hypervisor region.
2180 *
2181 * Callers of this API must never deregister the MMIO2 region before the
2182 * VM is powered off.
2183 *
2184 * @return VBox status code.
2185 * @param pDevIns The device owning the MMIO2 memory.
2186 * @param iRegion The region.
2187 * @param off The offset into the region. Will be rounded down
2188 * to closest page boundrary.
2189 * @param cb The number of bytes to map. Will be rounded up
2190 * to the closest page boundrary.
2191 * @param pszDesc Mapping description.
2192 * @param pRCPtr Where to store the RC address.
2193 */
2194 DECLR3CALLBACKMEMBER(int, pfnMMHyperMapMMIO2,(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS off, RTGCPHYS cb,
2195 const char *pszDesc, PRTRCPTR pRCPtr));
2196
2197 /**
2198 * Maps a portion of an MMIO2 region into kernel space (host).
2199 *
2200 * The kernel mapping will become invalid when the MMIO2 memory is deregistered
2201 * or the VM is terminated.
2202 *
2203 * @return VBox status code.
2204 * @param pDevIns The device owning the MMIO2 memory.
2205 * @param iRegion The region.
2206 * @param off The offset into the region. Must be page
2207 * aligned.
2208 * @param cb The number of bytes to map. Must be page
2209 * aligned.
2210 * @param pszDesc Mapping description.
2211 * @param pR0Ptr Where to store the R0 address.
2212 */
2213 DECLR3CALLBACKMEMBER(int, pfnMMIO2MapKernel,(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS off, RTGCPHYS cb,
2214 const char *pszDesc, PRTR0PTR pR0Ptr));
2215
2216 /**
2217 * Register a ROM (BIOS) region.
2218 *
2219 * It goes without saying that this is read-only memory. The memory region must be
2220 * in unassigned memory. I.e. from the top of the address space or on the PC in
2221 * the 0xa0000-0xfffff range.
2222 *
2223 * @returns VBox status.
2224 * @param pDevIns The device instance owning the ROM region.
2225 * @param GCPhysStart First physical address in the range.
2226 * Must be page aligned!
2227 * @param cbRange The size of the range (in bytes).
2228 * Must be page aligned!
2229 * @param pvBinary Pointer to the binary data backing the ROM image.
2230 * This must be cbRange bytes big.
2231 * It will be copied and doesn't have to stick around if fShadow is clear.
2232 * @param fFlags Shadow ROM flags, PGMPHYS_ROM_FLAGS_* in pgm.h.
2233 * @param pszDesc Pointer to description string. This must not be freed.
2234 *
2235 * @remark There is no way to remove the rom, automatically on device cleanup or
2236 * manually from the device yet. At present I doubt we need such features...
2237 */
2238 DECLR3CALLBACKMEMBER(int, pfnROMRegister,(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, const void *pvBinary, uint32_t fFlags, const char *pszDesc));
2239
2240 /**
2241 * Changes the protection of shadowed ROM mapping.
2242 *
2243 * This is intented for use by the system BIOS, chipset or device in question to
2244 * change the protection of shadowed ROM code after init and on reset.
2245 *
2246 * @param pDevIns The device instance.
2247 * @param GCPhysStart Where the mapping starts.
2248 * @param cbRange The size of the mapping.
2249 * @param enmProt The new protection type.
2250 */
2251 DECLR3CALLBACKMEMBER(int, pfnROMProtectShadow,(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, PGMROMPROT enmProt));
2252
2253 /**
2254 * Register a save state data unit.
2255 *
2256 * @returns VBox status.
2257 * @param pDevIns The device instance.
2258 * @param pszName Data unit name.
2259 * @param uInstance The instance identifier of the data unit.
2260 * This must together with the name be unique.
2261 * @param uVersion Data layout version number.
2262 * @param cbGuess The approximate amount of data in the unit.
2263 * Only for progress indicators.
2264 * @param pszBefore Name of data unit which we should be put in
2265 * front of. Optional (NULL).
2266 *
2267 * @param pfnLivePrep Prepare live save callback, optional.
2268 * @param pfnLiveExec Execute live save callback, optional.
2269 * @param pfnLiveVote Vote live save callback, optional.
2270 *
2271 * @param pfnSavePrep Prepare save callback, optional.
2272 * @param pfnSaveExec Execute save callback, optional.
2273 * @param pfnSaveDone Done save callback, optional.
2274 *
2275 * @param pfnLoadPrep Prepare load callback, optional.
2276 * @param pfnLoadExec Execute load callback, optional.
2277 * @param pfnLoadDone Done load callback, optional.
2278 */
2279 DECLR3CALLBACKMEMBER(int, pfnSSMRegister,(PPDMDEVINS pDevIns, uint32_t uVersion, size_t cbGuess, const char *pszBefore,
2280 PFNSSMDEVLIVEPREP pfnLivePrep, PFNSSMDEVLIVEEXEC pfnLiveExec, PFNSSMDEVLIVEVOTE pfnLiveVote,
2281 PFNSSMDEVSAVEPREP pfnSavePrep, PFNSSMDEVSAVEEXEC pfnSaveExec, PFNSSMDEVSAVEDONE pfnSaveDone,
2282 PFNSSMDEVLOADPREP pfnLoadPrep, PFNSSMDEVLOADEXEC pfnLoadExec, PFNSSMDEVLOADDONE pfnLoadDone));
2283
2284 /**
2285 * Creates a timer.
2286 *
2287 * @returns VBox status.
2288 * @param pDevIns The device instance.
2289 * @param enmClock The clock to use on this timer.
2290 * @param pfnCallback Callback function.
2291 * @param pvUser User argument for the callback.
2292 * @param fFlags Flags, see TMTIMER_FLAGS_*.
2293 * @param pszDesc Pointer to description string which must stay around
2294 * until the timer is fully destroyed (i.e. a bit after TMTimerDestroy()).
2295 * @param ppTimer Where to store the timer on success.
2296 */
2297 DECLR3CALLBACKMEMBER(int, pfnTMTimerCreate,(PPDMDEVINS pDevIns, TMCLOCK enmClock, PFNTMTIMERDEV pfnCallback, void *pvUser, uint32_t fFlags, const char *pszDesc, PPTMTIMERR3 ppTimer));
2298
2299 /**
2300 * Get the real world UTC time adjusted for VM lag, user offset and warpdrive.
2301 *
2302 * @returns pTime.
2303 * @param pDevIns The device instance.
2304 * @param pTime Where to store the time.
2305 */
2306 DECLR3CALLBACKMEMBER(PRTTIMESPEC, pfnTMUtcNow,(PPDMDEVINS pDevIns, PRTTIMESPEC pTime));
2307
2308 /**
2309 * Read physical memory.
2310 *
2311 * @returns VINF_SUCCESS (for now).
2312 * @param pDevIns The device instance.
2313 * @param GCPhys Physical address start reading from.
2314 * @param pvBuf Where to put the read bits.
2315 * @param cbRead How many bytes to read.
2316 * @thread Any thread, but the call may involve the emulation thread.
2317 */
2318 DECLR3CALLBACKMEMBER(int, pfnPhysRead,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead));
2319
2320 /**
2321 * Write to physical memory.
2322 *
2323 * @returns VINF_SUCCESS for now, and later maybe VERR_EM_MEMORY.
2324 * @param pDevIns The device instance.
2325 * @param GCPhys Physical address to write to.
2326 * @param pvBuf What to write.
2327 * @param cbWrite How many bytes to write.
2328 * @thread Any thread, but the call may involve the emulation thread.
2329 */
2330 DECLR3CALLBACKMEMBER(int, pfnPhysWrite,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite));
2331
2332 /**
2333 * Requests the mapping of a guest page into ring-3.
2334 *
2335 * When you're done with the page, call pfnPhysReleasePageMappingLock() ASAP to
2336 * release it.
2337 *
2338 * This API will assume your intention is to write to the page, and will
2339 * therefore replace shared and zero pages. If you do not intend to modify the
2340 * page, use the pfnPhysGCPhys2CCPtrReadOnly() API.
2341 *
2342 * @returns VBox status code.
2343 * @retval VINF_SUCCESS on success.
2344 * @retval VERR_PGM_PHYS_PAGE_RESERVED it it's a valid page but has no physical
2345 * backing or if the page has any active access handlers. The caller
2346 * must fall back on using PGMR3PhysWriteExternal.
2347 * @retval VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS if it's not a valid physical address.
2348 *
2349 * @param pVM The VM handle.
2350 * @param GCPhys The guest physical address of the page that
2351 * should be mapped.
2352 * @param fFlags Flags reserved for future use, MBZ.
2353 * @param ppv Where to store the address corresponding to
2354 * GCPhys.
2355 * @param pLock Where to store the lock information that
2356 * pfnPhysReleasePageMappingLock needs.
2357 *
2358 * @remark Avoid calling this API from within critical sections (other than the
2359 * PGM one) because of the deadlock risk when we have to delegating the
2360 * task to an EMT.
2361 * @thread Any.
2362 */
2363 DECLR3CALLBACKMEMBER(int, pfnPhysGCPhys2CCPtr,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, uint32_t fFlags, void **ppv, PPGMPAGEMAPLOCK pLock));
2364
2365 /**
2366 * Requests the mapping of a guest page into ring-3, external threads.
2367 *
2368 * When you're done with the page, call pfnPhysReleasePageMappingLock() ASAP to
2369 * release it.
2370 *
2371 * @returns VBox status code.
2372 * @retval VINF_SUCCESS on success.
2373 * @retval VERR_PGM_PHYS_PAGE_RESERVED it it's a valid page but has no physical
2374 * backing or if the page as an active ALL access handler. The caller
2375 * must fall back on using PGMPhysRead.
2376 * @retval VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS if it's not a valid physical address.
2377 *
2378 * @param pDevIns The device instance.
2379 * @param GCPhys The guest physical address of the page that
2380 * should be mapped.
2381 * @param fFlags Flags reserved for future use, MBZ.
2382 * @param ppv Where to store the address corresponding to
2383 * GCPhys.
2384 * @param pLock Where to store the lock information that
2385 * pfnPhysReleasePageMappingLock needs.
2386 *
2387 * @remark Avoid calling this API from within critical sections.
2388 * @thread Any.
2389 */
2390 DECLR3CALLBACKMEMBER(int, pfnPhysGCPhys2CCPtrReadOnly,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, uint32_t fFlags, void const **ppv, PPGMPAGEMAPLOCK pLock));
2391
2392 /**
2393 * Release the mapping of a guest page.
2394 *
2395 * This is the counter part of pfnPhysGCPhys2CCPtr and
2396 * pfnPhysGCPhys2CCPtrReadOnly.
2397 *
2398 * @param pDevIns The device instance.
2399 * @param pLock The lock structure initialized by the mapping
2400 * function.
2401 */
2402 DECLR3CALLBACKMEMBER(void, pfnPhysReleasePageMappingLock,(PPDMDEVINS pDevIns, PPGMPAGEMAPLOCK pLock));
2403
2404 /**
2405 * Read guest physical memory by virtual address.
2406 *
2407 * @param pDevIns The device instance.
2408 * @param pvDst Where to put the read bits.
2409 * @param GCVirtSrc Guest virtual address to start reading from.
2410 * @param cb How many bytes to read.
2411 * @thread The emulation thread.
2412 */
2413 DECLR3CALLBACKMEMBER(int, pfnPhysReadGCVirt,(PPDMDEVINS pDevIns, void *pvDst, RTGCPTR GCVirtSrc, size_t cb));
2414
2415 /**
2416 * Write to guest physical memory by virtual address.
2417 *
2418 * @param pDevIns The device instance.
2419 * @param GCVirtDst Guest virtual address to write to.
2420 * @param pvSrc What to write.
2421 * @param cb How many bytes to write.
2422 * @thread The emulation thread.
2423 */
2424 DECLR3CALLBACKMEMBER(int, pfnPhysWriteGCVirt,(PPDMDEVINS pDevIns, RTGCPTR GCVirtDst, const void *pvSrc, size_t cb));
2425
2426 /**
2427 * Convert a guest virtual address to a guest physical address.
2428 *
2429 * @returns VBox status code.
2430 * @param pDevIns The device instance.
2431 * @param GCPtr Guest virtual address.
2432 * @param pGCPhys Where to store the GC physical address
2433 * corresponding to GCPtr.
2434 * @thread The emulation thread.
2435 * @remark Careful with page boundraries.
2436 */
2437 DECLR3CALLBACKMEMBER(int, pfnPhysGCPtr2GCPhys, (PPDMDEVINS pDevIns, RTGCPTR GCPtr, PRTGCPHYS pGCPhys));
2438
2439 /**
2440 * Allocate memory which is associated with current VM instance
2441 * and automatically freed on it's destruction.
2442 *
2443 * @returns Pointer to allocated memory. The memory is *NOT* zero-ed.
2444 * @param pDevIns The device instance.
2445 * @param cb Number of bytes to allocate.
2446 */
2447 DECLR3CALLBACKMEMBER(void *, pfnMMHeapAlloc,(PPDMDEVINS pDevIns, size_t cb));
2448
2449 /**
2450 * Allocate memory which is associated with current VM instance
2451 * and automatically freed on it's destruction. The memory is ZEROed.
2452 *
2453 * @returns Pointer to allocated memory. The memory is *NOT* zero-ed.
2454 * @param pDevIns The device instance.
2455 * @param cb Number of bytes to allocate.
2456 */
2457 DECLR3CALLBACKMEMBER(void *, pfnMMHeapAllocZ,(PPDMDEVINS pDevIns, size_t cb));
2458
2459 /**
2460 * Free memory allocated with pfnMMHeapAlloc() and pfnMMHeapAllocZ().
2461 *
2462 * @param pDevIns The device instance.
2463 * @param pv Pointer to the memory to free.
2464 */
2465 DECLR3CALLBACKMEMBER(void, pfnMMHeapFree,(PPDMDEVINS pDevIns, void *pv));
2466
2467 /**
2468 * Gets the VM state.
2469 *
2470 * @returns VM state.
2471 * @param pDevIns The device instance.
2472 * @thread Any thread (just keep in mind that it's volatile info).
2473 */
2474 DECLR3CALLBACKMEMBER(VMSTATE, pfnVMState, (PPDMDEVINS pDevIns));
2475
2476 /**
2477 * Checks if the VM was teleported and hasn't been fully resumed yet.
2478 *
2479 * @returns true / false.
2480 * @param pDevIns The device instance.
2481 * @thread Any thread.
2482 */
2483 DECLR3CALLBACKMEMBER(bool, pfnVMTeleportedAndNotFullyResumedYet,(PPDMDEVINS pDevIns));
2484
2485 /**
2486 * Set the VM error message
2487 *
2488 * @returns rc.
2489 * @param pDevIns The device instance.
2490 * @param rc VBox status code.
2491 * @param RT_SRC_POS_DECL Use RT_SRC_POS.
2492 * @param pszFormat Error message format string.
2493 * @param ... Error message arguments.
2494 */
2495 DECLR3CALLBACKMEMBER(int, pfnVMSetError,(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...));
2496
2497 /**
2498 * Set the VM error message
2499 *
2500 * @returns rc.
2501 * @param pDevIns The device instance.
2502 * @param rc VBox status code.
2503 * @param RT_SRC_POS_DECL Use RT_SRC_POS.
2504 * @param pszFormat Error message format string.
2505 * @param va Error message arguments.
2506 */
2507 DECLR3CALLBACKMEMBER(int, pfnVMSetErrorV,(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va));
2508
2509 /**
2510 * Set the VM runtime error message
2511 *
2512 * @returns VBox status code.
2513 * @param pDevIns The device instance.
2514 * @param fFlags The action flags. See VMSETRTERR_FLAGS_*.
2515 * @param pszErrorId Error ID string.
2516 * @param pszFormat Error message format string.
2517 * @param ... Error message arguments.
2518 */
2519 DECLR3CALLBACKMEMBER(int, pfnVMSetRuntimeError,(PPDMDEVINS pDevIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, ...));
2520
2521 /**
2522 * Set the VM runtime error message
2523 *
2524 * @returns VBox status code.
2525 * @param pDevIns The device instance.
2526 * @param fFlags The action flags. See VMSETRTERR_FLAGS_*.
2527 * @param pszErrorId Error ID string.
2528 * @param pszFormat Error message format string.
2529 * @param va Error message arguments.
2530 */
2531 DECLR3CALLBACKMEMBER(int, pfnVMSetRuntimeErrorV,(PPDMDEVINS pDevIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, va_list va));
2532
2533 /**
2534 * Stops the VM and enters the debugger to look at the guest state.
2535 *
2536 * Use the PDMDeviceDBGFStop() inline function with the RT_SRC_POS macro instead of
2537 * invoking this function directly.
2538 *
2539 * @returns VBox status code which must be passed up to the VMM.
2540 * @param pDevIns The device instance.
2541 * @param pszFile Filename of the assertion location.
2542 * @param iLine The linenumber of the assertion location.
2543 * @param pszFunction Function of the assertion location.
2544 * @param pszFormat Message. (optional)
2545 * @param args Message parameters.
2546 */
2547 DECLR3CALLBACKMEMBER(int, pfnDBGFStopV,(PPDMDEVINS pDevIns, const char *pszFile, unsigned iLine, const char *pszFunction, const char *pszFormat, va_list args));
2548
2549 /**
2550 * Register a info handler with DBGF,
2551 *
2552 * @returns VBox status code.
2553 * @param pDevIns The device instance.
2554 * @param pszName The identifier of the info.
2555 * @param pszDesc The description of the info and any arguments
2556 * the handler may take.
2557 * @param pfnHandler The handler function to be called to display the
2558 * info.
2559 */
2560 DECLR3CALLBACKMEMBER(int, pfnDBGFInfoRegister,(PPDMDEVINS pDevIns, const char *pszName, const char *pszDesc, PFNDBGFHANDLERDEV pfnHandler));
2561
2562 /**
2563 * Registers a statistics sample if statistics are enabled.
2564 *
2565 * @param pDevIns Device instance of the DMA.
2566 * @param pvSample Pointer to the sample.
2567 * @param enmType Sample type. This indicates what pvSample is
2568 * pointing at.
2569 * @param pszName Sample name. The name is on this form
2570 * "/<component>/<sample>". Further nesting is
2571 * possible.
2572 * @param enmUnit Sample unit.
2573 * @param pszDesc Sample description.
2574 */
2575 DECLR3CALLBACKMEMBER(void, pfnSTAMRegister,(PPDMDEVINS pDevIns, void *pvSample, STAMTYPE enmType, const char *pszName, STAMUNIT enmUnit, const char *pszDesc));
2576
2577 /**
2578 * Same as pfnSTAMRegister except that the name is specified in a
2579 * RTStrPrintf like fashion.
2580 *
2581 * @returns VBox status.
2582 * @param pDevIns Device instance of the DMA.
2583 * @param pvSample Pointer to the sample.
2584 * @param enmType Sample type. This indicates what pvSample is
2585 * pointing at.
2586 * @param enmVisibility Visibility type specifying whether unused
2587 * statistics should be visible or not.
2588 * @param enmUnit Sample unit.
2589 * @param pszDesc Sample description.
2590 * @param pszName The sample name format string.
2591 * @param ... Arguments to the format string.
2592 */
2593 DECLR3CALLBACKMEMBER(void, pfnSTAMRegisterF,(PPDMDEVINS pDevIns, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility,
2594 STAMUNIT enmUnit, const char *pszDesc, const char *pszName, ...));
2595
2596 /**
2597 * Same as pfnSTAMRegister except that the name is specified in a
2598 * RTStrPrintfV like fashion.
2599 *
2600 * @returns VBox status.
2601 * @param pDevIns Device instance of the DMA.
2602 * @param pvSample Pointer to the sample.
2603 * @param enmType Sample type. This indicates what pvSample is
2604 * pointing at.
2605 * @param enmVisibility Visibility type specifying whether unused
2606 * statistics should be visible or not.
2607 * @param enmUnit Sample unit.
2608 * @param pszDesc Sample description.
2609 * @param pszName The sample name format string.
2610 * @param args Arguments to the format string.
2611 */
2612 DECLR3CALLBACKMEMBER(void, pfnSTAMRegisterV,(PPDMDEVINS pDevIns, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility,
2613 STAMUNIT enmUnit, const char *pszDesc, const char *pszName, va_list args));
2614
2615 /**
2616 * Registers the device with the default PCI bus.
2617 *
2618 * @returns VBox status code.
2619 * @param pDevIns The device instance.
2620 * @param pPciDev The PCI device structure.
2621 * Any PCI enabled device must keep this in it's instance data!
2622 * Fill in the PCI data config before registration, please.
2623 * @remark This is the simple interface, a Ex interface will be created if
2624 * more features are needed later.
2625 */
2626 DECLR3CALLBACKMEMBER(int, pfnPCIRegister,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev));
2627
2628 /**
2629 * Registers a I/O region (memory mapped or I/O ports) for a PCI device.
2630 *
2631 * @returns VBox status code.
2632 * @param pDevIns The device instance.
2633 * @param iRegion The region number.
2634 * @param cbRegion Size of the region.
2635 * @param enmType PCI_ADDRESS_SPACE_MEM, PCI_ADDRESS_SPACE_IO or PCI_ADDRESS_SPACE_MEM_PREFETCH.
2636 * @param pfnCallback Callback for doing the mapping.
2637 */
2638 DECLR3CALLBACKMEMBER(int, pfnPCIIORegionRegister,(PPDMDEVINS pDevIns, int iRegion, uint32_t cbRegion, PCIADDRESSSPACE enmType, PFNPCIIOREGIONMAP pfnCallback));
2639
2640 /**
2641 * Register PCI configuration space read/write callbacks.
2642 *
2643 * @param pDevIns The device instance.
2644 * @param pPciDev The PCI device structure.
2645 * If NULL the default PCI device for this device instance is used.
2646 * @param pfnRead Pointer to the user defined PCI config read function.
2647 * @param ppfnReadOld Pointer to function pointer which will receive the old (default)
2648 * PCI config read function. This way, user can decide when (and if)
2649 * to call default PCI config read function. Can be NULL.
2650 * @param pfnWrite Pointer to the user defined PCI config write function.
2651 * @param pfnWriteOld Pointer to function pointer which will receive the old (default)
2652 * PCI config write function. This way, user can decide when (and if)
2653 * to call default PCI config write function. Can be NULL.
2654 * @thread EMT
2655 */
2656 DECLR3CALLBACKMEMBER(void, pfnPCISetConfigCallbacks,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, PFNPCICONFIGREAD pfnRead, PPFNPCICONFIGREAD ppfnReadOld,
2657 PFNPCICONFIGWRITE pfnWrite, PPFNPCICONFIGWRITE ppfnWriteOld));
2658
2659 /**
2660 * Set the IRQ for a PCI device.
2661 *
2662 * @param pDevIns The device instance.
2663 * @param iIrq IRQ number to set.
2664 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
2665 * @thread Any thread, but will involve the emulation thread.
2666 */
2667 DECLR3CALLBACKMEMBER(void, pfnPCISetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
2668
2669 /**
2670 * Set the IRQ for a PCI device, but don't wait for EMT to process
2671 * the request when not called from EMT.
2672 *
2673 * @param pDevIns The device instance.
2674 * @param iIrq IRQ number to set.
2675 * @param iLevel IRQ level.
2676 * @thread Any thread, but will involve the emulation thread.
2677 */
2678 DECLR3CALLBACKMEMBER(void, pfnPCISetIrqNoWait,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
2679
2680 /**
2681 * Set ISA IRQ for a device.
2682 *
2683 * @param pDevIns The device instance.
2684 * @param iIrq IRQ number to set.
2685 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
2686 * @thread Any thread, but will involve the emulation thread.
2687 */
2688 DECLR3CALLBACKMEMBER(void, pfnISASetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
2689
2690 /**
2691 * Set the ISA IRQ for a device, but don't wait for EMT to process
2692 * the request when not called from EMT.
2693 *
2694 * @param pDevIns The device instance.
2695 * @param iIrq IRQ number to set.
2696 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
2697 * @thread Any thread, but will involve the emulation thread.
2698 */
2699 DECLR3CALLBACKMEMBER(void, pfnISASetIrqNoWait,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
2700
2701 /**
2702 * Attaches a driver (chain) to the device.
2703 *
2704 * The first call for a LUN this will serve as a registartion of the LUN. The pBaseInterface and
2705 * the pszDesc string will be registered with that LUN and kept around for PDMR3QueryDeviceLun().
2706 *
2707 * @returns VBox status code.
2708 * @param pDevIns The device instance.
2709 * @param iLun The logical unit to attach.
2710 * @param pBaseInterface Pointer to the base interface for that LUN. (device side / down)
2711 * @param ppBaseInterface Where to store the pointer to the base interface. (driver side / up)
2712 * @param pszDesc Pointer to a string describing the LUN. This string must remain valid
2713 * for the live of the device instance.
2714 */
2715 DECLR3CALLBACKMEMBER(int, pfnDriverAttach,(PPDMDEVINS pDevIns, RTUINT iLun, PPDMIBASE pBaseInterface, PPDMIBASE *ppBaseInterface, const char *pszDesc));
2716
2717 /**
2718 * Create a queue.
2719 *
2720 * @returns VBox status code.
2721 * @param pDevIns The device instance.
2722 * @param cbItem The size of a queue item.
2723 * @param cItems The number of items in the queue.
2724 * @param cMilliesInterval The number of milliseconds between polling the queue.
2725 * If 0 then the emulation thread will be notified whenever an item arrives.
2726 * @param pfnCallback The consumer function.
2727 * @param fRZEnabled Set if the queue should work in RC and R0.
2728 * @param pszName The queue base name. The instance number will be
2729 * appended automatically.
2730 * @param ppQueue Where to store the queue handle on success.
2731 * @thread The emulation thread.
2732 */
2733 DECLR3CALLBACKMEMBER(int, pfnQueueCreate,(PPDMDEVINS pDevIns, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval,
2734 PFNPDMQUEUEDEV pfnCallback, bool fRZEnabled, const char *pszName, PPDMQUEUE *ppQueue));
2735
2736 /**
2737 * Initializes a PDM critical section.
2738 *
2739 * The PDM critical sections are derived from the IPRT critical sections, but
2740 * works in GC as well.
2741 *
2742 * @returns VBox status code.
2743 * @param pDevIns The device instance.
2744 * @param pCritSect Pointer to the critical section.
2745 * @param RT_SRC_POS_DECL Use RT_SRC_POS.
2746 * @param pszNameFmt Format string for namging the critical section.
2747 * For statistics and lock validation.
2748 * @param va Arguments for the format string.
2749 */
2750 DECLR3CALLBACKMEMBER(int, pfnCritSectInit,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, RT_SRC_POS_DECL,
2751 const char *pszNameFmt, va_list va));
2752
2753 /**
2754 * Creates a PDM thread.
2755 *
2756 * This differs from the RTThreadCreate() API in that PDM takes care of suspending,
2757 * resuming, and destroying the thread as the VM state changes.
2758 *
2759 * @returns VBox status code.
2760 * @param pDevIns The device instance.
2761 * @param ppThread Where to store the thread 'handle'.
2762 * @param pvUser The user argument to the thread function.
2763 * @param pfnThread The thread function.
2764 * @param pfnWakeup The wakup callback. This is called on the EMT
2765 * thread when a state change is pending.
2766 * @param cbStack See RTThreadCreate.
2767 * @param enmType See RTThreadCreate.
2768 * @param pszName See RTThreadCreate.
2769 */
2770 DECLR3CALLBACKMEMBER(int, pfnThreadCreate,(PPDMDEVINS pDevIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADDEV pfnThread,
2771 PFNPDMTHREADWAKEUPDEV pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName));
2772
2773 /**
2774 * Set up asynchronous handling of a suspend, reset or power off notification.
2775 *
2776 * This shall only be called when getting the notification. It must be called
2777 * for each one.
2778 *
2779 * @returns VBox status code.
2780 * @param pDevIns The device instance.
2781 * @param pfnAsyncNotify The callback.
2782 * @thread EMT(0)
2783 */
2784 DECLR3CALLBACKMEMBER(int, pfnSetAsyncNotification, (PPDMDEVINS pDevIns, PFNPDMDEVASYNCNOTIFY pfnAsyncNotify));
2785
2786 /**
2787 * Notify EMT(0) that the device has completed the asynchronous notification
2788 * handling.
2789 *
2790 * This can be called at any time, spurious calls will simply be ignored.
2791 *
2792 * @param pDevIns The device instance.
2793 * @thread Any
2794 */
2795 DECLR3CALLBACKMEMBER(void, pfnAsyncNotificationCompleted, (PPDMDEVINS pDevIns));
2796
2797 /**
2798 * Register the RTC device.
2799 *
2800 * @returns VBox status code.
2801 * @param pDevIns The device instance.
2802 * @param pRtcReg Pointer to a RTC registration structure.
2803 * @param ppRtcHlp Where to store the pointer to the helper
2804 * functions.
2805 */
2806 DECLR3CALLBACKMEMBER(int, pfnRTCRegister,(PPDMDEVINS pDevIns, PCPDMRTCREG pRtcReg, PCPDMRTCHLP *ppRtcHlp));
2807
2808 /**
2809 * Register the PCI Bus.
2810 *
2811 * @returns VBox status code.
2812 * @param pDevIns The device instance.
2813 * @param pPciBusReg Pointer to PCI bus registration structure.
2814 * @param ppPciHlpR3 Where to store the pointer to the PCI Bus
2815 * helpers.
2816 */
2817 DECLR3CALLBACKMEMBER(int, pfnPCIBusRegister,(PPDMDEVINS pDevIns, PPDMPCIBUSREG pPciBusReg, PCPDMPCIHLPR3 *ppPciHlpR3));
2818
2819 /**
2820 * Register the PIC device.
2821 *
2822 * @returns VBox status code.
2823 * @param pDevIns The device instance.
2824 * @param pPicReg Pointer to a PIC registration structure.
2825 * @param ppPicHlpR3 Where to store the pointer to the PIC HC
2826 * helpers.
2827 */
2828 DECLR3CALLBACKMEMBER(int, pfnPICRegister,(PPDMDEVINS pDevIns, PPDMPICREG pPicReg, PCPDMPICHLPR3 *ppPicHlpR3));
2829
2830 /**
2831 * Register the APIC device.
2832 *
2833 * @returns VBox status code.
2834 * @param pDevIns The device instance.
2835 * @param pApicReg Pointer to a APIC registration structure.
2836 * @param ppApicHlpR3 Where to store the pointer to the APIC helpers.
2837 */
2838 DECLR3CALLBACKMEMBER(int, pfnAPICRegister,(PPDMDEVINS pDevIns, PPDMAPICREG pApicReg, PCPDMAPICHLPR3 *ppApicHlpR3));
2839
2840 /**
2841 * Register the I/O APIC device.
2842 *
2843 * @returns VBox status code.
2844 * @param pDevIns The device instance.
2845 * @param pIoApicReg Pointer to a I/O APIC registration structure.
2846 * @param ppIoApicHlpR3 Where to store the pointer to the IOAPIC
2847 * helpers.
2848 */
2849 DECLR3CALLBACKMEMBER(int, pfnIOAPICRegister,(PPDMDEVINS pDevIns, PPDMIOAPICREG pIoApicReg, PCPDMIOAPICHLPR3 *ppIoApicHlpR3));
2850
2851 /**
2852 * Register the HPET device.
2853 *
2854 * @returns VBox status code.
2855 * @param pDevIns The device instance.
2856 * @param pHpetReg Pointer to a HPET registration structure.
2857 * @param ppHpetHlpR3 Where to store the pointer to the HPET
2858 * helpers.
2859 */
2860 DECLR3CALLBACKMEMBER(int, pfnHPETRegister,(PPDMDEVINS pDevIns, PPDMHPETREG pHpetReg, PCPDMHPETHLPR3 *ppHpetHlpR3));
2861
2862 /**
2863 * Register the DMA device.
2864 *
2865 * @returns VBox status code.
2866 * @param pDevIns The device instance.
2867 * @param pDmacReg Pointer to a DMAC registration structure.
2868 * @param ppDmacHlp Where to store the pointer to the DMA helpers.
2869 */
2870 DECLR3CALLBACKMEMBER(int, pfnDMACRegister,(PPDMDEVINS pDevIns, PPDMDMACREG pDmacReg, PCPDMDMACHLP *ppDmacHlp));
2871
2872 /**
2873 * Register transfer function for DMA channel.
2874 *
2875 * @returns VBox status code.
2876 * @param pDevIns The device instance.
2877 * @param uChannel Channel number.
2878 * @param pfnTransferHandler Device specific transfer callback function.
2879 * @param pvUser User pointer to pass to the callback.
2880 * @thread EMT
2881 */
2882 DECLR3CALLBACKMEMBER(int, pfnDMARegister,(PPDMDEVINS pDevIns, unsigned uChannel, PFNDMATRANSFERHANDLER pfnTransferHandler, void *pvUser));
2883
2884 /**
2885 * Read memory.
2886 *
2887 * @returns VBox status code.
2888 * @param pDevIns The device instance.
2889 * @param uChannel Channel number.
2890 * @param pvBuffer Pointer to target buffer.
2891 * @param off DMA position.
2892 * @param cbBlock Block size.
2893 * @param pcbRead Where to store the number of bytes which was
2894 * read. optional.
2895 * @thread EMT
2896 */
2897 DECLR3CALLBACKMEMBER(int, pfnDMAReadMemory,(PPDMDEVINS pDevIns, unsigned uChannel, void *pvBuffer, uint32_t off, uint32_t cbBlock, uint32_t *pcbRead));
2898
2899 /**
2900 * Write memory.
2901 *
2902 * @returns VBox status code.
2903 * @param pDevIns The device instance.
2904 * @param uChannel Channel number.
2905 * @param pvBuffer Memory to write.
2906 * @param off DMA position.
2907 * @param cbBlock Block size.
2908 * @param pcbWritten Where to store the number of bytes which was
2909 * written. optional.
2910 * @thread EMT
2911 */
2912 DECLR3CALLBACKMEMBER(int, pfnDMAWriteMemory,(PPDMDEVINS pDevIns, unsigned uChannel, const void *pvBuffer, uint32_t off, uint32_t cbBlock, uint32_t *pcbWritten));
2913
2914 /**
2915 * Set the DREQ line.
2916 *
2917 * @returns VBox status code.
2918 * @param pDevIns Device instance.
2919 * @param uChannel Channel number.
2920 * @param uLevel Level of the line.
2921 * @thread EMT
2922 */
2923 DECLR3CALLBACKMEMBER(int, pfnDMASetDREQ,(PPDMDEVINS pDevIns, unsigned uChannel, unsigned uLevel));
2924
2925 /**
2926 * Get channel mode.
2927 *
2928 * @returns Channel mode. See specs.
2929 * @param pDevIns The device instance.
2930 * @param uChannel Channel number.
2931 * @thread EMT
2932 */
2933 DECLR3CALLBACKMEMBER(uint8_t, pfnDMAGetChannelMode,(PPDMDEVINS pDevIns, unsigned uChannel));
2934
2935 /**
2936 * Schedule DMA execution.
2937 *
2938 * @param pDevIns The device instance.
2939 * @thread Any thread.
2940 */
2941 DECLR3CALLBACKMEMBER(void, pfnDMASchedule,(PPDMDEVINS pDevIns));
2942
2943 /**
2944 * Write CMOS value and update the checksum(s).
2945 *
2946 * @returns VBox status code.
2947 * @param pDevIns The device instance.
2948 * @param iReg The CMOS register index.
2949 * @param u8Value The CMOS register value.
2950 * @thread EMT
2951 */
2952 DECLR3CALLBACKMEMBER(int, pfnCMOSWrite,(PPDMDEVINS pDevIns, unsigned iReg, uint8_t u8Value));
2953
2954 /**
2955 * Read CMOS value.
2956 *
2957 * @returns VBox status code.
2958 * @param pDevIns The device instance.
2959 * @param iReg The CMOS register index.
2960 * @param pu8Value Where to store the CMOS register value.
2961 * @thread EMT
2962 */
2963 DECLR3CALLBACKMEMBER(int, pfnCMOSRead,(PPDMDEVINS pDevIns, unsigned iReg, uint8_t *pu8Value));
2964
2965 /**
2966 * Assert that the current thread is the emulation thread.
2967 *
2968 * @returns True if correct.
2969 * @returns False if wrong.
2970 * @param pDevIns The device instance.
2971 * @param pszFile Filename of the assertion location.
2972 * @param iLine The linenumber of the assertion location.
2973 * @param pszFunction Function of the assertion location.
2974 */
2975 DECLR3CALLBACKMEMBER(bool, pfnAssertEMT,(PPDMDEVINS pDevIns, const char *pszFile, unsigned iLine, const char *pszFunction));
2976
2977 /**
2978 * Assert that the current thread is NOT the emulation thread.
2979 *
2980 * @returns True if correct.
2981 * @returns False if wrong.
2982 * @param pDevIns The device instance.
2983 * @param pszFile Filename of the assertion location.
2984 * @param iLine The linenumber of the assertion location.
2985 * @param pszFunction Function of the assertion location.
2986 */
2987 DECLR3CALLBACKMEMBER(bool, pfnAssertOther,(PPDMDEVINS pDevIns, const char *pszFile, unsigned iLine, const char *pszFunction));
2988
2989
2990 /** Space reserved for future members.
2991 * @{ */
2992 DECLR3CALLBACKMEMBER(void, pfnReserved1,(void));
2993 DECLR3CALLBACKMEMBER(void, pfnReserved2,(void));
2994 DECLR3CALLBACKMEMBER(void, pfnReserved3,(void));
2995 DECLR3CALLBACKMEMBER(void, pfnReserved4,(void));
2996 DECLR3CALLBACKMEMBER(void, pfnReserved5,(void));
2997 DECLR3CALLBACKMEMBER(void, pfnReserved6,(void));
2998 DECLR3CALLBACKMEMBER(void, pfnReserved7,(void));
2999 DECLR3CALLBACKMEMBER(void, pfnReserved8,(void));
3000 DECLR3CALLBACKMEMBER(void, pfnReserved9,(void));
3001 DECLR3CALLBACKMEMBER(void, pfnReserved10,(void));
3002 /** @} */
3003
3004
3005 /** API available to trusted devices only.
3006 *
3007 * These APIs are providing unrestricted access to the guest and the VM,
3008 * or they are interacting intimately with PDM.
3009 *
3010 * @{
3011 */
3012 /**
3013 * Gets the VM handle. Restricted API.
3014 *
3015 * @returns VM Handle.
3016 * @param pDevIns The device instance.
3017 */
3018 DECLR3CALLBACKMEMBER(PVM, pfnGetVM,(PPDMDEVINS pDevIns));
3019
3020 /**
3021 * Gets the VMCPU handle. Restricted API.
3022 *
3023 * @returns VMCPU Handle.
3024 * @param pDevIns The device instance.
3025 */
3026 DECLR3CALLBACKMEMBER(PVMCPU, pfnGetVMCPU,(PPDMDEVINS pDevIns));
3027
3028 /**
3029 * Registers the VMM device heap
3030 *
3031 * @returns VBox status code.
3032 * @param pDevIns The device instance.
3033 * @param GCPhys The physical address.
3034 * @param pvHeap Ring 3 heap pointer.
3035 * @param cbSize Size of the heap.
3036 * @thread EMT.
3037 */
3038 DECLR3CALLBACKMEMBER(int, pfnRegisterVMMDevHeap,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTR3PTR pvHeap, unsigned cbSize));
3039
3040 /**
3041 * Unregisters the VMM device heap
3042 *
3043 * @returns VBox status code.
3044 * @param pDevIns The device instance.
3045 * @param GCPhys The physical address.
3046 * @thread EMT.
3047 */
3048 DECLR3CALLBACKMEMBER(int, pfnUnregisterVMMDevHeap,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys));
3049
3050 /**
3051 * Resets the VM.
3052 *
3053 * @returns The appropriate VBox status code to pass around on reset.
3054 * @param pDevIns The device instance.
3055 * @thread The emulation thread.
3056 */
3057 DECLR3CALLBACKMEMBER(int, pfnVMReset,(PPDMDEVINS pDevIns));
3058
3059 /**
3060 * Suspends the VM.
3061 *
3062 * @returns The appropriate VBox status code to pass around on suspend.
3063 * @param pDevIns The device instance.
3064 * @thread The emulation thread.
3065 */
3066 DECLR3CALLBACKMEMBER(int, pfnVMSuspend,(PPDMDEVINS pDevIns));
3067
3068 /**
3069 * Power off the VM.
3070 *
3071 * @returns The appropriate VBox status code to pass around on power off.
3072 * @param pDevIns The device instance.
3073 * @thread The emulation thread.
3074 */
3075 DECLR3CALLBACKMEMBER(int, pfnVMPowerOff,(PPDMDEVINS pDevIns));
3076
3077 /**
3078 * Checks if the Gate A20 is enabled or not.
3079 *
3080 * @returns true if A20 is enabled.
3081 * @returns false if A20 is disabled.
3082 * @param pDevIns The device instance.
3083 * @thread The emulation thread.
3084 */
3085 DECLR3CALLBACKMEMBER(bool, pfnA20IsEnabled,(PPDMDEVINS pDevIns));
3086
3087 /**
3088 * Enables or disables the Gate A20.
3089 *
3090 * @param pDevIns The device instance.
3091 * @param fEnable Set this flag to enable the Gate A20; clear it
3092 * to disable.
3093 * @thread The emulation thread.
3094 */
3095 DECLR3CALLBACKMEMBER(void, pfnA20Set,(PPDMDEVINS pDevIns, bool fEnable));
3096
3097 /**
3098 * Get the specified CPUID leaf for the virtual CPU associated with the calling
3099 * thread.
3100 *
3101 * @param pDevIns The device instance.
3102 * @param iLeaf The CPUID leaf to get.
3103 * @param pEax Where to store the EAX value.
3104 * @param pEbx Where to store the EBX value.
3105 * @param pEcx Where to store the ECX value.
3106 * @param pEdx Where to store the EDX value.
3107 * @thread EMT.
3108 */
3109 DECLR3CALLBACKMEMBER(void, pfnGetCpuId,(PPDMDEVINS pDevIns, uint32_t iLeaf, uint32_t *pEax, uint32_t *pEbx, uint32_t *pEcx, uint32_t *pEdx));
3110
3111 /** @} */
3112
3113 /** Just a safety precaution. (PDM_DEVHLP_VERSION) */
3114 uint32_t u32TheEnd;
3115} PDMDEVHLPR3;
3116#endif /* !IN_RING3 */
3117/** Pointer to the R3 PDM Device API. */
3118typedef R3PTRTYPE(struct PDMDEVHLPR3 *) PPDMDEVHLPR3;
3119/** Pointer to the R3 PDM Device API, const variant. */
3120typedef R3PTRTYPE(const struct PDMDEVHLPR3 *) PCPDMDEVHLPR3;
3121
3122/** Current PDMDEVHLPR3 version number. */
3123#define PDM_DEVHLPR3_VERSION PDM_VERSION_MAKE(0xffe7, 2, 0)
3124
3125
3126/**
3127 * PDM Device API - RC Variant.
3128 */
3129typedef struct PDMDEVHLPRC
3130{
3131 /** Structure version. PDM_DEVHLPRC_VERSION defines the current version. */
3132 uint32_t u32Version;
3133
3134 /**
3135 * Set the IRQ for a PCI device.
3136 *
3137 * @param pDevIns Device instance.
3138 * @param iIrq IRQ number to set.
3139 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
3140 * @thread Any thread, but will involve the emulation thread.
3141 */
3142 DECLRCCALLBACKMEMBER(void, pfnPCISetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
3143
3144 /**
3145 * Set ISA IRQ for a device.
3146 *
3147 * @param pDevIns Device instance.
3148 * @param iIrq IRQ number to set.
3149 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
3150 * @thread Any thread, but will involve the emulation thread.
3151 */
3152 DECLRCCALLBACKMEMBER(void, pfnISASetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
3153
3154 /**
3155 * Read physical memory.
3156 *
3157 * @returns VINF_SUCCESS (for now).
3158 * @param pDevIns Device instance.
3159 * @param GCPhys Physical address start reading from.
3160 * @param pvBuf Where to put the read bits.
3161 * @param cbRead How many bytes to read.
3162 */
3163 DECLRCCALLBACKMEMBER(int, pfnPhysRead,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead));
3164
3165 /**
3166 * Write to physical memory.
3167 *
3168 * @returns VINF_SUCCESS for now, and later maybe VERR_EM_MEMORY.
3169 * @param pDevIns Device instance.
3170 * @param GCPhys Physical address to write to.
3171 * @param pvBuf What to write.
3172 * @param cbWrite How many bytes to write.
3173 */
3174 DECLRCCALLBACKMEMBER(int, pfnPhysWrite,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite));
3175
3176 /**
3177 * Checks if the Gate A20 is enabled or not.
3178 *
3179 * @returns true if A20 is enabled.
3180 * @returns false if A20 is disabled.
3181 * @param pDevIns Device instance.
3182 * @thread The emulation thread.
3183 */
3184 DECLRCCALLBACKMEMBER(bool, pfnA20IsEnabled,(PPDMDEVINS pDevIns));
3185
3186 /**
3187 * Set the VM error message
3188 *
3189 * @returns rc.
3190 * @param pDrvIns Driver instance.
3191 * @param rc VBox status code.
3192 * @param RT_SRC_POS_DECL Use RT_SRC_POS.
3193 * @param pszFormat Error message format string.
3194 * @param ... Error message arguments.
3195 */
3196 DECLRCCALLBACKMEMBER(int, pfnVMSetError,(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...));
3197
3198 /**
3199 * Set the VM error message
3200 *
3201 * @returns rc.
3202 * @param pDrvIns Driver instance.
3203 * @param rc VBox status code.
3204 * @param RT_SRC_POS_DECL Use RT_SRC_POS.
3205 * @param pszFormat Error message format string.
3206 * @param va Error message arguments.
3207 */
3208 DECLRCCALLBACKMEMBER(int, pfnVMSetErrorV,(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va));
3209
3210 /**
3211 * Set the VM runtime error message
3212 *
3213 * @returns VBox status code.
3214 * @param pDevIns Device instance.
3215 * @param fFlags The action flags. See VMSETRTERR_FLAGS_*.
3216 * @param pszErrorId Error ID string.
3217 * @param pszFormat Error message format string.
3218 * @param ... Error message arguments.
3219 */
3220 DECLRCCALLBACKMEMBER(int, pfnVMSetRuntimeError,(PPDMDEVINS pDevIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, ...));
3221
3222 /**
3223 * Set the VM runtime error message
3224 *
3225 * @returns VBox status code.
3226 * @param pDevIns Device instance.
3227 * @param fFlags The action flags. See VMSETRTERR_FLAGS_*.
3228 * @param pszErrorId Error ID string.
3229 * @param pszFormat Error message format string.
3230 * @param va Error message arguments.
3231 */
3232 DECLRCCALLBACKMEMBER(int, pfnVMSetRuntimeErrorV,(PPDMDEVINS pDevIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, va_list va));
3233
3234 /**
3235 * Set parameters for pending MMIO patch operation
3236 *
3237 * @returns VBox status code.
3238 * @param pDevIns Device instance.
3239 * @param GCPhys MMIO physical address
3240 * @param pCachedData GC pointer to cached data
3241 */
3242 DECLRCCALLBACKMEMBER(int, pfnPATMSetMMIOPatchInfo,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTGCPTR pCachedData));
3243
3244 /**
3245 * Gets the VM handle. Restricted API.
3246 *
3247 * @returns VM Handle.
3248 * @param pDevIns Device instance.
3249 */
3250 DECLRCCALLBACKMEMBER(PVM, pfnGetVM,(PPDMDEVINS pDevIns));
3251
3252 /**
3253 * Gets the VMCPU handle. Restricted API.
3254 *
3255 * @returns VMCPU Handle.
3256 * @param pDevIns The device instance.
3257 */
3258 DECLRCCALLBACKMEMBER(PVMCPU, pfnGetVMCPU,(PPDMDEVINS pDevIns));
3259
3260 /** Just a safety precaution. */
3261 uint32_t u32TheEnd;
3262} PDMDEVHLPRC;
3263/** Pointer PDM Device RC API. */
3264typedef RCPTRTYPE(struct PDMDEVHLPRC *) PPDMDEVHLPRC;
3265/** Pointer PDM Device RC API. */
3266typedef RCPTRTYPE(const struct PDMDEVHLPRC *) PCPDMDEVHLPRC;
3267
3268/** Current PDMDEVHLP version number. */
3269#define PDM_DEVHLPRC_VERSION PDM_VERSION_MAKE(0xffe6, 1, 0)
3270
3271
3272/**
3273 * PDM Device API - R0 Variant.
3274 */
3275typedef struct PDMDEVHLPR0
3276{
3277 /** Structure version. PDM_DEVHLPR0_VERSION defines the current version. */
3278 uint32_t u32Version;
3279
3280 /**
3281 * Set the IRQ for a PCI device.
3282 *
3283 * @param pDevIns Device instance.
3284 * @param iIrq IRQ number to set.
3285 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
3286 * @thread Any thread, but will involve the emulation thread.
3287 */
3288 DECLR0CALLBACKMEMBER(void, pfnPCISetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
3289
3290 /**
3291 * Set ISA IRQ for a device.
3292 *
3293 * @param pDevIns Device instance.
3294 * @param iIrq IRQ number to set.
3295 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
3296 * @thread Any thread, but will involve the emulation thread.
3297 */
3298 DECLR0CALLBACKMEMBER(void, pfnISASetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
3299
3300 /**
3301 * Read physical memory.
3302 *
3303 * @returns VINF_SUCCESS (for now).
3304 * @param pDevIns Device instance.
3305 * @param GCPhys Physical address start reading from.
3306 * @param pvBuf Where to put the read bits.
3307 * @param cbRead How many bytes to read.
3308 */
3309 DECLR0CALLBACKMEMBER(int, pfnPhysRead,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead));
3310
3311 /**
3312 * Write to physical memory.
3313 *
3314 * @returns VINF_SUCCESS for now, and later maybe VERR_EM_MEMORY.
3315 * @param pDevIns Device instance.
3316 * @param GCPhys Physical address to write to.
3317 * @param pvBuf What to write.
3318 * @param cbWrite How many bytes to write.
3319 */
3320 DECLR0CALLBACKMEMBER(int, pfnPhysWrite,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite));
3321
3322 /**
3323 * Checks if the Gate A20 is enabled or not.
3324 *
3325 * @returns true if A20 is enabled.
3326 * @returns false if A20 is disabled.
3327 * @param pDevIns Device instance.
3328 * @thread The emulation thread.
3329 */
3330 DECLR0CALLBACKMEMBER(bool, pfnA20IsEnabled,(PPDMDEVINS pDevIns));
3331
3332 /**
3333 * Set the VM error message
3334 *
3335 * @returns rc.
3336 * @param pDrvIns Driver instance.
3337 * @param rc VBox status code.
3338 * @param RT_SRC_POS_DECL Use RT_SRC_POS.
3339 * @param pszFormat Error message format string.
3340 * @param ... Error message arguments.
3341 */
3342 DECLR0CALLBACKMEMBER(int, pfnVMSetError,(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...));
3343
3344 /**
3345 * Set the VM error message
3346 *
3347 * @returns rc.
3348 * @param pDrvIns Driver instance.
3349 * @param rc VBox status code.
3350 * @param RT_SRC_POS_DECL Use RT_SRC_POS.
3351 * @param pszFormat Error message format string.
3352 * @param va Error message arguments.
3353 */
3354 DECLR0CALLBACKMEMBER(int, pfnVMSetErrorV,(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va));
3355
3356 /**
3357 * Set the VM runtime error message
3358 *
3359 * @returns VBox status code.
3360 * @param pDevIns Device instance.
3361 * @param fFlags The action flags. See VMSETRTERR_FLAGS_*.
3362 * @param pszErrorId Error ID string.
3363 * @param pszFormat Error message format string.
3364 * @param ... Error message arguments.
3365 */
3366 DECLR0CALLBACKMEMBER(int, pfnVMSetRuntimeError,(PPDMDEVINS pDevIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, ...));
3367
3368 /**
3369 * Set the VM runtime error message
3370 *
3371 * @returns VBox status code.
3372 * @param pDevIns Device instance.
3373 * @param fFlags The action flags. See VMSETRTERR_FLAGS_*.
3374 * @param pszErrorId Error ID string.
3375 * @param pszFormat Error message format string.
3376 * @param va Error message arguments.
3377 */
3378 DECLR0CALLBACKMEMBER(int, pfnVMSetRuntimeErrorV,(PPDMDEVINS pDevIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, va_list va));
3379
3380 /**
3381 * Set parameters for pending MMIO patch operation
3382 *
3383 * @returns rc.
3384 * @param pDevIns Device instance.
3385 * @param GCPhys MMIO physical address
3386 * @param pCachedData GC pointer to cached data
3387 */
3388 DECLR0CALLBACKMEMBER(int, pfnPATMSetMMIOPatchInfo,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTGCPTR pCachedData));
3389
3390 /**
3391 * Gets the VM handle. Restricted API.
3392 *
3393 * @returns VM Handle.
3394 * @param pDevIns Device instance.
3395 */
3396 DECLR0CALLBACKMEMBER(PVM, pfnGetVM,(PPDMDEVINS pDevIns));
3397
3398 /**
3399 * Checks if our current CPU state allows for IO block emulation fallback to the recompiler
3400 *
3401 * @returns true = yes, false = no
3402 * @param pDevIns Device instance.
3403 */
3404 DECLR0CALLBACKMEMBER(bool, pfnCanEmulateIoBlock,(PPDMDEVINS pDevIns));
3405
3406 /**
3407 * Gets the VMCPU handle. Restricted API.
3408 *
3409 * @returns VMCPU Handle.
3410 * @param pDevIns The device instance.
3411 */
3412 DECLR0CALLBACKMEMBER(PVMCPU, pfnGetVMCPU,(PPDMDEVINS pDevIns));
3413
3414 /** Just a safety precaution. */
3415 uint32_t u32TheEnd;
3416} PDMDEVHLPR0;
3417/** Pointer PDM Device R0 API. */
3418typedef R0PTRTYPE(struct PDMDEVHLPR0 *) PPDMDEVHLPR0;
3419/** Pointer PDM Device GC API. */
3420typedef R0PTRTYPE(const struct PDMDEVHLPR0 *) PCPDMDEVHLPR0;
3421
3422/** Current PDMDEVHLP version number. */
3423#define PDM_DEVHLPR0_VERSION PDM_VERSION_MAKE(0xffe5, 1, 0)
3424
3425
3426
3427/**
3428 * PDM Device Instance.
3429 */
3430typedef struct PDMDEVINS
3431{
3432 /** Structure version. PDM_DEVINS_VERSION defines the current version. */
3433 uint32_t u32Version;
3434 /** Device instance number. */
3435 uint32_t iInstance;
3436
3437 /** Pointer the GC PDM Device API. */
3438 PCPDMDEVHLPRC pDevHlpRC;
3439 /** Pointer to device instance data. */
3440 RTRCPTR pvInstanceDataRC;
3441
3442 /** Pointer the R0 PDM Device API. */
3443 PCPDMDEVHLPR0 pDevHlpR0;
3444 /** Pointer to device instance data (R0). */
3445 RTR0PTR pvInstanceDataR0;
3446
3447 /** Pointer the HC PDM Device API. */
3448 PCPDMDEVHLPR3 pDevHlpR3;
3449 /** Pointer to device instance data. */
3450 RTR3PTR pvInstanceDataR3;
3451
3452 /** Pointer to device registration structure. */
3453 R3PTRTYPE(PCPDMDEVREG) pDevReg;
3454 /** Configuration handle. */
3455 R3PTRTYPE(PCFGMNODE) pCfgHandle;
3456
3457 /** The base interface of the device.
3458 * The device constructor initializes this if it has any
3459 * device level interfaces to export. To obtain this interface
3460 * call PDMR3QueryDevice(). */
3461 PDMIBASE IBase;
3462 /** Align the internal data more naturally. */
3463 RTR3PTR R3PtrPadding;
3464
3465 /** Internal data. */
3466 union
3467 {
3468#ifdef PDMDEVINSINT_DECLARED
3469 PDMDEVINSINT s;
3470#endif
3471 uint8_t padding[HC_ARCH_BITS == 32 ? 64 + 16 : 112];
3472 } Internal;
3473
3474 /** Device instance data. The size of this area is defined
3475 * in the PDMDEVREG::cbInstanceData field. */
3476 char achInstanceData[8];
3477} PDMDEVINS;
3478
3479/** Current PDMDEVINS version number. */
3480#define PDM_DEVINS_VERSION PDM_VERSION_MAKE(0xffe4, 1, 0)
3481
3482/** Converts a pointer to the PDMDEVINS::IBase to a pointer to PDMDEVINS. */
3483#define PDMIBASE_2_PDMDEV(pInterface) ( (PPDMDEVINS)((char *)(pInterface) - RT_OFFSETOF(PDMDEVINS, IBase)) )
3484
3485/**
3486 * Checks the structure versions of the device instance and device helpers,
3487 * returning if they are incompatible.
3488 *
3489 * This is for use in the constructor.
3490 *
3491 * @param pDevIns The device instance pointer.
3492 */
3493#define PDMDEV_CHECK_VERSIONS_RETURN(pDevIns) \
3494 do \
3495 { \
3496 PPDMDEVINS pDevInsTypeCheck = (pDevIns); NOREF(pDevInsTypeCheck); \
3497 AssertLogRelMsgReturn(PDM_VERSION_ARE_COMPATIBLE((pDevIns)->u32Version, PDM_DEVINS_VERSION), \
3498 ("DevIns=%#x mine=%#x\n", (pDevIns)->u32Version, PDM_DEVINS_VERSION), \
3499 VERR_VERSION_MISMATCH); \
3500 AssertLogRelMsgReturn(PDM_VERSION_ARE_COMPATIBLE((pDevIns)->pDevHlpR3->u32Version, PDM_DEVHLPR3_VERSION), \
3501 ("DevHlp=%#x mine=%#x\n", (pDevIns)->pDevHlpR3->u32Version, PDM_DEVHLPR3_VERSION), \
3502 VERR_VERSION_MISMATCH); \
3503 } while (0)
3504
3505/**
3506 * Quietly checks the structure versions of the device instance and device
3507 * helpers, returning if they are incompatible.
3508 *
3509 * This is for use in the destructor.
3510 *
3511 * @param pDevIns The device instance pointer.
3512 */
3513#define PDMDEV_CHECK_VERSIONS_RETURN_QUIET(pDevIns) \
3514 do \
3515 { \
3516 PPDMDEVINS pDevInsTypeCheck = (pDevIns); NOREF(pDevInsTypeCheck); \
3517 if (RT_UNLIKELY( !PDM_VERSION_ARE_COMPATIBLE((pDevIns)->u32Version, PDM_DEVINS_VERSION) \
3518 || !PDM_VERSION_ARE_COMPATIBLE((pDevIns)->pDevHlpR3->u32Version, PDM_DEVHLPR3_VERSION) )) \
3519 return VERR_VERSION_MISMATCH; \
3520 } while (0)
3521
3522/** @def PDMDEV_ASSERT_EMT
3523 * Assert that the current thread is the emulation thread.
3524 */
3525#ifdef VBOX_STRICT
3526# define PDMDEV_ASSERT_EMT(pDevIns) pDevIns->pDevHlpR3->pfnAssertEMT(pDevIns, __FILE__, __LINE__, __FUNCTION__)
3527#else
3528# define PDMDEV_ASSERT_EMT(pDevIns) do { } while (0)
3529#endif
3530
3531/** @def PDMDEV_ASSERT_OTHER
3532 * Assert that the current thread is NOT the emulation thread.
3533 */
3534#ifdef VBOX_STRICT
3535# define PDMDEV_ASSERT_OTHER(pDevIns) pDevIns->pDevHlpR3->pfnAssertOther(pDevIns, __FILE__, __LINE__, __FUNCTION__)
3536#else
3537# define PDMDEV_ASSERT_OTHER(pDevIns) do { } while (0)
3538#endif
3539
3540/** @def PDMDEV_ASSERT_VMLOCK_OWNER
3541 * Assert that the current thread is owner of the VM lock.
3542 */
3543#ifdef VBOX_STRICT
3544# define PDMDEV_ASSERT_VMLOCK_OWNER(pDevIns) pDevIns->pDevHlpR3->pfnAssertVMLock(pDevIns, __FILE__, __LINE__, __FUNCTION__)
3545#else
3546# define PDMDEV_ASSERT_VMLOCK_OWNER(pDevIns) do { } while (0)
3547#endif
3548
3549/** @def PDMDEV_SET_ERROR
3550 * Set the VM error. See PDMDevHlpVMSetError() for printf like message formatting.
3551 */
3552#define PDMDEV_SET_ERROR(pDevIns, rc, pszError) \
3553 PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS, "%s", pszError)
3554
3555/** @def PDMDEV_SET_RUNTIME_ERROR
3556 * Set the VM runtime error. See PDMDevHlpVMSetRuntimeError() for printf like message formatting.
3557 */
3558#define PDMDEV_SET_RUNTIME_ERROR(pDevIns, fFlags, pszErrorId, pszError) \
3559 PDMDevHlpVMSetRuntimeError(pDevIns, fFlags, pszErrorId, "%s", pszError)
3560
3561/** @def PDMDEVINS_2_RCPTR
3562 * Converts a PDM Device instance pointer a RC PDM Device instance pointer.
3563 */
3564#define PDMDEVINS_2_RCPTR(pDevIns) ( (RCPTRTYPE(PPDMDEVINS))((RTGCUINTPTR)(pDevIns)->pvInstanceDataRC - RT_OFFSETOF(PDMDEVINS, achInstanceData)) )
3565
3566/** @def PDMDEVINS_2_R3PTR
3567 * Converts a PDM Device instance pointer a R3 PDM Device instance pointer.
3568 */
3569#define PDMDEVINS_2_R3PTR(pDevIns) ( (R3PTRTYPE(PPDMDEVINS))((RTHCUINTPTR)(pDevIns)->pvInstanceDataR3 - RT_OFFSETOF(PDMDEVINS, achInstanceData)) )
3570
3571/** @def PDMDEVINS_2_R0PTR
3572 * Converts a PDM Device instance pointer a R0 PDM Device instance pointer.
3573 */
3574#define PDMDEVINS_2_R0PTR(pDevIns) ( (R0PTRTYPE(PPDMDEVINS))((RTR0UINTPTR)(pDevIns)->pvInstanceDataR0 - RT_OFFSETOF(PDMDEVINS, achInstanceData)) )
3575
3576
3577#ifdef IN_RING3
3578
3579/**
3580 * @copydoc PDMDEVHLPR3::pfnIOPortRegister
3581 */
3582DECLINLINE(int) PDMDevHlpIOPortRegister(PPDMDEVINS pDevIns, RTIOPORT Port, RTUINT cPorts, RTHCPTR pvUser,
3583 PFNIOMIOPORTOUT pfnOut, PFNIOMIOPORTIN pfnIn,
3584 PFNIOMIOPORTOUTSTRING pfnOutStr, PFNIOMIOPORTINSTRING pfnInStr, const char *pszDesc)
3585{
3586 return pDevIns->pDevHlpR3->pfnIOPortRegister(pDevIns, Port, cPorts, pvUser, pfnOut, pfnIn, pfnOutStr, pfnInStr, pszDesc);
3587}
3588
3589/**
3590 * @copydoc PDMDEVHLPR3::pfnIOPortRegisterRC
3591 */
3592DECLINLINE(int) PDMDevHlpIOPortRegisterRC(PPDMDEVINS pDevIns, RTIOPORT Port, RTUINT cPorts, RTRCPTR pvUser,
3593 const char *pszOut, const char *pszIn, const char *pszOutStr,
3594 const char *pszInStr, const char *pszDesc)
3595{
3596 return pDevIns->pDevHlpR3->pfnIOPortRegisterRC(pDevIns, Port, cPorts, pvUser, pszOut, pszIn, pszOutStr, pszInStr, pszDesc);
3597}
3598
3599/**
3600 * @copydoc PDMDEVHLPR3::pfnIOPortRegisterR0
3601 */
3602DECLINLINE(int) PDMDevHlpIOPortRegisterR0(PPDMDEVINS pDevIns, RTIOPORT Port, RTUINT cPorts, RTR0PTR pvUser,
3603 const char *pszOut, const char *pszIn, const char *pszOutStr,
3604 const char *pszInStr, const char *pszDesc)
3605{
3606 return pDevIns->pDevHlpR3->pfnIOPortRegisterR0(pDevIns, Port, cPorts, pvUser, pszOut, pszIn, pszOutStr, pszInStr, pszDesc);
3607}
3608
3609/**
3610 * @copydoc PDMDEVHLPR3::pfnIOPortDeregister
3611 */
3612DECLINLINE(int) PDMDevHlpIOPortDeregister(PPDMDEVINS pDevIns, RTIOPORT Port, RTUINT cPorts)
3613{
3614 return pDevIns->pDevHlpR3->pfnIOPortDeregister(pDevIns, Port, cPorts);
3615}
3616
3617/**
3618 * @copydoc PDMDEVHLPR3::pfnMMIORegister
3619 */
3620DECLINLINE(int) PDMDevHlpMMIORegister(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, RTHCPTR pvUser,
3621 PFNIOMMMIOWRITE pfnWrite, PFNIOMMMIOREAD pfnRead, PFNIOMMMIOFILL pfnFill,
3622 const char *pszDesc)
3623{
3624 return pDevIns->pDevHlpR3->pfnMMIORegister(pDevIns, GCPhysStart, cbRange, pvUser, pfnWrite, pfnRead, pfnFill, pszDesc);
3625}
3626
3627/**
3628 * @copydoc PDMDEVHLPR3::pfnMMIORegisterRC
3629 */
3630DECLINLINE(int) PDMDevHlpMMIORegisterRC(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, RTGCPTR pvUser,
3631 const char *pszWrite, const char *pszRead, const char *pszFill)
3632{
3633 return pDevIns->pDevHlpR3->pfnMMIORegisterRC(pDevIns, GCPhysStart, cbRange, pvUser, pszWrite, pszRead, pszFill, NULL);
3634}
3635
3636/**
3637 * @copydoc PDMDEVHLPR3::pfnMMIORegisterR0
3638 */
3639DECLINLINE(int) PDMDevHlpMMIORegisterR0(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, RTR0PTR pvUser,
3640 const char *pszWrite, const char *pszRead, const char *pszFill)
3641{
3642 return pDevIns->pDevHlpR3->pfnMMIORegisterR0(pDevIns, GCPhysStart, cbRange, pvUser, pszWrite, pszRead, pszFill, NULL);
3643}
3644
3645/**
3646 * @copydoc PDMDEVHLPR3::pfnMMIO2Register
3647 */
3648DECLINLINE(int) PDMDevHlpMMIO2Register(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS cb, uint32_t fFlags, void **ppv, const char *pszDesc)
3649{
3650 return pDevIns->pDevHlpR3->pfnMMIO2Register(pDevIns, iRegion, cb, fFlags, ppv, pszDesc);
3651}
3652
3653/**
3654 * @copydoc PDMDEVHLPR3::pfnMMIO2Deregister
3655 */
3656DECLINLINE(int) PDMDevHlpMMIO2Deregister(PPDMDEVINS pDevIns, uint32_t iRegion)
3657{
3658 return pDevIns->pDevHlpR3->pfnMMIO2Deregister(pDevIns, iRegion);
3659}
3660
3661/**
3662 * @copydoc PDMDEVHLPR3::pfnMMIO2Map
3663 */
3664DECLINLINE(int) PDMDevHlpMMIO2Map(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS GCPhys)
3665{
3666 return pDevIns->pDevHlpR3->pfnMMIO2Map(pDevIns, iRegion, GCPhys);
3667}
3668
3669/**
3670 * @copydoc PDMDEVHLPR3::pfnMMIO2Unmap
3671 */
3672DECLINLINE(int) PDMDevHlpMMIO2Unmap(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS GCPhys)
3673{
3674 return pDevIns->pDevHlpR3->pfnMMIO2Unmap(pDevIns, iRegion, GCPhys);
3675}
3676
3677/**
3678 * @copydoc PDMDEVHLPR3::pfnMMHyperMapMMIO2
3679 */
3680DECLINLINE(int) PDMDevHlpMMHyperMapMMIO2(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS off, RTGCPHYS cb,
3681 const char *pszDesc, PRTRCPTR pRCPtr)
3682{
3683 return pDevIns->pDevHlpR3->pfnMMHyperMapMMIO2(pDevIns, iRegion, off, cb, pszDesc, pRCPtr);
3684}
3685
3686/**
3687 * @copydoc PDMDEVHLPR3::pfnMMIO2MapKernel
3688 */
3689DECLINLINE(int) PDMDevHlpMMIO2MapKernel(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS off, RTGCPHYS cb,
3690 const char *pszDesc, PRTR0PTR pR0Ptr)
3691{
3692 return pDevIns->pDevHlpR3->pfnMMIO2MapKernel(pDevIns, iRegion, off, cb, pszDesc, pR0Ptr);
3693}
3694
3695/**
3696 * @copydoc PDMDEVHLPR3::pfnROMRegister
3697 */
3698DECLINLINE(int) PDMDevHlpROMRegister(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, const void *pvBinary, uint32_t fFlags, const char *pszDesc)
3699{
3700 return pDevIns->pDevHlpR3->pfnROMRegister(pDevIns, GCPhysStart, cbRange, pvBinary, fFlags, pszDesc);
3701}
3702
3703/**
3704 * @copydoc PDMDEVHLPR3::pfnROMProtectShadow
3705 */
3706DECLINLINE(int) PDMDevHlpROMProtectShadow(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, PGMROMPROT enmProt)
3707{
3708 return pDevIns->pDevHlpR3->pfnROMProtectShadow(pDevIns, GCPhysStart, cbRange, enmProt);
3709}
3710
3711/**
3712 * Register a save state data unit.
3713 *
3714 * @returns VBox status.
3715 * @param pDevIns The device instance.
3716 * @param uVersion Data layout version number.
3717 * @param cbGuess The approximate amount of data in the unit.
3718 * Only for progress indicators.
3719 * @param pfnSaveExec Execute save callback, optional.
3720 * @param pfnLoadExec Execute load callback, optional.
3721 */
3722DECLINLINE(int) PDMDevHlpSSMRegister(PPDMDEVINS pDevIns, uint32_t uVersion, size_t cbGuess,
3723 PFNSSMDEVSAVEEXEC pfnSaveExec, PFNSSMDEVLOADEXEC pfnLoadExec)
3724{
3725 return pDevIns->pDevHlpR3->pfnSSMRegister(pDevIns, uVersion, cbGuess, NULL /*pszBefore*/,
3726 NULL /*pfnLivePrep*/, NULL /*pfnLiveExec*/, NULL /*pfnLiveDone*/,
3727 NULL /*pfnSavePrep*/, pfnSaveExec, NULL /*pfnSaveDone*/,
3728 NULL /*pfnLoadPrep*/, pfnLoadExec, NULL /*pfnLoadDone*/);
3729}
3730
3731/**
3732 * Register a save state data unit with a live save callback as well.
3733 *
3734 * @returns VBox status.
3735 * @param pDevIns The device instance.
3736 * @param uVersion Data layout version number.
3737 * @param cbGuess The approximate amount of data in the unit.
3738 * Only for progress indicators.
3739 * @param pfnLiveExec Execute live callback, optional.
3740 * @param pfnSaveExec Execute save callback, optional.
3741 * @param pfnLoadExec Execute load callback, optional.
3742 */
3743DECLINLINE(int) PDMDevHlpSSMRegister3(PPDMDEVINS pDevIns, uint32_t uVersion, size_t cbGuess,
3744 FNSSMDEVLIVEEXEC pfnLiveExec, PFNSSMDEVSAVEEXEC pfnSaveExec, PFNSSMDEVLOADEXEC pfnLoadExec)
3745{
3746 return pDevIns->pDevHlpR3->pfnSSMRegister(pDevIns, uVersion, cbGuess, NULL /*pszBefore*/,
3747 NULL /*pfnLivePrep*/, pfnLiveExec, NULL /*pfnLiveDone*/,
3748 NULL /*pfnSavePrep*/, pfnSaveExec, NULL /*pfnSaveDone*/,
3749 NULL /*pfnLoadPrep*/, pfnLoadExec, NULL /*pfnLoadDone*/);
3750}
3751
3752/**
3753 * @copydoc PDMDEVHLPR3::pfnSSMRegister
3754 */
3755DECLINLINE(int) PDMDevHlpSSMRegisterEx(PPDMDEVINS pDevIns, uint32_t uVersion, size_t cbGuess, const char *pszBefore,
3756 PFNSSMDEVLIVEPREP pfnLivePrep, PFNSSMDEVLIVEEXEC pfnLiveExec, PFNSSMDEVLIVEVOTE pfnLiveVote,
3757 PFNSSMDEVSAVEPREP pfnSavePrep, PFNSSMDEVSAVEEXEC pfnSaveExec, PFNSSMDEVSAVEDONE pfnSaveDone,
3758 PFNSSMDEVLOADPREP pfnLoadPrep, PFNSSMDEVLOADEXEC pfnLoadExec, PFNSSMDEVLOADDONE pfnLoadDone)
3759{
3760 return pDevIns->pDevHlpR3->pfnSSMRegister(pDevIns, uVersion, cbGuess, pszBefore,
3761 pfnLivePrep, pfnLiveExec, pfnLiveVote,
3762 pfnSavePrep, pfnSaveExec, pfnSaveDone,
3763 pfnLoadPrep, pfnLoadExec, pfnLoadDone);
3764}
3765
3766/**
3767 * @copydoc PDMDEVHLPR3::pfnTMTimerCreate
3768 */
3769DECLINLINE(int) PDMDevHlpTMTimerCreate(PPDMDEVINS pDevIns, TMCLOCK enmClock, PFNTMTIMERDEV pfnCallback, void *pvUser, uint32_t fFlags,
3770 const char *pszDesc, PPTMTIMERR3 ppTimer)
3771{
3772 return pDevIns->pDevHlpR3->pfnTMTimerCreate(pDevIns, enmClock, pfnCallback, pvUser, fFlags, pszDesc, ppTimer);
3773}
3774
3775/**
3776 * @copydoc PDMDEVHLPR3::pfnTMUtcNow
3777 */
3778DECLINLINE(PRTTIMESPEC) PDMDevHlpTMUtcNow(PPDMDEVINS pDevIns, PRTTIMESPEC pTime)
3779{
3780 return pDevIns->pDevHlpR3->pfnTMUtcNow(pDevIns, pTime);
3781}
3782
3783#endif /* IN_RING3 */
3784
3785/**
3786 * @copydoc PDMDEVHLPR3::pfnPhysRead
3787 */
3788DECLINLINE(int) PDMDevHlpPhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)
3789{
3790 return pDevIns->CTX_SUFF(pDevHlp)->pfnPhysRead(pDevIns, GCPhys, pvBuf, cbRead);
3791}
3792
3793/**
3794 * @copydoc PDMDEVHLPR3::pfnPhysWrite
3795 */
3796DECLINLINE(int) PDMDevHlpPhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)
3797{
3798 return pDevIns->CTX_SUFF(pDevHlp)->pfnPhysWrite(pDevIns, GCPhys, pvBuf, cbWrite);
3799}
3800
3801#ifdef IN_RING3
3802
3803/**
3804 * @copydoc PDMDEVHLPR3::pfnPhysGCPhys2CCPtr
3805 */
3806DECLINLINE(int) PDMDevHlpPhysGCPhys2CCPtr(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, uint32_t fFlags, void **ppv, PPGMPAGEMAPLOCK pLock)
3807{
3808 return pDevIns->CTX_SUFF(pDevHlp)->pfnPhysGCPhys2CCPtr(pDevIns, GCPhys, fFlags, ppv, pLock);
3809}
3810
3811/**
3812 * @copydoc PDMDEVHLPR3::pfnPhysGCPhys2CCPtrReadOnly
3813 */
3814DECLINLINE(int) PDMDevHlpPhysGCPhys2CCPtrReadOnly(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, uint32_t fFlags, void const **ppv, PPGMPAGEMAPLOCK pLock)
3815{
3816 return pDevIns->CTX_SUFF(pDevHlp)->pfnPhysGCPhys2CCPtrReadOnly(pDevIns, GCPhys, fFlags, ppv, pLock);
3817}
3818
3819/**
3820 * @copydoc PDMDEVHLPR3::pfnPhysReleasePageMappingLock
3821 */
3822DECLINLINE(void) PDMDevHlpPhysReleasePageMappingLock(PPDMDEVINS pDevIns, PPGMPAGEMAPLOCK pLock)
3823{
3824 pDevIns->CTX_SUFF(pDevHlp)->pfnPhysReleasePageMappingLock(pDevIns, pLock);
3825}
3826
3827/**
3828 * @copydoc PDMDEVHLPR3::pfnPhysReadGCVirt
3829 */
3830DECLINLINE(int) PDMDevHlpPhysReadGCVirt(PPDMDEVINS pDevIns, void *pvDst, RTGCPTR GCVirtSrc, size_t cb)
3831{
3832 return pDevIns->pDevHlpR3->pfnPhysReadGCVirt(pDevIns, pvDst, GCVirtSrc, cb);
3833}
3834
3835/**
3836 * @copydoc PDMDEVHLPR3::pfnPhysWriteGCVirt
3837 */
3838DECLINLINE(int) PDMDevHlpPhysWriteGCVirt(PPDMDEVINS pDevIns, RTGCPTR GCVirtDst, const void *pvSrc, size_t cb)
3839{
3840 return pDevIns->pDevHlpR3->pfnPhysWriteGCVirt(pDevIns, GCVirtDst, pvSrc, cb);
3841}
3842
3843/**
3844 * @copydoc PDMDEVHLPR3::pfnPhysGCPtr2GCPhys
3845 */
3846DECLINLINE(int) PDMDevHlpPhysGCPtr2GCPhys(PPDMDEVINS pDevIns, RTGCPTR GCPtr, PRTGCPHYS pGCPhys)
3847{
3848 return pDevIns->pDevHlpR3->pfnPhysGCPtr2GCPhys(pDevIns, GCPtr, pGCPhys);
3849}
3850
3851/**
3852 * @copydoc PDMDEVHLPR3::pfnMMHeapAlloc
3853 */
3854DECLINLINE(void *) PDMDevHlpMMHeapAlloc(PPDMDEVINS pDevIns, size_t cb)
3855{
3856 return pDevIns->pDevHlpR3->pfnMMHeapAlloc(pDevIns, cb);
3857}
3858
3859/**
3860 * @copydoc PDMDEVHLPR3::pfnMMHeapAllocZ
3861 */
3862DECLINLINE(void *) PDMDevHlpMMHeapAllocZ(PPDMDEVINS pDevIns, size_t cb)
3863{
3864 return pDevIns->pDevHlpR3->pfnMMHeapAllocZ(pDevIns, cb);
3865}
3866
3867/**
3868 * @copydoc PDMDEVHLPR3::pfnMMHeapFree
3869 */
3870DECLINLINE(void) PDMDevHlpMMHeapFree(PPDMDEVINS pDevIns, void *pv)
3871{
3872 pDevIns->pDevHlpR3->pfnMMHeapFree(pDevIns, pv);
3873}
3874
3875/**
3876 * @copydoc PDMDEVHLPR3::pfnVMState
3877 */
3878DECLINLINE(VMSTATE) PDMDevHlpVMState(PPDMDEVINS pDevIns)
3879{
3880 return pDevIns->pDevHlpR3->pfnVMState(pDevIns);
3881}
3882
3883/**
3884 * @copydoc PDMDEVHLPR3::pfnVMTeleportedAndNotFullyResumedYet
3885 */
3886DECLINLINE(bool) PDMDevHlpVMTeleportedAndNotFullyResumedYet(PPDMDEVINS pDevIns)
3887{
3888 return pDevIns->pDevHlpR3->pfnVMTeleportedAndNotFullyResumedYet(pDevIns);
3889}
3890
3891#endif /* IN_RING3 */
3892
3893/**
3894 * @copydoc PDMDEVHLPR3::pfnVMSetError
3895 */
3896DECLINLINE(int) PDMDevHlpVMSetError(PPDMDEVINS pDevIns, const int rc, RT_SRC_POS_DECL, const char *pszFormat, ...)
3897{
3898 va_list va;
3899 va_start(va, pszFormat);
3900 pDevIns->CTX_SUFF(pDevHlp)->pfnVMSetErrorV(pDevIns, rc, RT_SRC_POS_ARGS, pszFormat, va);
3901 va_end(va);
3902 return rc;
3903}
3904
3905/**
3906 * @copydoc PDMDEVHLPR3::pfnVMSetRuntimeError
3907 */
3908DECLINLINE(int) PDMDevHlpVMSetRuntimeError(PPDMDEVINS pDevIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, ...)
3909{
3910 va_list va;
3911 int rc;
3912 va_start(va, pszFormat);
3913 rc = pDevIns->CTX_SUFF(pDevHlp)->pfnVMSetRuntimeErrorV(pDevIns, fFlags, pszErrorId, pszFormat, va);
3914 va_end(va);
3915 return rc;
3916}
3917
3918/**
3919 * VBOX_STRICT wrapper for pDevHlp->pfnDBGFStopV.
3920 *
3921 * @returns VBox status code which must be passed up to the VMM. This will be
3922 * VINF_SUCCESS in non-strict builds.
3923 * @param pDevIns The device instance.
3924 * @param RT_SRC_POS_DECL Use RT_SRC_POS.
3925 * @param pszFormat Message. (optional)
3926 * @param ... Message parameters.
3927 */
3928DECLINLINE(int) PDMDevHlpDBGFStop(PPDMDEVINS pDevIns, RT_SRC_POS_DECL, const char *pszFormat, ...)
3929{
3930#ifdef VBOX_STRICT
3931# ifdef IN_RING3
3932 int rc;
3933 va_list args;
3934 va_start(args, pszFormat);
3935 rc = pDevIns->pDevHlpR3->pfnDBGFStopV(pDevIns, RT_SRC_POS_ARGS, pszFormat, args);
3936 va_end(args);
3937 return rc;
3938# else
3939 return VINF_EM_DBG_STOP;
3940# endif
3941#else
3942 NOREF(pDevIns);
3943 NOREF(pszFile);
3944 NOREF(iLine);
3945 NOREF(pszFunction);
3946 NOREF(pszFormat);
3947 return VINF_SUCCESS;
3948#endif
3949}
3950
3951#ifdef IN_RING3
3952
3953/**
3954 * @copydoc PDMDEVHLPR3::pfnDBGFInfoRegister
3955 */
3956DECLINLINE(int) PDMDevHlpDBGFInfoRegister(PPDMDEVINS pDevIns, const char *pszName, const char *pszDesc, PFNDBGFHANDLERDEV pfnHandler)
3957{
3958 return pDevIns->pDevHlpR3->pfnDBGFInfoRegister(pDevIns, pszName, pszDesc, pfnHandler);
3959}
3960
3961/**
3962 * @copydoc PDMDEVHLPR3::pfnSTAMRegister
3963 */
3964DECLINLINE(void) PDMDevHlpSTAMRegister(PPDMDEVINS pDevIns, void *pvSample, STAMTYPE enmType, const char *pszName, STAMUNIT enmUnit, const char *pszDesc)
3965{
3966 pDevIns->pDevHlpR3->pfnSTAMRegister(pDevIns, pvSample, enmType, pszName, enmUnit, pszDesc);
3967}
3968
3969/**
3970 * @copydoc PDMDEVHLPR3::pfnSTAMRegisterF
3971 */
3972DECLINLINE(void) PDMDevHlpSTAMRegisterF(PPDMDEVINS pDevIns, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility, STAMUNIT enmUnit,
3973 const char *pszDesc, const char *pszName, ...)
3974{
3975 va_list va;
3976 va_start(va, pszName);
3977 pDevIns->pDevHlpR3->pfnSTAMRegisterV(pDevIns, pvSample, enmType, enmVisibility, enmUnit, pszDesc, pszName, va);
3978 va_end(va);
3979}
3980
3981/**
3982 * @copydoc PDMDEVHLPR3::pfnPCIRegister
3983 */
3984DECLINLINE(int) PDMDevHlpPCIRegister(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev)
3985{
3986 return pDevIns->pDevHlpR3->pfnPCIRegister(pDevIns, pPciDev);
3987}
3988
3989/**
3990 * @copydoc PDMDEVHLPR3::pfnPCIIORegionRegister
3991 */
3992DECLINLINE(int) PDMDevHlpPCIIORegionRegister(PPDMDEVINS pDevIns, int iRegion, uint32_t cbRegion, PCIADDRESSSPACE enmType, PFNPCIIOREGIONMAP pfnCallback)
3993{
3994 return pDevIns->pDevHlpR3->pfnPCIIORegionRegister(pDevIns, iRegion, cbRegion, enmType, pfnCallback);
3995}
3996
3997/**
3998 * @copydoc PDMDEVHLPR3::pfnPCISetConfigCallbacks
3999 */
4000DECLINLINE(void) PDMDevHlpPCISetConfigCallbacks(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, PFNPCICONFIGREAD pfnRead, PPFNPCICONFIGREAD ppfnReadOld,
4001 PFNPCICONFIGWRITE pfnWrite, PPFNPCICONFIGWRITE ppfnWriteOld)
4002{
4003 pDevIns->pDevHlpR3->pfnPCISetConfigCallbacks(pDevIns, pPciDev, pfnRead, ppfnReadOld, pfnWrite, ppfnWriteOld);
4004}
4005
4006#endif /* IN_RING3 */
4007
4008/**
4009 * @copydoc PDMDEVHLPR3::pfnPCISetIrq
4010 */
4011DECLINLINE(void) PDMDevHlpPCISetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel)
4012{
4013 pDevIns->CTX_SUFF(pDevHlp)->pfnPCISetIrq(pDevIns, iIrq, iLevel);
4014}
4015
4016/**
4017 * @copydoc PDMDEVHLPR3::pfnPCISetIrqNoWait
4018 */
4019DECLINLINE(void) PDMDevHlpPCISetIrqNoWait(PPDMDEVINS pDevIns, int iIrq, int iLevel)
4020{
4021 pDevIns->CTX_SUFF(pDevHlp)->pfnPCISetIrq(pDevIns, iIrq, iLevel);
4022}
4023
4024/**
4025 * @copydoc PDMDEVHLPR3::pfnISASetIrq
4026 */
4027DECLINLINE(void) PDMDevHlpISASetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel)
4028{
4029 pDevIns->CTX_SUFF(pDevHlp)->pfnISASetIrq(pDevIns, iIrq, iLevel);
4030}
4031
4032/**
4033 * @copydoc PDMDEVHLPR3::pfnISASetIrqNoWait
4034 */
4035DECLINLINE(void) PDMDevHlpISASetIrqNoWait(PPDMDEVINS pDevIns, int iIrq, int iLevel)
4036{
4037 pDevIns->CTX_SUFF(pDevHlp)->pfnISASetIrq(pDevIns, iIrq, iLevel);
4038}
4039
4040#ifdef IN_RING3
4041
4042/**
4043 * @copydoc PDMDEVHLPR3::pfnDriverAttach
4044 */
4045DECLINLINE(int) PDMDevHlpDriverAttach(PPDMDEVINS pDevIns, RTUINT iLun, PPDMIBASE pBaseInterface, PPDMIBASE *ppBaseInterface, const char *pszDesc)
4046{
4047 return pDevIns->pDevHlpR3->pfnDriverAttach(pDevIns, iLun, pBaseInterface, ppBaseInterface, pszDesc);
4048}
4049
4050/**
4051 * @copydoc PDMDEVHLPR3::pfnQueueCreate
4052 */
4053DECLINLINE(int) PDMDevHlpQueueCreate(PPDMDEVINS pDevIns, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval,
4054 PFNPDMQUEUEDEV pfnCallback, bool fGCEnabled, const char *pszName, PPDMQUEUE *ppQueue)
4055{
4056 return pDevIns->pDevHlpR3->pfnQueueCreate(pDevIns, cbItem, cItems, cMilliesInterval, pfnCallback, fGCEnabled, pszName, ppQueue);
4057}
4058
4059/**
4060 * Initializes a PDM critical section.
4061 *
4062 * The PDM critical sections are derived from the IPRT critical sections, but
4063 * works in GC as well.
4064 *
4065 * @returns VBox status code.
4066 * @param pDevIns The device instance.
4067 * @param pCritSect Pointer to the critical section.
4068 * @param RT_SRC_POS_DECL Use RT_SRC_POS.
4069 * @param pszNameFmt Format string for namging the critical section.
4070 * For statistics and lock validation.
4071 * @param ... Arguments for the format string.
4072 */
4073DECLINLINE(int) PDMDevHlpCritSectInit(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, RT_SRC_POS_DECL, const char *pszNameFmt, ...)
4074{
4075 int rc;
4076 va_list va;
4077 va_start(va, pszNameFmt);
4078 rc = pDevIns->pDevHlpR3->pfnCritSectInit(pDevIns, pCritSect, RT_SRC_POS_ARGS, pszNameFmt, va);
4079 va_end(va);
4080 return rc;
4081}
4082
4083/**
4084 * @copydoc PDMDEVHLPR3::pfnThreadCreate
4085 */
4086DECLINLINE(int) PDMDevHlpThreadCreate(PPDMDEVINS pDevIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADDEV pfnThread,
4087 PFNPDMTHREADWAKEUPDEV pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName)
4088{
4089 return pDevIns->pDevHlpR3->pfnThreadCreate(pDevIns, ppThread, pvUser, pfnThread, pfnWakeup, cbStack, enmType, pszName);
4090}
4091
4092/**
4093 * @copydoc PDMDEVHLPR3::pfnSetAsyncNotification
4094 */
4095DECLINLINE(int) PDMDevHlpSetAsyncNotification(PPDMDEVINS pDevIns, PFNPDMDEVASYNCNOTIFY pfnAsyncNotify)
4096{
4097 return pDevIns->pDevHlpR3->pfnSetAsyncNotification(pDevIns, pfnAsyncNotify);
4098}
4099
4100/**
4101 * @copydoc PDMDEVHLPR3::pfnAsyncNotificationCompleted
4102 */
4103DECLINLINE(void) PDMDevHlpAsyncNotificationCompleted(PPDMDEVINS pDevIns)
4104{
4105 pDevIns->pDevHlpR3->pfnAsyncNotificationCompleted(pDevIns);
4106}
4107
4108/**
4109 * @copydoc PDMDEVHLPR3::pfnA20Set
4110 */
4111DECLINLINE(void) PDMDevHlpA20Set(PPDMDEVINS pDevIns, bool fEnable)
4112{
4113 pDevIns->pDevHlpR3->pfnA20Set(pDevIns, fEnable);
4114}
4115
4116/**
4117 * @copydoc PDMDEVHLPR3::pfnDMARegister
4118 */
4119DECLINLINE(int) PDMDevHlpDMARegister(PPDMDEVINS pDevIns, unsigned uChannel, PFNDMATRANSFERHANDLER pfnTransferHandler, void *pvUser)
4120{
4121 return pDevIns->pDevHlpR3->pfnDMARegister(pDevIns, uChannel, pfnTransferHandler, pvUser);
4122}
4123
4124/**
4125 * @copydoc PDMDEVHLPR3::pfnDMAReadMemory
4126 */
4127DECLINLINE(int) PDMDevHlpDMAReadMemory(PPDMDEVINS pDevIns, unsigned uChannel, void *pvBuffer, uint32_t off, uint32_t cbBlock, uint32_t *pcbRead)
4128{
4129 return pDevIns->pDevHlpR3->pfnDMAReadMemory(pDevIns, uChannel, pvBuffer, off, cbBlock, pcbRead);
4130}
4131
4132/**
4133 * @copydoc PDMDEVHLPR3::pfnDMAWriteMemory
4134 */
4135DECLINLINE(int) PDMDevHlpDMAWriteMemory(PPDMDEVINS pDevIns, unsigned uChannel, const void *pvBuffer, uint32_t off, uint32_t cbBlock, uint32_t *pcbWritten)
4136{
4137 return pDevIns->pDevHlpR3->pfnDMAWriteMemory(pDevIns, uChannel, pvBuffer, off, cbBlock, pcbWritten);
4138}
4139
4140/**
4141 * @copydoc PDMDEVHLPR3::pfnDMASetDREQ
4142 */
4143DECLINLINE(int) PDMDevHlpDMASetDREQ(PPDMDEVINS pDevIns, unsigned uChannel, unsigned uLevel)
4144{
4145 return pDevIns->pDevHlpR3->pfnDMASetDREQ(pDevIns, uChannel, uLevel);
4146}
4147
4148/**
4149 * @copydoc PDMDEVHLPR3::pfnDMAGetChannelMode
4150 */
4151DECLINLINE(uint8_t) PDMDevHlpDMAGetChannelMode(PPDMDEVINS pDevIns, unsigned uChannel)
4152{
4153 return pDevIns->pDevHlpR3->pfnDMAGetChannelMode(pDevIns, uChannel);
4154}
4155
4156/**
4157 * @copydoc PDMDEVHLPR3::pfnDMASchedule
4158 */
4159DECLINLINE(void) PDMDevHlpDMASchedule(PPDMDEVINS pDevIns)
4160{
4161 pDevIns->pDevHlpR3->pfnDMASchedule(pDevIns);
4162}
4163
4164/**
4165 * @copydoc PDMDEVHLPR3::pfnCMOSWrite
4166 */
4167DECLINLINE(int) PDMDevHlpCMOSWrite(PPDMDEVINS pDevIns, unsigned iReg, uint8_t u8Value)
4168{
4169 return pDevIns->pDevHlpR3->pfnCMOSWrite(pDevIns, iReg, u8Value);
4170}
4171
4172/**
4173 * @copydoc PDMDEVHLPR3::pfnCMOSRead
4174 */
4175DECLINLINE(int) PDMDevHlpCMOSRead(PPDMDEVINS pDevIns, unsigned iReg, uint8_t *pu8Value)
4176{
4177 return pDevIns->pDevHlpR3->pfnCMOSRead(pDevIns, iReg, pu8Value);
4178}
4179
4180#endif /* IN_RING3 */
4181
4182/**
4183 * @copydoc PDMDEVHLPR3::pfnGetVM
4184 */
4185DECLINLINE(PVM) PDMDevHlpGetVM(PPDMDEVINS pDevIns)
4186{
4187 return pDevIns->CTX_SUFF(pDevHlp)->pfnGetVM(pDevIns);
4188}
4189
4190/**
4191 * @copydoc PDMDEVHLPR3::pfnGetVMCPU
4192 */
4193DECLINLINE(PVMCPU) PDMDevHlpGetVMCPU(PPDMDEVINS pDevIns)
4194{
4195 return pDevIns->CTX_SUFF(pDevHlp)->pfnGetVMCPU(pDevIns);
4196}
4197
4198#ifdef IN_RING3
4199
4200/**
4201 * @copydoc PDMDEVHLPR3::pfnRegisterVMMDevHeap
4202 */
4203DECLINLINE(int) PDMDevHlpRegisterVMMDevHeap(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTR3PTR pvHeap, unsigned cbSize)
4204{
4205 return pDevIns->pDevHlpR3->pfnRegisterVMMDevHeap(pDevIns, GCPhys, pvHeap, cbSize);
4206}
4207
4208/**
4209 * @copydoc PDMDEVHLPR3::pfnUnregisterVMMDevHeap
4210 */
4211DECLINLINE(int) PDMDevHlpUnregisterVMMDevHeap(PPDMDEVINS pDevIns, RTGCPHYS GCPhys)
4212{
4213 return pDevIns->pDevHlpR3->pfnUnregisterVMMDevHeap(pDevIns, GCPhys);
4214}
4215
4216/**
4217 * @copydoc PDMDEVHLPR3::pfnVMReset
4218 */
4219DECLINLINE(int) PDMDevHlpVMReset(PPDMDEVINS pDevIns)
4220{
4221 return pDevIns->pDevHlpR3->pfnVMReset(pDevIns);
4222}
4223
4224/**
4225 * @copydoc PDMDEVHLPR3::pfnVMSuspend
4226 */
4227DECLINLINE(int) PDMDevHlpVMSuspend(PPDMDEVINS pDevIns)
4228{
4229 return pDevIns->pDevHlpR3->pfnVMSuspend(pDevIns);
4230}
4231
4232/**
4233 * @copydoc PDMDEVHLPR3::pfnVMPowerOff
4234 */
4235DECLINLINE(int) PDMDevHlpVMPowerOff(PPDMDEVINS pDevIns)
4236{
4237 return pDevIns->pDevHlpR3->pfnVMPowerOff(pDevIns);
4238}
4239
4240#endif /* IN_RING3 */
4241
4242/**
4243 * @copydoc PDMDEVHLPR3::pfnA20IsEnabled
4244 */
4245DECLINLINE(bool) PDMDevHlpA20IsEnabled(PPDMDEVINS pDevIns)
4246{
4247 return pDevIns->CTX_SUFF(pDevHlp)->pfnA20IsEnabled(pDevIns);
4248}
4249
4250#ifdef IN_RING3
4251
4252/**
4253 * @copydoc PDMDEVHLPR3::pfnGetCpuId
4254 */
4255DECLINLINE(void) PDMDevHlpGetCpuId(PPDMDEVINS pDevIns, uint32_t iLeaf, uint32_t *pEax, uint32_t *pEbx, uint32_t *pEcx, uint32_t *pEdx)
4256{
4257 pDevIns->pDevHlpR3->pfnGetCpuId(pDevIns, iLeaf, pEax, pEbx, pEcx, pEdx);
4258}
4259
4260#endif /* IN_RING3 */
4261#ifdef IN_RING0
4262
4263/**
4264 * @copydoc PDMDEVHLPR0::pfnCanEmulateIoBlock
4265 */
4266DECLINLINE(bool) PDMDevHlpCanEmulateIoBlock(PPDMDEVINS pDevIns)
4267{
4268 return pDevIns->CTX_SUFF(pDevHlp)->pfnCanEmulateIoBlock(pDevIns);
4269}
4270
4271#endif /* IN_RING0 */
4272
4273
4274
4275
4276/** Pointer to callbacks provided to the VBoxDeviceRegister() call. */
4277typedef struct PDMDEVREGCB *PPDMDEVREGCB;
4278
4279/**
4280 * Callbacks for VBoxDeviceRegister().
4281 */
4282typedef struct PDMDEVREGCB
4283{
4284 /** Interface version.
4285 * This is set to PDM_DEVREG_CB_VERSION. */
4286 uint32_t u32Version;
4287
4288 /**
4289 * Registers a device with the current VM instance.
4290 *
4291 * @returns VBox status code.
4292 * @param pCallbacks Pointer to the callback table.
4293 * @param pDevReg Pointer to the device registration record.
4294 * This data must be permanent and readonly.
4295 */
4296 DECLR3CALLBACKMEMBER(int, pfnRegister,(PPDMDEVREGCB pCallbacks, PCPDMDEVREG pDevReg));
4297
4298 /**
4299 * Allocate memory which is associated with current VM instance
4300 * and automatically freed on it's destruction.
4301 *
4302 * @returns Pointer to allocated memory. The memory is *NOT* zero-ed.
4303 * @param pCallbacks Pointer to the callback table.
4304 * @param cb Number of bytes to allocate.
4305 */
4306 DECLR3CALLBACKMEMBER(void *, pfnMMHeapAlloc,(PPDMDEVREGCB pCallbacks, size_t cb));
4307} PDMDEVREGCB;
4308
4309/** Current version of the PDMDEVREGCB structure. */
4310#define PDM_DEVREG_CB_VERSION PDM_VERSION_MAKE(0xffe3, 1, 0)
4311
4312
4313/**
4314 * The VBoxDevicesRegister callback function.
4315 *
4316 * PDM will invoke this function after loading a device module and letting
4317 * the module decide which devices to register and how to handle conflicts.
4318 *
4319 * @returns VBox status code.
4320 * @param pCallbacks Pointer to the callback table.
4321 * @param u32Version VBox version number.
4322 */
4323typedef DECLCALLBACK(int) FNPDMVBOXDEVICESREGISTER(PPDMDEVREGCB pCallbacks, uint32_t u32Version);
4324
4325/** @} */
4326
4327RT_C_DECLS_END
4328
4329#endif
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette