VirtualBox

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

Last change on this file since 58110 was 58106, checked in by vboxsync, 9 years ago

include,misc: Corrected a bunch of doxygen errors.

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