VirtualBox

source: vbox/trunk/include/VBox/vmm/pdmdev.h@ 53797

Last change on this file since 53797 was 53797, checked in by vboxsync, 10 years ago

Finally added PDMDevHlpGetCurrentCpuId.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 201.1 KB
Line 
1/** @file
2 * PDM - Pluggable Device Manager, Devices.
3 */
4
5/*
6 * Copyright (C) 2006-2013 Oracle Corporation
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
26#ifndef ___VBox_vmm_pdmdev_h
27#define ___VBox_vmm_pdmdev_h
28
29#include <VBox/vmm/pdmqueue.h>
30#include <VBox/vmm/pdmcritsect.h>
31#include <VBox/vmm/pdmthread.h>
32#include <VBox/vmm/pdmifs.h>
33#include <VBox/vmm/pdmins.h>
34#include <VBox/vmm/pdmcommon.h>
35#include <VBox/vmm/iom.h>
36#include <VBox/vmm/tm.h>
37#include <VBox/vmm/ssm.h>
38#include <VBox/vmm/cfgm.h>
39#include <VBox/vmm/dbgf.h>
40#include <VBox/err.h>
41#include <VBox/pci.h>
42#include <VBox/sup.h>
43#include <iprt/stdarg.h>
44
45
46RT_C_DECLS_BEGIN
47
48/** @defgroup grp_pdm_device The PDM Devices API
49 * @ingroup grp_pdm
50 * @{
51 */
52
53/**
54 * Construct a device instance for a VM.
55 *
56 * @returns VBox status.
57 * @param pDevIns The device instance data. If the registration structure
58 * is needed, it can be accessed thru pDevIns->pReg.
59 * @param iInstance Instance number. Use this to figure out which registers
60 * and such to use. The instance number is also found in
61 * pDevIns->iInstance, but since it's likely to be
62 * frequently used PDM passes it as parameter.
63 * @param pCfg Configuration node handle for the driver. This is
64 * expected to be in high demand in the constructor and is
65 * therefore passed as an argument. When using it at other
66 * times, it can be found in pDrvIns->pCfg.
67 */
68typedef DECLCALLBACK(int) FNPDMDEVCONSTRUCT(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg);
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 *
81 * @remarks The device critical section is not entered. The routine may delete
82 * the critical section, so the caller cannot exit it.
83 */
84typedef DECLCALLBACK(int) FNPDMDEVDESTRUCT(PPDMDEVINS pDevIns);
85/** Pointer to a FNPDMDEVDESTRUCT() function. */
86typedef FNPDMDEVDESTRUCT *PFNPDMDEVDESTRUCT;
87
88/**
89 * Device relocation callback.
90 *
91 * This is called when the instance data has been relocated in raw-mode context
92 * (RC). It is also called when the RC hypervisor selects changes. The device
93 * must fixup all necessary pointers and re-query all interfaces to other RC
94 * devices and drivers.
95 *
96 * Before the RC code is executed the first time, this function will be called
97 * with a 0 delta so RC pointer calculations can be one in one place.
98 *
99 * @param pDevIns Pointer to the device instance.
100 * @param offDelta The relocation delta relative to the old location.
101 *
102 * @remarks A relocation CANNOT fail.
103 *
104 * @remarks The device critical section is not entered. The relocations should
105 * not normally require any locking.
106 */
107typedef DECLCALLBACK(void) FNPDMDEVRELOCATE(PPDMDEVINS pDevIns, RTGCINTPTR offDelta);
108/** Pointer to a FNPDMDEVRELOCATE() function. */
109typedef FNPDMDEVRELOCATE *PFNPDMDEVRELOCATE;
110
111/**
112 * Power On notification.
113 *
114 * @returns VBox status.
115 * @param pDevIns The device instance data.
116 *
117 * @remarks Caller enters the device critical section.
118 */
119typedef DECLCALLBACK(void) FNPDMDEVPOWERON(PPDMDEVINS pDevIns);
120/** Pointer to a FNPDMDEVPOWERON() function. */
121typedef FNPDMDEVPOWERON *PFNPDMDEVPOWERON;
122
123/**
124 * Reset notification.
125 *
126 * @returns VBox status.
127 * @param pDevIns The device instance data.
128 *
129 * @remarks Caller enters the device critical section.
130 */
131typedef DECLCALLBACK(void) FNPDMDEVRESET(PPDMDEVINS pDevIns);
132/** Pointer to a FNPDMDEVRESET() function. */
133typedef FNPDMDEVRESET *PFNPDMDEVRESET;
134
135/**
136 * Suspend notification.
137 *
138 * @returns VBox status.
139 * @param pDevIns The device instance data.
140 * @thread EMT(0)
141 *
142 * @remarks Caller enters the device critical section.
143 */
144typedef DECLCALLBACK(void) FNPDMDEVSUSPEND(PPDMDEVINS pDevIns);
145/** Pointer to a FNPDMDEVSUSPEND() function. */
146typedef FNPDMDEVSUSPEND *PFNPDMDEVSUSPEND;
147
148/**
149 * Resume notification.
150 *
151 * @returns VBox status.
152 * @param pDevIns The device instance data.
153 *
154 * @remarks Caller enters the device critical section.
155 */
156typedef DECLCALLBACK(void) FNPDMDEVRESUME(PPDMDEVINS pDevIns);
157/** Pointer to a FNPDMDEVRESUME() function. */
158typedef FNPDMDEVRESUME *PFNPDMDEVRESUME;
159
160/**
161 * Power Off notification.
162 *
163 * This is only called when the VMR3PowerOff call is made on a running VM. This
164 * means that there is no notification if the VM was suspended before being
165 * powered off. There will also be no callback when hot plugging devices.
166 *
167 * @param pDevIns The device instance data.
168 * @thread EMT(0)
169 *
170 * @remarks Caller enters the device critical section.
171 */
172typedef DECLCALLBACK(void) FNPDMDEVPOWEROFF(PPDMDEVINS pDevIns);
173/** Pointer to a FNPDMDEVPOWEROFF() function. */
174typedef FNPDMDEVPOWEROFF *PFNPDMDEVPOWEROFF;
175
176/**
177 * Attach command.
178 *
179 * This is called to let the device attach to a driver for a specified LUN
180 * at runtime. This is not called during VM construction, the device
181 * constructor have to attach to all the available drivers.
182 *
183 * This is like plugging in the keyboard or mouse after turning on the PC.
184 *
185 * @returns VBox status code.
186 * @param pDevIns The device instance.
187 * @param iLUN The logical unit which is being detached.
188 * @param fFlags Flags, combination of the PDM_TACH_FLAGS_* \#defines.
189 *
190 * @remarks Caller enters the device critical section.
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 *
209 * @remarks Caller enters the device critical section.
210 */
211typedef DECLCALLBACK(void) FNPDMDEVDETACH(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags);
212/** Pointer to a FNPDMDEVDETACH() function. */
213typedef FNPDMDEVDETACH *PFNPDMDEVDETACH;
214
215/**
216 * Query the base interface of a logical unit.
217 *
218 * @returns VBOX status code.
219 * @param pDevIns The device instance.
220 * @param iLUN The logicial unit to query.
221 * @param ppBase Where to store the pointer to the base interface of the LUN.
222 *
223 * @remarks The device critical section is not entered.
224 */
225typedef DECLCALLBACK(int) FNPDMDEVQUERYINTERFACE(PPDMDEVINS pDevIns, unsigned iLUN, PPDMIBASE *ppBase);
226/** Pointer to a FNPDMDEVQUERYINTERFACE() function. */
227typedef FNPDMDEVQUERYINTERFACE *PFNPDMDEVQUERYINTERFACE;
228
229/**
230 * Init complete notification.
231 * This can be done to do communication with other devices and other
232 * initialization which requires everything to be in place.
233 *
234 * @returns VBOX status code.
235 * @param pDevIns The device instance.
236 *
237 * @remarks Caller enters the device critical section.
238 */
239typedef DECLCALLBACK(int) FNPDMDEVINITCOMPLETE(PPDMDEVINS pDevIns);
240/** Pointer to a FNPDMDEVINITCOMPLETE() function. */
241typedef FNPDMDEVINITCOMPLETE *PFNPDMDEVINITCOMPLETE;
242
243
244/**
245 * The context of a pfnMemSetup call.
246 */
247typedef enum PDMDEVMEMSETUPCTX
248{
249 /** Invalid zero value. */
250 PDMDEVMEMSETUPCTX_INVALID = 0,
251 /** After construction. */
252 PDMDEVMEMSETUPCTX_AFTER_CONSTRUCTION,
253 /** After reset. */
254 PDMDEVMEMSETUPCTX_AFTER_RESET,
255 /** Type size hack. */
256 PDMDEVMEMSETUPCTX_32BIT_HACK = 0x7fffffff
257} PDMDEVMEMSETUPCTX;
258
259
260/**
261 * PDM Device Registration Structure.
262 *
263 * This structure is used when registering a device from VBoxInitDevices() in HC
264 * Ring-3. PDM will continue use till the VM is terminated.
265 */
266typedef struct PDMDEVREG
267{
268 /** Structure version. PDM_DEVREG_VERSION defines the current version. */
269 uint32_t u32Version;
270 /** Device name. */
271 char szName[32];
272 /** Name of the raw-mode context module (no path).
273 * Only evalutated if PDM_DEVREG_FLAGS_RC is set. */
274 char szRCMod[32];
275 /** Name of the ring-0 module (no path).
276 * Only evalutated if PDM_DEVREG_FLAGS_R0 is set. */
277 char szR0Mod[32];
278 /** The description of the device. The UTF-8 string pointed to shall, like this structure,
279 * remain unchanged from registration till VM destruction. */
280 const char *pszDescription;
281
282 /** Flags, combination of the PDM_DEVREG_FLAGS_* \#defines. */
283 uint32_t fFlags;
284 /** Device class(es), combination of the PDM_DEVREG_CLASS_* \#defines. */
285 uint32_t fClass;
286 /** Maximum number of instances (per VM). */
287 uint32_t cMaxInstances;
288 /** Size of the instance data. */
289 uint32_t cbInstance;
290
291 /** Construct instance - required. */
292 PFNPDMDEVCONSTRUCT pfnConstruct;
293 /** Destruct instance - optional.
294 * Critical section NOT entered (will be destroyed). */
295 PFNPDMDEVDESTRUCT pfnDestruct;
296 /** Relocation command - optional.
297 * Critical section NOT entered. */
298 PFNPDMDEVRELOCATE pfnRelocate;
299
300 /**
301 * Memory setup callback.
302 *
303 * @param pDevIns The device instance data.
304 * @param enmCtx Indicates the context of the call.
305 * @remarks The critical section is entered prior to calling this method.
306 */
307 DECLR3CALLBACKMEMBER(void, pfnMemSetup, (PPDMDEVINS pDevIns, PDMDEVMEMSETUPCTX enmCtx));
308
309 /** Power on notification - optional.
310 * Critical section is entered. */
311 PFNPDMDEVPOWERON pfnPowerOn;
312 /** Reset notification - optional.
313 * Critical section is entered. */
314 PFNPDMDEVRESET pfnReset;
315 /** Suspend notification - optional.
316 * Critical section is entered. */
317 PFNPDMDEVSUSPEND pfnSuspend;
318 /** Resume notification - optional.
319 * Critical section is entered. */
320 PFNPDMDEVRESUME pfnResume;
321 /** Attach command - optional.
322 * Critical section is entered. */
323 PFNPDMDEVATTACH pfnAttach;
324 /** Detach notification - optional.
325 * Critical section is entered. */
326 PFNPDMDEVDETACH pfnDetach;
327 /** Query a LUN base interface - optional.
328 * Critical section is NOT entered. */
329 PFNPDMDEVQUERYINTERFACE pfnQueryInterface;
330 /** Init complete notification - optional.
331 * Critical section is entered. */
332 PFNPDMDEVINITCOMPLETE pfnInitComplete;
333 /** Power off notification - optional.
334 * Critical section is entered. */
335 PFNPDMDEVPOWEROFF pfnPowerOff;
336 /** @todo */
337 PFNRT pfnSoftReset;
338 /** Initialization safty marker. */
339 uint32_t u32VersionEnd;
340} PDMDEVREG;
341/** Pointer to a PDM Device Structure. */
342typedef PDMDEVREG *PPDMDEVREG;
343/** Const pointer to a PDM Device Structure. */
344typedef PDMDEVREG const *PCPDMDEVREG;
345
346/** Current DEVREG version number. */
347#define PDM_DEVREG_VERSION PDM_VERSION_MAKE(0xffff, 2, 0)
348
349/** PDM Device Flags.
350 * @{ */
351/** This flag is used to indicate that the device has a RC component. */
352#define PDM_DEVREG_FLAGS_RC 0x00000001
353/** This flag is used to indicate that the device has a R0 component. */
354#define PDM_DEVREG_FLAGS_R0 0x00000002
355
356/** @def PDM_DEVREG_FLAGS_HOST_BITS_DEFAULT
357 * The bit count for the current host. */
358#if HC_ARCH_BITS == 32
359# define PDM_DEVREG_FLAGS_HOST_BITS_DEFAULT 0x00000010
360#elif HC_ARCH_BITS == 64
361# define PDM_DEVREG_FLAGS_HOST_BITS_DEFAULT 0x00000020
362#else
363# error Unsupported HC_ARCH_BITS value.
364#endif
365/** The host bit count mask. */
366#define PDM_DEVREG_FLAGS_HOST_BITS_MASK 0x00000030
367
368/** The device support only 32-bit guests. */
369#define PDM_DEVREG_FLAGS_GUEST_BITS_32 0x00000100
370/** The device support only 64-bit guests. */
371#define PDM_DEVREG_FLAGS_GUEST_BITS_64 0x00000200
372/** The device support both 32-bit & 64-bit guests. */
373#define PDM_DEVREG_FLAGS_GUEST_BITS_32_64 0x00000300
374/** @def PDM_DEVREG_FLAGS_GUEST_BITS_DEFAULT
375 * The guest bit count for the current compilation. */
376#if GC_ARCH_BITS == 32
377# define PDM_DEVREG_FLAGS_GUEST_BITS_DEFAULT PDM_DEVREG_FLAGS_GUEST_BITS_32
378#elif GC_ARCH_BITS == 64
379# define PDM_DEVREG_FLAGS_GUEST_BITS_DEFAULT PDM_DEVREG_FLAGS_GUEST_BITS_32_64
380#else
381# error Unsupported GC_ARCH_BITS value.
382#endif
383/** The guest bit count mask. */
384#define PDM_DEVREG_FLAGS_GUEST_BITS_MASK 0x00000300
385
386/** A convenience. */
387#define PDM_DEVREG_FLAGS_DEFAULT_BITS (PDM_DEVREG_FLAGS_GUEST_BITS_DEFAULT | PDM_DEVREG_FLAGS_HOST_BITS_DEFAULT)
388
389/** Indicates that the devices support PAE36 on a 32-bit guest. */
390#define PDM_DEVREG_FLAGS_PAE36 0x00001000
391
392/** Indicates that the device needs to be notified before the drivers when suspending. */
393#define PDM_DEVREG_FLAGS_FIRST_SUSPEND_NOTIFICATION 0x00002000
394
395/** Indicates that the device needs to be notified before the drivers when powering off. */
396#define PDM_DEVREG_FLAGS_FIRST_POWEROFF_NOTIFICATION 0x00004000
397
398/** Indicates that the device needs to be notified before the drivers when resetting. */
399#define PDM_DEVREG_FLAGS_FIRST_RESET_NOTIFICATION 0x00008000
400/** @} */
401
402
403/** PDM Device Classes.
404 * The order is important, lower bit earlier instantiation.
405 * @{ */
406/** Architecture device. */
407#define PDM_DEVREG_CLASS_ARCH RT_BIT(0)
408/** Architecture BIOS device. */
409#define PDM_DEVREG_CLASS_ARCH_BIOS RT_BIT(1)
410/** PCI bus brigde. */
411#define PDM_DEVREG_CLASS_BUS_PCI RT_BIT(2)
412/** ISA bus brigde. */
413#define PDM_DEVREG_CLASS_BUS_ISA RT_BIT(3)
414/** Input device (mouse, keyboard, joystick, HID, ...). */
415#define PDM_DEVREG_CLASS_INPUT RT_BIT(4)
416/** Interrupt controller (PIC). */
417#define PDM_DEVREG_CLASS_PIC RT_BIT(5)
418/** Interval controoler (PIT). */
419#define PDM_DEVREG_CLASS_PIT RT_BIT(6)
420/** RTC/CMOS. */
421#define PDM_DEVREG_CLASS_RTC RT_BIT(7)
422/** DMA controller. */
423#define PDM_DEVREG_CLASS_DMA RT_BIT(8)
424/** VMM Device. */
425#define PDM_DEVREG_CLASS_VMM_DEV RT_BIT(9)
426/** Graphics device, like VGA. */
427#define PDM_DEVREG_CLASS_GRAPHICS RT_BIT(10)
428/** Storage controller device. */
429#define PDM_DEVREG_CLASS_STORAGE RT_BIT(11)
430/** Network interface controller. */
431#define PDM_DEVREG_CLASS_NETWORK RT_BIT(12)
432/** Audio. */
433#define PDM_DEVREG_CLASS_AUDIO RT_BIT(13)
434/** USB HIC. */
435#define PDM_DEVREG_CLASS_BUS_USB RT_BIT(14)
436/** ACPI. */
437#define PDM_DEVREG_CLASS_ACPI RT_BIT(15)
438/** Serial controller device. */
439#define PDM_DEVREG_CLASS_SERIAL RT_BIT(16)
440/** Parallel controller device */
441#define PDM_DEVREG_CLASS_PARALLEL RT_BIT(17)
442/** Host PCI pass-through device */
443#define PDM_DEVREG_CLASS_HOST_DEV RT_BIT(18)
444/** Misc devices (always last). */
445#define PDM_DEVREG_CLASS_MISC RT_BIT(31)
446/** @} */
447
448
449/** @name IRQ Level for use with the *SetIrq APIs.
450 * @{
451 */
452/** Assert the IRQ (can assume value 1). */
453#define PDM_IRQ_LEVEL_HIGH RT_BIT(0)
454/** Deassert the IRQ (can assume value 0). */
455#define PDM_IRQ_LEVEL_LOW 0
456/** flip-flop - deassert and then assert the IRQ again immediately. */
457#define PDM_IRQ_LEVEL_FLIP_FLOP (RT_BIT(1) | PDM_IRQ_LEVEL_HIGH)
458/** @} */
459
460/**
461 * Registration record for MSI.
462 */
463typedef struct PDMMSIREG
464{
465 /** Number of MSI interrupt vectors, 0 if MSI not supported */
466 uint16_t cMsiVectors;
467 /** Offset of MSI capability */
468 uint8_t iMsiCapOffset;
469 /** Offset of next capability to MSI */
470 uint8_t iMsiNextOffset;
471 /** If we support 64-bit MSI addressing */
472 bool fMsi64bit;
473
474 /** Number of MSI-X interrupt vectors, 0 if MSI-X not supported */
475 uint16_t cMsixVectors;
476 /** Offset of MSI-X capability */
477 uint8_t iMsixCapOffset;
478 /** Offset of next capability to MSI-X */
479 uint8_t iMsixNextOffset;
480 /** Value of PCI BAR (base addresss register) assigned by device for MSI-X page access */
481 uint8_t iMsixBar;
482} PDMMSIREG;
483typedef PDMMSIREG *PPDMMSIREG;
484
485/**
486 * PCI Bus registration structure.
487 * All the callbacks, except the PCIBIOS hack, are working on PCI devices.
488 */
489typedef struct PDMPCIBUSREG
490{
491 /** Structure version number. PDM_PCIBUSREG_VERSION defines the current version. */
492 uint32_t u32Version;
493
494 /**
495 * Registers the device with the default PCI bus.
496 *
497 * @returns VBox status code.
498 * @param pDevIns Device instance of the PCI Bus.
499 * @param pPciDev The PCI device structure.
500 * Any PCI enabled device must keep this in it's instance data!
501 * Fill in the PCI data config before registration, please.
502 * @param pszName Pointer to device name (permanent, readonly). For debugging, not unique.
503 * @param iDev The device number ((dev << 3) | function) the device should have on the bus.
504 * If negative, the pci bus device will assign one.
505 * @remarks Caller enters the PDM critical section.
506 */
507 DECLR3CALLBACKMEMBER(int, pfnRegisterR3,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, const char *pszName, int iDev));
508
509 /**
510 * Initialize MSI support in a PCI device.
511 *
512 * @returns VBox status code.
513 * @param pDevIns Device instance of the PCI Bus.
514 * @param pPciDev The PCI device structure.
515 * @param pMsiReg MSI registration structure
516 * @remarks Caller enters the PDM critical section.
517 */
518 DECLR3CALLBACKMEMBER(int, pfnRegisterMsiR3,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, PPDMMSIREG pMsiReg));
519
520 /**
521 * Registers a I/O region (memory mapped or I/O ports) for a PCI device.
522 *
523 * @returns VBox status code.
524 * @param pDevIns Device instance of the PCI Bus.
525 * @param pPciDev The PCI device structure.
526 * @param iRegion The region number.
527 * @param cbRegion Size of the region.
528 * @param iType PCI_ADDRESS_SPACE_MEM, PCI_ADDRESS_SPACE_IO or PCI_ADDRESS_SPACE_MEM_PREFETCH.
529 * @param pfnCallback Callback for doing the mapping.
530 * @remarks Caller enters the PDM critical section.
531 */
532 DECLR3CALLBACKMEMBER(int, pfnIORegionRegisterR3,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, int iRegion, uint32_t cbRegion, PCIADDRESSSPACE enmType, PFNPCIIOREGIONMAP pfnCallback));
533
534 /**
535 * Register PCI configuration space read/write callbacks.
536 *
537 * @param pDevIns Device instance of the PCI Bus.
538 * @param pPciDev The PCI device structure.
539 * @param pfnRead Pointer to the user defined PCI config read function.
540 * @param ppfnReadOld Pointer to function pointer which will receive the old (default)
541 * PCI config read function. This way, user can decide when (and if)
542 * to call default PCI config read function. Can be NULL.
543 * @param pfnWrite Pointer to the user defined PCI config write function.
544 * @param pfnWriteOld Pointer to function pointer which will receive the old (default)
545 * PCI config write function. This way, user can decide when (and if)
546 * to call default PCI config write function. Can be NULL.
547 * @remarks Caller enters the PDM critical section.
548 * @thread EMT
549 */
550 DECLR3CALLBACKMEMBER(void, pfnSetConfigCallbacksR3,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, PFNPCICONFIGREAD pfnRead, PPFNPCICONFIGREAD ppfnReadOld,
551 PFNPCICONFIGWRITE pfnWrite, PPFNPCICONFIGWRITE ppfnWriteOld));
552
553 /**
554 * Set the IRQ for a PCI device.
555 *
556 * @param pDevIns Device instance of the PCI Bus.
557 * @param pPciDev The PCI device structure.
558 * @param iIrq IRQ number to set.
559 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
560 * @param uTagSrc The IRQ tag and source (for tracing).
561 * @remarks Caller enters the PDM critical section.
562 */
563 DECLR3CALLBACKMEMBER(void, pfnSetIrqR3,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, int iIrq, int iLevel, uint32_t uTagSrc));
564
565 /**
566 * Called to perform the job of the bios.
567 * This is only called for the first PCI Bus - it is expected to
568 * service all the PCI buses.
569 *
570 * @returns VBox status.
571 * @param pDevIns Device instance of the first bus.
572 * @remarks Caller enters the PDM critical section.
573 */
574 DECLR3CALLBACKMEMBER(int, pfnFakePCIBIOSR3,(PPDMDEVINS pDevIns));
575
576 /** The name of the SetIrq RC entry point. */
577 const char *pszSetIrqRC;
578
579 /** The name of the SetIrq R0 entry point. */
580 const char *pszSetIrqR0;
581
582} PDMPCIBUSREG;
583/** Pointer to a PCI bus registration structure. */
584typedef PDMPCIBUSREG *PPDMPCIBUSREG;
585
586/** Current PDMPCIBUSREG version number. */
587#define PDM_PCIBUSREG_VERSION PDM_VERSION_MAKE(0xfffe, 4, 0)
588
589/**
590 * PCI Bus RC helpers.
591 */
592typedef struct PDMPCIHLPRC
593{
594 /** Structure version. PDM_PCIHLPRC_VERSION defines the current version. */
595 uint32_t u32Version;
596
597 /**
598 * Set an ISA IRQ.
599 *
600 * @param pDevIns PCI device instance.
601 * @param iIrq IRQ number to set.
602 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
603 * @param uTagSrc The IRQ tag and source (for tracing).
604 * @thread EMT only.
605 */
606 DECLRCCALLBACKMEMBER(void, pfnIsaSetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel, uint32_t uTagSrc));
607
608 /**
609 * Set an I/O-APIC IRQ.
610 *
611 * @param pDevIns PCI device instance.
612 * @param iIrq IRQ number to set.
613 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
614 * @param uTagSrc The IRQ tag and source (for tracing).
615 * @thread EMT only.
616 */
617 DECLRCCALLBACKMEMBER(void, pfnIoApicSetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel, uint32_t uTagSrc));
618
619 /**
620 * Send an MSI.
621 *
622 * @param pDevIns PCI device instance.
623 * @param GCPhys Physical address MSI request was written.
624 * @param uValue Value written.
625 * @param uTagSrc The IRQ tag and source (for tracing).
626 * @thread EMT only.
627 */
628 DECLRCCALLBACKMEMBER(void, pfnIoApicSendMsi,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, uint32_t uValue, uint32_t uTagSrc));
629
630
631 /**
632 * Acquires the PDM lock.
633 *
634 * @returns VINF_SUCCESS on success.
635 * @returns rc if we failed to acquire the lock.
636 * @param pDevIns The PCI device instance.
637 * @param rc What to return if we fail to acquire the lock.
638 */
639 DECLRCCALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
640
641 /**
642 * Releases the PDM lock.
643 *
644 * @param pDevIns The PCI device instance.
645 */
646 DECLRCCALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
647
648 /** Just a safety precaution. */
649 uint32_t u32TheEnd;
650} PDMPCIHLPRC;
651/** Pointer to PCI helpers. */
652typedef RCPTRTYPE(PDMPCIHLPRC *) PPDMPCIHLPRC;
653/** Pointer to const PCI helpers. */
654typedef RCPTRTYPE(const PDMPCIHLPRC *) PCPDMPCIHLPRC;
655
656/** Current PDMPCIHLPRC version number. */
657#define PDM_PCIHLPRC_VERSION PDM_VERSION_MAKE(0xfffd, 3, 0)
658
659
660/**
661 * PCI Bus R0 helpers.
662 */
663typedef struct PDMPCIHLPR0
664{
665 /** Structure version. PDM_PCIHLPR0_VERSION defines the current version. */
666 uint32_t u32Version;
667
668 /**
669 * Set an ISA IRQ.
670 *
671 * @param pDevIns PCI device instance.
672 * @param iIrq IRQ number to set.
673 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
674 * @param uTagSrc The IRQ tag and source (for tracing).
675 * @thread EMT only.
676 */
677 DECLR0CALLBACKMEMBER(void, pfnIsaSetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel, uint32_t uTagSrc));
678
679 /**
680 * Set an I/O-APIC IRQ.
681 *
682 * @param pDevIns PCI device instance.
683 * @param iIrq IRQ number to set.
684 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
685 * @param uTagSrc The IRQ tag and source (for tracing).
686 * @thread EMT only.
687 */
688 DECLR0CALLBACKMEMBER(void, pfnIoApicSetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel, uint32_t uTagSrc));
689
690 /**
691 * Send an MSI.
692 *
693 * @param pDevIns PCI device instance.
694 * @param GCPhys Physical address MSI request was written.
695 * @param uValue Value written.
696 * @param uTagSrc The IRQ tag and source (for tracing).
697 * @thread EMT only.
698 */
699 DECLR0CALLBACKMEMBER(void, pfnIoApicSendMsi,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, uint32_t uValue, uint32_t uTagSrc));
700
701
702 /**
703 * Acquires the PDM lock.
704 *
705 * @returns VINF_SUCCESS on success.
706 * @returns rc if we failed to acquire the lock.
707 * @param pDevIns The PCI device instance.
708 * @param rc What to return if we fail to acquire the lock.
709 */
710 DECLR0CALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
711
712 /**
713 * Releases the PDM lock.
714 *
715 * @param pDevIns The PCI device instance.
716 */
717 DECLR0CALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
718
719 /** Just a safety precaution. */
720 uint32_t u32TheEnd;
721} PDMPCIHLPR0;
722/** Pointer to PCI helpers. */
723typedef R0PTRTYPE(PDMPCIHLPR0 *) PPDMPCIHLPR0;
724/** Pointer to const PCI helpers. */
725typedef R0PTRTYPE(const PDMPCIHLPR0 *) PCPDMPCIHLPR0;
726
727/** Current PDMPCIHLPR0 version number. */
728#define PDM_PCIHLPR0_VERSION PDM_VERSION_MAKE(0xfffc, 3, 0)
729
730/**
731 * PCI device helpers.
732 */
733typedef struct PDMPCIHLPR3
734{
735 /** Structure version. PDM_PCIHLPR3_VERSION defines the current version. */
736 uint32_t u32Version;
737
738 /**
739 * Set an ISA IRQ.
740 *
741 * @param pDevIns The PCI device instance.
742 * @param iIrq IRQ number to set.
743 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
744 * @param uTagSrc The IRQ tag and source (for tracing).
745 */
746 DECLR3CALLBACKMEMBER(void, pfnIsaSetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel, uint32_t uTagSrc));
747
748 /**
749 * Set an I/O-APIC IRQ.
750 *
751 * @param pDevIns The PCI device instance.
752 * @param iIrq IRQ number to set.
753 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
754 * @param uTagSrc The IRQ tag and source (for tracing).
755 */
756 DECLR3CALLBACKMEMBER(void, pfnIoApicSetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel, uint32_t uTagSrc));
757
758 /**
759 * Send an MSI.
760 *
761 * @param pDevIns PCI device instance.
762 * @param GCPhys Physical address MSI request was written.
763 * @param uValue Value written.
764 * @param uTagSrc The IRQ tag and source (for tracing).
765 */
766 DECLR3CALLBACKMEMBER(void, pfnIoApicSendMsi,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, uint32_t uValue, uint32_t uTagSrc));
767
768 /**
769 * Checks if the given address is an MMIO2 base address or not.
770 *
771 * @returns true/false accordingly.
772 * @param pDevIns The PCI device instance.
773 * @param pOwner The owner of the memory, optional.
774 * @param GCPhys The address to check.
775 */
776 DECLR3CALLBACKMEMBER(bool, pfnIsMMIO2Base,(PPDMDEVINS pDevIns, PPDMDEVINS pOwner, RTGCPHYS GCPhys));
777
778 /**
779 * Gets the address of the RC PCI Bus helpers.
780 *
781 * This should be called at both construction and relocation time
782 * to obtain the correct address of the RC helpers.
783 *
784 * @returns RC pointer to the PCI Bus helpers.
785 * @param pDevIns Device instance of the PCI Bus.
786 * @thread EMT only.
787 */
788 DECLR3CALLBACKMEMBER(PCPDMPCIHLPRC, pfnGetRCHelpers,(PPDMDEVINS pDevIns));
789
790 /**
791 * Gets the address of the R0 PCI Bus helpers.
792 *
793 * This should be called at both construction and relocation time
794 * to obtain the correct address of the R0 helpers.
795 *
796 * @returns R0 pointer to the PCI Bus helpers.
797 * @param pDevIns Device instance of the PCI Bus.
798 * @thread EMT only.
799 */
800 DECLR3CALLBACKMEMBER(PCPDMPCIHLPR0, pfnGetR0Helpers,(PPDMDEVINS pDevIns));
801
802 /**
803 * Acquires the PDM lock.
804 *
805 * @returns VINF_SUCCESS on success.
806 * @returns Fatal error on failure.
807 * @param pDevIns The PCI device instance.
808 * @param rc Dummy for making the interface identical to the RC and R0 versions.
809 */
810 DECLR3CALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
811
812 /**
813 * Releases the PDM lock.
814 *
815 * @param pDevIns The PCI device instance.
816 */
817 DECLR3CALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
818
819 /** Just a safety precaution. */
820 uint32_t u32TheEnd;
821} PDMPCIHLPR3;
822/** Pointer to PCI helpers. */
823typedef R3PTRTYPE(PDMPCIHLPR3 *) PPDMPCIHLPR3;
824/** Pointer to const PCI helpers. */
825typedef R3PTRTYPE(const PDMPCIHLPR3 *) PCPDMPCIHLPR3;
826
827/** Current PDMPCIHLPR3 version number. */
828#define PDM_PCIHLPR3_VERSION PDM_VERSION_MAKE(0xfffb, 3, 0)
829
830
831/**
832 * Programmable Interrupt Controller registration structure.
833 */
834typedef struct PDMPICREG
835{
836 /** Structure version number. PDM_PICREG_VERSION defines the current version. */
837 uint32_t u32Version;
838
839 /**
840 * Set the an IRQ.
841 *
842 * @param pDevIns Device instance of the PIC.
843 * @param iIrq IRQ number to set.
844 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
845 * @param uTagSrc The IRQ tag and source (for tracing).
846 * @remarks Caller enters the PDM critical section.
847 */
848 DECLR3CALLBACKMEMBER(void, pfnSetIrqR3,(PPDMDEVINS pDevIns, int iIrq, int iLevel, uint32_t uTagSrc));
849
850 /**
851 * Get a pending interrupt.
852 *
853 * @returns Pending interrupt number.
854 * @param pDevIns Device instance of the PIC.
855 * @param puTagSrc Where to return the IRQ tag and source.
856 * @remarks Caller enters the PDM critical section.
857 */
858 DECLR3CALLBACKMEMBER(int, pfnGetInterruptR3,(PPDMDEVINS pDevIns, uint32_t *puTagSrc));
859
860 /** The name of the RC SetIrq entry point. */
861 const char *pszSetIrqRC;
862 /** The name of the RC GetInterrupt entry point. */
863 const char *pszGetInterruptRC;
864
865 /** The name of the R0 SetIrq entry point. */
866 const char *pszSetIrqR0;
867 /** The name of the R0 GetInterrupt entry point. */
868 const char *pszGetInterruptR0;
869} PDMPICREG;
870/** Pointer to a PIC registration structure. */
871typedef PDMPICREG *PPDMPICREG;
872
873/** Current PDMPICREG version number. */
874#define PDM_PICREG_VERSION PDM_VERSION_MAKE(0xfffa, 2, 0)
875
876/**
877 * PIC RC helpers.
878 */
879typedef struct PDMPICHLPRC
880{
881 /** Structure version. PDM_PICHLPRC_VERSION defines the current version. */
882 uint32_t u32Version;
883
884 /**
885 * Set the interrupt force action flag.
886 *
887 * @param pDevIns Device instance of the PIC.
888 */
889 DECLRCCALLBACKMEMBER(void, pfnSetInterruptFF,(PPDMDEVINS pDevIns));
890
891 /**
892 * Clear the interrupt force action flag.
893 *
894 * @param pDevIns Device instance of the PIC.
895 */
896 DECLRCCALLBACKMEMBER(void, pfnClearInterruptFF,(PPDMDEVINS pDevIns));
897
898 /**
899 * Acquires the PDM lock.
900 *
901 * @returns VINF_SUCCESS on success.
902 * @returns rc if we failed to acquire the lock.
903 * @param pDevIns The PIC device instance.
904 * @param rc What to return if we fail to acquire the lock.
905 */
906 DECLRCCALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
907
908 /**
909 * Releases the PDM lock.
910 *
911 * @param pDevIns The PIC device instance.
912 */
913 DECLRCCALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
914
915 /** Just a safety precaution. */
916 uint32_t u32TheEnd;
917} PDMPICHLPRC;
918
919/** Pointer to PIC RC helpers. */
920typedef RCPTRTYPE(PDMPICHLPRC *) PPDMPICHLPRC;
921/** Pointer to const PIC RC helpers. */
922typedef RCPTRTYPE(const PDMPICHLPRC *) PCPDMPICHLPRC;
923
924/** Current PDMPICHLPRC version number. */
925#define PDM_PICHLPRC_VERSION PDM_VERSION_MAKE(0xfff9, 2, 0)
926
927
928/**
929 * PIC R0 helpers.
930 */
931typedef struct PDMPICHLPR0
932{
933 /** Structure version. PDM_PICHLPR0_VERSION defines the current version. */
934 uint32_t u32Version;
935
936 /**
937 * Set the interrupt force action flag.
938 *
939 * @param pDevIns Device instance of the PIC.
940 */
941 DECLR0CALLBACKMEMBER(void, pfnSetInterruptFF,(PPDMDEVINS pDevIns));
942
943 /**
944 * Clear the interrupt force action flag.
945 *
946 * @param pDevIns Device instance of the PIC.
947 */
948 DECLR0CALLBACKMEMBER(void, pfnClearInterruptFF,(PPDMDEVINS pDevIns));
949
950 /**
951 * Acquires the PDM lock.
952 *
953 * @returns VINF_SUCCESS on success.
954 * @returns rc if we failed to acquire the lock.
955 * @param pDevIns The PIC device instance.
956 * @param rc What to return if we fail to acquire the lock.
957 */
958 DECLR0CALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
959
960 /**
961 * Releases the PDM lock.
962 *
963 * @param pDevIns The PCI device instance.
964 */
965 DECLR0CALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
966
967 /** Just a safety precaution. */
968 uint32_t u32TheEnd;
969} PDMPICHLPR0;
970
971/** Pointer to PIC R0 helpers. */
972typedef R0PTRTYPE(PDMPICHLPR0 *) PPDMPICHLPR0;
973/** Pointer to const PIC R0 helpers. */
974typedef R0PTRTYPE(const PDMPICHLPR0 *) PCPDMPICHLPR0;
975
976/** Current PDMPICHLPR0 version number. */
977#define PDM_PICHLPR0_VERSION PDM_VERSION_MAKE(0xfff8, 1, 0)
978
979/**
980 * PIC R3 helpers.
981 */
982typedef struct PDMPICHLPR3
983{
984 /** Structure version. PDM_PICHLP_VERSION defines the current version. */
985 uint32_t u32Version;
986
987 /**
988 * Set the interrupt force action flag.
989 *
990 * @param pDevIns Device instance of the PIC.
991 */
992 DECLR3CALLBACKMEMBER(void, pfnSetInterruptFF,(PPDMDEVINS pDevIns));
993
994 /**
995 * Clear the interrupt force action flag.
996 *
997 * @param pDevIns Device instance of the PIC.
998 */
999 DECLR3CALLBACKMEMBER(void, pfnClearInterruptFF,(PPDMDEVINS pDevIns));
1000
1001 /**
1002 * Acquires the PDM lock.
1003 *
1004 * @returns VINF_SUCCESS on success.
1005 * @returns Fatal error on failure.
1006 * @param pDevIns The PIC device instance.
1007 * @param rc Dummy for making the interface identical to the RC and R0 versions.
1008 */
1009 DECLR3CALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
1010
1011 /**
1012 * Releases the PDM lock.
1013 *
1014 * @param pDevIns The PIC device instance.
1015 */
1016 DECLR3CALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
1017
1018 /**
1019 * Gets the address of the RC PIC helpers.
1020 *
1021 * This should be called at both construction and relocation time
1022 * to obtain the correct address of the RC helpers.
1023 *
1024 * @returns RC pointer to the PIC helpers.
1025 * @param pDevIns Device instance of the PIC.
1026 */
1027 DECLR3CALLBACKMEMBER(PCPDMPICHLPRC, pfnGetRCHelpers,(PPDMDEVINS pDevIns));
1028
1029 /**
1030 * Gets the address of the R0 PIC helpers.
1031 *
1032 * This should be called at both construction and relocation time
1033 * to obtain the correct address of the R0 helpers.
1034 *
1035 * @returns R0 pointer to the PIC helpers.
1036 * @param pDevIns Device instance of the PIC.
1037 */
1038 DECLR3CALLBACKMEMBER(PCPDMPICHLPR0, pfnGetR0Helpers,(PPDMDEVINS pDevIns));
1039
1040 /** Just a safety precaution. */
1041 uint32_t u32TheEnd;
1042} PDMPICHLPR3;
1043
1044/** Pointer to PIC R3 helpers. */
1045typedef R3PTRTYPE(PDMPICHLPR3 *) PPDMPICHLPR3;
1046/** Pointer to const PIC R3 helpers. */
1047typedef R3PTRTYPE(const PDMPICHLPR3 *) PCPDMPICHLPR3;
1048
1049/** Current PDMPICHLPR3 version number. */
1050#define PDM_PICHLPR3_VERSION PDM_VERSION_MAKE(0xfff7, 1, 0)
1051
1052
1053
1054/**
1055 * Advanced Programmable Interrupt Controller registration structure.
1056 */
1057typedef struct PDMAPICREG
1058{
1059 /** Structure version number. PDM_APICREG_VERSION defines the current version. */
1060 uint32_t u32Version;
1061
1062 /**
1063 * Get a pending interrupt.
1064 *
1065 * @returns Pending interrupt number.
1066 * @param pDevIns Device instance of the APIC.
1067 * @param idCpu The VCPU Id.
1068 * @param puTagSrc Where to return the tag source.
1069 * @remarks Caller enters the PDM critical section
1070 */
1071 DECLR3CALLBACKMEMBER(int, pfnGetInterruptR3,(PPDMDEVINS pDevIns, VMCPUID idCpu, uint32_t *puTagSrc));
1072
1073 /**
1074 * Check if the APIC has a pending interrupt/if a TPR change would active one
1075 *
1076 * @returns Pending interrupt yes/no
1077 * @param pDevIns Device instance of the APIC.
1078 * @param idCpu The VCPU Id.
1079 * @param pu8PendingIrq Where to store the highest priority pending IRQ
1080 * (optional, can be NULL).
1081 * @remarks Unlike the other callbacks, the PDM lock may not always be entered
1082 * prior to calling this method.
1083 */
1084 DECLR3CALLBACKMEMBER(bool, pfnHasPendingIrqR3,(PPDMDEVINS pDevIns, VMCPUID idCpu, uint8_t *pu8PendingIrq));
1085
1086 /**
1087 * Set the APIC base.
1088 *
1089 * @param pDevIns Device instance of the APIC.
1090 * @param idCpu The VCPU Id.
1091 * @param u64Base The new base.
1092 * @remarks Caller enters the PDM critical section.
1093 */
1094 DECLR3CALLBACKMEMBER(void, pfnSetBaseR3,(PPDMDEVINS pDevIns, VMCPUID idCpu, uint64_t u64Base));
1095
1096 /**
1097 * Get the APIC base.
1098 *
1099 * @returns Current base.
1100 * @param pDevIns Device instance of the APIC.
1101 * @param idCpu The VCPU Id.
1102 * @remarks Caller enters the PDM critical section.
1103 */
1104 DECLR3CALLBACKMEMBER(uint64_t, pfnGetBaseR3,(PPDMDEVINS pDevIns, VMCPUID idCpu));
1105
1106 /**
1107 * Set the TPR (task priority register).
1108 *
1109 * @param pDevIns Device instance of the APIC.
1110 * @param idCpu The VCPU id.
1111 * @param u8TPR The new TPR.
1112 * @remarks Caller enters the PDM critical section.
1113 */
1114 DECLR3CALLBACKMEMBER(void, pfnSetTPRR3,(PPDMDEVINS pDevIns, VMCPUID idCpu, uint8_t u8TPR));
1115
1116 /**
1117 * Get the TPR (task priority register).
1118 *
1119 * @returns The current TPR.
1120 * @param pDevIns Device instance of the APIC.
1121 * @param idCpu VCPU id
1122 * @remarks Caller enters the PDM critical section.
1123 */
1124 DECLR3CALLBACKMEMBER(uint8_t, pfnGetTPRR3,(PPDMDEVINS pDevIns, VMCPUID idCpu));
1125
1126 /**
1127 * Write to a MSR in APIC range.
1128 *
1129 * @returns VBox status code.
1130 * @param pDevIns Device instance of the APIC.
1131 * @param idCpu Target CPU.
1132 * @param u32Reg The MSR begin written to.
1133 * @param u64Value The value to write.
1134 *
1135 * @remarks Unlike the other callbacks, the PDM lock is not taken before
1136 * calling this method.
1137 */
1138 DECLR3CALLBACKMEMBER(int, pfnWriteMSRR3, (PPDMDEVINS pDevIns, VMCPUID idCpu, uint32_t u32Reg, uint64_t u64Value));
1139
1140 /**
1141 * Read from a MSR in APIC range.
1142 *
1143 * @returns VBox status code.
1144 * @param pDevIns Device instance of the APIC.
1145 * @param idCpu Target CPU.
1146 * @param u32Reg MSR to read.
1147 * @param pu64Value Where to return the read value.
1148 *
1149 * @remarks Unlike the other callbacks, the PDM lock is not taken before
1150 * calling this method.
1151 */
1152 DECLR3CALLBACKMEMBER(int, pfnReadMSRR3, (PPDMDEVINS pDevIns, VMCPUID idCpu, uint32_t u32Reg, uint64_t *pu64Value));
1153
1154 /**
1155 * Private interface between the IOAPIC and APIC.
1156 *
1157 * This is a low-level, APIC/IOAPIC implementation specific interface which
1158 * is registered with PDM only because it makes life so much simpler right
1159 * now (GC bits). This is a bad bad hack! The correct way of doing this
1160 * would involve some way of querying GC interfaces and relocating them.
1161 * Perhaps doing some kind of device init in GC...
1162 *
1163 * @returns status code.
1164 * @param pDevIns Device instance of the APIC.
1165 * @param u8Dest See APIC implementation.
1166 * @param u8DestMode See APIC implementation.
1167 * @param u8DeliveryMode See APIC implementation.
1168 * @param iVector See APIC implementation.
1169 * @param u8Polarity See APIC implementation.
1170 * @param u8TriggerMode See APIC implementation.
1171 * @param uTagSrc The IRQ tag and source (for tracing).
1172 * @remarks Caller enters the PDM critical section
1173 */
1174 DECLR3CALLBACKMEMBER(int, pfnBusDeliverR3,(PPDMDEVINS pDevIns, uint8_t u8Dest, uint8_t u8DestMode, uint8_t u8DeliveryMode,
1175 uint8_t iVector, uint8_t u8Polarity, uint8_t u8TriggerMode, uint32_t uTagSrc));
1176
1177 /**
1178 * Deliver a signal to CPU's local interrupt pins (LINT0/LINT1).
1179 *
1180 * Used for virtual wire mode when interrupts from the PIC are passed through
1181 * LAPIC.
1182 *
1183 * @returns status code.
1184 * @param pDevIns Device instance of the APIC.
1185 * @param u8Pin Local pin number (0 or 1 for current CPUs).
1186 * @param u8Level The level.
1187 * @param uTagSrc The IRQ tag and source (for tracing).
1188 * @remarks Caller enters the PDM critical section
1189 */
1190 DECLR3CALLBACKMEMBER(int, pfnLocalInterruptR3,(PPDMDEVINS pDevIns, uint8_t u8Pin, uint8_t u8Level));
1191
1192 /**
1193 * Get the APIC timer frequency (in Hz).
1194 *
1195 * @returns The frequency of the APIC timer.
1196 * @param pDevIns Device instance of the APIC.
1197 */
1198 DECLR3CALLBACKMEMBER(uint64_t, pfnGetTimerFreqR3, (PPDMDEVINS pDevIns));
1199
1200 /** The name of the RC GetInterrupt entry point. */
1201 const char *pszGetInterruptRC;
1202 /** The name of the RC HasPendingIrq entry point. */
1203 const char *pszHasPendingIrqRC;
1204 /** The name of the RC SetBase entry point. */
1205 const char *pszSetBaseRC;
1206 /** The name of the RC GetBase entry point. */
1207 const char *pszGetBaseRC;
1208 /** The name of the RC SetTPR entry point. */
1209 const char *pszSetTPRRC;
1210 /** The name of the RC GetTPR entry point. */
1211 const char *pszGetTPRRC;
1212 /** The name of the RC WriteMSR entry point. */
1213 const char *pszWriteMSRRC;
1214 /** The name of the RC ReadMSR entry point. */
1215 const char *pszReadMSRRC;
1216 /** The name of the RC BusDeliver entry point. */
1217 const char *pszBusDeliverRC;
1218 /** The name of the RC LocalInterrupt entry point. */
1219 const char *pszLocalInterruptRC;
1220 /** The name of the RC GetTimerFreq entry point. */
1221 const char *pszGetTimerFreqRC;
1222
1223 /** The name of the R0 GetInterrupt entry point. */
1224 const char *pszGetInterruptR0;
1225 /** The name of the R0 HasPendingIrq entry point. */
1226 const char *pszHasPendingIrqR0;
1227 /** The name of the R0 SetBase entry point. */
1228 const char *pszSetBaseR0;
1229 /** The name of the R0 GetBase entry point. */
1230 const char *pszGetBaseR0;
1231 /** The name of the R0 SetTPR entry point. */
1232 const char *pszSetTPRR0;
1233 /** The name of the R0 GetTPR entry point. */
1234 const char *pszGetTPRR0;
1235 /** The name of the R0 WriteMSR entry point. */
1236 const char *pszWriteMSRR0;
1237 /** The name of the R0 ReadMSR entry point. */
1238 const char *pszReadMSRR0;
1239 /** The name of the R0 BusDeliver entry point. */
1240 const char *pszBusDeliverR0;
1241 /** The name of the R0 LocalInterrupt entry point. */
1242 const char *pszLocalInterruptR0;
1243 /** The name of the R0 GetTimerFreq entry point. */
1244 const char *pszGetTimerFreqR0;
1245} PDMAPICREG;
1246/** Pointer to an APIC registration structure. */
1247typedef PDMAPICREG *PPDMAPICREG;
1248
1249/** Current PDMAPICREG version number. */
1250#define PDM_APICREG_VERSION PDM_VERSION_MAKE(0xfff6, 2, 0)
1251
1252
1253/**
1254 * APIC version argument for pfnChangeFeature.
1255 */
1256typedef enum PDMAPICVERSION
1257{
1258 /** Invalid 0 entry. */
1259 PDMAPICVERSION_INVALID = 0,
1260 /** No APIC. */
1261 PDMAPICVERSION_NONE,
1262 /** Standard APIC (X86_CPUID_FEATURE_EDX_APIC). */
1263 PDMAPICVERSION_APIC,
1264 /** Intel X2APIC (X86_CPUID_FEATURE_ECX_X2APIC). */
1265 PDMAPICVERSION_X2APIC,
1266 /** The usual 32-bit paranoia. */
1267 PDMAPICVERSION_32BIT_HACK = 0x7fffffff
1268} PDMAPICVERSION;
1269
1270/**
1271 * APIC irq argument for SetInterruptFF.
1272 */
1273typedef enum PDMAPICIRQ
1274{
1275 /** Invalid 0 entry. */
1276 PDMAPICIRQ_INVALID = 0,
1277 /** Normal hardware interrupt. */
1278 PDMAPICIRQ_HARDWARE,
1279 /** NMI. */
1280 PDMAPICIRQ_NMI,
1281 /** SMI. */
1282 PDMAPICIRQ_SMI,
1283 /** ExtINT (HW interrupt via PIC). */
1284 PDMAPICIRQ_EXTINT,
1285 /** The usual 32-bit paranoia. */
1286 PDMAPICIRQ_32BIT_HACK = 0x7fffffff
1287} PDMAPICIRQ;
1288
1289
1290/**
1291 * APIC RC helpers.
1292 */
1293typedef struct PDMAPICHLPRC
1294{
1295 /** Structure version. PDM_APICHLPRC_VERSION defines the current version. */
1296 uint32_t u32Version;
1297
1298 /**
1299 * Set the interrupt force action flag.
1300 *
1301 * @param pDevIns Device instance of the APIC.
1302 * @param enmType IRQ type.
1303 * @param idCpu Virtual CPU to set flag upon.
1304 */
1305 DECLRCCALLBACKMEMBER(void, pfnSetInterruptFF,(PPDMDEVINS pDevIns, PDMAPICIRQ enmType, VMCPUID idCpu));
1306
1307 /**
1308 * Clear the interrupt force action flag.
1309 *
1310 * @param pDevIns Device instance of the APIC.
1311 * @param enmType IRQ type.
1312 * @param idCpu Virtual CPU to clear flag upon.
1313 */
1314 DECLRCCALLBACKMEMBER(void, pfnClearInterruptFF,(PPDMDEVINS pDevIns, PDMAPICIRQ enmType, VMCPUID idCpu));
1315
1316 /**
1317 * Calculates an IRQ tag for a timer, IPI or similar event.
1318 *
1319 * @returns The IRQ tag.
1320 * @param pDevIns Device instance of the APIC.
1321 * @param u8Level PDM_IRQ_LEVEL_HIGH or PDM_IRQ_LEVEL_FLIP_FLOP.
1322 */
1323 DECLRCCALLBACKMEMBER(uint32_t, pfnCalcIrqTag,(PPDMDEVINS pDevIns, uint8_t u8Level));
1324
1325 /**
1326 * Modifies APIC-related bits in the CPUID feature mask.
1327 *
1328 * @param pDevIns Device instance of the APIC.
1329 * @param enmVersion Supported APIC version.
1330 */
1331 DECLRCCALLBACKMEMBER(void, pfnChangeFeature,(PPDMDEVINS pDevIns, PDMAPICVERSION enmVersion));
1332
1333 /**
1334 * Acquires the PDM lock.
1335 *
1336 * @returns VINF_SUCCESS on success.
1337 * @returns rc if we failed to acquire the lock.
1338 * @param pDevIns The APIC device instance.
1339 * @param rc What to return if we fail to acquire the lock.
1340 */
1341 DECLRCCALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
1342
1343 /**
1344 * Releases the PDM lock.
1345 *
1346 * @param pDevIns The APIC device instance.
1347 */
1348 DECLRCCALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
1349
1350 /**
1351 * Get the virtual CPU id corresponding to the current EMT.
1352 *
1353 * @param pDevIns The APIC device instance.
1354 */
1355 DECLRCCALLBACKMEMBER(VMCPUID, pfnGetCpuId,(PPDMDEVINS pDevIns));
1356
1357 /** Just a safety precaution. */
1358 uint32_t u32TheEnd;
1359} PDMAPICHLPRC;
1360/** Pointer to APIC GC helpers. */
1361typedef RCPTRTYPE(PDMAPICHLPRC *) PPDMAPICHLPRC;
1362/** Pointer to const APIC helpers. */
1363typedef RCPTRTYPE(const PDMAPICHLPRC *) PCPDMAPICHLPRC;
1364
1365/** Current PDMAPICHLPRC version number. */
1366#define PDM_APICHLPRC_VERSION PDM_VERSION_MAKE(0xfff5, 2, 0)
1367
1368
1369/**
1370 * APIC R0 helpers.
1371 */
1372typedef struct PDMAPICHLPR0
1373{
1374 /** Structure version. PDM_APICHLPR0_VERSION defines the current version. */
1375 uint32_t u32Version;
1376
1377 /**
1378 * Set the interrupt force action flag.
1379 *
1380 * @param pDevIns Device instance of the APIC.
1381 * @param enmType IRQ type.
1382 * @param idCpu Virtual CPU to set flag upon.
1383 */
1384 DECLR0CALLBACKMEMBER(void, pfnSetInterruptFF,(PPDMDEVINS pDevIns, PDMAPICIRQ enmType, VMCPUID idCpu));
1385
1386 /**
1387 * Clear the interrupt force action flag.
1388 *
1389 * @param pDevIns Device instance of the APIC.
1390 * @param enmType IRQ type.
1391 * @param idCpu Virtual CPU to clear flag upon.
1392 */
1393 DECLR0CALLBACKMEMBER(void, pfnClearInterruptFF,(PPDMDEVINS pDevIns, PDMAPICIRQ enmType, VMCPUID idCpu));
1394
1395 /**
1396 * Calculates an IRQ tag for a timer, IPI or similar event.
1397 *
1398 * @returns The IRQ tag.
1399 * @param pDevIns Device instance of the APIC.
1400 * @param u8Level PDM_IRQ_LEVEL_HIGH or PDM_IRQ_LEVEL_FLIP_FLOP.
1401 */
1402 DECLR0CALLBACKMEMBER(uint32_t, pfnCalcIrqTag,(PPDMDEVINS pDevIns, uint8_t u8Level));
1403
1404 /**
1405 * Modifies APIC-related bits in the CPUID feature mask.
1406 *
1407 * @param pDevIns Device instance of the APIC.
1408 * @param enmVersion Supported APIC version.
1409 */
1410 DECLR0CALLBACKMEMBER(void, pfnChangeFeature,(PPDMDEVINS pDevIns, PDMAPICVERSION enmVersion));
1411
1412 /**
1413 * Acquires the PDM lock.
1414 *
1415 * @returns VINF_SUCCESS on success.
1416 * @returns rc if we failed to acquire the lock.
1417 * @param pDevIns The APIC device instance.
1418 * @param rc What to return if we fail to acquire the lock.
1419 */
1420 DECLR0CALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
1421
1422 /**
1423 * Releases the PDM lock.
1424 *
1425 * @param pDevIns The APIC device instance.
1426 */
1427 DECLR0CALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
1428
1429 /**
1430 * Get the virtual CPU id corresponding to the current EMT.
1431 *
1432 * @param pDevIns The APIC device instance.
1433 */
1434 DECLR0CALLBACKMEMBER(VMCPUID, pfnGetCpuId,(PPDMDEVINS pDevIns));
1435
1436 /** Just a safety precaution. */
1437 uint32_t u32TheEnd;
1438} PDMAPICHLPR0;
1439/** Pointer to APIC GC helpers. */
1440typedef RCPTRTYPE(PDMAPICHLPR0 *) PPDMAPICHLPR0;
1441/** Pointer to const APIC helpers. */
1442typedef R0PTRTYPE(const PDMAPICHLPR0 *) PCPDMAPICHLPR0;
1443
1444/** Current PDMAPICHLPR0 version number. */
1445#define PDM_APICHLPR0_VERSION PDM_VERSION_MAKE(0xfff4, 2, 0)
1446
1447/**
1448 * APIC R3 helpers.
1449 */
1450typedef struct PDMAPICHLPR3
1451{
1452 /** Structure version. PDM_APICHLPR3_VERSION defines the current version. */
1453 uint32_t u32Version;
1454
1455 /**
1456 * Set the interrupt force action flag.
1457 *
1458 * @param pDevIns Device instance of the APIC.
1459 * @param enmType IRQ type.
1460 * @param idCpu Virtual CPU to set flag upon.
1461 */
1462 DECLR3CALLBACKMEMBER(void, pfnSetInterruptFF,(PPDMDEVINS pDevIns, PDMAPICIRQ enmType, VMCPUID idCpu));
1463
1464 /**
1465 * Clear the interrupt force action flag.
1466 *
1467 * @param pDevIns Device instance of the APIC.
1468 * @param enmType IRQ type.
1469 * @param idCpu Virtual CPU to clear flag upon.
1470 */
1471 DECLR3CALLBACKMEMBER(void, pfnClearInterruptFF,(PPDMDEVINS pDevIns, PDMAPICIRQ enmType, VMCPUID idCpu));
1472
1473 /**
1474 * Calculates an IRQ tag for a timer, IPI or similar event.
1475 *
1476 * @returns The IRQ tag.
1477 * @param pDevIns Device instance of the APIC.
1478 * @param u8Level PDM_IRQ_LEVEL_HIGH or PDM_IRQ_LEVEL_FLIP_FLOP.
1479 */
1480 DECLR3CALLBACKMEMBER(uint32_t, pfnCalcIrqTag,(PPDMDEVINS pDevIns, uint8_t u8Level));
1481
1482 /**
1483 * Modifies APIC-related bits in the CPUID feature mask.
1484 *
1485 * @param pDevIns Device instance of the APIC.
1486 * @param enmVersion Supported APIC version.
1487 */
1488 DECLR3CALLBACKMEMBER(void, pfnChangeFeature,(PPDMDEVINS pDevIns, PDMAPICVERSION enmVersion));
1489
1490 /**
1491 * Get the virtual CPU id corresponding to the current EMT.
1492 *
1493 * @param pDevIns The APIC device instance.
1494 */
1495 DECLR3CALLBACKMEMBER(VMCPUID, pfnGetCpuId,(PPDMDEVINS pDevIns));
1496
1497 /**
1498 * Sends SIPI to given virtual CPU.
1499 *
1500 * @param pDevIns The APIC device instance.
1501 * @param idCpu Virtual CPU to perform SIPI on
1502 * @param iVector SIPI vector
1503 */
1504 DECLR3CALLBACKMEMBER(void, pfnSendSipi,(PPDMDEVINS pDevIns, VMCPUID idCpu, uint32_t uVector));
1505
1506 /**
1507 * Sends init IPI to given virtual CPU, should result in reset and
1508 * halting till SIPI.
1509 *
1510 * @param pDevIns The APIC device instance.
1511 * @param idCpu Virtual CPU to perform SIPI on
1512 */
1513 DECLR3CALLBACKMEMBER(void, pfnSendInitIpi,(PPDMDEVINS pDevIns, VMCPUID idCpu));
1514
1515 /**
1516 * Gets the address of the RC APIC helpers.
1517 *
1518 * This should be called at both construction and relocation time
1519 * to obtain the correct address of the RC helpers.
1520 *
1521 * @returns GC pointer to the APIC helpers.
1522 * @param pDevIns Device instance of the APIC.
1523 */
1524 DECLR3CALLBACKMEMBER(PCPDMAPICHLPRC, pfnGetRCHelpers,(PPDMDEVINS pDevIns));
1525
1526 /**
1527 * Gets the address of the R0 APIC helpers.
1528 *
1529 * This should be called at both construction and relocation time
1530 * to obtain the correct address of the R0 helpers.
1531 *
1532 * @returns R0 pointer to the APIC helpers.
1533 * @param pDevIns Device instance of the APIC.
1534 */
1535 DECLR3CALLBACKMEMBER(PCPDMAPICHLPR0, pfnGetR0Helpers,(PPDMDEVINS pDevIns));
1536
1537 /**
1538 * Get the critical section used to synchronize the PICs, PCI and stuff.
1539 *
1540 * @returns Ring-3 pointer to the critical section.
1541 * @param pDevIns The APIC device instance.
1542 */
1543 DECLR3CALLBACKMEMBER(R3PTRTYPE(PPDMCRITSECT), pfnGetR3CritSect,(PPDMDEVINS pDevIns));
1544
1545 /**
1546 * Get the critical section used to synchronize the PICs, PCI and stuff.
1547 *
1548 * @returns Raw-mode context pointer to the critical section.
1549 * @param pDevIns The APIC device instance.
1550 */
1551 DECLR3CALLBACKMEMBER(RCPTRTYPE(PPDMCRITSECT), pfnGetRCCritSect,(PPDMDEVINS pDevIns));
1552
1553 /**
1554 * Get the critical section used to synchronize the PICs, PCI and stuff.
1555 *
1556 * @returns Ring-0 pointer to the critical section.
1557 * @param pDevIns The APIC device instance.
1558 */
1559 DECLR3CALLBACKMEMBER(R0PTRTYPE(PPDMCRITSECT), pfnGetR0CritSect,(PPDMDEVINS pDevIns));
1560
1561 /** Just a safety precaution. */
1562 uint32_t u32TheEnd;
1563} PDMAPICHLPR3;
1564/** Pointer to APIC helpers. */
1565typedef R3PTRTYPE(PDMAPICHLPR3 *) PPDMAPICHLPR3;
1566/** Pointer to const APIC helpers. */
1567typedef R3PTRTYPE(const PDMAPICHLPR3 *) PCPDMAPICHLPR3;
1568
1569/** Current PDMAPICHLP version number. */
1570#define PDM_APICHLPR3_VERSION PDM_VERSION_MAKE(0xfff3, 2, 0)
1571
1572
1573/**
1574 * I/O APIC registration structure.
1575 */
1576typedef struct PDMIOAPICREG
1577{
1578 /** Struct version+magic number (PDM_IOAPICREG_VERSION). */
1579 uint32_t u32Version;
1580
1581 /**
1582 * Set the an IRQ.
1583 *
1584 * @param pDevIns Device instance of the I/O APIC.
1585 * @param iIrq IRQ number to set.
1586 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
1587 * @param uTagSrc The IRQ tag and source (for tracing).
1588 * @remarks Caller enters the PDM critical section
1589 */
1590 DECLR3CALLBACKMEMBER(void, pfnSetIrqR3,(PPDMDEVINS pDevIns, int iIrq, int iLevel, uint32_t uTagSrc));
1591
1592 /** The name of the RC SetIrq entry point. */
1593 const char *pszSetIrqRC;
1594
1595 /** The name of the R0 SetIrq entry point. */
1596 const char *pszSetIrqR0;
1597
1598 /**
1599 * Send a MSI.
1600 *
1601 * @param pDevIns Device instance of the I/O APIC.
1602 * @param GCPhys Request address.
1603 * @param uValue Request value.
1604 * @param uTagSrc The IRQ tag and source (for tracing).
1605 * @remarks Caller enters the PDM critical section
1606 */
1607 DECLR3CALLBACKMEMBER(void, pfnSendMsiR3,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, uint32_t uValue, uint32_t uTagSrc));
1608
1609 /** The name of the RC SendMsi entry point. */
1610 const char *pszSendMsiRC;
1611
1612 /** The name of the R0 SendMsi entry point. */
1613 const char *pszSendMsiR0;
1614} PDMIOAPICREG;
1615/** Pointer to an APIC registration structure. */
1616typedef PDMIOAPICREG *PPDMIOAPICREG;
1617
1618/** Current PDMAPICREG version number. */
1619#define PDM_IOAPICREG_VERSION PDM_VERSION_MAKE(0xfff2, 3, 0)
1620
1621
1622/**
1623 * IOAPIC RC helpers.
1624 */
1625typedef struct PDMIOAPICHLPRC
1626{
1627 /** Structure version. PDM_IOAPICHLPRC_VERSION defines the current version. */
1628 uint32_t u32Version;
1629
1630 /**
1631 * Private interface between the IOAPIC and APIC.
1632 *
1633 * See comments about this hack on PDMAPICREG::pfnBusDeliverR3.
1634 *
1635 * @returns status code.
1636 * @param pDevIns Device instance of the IOAPIC.
1637 * @param u8Dest See APIC implementation.
1638 * @param u8DestMode See APIC implementation.
1639 * @param u8DeliveryMode See APIC implementation.
1640 * @param iVector See APIC implementation.
1641 * @param u8Polarity See APIC implementation.
1642 * @param u8TriggerMode See APIC implementation.
1643 * @param uTagSrc The IRQ tag and source (for tracing).
1644 */
1645 DECLRCCALLBACKMEMBER(int, pfnApicBusDeliver,(PPDMDEVINS pDevIns, uint8_t u8Dest, uint8_t u8DestMode, uint8_t u8DeliveryMode,
1646 uint8_t iVector, uint8_t u8Polarity, uint8_t u8TriggerMode, uint32_t uTagSrc));
1647
1648 /**
1649 * Acquires the PDM lock.
1650 *
1651 * @returns VINF_SUCCESS on success.
1652 * @returns rc if we failed to acquire the lock.
1653 * @param pDevIns The IOAPIC device instance.
1654 * @param rc What to return if we fail to acquire the lock.
1655 */
1656 DECLRCCALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
1657
1658 /**
1659 * Releases the PDM lock.
1660 *
1661 * @param pDevIns The IOAPIC device instance.
1662 */
1663 DECLRCCALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
1664
1665 /** Just a safety precaution. */
1666 uint32_t u32TheEnd;
1667} PDMIOAPICHLPRC;
1668/** Pointer to IOAPIC RC helpers. */
1669typedef RCPTRTYPE(PDMIOAPICHLPRC *) PPDMIOAPICHLPRC;
1670/** Pointer to const IOAPIC helpers. */
1671typedef RCPTRTYPE(const PDMIOAPICHLPRC *) PCPDMIOAPICHLPRC;
1672
1673/** Current PDMIOAPICHLPRC version number. */
1674#define PDM_IOAPICHLPRC_VERSION PDM_VERSION_MAKE(0xfff1, 2, 0)
1675
1676
1677/**
1678 * IOAPIC R0 helpers.
1679 */
1680typedef struct PDMIOAPICHLPR0
1681{
1682 /** Structure version. PDM_IOAPICHLPR0_VERSION defines the current version. */
1683 uint32_t u32Version;
1684
1685 /**
1686 * Private interface between the IOAPIC and APIC.
1687 *
1688 * See comments about this hack on PDMAPICREG::pfnBusDeliverR3.
1689 *
1690 * @returns status code.
1691 * @param pDevIns Device instance of the IOAPIC.
1692 * @param u8Dest See APIC implementation.
1693 * @param u8DestMode See APIC implementation.
1694 * @param u8DeliveryMode See APIC implementation.
1695 * @param iVector See APIC implementation.
1696 * @param u8Polarity See APIC implementation.
1697 * @param u8TriggerMode See APIC implementation.
1698 * @param uTagSrc The IRQ tag and source (for tracing).
1699 */
1700 DECLR0CALLBACKMEMBER(int, pfnApicBusDeliver,(PPDMDEVINS pDevIns, uint8_t u8Dest, uint8_t u8DestMode, uint8_t u8DeliveryMode,
1701 uint8_t iVector, uint8_t u8Polarity, uint8_t u8TriggerMode, uint32_t uTagSrc));
1702
1703 /**
1704 * Acquires the PDM lock.
1705 *
1706 * @returns VINF_SUCCESS on success.
1707 * @returns rc if we failed to acquire the lock.
1708 * @param pDevIns The IOAPIC device instance.
1709 * @param rc What to return if we fail to acquire the lock.
1710 */
1711 DECLR0CALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
1712
1713 /**
1714 * Releases the PDM lock.
1715 *
1716 * @param pDevIns The IOAPIC device instance.
1717 */
1718 DECLR0CALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
1719
1720 /** Just a safety precaution. */
1721 uint32_t u32TheEnd;
1722} PDMIOAPICHLPR0;
1723/** Pointer to IOAPIC R0 helpers. */
1724typedef R0PTRTYPE(PDMIOAPICHLPR0 *) PPDMIOAPICHLPR0;
1725/** Pointer to const IOAPIC helpers. */
1726typedef R0PTRTYPE(const PDMIOAPICHLPR0 *) PCPDMIOAPICHLPR0;
1727
1728/** Current PDMIOAPICHLPR0 version number. */
1729#define PDM_IOAPICHLPR0_VERSION PDM_VERSION_MAKE(0xfff0, 2, 0)
1730
1731/**
1732 * IOAPIC R3 helpers.
1733 */
1734typedef struct PDMIOAPICHLPR3
1735{
1736 /** Structure version. PDM_IOAPICHLPR3_VERSION defines the current version. */
1737 uint32_t u32Version;
1738
1739 /**
1740 * Private interface between the IOAPIC and APIC.
1741 *
1742 * See comments about this hack on PDMAPICREG::pfnBusDeliverR3.
1743 *
1744 * @returns status code
1745 * @param pDevIns Device instance of the IOAPIC.
1746 * @param u8Dest See APIC implementation.
1747 * @param u8DestMode See APIC implementation.
1748 * @param u8DeliveryMode See APIC implementation.
1749 * @param iVector See APIC implementation.
1750 * @param u8Polarity See APIC implementation.
1751 * @param u8TriggerMode See APIC implementation.
1752 * @param uTagSrc The IRQ tag and source (for tracing).
1753 */
1754 DECLR3CALLBACKMEMBER(int, pfnApicBusDeliver,(PPDMDEVINS pDevIns, uint8_t u8Dest, uint8_t u8DestMode, uint8_t u8DeliveryMode,
1755 uint8_t iVector, uint8_t u8Polarity, uint8_t u8TriggerMode, uint32_t uTagSrc));
1756
1757 /**
1758 * Acquires the PDM lock.
1759 *
1760 * @returns VINF_SUCCESS on success.
1761 * @returns Fatal error on failure.
1762 * @param pDevIns The IOAPIC device instance.
1763 * @param rc Dummy for making the interface identical to the GC and R0 versions.
1764 */
1765 DECLR3CALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
1766
1767 /**
1768 * Releases the PDM lock.
1769 *
1770 * @param pDevIns The IOAPIC device instance.
1771 */
1772 DECLR3CALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
1773
1774 /**
1775 * Gets the address of the RC IOAPIC helpers.
1776 *
1777 * This should be called at both construction and relocation time
1778 * to obtain the correct address of the RC helpers.
1779 *
1780 * @returns RC pointer to the IOAPIC helpers.
1781 * @param pDevIns Device instance of the IOAPIC.
1782 */
1783 DECLR3CALLBACKMEMBER(PCPDMIOAPICHLPRC, pfnGetRCHelpers,(PPDMDEVINS pDevIns));
1784
1785 /**
1786 * Gets the address of the R0 IOAPIC helpers.
1787 *
1788 * This should be called at both construction and relocation time
1789 * to obtain the correct address of the R0 helpers.
1790 *
1791 * @returns R0 pointer to the IOAPIC helpers.
1792 * @param pDevIns Device instance of the IOAPIC.
1793 */
1794 DECLR3CALLBACKMEMBER(PCPDMIOAPICHLPR0, pfnGetR0Helpers,(PPDMDEVINS pDevIns));
1795
1796 /** Just a safety precaution. */
1797 uint32_t u32TheEnd;
1798} PDMIOAPICHLPR3;
1799/** Pointer to IOAPIC R3 helpers. */
1800typedef R3PTRTYPE(PDMIOAPICHLPR3 *) PPDMIOAPICHLPR3;
1801/** Pointer to const IOAPIC helpers. */
1802typedef R3PTRTYPE(const PDMIOAPICHLPR3 *) PCPDMIOAPICHLPR3;
1803
1804/** Current PDMIOAPICHLPR3 version number. */
1805#define PDM_IOAPICHLPR3_VERSION PDM_VERSION_MAKE(0xffef, 2, 0)
1806
1807
1808/**
1809 * HPET registration structure.
1810 */
1811typedef struct PDMHPETREG
1812{
1813 /** Struct version+magic number (PDM_HPETREG_VERSION). */
1814 uint32_t u32Version;
1815
1816} PDMHPETREG;
1817/** Pointer to an HPET registration structure. */
1818typedef PDMHPETREG *PPDMHPETREG;
1819
1820/** Current PDMHPETREG version number. */
1821#define PDM_HPETREG_VERSION PDM_VERSION_MAKE(0xffe2, 1, 0)
1822
1823/**
1824 * HPET RC helpers.
1825 *
1826 * @remarks Keep this around in case HPET will need PDM interaction in again RC
1827 * at some later point.
1828 */
1829typedef struct PDMHPETHLPRC
1830{
1831 /** Structure version. PDM_HPETHLPRC_VERSION defines the current version. */
1832 uint32_t u32Version;
1833
1834 /** Just a safety precaution. */
1835 uint32_t u32TheEnd;
1836} PDMHPETHLPRC;
1837
1838/** Pointer to HPET RC helpers. */
1839typedef RCPTRTYPE(PDMHPETHLPRC *) PPDMHPETHLPRC;
1840/** Pointer to const HPET RC helpers. */
1841typedef RCPTRTYPE(const PDMHPETHLPRC *) PCPDMHPETHLPRC;
1842
1843/** Current PDMHPETHLPRC version number. */
1844#define PDM_HPETHLPRC_VERSION PDM_VERSION_MAKE(0xffee, 2, 0)
1845
1846
1847/**
1848 * HPET R0 helpers.
1849 *
1850 * @remarks Keep this around in case HPET will need PDM interaction in again R0
1851 * at some later point.
1852 */
1853typedef struct PDMHPETHLPR0
1854{
1855 /** Structure version. PDM_HPETHLPR0_VERSION defines the current version. */
1856 uint32_t u32Version;
1857
1858 /** Just a safety precaution. */
1859 uint32_t u32TheEnd;
1860} PDMHPETHLPR0;
1861
1862/** Pointer to HPET R0 helpers. */
1863typedef R0PTRTYPE(PDMHPETHLPR0 *) PPDMHPETHLPR0;
1864/** Pointer to const HPET R0 helpers. */
1865typedef R0PTRTYPE(const PDMHPETHLPR0 *) PCPDMHPETHLPR0;
1866
1867/** Current PDMHPETHLPR0 version number. */
1868#define PDM_HPETHLPR0_VERSION PDM_VERSION_MAKE(0xffed, 2, 0)
1869
1870/**
1871 * HPET R3 helpers.
1872 */
1873typedef struct PDMHPETHLPR3
1874{
1875 /** Structure version. PDM_HPETHLP_VERSION defines the current version. */
1876 uint32_t u32Version;
1877
1878 /**
1879 * Gets the address of the RC HPET helpers.
1880 *
1881 * This should be called at both construction and relocation time
1882 * to obtain the correct address of the RC helpers.
1883 *
1884 * @returns RC pointer to the HPET helpers.
1885 * @param pDevIns Device instance of the HPET.
1886 */
1887 DECLR3CALLBACKMEMBER(PCPDMHPETHLPRC, pfnGetRCHelpers,(PPDMDEVINS pDevIns));
1888
1889 /**
1890 * Gets the address of the R0 HPET helpers.
1891 *
1892 * This should be called at both construction and relocation time
1893 * to obtain the correct address of the R0 helpers.
1894 *
1895 * @returns R0 pointer to the HPET helpers.
1896 * @param pDevIns Device instance of the HPET.
1897 */
1898 DECLR3CALLBACKMEMBER(PCPDMHPETHLPR0, pfnGetR0Helpers,(PPDMDEVINS pDevIns));
1899
1900 /**
1901 * Set legacy mode on PIT and RTC.
1902 *
1903 * @returns VINF_SUCCESS on success.
1904 * @returns rc if we failed to set legacy mode.
1905 * @param pDevIns Device instance of the HPET.
1906 * @param fActivated Whether legacy mode is activated or deactivated.
1907 */
1908 DECLR3CALLBACKMEMBER(int, pfnSetLegacyMode,(PPDMDEVINS pDevIns, bool fActivated));
1909
1910
1911 /**
1912 * Set IRQ, bypassing ISA bus override rules.
1913 *
1914 * @returns VINF_SUCCESS on success.
1915 * @returns rc if we failed to set legacy mode.
1916 * @param pDevIns Device instance of the HPET.
1917 * @param fActivate Activate or deactivate legacy mode.
1918 */
1919 DECLR3CALLBACKMEMBER(int, pfnSetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
1920
1921 /** Just a safety precaution. */
1922 uint32_t u32TheEnd;
1923} PDMHPETHLPR3;
1924
1925/** Pointer to HPET R3 helpers. */
1926typedef R3PTRTYPE(PDMHPETHLPR3 *) PPDMHPETHLPR3;
1927/** Pointer to const HPET R3 helpers. */
1928typedef R3PTRTYPE(const PDMHPETHLPR3 *) PCPDMHPETHLPR3;
1929
1930/** Current PDMHPETHLPR3 version number. */
1931#define PDM_HPETHLPR3_VERSION PDM_VERSION_MAKE(0xffec, 2, 0)
1932
1933
1934/**
1935 * Raw PCI device registration structure.
1936 */
1937typedef struct PDMPCIRAWREG
1938{
1939 /** Struct version+magic number (PDM_PCIRAWREG_VERSION). */
1940 uint32_t u32Version;
1941 /** Just a safety precaution. */
1942 uint32_t u32TheEnd;
1943} PDMPCIRAWREG;
1944/** Pointer to a raw PCI registration structure. */
1945typedef PDMPCIRAWREG *PPDMPCIRAWREG;
1946
1947/** Current PDMPCIRAWREG version number. */
1948#define PDM_PCIRAWREG_VERSION PDM_VERSION_MAKE(0xffe1, 1, 0)
1949
1950/**
1951 * Raw PCI device raw-mode context helpers.
1952 */
1953typedef struct PDMPCIRAWHLPRC
1954{
1955 /** Structure version and magic number (PDM_PCIRAWHLPRC_VERSION). */
1956 uint32_t u32Version;
1957 /** Just a safety precaution. */
1958 uint32_t u32TheEnd;
1959} PDMPCIRAWHLPRC;
1960/** Pointer to a raw PCI deviec raw-mode context helper structure. */
1961typedef RCPTRTYPE(PDMPCIRAWHLPRC *) PPDMPCIRAWHLPRC;
1962/** Pointer to a const raw PCI deviec raw-mode context helper structure. */
1963typedef RCPTRTYPE(const PDMPCIRAWHLPRC *) PCPDMPCIRAWHLPRC;
1964
1965/** Current PDMPCIRAWHLPRC version number. */
1966#define PDM_PCIRAWHLPRC_VERSION PDM_VERSION_MAKE(0xffe0, 1, 0)
1967
1968/**
1969 * Raw PCI device ring-0 context helpers.
1970 */
1971typedef struct PDMPCIRAWHLPR0
1972{
1973 /** Structure version and magic number (PDM_PCIRAWHLPR0_VERSION). */
1974 uint32_t u32Version;
1975 /** Just a safety precaution. */
1976 uint32_t u32TheEnd;
1977} PDMPCIRAWHLPR0;
1978/** Pointer to a raw PCI deviec ring-0 context helper structure. */
1979typedef R0PTRTYPE(PDMPCIRAWHLPR0 *) PPDMPCIRAWHLPR0;
1980/** Pointer to a const raw PCI deviec ring-0 context helper structure. */
1981typedef R0PTRTYPE(const PDMPCIRAWHLPR0 *) PCPDMPCIRAWHLPR0;
1982
1983/** Current PDMPCIRAWHLPR0 version number. */
1984#define PDM_PCIRAWHLPR0_VERSION PDM_VERSION_MAKE(0xffdf, 1, 0)
1985
1986
1987/**
1988 * Raw PCI device ring-3 context helpers.
1989 */
1990typedef struct PDMPCIRAWHLPR3
1991{
1992 /** Undefined structure version and magic number. */
1993 uint32_t u32Version;
1994
1995 /**
1996 * Gets the address of the RC raw PCI device helpers.
1997 *
1998 * This should be called at both construction and relocation time to obtain
1999 * the correct address of the RC helpers.
2000 *
2001 * @returns RC pointer to the raw PCI device helpers.
2002 * @param pDevIns Device instance of the raw PCI device.
2003 */
2004 DECLR3CALLBACKMEMBER(PCPDMPCIRAWHLPRC, pfnGetRCHelpers,(PPDMDEVINS pDevIns));
2005
2006 /**
2007 * Gets the address of the R0 raw PCI device helpers.
2008 *
2009 * This should be called at both construction and relocation time to obtain
2010 * the correct address of the R0 helpers.
2011 *
2012 * @returns R0 pointer to the raw PCI device helpers.
2013 * @param pDevIns Device instance of the raw PCI device.
2014 */
2015 DECLR3CALLBACKMEMBER(PCPDMPCIRAWHLPR0, pfnGetR0Helpers,(PPDMDEVINS pDevIns));
2016
2017 /** Just a safety precaution. */
2018 uint32_t u32TheEnd;
2019} PDMPCIRAWHLPR3;
2020/** Pointer to raw PCI R3 helpers. */
2021typedef R3PTRTYPE(PDMPCIRAWHLPR3 *) PPDMPCIRAWHLPR3;
2022/** Pointer to const raw PCI R3 helpers. */
2023typedef R3PTRTYPE(const PDMPCIRAWHLPR3 *) PCPDMPCIRAWHLPR3;
2024
2025/** Current PDMPCIRAWHLPR3 version number. */
2026#define PDM_PCIRAWHLPR3_VERSION PDM_VERSION_MAKE(0xffde, 1, 0)
2027
2028
2029#ifdef IN_RING3
2030
2031/**
2032 * DMA Transfer Handler.
2033 *
2034 * @returns Number of bytes transferred.
2035 * @param pDevIns Device instance of the DMA.
2036 * @param pvUser User pointer.
2037 * @param uChannel Channel number.
2038 * @param off DMA position.
2039 * @param cb Block size.
2040 * @remarks The device lock is not taken, however, the DMA device lock is held.
2041 */
2042typedef DECLCALLBACK(uint32_t) FNDMATRANSFERHANDLER(PPDMDEVINS pDevIns, void *pvUser, unsigned uChannel, uint32_t off, uint32_t cb);
2043/** Pointer to a FNDMATRANSFERHANDLER(). */
2044typedef FNDMATRANSFERHANDLER *PFNDMATRANSFERHANDLER;
2045
2046/**
2047 * DMA Controller registration structure.
2048 */
2049typedef struct PDMDMAREG
2050{
2051 /** Structure version number. PDM_DMACREG_VERSION defines the current version. */
2052 uint32_t u32Version;
2053
2054 /**
2055 * Execute pending transfers.
2056 *
2057 * @returns A more work indiciator. I.e. 'true' if there is more to be done, and 'false' if all is done.
2058 * @param pDevIns Device instance of the DMAC.
2059 * @remarks No locks held, called on EMT(0) as a form of serialization.
2060 */
2061 DECLR3CALLBACKMEMBER(bool, pfnRun,(PPDMDEVINS pDevIns));
2062
2063 /**
2064 * Register transfer function for DMA channel.
2065 *
2066 * @param pDevIns Device instance of the DMAC.
2067 * @param uChannel Channel number.
2068 * @param pfnTransferHandler Device specific transfer function.
2069 * @param pvUSer User pointer to be passed to the callback.
2070 * @remarks No locks held, called on an EMT.
2071 */
2072 DECLR3CALLBACKMEMBER(void, pfnRegister,(PPDMDEVINS pDevIns, unsigned uChannel, PFNDMATRANSFERHANDLER pfnTransferHandler, void *pvUser));
2073
2074 /**
2075 * Read memory
2076 *
2077 * @returns Number of bytes read.
2078 * @param pDevIns Device instance of the DMAC.
2079 * @param pvBuffer Pointer to target buffer.
2080 * @param off DMA position.
2081 * @param cbBlock Block size.
2082 * @remarks No locks held, called on an EMT.
2083 */
2084 DECLR3CALLBACKMEMBER(uint32_t, pfnReadMemory,(PPDMDEVINS pDevIns, unsigned uChannel, void *pvBuffer, uint32_t off, uint32_t cbBlock));
2085
2086 /**
2087 * Write memory
2088 *
2089 * @returns Number of bytes written.
2090 * @param pDevIns Device instance of the DMAC.
2091 * @param pvBuffer Memory to write.
2092 * @param off DMA position.
2093 * @param cbBlock Block size.
2094 * @remarks No locks held, called on an EMT.
2095 */
2096 DECLR3CALLBACKMEMBER(uint32_t, pfnWriteMemory,(PPDMDEVINS pDevIns, unsigned uChannel, const void *pvBuffer, uint32_t off, uint32_t cbBlock));
2097
2098 /**
2099 * Set the DREQ line.
2100 *
2101 * @param pDevIns Device instance of the DMAC.
2102 * @param uChannel Channel number.
2103 * @param uLevel Level of the line.
2104 * @remarks No locks held, called on an EMT.
2105 */
2106 DECLR3CALLBACKMEMBER(void, pfnSetDREQ,(PPDMDEVINS pDevIns, unsigned uChannel, unsigned uLevel));
2107
2108 /**
2109 * Get channel mode
2110 *
2111 * @returns Channel mode.
2112 * @param pDevIns Device instance of the DMAC.
2113 * @param uChannel Channel number.
2114 * @remarks No locks held, called on an EMT.
2115 */
2116 DECLR3CALLBACKMEMBER(uint8_t, pfnGetChannelMode,(PPDMDEVINS pDevIns, unsigned uChannel));
2117
2118} PDMDMACREG;
2119/** Pointer to a DMAC registration structure. */
2120typedef PDMDMACREG *PPDMDMACREG;
2121
2122/** Current PDMDMACREG version number. */
2123#define PDM_DMACREG_VERSION PDM_VERSION_MAKE(0xffeb, 1, 0)
2124
2125
2126/**
2127 * DMA Controller device helpers.
2128 */
2129typedef struct PDMDMACHLP
2130{
2131 /** Structure version. PDM_DMACHLP_VERSION defines the current version. */
2132 uint32_t u32Version;
2133
2134 /* to-be-defined */
2135
2136} PDMDMACHLP;
2137/** Pointer to DMAC helpers. */
2138typedef PDMDMACHLP *PPDMDMACHLP;
2139/** Pointer to const DMAC helpers. */
2140typedef const PDMDMACHLP *PCPDMDMACHLP;
2141
2142/** Current PDMDMACHLP version number. */
2143#define PDM_DMACHLP_VERSION PDM_VERSION_MAKE(0xffea, 1, 0)
2144
2145#endif /* IN_RING3 */
2146
2147
2148
2149/**
2150 * RTC registration structure.
2151 */
2152typedef struct PDMRTCREG
2153{
2154 /** Structure version number. PDM_RTCREG_VERSION defines the current version. */
2155 uint32_t u32Version;
2156 uint32_t u32Alignment; /**< structure size alignment. */
2157
2158 /**
2159 * Write to a CMOS register and update the checksum if necessary.
2160 *
2161 * @returns VBox status code.
2162 * @param pDevIns Device instance of the RTC.
2163 * @param iReg The CMOS register index.
2164 * @param u8Value The CMOS register value.
2165 * @remarks Caller enters the device critical section.
2166 */
2167 DECLR3CALLBACKMEMBER(int, pfnWrite,(PPDMDEVINS pDevIns, unsigned iReg, uint8_t u8Value));
2168
2169 /**
2170 * Read a CMOS register.
2171 *
2172 * @returns VBox status code.
2173 * @param pDevIns Device instance of the RTC.
2174 * @param iReg The CMOS register index.
2175 * @param pu8Value Where to store the CMOS register value.
2176 * @remarks Caller enters the device critical section.
2177 */
2178 DECLR3CALLBACKMEMBER(int, pfnRead,(PPDMDEVINS pDevIns, unsigned iReg, uint8_t *pu8Value));
2179
2180} PDMRTCREG;
2181/** Pointer to a RTC registration structure. */
2182typedef PDMRTCREG *PPDMRTCREG;
2183/** Pointer to a const RTC registration structure. */
2184typedef const PDMRTCREG *PCPDMRTCREG;
2185
2186/** Current PDMRTCREG version number. */
2187#define PDM_RTCREG_VERSION PDM_VERSION_MAKE(0xffe9, 2, 0)
2188
2189
2190/**
2191 * RTC device helpers.
2192 */
2193typedef struct PDMRTCHLP
2194{
2195 /** Structure version. PDM_RTCHLP_VERSION defines the current version. */
2196 uint32_t u32Version;
2197
2198 /* to-be-defined */
2199
2200} PDMRTCHLP;
2201/** Pointer to RTC helpers. */
2202typedef PDMRTCHLP *PPDMRTCHLP;
2203/** Pointer to const RTC helpers. */
2204typedef const PDMRTCHLP *PCPDMRTCHLP;
2205
2206/** Current PDMRTCHLP version number. */
2207#define PDM_RTCHLP_VERSION PDM_VERSION_MAKE(0xffe8, 1, 0)
2208
2209
2210
2211#ifdef IN_RING3
2212
2213/**
2214 * PDM Device API.
2215 */
2216typedef struct PDMDEVHLPR3
2217{
2218 /** Structure version. PDM_DEVHLPR3_VERSION defines the current version. */
2219 uint32_t u32Version;
2220
2221 /**
2222 * Register a number of I/O ports with a device.
2223 *
2224 * These callbacks are of course for the host context (HC).
2225 * Register HC handlers before guest context (GC) handlers! There must be a
2226 * HC handler for every GC handler!
2227 *
2228 * @returns VBox status.
2229 * @param pDevIns The device instance to register the ports with.
2230 * @param Port First port number in the range.
2231 * @param cPorts Number of ports to register.
2232 * @param pvUser User argument.
2233 * @param pfnOut Pointer to function which is gonna handle OUT operations.
2234 * @param pfnIn Pointer to function which is gonna handle IN operations.
2235 * @param pfnOutStr Pointer to function which is gonna handle string OUT operations.
2236 * @param pfnInStr Pointer to function which is gonna handle string IN operations.
2237 * @param pszDesc Pointer to description string. This must not be freed.
2238 * @remarks Caller enters the device critical section prior to invoking the
2239 * registered callback methods.
2240 */
2241 DECLR3CALLBACKMEMBER(int, pfnIOPortRegister,(PPDMDEVINS pDevIns, RTIOPORT Port, RTIOPORT cPorts, RTHCPTR pvUser,
2242 PFNIOMIOPORTOUT pfnOut, PFNIOMIOPORTIN pfnIn,
2243 PFNIOMIOPORTOUTSTRING pfnOutStr, PFNIOMIOPORTINSTRING pfnInStr, const char *pszDesc));
2244
2245 /**
2246 * Register a number of I/O ports with a device for RC.
2247 *
2248 * These callbacks are for the raw-mode context (RC). Register ring-3 context
2249 * (R3) handlers before raw-mode context handlers! There must be a R3 handler
2250 * for every RC handler!
2251 *
2252 * @returns VBox status.
2253 * @param pDevIns The device instance to register the ports with
2254 * and which RC module to resolve the names
2255 * against.
2256 * @param Port First port number in the range.
2257 * @param cPorts Number of ports to register.
2258 * @param pvUser User argument.
2259 * @param pszOut Name of the RC function which is gonna handle OUT operations.
2260 * @param pszIn Name of the RC function which is gonna handle IN operations.
2261 * @param pszOutStr Name of the RC function which is gonna handle string OUT operations.
2262 * @param pszInStr Name of the RC function which is gonna handle string IN operations.
2263 * @param pszDesc Pointer to description string. This must not be freed.
2264 * @remarks Caller enters the device critical section prior to invoking the
2265 * registered callback methods.
2266 */
2267 DECLR3CALLBACKMEMBER(int, pfnIOPortRegisterRC,(PPDMDEVINS pDevIns, RTIOPORT Port, RTIOPORT cPorts, RTRCPTR pvUser,
2268 const char *pszOut, const char *pszIn,
2269 const char *pszOutStr, const char *pszInStr, const char *pszDesc));
2270
2271 /**
2272 * Register a number of I/O ports with a device.
2273 *
2274 * These callbacks are of course for the ring-0 host context (R0).
2275 * Register R3 (HC) handlers before R0 (R0) handlers! There must be a R3 (HC) handler for every R0 handler!
2276 *
2277 * @returns VBox status.
2278 * @param pDevIns The device instance to register the ports with.
2279 * @param Port First port number in the range.
2280 * @param cPorts Number of ports to register.
2281 * @param pvUser User argument. (if pointer, then it must be in locked memory!)
2282 * @param pszOut Name of the R0 function which is gonna handle OUT operations.
2283 * @param pszIn Name of the R0 function which is gonna handle IN operations.
2284 * @param pszOutStr Name of the R0 function which is gonna handle string OUT operations.
2285 * @param pszInStr Name of the R0 function which is gonna handle string IN operations.
2286 * @param pszDesc Pointer to description string. This must not be freed.
2287 * @remarks Caller enters the device critical section prior to invoking the
2288 * registered callback methods.
2289 */
2290 DECLR3CALLBACKMEMBER(int, pfnIOPortRegisterR0,(PPDMDEVINS pDevIns, RTIOPORT Port, RTIOPORT cPorts, RTR0PTR pvUser,
2291 const char *pszOut, const char *pszIn,
2292 const char *pszOutStr, const char *pszInStr, const char *pszDesc));
2293
2294 /**
2295 * Deregister I/O ports.
2296 *
2297 * This naturally affects both guest context (GC), ring-0 (R0) and ring-3 (R3/HC) handlers.
2298 *
2299 * @returns VBox status.
2300 * @param pDevIns The device instance owning the ports.
2301 * @param Port First port number in the range.
2302 * @param cPorts Number of ports to deregister.
2303 */
2304 DECLR3CALLBACKMEMBER(int, pfnIOPortDeregister,(PPDMDEVINS pDevIns, RTIOPORT Port, RTIOPORT cPorts));
2305
2306 /**
2307 * Register a Memory Mapped I/O (MMIO) region.
2308 *
2309 * These callbacks are of course for the ring-3 context (R3). Register HC
2310 * handlers before raw-mode context (RC) and ring-0 context (R0) handlers! There
2311 * must be a R3 handler for every RC and R0 handler!
2312 *
2313 * @returns VBox status.
2314 * @param pDevIns The device instance to register the MMIO with.
2315 * @param GCPhysStart First physical address in the range.
2316 * @param cbRange The size of the range (in bytes).
2317 * @param pvUser User argument.
2318 * @param pfnWrite Pointer to function which is gonna handle Write operations.
2319 * @param pfnRead Pointer to function which is gonna handle Read operations.
2320 * @param pfnFill Pointer to function which is gonna handle Fill/memset operations. (optional)
2321 * @param fFlags Flags, IOMMMIO_FLAGS_XXX.
2322 * @param pszDesc Pointer to description string. This must not be freed.
2323 * @remarks Caller enters the device critical section prior to invoking the
2324 * registered callback methods.
2325 */
2326 DECLR3CALLBACKMEMBER(int, pfnMMIORegister,(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, uint32_t cbRange, RTHCPTR pvUser,
2327 PFNIOMMMIOWRITE pfnWrite, PFNIOMMMIOREAD pfnRead, PFNIOMMMIOFILL pfnFill,
2328 uint32_t fFlags, const char *pszDesc));
2329
2330 /**
2331 * Register a Memory Mapped I/O (MMIO) region for GC.
2332 *
2333 * These callbacks are for the raw-mode context (RC). Register ring-3 context
2334 * (R3) handlers before guest context handlers! There must be a R3 handler for
2335 * every RC handler!
2336 *
2337 * @returns VBox status.
2338 * @param pDevIns The device instance to register the MMIO with.
2339 * @param GCPhysStart First physical address in the range.
2340 * @param cbRange The size of the range (in bytes).
2341 * @param pvUser User argument.
2342 * @param pszWrite Name of the RC function which is gonna handle Write operations.
2343 * @param pszRead Name of the RC function which is gonna handle Read operations.
2344 * @param pszFill Name of the RC function which is gonna handle Fill/memset operations. (optional)
2345 * @remarks Caller enters the device critical section prior to invoking the
2346 * registered callback methods.
2347 */
2348 DECLR3CALLBACKMEMBER(int, pfnMMIORegisterRC,(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, uint32_t cbRange, RTRCPTR pvUser,
2349 const char *pszWrite, const char *pszRead, const char *pszFill));
2350
2351 /**
2352 * Register a Memory Mapped I/O (MMIO) region for R0.
2353 *
2354 * These callbacks are for the ring-0 host context (R0). Register ring-3
2355 * constext (R3) handlers before R0 handlers! There must be a R3 handler for
2356 * every R0 handler!
2357 *
2358 * @returns VBox status.
2359 * @param pDevIns The device instance to register the MMIO with.
2360 * @param GCPhysStart First physical address in the range.
2361 * @param cbRange The size of the range (in bytes).
2362 * @param pvUser User argument. (if pointer, then it must be in locked memory!)
2363 * @param pszWrite Name of the RC function which is gonna handle Write operations.
2364 * @param pszRead Name of the RC function which is gonna handle Read operations.
2365 * @param pszFill Name of the RC function which is gonna handle Fill/memset operations. (optional)
2366 * @param pszDesc Obsolete. NULL is fine.
2367 * @remarks Caller enters the device critical section prior to invoking the
2368 * registered callback methods.
2369 */
2370 DECLR3CALLBACKMEMBER(int, pfnMMIORegisterR0,(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, uint32_t cbRange, RTR0PTR pvUser,
2371 const char *pszWrite, const char *pszRead, const char *pszFill));
2372
2373 /**
2374 * Deregister a Memory Mapped I/O (MMIO) region.
2375 *
2376 * This naturally affects both guest context (GC), ring-0 (R0) and ring-3 (R3/HC) handlers.
2377 *
2378 * @returns VBox status.
2379 * @param pDevIns The device instance owning the MMIO region(s).
2380 * @param GCPhysStart First physical address in the range.
2381 * @param cbRange The size of the range (in bytes).
2382 */
2383 DECLR3CALLBACKMEMBER(int, pfnMMIODeregister,(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, uint32_t cbRange));
2384
2385 /**
2386 * Allocate and register a MMIO2 region.
2387 *
2388 * As mentioned elsewhere, MMIO2 is just RAM spelled differently. It's
2389 * RAM associated with a device. It is also non-shared memory with a
2390 * permanent ring-3 mapping and page backing (presently).
2391 *
2392 * @returns VBox status.
2393 * @param pDevIns The device instance.
2394 * @param iRegion The region number. Use the PCI region number as
2395 * this must be known to the PCI bus device too. If
2396 * it's not associated with the PCI device, then
2397 * any number up to UINT8_MAX is fine.
2398 * @param cb The size (in bytes) of the region.
2399 * @param fFlags Reserved for future use, must be zero.
2400 * @param ppv Where to store the address of the ring-3 mapping
2401 * of the memory.
2402 * @param pszDesc Pointer to description string. This must not be
2403 * freed.
2404 * @thread EMT.
2405 */
2406 DECLR3CALLBACKMEMBER(int, pfnMMIO2Register,(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS cb, uint32_t fFlags, void **ppv, const char *pszDesc));
2407
2408 /**
2409 * Deregisters and frees a MMIO2 region.
2410 *
2411 * Any physical (and virtual) access handlers registered for the region must
2412 * be deregistered before calling this function.
2413 *
2414 * @returns VBox status code.
2415 * @param pDevIns The device instance.
2416 * @param iRegion The region number used during registration.
2417 * @thread EMT.
2418 */
2419 DECLR3CALLBACKMEMBER(int, pfnMMIO2Deregister,(PPDMDEVINS pDevIns, uint32_t iRegion));
2420
2421 /**
2422 * Maps a MMIO2 region into the physical memory space.
2423 *
2424 * A MMIO2 range may overlap with base memory if a lot of RAM
2425 * is configured for the VM, in which case we'll drop the base
2426 * memory pages. Presently we will make no attempt to preserve
2427 * anything that happens to be present in the base memory that
2428 * is replaced, this is of course incorrect but it's too much
2429 * effort.
2430 *
2431 * @returns VBox status code.
2432 * @param pDevIns The device instance.
2433 * @param iRegion The region number used during registration.
2434 * @param GCPhys The physical address to map it at.
2435 * @thread EMT.
2436 */
2437 DECLR3CALLBACKMEMBER(int, pfnMMIO2Map,(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS GCPhys));
2438
2439 /**
2440 * Unmaps a MMIO2 region previously mapped using pfnMMIO2Map.
2441 *
2442 * @returns VBox status code.
2443 * @param pDevIns The device instance.
2444 * @param iRegion The region number used during registration.
2445 * @param GCPhys The physical address it's currently mapped at.
2446 * @thread EMT.
2447 */
2448 DECLR3CALLBACKMEMBER(int, pfnMMIO2Unmap,(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS GCPhys));
2449
2450 /**
2451 * Maps a portion of an MMIO2 region into the hypervisor region.
2452 *
2453 * Callers of this API must never deregister the MMIO2 region before the
2454 * VM is powered off.
2455 *
2456 * @return VBox status code.
2457 * @param pDevIns The device owning the MMIO2 memory.
2458 * @param iRegion The region.
2459 * @param off The offset into the region. Will be rounded down
2460 * to closest page boundary.
2461 * @param cb The number of bytes to map. Will be rounded up
2462 * to the closest page boundary.
2463 * @param pszDesc Mapping description.
2464 * @param pRCPtr Where to store the RC address.
2465 */
2466 DECLR3CALLBACKMEMBER(int, pfnMMHyperMapMMIO2,(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS off, RTGCPHYS cb,
2467 const char *pszDesc, PRTRCPTR pRCPtr));
2468
2469 /**
2470 * Maps a portion of an MMIO2 region into kernel space (host).
2471 *
2472 * The kernel mapping will become invalid when the MMIO2 memory is deregistered
2473 * or the VM is terminated.
2474 *
2475 * @return VBox status code.
2476 * @param pDevIns The device owning the MMIO2 memory.
2477 * @param iRegion The region.
2478 * @param off The offset into the region. Must be page
2479 * aligned.
2480 * @param cb The number of bytes to map. Must be page
2481 * aligned.
2482 * @param pszDesc Mapping description.
2483 * @param pR0Ptr Where to store the R0 address.
2484 */
2485 DECLR3CALLBACKMEMBER(int, pfnMMIO2MapKernel,(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS off, RTGCPHYS cb,
2486 const char *pszDesc, PRTR0PTR pR0Ptr));
2487
2488 /**
2489 * Register a ROM (BIOS) region.
2490 *
2491 * It goes without saying that this is read-only memory. The memory region must be
2492 * in unassigned memory. I.e. from the top of the address space or on the PC in
2493 * the 0xa0000-0xfffff range.
2494 *
2495 * @returns VBox status.
2496 * @param pDevIns The device instance owning the ROM region.
2497 * @param GCPhysStart First physical address in the range.
2498 * Must be page aligned!
2499 * @param cbRange The size of the range (in bytes).
2500 * Must be page aligned!
2501 * @param pvBinary Pointer to the binary data backing the ROM image.
2502 * @param cbBinary The size of the binary pointer. This must
2503 * be equal or smaller than @a cbRange.
2504 * @param fFlags Shadow ROM flags, PGMPHYS_ROM_FLAGS_* in pgm.h.
2505 * @param pszDesc Pointer to description string. This must not be freed.
2506 *
2507 * @remark There is no way to remove the rom, automatically on device cleanup or
2508 * manually from the device yet. At present I doubt we need such features...
2509 */
2510 DECLR3CALLBACKMEMBER(int, pfnROMRegister,(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, uint32_t cbRange,
2511 const void *pvBinary, uint32_t cbBinary, uint32_t fFlags, const char *pszDesc));
2512
2513 /**
2514 * Changes the protection of shadowed ROM mapping.
2515 *
2516 * This is intented for use by the system BIOS, chipset or device in question to
2517 * change the protection of shadowed ROM code after init and on reset.
2518 *
2519 * @param pDevIns The device instance.
2520 * @param GCPhysStart Where the mapping starts.
2521 * @param cbRange The size of the mapping.
2522 * @param enmProt The new protection type.
2523 */
2524 DECLR3CALLBACKMEMBER(int, pfnROMProtectShadow,(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, uint32_t cbRange, PGMROMPROT enmProt));
2525
2526 /**
2527 * Register a save state data unit.
2528 *
2529 * @returns VBox status.
2530 * @param pDevIns The device instance.
2531 * @param pszName Data unit name.
2532 * @param uInstance The instance identifier of the data unit.
2533 * This must together with the name be unique.
2534 * @param uVersion Data layout version number.
2535 * @param cbGuess The approximate amount of data in the unit.
2536 * Only for progress indicators.
2537 * @param pszBefore Name of data unit which we should be put in
2538 * front of. Optional (NULL).
2539 *
2540 * @param pfnLivePrep Prepare live save callback, optional.
2541 * @param pfnLiveExec Execute live save callback, optional.
2542 * @param pfnLiveVote Vote live save callback, optional.
2543 *
2544 * @param pfnSavePrep Prepare save callback, optional.
2545 * @param pfnSaveExec Execute save callback, optional.
2546 * @param pfnSaveDone Done save callback, optional.
2547 *
2548 * @param pfnLoadPrep Prepare load callback, optional.
2549 * @param pfnLoadExec Execute load callback, optional.
2550 * @param pfnLoadDone Done load callback, optional.
2551 * @remarks Caller enters the device critical section prior to invoking the
2552 * registered callback methods.
2553 */
2554 DECLR3CALLBACKMEMBER(int, pfnSSMRegister,(PPDMDEVINS pDevIns, uint32_t uVersion, size_t cbGuess, const char *pszBefore,
2555 PFNSSMDEVLIVEPREP pfnLivePrep, PFNSSMDEVLIVEEXEC pfnLiveExec, PFNSSMDEVLIVEVOTE pfnLiveVote,
2556 PFNSSMDEVSAVEPREP pfnSavePrep, PFNSSMDEVSAVEEXEC pfnSaveExec, PFNSSMDEVSAVEDONE pfnSaveDone,
2557 PFNSSMDEVLOADPREP pfnLoadPrep, PFNSSMDEVLOADEXEC pfnLoadExec, PFNSSMDEVLOADDONE pfnLoadDone));
2558
2559 /**
2560 * Creates a timer.
2561 *
2562 * @returns VBox status.
2563 * @param pDevIns The device instance.
2564 * @param enmClock The clock to use on this timer.
2565 * @param pfnCallback Callback function.
2566 * @param pvUser User argument for the callback.
2567 * @param fFlags Flags, see TMTIMER_FLAGS_*.
2568 * @param pszDesc Pointer to description string which must stay around
2569 * until the timer is fully destroyed (i.e. a bit after TMTimerDestroy()).
2570 * @param ppTimer Where to store the timer on success.
2571 * @remarks Caller enters the device critical section prior to invoking the
2572 * callback.
2573 */
2574 DECLR3CALLBACKMEMBER(int, pfnTMTimerCreate,(PPDMDEVINS pDevIns, TMCLOCK enmClock, PFNTMTIMERDEV pfnCallback, void *pvUser, uint32_t fFlags, const char *pszDesc, PPTMTIMERR3 ppTimer));
2575
2576 /**
2577 * Get the real world UTC time adjusted for VM lag, user offset and warpdrive.
2578 *
2579 * @returns pTime.
2580 * @param pDevIns The device instance.
2581 * @param pTime Where to store the time.
2582 */
2583 DECLR3CALLBACKMEMBER(PRTTIMESPEC, pfnTMUtcNow,(PPDMDEVINS pDevIns, PRTTIMESPEC pTime));
2584
2585 /**
2586 * Read physical memory.
2587 *
2588 * @returns VINF_SUCCESS (for now).
2589 * @param pDevIns The device instance.
2590 * @param GCPhys Physical address start reading from.
2591 * @param pvBuf Where to put the read bits.
2592 * @param cbRead How many bytes to read.
2593 * @thread Any thread, but the call may involve the emulation thread.
2594 */
2595 DECLR3CALLBACKMEMBER(int, pfnPhysRead,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead));
2596
2597 /**
2598 * Write to physical memory.
2599 *
2600 * @returns VINF_SUCCESS for now, and later maybe VERR_EM_MEMORY.
2601 * @param pDevIns The device instance.
2602 * @param GCPhys Physical address to write to.
2603 * @param pvBuf What to write.
2604 * @param cbWrite How many bytes to write.
2605 * @thread Any thread, but the call may involve the emulation thread.
2606 */
2607 DECLR3CALLBACKMEMBER(int, pfnPhysWrite,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite));
2608
2609 /**
2610 * Requests the mapping of a guest page into ring-3.
2611 *
2612 * When you're done with the page, call pfnPhysReleasePageMappingLock() ASAP to
2613 * release it.
2614 *
2615 * This API will assume your intention is to write to the page, and will
2616 * therefore replace shared and zero pages. If you do not intend to modify the
2617 * page, use the pfnPhysGCPhys2CCPtrReadOnly() API.
2618 *
2619 * @returns VBox status code.
2620 * @retval VINF_SUCCESS on success.
2621 * @retval VERR_PGM_PHYS_PAGE_RESERVED it it's a valid page but has no physical
2622 * backing or if the page has any active access handlers. The caller
2623 * must fall back on using PGMR3PhysWriteExternal.
2624 * @retval VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS if it's not a valid physical address.
2625 *
2626 * @param pVM The VM handle.
2627 * @param GCPhys The guest physical address of the page that
2628 * should be mapped.
2629 * @param fFlags Flags reserved for future use, MBZ.
2630 * @param ppv Where to store the address corresponding to
2631 * GCPhys.
2632 * @param pLock Where to store the lock information that
2633 * pfnPhysReleasePageMappingLock needs.
2634 *
2635 * @remark Avoid calling this API from within critical sections (other than the
2636 * PGM one) because of the deadlock risk when we have to delegating the
2637 * task to an EMT.
2638 * @thread Any.
2639 */
2640 DECLR3CALLBACKMEMBER(int, pfnPhysGCPhys2CCPtr,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, uint32_t fFlags, void **ppv, PPGMPAGEMAPLOCK pLock));
2641
2642 /**
2643 * Requests the mapping of a guest page into ring-3, external threads.
2644 *
2645 * When you're done with the page, call pfnPhysReleasePageMappingLock() ASAP to
2646 * release it.
2647 *
2648 * @returns VBox status code.
2649 * @retval VINF_SUCCESS on success.
2650 * @retval VERR_PGM_PHYS_PAGE_RESERVED it it's a valid page but has no physical
2651 * backing or if the page as an active ALL access handler. The caller
2652 * must fall back on using PGMPhysRead.
2653 * @retval VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS if it's not a valid physical address.
2654 *
2655 * @param pDevIns The device instance.
2656 * @param GCPhys The guest physical address of the page that
2657 * should be mapped.
2658 * @param fFlags Flags reserved for future use, MBZ.
2659 * @param ppv Where to store the address corresponding to
2660 * GCPhys.
2661 * @param pLock Where to store the lock information that
2662 * pfnPhysReleasePageMappingLock needs.
2663 *
2664 * @remark Avoid calling this API from within critical sections.
2665 * @thread Any.
2666 */
2667 DECLR3CALLBACKMEMBER(int, pfnPhysGCPhys2CCPtrReadOnly,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, uint32_t fFlags, void const **ppv, PPGMPAGEMAPLOCK pLock));
2668
2669 /**
2670 * Release the mapping of a guest page.
2671 *
2672 * This is the counter part of pfnPhysGCPhys2CCPtr and
2673 * pfnPhysGCPhys2CCPtrReadOnly.
2674 *
2675 * @param pDevIns The device instance.
2676 * @param pLock The lock structure initialized by the mapping
2677 * function.
2678 */
2679 DECLR3CALLBACKMEMBER(void, pfnPhysReleasePageMappingLock,(PPDMDEVINS pDevIns, PPGMPAGEMAPLOCK pLock));
2680
2681 /**
2682 * Read guest physical memory by virtual address.
2683 *
2684 * @param pDevIns The device instance.
2685 * @param pvDst Where to put the read bits.
2686 * @param GCVirtSrc Guest virtual address to start reading from.
2687 * @param cb How many bytes to read.
2688 * @thread The emulation thread.
2689 */
2690 DECLR3CALLBACKMEMBER(int, pfnPhysReadGCVirt,(PPDMDEVINS pDevIns, void *pvDst, RTGCPTR GCVirtSrc, size_t cb));
2691
2692 /**
2693 * Write to guest physical memory by virtual address.
2694 *
2695 * @param pDevIns The device instance.
2696 * @param GCVirtDst Guest virtual address to write to.
2697 * @param pvSrc What to write.
2698 * @param cb How many bytes to write.
2699 * @thread The emulation thread.
2700 */
2701 DECLR3CALLBACKMEMBER(int, pfnPhysWriteGCVirt,(PPDMDEVINS pDevIns, RTGCPTR GCVirtDst, const void *pvSrc, size_t cb));
2702
2703 /**
2704 * Convert a guest virtual address to a guest physical address.
2705 *
2706 * @returns VBox status code.
2707 * @param pDevIns The device instance.
2708 * @param GCPtr Guest virtual address.
2709 * @param pGCPhys Where to store the GC physical address
2710 * corresponding to GCPtr.
2711 * @thread The emulation thread.
2712 * @remark Careful with page boundaries.
2713 */
2714 DECLR3CALLBACKMEMBER(int, pfnPhysGCPtr2GCPhys, (PPDMDEVINS pDevIns, RTGCPTR GCPtr, PRTGCPHYS pGCPhys));
2715
2716 /**
2717 * Allocate memory which is associated with current VM instance
2718 * and automatically freed on it's destruction.
2719 *
2720 * @returns Pointer to allocated memory. The memory is *NOT* zero-ed.
2721 * @param pDevIns The device instance.
2722 * @param cb Number of bytes to allocate.
2723 */
2724 DECLR3CALLBACKMEMBER(void *, pfnMMHeapAlloc,(PPDMDEVINS pDevIns, size_t cb));
2725
2726 /**
2727 * Allocate memory which is associated with current VM instance
2728 * and automatically freed on it's destruction. The memory is ZEROed.
2729 *
2730 * @returns Pointer to allocated memory. The memory is *NOT* zero-ed.
2731 * @param pDevIns The device instance.
2732 * @param cb Number of bytes to allocate.
2733 */
2734 DECLR3CALLBACKMEMBER(void *, pfnMMHeapAllocZ,(PPDMDEVINS pDevIns, size_t cb));
2735
2736 /**
2737 * Free memory allocated with pfnMMHeapAlloc() and pfnMMHeapAllocZ().
2738 *
2739 * @param pDevIns The device instance.
2740 * @param pv Pointer to the memory to free.
2741 */
2742 DECLR3CALLBACKMEMBER(void, pfnMMHeapFree,(PPDMDEVINS pDevIns, void *pv));
2743
2744 /**
2745 * Gets the VM state.
2746 *
2747 * @returns VM state.
2748 * @param pDevIns The device instance.
2749 * @thread Any thread (just keep in mind that it's volatile info).
2750 */
2751 DECLR3CALLBACKMEMBER(VMSTATE, pfnVMState, (PPDMDEVINS pDevIns));
2752
2753 /**
2754 * Checks if the VM was teleported and hasn't been fully resumed yet.
2755 *
2756 * @returns true / false.
2757 * @param pDevIns The device instance.
2758 * @thread Any thread.
2759 */
2760 DECLR3CALLBACKMEMBER(bool, pfnVMTeleportedAndNotFullyResumedYet,(PPDMDEVINS pDevIns));
2761
2762 /**
2763 * Set the VM error message
2764 *
2765 * @returns rc.
2766 * @param pDevIns The device instance.
2767 * @param rc VBox status code.
2768 * @param RT_SRC_POS_DECL Use RT_SRC_POS.
2769 * @param pszFormat Error message format string.
2770 * @param ... Error message arguments.
2771 */
2772 DECLR3CALLBACKMEMBER(int, pfnVMSetError,(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...));
2773
2774 /**
2775 * Set the VM error message
2776 *
2777 * @returns rc.
2778 * @param pDevIns The device instance.
2779 * @param rc VBox status code.
2780 * @param RT_SRC_POS_DECL Use RT_SRC_POS.
2781 * @param pszFormat Error message format string.
2782 * @param va Error message arguments.
2783 */
2784 DECLR3CALLBACKMEMBER(int, pfnVMSetErrorV,(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va));
2785
2786 /**
2787 * Set the VM runtime error message
2788 *
2789 * @returns VBox status code.
2790 * @param pDevIns The device instance.
2791 * @param fFlags The action flags. See VMSETRTERR_FLAGS_*.
2792 * @param pszErrorId Error ID string.
2793 * @param pszFormat Error message format string.
2794 * @param ... Error message arguments.
2795 */
2796 DECLR3CALLBACKMEMBER(int, pfnVMSetRuntimeError,(PPDMDEVINS pDevIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, ...));
2797
2798 /**
2799 * Set the VM runtime error message
2800 *
2801 * @returns VBox status code.
2802 * @param pDevIns The device instance.
2803 * @param fFlags The action flags. See VMSETRTERR_FLAGS_*.
2804 * @param pszErrorId Error ID string.
2805 * @param pszFormat Error message format string.
2806 * @param va Error message arguments.
2807 */
2808 DECLR3CALLBACKMEMBER(int, pfnVMSetRuntimeErrorV,(PPDMDEVINS pDevIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, va_list va));
2809
2810 /**
2811 * Stops the VM and enters the debugger to look at the guest state.
2812 *
2813 * Use the PDMDeviceDBGFStop() inline function with the RT_SRC_POS macro instead of
2814 * invoking this function directly.
2815 *
2816 * @returns VBox status code which must be passed up to the VMM.
2817 * @param pDevIns The device instance.
2818 * @param pszFile Filename of the assertion location.
2819 * @param iLine The linenumber of the assertion location.
2820 * @param pszFunction Function of the assertion location.
2821 * @param pszFormat Message. (optional)
2822 * @param args Message parameters.
2823 */
2824 DECLR3CALLBACKMEMBER(int, pfnDBGFStopV,(PPDMDEVINS pDevIns, const char *pszFile, unsigned iLine, const char *pszFunction, const char *pszFormat, va_list args));
2825
2826 /**
2827 * Register a info handler with DBGF,
2828 *
2829 * @returns VBox status code.
2830 * @param pDevIns The device instance.
2831 * @param pszName The identifier of the info.
2832 * @param pszDesc The description of the info and any arguments
2833 * the handler may take.
2834 * @param pfnHandler The handler function to be called to display the
2835 * info.
2836 */
2837 DECLR3CALLBACKMEMBER(int, pfnDBGFInfoRegister,(PPDMDEVINS pDevIns, const char *pszName, const char *pszDesc, PFNDBGFHANDLERDEV pfnHandler));
2838
2839 /**
2840 * Registers a set of registers for a device.
2841 *
2842 * The @a pvUser argument of the getter and setter callbacks will be
2843 * @a pDevIns. The register names will be prefixed by the device name followed
2844 * immediately by the instance number.
2845 *
2846 * @returns VBox status code.
2847 * @param pDevIns The device instance.
2848 * @param paRegisters The register descriptors.
2849 *
2850 * @remarks The device critical section is NOT entered prior to working the
2851 * callbacks registered via this helper!
2852 */
2853 DECLR3CALLBACKMEMBER(int, pfnDBGFRegRegister,(PPDMDEVINS pDevIns, PCDBGFREGDESC paRegisters));
2854
2855 /**
2856 * Gets the trace buffer handle.
2857 *
2858 * This is used by the macros found in VBox/vmm/dbgftrace.h and is not
2859 * really inteded for direct usage, thus no inline wrapper function.
2860 *
2861 * @returns Trace buffer handle or NIL_RTTRACEBUF.
2862 * @param pDevIns The device instance.
2863 */
2864 DECLR3CALLBACKMEMBER(RTTRACEBUF, pfnDBGFTraceBuf,(PPDMDEVINS pDevIns));
2865
2866 /**
2867 * Registers a statistics sample if statistics are enabled.
2868 *
2869 * @param pDevIns Device instance of the DMA.
2870 * @param pvSample Pointer to the sample.
2871 * @param enmType Sample type. This indicates what pvSample is
2872 * pointing at.
2873 * @param pszName Sample name. The name is on this form
2874 * "/<component>/<sample>". Further nesting is
2875 * possible.
2876 * @param enmUnit Sample unit.
2877 * @param pszDesc Sample description.
2878 */
2879 DECLR3CALLBACKMEMBER(void, pfnSTAMRegister,(PPDMDEVINS pDevIns, void *pvSample, STAMTYPE enmType, const char *pszName, STAMUNIT enmUnit, const char *pszDesc));
2880
2881 /**
2882 * Same as pfnSTAMRegister except that the name is specified in a
2883 * RTStrPrintf like fashion.
2884 *
2885 * @returns VBox status.
2886 * @param pDevIns Device instance of the DMA.
2887 * @param pvSample Pointer to the sample.
2888 * @param enmType Sample type. This indicates what pvSample is
2889 * pointing at.
2890 * @param enmVisibility Visibility type specifying whether unused
2891 * statistics should be visible or not.
2892 * @param enmUnit Sample unit.
2893 * @param pszDesc Sample description.
2894 * @param pszName The sample name format string.
2895 * @param ... Arguments to the format string.
2896 */
2897 DECLR3CALLBACKMEMBER(void, pfnSTAMRegisterF,(PPDMDEVINS pDevIns, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility,
2898 STAMUNIT enmUnit, const char *pszDesc, const char *pszName, ...));
2899
2900 /**
2901 * Same as pfnSTAMRegister except that the name is specified in a
2902 * RTStrPrintfV like fashion.
2903 *
2904 * @returns VBox status.
2905 * @param pDevIns Device instance of the DMA.
2906 * @param pvSample Pointer to the sample.
2907 * @param enmType Sample type. This indicates what pvSample is
2908 * pointing at.
2909 * @param enmVisibility Visibility type specifying whether unused
2910 * statistics should be visible or not.
2911 * @param enmUnit Sample unit.
2912 * @param pszDesc Sample description.
2913 * @param pszName The sample name format string.
2914 * @param args Arguments to the format string.
2915 */
2916 DECLR3CALLBACKMEMBER(void, pfnSTAMRegisterV,(PPDMDEVINS pDevIns, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility,
2917 STAMUNIT enmUnit, const char *pszDesc, const char *pszName, va_list args));
2918
2919 /**
2920 * Registers the device with the default PCI bus.
2921 *
2922 * @returns VBox status code.
2923 * @param pDevIns The device instance.
2924 * @param pPciDev The PCI device structure.
2925 * Any PCI enabled device must keep this in it's instance data!
2926 * Fill in the PCI data config before registration, please.
2927 * @remark This is the simple interface, a Ex interface will be created if
2928 * more features are needed later.
2929 */
2930 DECLR3CALLBACKMEMBER(int, pfnPCIRegister,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev));
2931
2932 /**
2933 * Initialize MSI support in a PCI device.
2934 *
2935 * @returns VBox status code.
2936 * @param pDevIns The device instance.
2937 * @param pMsiReg MSI registartion structure.
2938 */
2939 DECLR3CALLBACKMEMBER(int, pfnPCIRegisterMsi,(PPDMDEVINS pDevIns, PPDMMSIREG pMsiReg));
2940
2941 /**
2942 * Registers a I/O region (memory mapped or I/O ports) for a PCI device.
2943 *
2944 * @returns VBox status code.
2945 * @param pDevIns The device instance.
2946 * @param iRegion The region number.
2947 * @param cbRegion Size of the region.
2948 * @param enmType PCI_ADDRESS_SPACE_MEM, PCI_ADDRESS_SPACE_IO or PCI_ADDRESS_SPACE_MEM_PREFETCH.
2949 * @param pfnCallback Callback for doing the mapping.
2950 * @remarks The callback will be invoked holding the PDM lock. The device lock
2951 * is NOT take because that is very likely be a lock order violation.
2952 */
2953 DECLR3CALLBACKMEMBER(int, pfnPCIIORegionRegister,(PPDMDEVINS pDevIns, int iRegion, uint32_t cbRegion,
2954 PCIADDRESSSPACE enmType, PFNPCIIOREGIONMAP pfnCallback));
2955
2956 /**
2957 * Register PCI configuration space read/write callbacks.
2958 *
2959 * @param pDevIns The device instance.
2960 * @param pPciDev The PCI device structure.
2961 * If NULL the default PCI device for this device instance is used.
2962 * @param pfnRead Pointer to the user defined PCI config read function.
2963 * @param ppfnReadOld Pointer to function pointer which will receive the old (default)
2964 * PCI config read function. This way, user can decide when (and if)
2965 * to call default PCI config read function. Can be NULL.
2966 * @param pfnWrite Pointer to the user defined PCI config write function.
2967 * @param pfnWriteOld Pointer to function pointer which will receive the old (default)
2968 * PCI config write function. This way, user can decide when (and if)
2969 * to call default PCI config write function. Can be NULL.
2970 * @remarks The callbacks will be invoked holding the PDM lock. The device lock
2971 * is NOT take because that is very likely be a lock order violation.
2972 * @thread EMT
2973 */
2974 DECLR3CALLBACKMEMBER(void, pfnPCISetConfigCallbacks,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, PFNPCICONFIGREAD pfnRead, PPFNPCICONFIGREAD ppfnReadOld,
2975 PFNPCICONFIGWRITE pfnWrite, PPFNPCICONFIGWRITE ppfnWriteOld));
2976
2977 /**
2978 * Bus master physical memory read.
2979 *
2980 * @returns VINF_SUCCESS or VERR_PGM_PCI_PHYS_READ_BM_DISABLED, later maybe
2981 * VERR_EM_MEMORY. The informational status shall NOT be propagated!
2982 * @param pDevIns The device instance.
2983 * @param GCPhys Physical address start reading from.
2984 * @param pvBuf Where to put the read bits.
2985 * @param cbRead How many bytes to read.
2986 * @thread Any thread, but the call may involve the emulation thread.
2987 */
2988 DECLR3CALLBACKMEMBER(int, pfnPCIPhysRead,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead));
2989
2990 /**
2991 * Bus master physical memory write.
2992 *
2993 * @returns VINF_SUCCESS or VERR_PGM_PCI_PHYS_WRITE_BM_DISABLED, later maybe
2994 * VERR_EM_MEMORY. The informational status shall NOT be propagated!
2995 * @param pDevIns The device instance.
2996 * @param GCPhys Physical address to write to.
2997 * @param pvBuf What to write.
2998 * @param cbWrite How many bytes to write.
2999 * @thread Any thread, but the call may involve the emulation thread.
3000 */
3001 DECLR3CALLBACKMEMBER(int, pfnPCIPhysWrite,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite));
3002
3003 /**
3004 * Set the IRQ for a PCI device.
3005 *
3006 * @param pDevIns The device instance.
3007 * @param iIrq IRQ number to set.
3008 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
3009 * @thread Any thread, but will involve the emulation thread.
3010 */
3011 DECLR3CALLBACKMEMBER(void, pfnPCISetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
3012
3013 /**
3014 * Set the IRQ for a PCI device, but don't wait for EMT to process
3015 * the request when not called from EMT.
3016 *
3017 * @param pDevIns The device instance.
3018 * @param iIrq IRQ number to set.
3019 * @param iLevel IRQ level.
3020 * @thread Any thread, but will involve the emulation thread.
3021 */
3022 DECLR3CALLBACKMEMBER(void, pfnPCISetIrqNoWait,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
3023
3024 /**
3025 * Set ISA IRQ for a device.
3026 *
3027 * @param pDevIns The device instance.
3028 * @param iIrq IRQ number to set.
3029 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
3030 * @thread Any thread, but will involve the emulation thread.
3031 */
3032 DECLR3CALLBACKMEMBER(void, pfnISASetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
3033
3034 /**
3035 * Set the ISA IRQ for a device, but don't wait for EMT to process
3036 * the request when not called from EMT.
3037 *
3038 * @param pDevIns The device instance.
3039 * @param iIrq IRQ number to set.
3040 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
3041 * @thread Any thread, but will involve the emulation thread.
3042 */
3043 DECLR3CALLBACKMEMBER(void, pfnISASetIrqNoWait,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
3044
3045 /**
3046 * Attaches a driver (chain) to the device.
3047 *
3048 * The first call for a LUN this will serve as a registartion of the LUN. The pBaseInterface and
3049 * the pszDesc string will be registered with that LUN and kept around for PDMR3QueryDeviceLun().
3050 *
3051 * @returns VBox status code.
3052 * @param pDevIns The device instance.
3053 * @param iLun The logical unit to attach.
3054 * @param pBaseInterface Pointer to the base interface for that LUN. (device side / down)
3055 * @param ppBaseInterface Where to store the pointer to the base interface. (driver side / up)
3056 * @param pszDesc Pointer to a string describing the LUN. This string must remain valid
3057 * for the live of the device instance.
3058 */
3059 DECLR3CALLBACKMEMBER(int, pfnDriverAttach,(PPDMDEVINS pDevIns, uint32_t iLun, PPDMIBASE pBaseInterface,
3060 PPDMIBASE *ppBaseInterface, const char *pszDesc));
3061
3062 /**
3063 * Create a queue.
3064 *
3065 * @returns VBox status code.
3066 * @param pDevIns The device instance.
3067 * @param cbItem The size of a queue item.
3068 * @param cItems The number of items in the queue.
3069 * @param cMilliesInterval The number of milliseconds between polling the queue.
3070 * If 0 then the emulation thread will be notified whenever an item arrives.
3071 * @param pfnCallback The consumer function.
3072 * @param fRZEnabled Set if the queue should work in RC and R0.
3073 * @param pszName The queue base name. The instance number will be
3074 * appended automatically.
3075 * @param ppQueue Where to store the queue handle on success.
3076 * @thread The emulation thread.
3077 * @remarks The device critical section will NOT be entered before calling the
3078 * callback. No locks will be held, but for now it's safe to assume
3079 * that only one EMT will do queue callbacks at any one time.
3080 */
3081 DECLR3CALLBACKMEMBER(int, pfnQueueCreate,(PPDMDEVINS pDevIns, size_t cbItem, uint32_t cItems, uint32_t cMilliesInterval,
3082 PFNPDMQUEUEDEV pfnCallback, bool fRZEnabled, const char *pszName, PPDMQUEUE *ppQueue));
3083
3084 /**
3085 * Initializes a PDM critical section.
3086 *
3087 * The PDM critical sections are derived from the IPRT critical sections, but
3088 * works in RC and R0 as well.
3089 *
3090 * @returns VBox status code.
3091 * @param pDevIns The device instance.
3092 * @param pCritSect Pointer to the critical section.
3093 * @param RT_SRC_POS_DECL Use RT_SRC_POS.
3094 * @param pszNameFmt Format string for naming the critical section.
3095 * For statistics and lock validation.
3096 * @param va Arguments for the format string.
3097 */
3098 DECLR3CALLBACKMEMBER(int, pfnCritSectInit,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, RT_SRC_POS_DECL,
3099 const char *pszNameFmt, va_list va));
3100
3101 /**
3102 * Gets the NOP critical section.
3103 *
3104 * @returns The ring-3 address of the NOP critical section.
3105 * @param pDevIns The device instance.
3106 */
3107 DECLR3CALLBACKMEMBER(PPDMCRITSECT, pfnCritSectGetNop,(PPDMDEVINS pDevIns));
3108
3109 /**
3110 * Gets the NOP critical section.
3111 *
3112 * @returns The ring-0 address of the NOP critical section.
3113 * @param pDevIns The device instance.
3114 */
3115 DECLR3CALLBACKMEMBER(R0PTRTYPE(PPDMCRITSECT), pfnCritSectGetNopR0,(PPDMDEVINS pDevIns));
3116
3117 /**
3118 * Gets the NOP critical section.
3119 *
3120 * @returns The raw-mode context address of the NOP critical section.
3121 * @param pDevIns The device instance.
3122 */
3123 DECLR3CALLBACKMEMBER(RCPTRTYPE(PPDMCRITSECT), pfnCritSectGetNopRC,(PPDMDEVINS pDevIns));
3124
3125 /**
3126 * Changes the device level critical section from the automatically created
3127 * default to one desired by the device constructor.
3128 *
3129 * @returns VBox status code.
3130 * @param pDevIns The device instance.
3131 * @param pCritSect The critical section to use. NULL is not
3132 * valid, instead use the NOP critical
3133 * section.
3134 */
3135 DECLR3CALLBACKMEMBER(int, pfnSetDeviceCritSect,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect));
3136
3137 /**
3138 * Creates a PDM thread.
3139 *
3140 * This differs from the RTThreadCreate() API in that PDM takes care of suspending,
3141 * resuming, and destroying the thread as the VM state changes.
3142 *
3143 * @returns VBox status code.
3144 * @param pDevIns The device instance.
3145 * @param ppThread Where to store the thread 'handle'.
3146 * @param pvUser The user argument to the thread function.
3147 * @param pfnThread The thread function.
3148 * @param pfnWakeup The wakup callback. This is called on the EMT
3149 * thread when a state change is pending.
3150 * @param cbStack See RTThreadCreate.
3151 * @param enmType See RTThreadCreate.
3152 * @param pszName See RTThreadCreate.
3153 * @remarks The device critical section will NOT be entered prior to invoking
3154 * the function pointers.
3155 */
3156 DECLR3CALLBACKMEMBER(int, pfnThreadCreate,(PPDMDEVINS pDevIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADDEV pfnThread,
3157 PFNPDMTHREADWAKEUPDEV pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName));
3158
3159 /**
3160 * Set up asynchronous handling of a suspend, reset or power off notification.
3161 *
3162 * This shall only be called when getting the notification. It must be called
3163 * for each one.
3164 *
3165 * @returns VBox status code.
3166 * @param pDevIns The device instance.
3167 * @param pfnAsyncNotify The callback.
3168 * @thread EMT(0)
3169 * @remarks The caller will enter the device critical section prior to invoking
3170 * the callback.
3171 */
3172 DECLR3CALLBACKMEMBER(int, pfnSetAsyncNotification, (PPDMDEVINS pDevIns, PFNPDMDEVASYNCNOTIFY pfnAsyncNotify));
3173
3174 /**
3175 * Notify EMT(0) that the device has completed the asynchronous notification
3176 * handling.
3177 *
3178 * This can be called at any time, spurious calls will simply be ignored.
3179 *
3180 * @param pDevIns The device instance.
3181 * @thread Any
3182 */
3183 DECLR3CALLBACKMEMBER(void, pfnAsyncNotificationCompleted, (PPDMDEVINS pDevIns));
3184
3185 /**
3186 * Register the RTC device.
3187 *
3188 * @returns VBox status code.
3189 * @param pDevIns The device instance.
3190 * @param pRtcReg Pointer to a RTC registration structure.
3191 * @param ppRtcHlp Where to store the pointer to the helper
3192 * functions.
3193 */
3194 DECLR3CALLBACKMEMBER(int, pfnRTCRegister,(PPDMDEVINS pDevIns, PCPDMRTCREG pRtcReg, PCPDMRTCHLP *ppRtcHlp));
3195
3196 /**
3197 * Register the PCI Bus.
3198 *
3199 * @returns VBox status code.
3200 * @param pDevIns The device instance.
3201 * @param pPciBusReg Pointer to PCI bus registration structure.
3202 * @param ppPciHlpR3 Where to store the pointer to the PCI Bus
3203 * helpers.
3204 */
3205 DECLR3CALLBACKMEMBER(int, pfnPCIBusRegister,(PPDMDEVINS pDevIns, PPDMPCIBUSREG pPciBusReg, PCPDMPCIHLPR3 *ppPciHlpR3));
3206
3207 /**
3208 * Register the PIC device.
3209 *
3210 * @returns VBox status code.
3211 * @param pDevIns The device instance.
3212 * @param pPicReg Pointer to a PIC registration structure.
3213 * @param ppPicHlpR3 Where to store the pointer to the PIC HC
3214 * helpers.
3215 */
3216 DECLR3CALLBACKMEMBER(int, pfnPICRegister,(PPDMDEVINS pDevIns, PPDMPICREG pPicReg, PCPDMPICHLPR3 *ppPicHlpR3));
3217
3218 /**
3219 * Register the APIC device.
3220 *
3221 * @returns VBox status code.
3222 * @param pDevIns The device instance.
3223 * @param pApicReg Pointer to a APIC registration structure.
3224 * @param ppApicHlpR3 Where to store the pointer to the APIC helpers.
3225 */
3226 DECLR3CALLBACKMEMBER(int, pfnAPICRegister,(PPDMDEVINS pDevIns, PPDMAPICREG pApicReg, PCPDMAPICHLPR3 *ppApicHlpR3));
3227
3228 /**
3229 * Register the I/O APIC device.
3230 *
3231 * @returns VBox status code.
3232 * @param pDevIns The device instance.
3233 * @param pIoApicReg Pointer to a I/O APIC registration structure.
3234 * @param ppIoApicHlpR3 Where to store the pointer to the IOAPIC
3235 * helpers.
3236 */
3237 DECLR3CALLBACKMEMBER(int, pfnIOAPICRegister,(PPDMDEVINS pDevIns, PPDMIOAPICREG pIoApicReg, PCPDMIOAPICHLPR3 *ppIoApicHlpR3));
3238
3239 /**
3240 * Register the HPET device.
3241 *
3242 * @returns VBox status code.
3243 * @param pDevIns The device instance.
3244 * @param pHpetReg Pointer to a HPET registration structure.
3245 * @param ppHpetHlpR3 Where to store the pointer to the HPET
3246 * helpers.
3247 */
3248 DECLR3CALLBACKMEMBER(int, pfnHPETRegister,(PPDMDEVINS pDevIns, PPDMHPETREG pHpetReg, PCPDMHPETHLPR3 *ppHpetHlpR3));
3249
3250 /**
3251 * Register a raw PCI device.
3252 *
3253 * @returns VBox status code.
3254 * @param pDevIns The device instance.
3255 * @param pHpetReg Pointer to a raw PCI registration structure.
3256 * @param ppPciRawHlpR3 Where to store the pointer to the raw PCI
3257 * device helpers.
3258 */
3259 DECLR3CALLBACKMEMBER(int, pfnPciRawRegister,(PPDMDEVINS pDevIns, PPDMPCIRAWREG pPciRawReg, PCPDMPCIRAWHLPR3 *ppPciRawHlpR3));
3260
3261 /**
3262 * Register the DMA device.
3263 *
3264 * @returns VBox status code.
3265 * @param pDevIns The device instance.
3266 * @param pDmacReg Pointer to a DMAC registration structure.
3267 * @param ppDmacHlp Where to store the pointer to the DMA helpers.
3268 */
3269 DECLR3CALLBACKMEMBER(int, pfnDMACRegister,(PPDMDEVINS pDevIns, PPDMDMACREG pDmacReg, PCPDMDMACHLP *ppDmacHlp));
3270
3271 /**
3272 * Register transfer function for DMA channel.
3273 *
3274 * @returns VBox status code.
3275 * @param pDevIns The device instance.
3276 * @param uChannel Channel number.
3277 * @param pfnTransferHandler Device specific transfer callback function.
3278 * @param pvUser User pointer to pass to the callback.
3279 * @thread EMT
3280 */
3281 DECLR3CALLBACKMEMBER(int, pfnDMARegister,(PPDMDEVINS pDevIns, unsigned uChannel, PFNDMATRANSFERHANDLER pfnTransferHandler, void *pvUser));
3282
3283 /**
3284 * Read memory.
3285 *
3286 * @returns VBox status code.
3287 * @param pDevIns The device instance.
3288 * @param uChannel Channel number.
3289 * @param pvBuffer Pointer to target buffer.
3290 * @param off DMA position.
3291 * @param cbBlock Block size.
3292 * @param pcbRead Where to store the number of bytes which was
3293 * read. optional.
3294 * @thread EMT
3295 */
3296 DECLR3CALLBACKMEMBER(int, pfnDMAReadMemory,(PPDMDEVINS pDevIns, unsigned uChannel, void *pvBuffer, uint32_t off, uint32_t cbBlock, uint32_t *pcbRead));
3297
3298 /**
3299 * Write memory.
3300 *
3301 * @returns VBox status code.
3302 * @param pDevIns The device instance.
3303 * @param uChannel Channel number.
3304 * @param pvBuffer Memory to write.
3305 * @param off DMA position.
3306 * @param cbBlock Block size.
3307 * @param pcbWritten Where to store the number of bytes which was
3308 * written. optional.
3309 * @thread EMT
3310 */
3311 DECLR3CALLBACKMEMBER(int, pfnDMAWriteMemory,(PPDMDEVINS pDevIns, unsigned uChannel, const void *pvBuffer, uint32_t off, uint32_t cbBlock, uint32_t *pcbWritten));
3312
3313 /**
3314 * Set the DREQ line.
3315 *
3316 * @returns VBox status code.
3317 * @param pDevIns Device instance.
3318 * @param uChannel Channel number.
3319 * @param uLevel Level of the line.
3320 * @thread EMT
3321 */
3322 DECLR3CALLBACKMEMBER(int, pfnDMASetDREQ,(PPDMDEVINS pDevIns, unsigned uChannel, unsigned uLevel));
3323
3324 /**
3325 * Get channel mode.
3326 *
3327 * @returns Channel mode. See specs.
3328 * @param pDevIns The device instance.
3329 * @param uChannel Channel number.
3330 * @thread EMT
3331 */
3332 DECLR3CALLBACKMEMBER(uint8_t, pfnDMAGetChannelMode,(PPDMDEVINS pDevIns, unsigned uChannel));
3333
3334 /**
3335 * Schedule DMA execution.
3336 *
3337 * @param pDevIns The device instance.
3338 * @thread Any thread.
3339 */
3340 DECLR3CALLBACKMEMBER(void, pfnDMASchedule,(PPDMDEVINS pDevIns));
3341
3342 /**
3343 * Write CMOS value and update the checksum(s).
3344 *
3345 * @returns VBox status code.
3346 * @param pDevIns The device instance.
3347 * @param iReg The CMOS register index.
3348 * @param u8Value The CMOS register value.
3349 * @thread EMT
3350 */
3351 DECLR3CALLBACKMEMBER(int, pfnCMOSWrite,(PPDMDEVINS pDevIns, unsigned iReg, uint8_t u8Value));
3352
3353 /**
3354 * Read CMOS value.
3355 *
3356 * @returns VBox status code.
3357 * @param pDevIns The device instance.
3358 * @param iReg The CMOS register index.
3359 * @param pu8Value Where to store the CMOS register value.
3360 * @thread EMT
3361 */
3362 DECLR3CALLBACKMEMBER(int, pfnCMOSRead,(PPDMDEVINS pDevIns, unsigned iReg, uint8_t *pu8Value));
3363
3364 /**
3365 * Assert that the current thread is the emulation thread.
3366 *
3367 * @returns True if correct.
3368 * @returns False if wrong.
3369 * @param pDevIns The device instance.
3370 * @param pszFile Filename of the assertion location.
3371 * @param iLine The linenumber of the assertion location.
3372 * @param pszFunction Function of the assertion location.
3373 */
3374 DECLR3CALLBACKMEMBER(bool, pfnAssertEMT,(PPDMDEVINS pDevIns, const char *pszFile, unsigned iLine, const char *pszFunction));
3375
3376 /**
3377 * Assert that the current thread is NOT the emulation thread.
3378 *
3379 * @returns True if correct.
3380 * @returns False if wrong.
3381 * @param pDevIns The device instance.
3382 * @param pszFile Filename of the assertion location.
3383 * @param iLine The linenumber of the assertion location.
3384 * @param pszFunction Function of the assertion location.
3385 */
3386 DECLR3CALLBACKMEMBER(bool, pfnAssertOther,(PPDMDEVINS pDevIns, const char *pszFile, unsigned iLine, const char *pszFunction));
3387
3388 /**
3389 * Resolves the symbol for a raw-mode context interface.
3390 *
3391 * @returns VBox status code.
3392 * @param pDevIns The device instance.
3393 * @param pvInterface The interface structure.
3394 * @param cbInterface The size of the interface structure.
3395 * @param pszSymPrefix What to prefix the symbols in the list with
3396 * before resolving them. This must start with
3397 * 'dev' and contain the driver name.
3398 * @param pszSymList List of symbols corresponding to the interface.
3399 * There is generally a there is generally a define
3400 * holding this list associated with the interface
3401 * definition (INTERFACE_SYM_LIST). For more
3402 * details see PDMR3LdrGetInterfaceSymbols.
3403 * @thread EMT
3404 */
3405 DECLR3CALLBACKMEMBER(int, pfnLdrGetRCInterfaceSymbols,(PPDMDEVINS pDevIns, void *pvInterface, size_t cbInterface,
3406 const char *pszSymPrefix, const char *pszSymList));
3407
3408 /**
3409 * Resolves the symbol for a ring-0 context interface.
3410 *
3411 * @returns VBox status code.
3412 * @param pDevIns The device instance.
3413 * @param pvInterface The interface structure.
3414 * @param cbInterface The size of the interface structure.
3415 * @param pszSymPrefix What to prefix the symbols in the list with
3416 * before resolving them. This must start with
3417 * 'dev' and contain the driver name.
3418 * @param pszSymList List of symbols corresponding to the interface.
3419 * There is generally a there is generally a define
3420 * holding this list associated with the interface
3421 * definition (INTERFACE_SYM_LIST). For more
3422 * details see PDMR3LdrGetInterfaceSymbols.
3423 * @thread EMT
3424 */
3425 DECLR3CALLBACKMEMBER(int, pfnLdrGetR0InterfaceSymbols,(PPDMDEVINS pDevIns, void *pvInterface, size_t cbInterface,
3426 const char *pszSymPrefix, const char *pszSymList));
3427
3428 /**
3429 * Call the ring-0 request handler routine of the device.
3430 *
3431 * For this to work, the device must be ring-0 enabled and export a request
3432 * handler function. The name of the function must be the device name in
3433 * the PDMDRVREG struct prefixed with 'drvR0' and suffixed with
3434 * 'ReqHandler'. The device name will be captialized. It shall take the
3435 * exact same arguments as this function and be declared using
3436 * PDMBOTHCBDECL. See FNPDMDEVREQHANDLERR0.
3437 *
3438 * Unlike PDMDrvHlpCallR0, this is current unsuitable for more than a call
3439 * or two as the handler address will be resolved on each invocation. This
3440 * is the reason for the EMT only restriction as well.
3441 *
3442 * @returns VBox status code.
3443 * @retval VERR_SYMBOL_NOT_FOUND if the device doesn't export the required
3444 * handler function.
3445 * @retval VERR_ACCESS_DENIED if the device isn't ring-0 capable.
3446 *
3447 * @param pDevIns The device instance.
3448 * @param uOperation The operation to perform.
3449 * @param u64Arg 64-bit integer argument.
3450 * @thread EMT
3451 */
3452 DECLR3CALLBACKMEMBER(int, pfnCallR0,(PPDMDEVINS pDevIns, uint32_t uOperation, uint64_t u64Arg));
3453
3454 /**
3455 * Gets the reason for the most recent VM suspend.
3456 *
3457 * @returns The suspend reason. VMSUSPENDREASON_INVALID is returned if no
3458 * suspend has been made or if the pDevIns is invalid.
3459 * @param pDevIns The device instance.
3460 */
3461 DECLR3CALLBACKMEMBER(VMSUSPENDREASON, pfnVMGetSuspendReason,(PPDMDEVINS pDevIns));
3462
3463 /**
3464 * Gets the reason for the most recent VM resume.
3465 *
3466 * @returns The resume reason. VMRESUMEREASON_INVALID is returned if no
3467 * resume has been made or if the pDevIns is invalid.
3468 * @param pDevIns The device instance.
3469 */
3470 DECLR3CALLBACKMEMBER(VMRESUMEREASON, pfnVMGetResumeReason,(PPDMDEVINS pDevIns));
3471
3472
3473 /** Space reserved for future members.
3474 * @{ */
3475 DECLR3CALLBACKMEMBER(void, pfnReserved1,(void));
3476 DECLR3CALLBACKMEMBER(void, pfnReserved2,(void));
3477 DECLR3CALLBACKMEMBER(void, pfnReserved3,(void));
3478 DECLR3CALLBACKMEMBER(void, pfnReserved4,(void));
3479 DECLR3CALLBACKMEMBER(void, pfnReserved5,(void));
3480 DECLR3CALLBACKMEMBER(void, pfnReserved6,(void));
3481 DECLR3CALLBACKMEMBER(void, pfnReserved7,(void));
3482 /*DECLR3CALLBACKMEMBER(void, pfnReserved8,(void));
3483 DECLR3CALLBACKMEMBER(void, pfnReserved9,(void));*/
3484 /*DECLR3CALLBACKMEMBER(void, pfnReserved10,(void));*/
3485 /** @} */
3486
3487
3488 /** API available to trusted devices only.
3489 *
3490 * These APIs are providing unrestricted access to the guest and the VM,
3491 * or they are interacting intimately with PDM.
3492 *
3493 * @{
3494 */
3495
3496 /**
3497 * Gets the user mode VM handle. Restricted API.
3498 *
3499 * @returns User mode VM Handle.
3500 * @param pDevIns The device instance.
3501 */
3502 DECLR3CALLBACKMEMBER(PUVM, pfnGetUVM,(PPDMDEVINS pDevIns));
3503
3504 /**
3505 * Gets the global VM handle. Restricted API.
3506 *
3507 * @returns VM Handle.
3508 * @param pDevIns The device instance.
3509 */
3510 DECLR3CALLBACKMEMBER(PVM, pfnGetVM,(PPDMDEVINS pDevIns));
3511
3512 /**
3513 * Gets the VMCPU handle. Restricted API.
3514 *
3515 * @returns VMCPU Handle.
3516 * @param pDevIns The device instance.
3517 */
3518 DECLR3CALLBACKMEMBER(PVMCPU, pfnGetVMCPU,(PPDMDEVINS pDevIns));
3519
3520 /**
3521 * The the VM CPU ID of the current thread (restricted API).
3522 *
3523 * @returns The VMCPUID of the calling thread, NIL_CPUID if not EMT.
3524 * @param pDevIns The device instance.
3525 */
3526 DECLR3CALLBACKMEMBER(VMCPUID, pfnGetCurrentCpuId,(PPDMDEVINS pDevIns));
3527
3528 /**
3529 * Registers the VMM device heap
3530 *
3531 * @returns VBox status code.
3532 * @param pDevIns The device instance.
3533 * @param GCPhys The physical address.
3534 * @param pvHeap Ring 3 heap pointer.
3535 * @param cbSize Size of the heap.
3536 * @thread EMT.
3537 */
3538 DECLR3CALLBACKMEMBER(int, pfnRegisterVMMDevHeap,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTR3PTR pvHeap, unsigned cbSize));
3539
3540 /**
3541 * Unregisters the VMM device heap
3542 *
3543 * @returns VBox status code.
3544 * @param pDevIns The device instance.
3545 * @param GCPhys The physical address.
3546 * @thread EMT.
3547 */
3548 DECLR3CALLBACKMEMBER(int, pfnUnregisterVMMDevHeap,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys));
3549
3550 /**
3551 * Resets the VM.
3552 *
3553 * @returns The appropriate VBox status code to pass around on reset.
3554 * @param pDevIns The device instance.
3555 * @thread The emulation thread.
3556 */
3557 DECLR3CALLBACKMEMBER(int, pfnVMReset,(PPDMDEVINS pDevIns));
3558
3559 /**
3560 * Suspends the VM.
3561 *
3562 * @returns The appropriate VBox status code to pass around on suspend.
3563 * @param pDevIns The device instance.
3564 * @thread The emulation thread.
3565 */
3566 DECLR3CALLBACKMEMBER(int, pfnVMSuspend,(PPDMDEVINS pDevIns));
3567
3568 /**
3569 * Suspends, saves and powers off the VM.
3570 *
3571 * @returns The appropriate VBox status code to pass around.
3572 * @param pDevIns The device instance.
3573 * @thread An emulation thread.
3574 */
3575 DECLR3CALLBACKMEMBER(int, pfnVMSuspendSaveAndPowerOff,(PPDMDEVINS pDevIns));
3576
3577 /**
3578 * Power off the VM.
3579 *
3580 * @returns The appropriate VBox status code to pass around on power off.
3581 * @param pDevIns The device instance.
3582 * @thread The emulation thread.
3583 */
3584 DECLR3CALLBACKMEMBER(int, pfnVMPowerOff,(PPDMDEVINS pDevIns));
3585
3586 /**
3587 * Checks if the Gate A20 is enabled or not.
3588 *
3589 * @returns true if A20 is enabled.
3590 * @returns false if A20 is disabled.
3591 * @param pDevIns The device instance.
3592 * @thread The emulation thread.
3593 */
3594 DECLR3CALLBACKMEMBER(bool, pfnA20IsEnabled,(PPDMDEVINS pDevIns));
3595
3596 /**
3597 * Enables or disables the Gate A20.
3598 *
3599 * @param pDevIns The device instance.
3600 * @param fEnable Set this flag to enable the Gate A20; clear it
3601 * to disable.
3602 * @thread The emulation thread.
3603 */
3604 DECLR3CALLBACKMEMBER(void, pfnA20Set,(PPDMDEVINS pDevIns, bool fEnable));
3605
3606 /**
3607 * Get the specified CPUID leaf for the virtual CPU associated with the calling
3608 * thread.
3609 *
3610 * @param pDevIns The device instance.
3611 * @param iLeaf The CPUID leaf to get.
3612 * @param pEax Where to store the EAX value.
3613 * @param pEbx Where to store the EBX value.
3614 * @param pEcx Where to store the ECX value.
3615 * @param pEdx Where to store the EDX value.
3616 * @thread EMT.
3617 */
3618 DECLR3CALLBACKMEMBER(void, pfnGetCpuId,(PPDMDEVINS pDevIns, uint32_t iLeaf, uint32_t *pEax, uint32_t *pEbx, uint32_t *pEcx, uint32_t *pEdx));
3619
3620 /**
3621 * Get the current virtual clock time in a VM. The clock frequency must be
3622 * queried separately.
3623 *
3624 * @returns Current clock time.
3625 * @param pDevIns The device instance.
3626 */
3627 DECLR3CALLBACKMEMBER(uint64_t, pfnTMTimeVirtGet,(PPDMDEVINS pDevIns));
3628
3629 /**
3630 * Get the frequency of the virtual clock.
3631 *
3632 * @returns The clock frequency (not variable at run-time).
3633 * @param pDevIns The device instance.
3634 */
3635 DECLR3CALLBACKMEMBER(uint64_t, pfnTMTimeVirtGetFreq,(PPDMDEVINS pDevIns));
3636
3637 /**
3638 * Get the current virtual clock time in a VM, in nanoseconds.
3639 *
3640 * @returns Current clock time (in ns).
3641 * @param pDevIns The device instance.
3642 */
3643 DECLR3CALLBACKMEMBER(uint64_t, pfnTMTimeVirtGetNano,(PPDMDEVINS pDevIns));
3644
3645 /**
3646 * Gets the support driver session.
3647 *
3648 * This is intended for working with the semaphore API.
3649 *
3650 * @returns Support driver session handle.
3651 * @param pDrvIns The driver instance.
3652 */
3653 DECLR3CALLBACKMEMBER(PSUPDRVSESSION, pfnGetSupDrvSession,(PPDMDEVINS pDevIns));
3654
3655 /** @} */
3656
3657 /** Just a safety precaution. (PDM_DEVHLPR3_VERSION) */
3658 uint32_t u32TheEnd;
3659} PDMDEVHLPR3;
3660#endif /* !IN_RING3 */
3661/** Pointer to the R3 PDM Device API. */
3662typedef R3PTRTYPE(struct PDMDEVHLPR3 *) PPDMDEVHLPR3;
3663/** Pointer to the R3 PDM Device API, const variant. */
3664typedef R3PTRTYPE(const struct PDMDEVHLPR3 *) PCPDMDEVHLPR3;
3665
3666/** Current PDMDEVHLPR3 version number. */
3667#define PDM_DEVHLPR3_VERSION PDM_VERSION_MAKE(0xffe7, 14, 1)
3668
3669
3670/**
3671 * PDM Device API - RC Variant.
3672 */
3673typedef struct PDMDEVHLPRC
3674{
3675 /** Structure version. PDM_DEVHLPRC_VERSION defines the current version. */
3676 uint32_t u32Version;
3677
3678 /**
3679 * Bus master physical memory read.
3680 *
3681 * @returns VINF_SUCCESS or VERR_PGM_PCI_PHYS_READ_BM_DISABLED, later maybe
3682 * VERR_EM_MEMORY. The informational status shall NOT be propagated!
3683 * @param pDevIns The device instance.
3684 * @param GCPhys Physical address start reading from.
3685 * @param pvBuf Where to put the read bits.
3686 * @param cbRead How many bytes to read.
3687 * @thread Any thread, but the call may involve the emulation thread.
3688 */
3689 DECLRCCALLBACKMEMBER(int, pfnPCIPhysRead,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead));
3690
3691 /**
3692 * Bus master physical memory write.
3693 *
3694 * @returns VINF_SUCCESS or VERR_PGM_PCI_PHYS_WRITE_BM_DISABLED, later maybe
3695 * VERR_EM_MEMORY. The informational status shall NOT be propagated!
3696 * @param pDevIns The device instance.
3697 * @param GCPhys Physical address to write to.
3698 * @param pvBuf What to write.
3699 * @param cbWrite How many bytes to write.
3700 * @thread Any thread, but the call may involve the emulation thread.
3701 */
3702 DECLRCCALLBACKMEMBER(int, pfnPCIPhysWrite,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite));
3703
3704 /**
3705 * Set the IRQ for a PCI device.
3706 *
3707 * @param pDevIns Device instance.
3708 * @param iIrq IRQ number to set.
3709 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
3710 * @thread Any thread, but will involve the emulation thread.
3711 */
3712 DECLRCCALLBACKMEMBER(void, pfnPCISetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
3713
3714 /**
3715 * Set ISA IRQ for a device.
3716 *
3717 * @param pDevIns Device instance.
3718 * @param iIrq IRQ number to set.
3719 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
3720 * @thread Any thread, but will involve the emulation thread.
3721 */
3722 DECLRCCALLBACKMEMBER(void, pfnISASetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
3723
3724 /**
3725 * Read physical memory.
3726 *
3727 * @returns VINF_SUCCESS (for now).
3728 * @param pDevIns Device instance.
3729 * @param GCPhys Physical address start reading from.
3730 * @param pvBuf Where to put the read bits.
3731 * @param cbRead How many bytes to read.
3732 */
3733 DECLRCCALLBACKMEMBER(int, pfnPhysRead,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead));
3734
3735 /**
3736 * Write to physical memory.
3737 *
3738 * @returns VINF_SUCCESS for now, and later maybe VERR_EM_MEMORY.
3739 * @param pDevIns Device instance.
3740 * @param GCPhys Physical address to write to.
3741 * @param pvBuf What to write.
3742 * @param cbWrite How many bytes to write.
3743 */
3744 DECLRCCALLBACKMEMBER(int, pfnPhysWrite,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite));
3745
3746 /**
3747 * Checks if the Gate A20 is enabled or not.
3748 *
3749 * @returns true if A20 is enabled.
3750 * @returns false if A20 is disabled.
3751 * @param pDevIns Device instance.
3752 * @thread The emulation thread.
3753 */
3754 DECLRCCALLBACKMEMBER(bool, pfnA20IsEnabled,(PPDMDEVINS pDevIns));
3755
3756 /**
3757 * Gets the VM state.
3758 *
3759 * @returns VM state.
3760 * @param pDevIns The device instance.
3761 * @thread Any thread (just keep in mind that it's volatile info).
3762 */
3763 DECLRCCALLBACKMEMBER(VMSTATE, pfnVMState, (PPDMDEVINS pDevIns));
3764
3765 /**
3766 * Set the VM error message
3767 *
3768 * @returns rc.
3769 * @param pDrvIns Driver instance.
3770 * @param rc VBox status code.
3771 * @param RT_SRC_POS_DECL Use RT_SRC_POS.
3772 * @param pszFormat Error message format string.
3773 * @param ... Error message arguments.
3774 */
3775 DECLRCCALLBACKMEMBER(int, pfnVMSetError,(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...));
3776
3777 /**
3778 * Set the VM error message
3779 *
3780 * @returns rc.
3781 * @param pDrvIns Driver instance.
3782 * @param rc VBox status code.
3783 * @param RT_SRC_POS_DECL Use RT_SRC_POS.
3784 * @param pszFormat Error message format string.
3785 * @param va Error message arguments.
3786 */
3787 DECLRCCALLBACKMEMBER(int, pfnVMSetErrorV,(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va));
3788
3789 /**
3790 * Set the VM runtime error message
3791 *
3792 * @returns VBox status code.
3793 * @param pDevIns Device instance.
3794 * @param fFlags The action flags. See VMSETRTERR_FLAGS_*.
3795 * @param pszErrorId Error ID string.
3796 * @param pszFormat Error message format string.
3797 * @param ... Error message arguments.
3798 */
3799 DECLRCCALLBACKMEMBER(int, pfnVMSetRuntimeError,(PPDMDEVINS pDevIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, ...));
3800
3801 /**
3802 * Set the VM runtime error message
3803 *
3804 * @returns VBox status code.
3805 * @param pDevIns Device instance.
3806 * @param fFlags The action flags. See VMSETRTERR_FLAGS_*.
3807 * @param pszErrorId Error ID string.
3808 * @param pszFormat Error message format string.
3809 * @param va Error message arguments.
3810 */
3811 DECLRCCALLBACKMEMBER(int, pfnVMSetRuntimeErrorV,(PPDMDEVINS pDevIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, va_list va));
3812
3813 /**
3814 * Set parameters for pending MMIO patch operation
3815 *
3816 * @returns VBox status code.
3817 * @param pDevIns Device instance.
3818 * @param GCPhys MMIO physical address
3819 * @param pCachedData GC pointer to cached data
3820 */
3821 DECLRCCALLBACKMEMBER(int, pfnPATMSetMMIOPatchInfo,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTGCPTR pCachedData));
3822
3823 /**
3824 * Gets the VM handle. Restricted API.
3825 *
3826 * @returns VM Handle.
3827 * @param pDevIns Device instance.
3828 */
3829 DECLRCCALLBACKMEMBER(PVM, pfnGetVM,(PPDMDEVINS pDevIns));
3830
3831 /**
3832 * Gets the VMCPU handle. Restricted API.
3833 *
3834 * @returns VMCPU Handle.
3835 * @param pDevIns The device instance.
3836 */
3837 DECLRCCALLBACKMEMBER(PVMCPU, pfnGetVMCPU,(PPDMDEVINS pDevIns));
3838
3839 /**
3840 * The the VM CPU ID of the current thread (restricted API).
3841 *
3842 * @returns The VMCPUID of the calling thread, NIL_CPUID if not EMT.
3843 * @param pDevIns The device instance.
3844 */
3845 DECLRCCALLBACKMEMBER(VMCPUID, pfnGetCurrentCpuId,(PPDMDEVINS pDevIns));
3846
3847 /**
3848 * Get the current virtual clock time in a VM. The clock frequency must be
3849 * queried separately.
3850 *
3851 * @returns Current clock time.
3852 * @param pDevIns The device instance.
3853 */
3854 DECLRCCALLBACKMEMBER(uint64_t, pfnTMTimeVirtGet,(PPDMDEVINS pDevIns));
3855
3856 /**
3857 * Get the frequency of the virtual clock.
3858 *
3859 * @returns The clock frequency (not variable at run-time).
3860 * @param pDevIns The device instance.
3861 */
3862 DECLRCCALLBACKMEMBER(uint64_t, pfnTMTimeVirtGetFreq,(PPDMDEVINS pDevIns));
3863
3864 /**
3865 * Get the current virtual clock time in a VM, in nanoseconds.
3866 *
3867 * @returns Current clock time (in ns).
3868 * @param pDevIns The device instance.
3869 */
3870 DECLRCCALLBACKMEMBER(uint64_t, pfnTMTimeVirtGetNano,(PPDMDEVINS pDevIns));
3871
3872 /**
3873 * Gets the trace buffer handle.
3874 *
3875 * This is used by the macros found in VBox/vmm/dbgftrace.h and is not
3876 * really inteded for direct usage, thus no inline wrapper function.
3877 *
3878 * @returns Trace buffer handle or NIL_RTTRACEBUF.
3879 * @param pDevIns The device instance.
3880 */
3881 DECLRCCALLBACKMEMBER(RTTRACEBUF, pfnDBGFTraceBuf,(PPDMDEVINS pDevIns));
3882
3883 /** Just a safety precaution. */
3884 uint32_t u32TheEnd;
3885} PDMDEVHLPRC;
3886/** Pointer PDM Device RC API. */
3887typedef RCPTRTYPE(struct PDMDEVHLPRC *) PPDMDEVHLPRC;
3888/** Pointer PDM Device RC API. */
3889typedef RCPTRTYPE(const struct PDMDEVHLPRC *) PCPDMDEVHLPRC;
3890
3891/** Current PDMDEVHLP version number. */
3892#define PDM_DEVHLPRC_VERSION PDM_VERSION_MAKE(0xffe6, 4, 1)
3893
3894
3895/**
3896 * PDM Device API - R0 Variant.
3897 */
3898typedef struct PDMDEVHLPR0
3899{
3900 /** Structure version. PDM_DEVHLPR0_VERSION defines the current version. */
3901 uint32_t u32Version;
3902
3903 /**
3904 * Bus master physical memory read.
3905 *
3906 * @returns VINF_SUCCESS or VERR_PDM_NOT_PCI_BUS_MASTER, later maybe
3907 * VERR_EM_MEMORY.
3908 * @param pDevIns The device instance.
3909 * @param GCPhys Physical address start reading from.
3910 * @param pvBuf Where to put the read bits.
3911 * @param cbRead How many bytes to read.
3912 * @thread Any thread, but the call may involve the emulation thread.
3913 */
3914 DECLR0CALLBACKMEMBER(int, pfnPCIPhysRead,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead));
3915
3916 /**
3917 * Bus master physical memory write.
3918 *
3919 * @returns VINF_SUCCESS or VERR_PDM_NOT_PCI_BUS_MASTER, later maybe
3920 * VERR_EM_MEMORY.
3921 * @param pDevIns The device instance.
3922 * @param GCPhys Physical address to write to.
3923 * @param pvBuf What to write.
3924 * @param cbWrite How many bytes to write.
3925 * @thread Any thread, but the call may involve the emulation thread.
3926 */
3927 DECLR0CALLBACKMEMBER(int, pfnPCIPhysWrite,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite));
3928
3929 /**
3930 * Set the IRQ for a PCI device.
3931 *
3932 * @param pDevIns Device instance.
3933 * @param iIrq IRQ number to set.
3934 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
3935 * @thread Any thread, but will involve the emulation thread.
3936 */
3937 DECLR0CALLBACKMEMBER(void, pfnPCISetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
3938
3939 /**
3940 * Set ISA IRQ for a device.
3941 *
3942 * @param pDevIns Device instance.
3943 * @param iIrq IRQ number to set.
3944 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
3945 * @thread Any thread, but will involve the emulation thread.
3946 */
3947 DECLR0CALLBACKMEMBER(void, pfnISASetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
3948
3949 /**
3950 * Read physical memory.
3951 *
3952 * @returns VINF_SUCCESS (for now).
3953 * @param pDevIns Device instance.
3954 * @param GCPhys Physical address start reading from.
3955 * @param pvBuf Where to put the read bits.
3956 * @param cbRead How many bytes to read.
3957 */
3958 DECLR0CALLBACKMEMBER(int, pfnPhysRead,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead));
3959
3960 /**
3961 * Write to physical memory.
3962 *
3963 * @returns VINF_SUCCESS for now, and later maybe VERR_EM_MEMORY.
3964 * @param pDevIns Device instance.
3965 * @param GCPhys Physical address to write to.
3966 * @param pvBuf What to write.
3967 * @param cbWrite How many bytes to write.
3968 */
3969 DECLR0CALLBACKMEMBER(int, pfnPhysWrite,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite));
3970
3971 /**
3972 * Checks if the Gate A20 is enabled or not.
3973 *
3974 * @returns true if A20 is enabled.
3975 * @returns false if A20 is disabled.
3976 * @param pDevIns Device instance.
3977 * @thread The emulation thread.
3978 */
3979 DECLR0CALLBACKMEMBER(bool, pfnA20IsEnabled,(PPDMDEVINS pDevIns));
3980
3981 /**
3982 * Gets the VM state.
3983 *
3984 * @returns VM state.
3985 * @param pDevIns The device instance.
3986 * @thread Any thread (just keep in mind that it's volatile info).
3987 */
3988 DECLR0CALLBACKMEMBER(VMSTATE, pfnVMState, (PPDMDEVINS pDevIns));
3989
3990 /**
3991 * Set the VM error message
3992 *
3993 * @returns rc.
3994 * @param pDrvIns Driver instance.
3995 * @param rc VBox status code.
3996 * @param RT_SRC_POS_DECL Use RT_SRC_POS.
3997 * @param pszFormat Error message format string.
3998 * @param ... Error message arguments.
3999 */
4000 DECLR0CALLBACKMEMBER(int, pfnVMSetError,(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...));
4001
4002 /**
4003 * Set the VM error message
4004 *
4005 * @returns rc.
4006 * @param pDrvIns Driver instance.
4007 * @param rc VBox status code.
4008 * @param RT_SRC_POS_DECL Use RT_SRC_POS.
4009 * @param pszFormat Error message format string.
4010 * @param va Error message arguments.
4011 */
4012 DECLR0CALLBACKMEMBER(int, pfnVMSetErrorV,(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va));
4013
4014 /**
4015 * Set the VM runtime error message
4016 *
4017 * @returns VBox status code.
4018 * @param pDevIns Device instance.
4019 * @param fFlags The action flags. See VMSETRTERR_FLAGS_*.
4020 * @param pszErrorId Error ID string.
4021 * @param pszFormat Error message format string.
4022 * @param ... Error message arguments.
4023 */
4024 DECLR0CALLBACKMEMBER(int, pfnVMSetRuntimeError,(PPDMDEVINS pDevIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, ...));
4025
4026 /**
4027 * Set the VM runtime error message
4028 *
4029 * @returns VBox status code.
4030 * @param pDevIns Device instance.
4031 * @param fFlags The action flags. See VMSETRTERR_FLAGS_*.
4032 * @param pszErrorId Error ID string.
4033 * @param pszFormat Error message format string.
4034 * @param va Error message arguments.
4035 */
4036 DECLR0CALLBACKMEMBER(int, pfnVMSetRuntimeErrorV,(PPDMDEVINS pDevIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, va_list va));
4037
4038 /**
4039 * Set parameters for pending MMIO patch operation
4040 *
4041 * @returns rc.
4042 * @param pDevIns Device instance.
4043 * @param GCPhys MMIO physical address
4044 * @param pCachedData GC pointer to cached data
4045 */
4046 DECLR0CALLBACKMEMBER(int, pfnPATMSetMMIOPatchInfo,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTGCPTR pCachedData));
4047
4048 /**
4049 * Gets the VM handle. Restricted API.
4050 *
4051 * @returns VM Handle.
4052 * @param pDevIns Device instance.
4053 */
4054 DECLR0CALLBACKMEMBER(PVM, pfnGetVM,(PPDMDEVINS pDevIns));
4055
4056 /**
4057 * Checks if our current CPU state allows for IO block emulation fallback to the recompiler
4058 *
4059 * @returns true = yes, false = no
4060 * @param pDevIns Device instance.
4061 */
4062 DECLR0CALLBACKMEMBER(bool, pfnCanEmulateIoBlock,(PPDMDEVINS pDevIns));
4063
4064 /**
4065 * Gets the VMCPU handle. Restricted API.
4066 *
4067 * @returns VMCPU Handle.
4068 * @param pDevIns The device instance.
4069 */
4070 DECLR0CALLBACKMEMBER(PVMCPU, pfnGetVMCPU,(PPDMDEVINS pDevIns));
4071
4072 /**
4073 * The the VM CPU ID of the current thread (restricted API).
4074 *
4075 * @returns The VMCPUID of the calling thread, NIL_CPUID if not EMT.
4076 * @param pDevIns The device instance.
4077 */
4078 DECLR0CALLBACKMEMBER(VMCPUID, pfnGetCurrentCpuId,(PPDMDEVINS pDevIns));
4079
4080 /**
4081 * Get the current virtual clock time in a VM. The clock frequency must be
4082 * queried separately.
4083 *
4084 * @returns Current clock time.
4085 * @param pDevIns The device instance.
4086 */
4087 DECLR0CALLBACKMEMBER(uint64_t, pfnTMTimeVirtGet,(PPDMDEVINS pDevIns));
4088
4089 /**
4090 * Get the frequency of the virtual clock.
4091 *
4092 * @returns The clock frequency (not variable at run-time).
4093 * @param pDevIns The device instance.
4094 */
4095 DECLR0CALLBACKMEMBER(uint64_t, pfnTMTimeVirtGetFreq,(PPDMDEVINS pDevIns));
4096
4097 /**
4098 * Get the current virtual clock time in a VM, in nanoseconds.
4099 *
4100 * @returns Current clock time (in ns).
4101 * @param pDevIns The device instance.
4102 */
4103 DECLR0CALLBACKMEMBER(uint64_t, pfnTMTimeVirtGetNano,(PPDMDEVINS pDevIns));
4104
4105 /**
4106 * Gets the trace buffer handle.
4107 *
4108 * This is used by the macros found in VBox/vmm/dbgftrace.h and is not
4109 * really inteded for direct usage, thus no inline wrapper function.
4110 *
4111 * @returns Trace buffer handle or NIL_RTTRACEBUF.
4112 * @param pDevIns The device instance.
4113 */
4114 DECLR0CALLBACKMEMBER(RTTRACEBUF, pfnDBGFTraceBuf,(PPDMDEVINS pDevIns));
4115
4116 /** Just a safety precaution. */
4117 uint32_t u32TheEnd;
4118} PDMDEVHLPR0;
4119/** Pointer PDM Device R0 API. */
4120typedef R0PTRTYPE(struct PDMDEVHLPR0 *) PPDMDEVHLPR0;
4121/** Pointer PDM Device GC API. */
4122typedef R0PTRTYPE(const struct PDMDEVHLPR0 *) PCPDMDEVHLPR0;
4123
4124/** Current PDMDEVHLP version number. */
4125#define PDM_DEVHLPR0_VERSION PDM_VERSION_MAKE(0xffe5, 4, 1)
4126
4127
4128
4129/**
4130 * PDM Device Instance.
4131 */
4132typedef struct PDMDEVINS
4133{
4134 /** Structure version. PDM_DEVINS_VERSION defines the current version. */
4135 uint32_t u32Version;
4136 /** Device instance number. */
4137 uint32_t iInstance;
4138
4139 /** Pointer the GC PDM Device API. */
4140 PCPDMDEVHLPRC pHlpRC;
4141 /** Pointer to device instance data. */
4142 RTRCPTR pvInstanceDataRC;
4143 /** The critical section for the device, see pCritSectXR3. */
4144 RCPTRTYPE(PPDMCRITSECT) pCritSectRoRC;
4145 /** Alignment padding. */
4146 RTRCPTR pAlignmentRC;
4147
4148 /** Pointer the R0 PDM Device API. */
4149 PCPDMDEVHLPR0 pHlpR0;
4150 /** Pointer to device instance data (R0). */
4151 RTR0PTR pvInstanceDataR0;
4152 /** The critical section for the device, see pCritSectXR3. */
4153 R0PTRTYPE(PPDMCRITSECT) pCritSectRoR0;
4154
4155 /** Pointer the HC PDM Device API. */
4156 PCPDMDEVHLPR3 pHlpR3;
4157 /** Pointer to device instance data. */
4158 RTR3PTR pvInstanceDataR3;
4159 /** The critical section for the device.
4160 *
4161 * TM and IOM will enter this critical section before calling into the device
4162 * code. PDM will when doing power on, power off, reset, suspend and resume
4163 * notifications. SSM will currently not, but this will be changed later on.
4164 *
4165 * The device gets a critical section automatically assigned to it before
4166 * the constructor is called. If the constructor wishes to use a different
4167 * critical section, it calls PDMDevHlpSetDeviceCritSect() to change it
4168 * very early on.
4169 */
4170 R3PTRTYPE(PPDMCRITSECT) pCritSectRoR3;
4171
4172 /** Pointer to device registration structure. */
4173 R3PTRTYPE(PCPDMDEVREG) pReg;
4174 /** Configuration handle. */
4175 R3PTRTYPE(PCFGMNODE) pCfg;
4176
4177 /** The base interface of the device.
4178 *
4179 * The device constructor initializes this if it has any
4180 * device level interfaces to export. To obtain this interface
4181 * call PDMR3QueryDevice(). */
4182 PDMIBASE IBase;
4183
4184 /** Tracing indicator. */
4185 uint32_t fTracing;
4186 /** The tracing ID of this device. */
4187 uint32_t idTracing;
4188#if HC_ARCH_BITS == 32
4189 /** Align the internal data more naturally. */
4190 uint32_t au32Padding[HC_ARCH_BITS == 32 ? 13 : 0];
4191#endif
4192
4193 /** Internal data. */
4194 union
4195 {
4196#ifdef PDMDEVINSINT_DECLARED
4197 PDMDEVINSINT s;
4198#endif
4199 uint8_t padding[HC_ARCH_BITS == 32 ? 72 : 112 + 0x28];
4200 } Internal;
4201
4202 /** Device instance data. The size of this area is defined
4203 * in the PDMDEVREG::cbInstanceData field. */
4204 char achInstanceData[8];
4205} PDMDEVINS;
4206
4207/** Current PDMDEVINS version number. */
4208#define PDM_DEVINS_VERSION PDM_VERSION_MAKE(0xffe4, 3, 0)
4209
4210/** Converts a pointer to the PDMDEVINS::IBase to a pointer to PDMDEVINS. */
4211#define PDMIBASE_2_PDMDEV(pInterface) ( (PPDMDEVINS)((char *)(pInterface) - RT_OFFSETOF(PDMDEVINS, IBase)) )
4212
4213/**
4214 * Checks the structure versions of the device instance and device helpers,
4215 * returning if they are incompatible.
4216 *
4217 * This is for use in the constructor.
4218 *
4219 * @param pDevIns The device instance pointer.
4220 */
4221#define PDMDEV_CHECK_VERSIONS_RETURN(pDevIns) \
4222 do \
4223 { \
4224 PPDMDEVINS pDevInsTypeCheck = (pDevIns); NOREF(pDevInsTypeCheck); \
4225 AssertLogRelMsgReturn(PDM_VERSION_ARE_COMPATIBLE((pDevIns)->u32Version, PDM_DEVINS_VERSION), \
4226 ("DevIns=%#x mine=%#x\n", (pDevIns)->u32Version, PDM_DEVINS_VERSION), \
4227 VERR_PDM_DEVINS_VERSION_MISMATCH); \
4228 AssertLogRelMsgReturn(PDM_VERSION_ARE_COMPATIBLE((pDevIns)->pHlpR3->u32Version, PDM_DEVHLPR3_VERSION), \
4229 ("DevHlp=%#x mine=%#x\n", (pDevIns)->pHlpR3->u32Version, PDM_DEVHLPR3_VERSION), \
4230 VERR_PDM_DEVHLPR3_VERSION_MISMATCH); \
4231 } while (0)
4232
4233/**
4234 * Quietly checks the structure versions of the device instance and device
4235 * helpers, returning if they are incompatible.
4236 *
4237 * This is for use in the destructor.
4238 *
4239 * @param pDevIns The device instance pointer.
4240 */
4241#define PDMDEV_CHECK_VERSIONS_RETURN_QUIET(pDevIns) \
4242 do \
4243 { \
4244 PPDMDEVINS pDevInsTypeCheck = (pDevIns); NOREF(pDevInsTypeCheck); \
4245 if (RT_UNLIKELY(!PDM_VERSION_ARE_COMPATIBLE((pDevIns)->u32Version, PDM_DEVINS_VERSION) )) \
4246 return VERR_PDM_DEVINS_VERSION_MISMATCH; \
4247 if (RT_UNLIKELY(!PDM_VERSION_ARE_COMPATIBLE((pDevIns)->pHlpR3->u32Version, PDM_DEVHLPR3_VERSION) )) \
4248 return VERR_PDM_DEVHLPR3_VERSION_MISMATCH; \
4249 } while (0)
4250
4251/**
4252 * Wrapper around CFGMR3ValidateConfig for the root config for use in the
4253 * constructor - returns on failure.
4254 *
4255 * This should be invoked after having initialized the instance data
4256 * sufficiently for the correct operation of the destructor. The destructor is
4257 * always called!
4258 *
4259 * @param pDevIns Pointer to the PDM device instance.
4260 * @param pszValidValues Patterns describing the valid value names. See
4261 * RTStrSimplePatternMultiMatch for details on the
4262 * pattern syntax.
4263 * @param pszValidNodes Patterns describing the valid node (key) names.
4264 * Pass empty string if no valid nodes.
4265 */
4266#define PDMDEV_VALIDATE_CONFIG_RETURN(pDevIns, pszValidValues, pszValidNodes) \
4267 do \
4268 { \
4269 int rcValCfg = CFGMR3ValidateConfig((pDevIns)->pCfg, "/", pszValidValues, pszValidNodes, \
4270 (pDevIns)->pReg->szName, (pDevIns)->iInstance); \
4271 if (RT_FAILURE(rcValCfg)) \
4272 return rcValCfg; \
4273 } while (0)
4274
4275/** @def PDMDEV_ASSERT_EMT
4276 * Assert that the current thread is the emulation thread.
4277 */
4278#ifdef VBOX_STRICT
4279# define PDMDEV_ASSERT_EMT(pDevIns) pDevIns->pHlpR3->pfnAssertEMT(pDevIns, __FILE__, __LINE__, __FUNCTION__)
4280#else
4281# define PDMDEV_ASSERT_EMT(pDevIns) do { } while (0)
4282#endif
4283
4284/** @def PDMDEV_ASSERT_OTHER
4285 * Assert that the current thread is NOT the emulation thread.
4286 */
4287#ifdef VBOX_STRICT
4288# define PDMDEV_ASSERT_OTHER(pDevIns) pDevIns->pHlpR3->pfnAssertOther(pDevIns, __FILE__, __LINE__, __FUNCTION__)
4289#else
4290# define PDMDEV_ASSERT_OTHER(pDevIns) do { } while (0)
4291#endif
4292
4293/** @def PDMDEV_ASSERT_VMLOCK_OWNER
4294 * Assert that the current thread is owner of the VM lock.
4295 */
4296#ifdef VBOX_STRICT
4297# define PDMDEV_ASSERT_VMLOCK_OWNER(pDevIns) pDevIns->pHlpR3->pfnAssertVMLock(pDevIns, __FILE__, __LINE__, __FUNCTION__)
4298#else
4299# define PDMDEV_ASSERT_VMLOCK_OWNER(pDevIns) do { } while (0)
4300#endif
4301
4302/** @def PDMDEV_SET_ERROR
4303 * Set the VM error. See PDMDevHlpVMSetError() for printf like message formatting.
4304 */
4305#define PDMDEV_SET_ERROR(pDevIns, rc, pszError) \
4306 PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS, "%s", pszError)
4307
4308/** @def PDMDEV_SET_RUNTIME_ERROR
4309 * Set the VM runtime error. See PDMDevHlpVMSetRuntimeError() for printf like message formatting.
4310 */
4311#define PDMDEV_SET_RUNTIME_ERROR(pDevIns, fFlags, pszErrorId, pszError) \
4312 PDMDevHlpVMSetRuntimeError(pDevIns, fFlags, pszErrorId, "%s", pszError)
4313
4314/** @def PDMDEVINS_2_RCPTR
4315 * Converts a PDM Device instance pointer a RC PDM Device instance pointer.
4316 */
4317#define PDMDEVINS_2_RCPTR(pDevIns) ( (RCPTRTYPE(PPDMDEVINS))((RTGCUINTPTR)(pDevIns)->pvInstanceDataRC - RT_OFFSETOF(PDMDEVINS, achInstanceData)) )
4318
4319/** @def PDMDEVINS_2_R3PTR
4320 * Converts a PDM Device instance pointer a R3 PDM Device instance pointer.
4321 */
4322#define PDMDEVINS_2_R3PTR(pDevIns) ( (R3PTRTYPE(PPDMDEVINS))((RTHCUINTPTR)(pDevIns)->pvInstanceDataR3 - RT_OFFSETOF(PDMDEVINS, achInstanceData)) )
4323
4324/** @def PDMDEVINS_2_R0PTR
4325 * Converts a PDM Device instance pointer a R0 PDM Device instance pointer.
4326 */
4327#define PDMDEVINS_2_R0PTR(pDevIns) ( (R0PTRTYPE(PPDMDEVINS))((RTR0UINTPTR)(pDevIns)->pvInstanceDataR0 - RT_OFFSETOF(PDMDEVINS, achInstanceData)) )
4328
4329
4330#ifdef IN_RING3
4331
4332/**
4333 * @copydoc PDMDEVHLPR3::pfnIOPortRegister
4334 */
4335DECLINLINE(int) PDMDevHlpIOPortRegister(PPDMDEVINS pDevIns, RTIOPORT Port, RTIOPORT cPorts, RTHCPTR pvUser,
4336 PFNIOMIOPORTOUT pfnOut, PFNIOMIOPORTIN pfnIn,
4337 PFNIOMIOPORTOUTSTRING pfnOutStr, PFNIOMIOPORTINSTRING pfnInStr, const char *pszDesc)
4338{
4339 return pDevIns->pHlpR3->pfnIOPortRegister(pDevIns, Port, cPorts, pvUser, pfnOut, pfnIn, pfnOutStr, pfnInStr, pszDesc);
4340}
4341
4342/**
4343 * @copydoc PDMDEVHLPR3::pfnIOPortRegisterRC
4344 */
4345DECLINLINE(int) PDMDevHlpIOPortRegisterRC(PPDMDEVINS pDevIns, RTIOPORT Port, RTIOPORT cPorts, RTRCPTR pvUser,
4346 const char *pszOut, const char *pszIn, const char *pszOutStr,
4347 const char *pszInStr, const char *pszDesc)
4348{
4349 return pDevIns->pHlpR3->pfnIOPortRegisterRC(pDevIns, Port, cPorts, pvUser, pszOut, pszIn, pszOutStr, pszInStr, pszDesc);
4350}
4351
4352/**
4353 * @copydoc PDMDEVHLPR3::pfnIOPortRegisterR0
4354 */
4355DECLINLINE(int) PDMDevHlpIOPortRegisterR0(PPDMDEVINS pDevIns, RTIOPORT Port, RTIOPORT cPorts, RTR0PTR pvUser,
4356 const char *pszOut, const char *pszIn, const char *pszOutStr,
4357 const char *pszInStr, const char *pszDesc)
4358{
4359 return pDevIns->pHlpR3->pfnIOPortRegisterR0(pDevIns, Port, cPorts, pvUser, pszOut, pszIn, pszOutStr, pszInStr, pszDesc);
4360}
4361
4362/**
4363 * @copydoc PDMDEVHLPR3::pfnIOPortDeregister
4364 */
4365DECLINLINE(int) PDMDevHlpIOPortDeregister(PPDMDEVINS pDevIns, RTIOPORT Port, RTIOPORT cPorts)
4366{
4367 return pDevIns->pHlpR3->pfnIOPortDeregister(pDevIns, Port, cPorts);
4368}
4369
4370/**
4371 * Register a Memory Mapped I/O (MMIO) region.
4372 *
4373 * These callbacks are of course for the ring-3 context (R3). Register HC
4374 * handlers before raw-mode context (RC) and ring-0 context (R0) handlers! There
4375 * must be a R3 handler for every RC and R0 handler!
4376 *
4377 * @returns VBox status.
4378 * @param pDevIns The device instance to register the MMIO with.
4379 * @param GCPhysStart First physical address in the range.
4380 * @param cbRange The size of the range (in bytes).
4381 * @param pvUser User argument.
4382 * @param fFlags Flags, IOMMMIO_FLAGS_XXX.
4383 * @param pfnWrite Pointer to function which is gonna handle Write operations.
4384 * @param pfnRead Pointer to function which is gonna handle Read operations.
4385 * @param pszDesc Pointer to description string. This must not be freed.
4386 */
4387DECLINLINE(int) PDMDevHlpMMIORegister(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, uint32_t cbRange, RTHCPTR pvUser,
4388 uint32_t fFlags, PFNIOMMMIOWRITE pfnWrite, PFNIOMMMIOREAD pfnRead, const char *pszDesc)
4389{
4390 return pDevIns->pHlpR3->pfnMMIORegister(pDevIns, GCPhysStart, cbRange, pvUser, pfnWrite, pfnRead, NULL /*pfnFill*/,
4391 fFlags, pszDesc);
4392}
4393
4394/**
4395 * Register a Memory Mapped I/O (MMIO) region for GC.
4396 *
4397 * These callbacks are for the raw-mode context (RC). Register ring-3 context
4398 * (R3) handlers before guest context handlers! There must be a R3 handler for
4399 * every RC handler!
4400 *
4401 * @returns VBox status.
4402 * @param pDevIns The device instance to register the MMIO with.
4403 * @param GCPhysStart First physical address in the range.
4404 * @param cbRange The size of the range (in bytes).
4405 * @param pvUser User argument.
4406 * @param pszWrite Name of the RC function which is gonna handle Write operations.
4407 * @param pszRead Name of the RC function which is gonna handle Read operations.
4408 */
4409DECLINLINE(int) PDMDevHlpMMIORegisterRC(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, uint32_t cbRange, RTRCPTR pvUser,
4410 const char *pszWrite, const char *pszRead)
4411{
4412 return pDevIns->pHlpR3->pfnMMIORegisterRC(pDevIns, GCPhysStart, cbRange, pvUser, pszWrite, pszRead, NULL /*pszFill*/);
4413}
4414
4415/**
4416 * @copydoc PDMDEVHLPR3::pfnMMIORegisterR0
4417 */
4418DECLINLINE(int) PDMDevHlpMMIORegisterR0(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, uint32_t cbRange, RTR0PTR pvUser,
4419 const char *pszWrite, const char *pszRead)
4420{
4421 return pDevIns->pHlpR3->pfnMMIORegisterR0(pDevIns, GCPhysStart, cbRange, pvUser, pszWrite, pszRead, NULL /*pszFill*/);
4422}
4423
4424/**
4425 * @copydoc PDMDEVHLPR3::pfnMMIORegister
4426 */
4427DECLINLINE(int) PDMDevHlpMMIORegisterEx(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, uint32_t cbRange, RTHCPTR pvUser,
4428 uint32_t fFlags, PFNIOMMMIOWRITE pfnWrite, PFNIOMMMIOREAD pfnRead,
4429 PFNIOMMMIOFILL pfnFill, const char *pszDesc)
4430{
4431 return pDevIns->pHlpR3->pfnMMIORegister(pDevIns, GCPhysStart, cbRange, pvUser, pfnWrite, pfnRead, pfnFill,
4432 fFlags, pszDesc);
4433}
4434
4435/**
4436 * @copydoc PDMDEVHLPR3::pfnMMIORegisterRC
4437 */
4438DECLINLINE(int) PDMDevHlpMMIORegisterRCEx(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, uint32_t cbRange, RTRCPTR pvUser,
4439 const char *pszWrite, const char *pszRead, const char *pszFill)
4440{
4441 return pDevIns->pHlpR3->pfnMMIORegisterRC(pDevIns, GCPhysStart, cbRange, pvUser, pszWrite, pszRead, pszFill);
4442}
4443
4444/**
4445 * @copydoc PDMDEVHLPR3::pfnMMIORegisterR0
4446 */
4447DECLINLINE(int) PDMDevHlpMMIORegisterR0Ex(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, uint32_t cbRange, RTR0PTR pvUser,
4448 const char *pszWrite, const char *pszRead, const char *pszFill)
4449{
4450 return pDevIns->pHlpR3->pfnMMIORegisterR0(pDevIns, GCPhysStart, cbRange, pvUser, pszWrite, pszRead, pszFill);
4451}
4452
4453/**
4454 * @copydoc PDMDEVHLPR3::pfnMMIODeregister
4455 */
4456DECLINLINE(int) PDMDevHlpMMIODeregister(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, uint32_t cbRange)
4457{
4458 return pDevIns->pHlpR3->pfnMMIODeregister(pDevIns, GCPhysStart, cbRange);
4459}
4460
4461/**
4462 * @copydoc PDMDEVHLPR3::pfnMMIO2Register
4463 */
4464DECLINLINE(int) PDMDevHlpMMIO2Register(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS cb, uint32_t fFlags, void **ppv, const char *pszDesc)
4465{
4466 return pDevIns->pHlpR3->pfnMMIO2Register(pDevIns, iRegion, cb, fFlags, ppv, pszDesc);
4467}
4468
4469/**
4470 * @copydoc PDMDEVHLPR3::pfnMMIO2Deregister
4471 */
4472DECLINLINE(int) PDMDevHlpMMIO2Deregister(PPDMDEVINS pDevIns, uint32_t iRegion)
4473{
4474 return pDevIns->pHlpR3->pfnMMIO2Deregister(pDevIns, iRegion);
4475}
4476
4477/**
4478 * @copydoc PDMDEVHLPR3::pfnMMIO2Map
4479 */
4480DECLINLINE(int) PDMDevHlpMMIO2Map(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS GCPhys)
4481{
4482 return pDevIns->pHlpR3->pfnMMIO2Map(pDevIns, iRegion, GCPhys);
4483}
4484
4485/**
4486 * @copydoc PDMDEVHLPR3::pfnMMIO2Unmap
4487 */
4488DECLINLINE(int) PDMDevHlpMMIO2Unmap(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS GCPhys)
4489{
4490 return pDevIns->pHlpR3->pfnMMIO2Unmap(pDevIns, iRegion, GCPhys);
4491}
4492
4493/**
4494 * @copydoc PDMDEVHLPR3::pfnMMHyperMapMMIO2
4495 */
4496DECLINLINE(int) PDMDevHlpMMHyperMapMMIO2(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS off, RTGCPHYS cb,
4497 const char *pszDesc, PRTRCPTR pRCPtr)
4498{
4499 return pDevIns->pHlpR3->pfnMMHyperMapMMIO2(pDevIns, iRegion, off, cb, pszDesc, pRCPtr);
4500}
4501
4502/**
4503 * @copydoc PDMDEVHLPR3::pfnMMIO2MapKernel
4504 */
4505DECLINLINE(int) PDMDevHlpMMIO2MapKernel(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS off, RTGCPHYS cb,
4506 const char *pszDesc, PRTR0PTR pR0Ptr)
4507{
4508 return pDevIns->pHlpR3->pfnMMIO2MapKernel(pDevIns, iRegion, off, cb, pszDesc, pR0Ptr);
4509}
4510
4511/**
4512 * @copydoc PDMDEVHLPR3::pfnROMRegister
4513 */
4514DECLINLINE(int) PDMDevHlpROMRegister(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, uint32_t cbRange,
4515 const void *pvBinary, uint32_t cbBinary, uint32_t fFlags, const char *pszDesc)
4516{
4517 return pDevIns->pHlpR3->pfnROMRegister(pDevIns, GCPhysStart, cbRange, pvBinary, cbBinary, fFlags, pszDesc);
4518}
4519
4520/**
4521 * @copydoc PDMDEVHLPR3::pfnROMProtectShadow
4522 */
4523DECLINLINE(int) PDMDevHlpROMProtectShadow(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, uint32_t cbRange, PGMROMPROT enmProt)
4524{
4525 return pDevIns->pHlpR3->pfnROMProtectShadow(pDevIns, GCPhysStart, cbRange, enmProt);
4526}
4527
4528/**
4529 * Register a save state data unit.
4530 *
4531 * @returns VBox status.
4532 * @param pDevIns The device instance.
4533 * @param uVersion Data layout version number.
4534 * @param cbGuess The approximate amount of data in the unit.
4535 * Only for progress indicators.
4536 * @param pfnSaveExec Execute save callback, optional.
4537 * @param pfnLoadExec Execute load callback, optional.
4538 */
4539DECLINLINE(int) PDMDevHlpSSMRegister(PPDMDEVINS pDevIns, uint32_t uVersion, size_t cbGuess,
4540 PFNSSMDEVSAVEEXEC pfnSaveExec, PFNSSMDEVLOADEXEC pfnLoadExec)
4541{
4542 return pDevIns->pHlpR3->pfnSSMRegister(pDevIns, uVersion, cbGuess, NULL /*pszBefore*/,
4543 NULL /*pfnLivePrep*/, NULL /*pfnLiveExec*/, NULL /*pfnLiveDone*/,
4544 NULL /*pfnSavePrep*/, pfnSaveExec, NULL /*pfnSaveDone*/,
4545 NULL /*pfnLoadPrep*/, pfnLoadExec, NULL /*pfnLoadDone*/);
4546}
4547
4548/**
4549 * Register a save state data unit with a live save callback as well.
4550 *
4551 * @returns VBox status.
4552 * @param pDevIns The device instance.
4553 * @param uVersion Data layout version number.
4554 * @param cbGuess The approximate amount of data in the unit.
4555 * Only for progress indicators.
4556 * @param pfnLiveExec Execute live callback, optional.
4557 * @param pfnSaveExec Execute save callback, optional.
4558 * @param pfnLoadExec Execute load callback, optional.
4559 */
4560DECLINLINE(int) PDMDevHlpSSMRegister3(PPDMDEVINS pDevIns, uint32_t uVersion, size_t cbGuess,
4561 FNSSMDEVLIVEEXEC pfnLiveExec, PFNSSMDEVSAVEEXEC pfnSaveExec, PFNSSMDEVLOADEXEC pfnLoadExec)
4562{
4563 return pDevIns->pHlpR3->pfnSSMRegister(pDevIns, uVersion, cbGuess, NULL /*pszBefore*/,
4564 NULL /*pfnLivePrep*/, pfnLiveExec, NULL /*pfnLiveDone*/,
4565 NULL /*pfnSavePrep*/, pfnSaveExec, NULL /*pfnSaveDone*/,
4566 NULL /*pfnLoadPrep*/, pfnLoadExec, NULL /*pfnLoadDone*/);
4567}
4568
4569/**
4570 * @copydoc PDMDEVHLPR3::pfnSSMRegister
4571 */
4572DECLINLINE(int) PDMDevHlpSSMRegisterEx(PPDMDEVINS pDevIns, uint32_t uVersion, size_t cbGuess, const char *pszBefore,
4573 PFNSSMDEVLIVEPREP pfnLivePrep, PFNSSMDEVLIVEEXEC pfnLiveExec, PFNSSMDEVLIVEVOTE pfnLiveVote,
4574 PFNSSMDEVSAVEPREP pfnSavePrep, PFNSSMDEVSAVEEXEC pfnSaveExec, PFNSSMDEVSAVEDONE pfnSaveDone,
4575 PFNSSMDEVLOADPREP pfnLoadPrep, PFNSSMDEVLOADEXEC pfnLoadExec, PFNSSMDEVLOADDONE pfnLoadDone)
4576{
4577 return pDevIns->pHlpR3->pfnSSMRegister(pDevIns, uVersion, cbGuess, pszBefore,
4578 pfnLivePrep, pfnLiveExec, pfnLiveVote,
4579 pfnSavePrep, pfnSaveExec, pfnSaveDone,
4580 pfnLoadPrep, pfnLoadExec, pfnLoadDone);
4581}
4582
4583/**
4584 * @copydoc PDMDEVHLPR3::pfnTMTimerCreate
4585 */
4586DECLINLINE(int) PDMDevHlpTMTimerCreate(PPDMDEVINS pDevIns, TMCLOCK enmClock, PFNTMTIMERDEV pfnCallback, void *pvUser, uint32_t fFlags,
4587 const char *pszDesc, PPTMTIMERR3 ppTimer)
4588{
4589 return pDevIns->pHlpR3->pfnTMTimerCreate(pDevIns, enmClock, pfnCallback, pvUser, fFlags, pszDesc, ppTimer);
4590}
4591
4592/**
4593 * @copydoc PDMDEVHLPR3::pfnTMUtcNow
4594 */
4595DECLINLINE(PRTTIMESPEC) PDMDevHlpTMUtcNow(PPDMDEVINS pDevIns, PRTTIMESPEC pTime)
4596{
4597 return pDevIns->pHlpR3->pfnTMUtcNow(pDevIns, pTime);
4598}
4599
4600#endif /* IN_RING3 */
4601
4602/**
4603 * @copydoc PDMDEVHLPR3::pfnPhysRead
4604 */
4605DECLINLINE(int) PDMDevHlpPhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)
4606{
4607 return pDevIns->CTX_SUFF(pHlp)->pfnPhysRead(pDevIns, GCPhys, pvBuf, cbRead);
4608}
4609
4610/**
4611 * @copydoc PDMDEVHLPR3::pfnPhysWrite
4612 */
4613DECLINLINE(int) PDMDevHlpPhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)
4614{
4615 return pDevIns->CTX_SUFF(pHlp)->pfnPhysWrite(pDevIns, GCPhys, pvBuf, cbWrite);
4616}
4617
4618#ifdef IN_RING3
4619
4620/**
4621 * @copydoc PDMDEVHLPR3::pfnPhysGCPhys2CCPtr
4622 */
4623DECLINLINE(int) PDMDevHlpPhysGCPhys2CCPtr(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, uint32_t fFlags, void **ppv, PPGMPAGEMAPLOCK pLock)
4624{
4625 return pDevIns->CTX_SUFF(pHlp)->pfnPhysGCPhys2CCPtr(pDevIns, GCPhys, fFlags, ppv, pLock);
4626}
4627
4628/**
4629 * @copydoc PDMDEVHLPR3::pfnPhysGCPhys2CCPtrReadOnly
4630 */
4631DECLINLINE(int) PDMDevHlpPhysGCPhys2CCPtrReadOnly(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, uint32_t fFlags, void const **ppv, PPGMPAGEMAPLOCK pLock)
4632{
4633 return pDevIns->CTX_SUFF(pHlp)->pfnPhysGCPhys2CCPtrReadOnly(pDevIns, GCPhys, fFlags, ppv, pLock);
4634}
4635
4636/**
4637 * @copydoc PDMDEVHLPR3::pfnPhysReleasePageMappingLock
4638 */
4639DECLINLINE(void) PDMDevHlpPhysReleasePageMappingLock(PPDMDEVINS pDevIns, PPGMPAGEMAPLOCK pLock)
4640{
4641 pDevIns->CTX_SUFF(pHlp)->pfnPhysReleasePageMappingLock(pDevIns, pLock);
4642}
4643
4644/**
4645 * @copydoc PDMDEVHLPR3::pfnPhysReadGCVirt
4646 */
4647DECLINLINE(int) PDMDevHlpPhysReadGCVirt(PPDMDEVINS pDevIns, void *pvDst, RTGCPTR GCVirtSrc, size_t cb)
4648{
4649 return pDevIns->pHlpR3->pfnPhysReadGCVirt(pDevIns, pvDst, GCVirtSrc, cb);
4650}
4651
4652/**
4653 * @copydoc PDMDEVHLPR3::pfnPhysWriteGCVirt
4654 */
4655DECLINLINE(int) PDMDevHlpPhysWriteGCVirt(PPDMDEVINS pDevIns, RTGCPTR GCVirtDst, const void *pvSrc, size_t cb)
4656{
4657 return pDevIns->pHlpR3->pfnPhysWriteGCVirt(pDevIns, GCVirtDst, pvSrc, cb);
4658}
4659
4660/**
4661 * @copydoc PDMDEVHLPR3::pfnPhysGCPtr2GCPhys
4662 */
4663DECLINLINE(int) PDMDevHlpPhysGCPtr2GCPhys(PPDMDEVINS pDevIns, RTGCPTR GCPtr, PRTGCPHYS pGCPhys)
4664{
4665 return pDevIns->pHlpR3->pfnPhysGCPtr2GCPhys(pDevIns, GCPtr, pGCPhys);
4666}
4667
4668/**
4669 * @copydoc PDMDEVHLPR3::pfnMMHeapAlloc
4670 */
4671DECLINLINE(void *) PDMDevHlpMMHeapAlloc(PPDMDEVINS pDevIns, size_t cb)
4672{
4673 return pDevIns->pHlpR3->pfnMMHeapAlloc(pDevIns, cb);
4674}
4675
4676/**
4677 * @copydoc PDMDEVHLPR3::pfnMMHeapAllocZ
4678 */
4679DECLINLINE(void *) PDMDevHlpMMHeapAllocZ(PPDMDEVINS pDevIns, size_t cb)
4680{
4681 return pDevIns->pHlpR3->pfnMMHeapAllocZ(pDevIns, cb);
4682}
4683
4684/**
4685 * @copydoc PDMDEVHLPR3::pfnMMHeapFree
4686 */
4687DECLINLINE(void) PDMDevHlpMMHeapFree(PPDMDEVINS pDevIns, void *pv)
4688{
4689 pDevIns->pHlpR3->pfnMMHeapFree(pDevIns, pv);
4690}
4691#endif /* IN_RING3 */
4692
4693/**
4694 * @copydoc PDMDEVHLPR3::pfnVMState
4695 */
4696DECLINLINE(VMSTATE) PDMDevHlpVMState(PPDMDEVINS pDevIns)
4697{
4698 return pDevIns->CTX_SUFF(pHlp)->pfnVMState(pDevIns);
4699}
4700
4701#ifdef IN_RING3
4702/**
4703 * @copydoc PDMDEVHLPR3::pfnVMTeleportedAndNotFullyResumedYet
4704 */
4705DECLINLINE(bool) PDMDevHlpVMTeleportedAndNotFullyResumedYet(PPDMDEVINS pDevIns)
4706{
4707 return pDevIns->pHlpR3->pfnVMTeleportedAndNotFullyResumedYet(pDevIns);
4708}
4709#endif /* IN_RING3 */
4710
4711/**
4712 * @copydoc PDMDEVHLPR3::pfnVMSetError
4713 */
4714DECLINLINE(int) PDMDevHlpVMSetError(PPDMDEVINS pDevIns, const int rc, RT_SRC_POS_DECL, const char *pszFormat, ...)
4715{
4716 va_list va;
4717 va_start(va, pszFormat);
4718 pDevIns->CTX_SUFF(pHlp)->pfnVMSetErrorV(pDevIns, rc, RT_SRC_POS_ARGS, pszFormat, va);
4719 va_end(va);
4720 return rc;
4721}
4722
4723/**
4724 * @copydoc PDMDEVHLPR3::pfnVMSetRuntimeError
4725 */
4726DECLINLINE(int) PDMDevHlpVMSetRuntimeError(PPDMDEVINS pDevIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, ...)
4727{
4728 va_list va;
4729 int rc;
4730 va_start(va, pszFormat);
4731 rc = pDevIns->CTX_SUFF(pHlp)->pfnVMSetRuntimeErrorV(pDevIns, fFlags, pszErrorId, pszFormat, va);
4732 va_end(va);
4733 return rc;
4734}
4735
4736/**
4737 * VBOX_STRICT wrapper for pHlp->pfnDBGFStopV.
4738 *
4739 * @returns VBox status code which must be passed up to the VMM. This will be
4740 * VINF_SUCCESS in non-strict builds.
4741 * @param pDevIns The device instance.
4742 * @param RT_SRC_POS_DECL Use RT_SRC_POS.
4743 * @param pszFormat Message. (optional)
4744 * @param ... Message parameters.
4745 */
4746DECLINLINE(int) PDMDevHlpDBGFStop(PPDMDEVINS pDevIns, RT_SRC_POS_DECL, const char *pszFormat, ...)
4747{
4748#ifdef VBOX_STRICT
4749# ifdef IN_RING3
4750 int rc;
4751 va_list args;
4752 va_start(args, pszFormat);
4753 rc = pDevIns->pHlpR3->pfnDBGFStopV(pDevIns, RT_SRC_POS_ARGS, pszFormat, args);
4754 va_end(args);
4755 return rc;
4756# else
4757 NOREF(pDevIns);
4758 NOREF(pszFile);
4759 NOREF(iLine);
4760 NOREF(pszFunction);
4761 NOREF(pszFormat);
4762 return VINF_EM_DBG_STOP;
4763# endif
4764#else
4765 NOREF(pDevIns);
4766 NOREF(pszFile);
4767 NOREF(iLine);
4768 NOREF(pszFunction);
4769 NOREF(pszFormat);
4770 return VINF_SUCCESS;
4771#endif
4772}
4773
4774#ifdef IN_RING3
4775
4776/**
4777 * @copydoc PDMDEVHLPR3::pfnDBGFInfoRegister
4778 */
4779DECLINLINE(int) PDMDevHlpDBGFInfoRegister(PPDMDEVINS pDevIns, const char *pszName, const char *pszDesc, PFNDBGFHANDLERDEV pfnHandler)
4780{
4781 return pDevIns->pHlpR3->pfnDBGFInfoRegister(pDevIns, pszName, pszDesc, pfnHandler);
4782}
4783
4784/**
4785 * @copydoc PDMDEVHLPR3::pfnDBGFRegRegister
4786 */
4787DECLINLINE(int) PDMDevHlpDBGFRegRegister(PPDMDEVINS pDevIns, PCDBGFREGDESC paRegisters)
4788{
4789 return pDevIns->pHlpR3->pfnDBGFRegRegister(pDevIns, paRegisters);
4790}
4791
4792/**
4793 * @copydoc PDMDEVHLPR3::pfnSTAMRegister
4794 */
4795DECLINLINE(void) PDMDevHlpSTAMRegister(PPDMDEVINS pDevIns, void *pvSample, STAMTYPE enmType, const char *pszName, STAMUNIT enmUnit, const char *pszDesc)
4796{
4797 pDevIns->pHlpR3->pfnSTAMRegister(pDevIns, pvSample, enmType, pszName, enmUnit, pszDesc);
4798}
4799
4800/**
4801 * @copydoc PDMDEVHLPR3::pfnSTAMRegisterF
4802 */
4803DECLINLINE(void) PDMDevHlpSTAMRegisterF(PPDMDEVINS pDevIns, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility, STAMUNIT enmUnit,
4804 const char *pszDesc, const char *pszName, ...)
4805{
4806 va_list va;
4807 va_start(va, pszName);
4808 pDevIns->pHlpR3->pfnSTAMRegisterV(pDevIns, pvSample, enmType, enmVisibility, enmUnit, pszDesc, pszName, va);
4809 va_end(va);
4810}
4811
4812/**
4813 * @copydoc PDMDEVHLPR3::pfnPCIRegister
4814 */
4815DECLINLINE(int) PDMDevHlpPCIRegister(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev)
4816{
4817 return pDevIns->pHlpR3->pfnPCIRegister(pDevIns, pPciDev);
4818}
4819
4820/**
4821 * @copydoc PDMDEVHLPR3::pfnPCIIORegionRegister
4822 */
4823DECLINLINE(int) PDMDevHlpPCIIORegionRegister(PPDMDEVINS pDevIns, int iRegion, uint32_t cbRegion, PCIADDRESSSPACE enmType, PFNPCIIOREGIONMAP pfnCallback)
4824{
4825 return pDevIns->pHlpR3->pfnPCIIORegionRegister(pDevIns, iRegion, cbRegion, enmType, pfnCallback);
4826}
4827
4828/**
4829 * @copydoc PDMDEVHLPR3::pfnPCIRegisterMsi
4830 */
4831DECLINLINE(int) PDMDevHlpPCIRegisterMsi(PPDMDEVINS pDevIns, PPDMMSIREG pMsiReg)
4832{
4833 return pDevIns->pHlpR3->pfnPCIRegisterMsi(pDevIns, pMsiReg);
4834}
4835
4836/**
4837 * @copydoc PDMDEVHLPR3::pfnPCISetConfigCallbacks
4838 */
4839DECLINLINE(void) PDMDevHlpPCISetConfigCallbacks(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, PFNPCICONFIGREAD pfnRead, PPFNPCICONFIGREAD ppfnReadOld,
4840 PFNPCICONFIGWRITE pfnWrite, PPFNPCICONFIGWRITE ppfnWriteOld)
4841{
4842 pDevIns->pHlpR3->pfnPCISetConfigCallbacks(pDevIns, pPciDev, pfnRead, ppfnReadOld, pfnWrite, ppfnWriteOld);
4843}
4844
4845#endif /* IN_RING3 */
4846
4847/**
4848 * @copydoc PDMDEVHLPR3::pfnPCIPhysRead
4849 */
4850DECLINLINE(int) PDMDevHlpPCIPhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)
4851{
4852 return pDevIns->CTX_SUFF(pHlp)->pfnPCIPhysRead(pDevIns, GCPhys, pvBuf, cbRead);
4853}
4854
4855/**
4856 * @copydoc PDMDEVHLPR3::pfnPCIPhysWrite
4857 */
4858DECLINLINE(int) PDMDevHlpPCIPhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)
4859{
4860 return pDevIns->CTX_SUFF(pHlp)->pfnPCIPhysWrite(pDevIns, GCPhys, pvBuf, cbWrite);
4861}
4862
4863/**
4864 * @copydoc PDMDEVHLPR3::pfnPCISetIrq
4865 */
4866DECLINLINE(void) PDMDevHlpPCISetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel)
4867{
4868 pDevIns->CTX_SUFF(pHlp)->pfnPCISetIrq(pDevIns, iIrq, iLevel);
4869}
4870
4871/**
4872 * @copydoc PDMDEVHLPR3::pfnPCISetIrqNoWait
4873 */
4874DECLINLINE(void) PDMDevHlpPCISetIrqNoWait(PPDMDEVINS pDevIns, int iIrq, int iLevel)
4875{
4876 pDevIns->CTX_SUFF(pHlp)->pfnPCISetIrq(pDevIns, iIrq, iLevel);
4877}
4878
4879/**
4880 * @copydoc PDMDEVHLPR3::pfnISASetIrq
4881 */
4882DECLINLINE(void) PDMDevHlpISASetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel)
4883{
4884 pDevIns->CTX_SUFF(pHlp)->pfnISASetIrq(pDevIns, iIrq, iLevel);
4885}
4886
4887/**
4888 * @copydoc PDMDEVHLPR3::pfnISASetIrqNoWait
4889 */
4890DECLINLINE(void) PDMDevHlpISASetIrqNoWait(PPDMDEVINS pDevIns, int iIrq, int iLevel)
4891{
4892 pDevIns->CTX_SUFF(pHlp)->pfnISASetIrq(pDevIns, iIrq, iLevel);
4893}
4894
4895#ifdef IN_RING3
4896
4897/**
4898 * @copydoc PDMDEVHLPR3::pfnDriverAttach
4899 */
4900DECLINLINE(int) PDMDevHlpDriverAttach(PPDMDEVINS pDevIns, uint32_t iLun, PPDMIBASE pBaseInterface, PPDMIBASE *ppBaseInterface, const char *pszDesc)
4901{
4902 return pDevIns->pHlpR3->pfnDriverAttach(pDevIns, iLun, pBaseInterface, ppBaseInterface, pszDesc);
4903}
4904
4905/**
4906 * @copydoc PDMDEVHLPR3::pfnQueueCreate
4907 */
4908DECLINLINE(int) PDMDevHlpQueueCreate(PPDMDEVINS pDevIns, size_t cbItem, uint32_t cItems, uint32_t cMilliesInterval,
4909 PFNPDMQUEUEDEV pfnCallback, bool fRZEnabled, const char *pszName, PPDMQUEUE *ppQueue)
4910{
4911 return pDevIns->pHlpR3->pfnQueueCreate(pDevIns, cbItem, cItems, cMilliesInterval, pfnCallback, fRZEnabled, pszName, ppQueue);
4912}
4913
4914/**
4915 * Initializes a PDM critical section.
4916 *
4917 * The PDM critical sections are derived from the IPRT critical sections, but
4918 * works in RC and R0 as well.
4919 *
4920 * @returns VBox status code.
4921 * @param pDevIns The device instance.
4922 * @param pCritSect Pointer to the critical section.
4923 * @param RT_SRC_POS_DECL Use RT_SRC_POS.
4924 * @param pszNameFmt Format string for naming the critical section.
4925 * For statistics and lock validation.
4926 * @param ... Arguments for the format string.
4927 */
4928DECLINLINE(int) PDMDevHlpCritSectInit(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, RT_SRC_POS_DECL, const char *pszNameFmt, ...)
4929{
4930 int rc;
4931 va_list va;
4932 va_start(va, pszNameFmt);
4933 rc = pDevIns->pHlpR3->pfnCritSectInit(pDevIns, pCritSect, RT_SRC_POS_ARGS, pszNameFmt, va);
4934 va_end(va);
4935 return rc;
4936}
4937
4938/**
4939 * @copydoc PDMDEVHLPR3::pfnCritSectGetNop
4940 */
4941DECLINLINE(PPDMCRITSECT) PDMDevHlpCritSectGetNop(PPDMDEVINS pDevIns)
4942{
4943 return pDevIns->pHlpR3->pfnCritSectGetNop(pDevIns);
4944}
4945
4946/**
4947 * @copydoc PDMDEVHLPR3::pfnCritSectGetNopR0
4948 */
4949DECLINLINE(R0PTRTYPE(PPDMCRITSECT)) PDMDevHlpCritSectGetNopR0(PPDMDEVINS pDevIns)
4950{
4951 return pDevIns->pHlpR3->pfnCritSectGetNopR0(pDevIns);
4952}
4953
4954/**
4955 * @copydoc PDMDEVHLPR3::pfnCritSectGetNopRC
4956 */
4957DECLINLINE(RCPTRTYPE(PPDMCRITSECT)) PDMDevHlpCritSectGetNopRC(PPDMDEVINS pDevIns)
4958{
4959 return pDevIns->pHlpR3->pfnCritSectGetNopRC(pDevIns);
4960}
4961
4962/**
4963 * @copydoc PDMDEVHLPR3::pfnSetDeviceCritSect
4964 */
4965DECLINLINE(int) PDMDevHlpSetDeviceCritSect(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect)
4966{
4967 return pDevIns->pHlpR3->pfnSetDeviceCritSect(pDevIns, pCritSect);
4968}
4969
4970/**
4971 * @copydoc PDMDEVHLPR3::pfnThreadCreate
4972 */
4973DECLINLINE(int) PDMDevHlpThreadCreate(PPDMDEVINS pDevIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADDEV pfnThread,
4974 PFNPDMTHREADWAKEUPDEV pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName)
4975{
4976 return pDevIns->pHlpR3->pfnThreadCreate(pDevIns, ppThread, pvUser, pfnThread, pfnWakeup, cbStack, enmType, pszName);
4977}
4978
4979/**
4980 * @copydoc PDMDEVHLPR3::pfnSetAsyncNotification
4981 */
4982DECLINLINE(int) PDMDevHlpSetAsyncNotification(PPDMDEVINS pDevIns, PFNPDMDEVASYNCNOTIFY pfnAsyncNotify)
4983{
4984 return pDevIns->pHlpR3->pfnSetAsyncNotification(pDevIns, pfnAsyncNotify);
4985}
4986
4987/**
4988 * @copydoc PDMDEVHLPR3::pfnAsyncNotificationCompleted
4989 */
4990DECLINLINE(void) PDMDevHlpAsyncNotificationCompleted(PPDMDEVINS pDevIns)
4991{
4992 pDevIns->pHlpR3->pfnAsyncNotificationCompleted(pDevIns);
4993}
4994
4995/**
4996 * @copydoc PDMDEVHLPR3::pfnA20Set
4997 */
4998DECLINLINE(void) PDMDevHlpA20Set(PPDMDEVINS pDevIns, bool fEnable)
4999{
5000 pDevIns->pHlpR3->pfnA20Set(pDevIns, fEnable);
5001}
5002
5003/**
5004 * @copydoc PDMDEVHLPR3::pfnRTCRegister
5005 */
5006DECLINLINE(int) PDMDevHlpRTCRegister(PPDMDEVINS pDevIns, PCPDMRTCREG pRtcReg, PCPDMRTCHLP *ppRtcHlp)
5007{
5008 return pDevIns->pHlpR3->pfnRTCRegister(pDevIns, pRtcReg, ppRtcHlp);
5009}
5010
5011/**
5012 * @copydoc PDMDEVHLPR3::pfnPCIBusRegister
5013 */
5014DECLINLINE(int) PDMDevHlpPCIBusRegister(PPDMDEVINS pDevIns, PPDMPCIBUSREG pPciBusReg, PCPDMPCIHLPR3 *ppPciHlpR3)
5015{
5016 return pDevIns->pHlpR3->pfnPCIBusRegister(pDevIns, pPciBusReg, ppPciHlpR3);
5017}
5018
5019/**
5020 * @copydoc PDMDEVHLPR3::pfnPICRegister
5021 */
5022DECLINLINE(int) PDMDevHlpPICRegister(PPDMDEVINS pDevIns, PPDMPICREG pPicReg, PCPDMPICHLPR3 *ppPicHlpR3)
5023{
5024 return pDevIns->pHlpR3->pfnPICRegister(pDevIns, pPicReg, ppPicHlpR3);
5025}
5026
5027/**
5028 * @copydoc PDMDEVHLPR3::pfnAPICRegister
5029 */
5030DECLINLINE(int) PDMDevHlpAPICRegister(PPDMDEVINS pDevIns, PPDMAPICREG pApicReg, PCPDMAPICHLPR3 *ppApicHlpR3)
5031{
5032 return pDevIns->pHlpR3->pfnAPICRegister(pDevIns, pApicReg, ppApicHlpR3);
5033}
5034
5035/**
5036 * @copydoc PDMDEVHLPR3::pfn
5037 */
5038DECLINLINE(int) PDMDevHlpIOAPICRegister(PPDMDEVINS pDevIns, PPDMIOAPICREG pIoApicReg, PCPDMIOAPICHLPR3 *ppIoApicHlpR3)
5039{
5040 return pDevIns->pHlpR3->pfnIOAPICRegister(pDevIns, pIoApicReg, ppIoApicHlpR3);
5041}
5042
5043/**
5044 * @copydoc PDMDEVHLPR3::pfnHPETRegister
5045 */
5046DECLINLINE(int) PDMDevHlpHPETRegister(PPDMDEVINS pDevIns, PPDMHPETREG pHpetReg, PCPDMHPETHLPR3 *ppHpetHlpR3)
5047{
5048 return pDevIns->pHlpR3->pfnHPETRegister(pDevIns, pHpetReg, ppHpetHlpR3);
5049}
5050
5051/**
5052 * @copydoc PDMDEVHLPR3::pfnPciRawRegister
5053 */
5054DECLINLINE(int) PDMDevHlpPciRawRegister(PPDMDEVINS pDevIns, PPDMPCIRAWREG pPciRawReg, PCPDMPCIRAWHLPR3 *ppPciRawHlpR3)
5055{
5056 return pDevIns->pHlpR3->pfnPciRawRegister(pDevIns, pPciRawReg, ppPciRawHlpR3);
5057}
5058
5059/**
5060 * @copydoc PDMDEVHLPR3::pfnDMACRegister
5061 */
5062DECLINLINE(int) PDMDevHlpDMACRegister(PPDMDEVINS pDevIns, PPDMDMACREG pDmacReg, PCPDMDMACHLP *ppDmacHlp)
5063{
5064 return pDevIns->pHlpR3->pfnDMACRegister(pDevIns, pDmacReg, ppDmacHlp);
5065}
5066
5067/**
5068 * @copydoc PDMDEVHLPR3::pfnDMARegister
5069 */
5070DECLINLINE(int) PDMDevHlpDMARegister(PPDMDEVINS pDevIns, unsigned uChannel, PFNDMATRANSFERHANDLER pfnTransferHandler, void *pvUser)
5071{
5072 return pDevIns->pHlpR3->pfnDMARegister(pDevIns, uChannel, pfnTransferHandler, pvUser);
5073}
5074
5075/**
5076 * @copydoc PDMDEVHLPR3::pfnDMAReadMemory
5077 */
5078DECLINLINE(int) PDMDevHlpDMAReadMemory(PPDMDEVINS pDevIns, unsigned uChannel, void *pvBuffer, uint32_t off, uint32_t cbBlock, uint32_t *pcbRead)
5079{
5080 return pDevIns->pHlpR3->pfnDMAReadMemory(pDevIns, uChannel, pvBuffer, off, cbBlock, pcbRead);
5081}
5082
5083/**
5084 * @copydoc PDMDEVHLPR3::pfnDMAWriteMemory
5085 */
5086DECLINLINE(int) PDMDevHlpDMAWriteMemory(PPDMDEVINS pDevIns, unsigned uChannel, const void *pvBuffer, uint32_t off, uint32_t cbBlock, uint32_t *pcbWritten)
5087{
5088 return pDevIns->pHlpR3->pfnDMAWriteMemory(pDevIns, uChannel, pvBuffer, off, cbBlock, pcbWritten);
5089}
5090
5091/**
5092 * @copydoc PDMDEVHLPR3::pfnDMASetDREQ
5093 */
5094DECLINLINE(int) PDMDevHlpDMASetDREQ(PPDMDEVINS pDevIns, unsigned uChannel, unsigned uLevel)
5095{
5096 return pDevIns->pHlpR3->pfnDMASetDREQ(pDevIns, uChannel, uLevel);
5097}
5098
5099/**
5100 * @copydoc PDMDEVHLPR3::pfnDMAGetChannelMode
5101 */
5102DECLINLINE(uint8_t) PDMDevHlpDMAGetChannelMode(PPDMDEVINS pDevIns, unsigned uChannel)
5103{
5104 return pDevIns->pHlpR3->pfnDMAGetChannelMode(pDevIns, uChannel);
5105}
5106
5107/**
5108 * @copydoc PDMDEVHLPR3::pfnDMASchedule
5109 */
5110DECLINLINE(void) PDMDevHlpDMASchedule(PPDMDEVINS pDevIns)
5111{
5112 pDevIns->pHlpR3->pfnDMASchedule(pDevIns);
5113}
5114
5115/**
5116 * @copydoc PDMDEVHLPR3::pfnCMOSWrite
5117 */
5118DECLINLINE(int) PDMDevHlpCMOSWrite(PPDMDEVINS pDevIns, unsigned iReg, uint8_t u8Value)
5119{
5120 return pDevIns->pHlpR3->pfnCMOSWrite(pDevIns, iReg, u8Value);
5121}
5122
5123/**
5124 * @copydoc PDMDEVHLPR3::pfnCMOSRead
5125 */
5126DECLINLINE(int) PDMDevHlpCMOSRead(PPDMDEVINS pDevIns, unsigned iReg, uint8_t *pu8Value)
5127{
5128 return pDevIns->pHlpR3->pfnCMOSRead(pDevIns, iReg, pu8Value);
5129}
5130
5131/**
5132 * @copydoc PDMDEVHLP::pfnCallR0
5133 */
5134DECLINLINE(int) PDMDevHlpCallR0(PPDMDEVINS pDevIns, uint32_t uOperation, uint64_t u64Arg)
5135{
5136 return pDevIns->pHlpR3->pfnCallR0(pDevIns, uOperation, u64Arg);
5137}
5138
5139/**
5140 * @copydoc PDMDEVHLP::pfnVMGetSuspendReason
5141 */
5142DECLINLINE(VMSUSPENDREASON) PDMDevHlpVMGetSuspendReason(PPDMDEVINS pDevIns)
5143{
5144 return pDevIns->pHlpR3->pfnVMGetSuspendReason(pDevIns);
5145}
5146
5147/**
5148 * @copydoc PDMDEVHLP::pfnVMGetResumeReason
5149 */
5150DECLINLINE(VMRESUMEREASON) PDMDevHlpVMGetResumeReason(PPDMDEVINS pDevIns)
5151{
5152 return pDevIns->pHlpR3->pfnVMGetResumeReason(pDevIns);
5153}
5154
5155/**
5156 * @copydoc PDMDEVHLPR3::pfnGetUVM
5157 */
5158DECLINLINE(PUVM) PDMDevHlpGetUVM(PPDMDEVINS pDevIns)
5159{
5160 return pDevIns->CTX_SUFF(pHlp)->pfnGetUVM(pDevIns);
5161}
5162
5163#endif /* IN_RING3 */
5164
5165/**
5166 * @copydoc PDMDEVHLPR3::pfnGetVM
5167 */
5168DECLINLINE(PVM) PDMDevHlpGetVM(PPDMDEVINS pDevIns)
5169{
5170 return pDevIns->CTX_SUFF(pHlp)->pfnGetVM(pDevIns);
5171}
5172
5173/**
5174 * @copydoc PDMDEVHLPR3::pfnGetVMCPU
5175 */
5176DECLINLINE(PVMCPU) PDMDevHlpGetVMCPU(PPDMDEVINS pDevIns)
5177{
5178 return pDevIns->CTX_SUFF(pHlp)->pfnGetVMCPU(pDevIns);
5179}
5180
5181/**
5182 * @copydoc PDMDEVHLPR3::pfnGetCurrentCpuId
5183 */
5184DECLINLINE(VMCPUID) PDMDevHlpGetCurrentCpuId(PPDMDEVINS pDevIns)
5185{
5186 return pDevIns->CTX_SUFF(pHlp)->pfnGetCurrentCpuId(pDevIns);
5187}
5188
5189/**
5190 * @copydoc PDMDEVHLPR3::pfnTMTimeVirtGet
5191 */
5192DECLINLINE(uint64_t) PDMDevHlpTMTimeVirtGet(PPDMDEVINS pDevIns)
5193{
5194 return pDevIns->CTX_SUFF(pHlp)->pfnTMTimeVirtGet(pDevIns);
5195}
5196
5197/**
5198 * @copydoc PDMDEVHLPR3::pfnTMTimeVirtGetFreq
5199 */
5200DECLINLINE(uint64_t) PDMDevHlpTMTimeVirtGetFreq(PPDMDEVINS pDevIns)
5201{
5202 return pDevIns->CTX_SUFF(pHlp)->pfnTMTimeVirtGetFreq(pDevIns);
5203}
5204
5205/**
5206 * @copydoc PDMDEVHLPR3::pfnTMTimeVirtGetFreq
5207 */
5208DECLINLINE(uint64_t) PDMDevHlpTMTimeVirtGetNano(PPDMDEVINS pDevIns)
5209{
5210 return pDevIns->CTX_SUFF(pHlp)->pfnTMTimeVirtGetNano(pDevIns);
5211}
5212
5213#ifdef IN_RING3
5214
5215/**
5216 * @copydoc PDMDEVHLPR3::pfnRegisterVMMDevHeap
5217 */
5218DECLINLINE(int) PDMDevHlpRegisterVMMDevHeap(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTR3PTR pvHeap, unsigned cbSize)
5219{
5220 return pDevIns->pHlpR3->pfnRegisterVMMDevHeap(pDevIns, GCPhys, pvHeap, cbSize);
5221}
5222
5223/**
5224 * @copydoc PDMDEVHLPR3::pfnUnregisterVMMDevHeap
5225 */
5226DECLINLINE(int) PDMDevHlpUnregisterVMMDevHeap(PPDMDEVINS pDevIns, RTGCPHYS GCPhys)
5227{
5228 return pDevIns->pHlpR3->pfnUnregisterVMMDevHeap(pDevIns, GCPhys);
5229}
5230
5231/**
5232 * @copydoc PDMDEVHLPR3::pfnVMReset
5233 */
5234DECLINLINE(int) PDMDevHlpVMReset(PPDMDEVINS pDevIns)
5235{
5236 return pDevIns->pHlpR3->pfnVMReset(pDevIns);
5237}
5238
5239/**
5240 * @copydoc PDMDEVHLPR3::pfnVMSuspend
5241 */
5242DECLINLINE(int) PDMDevHlpVMSuspend(PPDMDEVINS pDevIns)
5243{
5244 return pDevIns->pHlpR3->pfnVMSuspend(pDevIns);
5245}
5246
5247/**
5248 * @copydoc PDMDEVHLPR3::pfnVMSuspendSaveAndPowerOff
5249 */
5250DECLINLINE(int) PDMDevHlpVMSuspendSaveAndPowerOff(PPDMDEVINS pDevIns)
5251{
5252 return pDevIns->pHlpR3->pfnVMSuspendSaveAndPowerOff(pDevIns);
5253}
5254
5255/**
5256 * @copydoc PDMDEVHLPR3::pfnVMPowerOff
5257 */
5258DECLINLINE(int) PDMDevHlpVMPowerOff(PPDMDEVINS pDevIns)
5259{
5260 return pDevIns->pHlpR3->pfnVMPowerOff(pDevIns);
5261}
5262
5263#endif /* IN_RING3 */
5264
5265/**
5266 * @copydoc PDMDEVHLPR3::pfnA20IsEnabled
5267 */
5268DECLINLINE(bool) PDMDevHlpA20IsEnabled(PPDMDEVINS pDevIns)
5269{
5270 return pDevIns->CTX_SUFF(pHlp)->pfnA20IsEnabled(pDevIns);
5271}
5272
5273#ifdef IN_RING3
5274
5275/**
5276 * @copydoc PDMDEVHLPR3::pfnGetCpuId
5277 */
5278DECLINLINE(void) PDMDevHlpGetCpuId(PPDMDEVINS pDevIns, uint32_t iLeaf, uint32_t *pEax, uint32_t *pEbx, uint32_t *pEcx, uint32_t *pEdx)
5279{
5280 pDevIns->pHlpR3->pfnGetCpuId(pDevIns, iLeaf, pEax, pEbx, pEcx, pEdx);
5281}
5282
5283/**
5284 * @copydoc PDMDEVHLPR3::pfnGetSupDrvSession
5285 */
5286DECLINLINE(PSUPDRVSESSION) PDMDevHlpGetSupDrvSession(PPDMDEVINS pDevIns)
5287{
5288 return pDevIns->pHlpR3->pfnGetSupDrvSession(pDevIns);
5289}
5290
5291#endif /* IN_RING3 */
5292#ifdef IN_RING0
5293
5294/**
5295 * @copydoc PDMDEVHLPR0::pfnCanEmulateIoBlock
5296 */
5297DECLINLINE(bool) PDMDevHlpCanEmulateIoBlock(PPDMDEVINS pDevIns)
5298{
5299 return pDevIns->CTX_SUFF(pHlp)->pfnCanEmulateIoBlock(pDevIns);
5300}
5301
5302#endif /* IN_RING0 */
5303
5304
5305
5306
5307/** Pointer to callbacks provided to the VBoxDeviceRegister() call. */
5308typedef struct PDMDEVREGCB *PPDMDEVREGCB;
5309
5310/**
5311 * Callbacks for VBoxDeviceRegister().
5312 */
5313typedef struct PDMDEVREGCB
5314{
5315 /** Interface version.
5316 * This is set to PDM_DEVREG_CB_VERSION. */
5317 uint32_t u32Version;
5318
5319 /**
5320 * Registers a device with the current VM instance.
5321 *
5322 * @returns VBox status code.
5323 * @param pCallbacks Pointer to the callback table.
5324 * @param pReg Pointer to the device registration record.
5325 * This data must be permanent and readonly.
5326 */
5327 DECLR3CALLBACKMEMBER(int, pfnRegister,(PPDMDEVREGCB pCallbacks, PCPDMDEVREG pReg));
5328} PDMDEVREGCB;
5329
5330/** Current version of the PDMDEVREGCB structure. */
5331#define PDM_DEVREG_CB_VERSION PDM_VERSION_MAKE(0xffe3, 1, 0)
5332
5333
5334/**
5335 * The VBoxDevicesRegister callback function.
5336 *
5337 * PDM will invoke this function after loading a device module and letting
5338 * the module decide which devices to register and how to handle conflicts.
5339 *
5340 * @returns VBox status code.
5341 * @param pCallbacks Pointer to the callback table.
5342 * @param u32Version VBox version number.
5343 */
5344typedef DECLCALLBACK(int) FNPDMVBOXDEVICESREGISTER(PPDMDEVREGCB pCallbacks, uint32_t u32Version);
5345
5346/** @} */
5347
5348RT_C_DECLS_END
5349
5350#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