VirtualBox

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

最後變更 在這個檔案從85007是 85007,由 vboxsync 提交於 5 年 前

AMD IOMMU: bugref:9654 PDM, Main: Changes for southbridge I/O APIC and related PCI address assignment.

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Id Revision
檔案大小: 341.9 KB
 
1/** @file
2 * PDM - Pluggable Device Manager, Devices.
3 */
4
5/*
6 * Copyright (C) 2006-2020 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.alldomusa.eu.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_INCLUDED_vmm_pdmdev_h
27#define VBOX_INCLUDED_vmm_pdmdev_h
28#ifndef RT_WITHOUT_PRAGMA_ONCE
29# pragma once
30#endif
31
32#include <VBox/vmm/pdmcritsect.h>
33#include <VBox/vmm/pdmqueue.h>
34#include <VBox/vmm/pdmtask.h>
35#ifdef IN_RING3
36# include <VBox/vmm/pdmthread.h>
37#endif
38#include <VBox/vmm/pdmifs.h>
39#include <VBox/vmm/pdmins.h>
40#include <VBox/vmm/pdmcommon.h>
41#include <VBox/vmm/pdmpcidev.h>
42#include <VBox/vmm/iom.h>
43#include <VBox/vmm/tm.h>
44#include <VBox/vmm/ssm.h>
45#include <VBox/vmm/cfgm.h>
46#include <VBox/vmm/cpum.h>
47#include <VBox/vmm/dbgf.h>
48#include <VBox/vmm/pgm.h> /* PGMR3HandlerPhysicalTypeRegister() argument types. */
49#include <VBox/err.h> /* VINF_EM_DBG_STOP, also 120+ source files expecting this. */
50#include <VBox/msi.h>
51#include <iprt/stdarg.h>
52#include <iprt/list.h>
53
54
55RT_C_DECLS_BEGIN
56
57/** @defgroup grp_pdm_device The PDM Devices API
58 * @ingroup grp_pdm
59 * @{
60 */
61
62/**
63 * Construct a device instance for a VM.
64 *
65 * @returns VBox status.
66 * @param pDevIns The device instance data. If the registration structure
67 * is needed, it can be accessed thru pDevIns->pReg.
68 * @param iInstance Instance number. Use this to figure out which registers
69 * and such to use. The instance number is also found in
70 * pDevIns->iInstance, but since it's likely to be
71 * frequently used PDM passes it as parameter.
72 * @param pCfg Configuration node handle for the driver. This is
73 * expected to be in high demand in the constructor and is
74 * therefore passed as an argument. When using it at other
75 * times, it can be found in pDevIns->pCfg.
76 */
77typedef DECLCALLBACK(int) FNPDMDEVCONSTRUCT(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg);
78/** Pointer to a FNPDMDEVCONSTRUCT() function. */
79typedef FNPDMDEVCONSTRUCT *PFNPDMDEVCONSTRUCT;
80
81/**
82 * Destruct a device instance.
83 *
84 * Most VM resources are freed by the VM. This callback is provided so that any non-VM
85 * resources can be freed correctly.
86 *
87 * @returns VBox status.
88 * @param pDevIns The device instance data.
89 *
90 * @remarks The device critical section is not entered. The routine may delete
91 * the critical section, so the caller cannot exit it.
92 */
93typedef DECLCALLBACK(int) FNPDMDEVDESTRUCT(PPDMDEVINS pDevIns);
94/** Pointer to a FNPDMDEVDESTRUCT() function. */
95typedef FNPDMDEVDESTRUCT *PFNPDMDEVDESTRUCT;
96
97/**
98 * Device relocation callback.
99 *
100 * This is called when the instance data has been relocated in raw-mode context
101 * (RC). It is also called when the RC hypervisor selects changes. The device
102 * must fixup all necessary pointers and re-query all interfaces to other RC
103 * devices and drivers.
104 *
105 * Before the RC code is executed the first time, this function will be called
106 * with a 0 delta so RC pointer calculations can be one in one place.
107 *
108 * @param pDevIns Pointer to the device instance.
109 * @param offDelta The relocation delta relative to the old location.
110 *
111 * @remarks A relocation CANNOT fail.
112 *
113 * @remarks The device critical section is not entered. The relocations should
114 * not normally require any locking.
115 */
116typedef DECLCALLBACK(void) FNPDMDEVRELOCATE(PPDMDEVINS pDevIns, RTGCINTPTR offDelta);
117/** Pointer to a FNPDMDEVRELOCATE() function. */
118typedef FNPDMDEVRELOCATE *PFNPDMDEVRELOCATE;
119
120/**
121 * Power On notification.
122 *
123 * @returns VBox status.
124 * @param pDevIns The device instance data.
125 *
126 * @remarks Caller enters the device critical section.
127 */
128typedef DECLCALLBACK(void) FNPDMDEVPOWERON(PPDMDEVINS pDevIns);
129/** Pointer to a FNPDMDEVPOWERON() function. */
130typedef FNPDMDEVPOWERON *PFNPDMDEVPOWERON;
131
132/**
133 * Reset notification.
134 *
135 * @returns VBox status.
136 * @param pDevIns The device instance data.
137 *
138 * @remarks Caller enters the device critical section.
139 */
140typedef DECLCALLBACK(void) FNPDMDEVRESET(PPDMDEVINS pDevIns);
141/** Pointer to a FNPDMDEVRESET() function. */
142typedef FNPDMDEVRESET *PFNPDMDEVRESET;
143
144/**
145 * Soft reset notification.
146 *
147 * This is mainly for emulating the 286 style protected mode exits, in which
148 * most devices should remain in their current state.
149 *
150 * @returns VBox status.
151 * @param pDevIns The device instance data.
152 * @param fFlags PDMVMRESET_F_XXX (only bits relevant to soft resets).
153 *
154 * @remarks Caller enters the device critical section.
155 */
156typedef DECLCALLBACK(void) FNPDMDEVSOFTRESET(PPDMDEVINS pDevIns, uint32_t fFlags);
157/** Pointer to a FNPDMDEVSOFTRESET() function. */
158typedef FNPDMDEVSOFTRESET *PFNPDMDEVSOFTRESET;
159
160/** @name PDMVMRESET_F_XXX - VM reset flags.
161 * These flags are used both for FNPDMDEVSOFTRESET and for hardware signalling
162 * reset via PDMDevHlpVMReset.
163 * @{ */
164/** Unknown reason. */
165#define PDMVMRESET_F_UNKNOWN UINT32_C(0x00000000)
166/** GIM triggered reset. */
167#define PDMVMRESET_F_GIM UINT32_C(0x00000001)
168/** The last source always causing hard resets. */
169#define PDMVMRESET_F_LAST_ALWAYS_HARD PDMVMRESET_F_GIM
170/** ACPI triggered reset. */
171#define PDMVMRESET_F_ACPI UINT32_C(0x0000000c)
172/** PS/2 system port A (92h) reset. */
173#define PDMVMRESET_F_PORT_A UINT32_C(0x0000000d)
174/** Keyboard reset. */
175#define PDMVMRESET_F_KBD UINT32_C(0x0000000e)
176/** Tripple fault. */
177#define PDMVMRESET_F_TRIPLE_FAULT UINT32_C(0x0000000f)
178/** Reset source mask. */
179#define PDMVMRESET_F_SRC_MASK UINT32_C(0x0000000f)
180/** @} */
181
182/**
183 * Suspend notification.
184 *
185 * @returns VBox status.
186 * @param pDevIns The device instance data.
187 * @thread EMT(0)
188 *
189 * @remarks Caller enters the device critical section.
190 */
191typedef DECLCALLBACK(void) FNPDMDEVSUSPEND(PPDMDEVINS pDevIns);
192/** Pointer to a FNPDMDEVSUSPEND() function. */
193typedef FNPDMDEVSUSPEND *PFNPDMDEVSUSPEND;
194
195/**
196 * Resume notification.
197 *
198 * @returns VBox status.
199 * @param pDevIns The device instance data.
200 *
201 * @remarks Caller enters the device critical section.
202 */
203typedef DECLCALLBACK(void) FNPDMDEVRESUME(PPDMDEVINS pDevIns);
204/** Pointer to a FNPDMDEVRESUME() function. */
205typedef FNPDMDEVRESUME *PFNPDMDEVRESUME;
206
207/**
208 * Power Off notification.
209 *
210 * This is always called when VMR3PowerOff is called.
211 * There will be no callback when hot plugging devices.
212 *
213 * @param pDevIns The device instance data.
214 * @thread EMT(0)
215 *
216 * @remarks Caller enters the device critical section.
217 */
218typedef DECLCALLBACK(void) FNPDMDEVPOWEROFF(PPDMDEVINS pDevIns);
219/** Pointer to a FNPDMDEVPOWEROFF() function. */
220typedef FNPDMDEVPOWEROFF *PFNPDMDEVPOWEROFF;
221
222/**
223 * Attach command.
224 *
225 * This is called to let the device attach to a driver for a specified LUN
226 * at runtime. This is not called during VM construction, the device
227 * constructor has to attach to all the available drivers.
228 *
229 * This is like plugging in the keyboard or mouse after turning on the PC.
230 *
231 * @returns VBox status code.
232 * @param pDevIns The device instance.
233 * @param iLUN The logical unit which is being attached.
234 * @param fFlags Flags, combination of the PDM_TACH_FLAGS_* \#defines.
235 *
236 * @remarks Caller enters the device critical section.
237 */
238typedef DECLCALLBACK(int) FNPDMDEVATTACH(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags);
239/** Pointer to a FNPDMDEVATTACH() function. */
240typedef FNPDMDEVATTACH *PFNPDMDEVATTACH;
241
242/**
243 * Detach notification.
244 *
245 * This is called when a driver is detaching itself from a LUN of the device.
246 * The device should adjust its state to reflect this.
247 *
248 * This is like unplugging the network cable to use it for the laptop or
249 * something while the PC is still running.
250 *
251 * @param pDevIns The device instance.
252 * @param iLUN The logical unit which is being detached.
253 * @param fFlags Flags, combination of the PDMDEVATT_FLAGS_* \#defines.
254 *
255 * @remarks Caller enters the device critical section.
256 */
257typedef DECLCALLBACK(void) FNPDMDEVDETACH(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags);
258/** Pointer to a FNPDMDEVDETACH() function. */
259typedef FNPDMDEVDETACH *PFNPDMDEVDETACH;
260
261/**
262 * Query the base interface of a logical unit.
263 *
264 * @returns VBOX status code.
265 * @param pDevIns The device instance.
266 * @param iLUN The logicial unit to query.
267 * @param ppBase Where to store the pointer to the base interface of the LUN.
268 *
269 * @remarks The device critical section is not entered.
270 */
271typedef DECLCALLBACK(int) FNPDMDEVQUERYINTERFACE(PPDMDEVINS pDevIns, unsigned iLUN, PPDMIBASE *ppBase);
272/** Pointer to a FNPDMDEVQUERYINTERFACE() function. */
273typedef FNPDMDEVQUERYINTERFACE *PFNPDMDEVQUERYINTERFACE;
274
275/**
276 * Init complete notification (after ring-0 & RC init since 5.1).
277 *
278 * This can be done to do communication with other devices and other
279 * initialization which requires everything to be in place.
280 *
281 * @returns VBOX status code.
282 * @param pDevIns The device instance.
283 *
284 * @remarks Caller enters the device critical section.
285 */
286typedef DECLCALLBACK(int) FNPDMDEVINITCOMPLETE(PPDMDEVINS pDevIns);
287/** Pointer to a FNPDMDEVINITCOMPLETE() function. */
288typedef FNPDMDEVINITCOMPLETE *PFNPDMDEVINITCOMPLETE;
289
290
291/**
292 * The context of a pfnMemSetup call.
293 */
294typedef enum PDMDEVMEMSETUPCTX
295{
296 /** Invalid zero value. */
297 PDMDEVMEMSETUPCTX_INVALID = 0,
298 /** After construction. */
299 PDMDEVMEMSETUPCTX_AFTER_CONSTRUCTION,
300 /** After reset. */
301 PDMDEVMEMSETUPCTX_AFTER_RESET,
302 /** Type size hack. */
303 PDMDEVMEMSETUPCTX_32BIT_HACK = 0x7fffffff
304} PDMDEVMEMSETUPCTX;
305
306
307/**
308 * PDM Device Registration Structure.
309 *
310 * This structure is used when registering a device from VBoxInitDevices() in HC
311 * Ring-3. PDM will continue use till the VM is terminated.
312 *
313 * @note The first part is the same in every context.
314 */
315typedef struct PDMDEVREGR3
316{
317 /** Structure version. PDM_DEVREGR3_VERSION defines the current version. */
318 uint32_t u32Version;
319 /** Reserved, must be zero. */
320 uint32_t uReserved0;
321 /** Device name, must match the ring-3 one. */
322 char szName[32];
323 /** Flags, combination of the PDM_DEVREG_FLAGS_* \#defines. */
324 uint32_t fFlags;
325 /** Device class(es), combination of the PDM_DEVREG_CLASS_* \#defines. */
326 uint32_t fClass;
327 /** Maximum number of instances (per VM). */
328 uint32_t cMaxInstances;
329 /** The shared data structure version number. */
330 uint32_t uSharedVersion;
331 /** Size of the instance data. */
332 uint32_t cbInstanceShared;
333 /** Size of the ring-0 instance data. */
334 uint32_t cbInstanceCC;
335 /** Size of the raw-mode instance data. */
336 uint32_t cbInstanceRC;
337 /** Max number of PCI devices. */
338 uint16_t cMaxPciDevices;
339 /** Max number of MSI-X vectors in any of the PCI devices. */
340 uint16_t cMaxMsixVectors;
341 /** The description of the device. The UTF-8 string pointed to shall, like this structure,
342 * remain unchanged from registration till VM destruction. */
343 const char *pszDescription;
344
345 /** Name of the raw-mode context module (no path).
346 * Only evalutated if PDM_DEVREG_FLAGS_RC is set. */
347 const char *pszRCMod;
348 /** Name of the ring-0 module (no path).
349 * Only evalutated if PDM_DEVREG_FLAGS_R0 is set. */
350 const char *pszR0Mod;
351
352 /** Construct instance - required. */
353 PFNPDMDEVCONSTRUCT pfnConstruct;
354 /** Destruct instance - optional.
355 * Critical section NOT entered (will be destroyed). */
356 PFNPDMDEVDESTRUCT pfnDestruct;
357 /** Relocation command - optional.
358 * Critical section NOT entered. */
359 PFNPDMDEVRELOCATE pfnRelocate;
360 /**
361 * Memory setup callback.
362 *
363 * @param pDevIns The device instance data.
364 * @param enmCtx Indicates the context of the call.
365 * @remarks The critical section is entered prior to calling this method.
366 */
367 DECLR3CALLBACKMEMBER(void, pfnMemSetup, (PPDMDEVINS pDevIns, PDMDEVMEMSETUPCTX enmCtx));
368 /** Power on notification - optional.
369 * Critical section is entered. */
370 PFNPDMDEVPOWERON pfnPowerOn;
371 /** Reset notification - optional.
372 * Critical section is entered. */
373 PFNPDMDEVRESET pfnReset;
374 /** Suspend notification - optional.
375 * Critical section is entered. */
376 PFNPDMDEVSUSPEND pfnSuspend;
377 /** Resume notification - optional.
378 * Critical section is entered. */
379 PFNPDMDEVRESUME pfnResume;
380 /** Attach command - optional.
381 * Critical section is entered. */
382 PFNPDMDEVATTACH pfnAttach;
383 /** Detach notification - optional.
384 * Critical section is entered. */
385 PFNPDMDEVDETACH pfnDetach;
386 /** Query a LUN base interface - optional.
387 * Critical section is NOT entered. */
388 PFNPDMDEVQUERYINTERFACE pfnQueryInterface;
389 /** Init complete notification - optional.
390 * Critical section is entered. */
391 PFNPDMDEVINITCOMPLETE pfnInitComplete;
392 /** Power off notification - optional.
393 * Critical section is entered. */
394 PFNPDMDEVPOWEROFF pfnPowerOff;
395 /** Software system reset notification - optional.
396 * Critical section is entered. */
397 PFNPDMDEVSOFTRESET pfnSoftReset;
398
399 /** @name Reserved for future extensions, must be zero.
400 * @{ */
401 DECLR3CALLBACKMEMBER(int, pfnReserved0, (PPDMDEVINS pDevIns));
402 DECLR3CALLBACKMEMBER(int, pfnReserved1, (PPDMDEVINS pDevIns));
403 DECLR3CALLBACKMEMBER(int, pfnReserved2, (PPDMDEVINS pDevIns));
404 DECLR3CALLBACKMEMBER(int, pfnReserved3, (PPDMDEVINS pDevIns));
405 DECLR3CALLBACKMEMBER(int, pfnReserved4, (PPDMDEVINS pDevIns));
406 DECLR3CALLBACKMEMBER(int, pfnReserved5, (PPDMDEVINS pDevIns));
407 DECLR3CALLBACKMEMBER(int, pfnReserved6, (PPDMDEVINS pDevIns));
408 DECLR3CALLBACKMEMBER(int, pfnReserved7, (PPDMDEVINS pDevIns));
409 /** @} */
410
411 /** Initialization safty marker. */
412 uint32_t u32VersionEnd;
413} PDMDEVREGR3;
414/** Pointer to a PDM Device Structure. */
415typedef PDMDEVREGR3 *PPDMDEVREGR3;
416/** Const pointer to a PDM Device Structure. */
417typedef PDMDEVREGR3 const *PCPDMDEVREGR3;
418/** Current DEVREGR3 version number. */
419#define PDM_DEVREGR3_VERSION PDM_VERSION_MAKE(0xffff, 5, 0)
420
421
422/** PDM Device Flags.
423 * @{ */
424/** This flag is used to indicate that the device has a R0 component. */
425#define PDM_DEVREG_FLAGS_R0 UINT32_C(0x00000001)
426/** Requires the ring-0 component, ignore configuration values. */
427#define PDM_DEVREG_FLAGS_REQUIRE_R0 UINT32_C(0x00000002)
428/** Requires the ring-0 component, ignore configuration values. */
429#define PDM_DEVREG_FLAGS_OPT_IN_R0 UINT32_C(0x00000004)
430
431/** This flag is used to indicate that the device has a RC component. */
432#define PDM_DEVREG_FLAGS_RC UINT32_C(0x00000010)
433/** Requires the raw-mode component, ignore configuration values. */
434#define PDM_DEVREG_FLAGS_REQUIRE_RC UINT32_C(0x00000020)
435/** Requires the raw-mode component, ignore configuration values. */
436#define PDM_DEVREG_FLAGS_OPT_IN_RC UINT32_C(0x00000040)
437
438/** Convenience: PDM_DEVREG_FLAGS_R0 + PDM_DEVREG_FLAGS_RC */
439#define PDM_DEVREG_FLAGS_RZ (PDM_DEVREG_FLAGS_R0 | PDM_DEVREG_FLAGS_RC)
440
441/** @def PDM_DEVREG_FLAGS_HOST_BITS_DEFAULT
442 * The bit count for the current host.
443 * @note Superfluous, but still around for hysterical raisins. */
444#if HC_ARCH_BITS == 32
445# define PDM_DEVREG_FLAGS_HOST_BITS_DEFAULT UINT32_C(0x00000100)
446#elif HC_ARCH_BITS == 64
447# define PDM_DEVREG_FLAGS_HOST_BITS_DEFAULT UINT32_C(0x00000200)
448#else
449# error Unsupported HC_ARCH_BITS value.
450#endif
451/** The host bit count mask. */
452#define PDM_DEVREG_FLAGS_HOST_BITS_MASK UINT32_C(0x00000300)
453
454/** The device support only 32-bit guests. */
455#define PDM_DEVREG_FLAGS_GUEST_BITS_32 UINT32_C(0x00001000)
456/** The device support only 64-bit guests. */
457#define PDM_DEVREG_FLAGS_GUEST_BITS_64 UINT32_C(0x00002000)
458/** The device support both 32-bit & 64-bit guests. */
459#define PDM_DEVREG_FLAGS_GUEST_BITS_32_64 UINT32_C(0x00003000)
460/** @def PDM_DEVREG_FLAGS_GUEST_BITS_DEFAULT
461 * The guest bit count for the current compilation. */
462#if GC_ARCH_BITS == 32
463# define PDM_DEVREG_FLAGS_GUEST_BITS_DEFAULT PDM_DEVREG_FLAGS_GUEST_BITS_32
464#elif GC_ARCH_BITS == 64
465# define PDM_DEVREG_FLAGS_GUEST_BITS_DEFAULT PDM_DEVREG_FLAGS_GUEST_BITS_32_64
466#else
467# error Unsupported GC_ARCH_BITS value.
468#endif
469/** The guest bit count mask. */
470#define PDM_DEVREG_FLAGS_GUEST_BITS_MASK UINT32_C(0x00003000)
471
472/** A convenience. */
473#define PDM_DEVREG_FLAGS_DEFAULT_BITS (PDM_DEVREG_FLAGS_GUEST_BITS_DEFAULT | PDM_DEVREG_FLAGS_HOST_BITS_DEFAULT)
474
475/** Indicates that the device needs to be notified before the drivers when suspending. */
476#define PDM_DEVREG_FLAGS_FIRST_SUSPEND_NOTIFICATION UINT32_C(0x00010000)
477/** Indicates that the device needs to be notified before the drivers when powering off. */
478#define PDM_DEVREG_FLAGS_FIRST_POWEROFF_NOTIFICATION UINT32_C(0x00020000)
479/** Indicates that the device needs to be notified before the drivers when resetting. */
480#define PDM_DEVREG_FLAGS_FIRST_RESET_NOTIFICATION UINT32_C(0x00040000)
481
482/** This flag is used to indicate that the device has been converted to the
483 * new device style. */
484#define PDM_DEVREG_FLAGS_NEW_STYLE UINT32_C(0x80000000)
485
486/** @} */
487
488
489/** PDM Device Classes.
490 * The order is important, lower bit earlier instantiation.
491 * @{ */
492/** Architecture device. */
493#define PDM_DEVREG_CLASS_ARCH RT_BIT(0)
494/** Architecture BIOS device. */
495#define PDM_DEVREG_CLASS_ARCH_BIOS RT_BIT(1)
496/** PCI bus brigde. */
497#define PDM_DEVREG_CLASS_BUS_PCI RT_BIT(2)
498/** PCI built-in device (e.g. PCI root complex devices). */
499#define PDM_DEVREG_CLASS_PCI_BUILTIN RT_BIT(3)
500/** Input device (mouse, keyboard, joystick, HID, ...). */
501#define PDM_DEVREG_CLASS_INPUT RT_BIT(4)
502/** Interrupt controller (PIC). */
503#define PDM_DEVREG_CLASS_PIC RT_BIT(5)
504/** Interval controoler (PIT). */
505#define PDM_DEVREG_CLASS_PIT RT_BIT(6)
506/** RTC/CMOS. */
507#define PDM_DEVREG_CLASS_RTC RT_BIT(7)
508/** DMA controller. */
509#define PDM_DEVREG_CLASS_DMA RT_BIT(8)
510/** VMM Device. */
511#define PDM_DEVREG_CLASS_VMM_DEV RT_BIT(9)
512/** Graphics device, like VGA. */
513#define PDM_DEVREG_CLASS_GRAPHICS RT_BIT(10)
514/** Storage controller device. */
515#define PDM_DEVREG_CLASS_STORAGE RT_BIT(11)
516/** Network interface controller. */
517#define PDM_DEVREG_CLASS_NETWORK RT_BIT(12)
518/** Audio. */
519#define PDM_DEVREG_CLASS_AUDIO RT_BIT(13)
520/** USB HIC. */
521#define PDM_DEVREG_CLASS_BUS_USB RT_BIT(14)
522/** ACPI. */
523#define PDM_DEVREG_CLASS_ACPI RT_BIT(15)
524/** Serial controller device. */
525#define PDM_DEVREG_CLASS_SERIAL RT_BIT(16)
526/** Parallel controller device */
527#define PDM_DEVREG_CLASS_PARALLEL RT_BIT(17)
528/** Host PCI pass-through device */
529#define PDM_DEVREG_CLASS_HOST_DEV RT_BIT(18)
530/** Misc devices (always last). */
531#define PDM_DEVREG_CLASS_MISC RT_BIT(31)
532/** @} */
533
534
535/**
536 * PDM Device Registration Structure, ring-0.
537 *
538 * This structure is used when registering a device from VBoxInitDevices() in HC
539 * Ring-0. PDM will continue use till the VM is terminated.
540 */
541typedef struct PDMDEVREGR0
542{
543 /** Structure version. PDM_DEVREGR0_VERSION defines the current version. */
544 uint32_t u32Version;
545 /** Reserved, must be zero. */
546 uint32_t uReserved0;
547 /** Device name, must match the ring-3 one. */
548 char szName[32];
549 /** Flags, combination of the PDM_DEVREG_FLAGS_* \#defines. */
550 uint32_t fFlags;
551 /** Device class(es), combination of the PDM_DEVREG_CLASS_* \#defines. */
552 uint32_t fClass;
553 /** Maximum number of instances (per VM). */
554 uint32_t cMaxInstances;
555 /** The shared data structure version number. */
556 uint32_t uSharedVersion;
557 /** Size of the instance data. */
558 uint32_t cbInstanceShared;
559 /** Size of the ring-0 instance data. */
560 uint32_t cbInstanceCC;
561 /** Size of the raw-mode instance data. */
562 uint32_t cbInstanceRC;
563 /** Max number of PCI devices. */
564 uint16_t cMaxPciDevices;
565 /** Max number of MSI-X vectors in any of the PCI devices. */
566 uint16_t cMaxMsixVectors;
567 /** The description of the device. The UTF-8 string pointed to shall, like this structure,
568 * remain unchanged from registration till VM destruction. */
569 const char *pszDescription;
570
571 /**
572 * Early construction callback (optional).
573 *
574 * This is called right after the device instance structure has been allocated
575 * and before the ring-3 constructor gets called.
576 *
577 * @returns VBox status code.
578 * @param pDevIns The device instance data.
579 * @note The destructure is always called, regardless of the return status.
580 */
581 DECLR0CALLBACKMEMBER(int, pfnEarlyConstruct, (PPDMDEVINS pDevIns));
582
583 /**
584 * Regular construction callback (optional).
585 *
586 * This is called after (or during) the ring-3 constructor.
587 *
588 * @returns VBox status code.
589 * @param pDevIns The device instance data.
590 * @note The destructure is always called, regardless of the return status.
591 */
592 DECLR0CALLBACKMEMBER(int, pfnConstruct, (PPDMDEVINS pDevIns));
593
594 /**
595 * Destructor (optional).
596 *
597 * This is called after the ring-3 destruction. This is not called if ring-3
598 * fails to trigger it (e.g. process is killed or crashes).
599 *
600 * @param pDevIns The device instance data.
601 */
602 DECLR0CALLBACKMEMBER(void, pfnDestruct, (PPDMDEVINS pDevIns));
603
604 /**
605 * Final destructor (optional).
606 *
607 * This is called right before the memory is freed, which happens when the
608 * VM/GVM object is destroyed. This is always called.
609 *
610 * @param pDevIns The device instance data.
611 */
612 DECLR0CALLBACKMEMBER(void, pfnFinalDestruct, (PPDMDEVINS pDevIns));
613
614 /**
615 * Generic request handler (optional).
616 *
617 * @param pDevIns The device instance data.
618 * @param uReq Device specific request.
619 * @param uArg Request argument.
620 */
621 DECLR0CALLBACKMEMBER(int, pfnRequest, (PPDMDEVINS pDevIns, uint32_t uReq, uint64_t uArg));
622
623 /** @name Reserved for future extensions, must be zero.
624 * @{ */
625 DECLR0CALLBACKMEMBER(int, pfnReserved0, (PPDMDEVINS pDevIns));
626 DECLR0CALLBACKMEMBER(int, pfnReserved1, (PPDMDEVINS pDevIns));
627 DECLR0CALLBACKMEMBER(int, pfnReserved2, (PPDMDEVINS pDevIns));
628 DECLR0CALLBACKMEMBER(int, pfnReserved3, (PPDMDEVINS pDevIns));
629 DECLR0CALLBACKMEMBER(int, pfnReserved4, (PPDMDEVINS pDevIns));
630 DECLR0CALLBACKMEMBER(int, pfnReserved5, (PPDMDEVINS pDevIns));
631 DECLR0CALLBACKMEMBER(int, pfnReserved6, (PPDMDEVINS pDevIns));
632 DECLR0CALLBACKMEMBER(int, pfnReserved7, (PPDMDEVINS pDevIns));
633 /** @} */
634
635 /** Initialization safty marker. */
636 uint32_t u32VersionEnd;
637} PDMDEVREGR0;
638/** Pointer to a ring-0 PDM device registration structure. */
639typedef PDMDEVREGR0 *PPDMDEVREGR0;
640/** Pointer to a const ring-0 PDM device registration structure. */
641typedef PDMDEVREGR0 const *PCPDMDEVREGR0;
642/** Current DEVREGR0 version number. */
643#define PDM_DEVREGR0_VERSION PDM_VERSION_MAKE(0xff80, 2, 0)
644
645
646/**
647 * PDM Device Registration Structure, raw-mode
648 *
649 * At the moment, this structure is mostly here to match the other two contexts.
650 */
651typedef struct PDMDEVREGRC
652{
653 /** Structure version. PDM_DEVREGRC_VERSION defines the current version. */
654 uint32_t u32Version;
655 /** Reserved, must be zero. */
656 uint32_t uReserved0;
657 /** Device name, must match the ring-3 one. */
658 char szName[32];
659 /** Flags, combination of the PDM_DEVREG_FLAGS_* \#defines. */
660 uint32_t fFlags;
661 /** Device class(es), combination of the PDM_DEVREG_CLASS_* \#defines. */
662 uint32_t fClass;
663 /** Maximum number of instances (per VM). */
664 uint32_t cMaxInstances;
665 /** The shared data structure version number. */
666 uint32_t uSharedVersion;
667 /** Size of the instance data. */
668 uint32_t cbInstanceShared;
669 /** Size of the ring-0 instance data. */
670 uint32_t cbInstanceCC;
671 /** Size of the raw-mode instance data. */
672 uint32_t cbInstanceRC;
673 /** Max number of PCI devices. */
674 uint16_t cMaxPciDevices;
675 /** Max number of MSI-X vectors in any of the PCI devices. */
676 uint16_t cMaxMsixVectors;
677 /** The description of the device. The UTF-8 string pointed to shall, like this structure,
678 * remain unchanged from registration till VM destruction. */
679 const char *pszDescription;
680
681 /**
682 * Constructor callback.
683 *
684 * This is called much later than both the ring-0 and ring-3 constructors, since
685 * raw-mode v2 require a working VMM to run actual code.
686 *
687 * @returns VBox status code.
688 * @param pDevIns The device instance data.
689 * @note The destructure is always called, regardless of the return status.
690 */
691 DECLRGCALLBACKMEMBER(int, pfnConstruct, (PPDMDEVINS pDevIns));
692
693 /** @name Reserved for future extensions, must be zero.
694 * @{ */
695 DECLRCCALLBACKMEMBER(int, pfnReserved0, (PPDMDEVINS pDevIns));
696 DECLRCCALLBACKMEMBER(int, pfnReserved1, (PPDMDEVINS pDevIns));
697 DECLRCCALLBACKMEMBER(int, pfnReserved2, (PPDMDEVINS pDevIns));
698 DECLRCCALLBACKMEMBER(int, pfnReserved3, (PPDMDEVINS pDevIns));
699 DECLRCCALLBACKMEMBER(int, pfnReserved4, (PPDMDEVINS pDevIns));
700 DECLRCCALLBACKMEMBER(int, pfnReserved5, (PPDMDEVINS pDevIns));
701 DECLRCCALLBACKMEMBER(int, pfnReserved6, (PPDMDEVINS pDevIns));
702 DECLRCCALLBACKMEMBER(int, pfnReserved7, (PPDMDEVINS pDevIns));
703 /** @} */
704
705 /** Initialization safty marker. */
706 uint32_t u32VersionEnd;
707} PDMDEVREGRC;
708/** Pointer to a raw-mode PDM device registration structure. */
709typedef PDMDEVREGRC *PPDMDEVREGRC;
710/** Pointer to a const raw-mode PDM device registration structure. */
711typedef PDMDEVREGRC const *PCPDMDEVREGRC;
712/** Current DEVREGRC version number. */
713#define PDM_DEVREGRC_VERSION PDM_VERSION_MAKE(0xff81, 2, 0)
714
715
716
717/** @def PDM_DEVREG_VERSION
718 * Current DEVREG version number. */
719/** @typedef PDMDEVREGR3
720 * A current context PDM device registration structure. */
721/** @typedef PPDMDEVREGR3
722 * Pointer to a current context PDM device registration structure. */
723/** @typedef PCPDMDEVREGR3
724 * Pointer to a const current context PDM device registration structure. */
725#if defined(IN_RING3) || defined(DOXYGEN_RUNNING)
726# define PDM_DEVREG_VERSION PDM_DEVREGR3_VERSION
727typedef PDMDEVREGR3 PDMDEVREG;
728typedef PPDMDEVREGR3 PPDMDEVREG;
729typedef PCPDMDEVREGR3 PCPDMDEVREG;
730#elif defined(IN_RING0)
731# define PDM_DEVREG_VERSION PDM_DEVREGR0_VERSION
732typedef PDMDEVREGR0 PDMDEVREG;
733typedef PPDMDEVREGR0 PPDMDEVREG;
734typedef PCPDMDEVREGR0 PCPDMDEVREG;
735#elif defined(IN_RC)
736# define PDM_DEVREG_VERSION PDM_DEVREGRC_VERSION
737typedef PDMDEVREGRC PDMDEVREG;
738typedef PPDMDEVREGRC PPDMDEVREG;
739typedef PCPDMDEVREGRC PCPDMDEVREG;
740#else
741# error "Not IN_RING3, IN_RING0 or IN_RC"
742#endif
743
744
745/**
746 * Device registrations for ring-0 modules.
747 *
748 * This structure is used directly and must therefore reside in persistent
749 * memory (i.e. the data section).
750 */
751typedef struct PDMDEVMODREGR0
752{
753 /** The structure version (PDM_DEVMODREGR0_VERSION). */
754 uint32_t u32Version;
755 /** Number of devices in the array papDevRegs points to. */
756 uint32_t cDevRegs;
757 /** Pointer to device registration structures. */
758 PCPDMDEVREGR0 *papDevRegs;
759 /** The ring-0 module handle - PDM internal, fingers off. */
760 void *hMod;
761 /** List entry - PDM internal, fingers off. */
762 RTLISTNODE ListEntry;
763} PDMDEVMODREGR0;
764/** Pointer to device registriations for a ring-0 module. */
765typedef PDMDEVMODREGR0 *PPDMDEVMODREGR0;
766/** Current PDMDEVMODREGR0 version number. */
767#define PDM_DEVMODREGR0_VERSION PDM_VERSION_MAKE(0xff85, 1, 0)
768
769
770/** @name IRQ Level for use with the *SetIrq APIs.
771 * @{
772 */
773/** Assert the IRQ (can assume value 1). */
774#define PDM_IRQ_LEVEL_HIGH RT_BIT(0)
775/** Deassert the IRQ (can assume value 0). */
776#define PDM_IRQ_LEVEL_LOW 0
777/** flip-flop - deassert and then assert the IRQ again immediately. */
778#define PDM_IRQ_LEVEL_FLIP_FLOP (RT_BIT(1) | PDM_IRQ_LEVEL_HIGH)
779/** @} */
780
781/**
782 * Registration record for MSI/MSI-X emulation.
783 */
784typedef struct PDMMSIREG
785{
786 /** Number of MSI interrupt vectors, 0 if MSI not supported */
787 uint16_t cMsiVectors;
788 /** Offset of MSI capability */
789 uint8_t iMsiCapOffset;
790 /** Offset of next capability to MSI */
791 uint8_t iMsiNextOffset;
792 /** If we support 64-bit MSI addressing */
793 bool fMsi64bit;
794 /** If we do not support per-vector masking */
795 bool fMsiNoMasking;
796
797 /** Number of MSI-X interrupt vectors, 0 if MSI-X not supported */
798 uint16_t cMsixVectors;
799 /** Offset of MSI-X capability */
800 uint8_t iMsixCapOffset;
801 /** Offset of next capability to MSI-X */
802 uint8_t iMsixNextOffset;
803 /** Value of PCI BAR (base addresss register) assigned by device for MSI-X page access */
804 uint8_t iMsixBar;
805} PDMMSIREG;
806typedef PDMMSIREG *PPDMMSIREG;
807
808/**
809 * PCI Bus registration structure.
810 * All the callbacks, except the PCIBIOS hack, are working on PCI devices.
811 */
812typedef struct PDMPCIBUSREGR3
813{
814 /** Structure version number. PDM_PCIBUSREGR3_VERSION defines the current version. */
815 uint32_t u32Version;
816
817 /**
818 * Registers the device with the default PCI bus.
819 *
820 * @returns VBox status code.
821 * @param pDevIns Device instance of the PCI Bus.
822 * @param pPciDev The PCI device structure.
823 * @param fFlags Reserved for future use, PDMPCIDEVREG_F_MBZ.
824 * @param uPciDevNo PDMPCIDEVREG_DEV_NO_FIRST_UNUSED, or a specific
825 * device number (0-31).
826 * @param uPciFunNo PDMPCIDEVREG_FUN_NO_FIRST_UNUSED, or a specific
827 * function number (0-7).
828 * @param pszName Device name (static but not unique).
829 *
830 * @remarks Caller enters the PDM critical section.
831 */
832 DECLR3CALLBACKMEMBER(int, pfnRegisterR3,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t fFlags,
833 uint8_t uPciDevNo, uint8_t uPciFunNo, const char *pszName));
834
835 /**
836 * Initialize MSI or MSI-X emulation support in a PCI device.
837 *
838 * This cannot handle all corner cases of the MSI/MSI-X spec, but for the
839 * vast majority of device emulation it covers everything necessary. It's
840 * fully automatic, taking care of all BAR and config space requirements,
841 * and interrupt delivery is done using PDMDevHlpPCISetIrq and friends.
842 * When MSI/MSI-X is enabled then the iIrq parameter is redefined to take
843 * the vector number (otherwise it has the usual INTA-D meaning for PCI).
844 *
845 * A device not using this can still offer MSI/MSI-X. In this case it's
846 * completely up to the device (in the MSI-X case) to create/register the
847 * necessary MMIO BAR, handle all config space/BAR updating and take care
848 * of delivering the interrupts appropriately.
849 *
850 * @returns VBox status code.
851 * @param pDevIns Device instance of the PCI Bus.
852 * @param pPciDev The PCI device structure.
853 * @param pMsiReg MSI emulation registration structure
854 * @remarks Caller enters the PDM critical section.
855 */
856 DECLR3CALLBACKMEMBER(int, pfnRegisterMsiR3,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, PPDMMSIREG pMsiReg));
857
858 /**
859 * Registers a I/O region (memory mapped or I/O ports) for a PCI device.
860 *
861 * @returns VBox status code.
862 * @param pDevIns Device instance of the PCI Bus.
863 * @param pPciDev The PCI device structure.
864 * @param iRegion The region number.
865 * @param cbRegion Size of the region.
866 * @param enmType PCI_ADDRESS_SPACE_MEM, PCI_ADDRESS_SPACE_IO or
867 * PCI_ADDRESS_SPACE_MEM_PREFETCH, optionally with
868 * PCI_ADDRESS_SPACE_BAR64 or'ed in.
869 * @param fFlags PDMPCIDEV_IORGN_F_XXX.
870 * @param hHandle An I/O port, MMIO or MMIO2 handle according to
871 * @a fFlags, UINT64_MAX if no handle is passed
872 * (old style).
873 * @param pfnMapUnmap Callback for doing the mapping. Optional if a handle
874 * is given.
875 * @remarks Caller enters the PDM critical section.
876 */
877 DECLR3CALLBACKMEMBER(int, pfnIORegionRegisterR3,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion,
878 RTGCPHYS cbRegion, PCIADDRESSSPACE enmType, uint32_t fFlags,
879 uint64_t hHandle, PFNPCIIOREGIONMAP pfnMapUnmap));
880
881 /**
882 * Register PCI configuration space read/write intercept callbacks.
883 *
884 * @param pDevIns Device instance of the PCI Bus.
885 * @param pPciDev The PCI device structure.
886 * @param pfnRead Pointer to the user defined PCI config read function.
887 * @param pfnWrite Pointer to the user defined PCI config write function.
888 * to call default PCI config write function. Can be NULL.
889 * @remarks Caller enters the PDM critical section.
890 * @thread EMT
891 */
892 DECLR3CALLBACKMEMBER(void, pfnInterceptConfigAccesses,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev,
893 PFNPCICONFIGREAD pfnRead, PFNPCICONFIGWRITE pfnWrite));
894
895 /**
896 * Perform a PCI configuration space write, bypassing interception.
897 *
898 * This is for devices that make use of PDMDevHlpPCIInterceptConfigAccesses().
899 *
900 * @returns Strict VBox status code (mainly DBGFSTOP).
901 * @param pDevIns Device instance of the PCI Bus.
902 * @param pPciDev The PCI device which config space is being read.
903 * @param uAddress The config space address.
904 * @param cb The size of the read: 1, 2 or 4 bytes.
905 * @param u32Value The value to write.
906 * @note The caller (PDM) does not enter the PDM critsect, but it is possible
907 * that the (root) bus will have done that already.
908 */
909 DECLR3CALLBACKMEMBER(VBOXSTRICTRC, pfnConfigWrite,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev,
910 uint32_t uAddress, unsigned cb, uint32_t u32Value));
911
912 /**
913 * Perform a PCI configuration space read, bypassing interception.
914 *
915 * This is for devices that make use of PDMDevHlpPCIInterceptConfigAccesses().
916 *
917 * @returns Strict VBox status code (mainly DBGFSTOP).
918 * @param pDevIns Device instance of the PCI Bus.
919 * @param pPciDev The PCI device which config space is being read.
920 * @param uAddress The config space address.
921 * @param cb The size of the read: 1, 2 or 4 bytes.
922 * @param pu32Value Where to return the value.
923 * @note The caller (PDM) does not enter the PDM critsect, but it is possible
924 * that the (root) bus will have done that already.
925 */
926 DECLR3CALLBACKMEMBER(VBOXSTRICTRC, pfnConfigRead,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev,
927 uint32_t uAddress, unsigned cb, uint32_t *pu32Value));
928
929 /**
930 * Set the IRQ for a PCI device.
931 *
932 * @param pDevIns Device instance of the PCI Bus.
933 * @param pPciDev The PCI device structure.
934 * @param iIrq IRQ number to set.
935 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
936 * @param uTagSrc The IRQ tag and source (for tracing).
937 * @remarks Caller enters the PDM critical section.
938 */
939 DECLR3CALLBACKMEMBER(void, pfnSetIrqR3,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iIrq, int iLevel, uint32_t uTagSrc));
940
941 /** Marks the end of the structure with PDM_PCIBUSREGR3_VERSION. */
942 uint32_t u32EndVersion;
943} PDMPCIBUSREGR3;
944/** Pointer to a PCI bus registration structure. */
945typedef PDMPCIBUSREGR3 *PPDMPCIBUSREGR3;
946/** Current PDMPCIBUSREGR3 version number. */
947#define PDM_PCIBUSREGR3_VERSION PDM_VERSION_MAKE(0xff86, 2, 0)
948
949/**
950 * PCI Bus registration structure for ring-0.
951 */
952typedef struct PDMPCIBUSREGR0
953{
954 /** Structure version number. PDM_PCIBUSREGR0_VERSION defines the current version. */
955 uint32_t u32Version;
956 /** The PCI bus number (from ring-3 registration). */
957 uint32_t iBus;
958 /**
959 * Set the IRQ for a PCI device.
960 *
961 * @param pDevIns Device instance of the PCI Bus.
962 * @param pPciDev The PCI device structure.
963 * @param iIrq IRQ number to set.
964 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
965 * @param uTagSrc The IRQ tag and source (for tracing).
966 * @remarks Caller enters the PDM critical section.
967 */
968 DECLR0CALLBACKMEMBER(void, pfnSetIrq,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iIrq, int iLevel, uint32_t uTagSrc));
969 /** Marks the end of the structure with PDM_PCIBUSREGR0_VERSION. */
970 uint32_t u32EndVersion;
971} PDMPCIBUSREGR0;
972/** Pointer to a PCI bus ring-0 registration structure. */
973typedef PDMPCIBUSREGR0 *PPDMPCIBUSREGR0;
974/** Current PDMPCIBUSREGR0 version number. */
975#define PDM_PCIBUSREGR0_VERSION PDM_VERSION_MAKE(0xff87, 1, 0)
976
977/**
978 * PCI Bus registration structure for raw-mode.
979 */
980typedef struct PDMPCIBUSREGRC
981{
982 /** Structure version number. PDM_PCIBUSREGRC_VERSION defines the current version. */
983 uint32_t u32Version;
984 /** The PCI bus number (from ring-3 registration). */
985 uint32_t iBus;
986 /**
987 * Set the IRQ for a PCI device.
988 *
989 * @param pDevIns Device instance of the PCI Bus.
990 * @param pPciDev The PCI device structure.
991 * @param iIrq IRQ number to set.
992 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
993 * @param uTagSrc The IRQ tag and source (for tracing).
994 * @remarks Caller enters the PDM critical section.
995 */
996 DECLRCCALLBACKMEMBER(void, pfnSetIrq,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iIrq, int iLevel, uint32_t uTagSrc));
997 /** Marks the end of the structure with PDM_PCIBUSREGRC_VERSION. */
998 uint32_t u32EndVersion;
999} PDMPCIBUSREGRC;
1000/** Pointer to a PCI bus raw-mode registration structure. */
1001typedef PDMPCIBUSREGRC *PPDMPCIBUSREGRC;
1002/** Current PDMPCIBUSREGRC version number. */
1003#define PDM_PCIBUSREGRC_VERSION PDM_VERSION_MAKE(0xff88, 1, 0)
1004
1005/** PCI bus registration structure for the current context. */
1006typedef CTX_SUFF(PDMPCIBUSREG) PDMPCIBUSREGCC;
1007/** Pointer to a PCI bus registration structure for the current context. */
1008typedef CTX_SUFF(PPDMPCIBUSREG) PPDMPCIBUSREGCC;
1009/** PCI bus registration structure version for the current context. */
1010#define PDM_PCIBUSREGCC_VERSION CTX_MID(PDM_PCIBUSREG,_VERSION)
1011
1012
1013/**
1014 * PCI Bus RC helpers.
1015 */
1016typedef struct PDMPCIHLPRC
1017{
1018 /** Structure version. PDM_PCIHLPRC_VERSION defines the current version. */
1019 uint32_t u32Version;
1020
1021 /**
1022 * Set an ISA IRQ.
1023 *
1024 * @param pDevIns PCI device instance.
1025 * @param iIrq IRQ number to set.
1026 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
1027 * @param uTagSrc The IRQ tag and source (for tracing).
1028 * @thread EMT only.
1029 */
1030 DECLRCCALLBACKMEMBER(void, pfnIsaSetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel, uint32_t uTagSrc));
1031
1032 /**
1033 * Set an I/O-APIC IRQ.
1034 *
1035 * @param pDevIns PCI device instance.
1036 * @param uBusDevFn The bus:device:function of the device initiating the
1037 * IRQ. Pass NIL_PCIBDF when it's not a PCI device or
1038 * interrupt.
1039 * @param iIrq IRQ number to set.
1040 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
1041 * @param uTagSrc The IRQ tag and source (for tracing).
1042 * @thread EMT only.
1043 */
1044 DECLRCCALLBACKMEMBER(void, pfnIoApicSetIrq,(PPDMDEVINS pDevIns, PCIBDF uBusDevFn, int iIrq, int iLevel, uint32_t uTagSrc));
1045
1046 /**
1047 * Send an MSI.
1048 *
1049 * @param pDevIns PCI device instance.
1050 * @param uBusDevFn The bus:device:function of the device initiating the
1051 * MSI. Cannot be NIL_PCIBDF.
1052 * @param pMsi The MSI to send.
1053 * @param uTagSrc The IRQ tag and source (for tracing).
1054 * @thread EMT only.
1055 */
1056 DECLRCCALLBACKMEMBER(void, pfnIoApicSendMsi,(PPDMDEVINS pDevIns, PCIBDF uBusDevFn, PCMSIMSG pMsi, uint32_t uTagSrc));
1057
1058
1059 /**
1060 * Acquires the PDM lock.
1061 *
1062 * @returns VINF_SUCCESS on success.
1063 * @returns rc if we failed to acquire the lock.
1064 * @param pDevIns The PCI device instance.
1065 * @param rc What to return if we fail to acquire the lock.
1066 */
1067 DECLRCCALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
1068
1069 /**
1070 * Releases the PDM lock.
1071 *
1072 * @param pDevIns The PCI device instance.
1073 */
1074 DECLRCCALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
1075
1076 /**
1077 * Gets a bus by it's PDM ordinal (typically the parent bus).
1078 *
1079 * @returns Pointer to the device instance of the bus.
1080 * @param pDevIns The PCI bus device instance.
1081 * @param idxPdmBus The PDM ordinal value of the bus to get.
1082 */
1083 DECLRCCALLBACKMEMBER(PPDMDEVINS, pfnGetBusByNo,(PPDMDEVINS pDevIns, uint32_t idxPdmBus));
1084
1085 /** Just a safety precaution. */
1086 uint32_t u32TheEnd;
1087} PDMPCIHLPRC;
1088/** Pointer to PCI helpers. */
1089typedef RCPTRTYPE(PDMPCIHLPRC *) PPDMPCIHLPRC;
1090/** Pointer to const PCI helpers. */
1091typedef RCPTRTYPE(const PDMPCIHLPRC *) PCPDMPCIHLPRC;
1092
1093/** Current PDMPCIHLPRC version number. */
1094#define PDM_PCIHLPRC_VERSION PDM_VERSION_MAKE(0xfffd, 4, 0)
1095
1096
1097/**
1098 * PCI Bus R0 helpers.
1099 */
1100typedef struct PDMPCIHLPR0
1101{
1102 /** Structure version. PDM_PCIHLPR0_VERSION defines the current version. */
1103 uint32_t u32Version;
1104
1105 /**
1106 * Set an ISA IRQ.
1107 *
1108 * @param pDevIns PCI device instance.
1109 * @param iIrq IRQ number to set.
1110 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
1111 * @param uTagSrc The IRQ tag and source (for tracing).
1112 * @thread EMT only.
1113 */
1114 DECLR0CALLBACKMEMBER(void, pfnIsaSetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel, uint32_t uTagSrc));
1115
1116 /**
1117 * Set an I/O-APIC IRQ.
1118 *
1119 * @param pDevIns PCI device instance.
1120 * @param uBusDevFn The bus:device:function of the device initiating the
1121 * IRQ. Pass NIL_PCIBDF when it's not a PCI device or
1122 * interrupt.
1123 * @param iIrq IRQ number to set.
1124 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
1125 * @param uTagSrc The IRQ tag and source (for tracing).
1126 * @thread EMT only.
1127 */
1128 DECLR0CALLBACKMEMBER(void, pfnIoApicSetIrq,(PPDMDEVINS pDevIns, PCIBDF uBusDevFn, int iIrq, int iLevel, uint32_t uTagSrc));
1129
1130 /**
1131 * Send an MSI.
1132 *
1133 * @param pDevIns PCI device instance.
1134 * @param uBusDevFn The bus:device:function of the device initiating the
1135 * MSI. Cannot be NIL_PCIBDF.
1136 * @param pMsi The MSI to send.
1137 * @param uTagSrc The IRQ tag and source (for tracing).
1138 * @thread EMT only.
1139 */
1140 DECLR0CALLBACKMEMBER(void, pfnIoApicSendMsi,(PPDMDEVINS pDevIns, PCIBDF uBusDevFn, PCMSIMSG pMsi, uint32_t uTagSrc));
1141
1142 /**
1143 * Acquires the PDM lock.
1144 *
1145 * @returns VINF_SUCCESS on success.
1146 * @returns rc if we failed to acquire the lock.
1147 * @param pDevIns The PCI device instance.
1148 * @param rc What to return if we fail to acquire the lock.
1149 */
1150 DECLR0CALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
1151
1152 /**
1153 * Releases the PDM lock.
1154 *
1155 * @param pDevIns The PCI device instance.
1156 */
1157 DECLR0CALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
1158
1159 /**
1160 * Gets a bus by it's PDM ordinal (typically the parent bus).
1161 *
1162 * @returns Pointer to the device instance of the bus.
1163 * @param pDevIns The PCI bus device instance.
1164 * @param idxPdmBus The PDM ordinal value of the bus to get.
1165 */
1166 DECLR0CALLBACKMEMBER(PPDMDEVINS, pfnGetBusByNo,(PPDMDEVINS pDevIns, uint32_t idxPdmBus));
1167
1168 /** Just a safety precaution. */
1169 uint32_t u32TheEnd;
1170} PDMPCIHLPR0;
1171/** Pointer to PCI helpers. */
1172typedef R0PTRTYPE(PDMPCIHLPR0 *) PPDMPCIHLPR0;
1173/** Pointer to const PCI helpers. */
1174typedef R0PTRTYPE(const PDMPCIHLPR0 *) PCPDMPCIHLPR0;
1175
1176/** Current PDMPCIHLPR0 version number. */
1177#define PDM_PCIHLPR0_VERSION PDM_VERSION_MAKE(0xfffc, 6, 0)
1178
1179/**
1180 * PCI device helpers.
1181 */
1182typedef struct PDMPCIHLPR3
1183{
1184 /** Structure version. PDM_PCIHLPR3_VERSION defines the current version. */
1185 uint32_t u32Version;
1186
1187 /**
1188 * Set an ISA IRQ.
1189 *
1190 * @param pDevIns The PCI device instance.
1191 * @param iIrq IRQ number to set.
1192 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
1193 * @param uTagSrc The IRQ tag and source (for tracing).
1194 */
1195 DECLR3CALLBACKMEMBER(void, pfnIsaSetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel, uint32_t uTagSrc));
1196
1197 /**
1198 * Set an I/O-APIC IRQ.
1199 *
1200 * @param pDevIns The PCI device instance.
1201 * @param uBusDevFn The bus:device:function of the device initiating the
1202 * IRQ. Pass NIL_PCIBDF when it's not a PCI device or
1203 * interrupt.
1204 * @param iIrq IRQ number to set.
1205 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
1206 * @param uTagSrc The IRQ tag and source (for tracing).
1207 */
1208 DECLR3CALLBACKMEMBER(void, pfnIoApicSetIrq,(PPDMDEVINS pDevIns, PCIBDF uBusDevFn, int iIrq, int iLevel, uint32_t uTagSrc));
1209
1210 /**
1211 * Send an MSI.
1212 *
1213 * @param pDevIns PCI device instance.
1214 * @param uBusDevFn The bus:device:function of the device initiating the
1215 * MSI. Cannot be NIL_PCIBDF.
1216 * @param pMsi The MSI to send.
1217 * @param uTagSrc The IRQ tag and source (for tracing).
1218 */
1219 DECLR3CALLBACKMEMBER(void, pfnIoApicSendMsi,(PPDMDEVINS pDevIns, PCIBDF uBusDevFn, PCMSIMSG pMsi, uint32_t uTagSrc));
1220
1221 /**
1222 * Acquires the PDM lock.
1223 *
1224 * @returns VINF_SUCCESS on success.
1225 * @returns Fatal error on failure.
1226 * @param pDevIns The PCI device instance.
1227 * @param rc Dummy for making the interface identical to the RC and R0 versions.
1228 */
1229 DECLR3CALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
1230
1231 /**
1232 * Releases the PDM lock.
1233 *
1234 * @param pDevIns The PCI device instance.
1235 */
1236 DECLR3CALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
1237
1238 /**
1239 * Gets a bus by it's PDM ordinal (typically the parent bus).
1240 *
1241 * @returns Pointer to the device instance of the bus.
1242 * @param pDevIns The PCI bus device instance.
1243 * @param idxPdmBus The PDM ordinal value of the bus to get.
1244 */
1245 DECLR3CALLBACKMEMBER(PPDMDEVINS, pfnGetBusByNo,(PPDMDEVINS pDevIns, uint32_t idxPdmBus));
1246
1247 /** Just a safety precaution. */
1248 uint32_t u32TheEnd;
1249} PDMPCIHLPR3;
1250/** Pointer to PCI helpers. */
1251typedef R3PTRTYPE(PDMPCIHLPR3 *) PPDMPCIHLPR3;
1252/** Pointer to const PCI helpers. */
1253typedef R3PTRTYPE(const PDMPCIHLPR3 *) PCPDMPCIHLPR3;
1254
1255/** Current PDMPCIHLPR3 version number. */
1256#define PDM_PCIHLPR3_VERSION PDM_VERSION_MAKE(0xfffb, 5, 0)
1257
1258
1259/**
1260 * IOMMU registration structure for ring-0.
1261 */
1262typedef struct PDMIOMMUREGR0
1263{
1264 /** Structure version number. PDM_IOMMUREG_VERSION defines the current
1265 * version. */
1266 uint32_t u32Version;
1267 /** Index into the PDM IOMMU array (PDM::aIommus) from ring-3. */
1268 uint32_t idxIommu;
1269
1270 /**
1271 * Performs a physical memory read transaction through the IOMMU.
1272 *
1273 * @returns VBox status code.
1274 * @param pDevIns The IOMMU device instance.
1275 * @param uDevId The device identifier (bus, device, function).
1276 * @param uIova The I/O virtual address being read.
1277 * @param cbRead The number of bytes being read.
1278 * @param pGCPhysSpa Where to store the translated system physical address.
1279 *
1280 * @thread Any.
1281 */
1282 DECLR0CALLBACKMEMBER(int, pfnMemRead,(PPDMDEVINS pDevIns, uint16_t uDevId, uint64_t uIova, size_t cbRead,
1283 PRTGCPHYS pGCPhysSpa));
1284
1285 /**
1286 * Performs a physical memory write transaction through the IOMMU.
1287 *
1288 * @returns VBox status code.
1289 * @param pDevIns The IOMMU device instance.
1290 * @param uDevId The device identifier (bus, device, function).
1291 * @param uIova The I/O virtual address being written.
1292 * @param cbRead The number of bytes being written.
1293 * @param pGCPhysSpa Where to store the translated system physical address.
1294 *
1295 * @thread Any.
1296 */
1297 DECLR0CALLBACKMEMBER(int, pfnMemWrite,(PPDMDEVINS pDevIns, uint16_t uDevId, uint64_t uIova, size_t cbWrite,
1298 PRTGCPHYS pGCPhysSpa));
1299
1300 /**
1301 * Performs an interrupt remap request through the IOMMU.
1302 *
1303 * @returns VBox status code.
1304 * @param pDevIns The IOMMU device instance.
1305 * @param uDevId The device identifier (bus, device, function).
1306 * @param pMsiIn The source MSI.
1307 * @param pMsiOut Where to store the remapped MSI.
1308 *
1309 * @thread Any.
1310 */
1311 DECLR0CALLBACKMEMBER(int, pfnMsiRemap,(PPDMDEVINS pDevIns, uint16_t uDevId, PCMSIMSG pMsiIn, PMSIMSG pMsiOut));
1312
1313 /** Just a safety precaution. */
1314 uint32_t u32TheEnd;
1315} PDMIOMMUREGR0;
1316/** Pointer to a IOMMU registration structure. */
1317typedef PDMIOMMUREGR0 *PPDMIOMMUREGR0;
1318
1319/** Current PDMIOMMUREG version number. */
1320#define PDM_IOMMUREGR0_VERSION PDM_VERSION_MAKE(0xff10, 1, 0)
1321
1322
1323/**
1324 * IOMMU registration structure for raw-mode.
1325 */
1326typedef struct PDMIOMMUREGRC
1327{
1328 /** Structure version number. PDM_IOMMUREG_VERSION defines the current
1329 * version. */
1330 uint32_t u32Version;
1331 /** Index into the PDM IOMMU array (PDM::aIommus) from ring-3. */
1332 uint32_t idxIommu;
1333
1334 /**
1335 * Performs a physical memory read transaction through the IOMMU.
1336 *
1337 * @returns VBox status code.
1338 * @param pDevIns The IOMMU device instance.
1339 * @param uDevId The device identifier (bus, device, function).
1340 * @param uIova The I/O virtual address being read.
1341 * @param cbRead The number of bytes being read.
1342 * @param pGCPhysSpa Where to store the translated system physical address.
1343 *
1344 * @thread Any.
1345 */
1346 DECLRCCALLBACKMEMBER(int, pfnMemRead,(PPDMDEVINS pDevIns, uint16_t uDevId, uint64_t uIova, size_t cbRead,
1347 PRTGCPHYS pGCPhysSpa));
1348
1349 /**
1350 * Performs a physical memory write transaction through the IOMMU.
1351 *
1352 * @returns VBox status code.
1353 * @param pDevIns The IOMMU device instance.
1354 * @param uDevId The device identifier (bus, device, function).
1355 * @param uIova The I/O virtual address being written.
1356 * @param cbRead The number of bytes being written.
1357 * @param pGCPhysSpa Where to store the translated system physical address.
1358 *
1359 * @thread Any.
1360 */
1361 DECLRCCALLBACKMEMBER(int, pfnMemWrite,(PPDMDEVINS pDevIns, uint16_t uDevId, uint64_t uIova, size_t cbWrite,
1362 PRTGCPHYS pGCPhysSpa));
1363
1364 /**
1365 * Performs an interrupt remap request through the IOMMU.
1366 *
1367 * @returns VBox status code.
1368 * @param pDevIns The IOMMU device instance.
1369 * @param uDevId The device identifier (bus, device, function).
1370 * @param pMsiIn The source MSI.
1371 * @param pMsiOut Where to store the remapped MSI.
1372 *
1373 * @thread Any.
1374 */
1375 DECLRCCALLBACKMEMBER(int, pfnMsiRemap,(PPDMDEVINS pDevIns, uint16_t uDevId, PCMSIMSG pMsiIn, PMSIMSG pMsiOut));
1376
1377 /** Just a safety precaution. */
1378 uint32_t u32TheEnd;
1379} PDMIOMMUREGRC;
1380/** Pointer to a IOMMU registration structure. */
1381typedef PDMIOMMUREGRC *PPDMIOMMUREGRC;
1382
1383/** Current PDMIOMMUREG version number. */
1384#define PDM_IOMMUREGRC_VERSION PDM_VERSION_MAKE(0xff11, 1, 0)
1385
1386
1387/**
1388 * IOMMU registration structure for ring-3.
1389 */
1390typedef struct PDMIOMMUREGR3
1391{
1392 /** Structure version number. PDM_IOMMUREG_VERSION defines the current
1393 * version. */
1394 uint32_t u32Version;
1395 /** Padding. */
1396 uint32_t uPadding0;
1397
1398 /**
1399 * Performs a physical memory read transaction through the IOMMU.
1400 *
1401 * @returns VBox status code.
1402 * @param pDevIns The IOMMU device instance.
1403 * @param uDevId The device identifier (bus, device, function).
1404 * @param uIova The I/O virtual address being read.
1405 * @param cbRead The number of bytes being read.
1406 * @param pGCPhysSpa Where to store the translated system physical address.
1407 *
1408 * @thread Any.
1409 */
1410 DECLR3CALLBACKMEMBER(int, pfnMemRead,(PPDMDEVINS pDevIns, uint16_t uDevId, uint64_t uIova, size_t cbRead,
1411 PRTGCPHYS pGCPhysSpa));
1412
1413 /**
1414 * Performs a physical memory write transaction through the IOMMU.
1415 *
1416 * @returns VBox status code.
1417 * @param pDevIns The IOMMU device instance.
1418 * @param uDevId The device identifier (bus, device, function).
1419 * @param uIova The I/O virtual address being written.
1420 * @param cbWrite The number of bytes being written.
1421 * @param pGCPhysSpa Where to store the translated system physical address.
1422 *
1423 * @thread Any.
1424 */
1425 DECLR3CALLBACKMEMBER(int, pfnMemWrite,(PPDMDEVINS pDevIns, uint16_t uDevId, uint64_t uIova, size_t cbWrite,
1426 PRTGCPHYS pGCPhysSpa));
1427
1428 /**
1429 * Performs an interrupt remap request through the IOMMU.
1430 *
1431 * @returns VBox status code.
1432 * @param pDevIns The IOMMU device instance.
1433 * @param uDevId The device identifier (bus, device, function).
1434 * @param pMsiIn The source MSI.
1435 * @param pMsiOut Where to store the remapped MSI.
1436 *
1437 * @thread Any.
1438 */
1439 DECLR3CALLBACKMEMBER(int, pfnMsiRemap,(PPDMDEVINS pDevIns, uint16_t uDevId, PCMSIMSG pMsiIn, PMSIMSG pMsiOut));
1440
1441 /** Just a safety precaution. */
1442 uint32_t u32TheEnd;
1443} PDMIOMMUREGR3;
1444/** Pointer to a IOMMU registration structure. */
1445typedef PDMIOMMUREGR3 *PPDMIOMMUREGR3;
1446
1447/** Current PDMIOMMUREG version number. */
1448#define PDM_IOMMUREGR3_VERSION PDM_VERSION_MAKE(0xff12, 1, 0)
1449
1450/** IOMMU registration structure for the current context. */
1451typedef CTX_SUFF(PDMIOMMUREG) PDMIOMMUREGCC;
1452/** Pointer to an IOMMU registration structure for the current context. */
1453typedef CTX_SUFF(PPDMIOMMUREG) PPDMIOMMUREGCC;
1454/** IOMMU registration structure version for the current context. */
1455#define PDM_IOMMUREGCC_VERSION CTX_MID(PDM_IOMMUREG,_VERSION)
1456
1457
1458/**
1459 * IOMMU helpers for ring-0.
1460 */
1461typedef struct PDMIOMMUHLPR0
1462{
1463 /** Structure version. PDM_IOMMUHLP_VERSION defines the current version. */
1464 uint32_t u32Version;
1465 /** Just a safety precaution. */
1466 uint32_t u32TheEnd;
1467} PDMIOMMUHLPR0;
1468/** Pointer to IOMMU helpers for ring-0. */
1469typedef PDMIOMMUHLPR0 *PPDMIOMMUHLPR0;
1470/** Pointer to const IOMMU helpers for ring-0. */
1471typedef const PDMIOMMUHLPR0 *PCPDMIOMMUHLPR0;
1472
1473/** Current PDMIOMMUHLPR0 version number. */
1474#define PDM_IOMMUHLPR0_VERSION PDM_VERSION_MAKE(0xff13, 1, 0)
1475
1476
1477/**
1478 * IOMMU helpers for raw-mode.
1479 */
1480typedef struct PDMIOMMUHLPRC
1481{
1482 /** Structure version. PDM_IOMMUHLP_VERSION defines the current version. */
1483 uint32_t u32Version;
1484 /** Just a safety precaution. */
1485 uint32_t u32TheEnd;
1486} PDMIOMMUHLPRC;
1487/** Pointer to IOMMU helpers for raw-mode. */
1488typedef PDMIOMMUHLPRC *PPDMIOMMUHLPRC;
1489/** Pointer to const IOMMU helpers for raw-mode. */
1490typedef const PDMIOMMUHLPRC *PCPDMIOMMUHLPRC;
1491
1492/** Current PDMIOMMUHLPRC version number. */
1493#define PDM_IOMMUHLPRC_VERSION PDM_VERSION_MAKE(0xff14, 1, 0)
1494
1495
1496/**
1497 * IOMMU helpers for ring-3.
1498 */
1499typedef struct PDMIOMMUHLPR3
1500{
1501 /** Structure version. PDM_IOMMUHLP_VERSION defines the current version. */
1502 uint32_t u32Version;
1503 /** Just a safety precaution. */
1504 uint32_t u32TheEnd;
1505} PDMIOMMUHLPR3;
1506/** Pointer to IOMMU helpers for raw-mode. */
1507typedef PDMIOMMUHLPR3 *PPDMIOMMUHLPR3;
1508/** Pointer to const IOMMU helpers for raw-mode. */
1509typedef const PDMIOMMUHLPR3 *PCPDMIOMMUHLPR3;
1510
1511/** Current PDMIOMMUHLPR3 version number. */
1512#define PDM_IOMMUHLPR3_VERSION PDM_VERSION_MAKE(0xff15, 1, 0)
1513
1514
1515/**
1516 * Programmable Interrupt Controller registration structure (all contexts).
1517 */
1518typedef struct PDMPICREG
1519{
1520 /** Structure version number. PDM_PICREG_VERSION defines the current version. */
1521 uint32_t u32Version;
1522
1523 /**
1524 * Set the an IRQ.
1525 *
1526 * @param pDevIns Device instance of the PIC.
1527 * @param iIrq IRQ number to set.
1528 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
1529 * @param uTagSrc The IRQ tag and source (for tracing).
1530 * @remarks Caller enters the PDM critical section.
1531 */
1532 DECLCALLBACKMEMBER(void, pfnSetIrq)(PPDMDEVINS pDevIns, int iIrq, int iLevel, uint32_t uTagSrc);
1533
1534 /**
1535 * Get a pending interrupt.
1536 *
1537 * @returns Pending interrupt number.
1538 * @param pDevIns Device instance of the PIC.
1539 * @param puTagSrc Where to return the IRQ tag and source.
1540 * @remarks Caller enters the PDM critical section.
1541 */
1542 DECLCALLBACKMEMBER(int, pfnGetInterrupt)(PPDMDEVINS pDevIns, uint32_t *puTagSrc);
1543
1544 /** Just a safety precaution. */
1545 uint32_t u32TheEnd;
1546} PDMPICREG;
1547/** Pointer to a PIC registration structure. */
1548typedef PDMPICREG *PPDMPICREG;
1549
1550/** Current PDMPICREG version number. */
1551#define PDM_PICREG_VERSION PDM_VERSION_MAKE(0xfffa, 3, 0)
1552
1553/**
1554 * PIC helpers, same in all contexts.
1555 */
1556typedef struct PDMPICHLP
1557{
1558 /** Structure version. PDM_PICHLP_VERSION defines the current version. */
1559 uint32_t u32Version;
1560
1561 /**
1562 * Set the interrupt force action flag.
1563 *
1564 * @param pDevIns Device instance of the PIC.
1565 */
1566 DECLCALLBACKMEMBER(void, pfnSetInterruptFF)(PPDMDEVINS pDevIns);
1567
1568 /**
1569 * Clear the interrupt force action flag.
1570 *
1571 * @param pDevIns Device instance of the PIC.
1572 */
1573 DECLCALLBACKMEMBER(void, pfnClearInterruptFF)(PPDMDEVINS pDevIns);
1574
1575 /**
1576 * Acquires the PDM lock.
1577 *
1578 * @returns VINF_SUCCESS on success.
1579 * @returns rc if we failed to acquire the lock.
1580 * @param pDevIns The PIC device instance.
1581 * @param rc What to return if we fail to acquire the lock.
1582 */
1583 DECLCALLBACKMEMBER(int, pfnLock)(PPDMDEVINS pDevIns, int rc);
1584
1585 /**
1586 * Releases the PDM lock.
1587 *
1588 * @param pDevIns The PIC device instance.
1589 */
1590 DECLCALLBACKMEMBER(void, pfnUnlock)(PPDMDEVINS pDevIns);
1591
1592 /** Just a safety precaution. */
1593 uint32_t u32TheEnd;
1594} PDMPICHLP;
1595/** Pointer to PIC helpers. */
1596typedef PDMPICHLP *PPDMPICHLP;
1597/** Pointer to const PIC helpers. */
1598typedef const PDMPICHLP *PCPDMPICHLP;
1599
1600/** Current PDMPICHLP version number. */
1601#define PDM_PICHLP_VERSION PDM_VERSION_MAKE(0xfff9, 3, 0)
1602
1603
1604/**
1605 * Firmware registration structure.
1606 */
1607typedef struct PDMFWREG
1608{
1609 /** Struct version+magic number (PDM_FWREG_VERSION). */
1610 uint32_t u32Version;
1611
1612 /**
1613 * Checks whether this is a hard or soft reset.
1614 *
1615 * The current definition of soft reset is what the PC BIOS does when CMOS[0xF]
1616 * is 5, 9 or 0xA.
1617 *
1618 * @returns true if hard reset, false if soft.
1619 * @param pDevIns Device instance of the firmware.
1620 * @param fFlags PDMRESET_F_XXX passed to the PDMDevHlpVMReset API.
1621 */
1622 DECLR3CALLBACKMEMBER(bool, pfnIsHardReset,(PPDMDEVINS pDevIns, uint32_t fFlags));
1623
1624 /** Just a safety precaution. */
1625 uint32_t u32TheEnd;
1626} PDMFWREG;
1627/** Pointer to a FW registration structure. */
1628typedef PDMFWREG *PPDMFWREG;
1629/** Pointer to a const FW registration structure. */
1630typedef PDMFWREG const *PCPDMFWREG;
1631
1632/** Current PDMFWREG version number. */
1633#define PDM_FWREG_VERSION PDM_VERSION_MAKE(0xffdd, 1, 0)
1634
1635/**
1636 * Firmware R3 helpers.
1637 */
1638typedef struct PDMFWHLPR3
1639{
1640 /** Structure version. PDM_FWHLP_VERSION defines the current version. */
1641 uint32_t u32Version;
1642
1643 /** Just a safety precaution. */
1644 uint32_t u32TheEnd;
1645} PDMFWHLPR3;
1646
1647/** Pointer to FW R3 helpers. */
1648typedef R3PTRTYPE(PDMFWHLPR3 *) PPDMFWHLPR3;
1649/** Pointer to const FW R3 helpers. */
1650typedef R3PTRTYPE(const PDMFWHLPR3 *) PCPDMFWHLPR3;
1651
1652/** Current PDMFWHLPR3 version number. */
1653#define PDM_FWHLPR3_VERSION PDM_VERSION_MAKE(0xffdb, 1, 0)
1654
1655
1656/**
1657 * APIC mode argument for apicR3SetCpuIdFeatureLevel.
1658 *
1659 * Also used in saved-states, CFGM don't change existing values.
1660 */
1661typedef enum PDMAPICMODE
1662{
1663 /** Invalid 0 entry. */
1664 PDMAPICMODE_INVALID = 0,
1665 /** No APIC. */
1666 PDMAPICMODE_NONE,
1667 /** Standard APIC (X86_CPUID_FEATURE_EDX_APIC). */
1668 PDMAPICMODE_APIC,
1669 /** Intel X2APIC (X86_CPUID_FEATURE_ECX_X2APIC). */
1670 PDMAPICMODE_X2APIC,
1671 /** The usual 32-bit paranoia. */
1672 PDMAPICMODE_32BIT_HACK = 0x7fffffff
1673} PDMAPICMODE;
1674
1675/**
1676 * APIC irq argument for pfnSetInterruptFF and pfnClearInterruptFF.
1677 */
1678typedef enum PDMAPICIRQ
1679{
1680 /** Invalid 0 entry. */
1681 PDMAPICIRQ_INVALID = 0,
1682 /** Normal hardware interrupt. */
1683 PDMAPICIRQ_HARDWARE,
1684 /** NMI. */
1685 PDMAPICIRQ_NMI,
1686 /** SMI. */
1687 PDMAPICIRQ_SMI,
1688 /** ExtINT (HW interrupt via PIC). */
1689 PDMAPICIRQ_EXTINT,
1690 /** Interrupt arrived, needs to be updated to the IRR. */
1691 PDMAPICIRQ_UPDATE_PENDING,
1692 /** The usual 32-bit paranoia. */
1693 PDMAPICIRQ_32BIT_HACK = 0x7fffffff
1694} PDMAPICIRQ;
1695
1696
1697/**
1698 * I/O APIC registration structure (all contexts).
1699 */
1700typedef struct PDMIOAPICREG
1701{
1702 /** Struct version+magic number (PDM_IOAPICREG_VERSION). */
1703 uint32_t u32Version;
1704
1705 /**
1706 * Set an IRQ.
1707 *
1708 * @param pDevIns Device instance of the I/O APIC.
1709 * @param uBusDevFn The bus:device:function of the device initiating the
1710 * IRQ. Can be NIL_PCIBDF.
1711 * @param iIrq IRQ number to set.
1712 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
1713 * @param uTagSrc The IRQ tag and source (for tracing).
1714 *
1715 * @remarks Caller enters the PDM critical section
1716 * Actually, as per 2018-07-21 this isn't true (bird).
1717 */
1718 DECLCALLBACKMEMBER(void, pfnSetIrq)(PPDMDEVINS pDevIns, PCIBDF uBusDevFn, int iIrq, int iLevel, uint32_t uTagSrc);
1719
1720 /**
1721 * Send a MSI.
1722 *
1723 * @param pDevIns Device instance of the I/O APIC.
1724 * @param uBusDevFn The bus:device:function of the device initiating the
1725 * MSI. Cannot be NIL_PCIBDF.
1726 * @param pMsi The MSI to send.
1727 * @param uTagSrc The IRQ tag and source (for tracing).
1728 *
1729 * @remarks Caller enters the PDM critical section
1730 * Actually, as per 2018-07-21 this isn't true (bird).
1731 */
1732 DECLCALLBACKMEMBER(void, pfnSendMsi)(PPDMDEVINS pDevIns, PCIBDF uBusDevFn, PCMSIMSG pMsi, uint32_t uTagSrc);
1733
1734 /**
1735 * Set the EOI for an interrupt vector.
1736 *
1737 * @returns Strict VBox status code - only the following informational status codes:
1738 * @retval VINF_IOM_R3_MMIO_WRITE if the I/O APIC lock is contenteded and we're in R0 or RC.
1739 * @retval VINF_SUCCESS
1740 *
1741 * @param pDevIns Device instance of the I/O APIC.
1742 * @param u8Vector The vector.
1743 *
1744 * @remarks Caller enters the PDM critical section
1745 * Actually, as per 2018-07-21 this isn't true (bird).
1746 */
1747 DECLCALLBACKMEMBER(VBOXSTRICTRC, pfnSetEoi)(PPDMDEVINS pDevIns, uint8_t u8Vector);
1748
1749 /** Just a safety precaution. */
1750 uint32_t u32TheEnd;
1751} PDMIOAPICREG;
1752/** Pointer to an APIC registration structure. */
1753typedef PDMIOAPICREG *PPDMIOAPICREG;
1754
1755/** Current PDMAPICREG version number. */
1756#define PDM_IOAPICREG_VERSION PDM_VERSION_MAKE(0xfff2, 7, 0)
1757
1758
1759/**
1760 * IOAPIC helpers, same in all contexts.
1761 */
1762typedef struct PDMIOAPICHLP
1763{
1764 /** Structure version. PDM_IOAPICHLP_VERSION defines the current version. */
1765 uint32_t u32Version;
1766
1767 /**
1768 * Private interface between the IOAPIC and APIC.
1769 *
1770 * @returns status code.
1771 * @param pDevIns Device instance of the IOAPIC.
1772 * @param u8Dest See APIC implementation.
1773 * @param u8DestMode See APIC implementation.
1774 * @param u8DeliveryMode See APIC implementation.
1775 * @param uVector See APIC implementation.
1776 * @param u8Polarity See APIC implementation.
1777 * @param u8TriggerMode See APIC implementation.
1778 * @param uTagSrc The IRQ tag and source (for tracing).
1779 *
1780 * @sa APICBusDeliver()
1781 */
1782 DECLCALLBACKMEMBER(int, pfnApicBusDeliver)(PPDMDEVINS pDevIns, uint8_t u8Dest, uint8_t u8DestMode, uint8_t u8DeliveryMode,
1783 uint8_t uVector, uint8_t u8Polarity, uint8_t u8TriggerMode, uint32_t uTagSrc);
1784
1785 /**
1786 * Acquires the PDM lock.
1787 *
1788 * @returns VINF_SUCCESS on success.
1789 * @returns rc if we failed to acquire the lock.
1790 * @param pDevIns The IOAPIC device instance.
1791 * @param rc What to return if we fail to acquire the lock.
1792 */
1793 DECLCALLBACKMEMBER(int, pfnLock)(PPDMDEVINS pDevIns, int rc);
1794
1795 /**
1796 * Releases the PDM lock.
1797 *
1798 * @param pDevIns The IOAPIC device instance.
1799 */
1800 DECLCALLBACKMEMBER(void, pfnUnlock)(PPDMDEVINS pDevIns);
1801
1802 /**
1803 * Private interface between the IOAPIC and IOMMU.
1804 *
1805 * @returns status code.
1806 * @param pDevIns Device instance of the IOAPIC.
1807 * @param uDevId The device ID (bus, device, function) for the source MSI.
1808 * @param pMsiIn The source MSI.
1809 * @param pMsiOut Where to store the remapped MSI.
1810 *
1811 * @sa iommuAmdDeviceMsiRemap().
1812 */
1813 DECLCALLBACKMEMBER(int, pfnIommuMsiRemap)(PPDMDEVINS pDevIns, uint16_t uDevIt, PCMSIMSG pMsiIn, PMSIMSG pMsiOut);
1814
1815 /** Just a safety precaution. */
1816 uint32_t u32TheEnd;
1817} PDMIOAPICHLP;
1818/** Pointer to IOAPIC helpers. */
1819typedef PDMIOAPICHLP * PPDMIOAPICHLP;
1820/** Pointer to const IOAPIC helpers. */
1821typedef const PDMIOAPICHLP * PCPDMIOAPICHLP;
1822
1823/** Current PDMIOAPICHLP version number. */
1824#define PDM_IOAPICHLP_VERSION PDM_VERSION_MAKE(0xfff0, 2, 1)
1825
1826
1827/**
1828 * HPET registration structure.
1829 */
1830typedef struct PDMHPETREG
1831{
1832 /** Struct version+magic number (PDM_HPETREG_VERSION). */
1833 uint32_t u32Version;
1834} PDMHPETREG;
1835/** Pointer to an HPET registration structure. */
1836typedef PDMHPETREG *PPDMHPETREG;
1837
1838/** Current PDMHPETREG version number. */
1839#define PDM_HPETREG_VERSION PDM_VERSION_MAKE(0xffe2, 1, 0)
1840
1841/**
1842 * HPET RC helpers.
1843 *
1844 * @remarks Keep this around in case HPET will need PDM interaction in again RC
1845 * at some later point.
1846 */
1847typedef struct PDMHPETHLPRC
1848{
1849 /** Structure version. PDM_HPETHLPRC_VERSION defines the current version. */
1850 uint32_t u32Version;
1851
1852 /** Just a safety precaution. */
1853 uint32_t u32TheEnd;
1854} PDMHPETHLPRC;
1855
1856/** Pointer to HPET RC helpers. */
1857typedef RCPTRTYPE(PDMHPETHLPRC *) PPDMHPETHLPRC;
1858/** Pointer to const HPET RC helpers. */
1859typedef RCPTRTYPE(const PDMHPETHLPRC *) PCPDMHPETHLPRC;
1860
1861/** Current PDMHPETHLPRC version number. */
1862#define PDM_HPETHLPRC_VERSION PDM_VERSION_MAKE(0xffee, 2, 0)
1863
1864
1865/**
1866 * HPET R0 helpers.
1867 *
1868 * @remarks Keep this around in case HPET will need PDM interaction in again R0
1869 * at some later point.
1870 */
1871typedef struct PDMHPETHLPR0
1872{
1873 /** Structure version. PDM_HPETHLPR0_VERSION defines the current version. */
1874 uint32_t u32Version;
1875
1876 /** Just a safety precaution. */
1877 uint32_t u32TheEnd;
1878} PDMHPETHLPR0;
1879
1880/** Pointer to HPET R0 helpers. */
1881typedef R0PTRTYPE(PDMHPETHLPR0 *) PPDMHPETHLPR0;
1882/** Pointer to const HPET R0 helpers. */
1883typedef R0PTRTYPE(const PDMHPETHLPR0 *) PCPDMHPETHLPR0;
1884
1885/** Current PDMHPETHLPR0 version number. */
1886#define PDM_HPETHLPR0_VERSION PDM_VERSION_MAKE(0xffed, 2, 0)
1887
1888/**
1889 * HPET R3 helpers.
1890 */
1891typedef struct PDMHPETHLPR3
1892{
1893 /** Structure version. PDM_HPETHLP_VERSION defines the current version. */
1894 uint32_t u32Version;
1895
1896 /**
1897 * Set legacy mode on PIT and RTC.
1898 *
1899 * @returns VINF_SUCCESS on success.
1900 * @returns rc if we failed to set legacy mode.
1901 * @param pDevIns Device instance of the HPET.
1902 * @param fActivated Whether legacy mode is activated or deactivated.
1903 */
1904 DECLR3CALLBACKMEMBER(int, pfnSetLegacyMode,(PPDMDEVINS pDevIns, bool fActivated));
1905
1906
1907 /**
1908 * Set IRQ, bypassing ISA bus override rules.
1909 *
1910 * @returns VINF_SUCCESS on success.
1911 * @returns rc if we failed to set legacy mode.
1912 * @param pDevIns Device instance of the HPET.
1913 * @param iIrq IRQ number to set.
1914 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
1915 */
1916 DECLR3CALLBACKMEMBER(int, pfnSetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
1917
1918 /** Just a safety precaution. */
1919 uint32_t u32TheEnd;
1920} PDMHPETHLPR3;
1921
1922/** Pointer to HPET R3 helpers. */
1923typedef R3PTRTYPE(PDMHPETHLPR3 *) PPDMHPETHLPR3;
1924/** Pointer to const HPET R3 helpers. */
1925typedef R3PTRTYPE(const PDMHPETHLPR3 *) PCPDMHPETHLPR3;
1926
1927/** Current PDMHPETHLPR3 version number. */
1928#define PDM_HPETHLPR3_VERSION PDM_VERSION_MAKE(0xffec, 3, 0)
1929
1930
1931/**
1932 * Raw PCI device registration structure.
1933 */
1934typedef struct PDMPCIRAWREG
1935{
1936 /** Struct version+magic number (PDM_PCIRAWREG_VERSION). */
1937 uint32_t u32Version;
1938 /** Just a safety precaution. */
1939 uint32_t u32TheEnd;
1940} PDMPCIRAWREG;
1941/** Pointer to a raw PCI registration structure. */
1942typedef PDMPCIRAWREG *PPDMPCIRAWREG;
1943
1944/** Current PDMPCIRAWREG version number. */
1945#define PDM_PCIRAWREG_VERSION PDM_VERSION_MAKE(0xffe1, 1, 0)
1946
1947/**
1948 * Raw PCI device raw-mode context helpers.
1949 */
1950typedef struct PDMPCIRAWHLPRC
1951{
1952 /** Structure version and magic number (PDM_PCIRAWHLPRC_VERSION). */
1953 uint32_t u32Version;
1954 /** Just a safety precaution. */
1955 uint32_t u32TheEnd;
1956} PDMPCIRAWHLPRC;
1957/** Pointer to a raw PCI deviec raw-mode context helper structure. */
1958typedef RCPTRTYPE(PDMPCIRAWHLPRC *) PPDMPCIRAWHLPRC;
1959/** Pointer to a const raw PCI deviec raw-mode context helper structure. */
1960typedef RCPTRTYPE(const PDMPCIRAWHLPRC *) PCPDMPCIRAWHLPRC;
1961
1962/** Current PDMPCIRAWHLPRC version number. */
1963#define PDM_PCIRAWHLPRC_VERSION PDM_VERSION_MAKE(0xffe0, 1, 0)
1964
1965/**
1966 * Raw PCI device ring-0 context helpers.
1967 */
1968typedef struct PDMPCIRAWHLPR0
1969{
1970 /** Structure version and magic number (PDM_PCIRAWHLPR0_VERSION). */
1971 uint32_t u32Version;
1972 /** Just a safety precaution. */
1973 uint32_t u32TheEnd;
1974} PDMPCIRAWHLPR0;
1975/** Pointer to a raw PCI deviec ring-0 context helper structure. */
1976typedef R0PTRTYPE(PDMPCIRAWHLPR0 *) PPDMPCIRAWHLPR0;
1977/** Pointer to a const raw PCI deviec ring-0 context helper structure. */
1978typedef R0PTRTYPE(const PDMPCIRAWHLPR0 *) PCPDMPCIRAWHLPR0;
1979
1980/** Current PDMPCIRAWHLPR0 version number. */
1981#define PDM_PCIRAWHLPR0_VERSION PDM_VERSION_MAKE(0xffdf, 1, 0)
1982
1983
1984/**
1985 * Raw PCI device ring-3 context helpers.
1986 */
1987typedef struct PDMPCIRAWHLPR3
1988{
1989 /** Undefined structure version and magic number. */
1990 uint32_t u32Version;
1991
1992 /**
1993 * Gets the address of the RC raw PCI device helpers.
1994 *
1995 * This should be called at both construction and relocation time to obtain
1996 * the correct address of the RC helpers.
1997 *
1998 * @returns RC pointer to the raw PCI device helpers.
1999 * @param pDevIns Device instance of the raw PCI device.
2000 */
2001 DECLR3CALLBACKMEMBER(PCPDMPCIRAWHLPRC, pfnGetRCHelpers,(PPDMDEVINS pDevIns));
2002
2003 /**
2004 * Gets the address of the R0 raw PCI device helpers.
2005 *
2006 * This should be called at both construction and relocation time to obtain
2007 * the correct address of the R0 helpers.
2008 *
2009 * @returns R0 pointer to the raw PCI device helpers.
2010 * @param pDevIns Device instance of the raw PCI device.
2011 */
2012 DECLR3CALLBACKMEMBER(PCPDMPCIRAWHLPR0, pfnGetR0Helpers,(PPDMDEVINS pDevIns));
2013
2014 /** Just a safety precaution. */
2015 uint32_t u32TheEnd;
2016} PDMPCIRAWHLPR3;
2017/** Pointer to raw PCI R3 helpers. */
2018typedef R3PTRTYPE(PDMPCIRAWHLPR3 *) PPDMPCIRAWHLPR3;
2019/** Pointer to const raw PCI R3 helpers. */
2020typedef R3PTRTYPE(const PDMPCIRAWHLPR3 *) PCPDMPCIRAWHLPR3;
2021
2022/** Current PDMPCIRAWHLPR3 version number. */
2023#define PDM_PCIRAWHLPR3_VERSION PDM_VERSION_MAKE(0xffde, 1, 0)
2024
2025
2026#ifdef IN_RING3
2027
2028/**
2029 * DMA Transfer Handler.
2030 *
2031 * @returns Number of bytes transferred.
2032 * @param pDevIns Device instance of the DMA.
2033 * @param pvUser User pointer.
2034 * @param uChannel Channel number.
2035 * @param off DMA position.
2036 * @param cb Block size.
2037 * @remarks The device lock is not taken, however, the DMA device lock is held.
2038 */
2039typedef DECLCALLBACK(uint32_t) FNDMATRANSFERHANDLER(PPDMDEVINS pDevIns, void *pvUser, unsigned uChannel, uint32_t off, uint32_t cb);
2040/** Pointer to a FNDMATRANSFERHANDLER(). */
2041typedef FNDMATRANSFERHANDLER *PFNDMATRANSFERHANDLER;
2042
2043/**
2044 * DMA Controller registration structure.
2045 */
2046typedef struct PDMDMAREG
2047{
2048 /** Structure version number. PDM_DMACREG_VERSION defines the current version. */
2049 uint32_t u32Version;
2050
2051 /**
2052 * Execute pending transfers.
2053 *
2054 * @returns A more work indiciator. I.e. 'true' if there is more to be done, and 'false' if all is done.
2055 * @param pDevIns Device instance of the DMAC.
2056 * @remarks No locks held, called on EMT(0) as a form of serialization.
2057 */
2058 DECLR3CALLBACKMEMBER(bool, pfnRun,(PPDMDEVINS pDevIns));
2059
2060 /**
2061 * Register transfer function for DMA channel.
2062 *
2063 * @param pDevIns Device instance of the DMAC.
2064 * @param uChannel Channel number.
2065 * @param pfnTransferHandler Device specific transfer function.
2066 * @param pvUser User pointer to be passed to the callback.
2067 * @remarks No locks held, called on an EMT.
2068 */
2069 DECLR3CALLBACKMEMBER(void, pfnRegister,(PPDMDEVINS pDevIns, unsigned uChannel, PFNDMATRANSFERHANDLER pfnTransferHandler, void *pvUser));
2070
2071 /**
2072 * Read memory
2073 *
2074 * @returns Number of bytes read.
2075 * @param pDevIns Device instance of the DMAC.
2076 * @param uChannel Channel number.
2077 * @param pvBuffer Pointer to target buffer.
2078 * @param off DMA position.
2079 * @param cbBlock Block size.
2080 * @remarks No locks held, called on an EMT.
2081 */
2082 DECLR3CALLBACKMEMBER(uint32_t, pfnReadMemory,(PPDMDEVINS pDevIns, unsigned uChannel, void *pvBuffer, uint32_t off, uint32_t cbBlock));
2083
2084 /**
2085 * Write memory
2086 *
2087 * @returns Number of bytes written.
2088 * @param pDevIns Device instance of the DMAC.
2089 * @param uChannel Channel number.
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/** @name Flags for PCI I/O region registration
2211 * @{ */
2212/** No handle is passed. */
2213#define PDMPCIDEV_IORGN_F_NO_HANDLE UINT32_C(0x00000000)
2214/** An I/O port handle is passed. */
2215#define PDMPCIDEV_IORGN_F_IOPORT_HANDLE UINT32_C(0x00000001)
2216/** An MMIO range handle is passed. */
2217#define PDMPCIDEV_IORGN_F_MMIO_HANDLE UINT32_C(0x00000002)
2218/** An MMIO2 handle is passed. */
2219#define PDMPCIDEV_IORGN_F_MMIO2_HANDLE UINT32_C(0x00000003)
2220/** Handle type mask. */
2221#define PDMPCIDEV_IORGN_F_HANDLE_MASK UINT32_C(0x00000003)
2222/** New-style (mostly wrt callbacks). */
2223#define PDMPCIDEV_IORGN_F_NEW_STYLE UINT32_C(0x00000004)
2224/** Mask of valid flags. */
2225#define PDMPCIDEV_IORGN_F_VALID_MASK UINT32_C(0x00000007)
2226/** @} */
2227
2228
2229/** @name Flags for the guest physical read/write helpers
2230 * @{ */
2231/** Default flag with no indication whether the data is processed by the device or just passed through. */
2232#define PDM_DEVHLP_PHYS_RW_F_DEFAULT UINT32_C(0x00000000)
2233/** The data is user data which is just passed through between the guest and the source or destination and not processed
2234 * by the device in any way. */
2235#define PDM_DEVHLP_PHYS_RW_F_DATA_USER RT_BIT_32(0)
2236/** The data is metadata and being processed by the device in some way. */
2237#define PDM_DEVHLP_PHYS_RW_F_DATA_META RT_BIT_32(1)
2238/** @} */
2239
2240
2241#ifdef IN_RING3
2242
2243/** @name Special values for PDMDEVHLPR3::pfnPCIRegister parameters.
2244 * @{ */
2245/** Same device number (and bus) as the previous PCI device registered with the PDM device.
2246 * This is handy when registering multiple PCI device functions and the device
2247 * number is left up to the PCI bus. In order to facilitate one PDM device
2248 * instance for each PCI function, this searches earlier PDM device
2249 * instances as well. */
2250# define PDMPCIDEVREG_DEV_NO_SAME_AS_PREV UINT8_C(0xfd)
2251/** Use the first unused device number (all functions must be unused). */
2252# define PDMPCIDEVREG_DEV_NO_FIRST_UNUSED UINT8_C(0xfe)
2253/** Use the first unused device function. */
2254# define PDMPCIDEVREG_FUN_NO_FIRST_UNUSED UINT8_C(0xff)
2255
2256/** The device and function numbers are not mandatory, just suggestions. */
2257# define PDMPCIDEVREG_F_NOT_MANDATORY_NO RT_BIT_32(0)
2258/** Registering a PCI bridge device. */
2259# define PDMPCIDEVREG_F_PCI_BRIDGE RT_BIT_32(1)
2260/** Valid flag mask. */
2261# define PDMPCIDEVREG_F_VALID_MASK UINT32_C(0x00000003)
2262/** @} */
2263
2264/** Current PDMDEVHLPR3 version number. */
2265#define PDM_DEVHLPR3_VERSION PDM_VERSION_MAKE_PP(0xffe7, 43, 0)
2266
2267/**
2268 * PDM Device API.
2269 */
2270typedef struct PDMDEVHLPR3
2271{
2272 /** Structure version. PDM_DEVHLPR3_VERSION defines the current version. */
2273 uint32_t u32Version;
2274
2275 /** @name I/O ports
2276 * @{ */
2277 /**
2278 * Creates a range of I/O ports for a device.
2279 *
2280 * The I/O port range must be mapped in a separately call. Any ring-0 and
2281 * raw-mode context callback handlers needs to be set up in the respective
2282 * contexts.
2283 *
2284 * @returns VBox status.
2285 * @param pDevIns The device instance to register the ports with.
2286 * @param cPorts Number of ports to register.
2287 * @param fFlags IOM_IOPORT_F_XXX.
2288 * @param pPciDev The PCI device the range is associated with, if
2289 * applicable.
2290 * @param iPciRegion The PCI device region in the high 16-bit word and
2291 * sub-region in the low 16-bit word. UINT32_MAX if NA.
2292 * @param pfnOut Pointer to function which is gonna handle OUT
2293 * operations. Optional.
2294 * @param pfnIn Pointer to function which is gonna handle IN operations.
2295 * Optional.
2296 * @param pfnOutStr Pointer to function which is gonna handle string OUT
2297 * operations. Optional.
2298 * @param pfnInStr Pointer to function which is gonna handle string IN
2299 * operations. Optional.
2300 * @param pvUser User argument to pass to the callbacks.
2301 * @param pszDesc Pointer to description string. This must not be freed.
2302 * @param paExtDescs Extended per-port descriptions, optional. Partial range
2303 * coverage is allowed. This must not be freed.
2304 * @param phIoPorts Where to return the I/O port range handle.
2305 *
2306 * @remarks Caller enters the device critical section prior to invoking the
2307 * registered callback methods.
2308 *
2309 * @sa PDMDevHlpIoPortSetUpContext, PDMDevHlpIoPortMap,
2310 * PDMDevHlpIoPortUnmap.
2311 */
2312 DECLR3CALLBACKMEMBER(int, pfnIoPortCreateEx,(PPDMDEVINS pDevIns, RTIOPORT cPorts, uint32_t fFlags, PPDMPCIDEV pPciDev,
2313 uint32_t iPciRegion, PFNIOMIOPORTNEWOUT pfnOut, PFNIOMIOPORTNEWIN pfnIn,
2314 PFNIOMIOPORTNEWOUTSTRING pfnOutStr, PFNIOMIOPORTNEWINSTRING pfnInStr, RTR3PTR pvUser,
2315 const char *pszDesc, PCIOMIOPORTDESC paExtDescs, PIOMIOPORTHANDLE phIoPorts));
2316
2317 /**
2318 * Maps an I/O port range.
2319 *
2320 * @returns VBox status.
2321 * @param pDevIns The device instance to register the ports with.
2322 * @param hIoPorts The I/O port range handle.
2323 * @param Port Where to map the range.
2324 * @sa PDMDevHlpIoPortUnmap, PDMDevHlpIoPortSetUpContext,
2325 * PDMDevHlpIoPortCreate, PDMDevHlpIoPortCreateEx.
2326 */
2327 DECLR3CALLBACKMEMBER(int, pfnIoPortMap,(PPDMDEVINS pDevIns, IOMIOPORTHANDLE hIoPorts, RTIOPORT Port));
2328
2329 /**
2330 * Unmaps an I/O port range.
2331 *
2332 * @returns VBox status.
2333 * @param pDevIns The device instance to register the ports with.
2334 * @param hIoPorts The I/O port range handle.
2335 * @sa PDMDevHlpIoPortMap, PDMDevHlpIoPortSetUpContext,
2336 * PDMDevHlpIoPortCreate, PDMDevHlpIoPortCreateEx.
2337 */
2338 DECLR3CALLBACKMEMBER(int, pfnIoPortUnmap,(PPDMDEVINS pDevIns, IOMIOPORTHANDLE hIoPorts));
2339
2340 /**
2341 * Gets the mapping address of the I/O port range @a hIoPorts.
2342 *
2343 * @returns Mapping address (0..65535) or UINT32_MAX if not mapped (or invalid
2344 * parameters).
2345 * @param pDevIns The device instance to register the ports with.
2346 * @param hIoPorts The I/O port range handle.
2347 */
2348 DECLR3CALLBACKMEMBER(uint32_t, pfnIoPortGetMappingAddress,(PPDMDEVINS pDevIns, IOMIOPORTHANDLE hIoPorts));
2349 /** @} */
2350
2351 /** @name MMIO
2352 * @{ */
2353 /**
2354 * Creates a memory mapped I/O (MMIO) region for a device.
2355 *
2356 * The MMIO region must be mapped in a separately call. Any ring-0 and
2357 * raw-mode context callback handlers needs to be set up in the respective
2358 * contexts.
2359 *
2360 * @returns VBox status.
2361 * @param pDevIns The device instance to register the ports with.
2362 * @param cbRegion The size of the region in bytes.
2363 * @param fFlags Flags, IOMMMIO_FLAGS_XXX.
2364 * @param pPciDev The PCI device the range is associated with, if
2365 * applicable.
2366 * @param iPciRegion The PCI device region in the high 16-bit word and
2367 * sub-region in the low 16-bit word. UINT32_MAX if NA.
2368 * @param pfnWrite Pointer to function which is gonna handle Write
2369 * operations.
2370 * @param pfnRead Pointer to function which is gonna handle Read
2371 * operations.
2372 * @param pfnFill Pointer to function which is gonna handle Fill/memset
2373 * operations. (optional)
2374 * @param pvUser User argument to pass to the callbacks.
2375 * @param pszDesc Pointer to description string. This must not be freed.
2376 * @param phRegion Where to return the MMIO region handle.
2377 *
2378 * @remarks Caller enters the device critical section prior to invoking the
2379 * registered callback methods.
2380 *
2381 * @sa PDMDevHlpMmioSetUpContext, PDMDevHlpMmioMap, PDMDevHlpMmioUnmap.
2382 */
2383 DECLR3CALLBACKMEMBER(int, pfnMmioCreateEx,(PPDMDEVINS pDevIns, RTGCPHYS cbRegion,
2384 uint32_t fFlags, PPDMPCIDEV pPciDev, uint32_t iPciRegion,
2385 PFNIOMMMIONEWWRITE pfnWrite, PFNIOMMMIONEWREAD pfnRead, PFNIOMMMIONEWFILL pfnFill,
2386 void *pvUser, const char *pszDesc, PIOMMMIOHANDLE phRegion));
2387
2388 /**
2389 * Maps a memory mapped I/O (MMIO) region (into the guest physical address space).
2390 *
2391 * @returns VBox status.
2392 * @param pDevIns The device instance the region is associated with.
2393 * @param hRegion The MMIO region handle.
2394 * @param GCPhys Where to map the region.
2395 * @note An MMIO range may overlap with base memory if a lot of RAM is
2396 * configured for the VM, in which case we'll drop the base memory
2397 * pages. Presently we will make no attempt to preserve anything that
2398 * happens to be present in the base memory that is replaced, this is
2399 * technically incorrect but it's just not worth the effort to do
2400 * right, at least not at this point.
2401 * @sa PDMDevHlpMmioUnmap, PDMDevHlpMmioCreate, PDMDevHlpMmioCreateEx,
2402 * PDMDevHlpMmioSetUpContext
2403 */
2404 DECLR3CALLBACKMEMBER(int, pfnMmioMap,(PPDMDEVINS pDevIns, IOMMMIOHANDLE hRegion, RTGCPHYS GCPhys));
2405
2406 /**
2407 * Unmaps a memory mapped I/O (MMIO) region.
2408 *
2409 * @returns VBox status.
2410 * @param pDevIns The device instance the region is associated with.
2411 * @param hRegion The MMIO region handle.
2412 * @sa PDMDevHlpMmioMap, PDMDevHlpMmioCreate, PDMDevHlpMmioCreateEx,
2413 * PDMDevHlpMmioSetUpContext
2414 */
2415 DECLR3CALLBACKMEMBER(int, pfnMmioUnmap,(PPDMDEVINS pDevIns, IOMMMIOHANDLE hRegion));
2416
2417 /**
2418 * Reduces the length of a MMIO range.
2419 *
2420 * This is for implementations of PDMPCIDEV::pfnRegionLoadChangeHookR3 and will
2421 * only work during saved state restore. It will not call the PCI bus code, as
2422 * that is expected to restore the saved resource configuration.
2423 *
2424 * It just adjusts the mapping length of the region so that when pfnMmioMap is
2425 * called it will only map @a cbRegion bytes and not the value set during
2426 * registration.
2427 *
2428 * @return VBox status code.
2429 * @param pDevIns The device owning the range.
2430 * @param hRegion The MMIO region handle.
2431 * @param cbRegion The new size, must be smaller.
2432 */
2433 DECLR3CALLBACKMEMBER(int, pfnMmioReduce,(PPDMDEVINS pDevIns, IOMMMIOHANDLE hRegion, RTGCPHYS cbRegion));
2434
2435 /**
2436 * Gets the mapping address of the MMIO region @a hRegion.
2437 *
2438 * @returns Mapping address, NIL_RTGCPHYS if not mapped (or invalid parameters).
2439 * @param pDevIns The device instance to register the ports with.
2440 * @param hRegion The MMIO region handle.
2441 */
2442 DECLR3CALLBACKMEMBER(RTGCPHYS, pfnMmioGetMappingAddress,(PPDMDEVINS pDevIns, IOMMMIOHANDLE hRegion));
2443 /** @} */
2444
2445 /** @name MMIO2
2446 * @{ */
2447 /**
2448 * Creates a MMIO2 region.
2449 *
2450 * As mentioned elsewhere, MMIO2 is just RAM spelled differently. It's RAM
2451 * associated with a device. It is also non-shared memory with a permanent
2452 * ring-3 mapping and page backing (presently).
2453 *
2454 * @returns VBox status.
2455 * @param pDevIns The device instance.
2456 * @param pPciDev The PCI device the region is associated with, or
2457 * NULL if no PCI device association.
2458 * @param iPciRegion The region number. Use the PCI region number as
2459 * this must be known to the PCI bus device too. If
2460 * it's not associated with the PCI device, then
2461 * any number up to UINT8_MAX is fine.
2462 * @param cbRegion The size (in bytes) of the region.
2463 * @param fFlags Reserved for future use, must be zero.
2464 * @param pszDesc Pointer to description string. This must not be
2465 * freed.
2466 * @param ppvMapping Where to store the address of the ring-3 mapping
2467 * of the memory.
2468 * @param phRegion Where to return the MMIO2 region handle.
2469 *
2470 * @thread EMT(0)
2471 */
2472 DECLR3CALLBACKMEMBER(int, pfnMmio2Create,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iPciRegion, RTGCPHYS cbRegion,
2473 uint32_t fFlags, const char *pszDesc, void **ppvMapping, PPGMMMIO2HANDLE phRegion));
2474
2475 /**
2476 * Destroys a MMIO2 region, unmapping it and freeing the memory.
2477 *
2478 * Any physical access handlers registered for the region must be deregistered
2479 * before calling this function.
2480 *
2481 * @returns VBox status code.
2482 * @param pDevIns The device instance.
2483 * @param hRegion The MMIO2 region handle.
2484 * @thread EMT.
2485 */
2486 DECLR3CALLBACKMEMBER(int, pfnMmio2Destroy,(PPDMDEVINS pDevIns, PGMMMIO2HANDLE hRegion));
2487
2488 /**
2489 * Maps a MMIO2 region (into the guest physical address space).
2490 *
2491 * @returns VBox status.
2492 * @param pDevIns The device instance the region is associated with.
2493 * @param hRegion The MMIO2 region handle.
2494 * @param GCPhys Where to map the region.
2495 * @note A MMIO2 region overlap with base memory if a lot of RAM is
2496 * configured for the VM, in which case we'll drop the base memory
2497 * pages. Presently we will make no attempt to preserve anything that
2498 * happens to be present in the base memory that is replaced, this is
2499 * technically incorrect but it's just not worth the effort to do
2500 * right, at least not at this point.
2501 * @sa PDMDevHlpMmio2Unmap, PDMDevHlpMmio2Create, PDMDevHlpMmio2SetUpContext
2502 */
2503 DECLR3CALLBACKMEMBER(int, pfnMmio2Map,(PPDMDEVINS pDevIns, PGMMMIO2HANDLE hRegion, RTGCPHYS GCPhys));
2504
2505 /**
2506 * Unmaps a MMIO2 region.
2507 *
2508 * @returns VBox status.
2509 * @param pDevIns The device instance the region is associated with.
2510 * @param hRegion The MMIO2 region handle.
2511 * @sa PDMDevHlpMmio2Map, PDMDevHlpMmio2Create, PDMDevHlpMmio2SetUpContext
2512 */
2513 DECLR3CALLBACKMEMBER(int, pfnMmio2Unmap,(PPDMDEVINS pDevIns, PGMMMIO2HANDLE hRegion));
2514
2515 /**
2516 * Reduces the length of a MMIO range.
2517 *
2518 * This is for implementations of PDMPCIDEV::pfnRegionLoadChangeHookR3 and will
2519 * only work during saved state restore. It will not call the PCI bus code, as
2520 * that is expected to restore the saved resource configuration.
2521 *
2522 * It just adjusts the mapping length of the region so that when pfnMmioMap is
2523 * called it will only map @a cbRegion bytes and not the value set during
2524 * registration.
2525 *
2526 * @return VBox status code.
2527 * @param pDevIns The device owning the range.
2528 * @param hRegion The MMIO2 region handle.
2529 * @param cbRegion The new size, must be smaller.
2530 */
2531 DECLR3CALLBACKMEMBER(int, pfnMmio2Reduce,(PPDMDEVINS pDevIns, PGMMMIO2HANDLE hRegion, RTGCPHYS cbRegion));
2532
2533 /**
2534 * Gets the mapping address of the MMIO region @a hRegion.
2535 *
2536 * @returns Mapping address, NIL_RTGCPHYS if not mapped (or invalid parameters).
2537 * @param pDevIns The device instance to register the ports with.
2538 * @param hRegion The MMIO2 region handle.
2539 */
2540 DECLR3CALLBACKMEMBER(RTGCPHYS, pfnMmio2GetMappingAddress,(PPDMDEVINS pDevIns, PGMMMIO2HANDLE hRegion));
2541
2542 /**
2543 * Changes the number of an MMIO2 or pre-registered MMIO region.
2544 *
2545 * This should only be used to deal with saved state problems, so there is no
2546 * convenience inline wrapper for this method.
2547 *
2548 * @returns VBox status code.
2549 * @param pDevIns The device instance.
2550 * @param hRegion The MMIO2 region handle.
2551 * @param iNewRegion The new region index.
2552 *
2553 * @sa @bugref{9359}
2554 */
2555 DECLR3CALLBACKMEMBER(int, pfnMmio2ChangeRegionNo,(PPDMDEVINS pDevIns, PGMMMIO2HANDLE hRegion, uint32_t iNewRegion));
2556 /** @} */
2557
2558 /**
2559 * Register a ROM (BIOS) region.
2560 *
2561 * It goes without saying that this is read-only memory. The memory region must be
2562 * in unassigned memory. I.e. from the top of the address space or on the PC in
2563 * the 0xa0000-0xfffff range.
2564 *
2565 * @returns VBox status.
2566 * @param pDevIns The device instance owning the ROM region.
2567 * @param GCPhysStart First physical address in the range.
2568 * Must be page aligned!
2569 * @param cbRange The size of the range (in bytes).
2570 * Must be page aligned!
2571 * @param pvBinary Pointer to the binary data backing the ROM image.
2572 * @param cbBinary The size of the binary pointer. This must
2573 * be equal or smaller than @a cbRange.
2574 * @param fFlags Shadow ROM flags, PGMPHYS_ROM_FLAGS_* in pgm.h.
2575 * @param pszDesc Pointer to description string. This must not be freed.
2576 *
2577 * @remark There is no way to remove the rom, automatically on device cleanup or
2578 * manually from the device yet. At present I doubt we need such features...
2579 */
2580 DECLR3CALLBACKMEMBER(int, pfnROMRegister,(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, uint32_t cbRange,
2581 const void *pvBinary, uint32_t cbBinary, uint32_t fFlags, const char *pszDesc));
2582
2583 /**
2584 * Changes the protection of shadowed ROM mapping.
2585 *
2586 * This is intented for use by the system BIOS, chipset or device in question to
2587 * change the protection of shadowed ROM code after init and on reset.
2588 *
2589 * @param pDevIns The device instance.
2590 * @param GCPhysStart Where the mapping starts.
2591 * @param cbRange The size of the mapping.
2592 * @param enmProt The new protection type.
2593 */
2594 DECLR3CALLBACKMEMBER(int, pfnROMProtectShadow,(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, uint32_t cbRange, PGMROMPROT enmProt));
2595
2596 /**
2597 * Register a save state data unit.
2598 *
2599 * @returns VBox status.
2600 * @param pDevIns The device instance.
2601 * @param uVersion Data layout version number.
2602 * @param cbGuess The approximate amount of data in the unit.
2603 * Only for progress indicators.
2604 * @param pszBefore Name of data unit which we should be put in
2605 * front of. Optional (NULL).
2606 *
2607 * @param pfnLivePrep Prepare live save callback, optional.
2608 * @param pfnLiveExec Execute live save callback, optional.
2609 * @param pfnLiveVote Vote live save callback, optional.
2610 *
2611 * @param pfnSavePrep Prepare save callback, optional.
2612 * @param pfnSaveExec Execute save callback, optional.
2613 * @param pfnSaveDone Done save callback, optional.
2614 *
2615 * @param pfnLoadPrep Prepare load callback, optional.
2616 * @param pfnLoadExec Execute load callback, optional.
2617 * @param pfnLoadDone Done load callback, optional.
2618 * @remarks Caller enters the device critical section prior to invoking the
2619 * registered callback methods.
2620 */
2621 DECLR3CALLBACKMEMBER(int, pfnSSMRegister,(PPDMDEVINS pDevIns, uint32_t uVersion, size_t cbGuess, const char *pszBefore,
2622 PFNSSMDEVLIVEPREP pfnLivePrep, PFNSSMDEVLIVEEXEC pfnLiveExec, PFNSSMDEVLIVEVOTE pfnLiveVote,
2623 PFNSSMDEVSAVEPREP pfnSavePrep, PFNSSMDEVSAVEEXEC pfnSaveExec, PFNSSMDEVSAVEDONE pfnSaveDone,
2624 PFNSSMDEVLOADPREP pfnLoadPrep, PFNSSMDEVLOADEXEC pfnLoadExec, PFNSSMDEVLOADDONE pfnLoadDone));
2625
2626 /** @name Exported SSM Functions
2627 * @{ */
2628 DECLR3CALLBACKMEMBER(int, pfnSSMPutStruct,(PSSMHANDLE pSSM, const void *pvStruct, PCSSMFIELD paFields));
2629 DECLR3CALLBACKMEMBER(int, pfnSSMPutStructEx,(PSSMHANDLE pSSM, const void *pvStruct, size_t cbStruct, uint32_t fFlags, PCSSMFIELD paFields, void *pvUser));
2630 DECLR3CALLBACKMEMBER(int, pfnSSMPutBool,(PSSMHANDLE pSSM, bool fBool));
2631 DECLR3CALLBACKMEMBER(int, pfnSSMPutU8,(PSSMHANDLE pSSM, uint8_t u8));
2632 DECLR3CALLBACKMEMBER(int, pfnSSMPutS8,(PSSMHANDLE pSSM, int8_t i8));
2633 DECLR3CALLBACKMEMBER(int, pfnSSMPutU16,(PSSMHANDLE pSSM, uint16_t u16));
2634 DECLR3CALLBACKMEMBER(int, pfnSSMPutS16,(PSSMHANDLE pSSM, int16_t i16));
2635 DECLR3CALLBACKMEMBER(int, pfnSSMPutU32,(PSSMHANDLE pSSM, uint32_t u32));
2636 DECLR3CALLBACKMEMBER(int, pfnSSMPutS32,(PSSMHANDLE pSSM, int32_t i32));
2637 DECLR3CALLBACKMEMBER(int, pfnSSMPutU64,(PSSMHANDLE pSSM, uint64_t u64));
2638 DECLR3CALLBACKMEMBER(int, pfnSSMPutS64,(PSSMHANDLE pSSM, int64_t i64));
2639 DECLR3CALLBACKMEMBER(int, pfnSSMPutU128,(PSSMHANDLE pSSM, uint128_t u128));
2640 DECLR3CALLBACKMEMBER(int, pfnSSMPutS128,(PSSMHANDLE pSSM, int128_t i128));
2641 DECLR3CALLBACKMEMBER(int, pfnSSMPutUInt,(PSSMHANDLE pSSM, RTUINT u));
2642 DECLR3CALLBACKMEMBER(int, pfnSSMPutSInt,(PSSMHANDLE pSSM, RTINT i));
2643 DECLR3CALLBACKMEMBER(int, pfnSSMPutGCUInt,(PSSMHANDLE pSSM, RTGCUINT u));
2644 DECLR3CALLBACKMEMBER(int, pfnSSMPutGCUIntReg,(PSSMHANDLE pSSM, RTGCUINTREG u));
2645 DECLR3CALLBACKMEMBER(int, pfnSSMPutGCPhys32,(PSSMHANDLE pSSM, RTGCPHYS32 GCPhys));
2646 DECLR3CALLBACKMEMBER(int, pfnSSMPutGCPhys64,(PSSMHANDLE pSSM, RTGCPHYS64 GCPhys));
2647 DECLR3CALLBACKMEMBER(int, pfnSSMPutGCPhys,(PSSMHANDLE pSSM, RTGCPHYS GCPhys));
2648 DECLR3CALLBACKMEMBER(int, pfnSSMPutGCPtr,(PSSMHANDLE pSSM, RTGCPTR GCPtr));
2649 DECLR3CALLBACKMEMBER(int, pfnSSMPutGCUIntPtr,(PSSMHANDLE pSSM, RTGCUINTPTR GCPtr));
2650 DECLR3CALLBACKMEMBER(int, pfnSSMPutRCPtr,(PSSMHANDLE pSSM, RTRCPTR RCPtr));
2651 DECLR3CALLBACKMEMBER(int, pfnSSMPutIOPort,(PSSMHANDLE pSSM, RTIOPORT IOPort));
2652 DECLR3CALLBACKMEMBER(int, pfnSSMPutSel,(PSSMHANDLE pSSM, RTSEL Sel));
2653 DECLR3CALLBACKMEMBER(int, pfnSSMPutMem,(PSSMHANDLE pSSM, const void *pv, size_t cb));
2654 DECLR3CALLBACKMEMBER(int, pfnSSMPutStrZ,(PSSMHANDLE pSSM, const char *psz));
2655 DECLR3CALLBACKMEMBER(int, pfnSSMGetStruct,(PSSMHANDLE pSSM, void *pvStruct, PCSSMFIELD paFields));
2656 DECLR3CALLBACKMEMBER(int, pfnSSMGetStructEx,(PSSMHANDLE pSSM, void *pvStruct, size_t cbStruct, uint32_t fFlags, PCSSMFIELD paFields, void *pvUser));
2657 DECLR3CALLBACKMEMBER(int, pfnSSMGetBool,(PSSMHANDLE pSSM, bool *pfBool));
2658 DECLR3CALLBACKMEMBER(int, pfnSSMGetBoolV,(PSSMHANDLE pSSM, bool volatile *pfBool));
2659 DECLR3CALLBACKMEMBER(int, pfnSSMGetU8,(PSSMHANDLE pSSM, uint8_t *pu8));
2660 DECLR3CALLBACKMEMBER(int, pfnSSMGetU8V,(PSSMHANDLE pSSM, uint8_t volatile *pu8));
2661 DECLR3CALLBACKMEMBER(int, pfnSSMGetS8,(PSSMHANDLE pSSM, int8_t *pi8));
2662 DECLR3CALLBACKMEMBER(int, pfnSSMGetS8V,(PSSMHANDLE pSSM, int8_t volatile *pi8));
2663 DECLR3CALLBACKMEMBER(int, pfnSSMGetU16,(PSSMHANDLE pSSM, uint16_t *pu16));
2664 DECLR3CALLBACKMEMBER(int, pfnSSMGetU16V,(PSSMHANDLE pSSM, uint16_t volatile *pu16));
2665 DECLR3CALLBACKMEMBER(int, pfnSSMGetS16,(PSSMHANDLE pSSM, int16_t *pi16));
2666 DECLR3CALLBACKMEMBER(int, pfnSSMGetS16V,(PSSMHANDLE pSSM, int16_t volatile *pi16));
2667 DECLR3CALLBACKMEMBER(int, pfnSSMGetU32,(PSSMHANDLE pSSM, uint32_t *pu32));
2668 DECLR3CALLBACKMEMBER(int, pfnSSMGetU32V,(PSSMHANDLE pSSM, uint32_t volatile *pu32));
2669 DECLR3CALLBACKMEMBER(int, pfnSSMGetS32,(PSSMHANDLE pSSM, int32_t *pi32));
2670 DECLR3CALLBACKMEMBER(int, pfnSSMGetS32V,(PSSMHANDLE pSSM, int32_t volatile *pi32));
2671 DECLR3CALLBACKMEMBER(int, pfnSSMGetU64,(PSSMHANDLE pSSM, uint64_t *pu64));
2672 DECLR3CALLBACKMEMBER(int, pfnSSMGetU64V,(PSSMHANDLE pSSM, uint64_t volatile *pu64));
2673 DECLR3CALLBACKMEMBER(int, pfnSSMGetS64,(PSSMHANDLE pSSM, int64_t *pi64));
2674 DECLR3CALLBACKMEMBER(int, pfnSSMGetS64V,(PSSMHANDLE pSSM, int64_t volatile *pi64));
2675 DECLR3CALLBACKMEMBER(int, pfnSSMGetU128,(PSSMHANDLE pSSM, uint128_t *pu128));
2676 DECLR3CALLBACKMEMBER(int, pfnSSMGetU128V,(PSSMHANDLE pSSM, uint128_t volatile *pu128));
2677 DECLR3CALLBACKMEMBER(int, pfnSSMGetS128,(PSSMHANDLE pSSM, int128_t *pi128));
2678 DECLR3CALLBACKMEMBER(int, pfnSSMGetS128V,(PSSMHANDLE pSSM, int128_t volatile *pi128));
2679 DECLR3CALLBACKMEMBER(int, pfnSSMGetGCPhys32,(PSSMHANDLE pSSM, PRTGCPHYS32 pGCPhys));
2680 DECLR3CALLBACKMEMBER(int, pfnSSMGetGCPhys32V,(PSSMHANDLE pSSM, RTGCPHYS32 volatile *pGCPhys));
2681 DECLR3CALLBACKMEMBER(int, pfnSSMGetGCPhys64,(PSSMHANDLE pSSM, PRTGCPHYS64 pGCPhys));
2682 DECLR3CALLBACKMEMBER(int, pfnSSMGetGCPhys64V,(PSSMHANDLE pSSM, RTGCPHYS64 volatile *pGCPhys));
2683 DECLR3CALLBACKMEMBER(int, pfnSSMGetGCPhys,(PSSMHANDLE pSSM, PRTGCPHYS pGCPhys));
2684 DECLR3CALLBACKMEMBER(int, pfnSSMGetGCPhysV,(PSSMHANDLE pSSM, RTGCPHYS volatile *pGCPhys));
2685 DECLR3CALLBACKMEMBER(int, pfnSSMGetUInt,(PSSMHANDLE pSSM, PRTUINT pu));
2686 DECLR3CALLBACKMEMBER(int, pfnSSMGetSInt,(PSSMHANDLE pSSM, PRTINT pi));
2687 DECLR3CALLBACKMEMBER(int, pfnSSMGetGCUInt,(PSSMHANDLE pSSM, PRTGCUINT pu));
2688 DECLR3CALLBACKMEMBER(int, pfnSSMGetGCUIntReg,(PSSMHANDLE pSSM, PRTGCUINTREG pu));
2689 DECLR3CALLBACKMEMBER(int, pfnSSMGetGCPtr,(PSSMHANDLE pSSM, PRTGCPTR pGCPtr));
2690 DECLR3CALLBACKMEMBER(int, pfnSSMGetGCUIntPtr,(PSSMHANDLE pSSM, PRTGCUINTPTR pGCPtr));
2691 DECLR3CALLBACKMEMBER(int, pfnSSMGetRCPtr,(PSSMHANDLE pSSM, PRTRCPTR pRCPtr));
2692 DECLR3CALLBACKMEMBER(int, pfnSSMGetIOPort,(PSSMHANDLE pSSM, PRTIOPORT pIOPort));
2693 DECLR3CALLBACKMEMBER(int, pfnSSMGetSel,(PSSMHANDLE pSSM, PRTSEL pSel));
2694 DECLR3CALLBACKMEMBER(int, pfnSSMGetMem,(PSSMHANDLE pSSM, void *pv, size_t cb));
2695 DECLR3CALLBACKMEMBER(int, pfnSSMGetStrZ,(PSSMHANDLE pSSM, char *psz, size_t cbMax));
2696 DECLR3CALLBACKMEMBER(int, pfnSSMGetStrZEx,(PSSMHANDLE pSSM, char *psz, size_t cbMax, size_t *pcbStr));
2697 DECLR3CALLBACKMEMBER(int, pfnSSMSkip,(PSSMHANDLE pSSM, size_t cb));
2698 DECLR3CALLBACKMEMBER(int, pfnSSMSkipToEndOfUnit,(PSSMHANDLE pSSM));
2699 DECLR3CALLBACKMEMBER(int, pfnSSMSetLoadError,(PSSMHANDLE pSSM, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(6, 7));
2700 DECLR3CALLBACKMEMBER(int, pfnSSMSetLoadErrorV,(PSSMHANDLE pSSM, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(6, 0));
2701 DECLR3CALLBACKMEMBER(int, pfnSSMSetCfgError,(PSSMHANDLE pSSM, RT_SRC_POS_DECL, const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(5, 6));
2702 DECLR3CALLBACKMEMBER(int, pfnSSMSetCfgErrorV,(PSSMHANDLE pSSM, RT_SRC_POS_DECL, const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(5, 0));
2703 DECLR3CALLBACKMEMBER(int, pfnSSMHandleGetStatus,(PSSMHANDLE pSSM));
2704 DECLR3CALLBACKMEMBER(SSMAFTER, pfnSSMHandleGetAfter,(PSSMHANDLE pSSM));
2705 DECLR3CALLBACKMEMBER(bool, pfnSSMHandleIsLiveSave,(PSSMHANDLE pSSM));
2706 DECLR3CALLBACKMEMBER(uint32_t, pfnSSMHandleMaxDowntime,(PSSMHANDLE pSSM));
2707 DECLR3CALLBACKMEMBER(uint32_t, pfnSSMHandleHostBits,(PSSMHANDLE pSSM));
2708 DECLR3CALLBACKMEMBER(uint32_t, pfnSSMHandleRevision,(PSSMHANDLE pSSM));
2709 DECLR3CALLBACKMEMBER(uint32_t, pfnSSMHandleVersion,(PSSMHANDLE pSSM));
2710 DECLR3CALLBACKMEMBER(const char *, pfnSSMHandleHostOSAndArch,(PSSMHANDLE pSSM));
2711 /** @} */
2712
2713 /**
2714 * Creates a timer.
2715 *
2716 * @returns VBox status.
2717 * @param pDevIns The device instance.
2718 * @param enmClock The clock to use on this timer.
2719 * @param pfnCallback Callback function.
2720 * @param pvUser User argument for the callback.
2721 * @param fFlags Flags, see TMTIMER_FLAGS_*.
2722 * @param pszDesc Pointer to description string which must stay around
2723 * until the timer is fully destroyed (i.e. a bit after TMTimerDestroy()).
2724 * @param ppTimer Where to store the timer on success.
2725 * @remarks Caller enters the device critical section prior to invoking the
2726 * callback.
2727 */
2728 DECLR3CALLBACKMEMBER(int, pfnTMTimerCreate,(PPDMDEVINS pDevIns, TMCLOCK enmClock, PFNTMTIMERDEV pfnCallback,
2729 void *pvUser, uint32_t fFlags, const char *pszDesc, PPTMTIMERR3 ppTimer));
2730
2731 /**
2732 * Creates a timer w/ a cross context handle.
2733 *
2734 * @returns VBox status.
2735 * @param pDevIns The device instance.
2736 * @param enmClock The clock to use on this timer.
2737 * @param pfnCallback Callback function.
2738 * @param pvUser User argument for the callback.
2739 * @param fFlags Flags, see TMTIMER_FLAGS_*.
2740 * @param pszDesc Pointer to description string which must stay around
2741 * until the timer is fully destroyed (i.e. a bit after TMTimerDestroy()).
2742 * @param phTimer Where to store the timer handle on success.
2743 * @remarks Caller enters the device critical section prior to invoking the
2744 * callback.
2745 */
2746 DECLR3CALLBACKMEMBER(int, pfnTimerCreate,(PPDMDEVINS pDevIns, TMCLOCK enmClock, PFNTMTIMERDEV pfnCallback,
2747 void *pvUser, uint32_t fFlags, const char *pszDesc, PTMTIMERHANDLE phTimer));
2748
2749 /**
2750 * Translates a timer handle to a pointer.
2751 *
2752 * @returns The time address.
2753 * @param pDevIns The device instance.
2754 * @param hTimer The timer handle.
2755 */
2756 DECLR3CALLBACKMEMBER(PTMTIMERR3, pfnTimerToPtr,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer));
2757
2758 /** @name Timer handle method wrappers
2759 * @{ */
2760 DECLR3CALLBACKMEMBER(uint64_t, pfnTimerFromMicro,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint64_t cMicroSecs));
2761 DECLR3CALLBACKMEMBER(uint64_t, pfnTimerFromMilli,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint64_t cMilliSecs));
2762 DECLR3CALLBACKMEMBER(uint64_t, pfnTimerFromNano,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint64_t cNanoSecs));
2763 DECLR3CALLBACKMEMBER(uint64_t, pfnTimerGet,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer));
2764 DECLR3CALLBACKMEMBER(uint64_t, pfnTimerGetFreq,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer));
2765 DECLR3CALLBACKMEMBER(uint64_t, pfnTimerGetNano,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer));
2766 DECLR3CALLBACKMEMBER(bool, pfnTimerIsActive,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer));
2767 DECLR3CALLBACKMEMBER(bool, pfnTimerIsLockOwner,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer));
2768 DECLR3CALLBACKMEMBER(VBOXSTRICTRC, pfnTimerLockClock,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, int rcBusy));
2769 /** Takes the clock lock then enters the specified critical section. */
2770 DECLR3CALLBACKMEMBER(VBOXSTRICTRC, pfnTimerLockClock2,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, PPDMCRITSECT pCritSect, int rcBusy));
2771 DECLR3CALLBACKMEMBER(int, pfnTimerSet,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint64_t uExpire));
2772 DECLR3CALLBACKMEMBER(int, pfnTimerSetFrequencyHint,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint32_t uHz));
2773 DECLR3CALLBACKMEMBER(int, pfnTimerSetMicro,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint64_t cMicrosToNext));
2774 DECLR3CALLBACKMEMBER(int, pfnTimerSetMillies,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint64_t cMilliesToNext));
2775 DECLR3CALLBACKMEMBER(int, pfnTimerSetNano,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint64_t cNanosToNext));
2776 DECLR3CALLBACKMEMBER(int, pfnTimerSetRelative,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint64_t cTicksToNext, uint64_t *pu64Now));
2777 DECLR3CALLBACKMEMBER(int, pfnTimerStop,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer));
2778 DECLR3CALLBACKMEMBER(void, pfnTimerUnlockClock,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer));
2779 DECLR3CALLBACKMEMBER(void, pfnTimerUnlockClock2,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, PPDMCRITSECT pCritSect));
2780 DECLR3CALLBACKMEMBER(int, pfnTimerSetCritSect,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, PPDMCRITSECT pCritSect));
2781 DECLR3CALLBACKMEMBER(int, pfnTimerSave,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, PSSMHANDLE pSSM));
2782 DECLR3CALLBACKMEMBER(int, pfnTimerLoad,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, PSSMHANDLE pSSM));
2783 DECLR3CALLBACKMEMBER(int, pfnTimerDestroy,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer));
2784 /** @sa TMR3TimerSkip */
2785 DECLR3CALLBACKMEMBER(int, pfnTimerSkipLoad,(PSSMHANDLE pSSM, bool *pfActive));
2786 /** @} */
2787
2788 /**
2789 * Get the real world UTC time adjusted for VM lag, user offset and warpdrive.
2790 *
2791 * @returns pTime.
2792 * @param pDevIns The device instance.
2793 * @param pTime Where to store the time.
2794 */
2795 DECLR3CALLBACKMEMBER(PRTTIMESPEC, pfnTMUtcNow,(PPDMDEVINS pDevIns, PRTTIMESPEC pTime));
2796
2797 /** @name Exported CFGM Functions.
2798 * @{ */
2799 DECLR3CALLBACKMEMBER(bool, pfnCFGMExists,( PCFGMNODE pNode, const char *pszName));
2800 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryType,( PCFGMNODE pNode, const char *pszName, PCFGMVALUETYPE penmType));
2801 DECLR3CALLBACKMEMBER(int, pfnCFGMQuerySize,( PCFGMNODE pNode, const char *pszName, size_t *pcb));
2802 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryInteger,( PCFGMNODE pNode, const char *pszName, uint64_t *pu64));
2803 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryIntegerDef,( PCFGMNODE pNode, const char *pszName, uint64_t *pu64, uint64_t u64Def));
2804 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryString,( PCFGMNODE pNode, const char *pszName, char *pszString, size_t cchString));
2805 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryStringDef,( PCFGMNODE pNode, const char *pszName, char *pszString, size_t cchString, const char *pszDef));
2806 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryBytes,( PCFGMNODE pNode, const char *pszName, void *pvData, size_t cbData));
2807 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryU64,( PCFGMNODE pNode, const char *pszName, uint64_t *pu64));
2808 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryU64Def,( PCFGMNODE pNode, const char *pszName, uint64_t *pu64, uint64_t u64Def));
2809 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryS64,( PCFGMNODE pNode, const char *pszName, int64_t *pi64));
2810 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryS64Def,( PCFGMNODE pNode, const char *pszName, int64_t *pi64, int64_t i64Def));
2811 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryU32,( PCFGMNODE pNode, const char *pszName, uint32_t *pu32));
2812 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryU32Def,( PCFGMNODE pNode, const char *pszName, uint32_t *pu32, uint32_t u32Def));
2813 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryS32,( PCFGMNODE pNode, const char *pszName, int32_t *pi32));
2814 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryS32Def,( PCFGMNODE pNode, const char *pszName, int32_t *pi32, int32_t i32Def));
2815 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryU16,( PCFGMNODE pNode, const char *pszName, uint16_t *pu16));
2816 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryU16Def,( PCFGMNODE pNode, const char *pszName, uint16_t *pu16, uint16_t u16Def));
2817 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryS16,( PCFGMNODE pNode, const char *pszName, int16_t *pi16));
2818 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryS16Def,( PCFGMNODE pNode, const char *pszName, int16_t *pi16, int16_t i16Def));
2819 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryU8,( PCFGMNODE pNode, const char *pszName, uint8_t *pu8));
2820 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryU8Def,( PCFGMNODE pNode, const char *pszName, uint8_t *pu8, uint8_t u8Def));
2821 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryS8,( PCFGMNODE pNode, const char *pszName, int8_t *pi8));
2822 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryS8Def,( PCFGMNODE pNode, const char *pszName, int8_t *pi8, int8_t i8Def));
2823 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryBool,( PCFGMNODE pNode, const char *pszName, bool *pf));
2824 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryBoolDef,( PCFGMNODE pNode, const char *pszName, bool *pf, bool fDef));
2825 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryPort,( PCFGMNODE pNode, const char *pszName, PRTIOPORT pPort));
2826 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryPortDef,( PCFGMNODE pNode, const char *pszName, PRTIOPORT pPort, RTIOPORT PortDef));
2827 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryUInt,( PCFGMNODE pNode, const char *pszName, unsigned int *pu));
2828 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryUIntDef,( PCFGMNODE pNode, const char *pszName, unsigned int *pu, unsigned int uDef));
2829 DECLR3CALLBACKMEMBER(int, pfnCFGMQuerySInt,( PCFGMNODE pNode, const char *pszName, signed int *pi));
2830 DECLR3CALLBACKMEMBER(int, pfnCFGMQuerySIntDef,( PCFGMNODE pNode, const char *pszName, signed int *pi, signed int iDef));
2831 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryPtr,( PCFGMNODE pNode, const char *pszName, void **ppv));
2832 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryPtrDef,( PCFGMNODE pNode, const char *pszName, void **ppv, void *pvDef));
2833 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryGCPtr,( PCFGMNODE pNode, const char *pszName, PRTGCPTR pGCPtr));
2834 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryGCPtrDef,( PCFGMNODE pNode, const char *pszName, PRTGCPTR pGCPtr, RTGCPTR GCPtrDef));
2835 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryGCPtrU,( PCFGMNODE pNode, const char *pszName, PRTGCUINTPTR pGCPtr));
2836 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryGCPtrUDef,( PCFGMNODE pNode, const char *pszName, PRTGCUINTPTR pGCPtr, RTGCUINTPTR GCPtrDef));
2837 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryGCPtrS,( PCFGMNODE pNode, const char *pszName, PRTGCINTPTR pGCPtr));
2838 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryGCPtrSDef,( PCFGMNODE pNode, const char *pszName, PRTGCINTPTR pGCPtr, RTGCINTPTR GCPtrDef));
2839 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryStringAlloc,( PCFGMNODE pNode, const char *pszName, char **ppszString));
2840 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryStringAllocDef,(PCFGMNODE pNode, const char *pszName, char **ppszString, const char *pszDef));
2841 DECLR3CALLBACKMEMBER(PCFGMNODE, pfnCFGMGetParent,(PCFGMNODE pNode));
2842 DECLR3CALLBACKMEMBER(PCFGMNODE, pfnCFGMGetChild,(PCFGMNODE pNode, const char *pszPath));
2843 DECLR3CALLBACKMEMBER(PCFGMNODE, pfnCFGMGetChildF,(PCFGMNODE pNode, const char *pszPathFormat, ...) RT_IPRT_FORMAT_ATTR(2, 3));
2844 DECLR3CALLBACKMEMBER(PCFGMNODE, pfnCFGMGetChildFV,(PCFGMNODE pNode, const char *pszPathFormat, va_list Args) RT_IPRT_FORMAT_ATTR(3, 0));
2845 DECLR3CALLBACKMEMBER(PCFGMNODE, pfnCFGMGetFirstChild,(PCFGMNODE pNode));
2846 DECLR3CALLBACKMEMBER(PCFGMNODE, pfnCFGMGetNextChild,(PCFGMNODE pCur));
2847 DECLR3CALLBACKMEMBER(int, pfnCFGMGetName,(PCFGMNODE pCur, char *pszName, size_t cchName));
2848 DECLR3CALLBACKMEMBER(size_t, pfnCFGMGetNameLen,(PCFGMNODE pCur));
2849 DECLR3CALLBACKMEMBER(bool, pfnCFGMAreChildrenValid,(PCFGMNODE pNode, const char *pszzValid));
2850 DECLR3CALLBACKMEMBER(PCFGMLEAF, pfnCFGMGetFirstValue,(PCFGMNODE pCur));
2851 DECLR3CALLBACKMEMBER(PCFGMLEAF, pfnCFGMGetNextValue,(PCFGMLEAF pCur));
2852 DECLR3CALLBACKMEMBER(int, pfnCFGMGetValueName,(PCFGMLEAF pCur, char *pszName, size_t cchName));
2853 DECLR3CALLBACKMEMBER(size_t, pfnCFGMGetValueNameLen,(PCFGMLEAF pCur));
2854 DECLR3CALLBACKMEMBER(CFGMVALUETYPE, pfnCFGMGetValueType,(PCFGMLEAF pCur));
2855 DECLR3CALLBACKMEMBER(bool, pfnCFGMAreValuesValid,(PCFGMNODE pNode, const char *pszzValid));
2856 DECLR3CALLBACKMEMBER(int, pfnCFGMValidateConfig,(PCFGMNODE pNode, const char *pszNode,
2857 const char *pszValidValues, const char *pszValidNodes,
2858 const char *pszWho, uint32_t uInstance));
2859 /** @} */
2860
2861 /**
2862 * Read physical memory.
2863 *
2864 * @returns VINF_SUCCESS (for now).
2865 * @param pDevIns The device instance.
2866 * @param GCPhys Physical address start reading from.
2867 * @param pvBuf Where to put the read bits.
2868 * @param cbRead How many bytes to read.
2869 * @param fFlags Combination of PDM_DEVHLP_PHYS_RW_F_XXX.
2870 * @thread Any thread, but the call may involve the emulation thread.
2871 */
2872 DECLR3CALLBACKMEMBER(int, pfnPhysRead,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead, uint32_t fFlags));
2873
2874 /**
2875 * Write to physical memory.
2876 *
2877 * @returns VINF_SUCCESS for now, and later maybe VERR_EM_MEMORY.
2878 * @param pDevIns The device instance.
2879 * @param GCPhys Physical address to write to.
2880 * @param pvBuf What to write.
2881 * @param cbWrite How many bytes to write.
2882 * @param fFlags Combination of PDM_DEVHLP_PHYS_RW_F_XXX.
2883 * @thread Any thread, but the call may involve the emulation thread.
2884 */
2885 DECLR3CALLBACKMEMBER(int, pfnPhysWrite,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite, uint32_t fFlags));
2886
2887 /**
2888 * Requests the mapping of a guest page into ring-3.
2889 *
2890 * When you're done with the page, call pfnPhysReleasePageMappingLock() ASAP to
2891 * release it.
2892 *
2893 * This API will assume your intention is to write to the page, and will
2894 * therefore replace shared and zero pages. If you do not intend to modify the
2895 * page, use the pfnPhysGCPhys2CCPtrReadOnly() API.
2896 *
2897 * @returns VBox status code.
2898 * @retval VINF_SUCCESS on success.
2899 * @retval VERR_PGM_PHYS_PAGE_RESERVED it it's a valid page but has no physical
2900 * backing or if the page has any active access handlers. The caller
2901 * must fall back on using PGMR3PhysWriteExternal.
2902 * @retval VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS if it's not a valid physical address.
2903 *
2904 * @param pDevIns The device instance.
2905 * @param GCPhys The guest physical address of the page that
2906 * should be mapped.
2907 * @param fFlags Flags reserved for future use, MBZ.
2908 * @param ppv Where to store the address corresponding to
2909 * GCPhys.
2910 * @param pLock Where to store the lock information that
2911 * pfnPhysReleasePageMappingLock needs.
2912 *
2913 * @remark Avoid calling this API from within critical sections (other than the
2914 * PGM one) because of the deadlock risk when we have to delegating the
2915 * task to an EMT.
2916 * @thread Any.
2917 */
2918 DECLR3CALLBACKMEMBER(int, pfnPhysGCPhys2CCPtr,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, uint32_t fFlags, void **ppv,
2919 PPGMPAGEMAPLOCK pLock));
2920
2921 /**
2922 * Requests the mapping of a guest page into ring-3, external threads.
2923 *
2924 * When you're done with the page, call pfnPhysReleasePageMappingLock() ASAP to
2925 * release it.
2926 *
2927 * @returns VBox status code.
2928 * @retval VINF_SUCCESS on success.
2929 * @retval VERR_PGM_PHYS_PAGE_RESERVED it it's a valid page but has no physical
2930 * backing or if the page as an active ALL access handler. The caller
2931 * must fall back on using PGMPhysRead.
2932 * @retval VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS if it's not a valid physical address.
2933 *
2934 * @param pDevIns The device instance.
2935 * @param GCPhys The guest physical address of the page that
2936 * should be mapped.
2937 * @param fFlags Flags reserved for future use, MBZ.
2938 * @param ppv Where to store the address corresponding to
2939 * GCPhys.
2940 * @param pLock Where to store the lock information that
2941 * pfnPhysReleasePageMappingLock needs.
2942 *
2943 * @remark Avoid calling this API from within critical sections.
2944 * @thread Any.
2945 */
2946 DECLR3CALLBACKMEMBER(int, pfnPhysGCPhys2CCPtrReadOnly,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, uint32_t fFlags,
2947 void const **ppv, PPGMPAGEMAPLOCK pLock));
2948
2949 /**
2950 * Release the mapping of a guest page.
2951 *
2952 * This is the counter part of pfnPhysGCPhys2CCPtr and
2953 * pfnPhysGCPhys2CCPtrReadOnly.
2954 *
2955 * @param pDevIns The device instance.
2956 * @param pLock The lock structure initialized by the mapping
2957 * function.
2958 */
2959 DECLR3CALLBACKMEMBER(void, pfnPhysReleasePageMappingLock,(PPDMDEVINS pDevIns, PPGMPAGEMAPLOCK pLock));
2960
2961 /**
2962 * Read guest physical memory by virtual address.
2963 *
2964 * @param pDevIns The device instance.
2965 * @param pvDst Where to put the read bits.
2966 * @param GCVirtSrc Guest virtual address to start reading from.
2967 * @param cb How many bytes to read.
2968 * @thread The emulation thread.
2969 */
2970 DECLR3CALLBACKMEMBER(int, pfnPhysReadGCVirt,(PPDMDEVINS pDevIns, void *pvDst, RTGCPTR GCVirtSrc, size_t cb));
2971
2972 /**
2973 * Write to guest physical memory by virtual address.
2974 *
2975 * @param pDevIns The device instance.
2976 * @param GCVirtDst Guest virtual address to write to.
2977 * @param pvSrc What to write.
2978 * @param cb How many bytes to write.
2979 * @thread The emulation thread.
2980 */
2981 DECLR3CALLBACKMEMBER(int, pfnPhysWriteGCVirt,(PPDMDEVINS pDevIns, RTGCPTR GCVirtDst, const void *pvSrc, size_t cb));
2982
2983 /**
2984 * Convert a guest virtual address to a guest physical address.
2985 *
2986 * @returns VBox status code.
2987 * @param pDevIns The device instance.
2988 * @param GCPtr Guest virtual address.
2989 * @param pGCPhys Where to store the GC physical address
2990 * corresponding to GCPtr.
2991 * @thread The emulation thread.
2992 * @remark Careful with page boundaries.
2993 */
2994 DECLR3CALLBACKMEMBER(int, pfnPhysGCPtr2GCPhys, (PPDMDEVINS pDevIns, RTGCPTR GCPtr, PRTGCPHYS pGCPhys));
2995
2996 /**
2997 * Allocate memory which is associated with current VM instance
2998 * and automatically freed on it's destruction.
2999 *
3000 * @returns Pointer to allocated memory. The memory is *NOT* zero-ed.
3001 * @param pDevIns The device instance.
3002 * @param cb Number of bytes to allocate.
3003 */
3004 DECLR3CALLBACKMEMBER(void *, pfnMMHeapAlloc,(PPDMDEVINS pDevIns, size_t cb));
3005
3006 /**
3007 * Allocate memory which is associated with current VM instance
3008 * and automatically freed on it's destruction. The memory is ZEROed.
3009 *
3010 * @returns Pointer to allocated memory. The memory is *NOT* zero-ed.
3011 * @param pDevIns The device instance.
3012 * @param cb Number of bytes to allocate.
3013 */
3014 DECLR3CALLBACKMEMBER(void *, pfnMMHeapAllocZ,(PPDMDEVINS pDevIns, size_t cb));
3015
3016 /**
3017 * Free memory allocated with pfnMMHeapAlloc() and pfnMMHeapAllocZ().
3018 *
3019 * @param pDevIns The device instance.
3020 * @param pv Pointer to the memory to free.
3021 */
3022 DECLR3CALLBACKMEMBER(void, pfnMMHeapFree,(PPDMDEVINS pDevIns, void *pv));
3023
3024 /**
3025 * Gets the VM state.
3026 *
3027 * @returns VM state.
3028 * @param pDevIns The device instance.
3029 * @thread Any thread (just keep in mind that it's volatile info).
3030 */
3031 DECLR3CALLBACKMEMBER(VMSTATE, pfnVMState, (PPDMDEVINS pDevIns));
3032
3033 /**
3034 * Checks if the VM was teleported and hasn't been fully resumed yet.
3035 *
3036 * @returns true / false.
3037 * @param pDevIns The device instance.
3038 * @thread Any thread.
3039 */
3040 DECLR3CALLBACKMEMBER(bool, pfnVMTeleportedAndNotFullyResumedYet,(PPDMDEVINS pDevIns));
3041
3042 /**
3043 * Set the VM error message
3044 *
3045 * @returns rc.
3046 * @param pDevIns The device instance.
3047 * @param rc VBox status code.
3048 * @param SRC_POS Use RT_SRC_POS.
3049 * @param pszFormat Error message format string.
3050 * @param ... Error message arguments.
3051 */
3052 DECLR3CALLBACKMEMBER(int, pfnVMSetError,(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL,
3053 const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(6, 7));
3054
3055 /**
3056 * Set the VM error message
3057 *
3058 * @returns rc.
3059 * @param pDevIns The device instance.
3060 * @param rc VBox status code.
3061 * @param SRC_POS Use RT_SRC_POS.
3062 * @param pszFormat Error message format string.
3063 * @param va Error message arguments.
3064 */
3065 DECLR3CALLBACKMEMBER(int, pfnVMSetErrorV,(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL,
3066 const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(6, 0));
3067
3068 /**
3069 * Set the VM runtime error message
3070 *
3071 * @returns VBox status code.
3072 * @param pDevIns The device instance.
3073 * @param fFlags The action flags. See VMSETRTERR_FLAGS_*.
3074 * @param pszErrorId Error ID string.
3075 * @param pszFormat Error message format string.
3076 * @param ... Error message arguments.
3077 */
3078 DECLR3CALLBACKMEMBER(int, pfnVMSetRuntimeError,(PPDMDEVINS pDevIns, uint32_t fFlags, const char *pszErrorId,
3079 const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(4, 5));
3080
3081 /**
3082 * Set the VM runtime error message
3083 *
3084 * @returns VBox status code.
3085 * @param pDevIns The device instance.
3086 * @param fFlags The action flags. See VMSETRTERR_FLAGS_*.
3087 * @param pszErrorId Error ID string.
3088 * @param pszFormat Error message format string.
3089 * @param va Error message arguments.
3090 */
3091 DECLR3CALLBACKMEMBER(int, pfnVMSetRuntimeErrorV,(PPDMDEVINS pDevIns, uint32_t fFlags, const char *pszErrorId,
3092 const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(4, 0));
3093
3094 /**
3095 * Stops the VM and enters the debugger to look at the guest state.
3096 *
3097 * Use the PDMDeviceDBGFStop() inline function with the RT_SRC_POS macro instead of
3098 * invoking this function directly.
3099 *
3100 * @returns VBox status code which must be passed up to the VMM.
3101 * @param pDevIns The device instance.
3102 * @param pszFile Filename of the assertion location.
3103 * @param iLine The linenumber of the assertion location.
3104 * @param pszFunction Function of the assertion location.
3105 * @param pszFormat Message. (optional)
3106 * @param args Message parameters.
3107 */
3108 DECLR3CALLBACKMEMBER(int, pfnDBGFStopV,(PPDMDEVINS pDevIns, const char *pszFile, unsigned iLine, const char *pszFunction,
3109 const char *pszFormat, va_list args) RT_IPRT_FORMAT_ATTR(5, 0));
3110
3111 /**
3112 * Register a info handler with DBGF.
3113 *
3114 * @returns VBox status code.
3115 * @param pDevIns The device instance.
3116 * @param pszName The identifier of the info.
3117 * @param pszDesc The description of the info and any arguments
3118 * the handler may take.
3119 * @param pfnHandler The handler function to be called to display the
3120 * info.
3121 */
3122 DECLR3CALLBACKMEMBER(int, pfnDBGFInfoRegister,(PPDMDEVINS pDevIns, const char *pszName, const char *pszDesc, PFNDBGFHANDLERDEV pfnHandler));
3123
3124 /**
3125 * Register a info handler with DBGF, argv style.
3126 *
3127 * @returns VBox status code.
3128 * @param pDevIns The device instance.
3129 * @param pszName The identifier of the info.
3130 * @param pszDesc The description of the info and any arguments
3131 * the handler may take.
3132 * @param pfnHandler The handler function to be called to display the
3133 * info.
3134 */
3135 DECLR3CALLBACKMEMBER(int, pfnDBGFInfoRegisterArgv,(PPDMDEVINS pDevIns, const char *pszName, const char *pszDesc, PFNDBGFINFOARGVDEV pfnHandler));
3136
3137 /**
3138 * Registers a set of registers for a device.
3139 *
3140 * The @a pvUser argument of the getter and setter callbacks will be
3141 * @a pDevIns. The register names will be prefixed by the device name followed
3142 * immediately by the instance number.
3143 *
3144 * @returns VBox status code.
3145 * @param pDevIns The device instance.
3146 * @param paRegisters The register descriptors.
3147 *
3148 * @remarks The device critical section is NOT entered prior to working the
3149 * callbacks registered via this helper!
3150 */
3151 DECLR3CALLBACKMEMBER(int, pfnDBGFRegRegister,(PPDMDEVINS pDevIns, PCDBGFREGDESC paRegisters));
3152
3153 /**
3154 * Gets the trace buffer handle.
3155 *
3156 * This is used by the macros found in VBox/vmm/dbgftrace.h and is not
3157 * really inteded for direct usage, thus no inline wrapper function.
3158 *
3159 * @returns Trace buffer handle or NIL_RTTRACEBUF.
3160 * @param pDevIns The device instance.
3161 */
3162 DECLR3CALLBACKMEMBER(RTTRACEBUF, pfnDBGFTraceBuf,(PPDMDEVINS pDevIns));
3163
3164 /**
3165 * Registers a statistics sample.
3166 *
3167 * @param pDevIns Device instance of the DMA.
3168 * @param pvSample Pointer to the sample.
3169 * @param enmType Sample type. This indicates what pvSample is
3170 * pointing at.
3171 * @param pszName Sample name, unix path style. If this does not
3172 * start with a '/', the default prefix will be
3173 * prepended, otherwise it will be used as-is.
3174 * @param enmUnit Sample unit.
3175 * @param pszDesc Sample description.
3176 */
3177 DECLR3CALLBACKMEMBER(void, pfnSTAMRegister,(PPDMDEVINS pDevIns, void *pvSample, STAMTYPE enmType, const char *pszName, STAMUNIT enmUnit, const char *pszDesc));
3178
3179 /**
3180 * Same as pfnSTAMRegister except that the name is specified in a
3181 * RTStrPrintfV like fashion.
3182 *
3183 * @returns VBox status.
3184 * @param pDevIns Device instance of the DMA.
3185 * @param pvSample Pointer to the sample.
3186 * @param enmType Sample type. This indicates what pvSample is
3187 * pointing at.
3188 * @param enmVisibility Visibility type specifying whether unused
3189 * statistics should be visible or not.
3190 * @param enmUnit Sample unit.
3191 * @param pszDesc Sample description.
3192 * @param pszName Sample name format string, unix path style. If
3193 * this does not start with a '/', the default
3194 * prefix will be prepended, otherwise it will be
3195 * used as-is.
3196 * @param args Arguments to the format string.
3197 */
3198 DECLR3CALLBACKMEMBER(void, pfnSTAMRegisterV,(PPDMDEVINS pDevIns, void *pvSample, STAMTYPE enmType,
3199 STAMVISIBILITY enmVisibility, STAMUNIT enmUnit, const char *pszDesc,
3200 const char *pszName, va_list args) RT_IPRT_FORMAT_ATTR(7, 0));
3201
3202 /**
3203 * Registers a PCI device with the default PCI bus.
3204 *
3205 * If a PDM device has more than one PCI device, they must be registered in the
3206 * order of PDMDEVINSR3::apPciDevs.
3207 *
3208 * @returns VBox status code.
3209 * @param pDevIns The device instance.
3210 * @param pPciDev The PCI device structure.
3211 * This must be kept in the instance data.
3212 * The PCI configuration must be initialized before registration.
3213 * @param fFlags 0, PDMPCIDEVREG_F_PCI_BRIDGE or
3214 * PDMPCIDEVREG_F_NOT_MANDATORY_NO.
3215 * @param uPciDevNo PDMPCIDEVREG_DEV_NO_FIRST_UNUSED,
3216 * PDMPCIDEVREG_DEV_NO_SAME_AS_PREV, or a specific
3217 * device number (0-31). This will be ignored if
3218 * the CFGM configuration contains a PCIDeviceNo
3219 * value.
3220 * @param uPciFunNo PDMPCIDEVREG_FUN_NO_FIRST_UNUSED, or a specific
3221 * function number (0-7). This will be ignored if
3222 * the CFGM configuration contains a PCIFunctionNo
3223 * value.
3224 * @param pszName Device name, if NULL PDMDEVREG::szName is used.
3225 * The pointer is saved, so don't free or changed.
3226 * @note The PCI device configuration is now implicit from the apPciDevs
3227 * index, meaning that the zero'th entry is the primary one and
3228 * subsequent uses CFGM subkeys "PciDev1", "PciDev2" and so on.
3229 */
3230 DECLR3CALLBACKMEMBER(int, pfnPCIRegister,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t fFlags,
3231 uint8_t uPciDevNo, uint8_t uPciFunNo, const char *pszName));
3232
3233 /**
3234 * Initialize MSI or MSI-X emulation support for the given PCI device.
3235 *
3236 * @see PDMPCIBUSREG::pfnRegisterMsiR3 for details.
3237 *
3238 * @returns VBox status code.
3239 * @param pDevIns The device instance.
3240 * @param pPciDev The PCI device. NULL is an alias for the first
3241 * one registered.
3242 * @param pMsiReg MSI emulation registration structure.
3243 */
3244 DECLR3CALLBACKMEMBER(int, pfnPCIRegisterMsi,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, PPDMMSIREG pMsiReg));
3245
3246 /**
3247 * Registers a I/O region (memory mapped or I/O ports) for a PCI device.
3248 *
3249 * @returns VBox status code.
3250 * @param pDevIns The device instance.
3251 * @param pPciDev The PCI device structure. If NULL the default
3252 * PCI device for this device instance is used.
3253 * @param iRegion The region number.
3254 * @param cbRegion Size of the region.
3255 * @param enmType PCI_ADDRESS_SPACE_MEM, PCI_ADDRESS_SPACE_IO or PCI_ADDRESS_SPACE_MEM_PREFETCH.
3256 * @param fFlags PDMPCIDEV_IORGN_F_XXX.
3257 * @param hHandle An I/O port, MMIO or MMIO2 handle according to
3258 * @a fFlags, UINT64_MAX if no handle is passed
3259 * (old style).
3260 * @param pfnMapUnmap Callback for doing the mapping, optional when a
3261 * handle is specified. The callback will be
3262 * invoked holding only the PDM lock. The device
3263 * lock will _not_ be taken (due to lock order).
3264 */
3265 DECLR3CALLBACKMEMBER(int, pfnPCIIORegionRegister,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion,
3266 RTGCPHYS cbRegion, PCIADDRESSSPACE enmType, uint32_t fFlags,
3267 uint64_t hHandle, PFNPCIIOREGIONMAP pfnMapUnmap));
3268
3269 /**
3270 * Register PCI configuration space read/write callbacks.
3271 *
3272 * @returns VBox status code.
3273 * @param pDevIns The device instance.
3274 * @param pPciDev The PCI device structure. If NULL the default
3275 * PCI device for this device instance is used.
3276 * @param pfnRead Pointer to the user defined PCI config read function.
3277 * to call default PCI config read function. Can be NULL.
3278 * @param pfnWrite Pointer to the user defined PCI config write function.
3279 * @remarks The callbacks will be invoked holding the PDM lock. The device lock
3280 * is NOT take because that is very likely be a lock order violation.
3281 * @thread EMT(0)
3282 * @note Only callable during VM creation.
3283 * @sa PDMDevHlpPCIConfigRead, PDMDevHlpPCIConfigWrite
3284 */
3285 DECLR3CALLBACKMEMBER(int, pfnPCIInterceptConfigAccesses,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev,
3286 PFNPCICONFIGREAD pfnRead, PFNPCICONFIGWRITE pfnWrite));
3287
3288 /**
3289 * Perform a PCI configuration space write.
3290 *
3291 * This is for devices that make use of PDMDevHlpPCIInterceptConfigAccesses().
3292 *
3293 * @returns Strict VBox status code (mainly DBGFSTOP).
3294 * @param pDevIns The device instance.
3295 * @param pPciDev The PCI device which config space is being read.
3296 * @param uAddress The config space address.
3297 * @param cb The size of the read: 1, 2 or 4 bytes.
3298 * @param u32Value The value to write.
3299 */
3300 DECLR3CALLBACKMEMBER(VBOXSTRICTRC, pfnPCIConfigWrite,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev,
3301 uint32_t uAddress, unsigned cb, uint32_t u32Value));
3302
3303 /**
3304 * Perform a PCI configuration space read.
3305 *
3306 * This is for devices that make use of PDMDevHlpPCIInterceptConfigAccesses().
3307 *
3308 * @returns Strict VBox status code (mainly DBGFSTOP).
3309 * @param pDevIns The device instance.
3310 * @param pPciDev The PCI device which config space is being read.
3311 * @param uAddress The config space address.
3312 * @param cb The size of the read: 1, 2 or 4 bytes.
3313 * @param pu32Value Where to return the value.
3314 */
3315 DECLR3CALLBACKMEMBER(VBOXSTRICTRC, pfnPCIConfigRead,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev,
3316 uint32_t uAddress, unsigned cb, uint32_t *pu32Value));
3317
3318 /**
3319 * Bus master physical memory read.
3320 *
3321 * @returns VINF_SUCCESS or VERR_PGM_PCI_PHYS_READ_BM_DISABLED, later maybe
3322 * VERR_EM_MEMORY. The informational status shall NOT be propagated!
3323 * @param pDevIns The device instance.
3324 * @param pPciDev The PCI device structure. If NULL the default
3325 * PCI device for this device instance is used.
3326 * @param GCPhys Physical address start reading from.
3327 * @param pvBuf Where to put the read bits.
3328 * @param cbRead How many bytes to read.
3329 * @param fFlags Combination of PDM_DEVHLP_PHYS_RW_F_XXX.
3330 * @thread Any thread, but the call may involve the emulation thread.
3331 */
3332 DECLR3CALLBACKMEMBER(int, pfnPCIPhysRead,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead, uint32_t fFlags));
3333
3334 /**
3335 * Bus master physical memory write.
3336 *
3337 * @returns VINF_SUCCESS or VERR_PGM_PCI_PHYS_WRITE_BM_DISABLED, later maybe
3338 * VERR_EM_MEMORY. The informational status shall NOT be propagated!
3339 * @param pDevIns The device instance.
3340 * @param pPciDev The PCI device structure. If NULL the default
3341 * PCI device for this device instance is used.
3342 * @param GCPhys Physical address to write to.
3343 * @param pvBuf What to write.
3344 * @param cbWrite How many bytes to write.
3345 * @param fFlags Combination of PDM_DEVHLP_PHYS_RW_F_XXX.
3346 * @thread Any thread, but the call may involve the emulation thread.
3347 */
3348 DECLR3CALLBACKMEMBER(int, pfnPCIPhysWrite,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite, uint32_t fFlags));
3349
3350 /**
3351 * Sets the IRQ for the given PCI device.
3352 *
3353 * @param pDevIns The device instance.
3354 * @param pPciDev The PCI device structure. If NULL the default
3355 * PCI device for this device instance is used.
3356 * @param iIrq IRQ number to set.
3357 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
3358 * @thread Any thread, but will involve the emulation thread.
3359 */
3360 DECLR3CALLBACKMEMBER(void, pfnPCISetIrq,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iIrq, int iLevel));
3361
3362 /**
3363 * Sets the IRQ for the given PCI device, but doesn't wait for EMT to process
3364 * the request when not called from EMT.
3365 *
3366 * @param pDevIns The device instance.
3367 * @param pPciDev The PCI device structure. If NULL the default
3368 * PCI device for this device instance is used.
3369 * @param iIrq IRQ number to set.
3370 * @param iLevel IRQ level.
3371 * @thread Any thread, but will involve the emulation thread.
3372 */
3373 DECLR3CALLBACKMEMBER(void, pfnPCISetIrqNoWait,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iIrq, int iLevel));
3374
3375 /**
3376 * Set ISA IRQ for a device.
3377 *
3378 * @param pDevIns The device instance.
3379 * @param iIrq IRQ number to set.
3380 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
3381 * @thread Any thread, but will involve the emulation thread.
3382 */
3383 DECLR3CALLBACKMEMBER(void, pfnISASetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
3384
3385 /**
3386 * Set the ISA IRQ for a device, but don't wait for EMT to process
3387 * the request when not called from EMT.
3388 *
3389 * @param pDevIns The device instance.
3390 * @param iIrq IRQ number to set.
3391 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
3392 * @thread Any thread, but will involve the emulation thread.
3393 */
3394 DECLR3CALLBACKMEMBER(void, pfnISASetIrqNoWait,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
3395
3396 /**
3397 * Attaches a driver (chain) to the device.
3398 *
3399 * The first call for a LUN this will serve as a registration of the LUN. The pBaseInterface and
3400 * the pszDesc string will be registered with that LUN and kept around for PDMR3QueryDeviceLun().
3401 *
3402 * @returns VBox status code.
3403 * @param pDevIns The device instance.
3404 * @param iLun The logical unit to attach.
3405 * @param pBaseInterface Pointer to the base interface for that LUN. (device side / down)
3406 * @param ppBaseInterface Where to store the pointer to the base interface. (driver side / up)
3407 * @param pszDesc Pointer to a string describing the LUN. This string must remain valid
3408 * for the live of the device instance.
3409 */
3410 DECLR3CALLBACKMEMBER(int, pfnDriverAttach,(PPDMDEVINS pDevIns, uint32_t iLun, PPDMIBASE pBaseInterface,
3411 PPDMIBASE *ppBaseInterface, const char *pszDesc));
3412
3413 /**
3414 * Detaches an attached driver (chain) from the device again.
3415 *
3416 * @returns VBox status code.
3417 * @param pDevIns The device instance.
3418 * @param pDrvIns The driver instance to detach.
3419 * @param fFlags Flags, combination of the PDMDEVATT_FLAGS_* \#defines.
3420 */
3421 DECLR3CALLBACKMEMBER(int, pfnDriverDetach,(PPDMDEVINS pDevIns, PPDMDRVINS pDrvIns, uint32_t fFlags));
3422
3423 /**
3424 * Reconfigures the driver chain for a LUN, detaching any driver currently
3425 * present there.
3426 *
3427 * Caller will have attach it, of course.
3428 *
3429 * @returns VBox status code.
3430 * @param pDevIns The device instance.
3431 * @param iLun The logical unit to reconfigure.
3432 * @param cDepth The depth of the driver chain. Determins the
3433 * size of @a papszDrivers and @a papConfigs.
3434 * @param papszDrivers The names of the drivers to configure in the
3435 * chain, first entry is the one immediately
3436 * below the device/LUN
3437 * @param papConfigs The configurations for each of the drivers
3438 * in @a papszDrivers array. NULL entries
3439 * corresponds to empty 'Config' nodes. This
3440 * function will take ownership of non-NULL
3441 * CFGM sub-trees and set the array member to
3442 * NULL, so the caller can do cleanups on
3443 * failure. This parameter is optional.
3444 * @param fFlags Reserved, MBZ.
3445 */
3446 DECLR3CALLBACKMEMBER(int, pfnDriverReconfigure,(PPDMDEVINS pDevIns, uint32_t iLun, uint32_t cDepth,
3447 const char * const *papszDrivers, PCFGMNODE *papConfigs, uint32_t fFlags));
3448
3449 /** @name Exported PDM Queue Functions
3450 * @{ */
3451 /**
3452 * Create a queue.
3453 *
3454 * @returns VBox status code.
3455 * @param pDevIns The device instance.
3456 * @param cbItem The size of a queue item.
3457 * @param cItems The number of items in the queue.
3458 * @param cMilliesInterval The number of milliseconds between polling the queue.
3459 * If 0 then the emulation thread will be notified whenever an item arrives.
3460 * @param pfnCallback The consumer function.
3461 * @param fRZEnabled Set if the queue should work in RC and R0.
3462 * @param pszName The queue base name. The instance number will be
3463 * appended automatically.
3464 * @param ppQueue Where to store the queue pointer on success.
3465 * @thread The emulation thread.
3466 * @remarks The device critical section will NOT be entered before calling the
3467 * callback. No locks will be held, but for now it's safe to assume
3468 * that only one EMT will do queue callbacks at any one time.
3469 */
3470 DECLR3CALLBACKMEMBER(int, pfnQueueCreatePtr,(PPDMDEVINS pDevIns, size_t cbItem, uint32_t cItems, uint32_t cMilliesInterval,
3471 PFNPDMQUEUEDEV pfnCallback, bool fRZEnabled, const char *pszName,
3472 PPDMQUEUE *ppQueue));
3473
3474 /**
3475 * Create a queue.
3476 *
3477 * @returns VBox status code.
3478 * @param pDevIns The device instance.
3479 * @param cbItem The size of a queue item.
3480 * @param cItems The number of items in the queue.
3481 * @param cMilliesInterval The number of milliseconds between polling the queue.
3482 * If 0 then the emulation thread will be notified whenever an item arrives.
3483 * @param pfnCallback The consumer function.
3484 * @param fRZEnabled Set if the queue should work in RC and R0.
3485 * @param pszName The queue base name. The instance number will be
3486 * appended automatically.
3487 * @param phQueue Where to store the queue handle on success.
3488 * @thread EMT(0)
3489 * @remarks The device critical section will NOT be entered before calling the
3490 * callback. No locks will be held, but for now it's safe to assume
3491 * that only one EMT will do queue callbacks at any one time.
3492 */
3493 DECLR3CALLBACKMEMBER(int, pfnQueueCreate,(PPDMDEVINS pDevIns, size_t cbItem, uint32_t cItems, uint32_t cMilliesInterval,
3494 PFNPDMQUEUEDEV pfnCallback, bool fRZEnabled, const char *pszName,
3495 PDMQUEUEHANDLE *phQueue));
3496
3497 DECLR3CALLBACKMEMBER(PPDMQUEUE, pfnQueueToPtr,(PPDMDEVINS pDevIns, PDMQUEUEHANDLE hQueue));
3498 DECLR3CALLBACKMEMBER(PPDMQUEUEITEMCORE, pfnQueueAlloc,(PPDMDEVINS pDevIns, PDMQUEUEHANDLE hQueue));
3499 DECLR3CALLBACKMEMBER(void, pfnQueueInsert,(PPDMDEVINS pDevIns, PDMQUEUEHANDLE hQueue, PPDMQUEUEITEMCORE pItem));
3500 DECLR3CALLBACKMEMBER(void, pfnQueueInsertEx,(PPDMDEVINS pDevIns, PDMQUEUEHANDLE hQueue, PPDMQUEUEITEMCORE pItem, uint64_t cNanoMaxDelay));
3501 DECLR3CALLBACKMEMBER(bool, pfnQueueFlushIfNecessary,(PPDMDEVINS pDevIns, PDMQUEUEHANDLE hQueue));
3502 /** @} */
3503
3504 /** @name PDM Task
3505 * @{ */
3506 /**
3507 * Create an asynchronous ring-3 task.
3508 *
3509 * @returns VBox status code.
3510 * @param pDevIns The device instance.
3511 * @param fFlags PDMTASK_F_XXX
3512 * @param pszName The function name or similar. Used for statistics,
3513 * so no slashes.
3514 * @param pfnCallback The task function.
3515 * @param pvUser User argument for the task function.
3516 * @param phTask Where to return the task handle.
3517 * @thread EMT(0)
3518 */
3519 DECLR3CALLBACKMEMBER(int, pfnTaskCreate,(PPDMDEVINS pDevIns, uint32_t fFlags, const char *pszName,
3520 PFNPDMTASKDEV pfnCallback, void *pvUser, PDMTASKHANDLE *phTask));
3521 /**
3522 * Triggers the running the given task.
3523 *
3524 * @returns VBox status code.
3525 * @retval VINF_ALREADY_POSTED is the task is already pending.
3526 * @param pDevIns The device instance.
3527 * @param hTask The task to trigger.
3528 * @thread Any thread.
3529 */
3530 DECLR3CALLBACKMEMBER(int, pfnTaskTrigger,(PPDMDEVINS pDevIns, PDMTASKHANDLE hTask));
3531 /** @} */
3532
3533 /** @name SUP Event Semaphore Wrappers (single release / auto reset)
3534 * These semaphores can be signalled from ring-0.
3535 * @{ */
3536 /** @sa SUPSemEventCreate */
3537 DECLR3CALLBACKMEMBER(int, pfnSUPSemEventCreate,(PPDMDEVINS pDevIns, PSUPSEMEVENT phEvent));
3538 /** @sa SUPSemEventClose */
3539 DECLR3CALLBACKMEMBER(int, pfnSUPSemEventClose,(PPDMDEVINS pDevIns, SUPSEMEVENT hEvent));
3540 /** @sa SUPSemEventSignal */
3541 DECLR3CALLBACKMEMBER(int, pfnSUPSemEventSignal,(PPDMDEVINS pDevIns, SUPSEMEVENT hEvent));
3542 /** @sa SUPSemEventWaitNoResume */
3543 DECLR3CALLBACKMEMBER(int, pfnSUPSemEventWaitNoResume,(PPDMDEVINS pDevIns, SUPSEMEVENT hEvent, uint32_t cMillies));
3544 /** @sa SUPSemEventWaitNsAbsIntr */
3545 DECLR3CALLBACKMEMBER(int, pfnSUPSemEventWaitNsAbsIntr,(PPDMDEVINS pDevIns, SUPSEMEVENT hEvent, uint64_t uNsTimeout));
3546 /** @sa SUPSemEventWaitNsRelIntr */
3547 DECLR3CALLBACKMEMBER(int, pfnSUPSemEventWaitNsRelIntr,(PPDMDEVINS pDevIns, SUPSEMEVENT hEvent, uint64_t cNsTimeout));
3548 /** @sa SUPSemEventGetResolution */
3549 DECLR3CALLBACKMEMBER(uint32_t, pfnSUPSemEventGetResolution,(PPDMDEVINS pDevIns));
3550 /** @} */
3551
3552 /** @name SUP Multi Event Semaphore Wrappers (multiple release / manual reset)
3553 * These semaphores can be signalled from ring-0.
3554 * @{ */
3555 /** @sa SUPSemEventMultiCreate */
3556 DECLR3CALLBACKMEMBER(int, pfnSUPSemEventMultiCreate,(PPDMDEVINS pDevIns, PSUPSEMEVENTMULTI phEventMulti));
3557 /** @sa SUPSemEventMultiClose */
3558 DECLR3CALLBACKMEMBER(int, pfnSUPSemEventMultiClose,(PPDMDEVINS pDevIns, SUPSEMEVENTMULTI hEventMulti));
3559 /** @sa SUPSemEventMultiSignal */
3560 DECLR3CALLBACKMEMBER(int, pfnSUPSemEventMultiSignal,(PPDMDEVINS pDevIns, SUPSEMEVENTMULTI hEventMulti));
3561 /** @sa SUPSemEventMultiReset */
3562 DECLR3CALLBACKMEMBER(int, pfnSUPSemEventMultiReset,(PPDMDEVINS pDevIns, SUPSEMEVENTMULTI hEventMulti));
3563 /** @sa SUPSemEventMultiWaitNoResume */
3564 DECLR3CALLBACKMEMBER(int, pfnSUPSemEventMultiWaitNoResume,(PPDMDEVINS pDevIns, SUPSEMEVENTMULTI hEventMulti, uint32_t cMillies));
3565 /** @sa SUPSemEventMultiWaitNsAbsIntr */
3566 DECLR3CALLBACKMEMBER(int, pfnSUPSemEventMultiWaitNsAbsIntr,(PPDMDEVINS pDevIns, SUPSEMEVENTMULTI hEventMulti, uint64_t uNsTimeout));
3567 /** @sa SUPSemEventMultiWaitNsRelIntr */
3568 DECLR3CALLBACKMEMBER(int, pfnSUPSemEventMultiWaitNsRelIntr,(PPDMDEVINS pDevIns, SUPSEMEVENTMULTI hEventMulti, uint64_t cNsTimeout));
3569 /** @sa SUPSemEventMultiGetResolution */
3570 DECLR3CALLBACKMEMBER(uint32_t, pfnSUPSemEventMultiGetResolution,(PPDMDEVINS pDevIns));
3571 /** @} */
3572
3573 /**
3574 * Initializes a PDM critical section.
3575 *
3576 * The PDM critical sections are derived from the IPRT critical sections, but
3577 * works in RC and R0 as well.
3578 *
3579 * @returns VBox status code.
3580 * @param pDevIns The device instance.
3581 * @param pCritSect Pointer to the critical section.
3582 * @param SRC_POS Use RT_SRC_POS.
3583 * @param pszNameFmt Format string for naming the critical section.
3584 * For statistics and lock validation.
3585 * @param va Arguments for the format string.
3586 */
3587 DECLR3CALLBACKMEMBER(int, pfnCritSectInit,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, RT_SRC_POS_DECL,
3588 const char *pszNameFmt, va_list va) RT_IPRT_FORMAT_ATTR(6, 0));
3589
3590 /**
3591 * Gets the NOP critical section.
3592 *
3593 * @returns The ring-3 address of the NOP critical section.
3594 * @param pDevIns The device instance.
3595 */
3596 DECLR3CALLBACKMEMBER(PPDMCRITSECT, pfnCritSectGetNop,(PPDMDEVINS pDevIns));
3597
3598 /**
3599 * Gets the NOP critical section.
3600 *
3601 * @returns The ring-0 address of the NOP critical section.
3602 * @param pDevIns The device instance.
3603 * @deprecated
3604 */
3605 DECLR3CALLBACKMEMBER(R0PTRTYPE(PPDMCRITSECT), pfnCritSectGetNopR0,(PPDMDEVINS pDevIns));
3606
3607 /**
3608 * Gets the NOP critical section.
3609 *
3610 * @returns The raw-mode context address of the NOP critical section.
3611 * @param pDevIns The device instance.
3612 * @deprecated
3613 */
3614 DECLR3CALLBACKMEMBER(RCPTRTYPE(PPDMCRITSECT), pfnCritSectGetNopRC,(PPDMDEVINS pDevIns));
3615
3616 /**
3617 * Changes the device level critical section from the automatically created
3618 * default to one desired by the device constructor.
3619 *
3620 * For ring-0 and raw-mode capable devices, the call must be repeated in each of
3621 * the additional contexts.
3622 *
3623 * @returns VBox status code.
3624 * @param pDevIns The device instance.
3625 * @param pCritSect The critical section to use. NULL is not
3626 * valid, instead use the NOP critical
3627 * section.
3628 */
3629 DECLR3CALLBACKMEMBER(int, pfnSetDeviceCritSect,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect));
3630
3631 /** @name Exported PDM Critical Section Functions
3632 * @{ */
3633 DECLR3CALLBACKMEMBER(bool, pfnCritSectYield,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect));
3634 DECLR3CALLBACKMEMBER(int, pfnCritSectEnter,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, int rcBusy));
3635 DECLR3CALLBACKMEMBER(int, pfnCritSectEnterDebug,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, int rcBusy, RTHCUINTPTR uId, RT_SRC_POS_DECL));
3636 DECLR3CALLBACKMEMBER(int, pfnCritSectTryEnter,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect));
3637 DECLR3CALLBACKMEMBER(int, pfnCritSectTryEnterDebug,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, RTHCUINTPTR uId, RT_SRC_POS_DECL));
3638 DECLR3CALLBACKMEMBER(int, pfnCritSectLeave,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect));
3639 DECLR3CALLBACKMEMBER(bool, pfnCritSectIsOwner,(PPDMDEVINS pDevIns, PCPDMCRITSECT pCritSect));
3640 DECLR3CALLBACKMEMBER(bool, pfnCritSectIsInitialized,(PPDMDEVINS pDevIns, PCPDMCRITSECT pCritSect));
3641 DECLR3CALLBACKMEMBER(bool, pfnCritSectHasWaiters,(PPDMDEVINS pDevIns, PCPDMCRITSECT pCritSect));
3642 DECLR3CALLBACKMEMBER(uint32_t, pfnCritSectGetRecursion,(PPDMDEVINS pDevIns, PCPDMCRITSECT pCritSect));
3643 DECLR3CALLBACKMEMBER(int, pfnCritSectScheduleExitEvent,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, SUPSEMEVENT hEventToSignal));
3644 DECLR3CALLBACKMEMBER(int, pfnCritSectDelete,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect));
3645 /** @} */
3646
3647 /**
3648 * Creates a PDM thread.
3649 *
3650 * This differs from the RTThreadCreate() API in that PDM takes care of suspending,
3651 * resuming, and destroying the thread as the VM state changes.
3652 *
3653 * @returns VBox status code.
3654 * @param pDevIns The device instance.
3655 * @param ppThread Where to store the thread 'handle'.
3656 * @param pvUser The user argument to the thread function.
3657 * @param pfnThread The thread function.
3658 * @param pfnWakeup The wakup callback. This is called on the EMT
3659 * thread when a state change is pending.
3660 * @param cbStack See RTThreadCreate.
3661 * @param enmType See RTThreadCreate.
3662 * @param pszName See RTThreadCreate.
3663 * @remarks The device critical section will NOT be entered prior to invoking
3664 * the function pointers.
3665 */
3666 DECLR3CALLBACKMEMBER(int, pfnThreadCreate,(PPDMDEVINS pDevIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADDEV pfnThread,
3667 PFNPDMTHREADWAKEUPDEV pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName));
3668
3669 /** @name Exported PDM Thread Functions
3670 * @{ */
3671 DECLR3CALLBACKMEMBER(int, pfnThreadDestroy,(PPDMTHREAD pThread, int *pRcThread));
3672 DECLR3CALLBACKMEMBER(int, pfnThreadIAmSuspending,(PPDMTHREAD pThread));
3673 DECLR3CALLBACKMEMBER(int, pfnThreadIAmRunning,(PPDMTHREAD pThread));
3674 DECLR3CALLBACKMEMBER(int, pfnThreadSleep,(PPDMTHREAD pThread, RTMSINTERVAL cMillies));
3675 DECLR3CALLBACKMEMBER(int, pfnThreadSuspend,(PPDMTHREAD pThread));
3676 DECLR3CALLBACKMEMBER(int, pfnThreadResume,(PPDMTHREAD pThread));
3677 /** @} */
3678
3679 /**
3680 * Set up asynchronous handling of a suspend, reset or power off notification.
3681 *
3682 * This shall only be called when getting the notification. It must be called
3683 * for each one.
3684 *
3685 * @returns VBox status code.
3686 * @param pDevIns The device instance.
3687 * @param pfnAsyncNotify The callback.
3688 * @thread EMT(0)
3689 * @remarks The caller will enter the device critical section prior to invoking
3690 * the callback.
3691 */
3692 DECLR3CALLBACKMEMBER(int, pfnSetAsyncNotification, (PPDMDEVINS pDevIns, PFNPDMDEVASYNCNOTIFY pfnAsyncNotify));
3693
3694 /**
3695 * Notify EMT(0) that the device has completed the asynchronous notification
3696 * handling.
3697 *
3698 * This can be called at any time, spurious calls will simply be ignored.
3699 *
3700 * @param pDevIns The device instance.
3701 * @thread Any
3702 */
3703 DECLR3CALLBACKMEMBER(void, pfnAsyncNotificationCompleted, (PPDMDEVINS pDevIns));
3704
3705 /**
3706 * Register the RTC device.
3707 *
3708 * @returns VBox status code.
3709 * @param pDevIns The device instance.
3710 * @param pRtcReg Pointer to a RTC registration structure.
3711 * @param ppRtcHlp Where to store the pointer to the helper
3712 * functions.
3713 */
3714 DECLR3CALLBACKMEMBER(int, pfnRTCRegister,(PPDMDEVINS pDevIns, PCPDMRTCREG pRtcReg, PCPDMRTCHLP *ppRtcHlp));
3715
3716 /**
3717 * Register a PCI Bus.
3718 *
3719 * @returns VBox status code, but the positive values 0..31 are used to indicate
3720 * bus number rather than informational status codes.
3721 * @param pDevIns The device instance.
3722 * @param pPciBusReg Pointer to PCI bus registration structure.
3723 * @param ppPciHlp Where to store the pointer to the PCI Bus
3724 * helpers.
3725 * @param piBus Where to return the PDM bus number. Optional.
3726 */
3727 DECLR3CALLBACKMEMBER(int, pfnPCIBusRegister,(PPDMDEVINS pDevIns, PPDMPCIBUSREGR3 pPciBusReg,
3728 PCPDMPCIHLPR3 *ppPciHlp, uint32_t *piBus));
3729
3730 /**
3731 * Register the IOMMU device.
3732 *
3733 * @returns VBox status code.
3734 * @param pDevIns The device instance.
3735 * @param pIommuReg Pointer to a IOMMU registration structure.
3736 * @param ppIommuHlp Where to store the pointer to the ring-3 IOMMU
3737 * helpers.
3738 * @param pidxIommu Where to return the IOMMU index. Optional.
3739 */
3740 DECLR3CALLBACKMEMBER(int, pfnIommuRegister,(PPDMDEVINS pDevIns, PPDMIOMMUREGR3 pIommuReg, PCPDMIOMMUHLPR3 *ppIommuHlp,
3741 uint32_t *pidxIommu));
3742
3743 /**
3744 * Register the PIC device.
3745 *
3746 * @returns VBox status code.
3747 * @param pDevIns The device instance.
3748 * @param pPicReg Pointer to a PIC registration structure.
3749 * @param ppPicHlp Where to store the pointer to the ring-3 PIC
3750 * helpers.
3751 * @sa PDMDevHlpPICSetUpContext
3752 */
3753 DECLR3CALLBACKMEMBER(int, pfnPICRegister,(PPDMDEVINS pDevIns, PPDMPICREG pPicReg, PCPDMPICHLP *ppPicHlp));
3754
3755 /**
3756 * Register the APIC device.
3757 *
3758 * @returns VBox status code.
3759 * @param pDevIns The device instance.
3760 */
3761 DECLR3CALLBACKMEMBER(int, pfnApicRegister,(PPDMDEVINS pDevIns));
3762
3763 /**
3764 * Register the I/O APIC device.
3765 *
3766 * @returns VBox status code.
3767 * @param pDevIns The device instance.
3768 * @param pIoApicReg Pointer to a I/O APIC registration structure.
3769 * @param ppIoApicHlp Where to store the pointer to the IOAPIC
3770 * helpers.
3771 */
3772 DECLR3CALLBACKMEMBER(int, pfnIoApicRegister,(PPDMDEVINS pDevIns, PPDMIOAPICREG pIoApicReg, PCPDMIOAPICHLP *ppIoApicHlp));
3773
3774 /**
3775 * Register the HPET device.
3776 *
3777 * @returns VBox status code.
3778 * @param pDevIns The device instance.
3779 * @param pHpetReg Pointer to a HPET registration structure.
3780 * @param ppHpetHlpR3 Where to store the pointer to the HPET
3781 * helpers.
3782 */
3783 DECLR3CALLBACKMEMBER(int, pfnHpetRegister,(PPDMDEVINS pDevIns, PPDMHPETREG pHpetReg, PCPDMHPETHLPR3 *ppHpetHlpR3));
3784
3785 /**
3786 * Register a raw PCI device.
3787 *
3788 * @returns VBox status code.
3789 * @param pDevIns The device instance.
3790 * @param pPciRawReg Pointer to a raw PCI registration structure.
3791 * @param ppPciRawHlpR3 Where to store the pointer to the raw PCI
3792 * device helpers.
3793 */
3794 DECLR3CALLBACKMEMBER(int, pfnPciRawRegister,(PPDMDEVINS pDevIns, PPDMPCIRAWREG pPciRawReg, PCPDMPCIRAWHLPR3 *ppPciRawHlpR3));
3795
3796 /**
3797 * Register the DMA device.
3798 *
3799 * @returns VBox status code.
3800 * @param pDevIns The device instance.
3801 * @param pDmacReg Pointer to a DMAC registration structure.
3802 * @param ppDmacHlp Where to store the pointer to the DMA helpers.
3803 */
3804 DECLR3CALLBACKMEMBER(int, pfnDMACRegister,(PPDMDEVINS pDevIns, PPDMDMACREG pDmacReg, PCPDMDMACHLP *ppDmacHlp));
3805
3806 /**
3807 * Register transfer function for DMA channel.
3808 *
3809 * @returns VBox status code.
3810 * @param pDevIns The device instance.
3811 * @param uChannel Channel number.
3812 * @param pfnTransferHandler Device specific transfer callback function.
3813 * @param pvUser User pointer to pass to the callback.
3814 * @thread EMT
3815 */
3816 DECLR3CALLBACKMEMBER(int, pfnDMARegister,(PPDMDEVINS pDevIns, unsigned uChannel, PFNDMATRANSFERHANDLER pfnTransferHandler, void *pvUser));
3817
3818 /**
3819 * Read memory.
3820 *
3821 * @returns VBox status code.
3822 * @param pDevIns The device instance.
3823 * @param uChannel Channel number.
3824 * @param pvBuffer Pointer to target buffer.
3825 * @param off DMA position.
3826 * @param cbBlock Block size.
3827 * @param pcbRead Where to store the number of bytes which was
3828 * read. optional.
3829 * @thread EMT
3830 */
3831 DECLR3CALLBACKMEMBER(int, pfnDMAReadMemory,(PPDMDEVINS pDevIns, unsigned uChannel, void *pvBuffer, uint32_t off, uint32_t cbBlock, uint32_t *pcbRead));
3832
3833 /**
3834 * Write memory.
3835 *
3836 * @returns VBox status code.
3837 * @param pDevIns The device instance.
3838 * @param uChannel Channel number.
3839 * @param pvBuffer Memory to write.
3840 * @param off DMA position.
3841 * @param cbBlock Block size.
3842 * @param pcbWritten Where to store the number of bytes which was
3843 * written. optional.
3844 * @thread EMT
3845 */
3846 DECLR3CALLBACKMEMBER(int, pfnDMAWriteMemory,(PPDMDEVINS pDevIns, unsigned uChannel, const void *pvBuffer, uint32_t off, uint32_t cbBlock, uint32_t *pcbWritten));
3847
3848 /**
3849 * Set the DREQ line.
3850 *
3851 * @returns VBox status code.
3852 * @param pDevIns Device instance.
3853 * @param uChannel Channel number.
3854 * @param uLevel Level of the line.
3855 * @thread EMT
3856 */
3857 DECLR3CALLBACKMEMBER(int, pfnDMASetDREQ,(PPDMDEVINS pDevIns, unsigned uChannel, unsigned uLevel));
3858
3859 /**
3860 * Get channel mode.
3861 *
3862 * @returns Channel mode. See specs.
3863 * @param pDevIns The device instance.
3864 * @param uChannel Channel number.
3865 * @thread EMT
3866 */
3867 DECLR3CALLBACKMEMBER(uint8_t, pfnDMAGetChannelMode,(PPDMDEVINS pDevIns, unsigned uChannel));
3868
3869 /**
3870 * Schedule DMA execution.
3871 *
3872 * @param pDevIns The device instance.
3873 * @thread Any thread.
3874 */
3875 DECLR3CALLBACKMEMBER(void, pfnDMASchedule,(PPDMDEVINS pDevIns));
3876
3877 /**
3878 * Write CMOS value and update the checksum(s).
3879 *
3880 * @returns VBox status code.
3881 * @param pDevIns The device instance.
3882 * @param iReg The CMOS register index.
3883 * @param u8Value The CMOS register value.
3884 * @thread EMT
3885 */
3886 DECLR3CALLBACKMEMBER(int, pfnCMOSWrite,(PPDMDEVINS pDevIns, unsigned iReg, uint8_t u8Value));
3887
3888 /**
3889 * Read CMOS value.
3890 *
3891 * @returns VBox status code.
3892 * @param pDevIns The device instance.
3893 * @param iReg The CMOS register index.
3894 * @param pu8Value Where to store the CMOS register value.
3895 * @thread EMT
3896 */
3897 DECLR3CALLBACKMEMBER(int, pfnCMOSRead,(PPDMDEVINS pDevIns, unsigned iReg, uint8_t *pu8Value));
3898
3899 /**
3900 * Assert that the current thread is the emulation thread.
3901 *
3902 * @returns True if correct.
3903 * @returns False if wrong.
3904 * @param pDevIns The device instance.
3905 * @param pszFile Filename of the assertion location.
3906 * @param iLine The linenumber of the assertion location.
3907 * @param pszFunction Function of the assertion location.
3908 */
3909 DECLR3CALLBACKMEMBER(bool, pfnAssertEMT,(PPDMDEVINS pDevIns, const char *pszFile, unsigned iLine, const char *pszFunction));
3910
3911 /**
3912 * Assert that the current thread is NOT the emulation thread.
3913 *
3914 * @returns True if correct.
3915 * @returns False if wrong.
3916 * @param pDevIns The device instance.
3917 * @param pszFile Filename of the assertion location.
3918 * @param iLine The linenumber of the assertion location.
3919 * @param pszFunction Function of the assertion location.
3920 */
3921 DECLR3CALLBACKMEMBER(bool, pfnAssertOther,(PPDMDEVINS pDevIns, const char *pszFile, unsigned iLine, const char *pszFunction));
3922
3923 /**
3924 * Resolves the symbol for a raw-mode context interface.
3925 *
3926 * @returns VBox status code.
3927 * @param pDevIns The device instance.
3928 * @param pvInterface The interface structure.
3929 * @param cbInterface The size of the interface structure.
3930 * @param pszSymPrefix What to prefix the symbols in the list with
3931 * before resolving them. This must start with
3932 * 'dev' and contain the driver name.
3933 * @param pszSymList List of symbols corresponding to the interface.
3934 * There is generally a there is generally a define
3935 * holding this list associated with the interface
3936 * definition (INTERFACE_SYM_LIST). For more
3937 * details see PDMR3LdrGetInterfaceSymbols.
3938 * @thread EMT
3939 */
3940 DECLR3CALLBACKMEMBER(int, pfnLdrGetRCInterfaceSymbols,(PPDMDEVINS pDevIns, void *pvInterface, size_t cbInterface,
3941 const char *pszSymPrefix, const char *pszSymList));
3942
3943 /**
3944 * Resolves the symbol for a ring-0 context interface.
3945 *
3946 * @returns VBox status code.
3947 * @param pDevIns The device instance.
3948 * @param pvInterface The interface structure.
3949 * @param cbInterface The size of the interface structure.
3950 * @param pszSymPrefix What to prefix the symbols in the list with
3951 * before resolving them. This must start with
3952 * 'dev' and contain the driver name.
3953 * @param pszSymList List of symbols corresponding to the interface.
3954 * There is generally a there is generally a define
3955 * holding this list associated with the interface
3956 * definition (INTERFACE_SYM_LIST). For more
3957 * details see PDMR3LdrGetInterfaceSymbols.
3958 * @thread EMT
3959 */
3960 DECLR3CALLBACKMEMBER(int, pfnLdrGetR0InterfaceSymbols,(PPDMDEVINS pDevIns, void *pvInterface, size_t cbInterface,
3961 const char *pszSymPrefix, const char *pszSymList));
3962
3963 /**
3964 * Calls the PDMDEVREGR0::pfnRequest callback (in ring-0 context).
3965 *
3966 * @returns VBox status code.
3967 * @retval VERR_INVALID_FUNCTION if the callback member is NULL.
3968 * @retval VERR_ACCESS_DENIED if the device isn't ring-0 capable.
3969 *
3970 * @param pDevIns The device instance.
3971 * @param uOperation The operation to perform.
3972 * @param u64Arg 64-bit integer argument.
3973 * @thread EMT
3974 */
3975 DECLR3CALLBACKMEMBER(int, pfnCallR0,(PPDMDEVINS pDevIns, uint32_t uOperation, uint64_t u64Arg));
3976
3977 /**
3978 * Gets the reason for the most recent VM suspend.
3979 *
3980 * @returns The suspend reason. VMSUSPENDREASON_INVALID is returned if no
3981 * suspend has been made or if the pDevIns is invalid.
3982 * @param pDevIns The device instance.
3983 */
3984 DECLR3CALLBACKMEMBER(VMSUSPENDREASON, pfnVMGetSuspendReason,(PPDMDEVINS pDevIns));
3985
3986 /**
3987 * Gets the reason for the most recent VM resume.
3988 *
3989 * @returns The resume reason. VMRESUMEREASON_INVALID is returned if no
3990 * resume has been made or if the pDevIns is invalid.
3991 * @param pDevIns The device instance.
3992 */
3993 DECLR3CALLBACKMEMBER(VMRESUMEREASON, pfnVMGetResumeReason,(PPDMDEVINS pDevIns));
3994
3995 /**
3996 * Requests the mapping of multiple guest page into ring-3.
3997 *
3998 * When you're done with the pages, call pfnPhysBulkReleasePageMappingLocks()
3999 * ASAP to release them.
4000 *
4001 * This API will assume your intention is to write to the pages, and will
4002 * therefore replace shared and zero pages. If you do not intend to modify the
4003 * pages, use the pfnPhysBulkGCPhys2CCPtrReadOnly() API.
4004 *
4005 * @returns VBox status code.
4006 * @retval VINF_SUCCESS on success.
4007 * @retval VERR_PGM_PHYS_PAGE_RESERVED if any of the pages has no physical
4008 * backing or if any of the pages the page has any active access
4009 * handlers. The caller must fall back on using PGMR3PhysWriteExternal.
4010 * @retval VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS if @a paGCPhysPages contains
4011 * an invalid physical address.
4012 *
4013 * @param pDevIns The device instance.
4014 * @param cPages Number of pages to lock.
4015 * @param paGCPhysPages The guest physical address of the pages that
4016 * should be mapped (@a cPages entries).
4017 * @param fFlags Flags reserved for future use, MBZ.
4018 * @param papvPages Where to store the ring-3 mapping addresses
4019 * corresponding to @a paGCPhysPages.
4020 * @param paLocks Where to store the locking information that
4021 * pfnPhysBulkReleasePageMappingLock needs (@a cPages
4022 * in length).
4023 *
4024 * @remark Avoid calling this API from within critical sections (other than the
4025 * PGM one) because of the deadlock risk when we have to delegating the
4026 * task to an EMT.
4027 * @thread Any.
4028 * @since 6.0.6
4029 */
4030 DECLR3CALLBACKMEMBER(int, pfnPhysBulkGCPhys2CCPtr,(PPDMDEVINS pDevIns, uint32_t cPages, PCRTGCPHYS paGCPhysPages,
4031 uint32_t fFlags, void **papvPages, PPGMPAGEMAPLOCK paLocks));
4032
4033 /**
4034 * Requests the mapping of multiple guest page into ring-3, for reading only.
4035 *
4036 * When you're done with the pages, call pfnPhysBulkReleasePageMappingLocks()
4037 * ASAP to release them.
4038 *
4039 * @returns VBox status code.
4040 * @retval VINF_SUCCESS on success.
4041 * @retval VERR_PGM_PHYS_PAGE_RESERVED if any of the pages has no physical
4042 * backing or if any of the pages the page has an active ALL access
4043 * handler. The caller must fall back on using PGMR3PhysWriteExternal.
4044 * @retval VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS if @a paGCPhysPages contains
4045 * an invalid physical address.
4046 *
4047 * @param pDevIns The device instance.
4048 * @param cPages Number of pages to lock.
4049 * @param paGCPhysPages The guest physical address of the pages that
4050 * should be mapped (@a cPages entries).
4051 * @param fFlags Flags reserved for future use, MBZ.
4052 * @param papvPages Where to store the ring-3 mapping addresses
4053 * corresponding to @a paGCPhysPages.
4054 * @param paLocks Where to store the lock information that
4055 * pfnPhysReleasePageMappingLock needs (@a cPages
4056 * in length).
4057 *
4058 * @remark Avoid calling this API from within critical sections.
4059 * @thread Any.
4060 * @since 6.0.6
4061 */
4062 DECLR3CALLBACKMEMBER(int, pfnPhysBulkGCPhys2CCPtrReadOnly,(PPDMDEVINS pDevIns, uint32_t cPages, PCRTGCPHYS paGCPhysPages,
4063 uint32_t fFlags, void const **papvPages, PPGMPAGEMAPLOCK paLocks));
4064
4065 /**
4066 * Release the mappings of multiple guest pages.
4067 *
4068 * This is the counter part of pfnPhysBulkGCPhys2CCPtr and
4069 * pfnPhysBulkGCPhys2CCPtrReadOnly.
4070 *
4071 * @param pDevIns The device instance.
4072 * @param cPages Number of pages to unlock.
4073 * @param paLocks The lock structures initialized by the mapping
4074 * function (@a cPages in length).
4075 * @thread Any.
4076 * @since 6.0.6
4077 */
4078 DECLR3CALLBACKMEMBER(void, pfnPhysBulkReleasePageMappingLocks,(PPDMDEVINS pDevIns, uint32_t cPages, PPGMPAGEMAPLOCK paLocks));
4079
4080 /**
4081 * Returns the micro architecture used for the guest.
4082 *
4083 * @returns CPU micro architecture enum.
4084 * @param pDevIns The device instance.
4085 */
4086 DECLR3CALLBACKMEMBER(CPUMMICROARCH, pfnCpuGetGuestMicroarch,(PPDMDEVINS pDevIns));
4087
4088 /** Space reserved for future members.
4089 * @{ */
4090 DECLR3CALLBACKMEMBER(void, pfnReserved1,(void));
4091 DECLR3CALLBACKMEMBER(void, pfnReserved2,(void));
4092 DECLR3CALLBACKMEMBER(void, pfnReserved3,(void));
4093 DECLR3CALLBACKMEMBER(void, pfnReserved4,(void));
4094 DECLR3CALLBACKMEMBER(void, pfnReserved5,(void));
4095 DECLR3CALLBACKMEMBER(void, pfnReserved6,(void));
4096 DECLR3CALLBACKMEMBER(void, pfnReserved7,(void));
4097 DECLR3CALLBACKMEMBER(void, pfnReserved8,(void));
4098 DECLR3CALLBACKMEMBER(void, pfnReserved9,(void));
4099 DECLR3CALLBACKMEMBER(void, pfnReserved10,(void));
4100 /** @} */
4101
4102
4103 /** API available to trusted devices only.
4104 *
4105 * These APIs are providing unrestricted access to the guest and the VM,
4106 * or they are interacting intimately with PDM.
4107 *
4108 * @{
4109 */
4110
4111 /**
4112 * Gets the user mode VM handle. Restricted API.
4113 *
4114 * @returns User mode VM Handle.
4115 * @param pDevIns The device instance.
4116 */
4117 DECLR3CALLBACKMEMBER(PUVM, pfnGetUVM,(PPDMDEVINS pDevIns));
4118
4119 /**
4120 * Gets the global VM handle. Restricted API.
4121 *
4122 * @returns VM Handle.
4123 * @param pDevIns The device instance.
4124 */
4125 DECLR3CALLBACKMEMBER(PVMCC, pfnGetVM,(PPDMDEVINS pDevIns));
4126
4127 /**
4128 * Gets the VMCPU handle. Restricted API.
4129 *
4130 * @returns VMCPU Handle.
4131 * @param pDevIns The device instance.
4132 */
4133 DECLR3CALLBACKMEMBER(PVMCPU, pfnGetVMCPU,(PPDMDEVINS pDevIns));
4134
4135 /**
4136 * The the VM CPU ID of the current thread (restricted API).
4137 *
4138 * @returns The VMCPUID of the calling thread, NIL_VMCPUID if not EMT.
4139 * @param pDevIns The device instance.
4140 */
4141 DECLR3CALLBACKMEMBER(VMCPUID, pfnGetCurrentCpuId,(PPDMDEVINS pDevIns));
4142
4143 /**
4144 * Registers the VMM device heap or notifies about mapping/unmapping.
4145 *
4146 * This interface serves three purposes:
4147 *
4148 * -# Register the VMM device heap during device construction
4149 * for the HM to use.
4150 * -# Notify PDM/HM that it's mapped into guest address
4151 * space (i.e. usable).
4152 * -# Notify PDM/HM that it is being unmapped from the guest
4153 * address space (i.e. not usable).
4154 *
4155 * @returns VBox status code.
4156 * @param pDevIns The device instance.
4157 * @param GCPhys The physical address if mapped, NIL_RTGCPHYS if
4158 * not mapped.
4159 * @param pvHeap Ring 3 heap pointer.
4160 * @param cbHeap Size of the heap.
4161 * @thread EMT.
4162 */
4163 DECLR3CALLBACKMEMBER(int, pfnRegisterVMMDevHeap,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTR3PTR pvHeap, unsigned cbHeap));
4164
4165 /**
4166 * Registers the firmware (BIOS, EFI) device with PDM.
4167 *
4168 * The firmware provides a callback table and gets a special PDM helper table.
4169 * There can only be one firmware device for a VM.
4170 *
4171 * @returns VBox status code.
4172 * @param pDevIns The device instance.
4173 * @param pFwReg Firmware registration structure.
4174 * @param ppFwHlp Where to return the firmware helper structure.
4175 * @remarks Only valid during device construction.
4176 * @thread EMT(0)
4177 */
4178 DECLR3CALLBACKMEMBER(int, pfnFirmwareRegister,(PPDMDEVINS pDevIns, PCPDMFWREG pFwReg, PCPDMFWHLPR3 *ppFwHlp));
4179
4180 /**
4181 * Resets the VM.
4182 *
4183 * @returns The appropriate VBox status code to pass around on reset.
4184 * @param pDevIns The device instance.
4185 * @param fFlags PDMVMRESET_F_XXX flags.
4186 * @thread The emulation thread.
4187 */
4188 DECLR3CALLBACKMEMBER(int, pfnVMReset,(PPDMDEVINS pDevIns, uint32_t fFlags));
4189
4190 /**
4191 * Suspends the VM.
4192 *
4193 * @returns The appropriate VBox status code to pass around on suspend.
4194 * @param pDevIns The device instance.
4195 * @thread The emulation thread.
4196 */
4197 DECLR3CALLBACKMEMBER(int, pfnVMSuspend,(PPDMDEVINS pDevIns));
4198
4199 /**
4200 * Suspends, saves and powers off the VM.
4201 *
4202 * @returns The appropriate VBox status code to pass around.
4203 * @param pDevIns The device instance.
4204 * @thread An emulation thread.
4205 */
4206 DECLR3CALLBACKMEMBER(int, pfnVMSuspendSaveAndPowerOff,(PPDMDEVINS pDevIns));
4207
4208 /**
4209 * Power off the VM.
4210 *
4211 * @returns The appropriate VBox status code to pass around on power off.
4212 * @param pDevIns The device instance.
4213 * @thread The emulation thread.
4214 */
4215 DECLR3CALLBACKMEMBER(int, pfnVMPowerOff,(PPDMDEVINS pDevIns));
4216
4217 /**
4218 * Checks if the Gate A20 is enabled or not.
4219 *
4220 * @returns true if A20 is enabled.
4221 * @returns false if A20 is disabled.
4222 * @param pDevIns The device instance.
4223 * @thread The emulation thread.
4224 */
4225 DECLR3CALLBACKMEMBER(bool, pfnA20IsEnabled,(PPDMDEVINS pDevIns));
4226
4227 /**
4228 * Enables or disables the Gate A20.
4229 *
4230 * @param pDevIns The device instance.
4231 * @param fEnable Set this flag to enable the Gate A20; clear it
4232 * to disable.
4233 * @thread The emulation thread.
4234 */
4235 DECLR3CALLBACKMEMBER(void, pfnA20Set,(PPDMDEVINS pDevIns, bool fEnable));
4236
4237 /**
4238 * Get the specified CPUID leaf for the virtual CPU associated with the calling
4239 * thread.
4240 *
4241 * @param pDevIns The device instance.
4242 * @param iLeaf The CPUID leaf to get.
4243 * @param pEax Where to store the EAX value.
4244 * @param pEbx Where to store the EBX value.
4245 * @param pEcx Where to store the ECX value.
4246 * @param pEdx Where to store the EDX value.
4247 * @thread EMT.
4248 */
4249 DECLR3CALLBACKMEMBER(void, pfnGetCpuId,(PPDMDEVINS pDevIns, uint32_t iLeaf, uint32_t *pEax, uint32_t *pEbx, uint32_t *pEcx, uint32_t *pEdx));
4250
4251 /**
4252 * Get the current virtual clock time in a VM. The clock frequency must be
4253 * queried separately.
4254 *
4255 * @returns Current clock time.
4256 * @param pDevIns The device instance.
4257 */
4258 DECLR3CALLBACKMEMBER(uint64_t, pfnTMTimeVirtGet,(PPDMDEVINS pDevIns));
4259
4260 /**
4261 * Get the frequency of the virtual clock.
4262 *
4263 * @returns The clock frequency (not variable at run-time).
4264 * @param pDevIns The device instance.
4265 */
4266 DECLR3CALLBACKMEMBER(uint64_t, pfnTMTimeVirtGetFreq,(PPDMDEVINS pDevIns));
4267
4268 /**
4269 * Get the current virtual clock time in a VM, in nanoseconds.
4270 *
4271 * @returns Current clock time (in ns).
4272 * @param pDevIns The device instance.
4273 */
4274 DECLR3CALLBACKMEMBER(uint64_t, pfnTMTimeVirtGetNano,(PPDMDEVINS pDevIns));
4275
4276 /**
4277 * Gets the support driver session.
4278 *
4279 * This is intended for working with the semaphore API.
4280 *
4281 * @returns Support driver session handle.
4282 * @param pDevIns The device instance.
4283 */
4284 DECLR3CALLBACKMEMBER(PSUPDRVSESSION, pfnGetSupDrvSession,(PPDMDEVINS pDevIns));
4285
4286 /**
4287 * Queries a generic object from the VMM user.
4288 *
4289 * @returns Pointer to the object if found, NULL if not.
4290 * @param pDevIns The device instance.
4291 * @param pUuid The UUID of what's being queried. The UUIDs and
4292 * the usage conventions are defined by the user.
4293 *
4294 * @note It is strictly forbidden to call this internally in VBox! This
4295 * interface is exclusively for hacks in externally developed devices.
4296 */
4297 DECLR3CALLBACKMEMBER(void *, pfnQueryGenericUserObject,(PPDMDEVINS pDevIns, PCRTUUID pUuid));
4298
4299 /**
4300 * Register a physical page access handler type.
4301 *
4302 * @returns VBox status code.
4303 * @param pDevIns The device instance.
4304 * @param enmKind The kind of access handler.
4305 * @param pfnHandlerR3 Pointer to the ring-3 handler callback.
4306 * @param pszHandlerR0 The name of the ring-0 handler, NULL if the ring-3
4307 * handler should be called.
4308 * @param pszPfHandlerR0 The name of the ring-0 \#PF handler, NULL if the
4309 * ring-3 handler should be called.
4310 * @param pszHandlerRC The name of the raw-mode context handler, NULL if
4311 * the ring-3 handler should be called.
4312 * @param pszPfHandlerRC The name of the raw-mode context \#PF handler, NULL
4313 * if the ring-3 handler should be called.
4314 * @param pszDesc The type description.
4315 * @param phType Where to return the type handle (cross context
4316 * safe).
4317 */
4318 DECLR3CALLBACKMEMBER(int, pfnPGMHandlerPhysicalTypeRegister, (PPDMDEVINS pDevIns, PGMPHYSHANDLERKIND enmKind,
4319 R3PTRTYPE(PFNPGMPHYSHANDLER) pfnHandlerR3,
4320 const char *pszHandlerR0, const char *pszPfHandlerR0,
4321 const char *pszHandlerRC, const char *pszPfHandlerRC,
4322 const char *pszDesc, PPGMPHYSHANDLERTYPE phType));
4323
4324 /** @} */
4325
4326 /** Just a safety precaution. (PDM_DEVHLPR3_VERSION) */
4327 uint32_t u32TheEnd;
4328} PDMDEVHLPR3;
4329#endif /* !IN_RING3 || DOXYGEN_RUNNING */
4330/** Pointer to the R3 PDM Device API. */
4331typedef R3PTRTYPE(struct PDMDEVHLPR3 *) PPDMDEVHLPR3;
4332/** Pointer to the R3 PDM Device API, const variant. */
4333typedef R3PTRTYPE(const struct PDMDEVHLPR3 *) PCPDMDEVHLPR3;
4334
4335
4336/**
4337 * PDM Device API - RC Variant.
4338 */
4339typedef struct PDMDEVHLPRC
4340{
4341 /** Structure version. PDM_DEVHLPRC_VERSION defines the current version. */
4342 uint32_t u32Version;
4343
4344 /**
4345 * Sets up raw-mode context callback handlers for an I/O port range.
4346 *
4347 * The range must have been registered in ring-3 first using
4348 * PDMDevHlpIoPortCreate() or PDMDevHlpIoPortCreateEx().
4349 *
4350 * @returns VBox status.
4351 * @param pDevIns The device instance to register the ports with.
4352 * @param hIoPorts The I/O port range handle.
4353 * @param pfnOut Pointer to function which is gonna handle OUT
4354 * operations. Optional.
4355 * @param pfnIn Pointer to function which is gonna handle IN operations.
4356 * Optional.
4357 * @param pfnOutStr Pointer to function which is gonna handle string OUT
4358 * operations. Optional.
4359 * @param pfnInStr Pointer to function which is gonna handle string IN
4360 * operations. Optional.
4361 * @param pvUser User argument to pass to the callbacks.
4362 *
4363 * @remarks Caller enters the device critical section prior to invoking the
4364 * registered callback methods.
4365 *
4366 * @sa PDMDevHlpIoPortCreate, PDMDevHlpIoPortCreateEx, PDMDevHlpIoPortMap,
4367 * PDMDevHlpIoPortUnmap.
4368 */
4369 DECLRCCALLBACKMEMBER(int, pfnIoPortSetUpContextEx,(PPDMDEVINS pDevIns, IOMIOPORTHANDLE hIoPorts,
4370 PFNIOMIOPORTNEWOUT pfnOut, PFNIOMIOPORTNEWIN pfnIn,
4371 PFNIOMIOPORTNEWOUTSTRING pfnOutStr, PFNIOMIOPORTNEWINSTRING pfnInStr,
4372 void *pvUser));
4373
4374 /**
4375 * Sets up raw-mode context callback handlers for an MMIO region.
4376 *
4377 * The region must have been registered in ring-3 first using
4378 * PDMDevHlpMmioCreate() or PDMDevHlpMmioCreateEx().
4379 *
4380 * @returns VBox status.
4381 * @param pDevIns The device instance to register the ports with.
4382 * @param hRegion The MMIO region handle.
4383 * @param pfnWrite Pointer to function which is gonna handle Write
4384 * operations.
4385 * @param pfnRead Pointer to function which is gonna handle Read
4386 * operations.
4387 * @param pfnFill Pointer to function which is gonna handle Fill/memset
4388 * operations. (optional)
4389 * @param pvUser User argument to pass to the callbacks.
4390 *
4391 * @remarks Caller enters the device critical section prior to invoking the
4392 * registered callback methods.
4393 *
4394 * @sa PDMDevHlpMmioCreate, PDMDevHlpMmioCreateEx, PDMDevHlpMmioMap,
4395 * PDMDevHlpMmioUnmap.
4396 */
4397 DECLRCCALLBACKMEMBER(int, pfnMmioSetUpContextEx,(PPDMDEVINS pDevIns, IOMMMIOHANDLE hRegion, PFNIOMMMIONEWWRITE pfnWrite,
4398 PFNIOMMMIONEWREAD pfnRead, PFNIOMMMIONEWFILL pfnFill, void *pvUser));
4399
4400 /**
4401 * Sets up a raw-mode mapping for an MMIO2 region.
4402 *
4403 * The region must have been created in ring-3 first using
4404 * PDMDevHlpMmio2Create().
4405 *
4406 * @returns VBox status.
4407 * @param pDevIns The device instance to register the ports with.
4408 * @param hRegion The MMIO2 region handle.
4409 * @param offSub Start of what to map into raw-mode. Must be page aligned.
4410 * @param cbSub Number of bytes to map into raw-mode. Must be page
4411 * aligned. Zero is an alias for everything.
4412 * @param ppvMapping Where to return the mapping corresponding to @a offSub.
4413 * @thread EMT(0)
4414 * @note Only available at VM creation time.
4415 *
4416 * @sa PDMDevHlpMmio2Create().
4417 */
4418 DECLRCCALLBACKMEMBER(int, pfnMmio2SetUpContext,(PPDMDEVINS pDevIns, PGMMMIO2HANDLE hRegion,
4419 size_t offSub, size_t cbSub, void **ppvMapping));
4420
4421 /**
4422 * Bus master physical memory read from the given PCI device.
4423 *
4424 * @returns VINF_SUCCESS or VERR_PGM_PCI_PHYS_READ_BM_DISABLED, later maybe
4425 * VERR_EM_MEMORY. The informational status shall NOT be propagated!
4426 * @param pDevIns The device instance.
4427 * @param pPciDev The PCI device structure. If NULL the default
4428 * PCI device for this device instance is used.
4429 * @param GCPhys Physical address start reading from.
4430 * @param pvBuf Where to put the read bits.
4431 * @param cbRead How many bytes to read.
4432 * @param fFlags Combination of PDM_DEVHLP_PHYS_RW_F_XXX.
4433 * @thread Any thread, but the call may involve the emulation thread.
4434 */
4435 DECLRCCALLBACKMEMBER(int, pfnPCIPhysRead,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, RTGCPHYS GCPhys,
4436 void *pvBuf, size_t cbRead, uint32_t fFlags));
4437
4438 /**
4439 * Bus master physical memory write from the given PCI device.
4440 *
4441 * @returns VINF_SUCCESS or VERR_PGM_PCI_PHYS_WRITE_BM_DISABLED, later maybe
4442 * VERR_EM_MEMORY. The informational status shall NOT be propagated!
4443 * @param pDevIns The device instance.
4444 * @param pPciDev The PCI device structure. If NULL the default
4445 * PCI device for this device instance is used.
4446 * @param GCPhys Physical address to write to.
4447 * @param pvBuf What to write.
4448 * @param cbWrite How many bytes to write.
4449 * @param fFlags Combination of PDM_DEVHLP_PHYS_RW_F_XXX.
4450 * @thread Any thread, but the call may involve the emulation thread.
4451 */
4452 DECLRCCALLBACKMEMBER(int, pfnPCIPhysWrite,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, RTGCPHYS GCPhys,
4453 const void *pvBuf, size_t cbWrite, uint32_t fFlags));
4454
4455 /**
4456 * Set the IRQ for the given PCI device.
4457 *
4458 * @param pDevIns Device instance.
4459 * @param pPciDev The PCI device structure. If NULL the default
4460 * PCI device for this device instance is used.
4461 * @param iIrq IRQ number to set.
4462 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
4463 * @thread Any thread, but will involve the emulation thread.
4464 */
4465 DECLRCCALLBACKMEMBER(void, pfnPCISetIrq,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iIrq, int iLevel));
4466
4467 /**
4468 * Set ISA IRQ for a device.
4469 *
4470 * @param pDevIns Device instance.
4471 * @param iIrq IRQ number to set.
4472 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
4473 * @thread Any thread, but will involve the emulation thread.
4474 */
4475 DECLRCCALLBACKMEMBER(void, pfnISASetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
4476
4477 /**
4478 * Read physical memory.
4479 *
4480 * @returns VINF_SUCCESS (for now).
4481 * @param pDevIns Device instance.
4482 * @param GCPhys Physical address start reading from.
4483 * @param pvBuf Where to put the read bits.
4484 * @param cbRead How many bytes to read.
4485 * @param fFlags Combination of PDM_DEVHLP_PHYS_RW_F_XXX.
4486 */
4487 DECLRCCALLBACKMEMBER(int, pfnPhysRead,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead, uint32_t fFlags));
4488
4489 /**
4490 * Write to physical memory.
4491 *
4492 * @returns VINF_SUCCESS for now, and later maybe VERR_EM_MEMORY.
4493 * @param pDevIns Device instance.
4494 * @param GCPhys Physical address to write to.
4495 * @param pvBuf What to write.
4496 * @param cbWrite How many bytes to write.
4497 * @param fFlags Combination of PDM_DEVHLP_PHYS_RW_F_XXX.
4498 */
4499 DECLRCCALLBACKMEMBER(int, pfnPhysWrite,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite, uint32_t fFlags));
4500
4501 /**
4502 * Checks if the Gate A20 is enabled or not.
4503 *
4504 * @returns true if A20 is enabled.
4505 * @returns false if A20 is disabled.
4506 * @param pDevIns Device instance.
4507 * @thread The emulation thread.
4508 */
4509 DECLRCCALLBACKMEMBER(bool, pfnA20IsEnabled,(PPDMDEVINS pDevIns));
4510
4511 /**
4512 * Gets the VM state.
4513 *
4514 * @returns VM state.
4515 * @param pDevIns The device instance.
4516 * @thread Any thread (just keep in mind that it's volatile info).
4517 */
4518 DECLRCCALLBACKMEMBER(VMSTATE, pfnVMState, (PPDMDEVINS pDevIns));
4519
4520 /**
4521 * Set the VM error message
4522 *
4523 * @returns rc.
4524 * @param pDevIns Driver instance.
4525 * @param rc VBox status code.
4526 * @param SRC_POS Use RT_SRC_POS.
4527 * @param pszFormat Error message format string.
4528 * @param ... Error message arguments.
4529 */
4530 DECLRCCALLBACKMEMBER(int, pfnVMSetError,(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL,
4531 const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(6, 7));
4532
4533 /**
4534 * Set the VM error message
4535 *
4536 * @returns rc.
4537 * @param pDevIns Driver instance.
4538 * @param rc VBox status code.
4539 * @param SRC_POS Use RT_SRC_POS.
4540 * @param pszFormat Error message format string.
4541 * @param va Error message arguments.
4542 */
4543 DECLRCCALLBACKMEMBER(int, pfnVMSetErrorV,(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL,
4544 const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(6, 0));
4545
4546 /**
4547 * Set the VM runtime error message
4548 *
4549 * @returns VBox status code.
4550 * @param pDevIns Device instance.
4551 * @param fFlags The action flags. See VMSETRTERR_FLAGS_*.
4552 * @param pszErrorId Error ID string.
4553 * @param pszFormat Error message format string.
4554 * @param ... Error message arguments.
4555 */
4556 DECLRCCALLBACKMEMBER(int, pfnVMSetRuntimeError,(PPDMDEVINS pDevIns, uint32_t fFlags, const char *pszErrorId,
4557 const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(4, 5));
4558
4559 /**
4560 * Set the VM runtime error message
4561 *
4562 * @returns VBox status code.
4563 * @param pDevIns Device instance.
4564 * @param fFlags The action flags. See VMSETRTERR_FLAGS_*.
4565 * @param pszErrorId Error ID string.
4566 * @param pszFormat Error message format string.
4567 * @param va Error message arguments.
4568 */
4569 DECLRCCALLBACKMEMBER(int, pfnVMSetRuntimeErrorV,(PPDMDEVINS pDevIns, uint32_t fFlags, const char *pszErrorId,
4570 const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(4, 0));
4571
4572 /**
4573 * Gets the VM handle. Restricted API.
4574 *
4575 * @returns VM Handle.
4576 * @param pDevIns Device instance.
4577 */
4578 DECLRCCALLBACKMEMBER(PVMCC, pfnGetVM,(PPDMDEVINS pDevIns));
4579
4580 /**
4581 * Gets the VMCPU handle. Restricted API.
4582 *
4583 * @returns VMCPU Handle.
4584 * @param pDevIns The device instance.
4585 */
4586 DECLRCCALLBACKMEMBER(PVMCPUCC, pfnGetVMCPU,(PPDMDEVINS pDevIns));
4587
4588 /**
4589 * The the VM CPU ID of the current thread (restricted API).
4590 *
4591 * @returns The VMCPUID of the calling thread, NIL_VMCPUID if not EMT.
4592 * @param pDevIns The device instance.
4593 */
4594 DECLRCCALLBACKMEMBER(VMCPUID, pfnGetCurrentCpuId,(PPDMDEVINS pDevIns));
4595
4596 /**
4597 * Get the current virtual clock time in a VM. The clock frequency must be
4598 * queried separately.
4599 *
4600 * @returns Current clock time.
4601 * @param pDevIns The device instance.
4602 */
4603 DECLRCCALLBACKMEMBER(uint64_t, pfnTMTimeVirtGet,(PPDMDEVINS pDevIns));
4604
4605 /**
4606 * Get the frequency of the virtual clock.
4607 *
4608 * @returns The clock frequency (not variable at run-time).
4609 * @param pDevIns The device instance.
4610 */
4611 DECLRCCALLBACKMEMBER(uint64_t, pfnTMTimeVirtGetFreq,(PPDMDEVINS pDevIns));
4612
4613 /**
4614 * Get the current virtual clock time in a VM, in nanoseconds.
4615 *
4616 * @returns Current clock time (in ns).
4617 * @param pDevIns The device instance.
4618 */
4619 DECLRCCALLBACKMEMBER(uint64_t, pfnTMTimeVirtGetNano,(PPDMDEVINS pDevIns));
4620
4621 /**
4622 * Gets the NOP critical section.
4623 *
4624 * @returns The ring-3 address of the NOP critical section.
4625 * @param pDevIns The device instance.
4626 */
4627 DECLRCCALLBACKMEMBER(PPDMCRITSECT, pfnCritSectGetNop,(PPDMDEVINS pDevIns));
4628
4629 /**
4630 * Changes the device level critical section from the automatically created
4631 * default to one desired by the device constructor.
4632 *
4633 * Must first be done in ring-3.
4634 *
4635 * @returns VBox status code.
4636 * @param pDevIns The device instance.
4637 * @param pCritSect The critical section to use. NULL is not
4638 * valid, instead use the NOP critical
4639 * section.
4640 */
4641 DECLRCCALLBACKMEMBER(int, pfnSetDeviceCritSect,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect));
4642
4643 /** @name Exported PDM Critical Section Functions
4644 * @{ */
4645 DECLRCCALLBACKMEMBER(int, pfnCritSectEnter,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, int rcBusy));
4646 DECLRCCALLBACKMEMBER(int, pfnCritSectEnterDebug,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, int rcBusy, RTHCUINTPTR uId, RT_SRC_POS_DECL));
4647 DECLRCCALLBACKMEMBER(int, pfnCritSectTryEnter,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect));
4648 DECLRCCALLBACKMEMBER(int, pfnCritSectTryEnterDebug,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, RTHCUINTPTR uId, RT_SRC_POS_DECL));
4649 DECLRCCALLBACKMEMBER(int, pfnCritSectLeave,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect));
4650 DECLRCCALLBACKMEMBER(bool, pfnCritSectIsOwner,(PPDMDEVINS pDevIns, PCPDMCRITSECT pCritSect));
4651 DECLRCCALLBACKMEMBER(bool, pfnCritSectIsInitialized,(PPDMDEVINS pDevIns, PCPDMCRITSECT pCritSect));
4652 DECLRCCALLBACKMEMBER(bool, pfnCritSectHasWaiters,(PPDMDEVINS pDevIns, PCPDMCRITSECT pCritSect));
4653 DECLRCCALLBACKMEMBER(uint32_t, pfnCritSectGetRecursion,(PPDMDEVINS pDevIns, PCPDMCRITSECT pCritSect));
4654 /** @} */
4655
4656 /**
4657 * Gets the trace buffer handle.
4658 *
4659 * This is used by the macros found in VBox/vmm/dbgftrace.h and is not
4660 * really inteded for direct usage, thus no inline wrapper function.
4661 *
4662 * @returns Trace buffer handle or NIL_RTTRACEBUF.
4663 * @param pDevIns The device instance.
4664 */
4665 DECLRCCALLBACKMEMBER(RTTRACEBUF, pfnDBGFTraceBuf,(PPDMDEVINS pDevIns));
4666
4667 /**
4668 * Sets up the PCI bus for the raw-mode context.
4669 *
4670 * This must be called after ring-3 has registered the PCI bus using
4671 * PDMDevHlpPCIBusRegister().
4672 *
4673 * @returns VBox status code.
4674 * @param pDevIns The device instance.
4675 * @param pPciBusReg The PCI bus registration information for raw-mode,
4676 * considered volatile.
4677 * @param ppPciHlp Where to return the raw-mode PCI bus helpers.
4678 */
4679 DECLRCCALLBACKMEMBER(int, pfnPCIBusSetUpContext,(PPDMDEVINS pDevIns, PPDMPCIBUSREGRC pPciBusReg, PCPDMPCIHLPRC *ppPciHlp));
4680
4681 /**
4682 * Sets up the IOMMU for the raw-mode context.
4683 *
4684 * This must be called after ring-3 has registered the IOMMU using
4685 * PDMDevHlpIommuRegister().
4686 *
4687 * @returns VBox status code.
4688 * @param pDevIns The device instance.
4689 * @param pIommuReg The IOMMU registration information for raw-mode,
4690 * considered volatile.
4691 * @param ppIommuHlp Where to return the raw-mode IOMMU helpers.
4692 */
4693 DECLRCCALLBACKMEMBER(int, pfnIommuSetUpContext,(PPDMDEVINS pDevIns, PPDMIOMMUREGRC pIommuReg, PCPDMIOMMUHLPRC *ppIommuHlp));
4694
4695 /**
4696 * Sets up the PIC for the ring-0 context.
4697 *
4698 * This must be called after ring-3 has registered the PIC using
4699 * PDMDevHlpPICRegister().
4700 *
4701 * @returns VBox status code.
4702 * @param pDevIns The device instance.
4703 * @param pPicReg The PIC registration information for ring-0,
4704 * considered volatile and copied.
4705 * @param ppPicHlp Where to return the ring-0 PIC helpers.
4706 */
4707 DECLRCCALLBACKMEMBER(int, pfnPICSetUpContext,(PPDMDEVINS pDevIns, PPDMPICREG pPicReg, PCPDMPICHLP *ppPicHlp));
4708
4709 /**
4710 * Sets up the APIC for the raw-mode context.
4711 *
4712 * This must be called after ring-3 has registered the APIC using
4713 * PDMDevHlpApicRegister().
4714 *
4715 * @returns VBox status code.
4716 * @param pDevIns The device instance.
4717 */
4718 DECLRCCALLBACKMEMBER(int, pfnApicSetUpContext,(PPDMDEVINS pDevIns));
4719
4720 /**
4721 * Sets up the IOAPIC for the ring-0 context.
4722 *
4723 * This must be called after ring-3 has registered the PIC using
4724 * PDMDevHlpIoApicRegister().
4725 *
4726 * @returns VBox status code.
4727 * @param pDevIns The device instance.
4728 * @param pIoApicReg The PIC registration information for ring-0,
4729 * considered volatile and copied.
4730 * @param ppIoApicHlp Where to return the ring-0 IOAPIC helpers.
4731 */
4732 DECLRCCALLBACKMEMBER(int, pfnIoApicSetUpContext,(PPDMDEVINS pDevIns, PPDMIOAPICREG pIoApicReg, PCPDMIOAPICHLP *ppIoApicHlp));
4733
4734 /**
4735 * Sets up the HPET for the raw-mode context.
4736 *
4737 * This must be called after ring-3 has registered the PIC using
4738 * PDMDevHlpHpetRegister().
4739 *
4740 * @returns VBox status code.
4741 * @param pDevIns The device instance.
4742 * @param pHpetReg The PIC registration information for raw-mode,
4743 * considered volatile and copied.
4744 * @param ppHpetHlp Where to return the raw-mode HPET helpers.
4745 */
4746 DECLRCCALLBACKMEMBER(int, pfnHpetSetUpContext,(PPDMDEVINS pDevIns, PPDMHPETREG pHpetReg, PCPDMHPETHLPRC *ppHpetHlp));
4747
4748 /** Space reserved for future members.
4749 * @{ */
4750 DECLRCCALLBACKMEMBER(void, pfnReserved1,(void));
4751 DECLRCCALLBACKMEMBER(void, pfnReserved2,(void));
4752 DECLRCCALLBACKMEMBER(void, pfnReserved3,(void));
4753 DECLRCCALLBACKMEMBER(void, pfnReserved4,(void));
4754 DECLRCCALLBACKMEMBER(void, pfnReserved5,(void));
4755 DECLRCCALLBACKMEMBER(void, pfnReserved6,(void));
4756 DECLRCCALLBACKMEMBER(void, pfnReserved7,(void));
4757 DECLRCCALLBACKMEMBER(void, pfnReserved8,(void));
4758 DECLRCCALLBACKMEMBER(void, pfnReserved9,(void));
4759 DECLRCCALLBACKMEMBER(void, pfnReserved10,(void));
4760 /** @} */
4761
4762 /** Just a safety precaution. */
4763 uint32_t u32TheEnd;
4764} PDMDEVHLPRC;
4765/** Pointer PDM Device RC API. */
4766typedef RGPTRTYPE(struct PDMDEVHLPRC *) PPDMDEVHLPRC;
4767/** Pointer PDM Device RC API. */
4768typedef RGPTRTYPE(const struct PDMDEVHLPRC *) PCPDMDEVHLPRC;
4769
4770/** Current PDMDEVHLP version number. */
4771#define PDM_DEVHLPRC_VERSION PDM_VERSION_MAKE(0xffe6, 15, 0)
4772
4773
4774/**
4775 * PDM Device API - R0 Variant.
4776 */
4777typedef struct PDMDEVHLPR0
4778{
4779 /** Structure version. PDM_DEVHLPR0_VERSION defines the current version. */
4780 uint32_t u32Version;
4781
4782 /**
4783 * Sets up ring-0 callback handlers for an I/O port range.
4784 *
4785 * The range must have been created in ring-3 first using
4786 * PDMDevHlpIoPortCreate() or PDMDevHlpIoPortCreateEx().
4787 *
4788 * @returns VBox status.
4789 * @param pDevIns The device instance to register the ports with.
4790 * @param hIoPorts The I/O port range handle.
4791 * @param pfnOut Pointer to function which is gonna handle OUT
4792 * operations. Optional.
4793 * @param pfnIn Pointer to function which is gonna handle IN operations.
4794 * Optional.
4795 * @param pfnOutStr Pointer to function which is gonna handle string OUT
4796 * operations. Optional.
4797 * @param pfnInStr Pointer to function which is gonna handle string IN
4798 * operations. Optional.
4799 * @param pvUser User argument to pass to the callbacks.
4800 *
4801 * @remarks Caller enters the device critical section prior to invoking the
4802 * registered callback methods.
4803 *
4804 * @sa PDMDevHlpIoPortCreate(), PDMDevHlpIoPortCreateEx(),
4805 * PDMDevHlpIoPortMap(), PDMDevHlpIoPortUnmap().
4806 */
4807 DECLR0CALLBACKMEMBER(int, pfnIoPortSetUpContextEx,(PPDMDEVINS pDevIns, IOMIOPORTHANDLE hIoPorts,
4808 PFNIOMIOPORTNEWOUT pfnOut, PFNIOMIOPORTNEWIN pfnIn,
4809 PFNIOMIOPORTNEWOUTSTRING pfnOutStr, PFNIOMIOPORTNEWINSTRING pfnInStr,
4810 void *pvUser));
4811
4812 /**
4813 * Sets up ring-0 callback handlers for an MMIO region.
4814 *
4815 * The region must have been created in ring-3 first using
4816 * PDMDevHlpMmioCreate(), PDMDevHlpMmioCreateEx(), PDMDevHlpMmioCreateAndMap(),
4817 * PDMDevHlpMmioCreateExAndMap() or PDMDevHlpPCIIORegionCreateMmio().
4818 *
4819 * @returns VBox status.
4820 * @param pDevIns The device instance to register the ports with.
4821 * @param hRegion The MMIO region handle.
4822 * @param pfnWrite Pointer to function which is gonna handle Write
4823 * operations.
4824 * @param pfnRead Pointer to function which is gonna handle Read
4825 * operations.
4826 * @param pfnFill Pointer to function which is gonna handle Fill/memset
4827 * operations. (optional)
4828 * @param pvUser User argument to pass to the callbacks.
4829 *
4830 * @remarks Caller enters the device critical section prior to invoking the
4831 * registered callback methods.
4832 *
4833 * @sa PDMDevHlpMmioCreate(), PDMDevHlpMmioCreateEx(), PDMDevHlpMmioMap(),
4834 * PDMDevHlpMmioUnmap().
4835 */
4836 DECLR0CALLBACKMEMBER(int, pfnMmioSetUpContextEx,(PPDMDEVINS pDevIns, IOMMMIOHANDLE hRegion, PFNIOMMMIONEWWRITE pfnWrite,
4837 PFNIOMMMIONEWREAD pfnRead, PFNIOMMMIONEWFILL pfnFill, void *pvUser));
4838
4839 /**
4840 * Sets up a ring-0 mapping for an MMIO2 region.
4841 *
4842 * The region must have been created in ring-3 first using
4843 * PDMDevHlpMmio2Create().
4844 *
4845 * @returns VBox status.
4846 * @param pDevIns The device instance to register the ports with.
4847 * @param hRegion The MMIO2 region handle.
4848 * @param offSub Start of what to map into ring-0. Must be page aligned.
4849 * @param cbSub Number of bytes to map into ring-0. Must be page
4850 * aligned. Zero is an alias for everything.
4851 * @param ppvMapping Where to return the mapping corresponding to @a offSub.
4852 *
4853 * @thread EMT(0)
4854 * @note Only available at VM creation time.
4855 *
4856 * @sa PDMDevHlpMmio2Create().
4857 */
4858 DECLR0CALLBACKMEMBER(int, pfnMmio2SetUpContext,(PPDMDEVINS pDevIns, PGMMMIO2HANDLE hRegion, size_t offSub, size_t cbSub,
4859 void **ppvMapping));
4860
4861 /**
4862 * Bus master physical memory read from the given PCI device.
4863 *
4864 * @returns VINF_SUCCESS or VERR_PDM_NOT_PCI_BUS_MASTER, later maybe
4865 * VERR_EM_MEMORY.
4866 * @param pDevIns The device instance.
4867 * @param pPciDev The PCI device structure. If NULL the default
4868 * PCI device for this device instance is used.
4869 * @param GCPhys Physical address start reading from.
4870 * @param pvBuf Where to put the read bits.
4871 * @param cbRead How many bytes to read.
4872 * @param fFlags Combination of PDM_DEVHLP_PHYS_RW_F_XXX.
4873 * @thread Any thread, but the call may involve the emulation thread.
4874 */
4875 DECLR0CALLBACKMEMBER(int, pfnPCIPhysRead,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, RTGCPHYS GCPhys,
4876 void *pvBuf, size_t cbRead, uint32_t fFlags));
4877
4878 /**
4879 * Bus master physical memory write from the given PCI device.
4880 *
4881 * @returns VINF_SUCCESS or VERR_PDM_NOT_PCI_BUS_MASTER, later maybe
4882 * VERR_EM_MEMORY.
4883 * @param pDevIns The device instance.
4884 * @param pPciDev The PCI device structure. If NULL the default
4885 * PCI device for this device instance is used.
4886 * @param GCPhys Physical address to write to.
4887 * @param pvBuf What to write.
4888 * @param cbWrite How many bytes to write.
4889 * @param fFlags Combination of PDM_DEVHLP_PHYS_RW_F_XXX.
4890 * @thread Any thread, but the call may involve the emulation thread.
4891 */
4892 DECLR0CALLBACKMEMBER(int, pfnPCIPhysWrite,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, RTGCPHYS GCPhys,
4893 const void *pvBuf, size_t cbWrite, uint32_t fFlags));
4894
4895 /**
4896 * Set the IRQ for the given PCI device.
4897 *
4898 * @param pDevIns Device instance.
4899 * @param pPciDev The PCI device structure. If NULL the default
4900 * PCI device for this device instance is used.
4901 * @param iIrq IRQ number to set.
4902 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
4903 * @thread Any thread, but will involve the emulation thread.
4904 */
4905 DECLR0CALLBACKMEMBER(void, pfnPCISetIrq,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iIrq, int iLevel));
4906
4907 /**
4908 * Set ISA IRQ for a device.
4909 *
4910 * @param pDevIns Device instance.
4911 * @param iIrq IRQ number to set.
4912 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
4913 * @thread Any thread, but will involve the emulation thread.
4914 */
4915 DECLR0CALLBACKMEMBER(void, pfnISASetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
4916
4917 /**
4918 * Read physical memory.
4919 *
4920 * @returns VINF_SUCCESS (for now).
4921 * @param pDevIns Device instance.
4922 * @param GCPhys Physical address start reading from.
4923 * @param pvBuf Where to put the read bits.
4924 * @param cbRead How many bytes to read.
4925 * @param fFlags Combination of PDM_DEVHLP_PHYS_RW_F_XXX.
4926 */
4927 DECLR0CALLBACKMEMBER(int, pfnPhysRead,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead, uint32_t fFlags));
4928
4929 /**
4930 * Write to physical memory.
4931 *
4932 * @returns VINF_SUCCESS for now, and later maybe VERR_EM_MEMORY.
4933 * @param pDevIns Device instance.
4934 * @param GCPhys Physical address to write to.
4935 * @param pvBuf What to write.
4936 * @param cbWrite How many bytes to write.
4937 * @param fFlags Combination of PDM_DEVHLP_PHYS_RW_F_XXX.
4938 */
4939 DECLR0CALLBACKMEMBER(int, pfnPhysWrite,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite, uint32_t fFlags));
4940
4941 /**
4942 * Checks if the Gate A20 is enabled or not.
4943 *
4944 * @returns true if A20 is enabled.
4945 * @returns false if A20 is disabled.
4946 * @param pDevIns Device instance.
4947 * @thread The emulation thread.
4948 */
4949 DECLR0CALLBACKMEMBER(bool, pfnA20IsEnabled,(PPDMDEVINS pDevIns));
4950
4951 /**
4952 * Gets the VM state.
4953 *
4954 * @returns VM state.
4955 * @param pDevIns The device instance.
4956 * @thread Any thread (just keep in mind that it's volatile info).
4957 */
4958 DECLR0CALLBACKMEMBER(VMSTATE, pfnVMState, (PPDMDEVINS pDevIns));
4959
4960 /**
4961 * Set the VM error message
4962 *
4963 * @returns rc.
4964 * @param pDevIns Driver instance.
4965 * @param rc VBox status code.
4966 * @param SRC_POS Use RT_SRC_POS.
4967 * @param pszFormat Error message format string.
4968 * @param ... Error message arguments.
4969 */
4970 DECLR0CALLBACKMEMBER(int, pfnVMSetError,(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL,
4971 const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(6, 7));
4972
4973 /**
4974 * Set the VM error message
4975 *
4976 * @returns rc.
4977 * @param pDevIns Driver instance.
4978 * @param rc VBox status code.
4979 * @param SRC_POS Use RT_SRC_POS.
4980 * @param pszFormat Error message format string.
4981 * @param va Error message arguments.
4982 */
4983 DECLR0CALLBACKMEMBER(int, pfnVMSetErrorV,(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL,
4984 const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(6, 0));
4985
4986 /**
4987 * Set the VM runtime error message
4988 *
4989 * @returns VBox status code.
4990 * @param pDevIns Device instance.
4991 * @param fFlags The action flags. See VMSETRTERR_FLAGS_*.
4992 * @param pszErrorId Error ID string.
4993 * @param pszFormat Error message format string.
4994 * @param ... Error message arguments.
4995 */
4996 DECLR0CALLBACKMEMBER(int, pfnVMSetRuntimeError,(PPDMDEVINS pDevIns, uint32_t fFlags, const char *pszErrorId,
4997 const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(4, 5));
4998
4999 /**
5000 * Set the VM runtime error message
5001 *
5002 * @returns VBox status code.
5003 * @param pDevIns Device instance.
5004 * @param fFlags The action flags. See VMSETRTERR_FLAGS_*.
5005 * @param pszErrorId Error ID string.
5006 * @param pszFormat Error message format string.
5007 * @param va Error message arguments.
5008 */
5009 DECLR0CALLBACKMEMBER(int, pfnVMSetRuntimeErrorV,(PPDMDEVINS pDevIns, uint32_t fFlags, const char *pszErrorId,
5010 const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(4, 0));
5011
5012 /**
5013 * Gets the VM handle. Restricted API.
5014 *
5015 * @returns VM Handle.
5016 * @param pDevIns Device instance.
5017 */
5018 DECLR0CALLBACKMEMBER(PVMCC, pfnGetVM,(PPDMDEVINS pDevIns));
5019
5020 /**
5021 * Gets the VMCPU handle. Restricted API.
5022 *
5023 * @returns VMCPU Handle.
5024 * @param pDevIns The device instance.
5025 */
5026 DECLR0CALLBACKMEMBER(PVMCPUCC, pfnGetVMCPU,(PPDMDEVINS pDevIns));
5027
5028 /**
5029 * The the VM CPU ID of the current thread (restricted API).
5030 *
5031 * @returns The VMCPUID of the calling thread, NIL_VMCPUID if not EMT.
5032 * @param pDevIns The device instance.
5033 */
5034 DECLR0CALLBACKMEMBER(VMCPUID, pfnGetCurrentCpuId,(PPDMDEVINS pDevIns));
5035
5036 /**
5037 * Translates a timer handle to a pointer.
5038 *
5039 * @returns The time address.
5040 * @param pDevIns The device instance.
5041 * @param hTimer The timer handle.
5042 */
5043 DECLR0CALLBACKMEMBER(PTMTIMERR0, pfnTimerToPtr,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer));
5044
5045 /** @name Timer handle method wrappers
5046 * @{ */
5047 DECLR0CALLBACKMEMBER(uint64_t, pfnTimerFromMicro,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint64_t cMicroSecs));
5048 DECLR0CALLBACKMEMBER(uint64_t, pfnTimerFromMilli,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint64_t cMilliSecs));
5049 DECLR0CALLBACKMEMBER(uint64_t, pfnTimerFromNano,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint64_t cNanoSecs));
5050 DECLR0CALLBACKMEMBER(uint64_t, pfnTimerGet,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer));
5051 DECLR0CALLBACKMEMBER(uint64_t, pfnTimerGetFreq,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer));
5052 DECLR0CALLBACKMEMBER(uint64_t, pfnTimerGetNano,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer));
5053 DECLR0CALLBACKMEMBER(bool, pfnTimerIsActive,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer));
5054 DECLR0CALLBACKMEMBER(bool, pfnTimerIsLockOwner,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer));
5055 DECLR0CALLBACKMEMBER(VBOXSTRICTRC, pfnTimerLockClock,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, int rcBusy));
5056 /** Takes the clock lock then enters the specified critical section. */
5057 DECLR0CALLBACKMEMBER(VBOXSTRICTRC, pfnTimerLockClock2,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, PPDMCRITSECT pCritSect, int rcBusy));
5058 DECLR0CALLBACKMEMBER(int, pfnTimerSet,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint64_t uExpire));
5059 DECLR0CALLBACKMEMBER(int, pfnTimerSetFrequencyHint,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint32_t uHz));
5060 DECLR0CALLBACKMEMBER(int, pfnTimerSetMicro,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint64_t cMicrosToNext));
5061 DECLR0CALLBACKMEMBER(int, pfnTimerSetMillies,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint64_t cMilliesToNext));
5062 DECLR0CALLBACKMEMBER(int, pfnTimerSetNano,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint64_t cNanosToNext));
5063 DECLR0CALLBACKMEMBER(int, pfnTimerSetRelative,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint64_t cTicksToNext, uint64_t *pu64Now));
5064 DECLR0CALLBACKMEMBER(int, pfnTimerStop,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer));
5065 DECLR0CALLBACKMEMBER(void, pfnTimerUnlockClock,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer));
5066 DECLR0CALLBACKMEMBER(void, pfnTimerUnlockClock2,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, PPDMCRITSECT pCritSect));
5067 /** @} */
5068
5069 /**
5070 * Get the current virtual clock time in a VM. The clock frequency must be
5071 * queried separately.
5072 *
5073 * @returns Current clock time.
5074 * @param pDevIns The device instance.
5075 */
5076 DECLR0CALLBACKMEMBER(uint64_t, pfnTMTimeVirtGet,(PPDMDEVINS pDevIns));
5077
5078 /**
5079 * Get the frequency of the virtual clock.
5080 *
5081 * @returns The clock frequency (not variable at run-time).
5082 * @param pDevIns The device instance.
5083 */
5084 DECLR0CALLBACKMEMBER(uint64_t, pfnTMTimeVirtGetFreq,(PPDMDEVINS pDevIns));
5085
5086 /**
5087 * Get the current virtual clock time in a VM, in nanoseconds.
5088 *
5089 * @returns Current clock time (in ns).
5090 * @param pDevIns The device instance.
5091 */
5092 DECLR0CALLBACKMEMBER(uint64_t, pfnTMTimeVirtGetNano,(PPDMDEVINS pDevIns));
5093
5094 /** @name Exported PDM Queue Functions
5095 * @{ */
5096 DECLR0CALLBACKMEMBER(PPDMQUEUE, pfnQueueToPtr,(PPDMDEVINS pDevIns, PDMQUEUEHANDLE hQueue));
5097 DECLR0CALLBACKMEMBER(PPDMQUEUEITEMCORE, pfnQueueAlloc,(PPDMDEVINS pDevIns, PDMQUEUEHANDLE hQueue));
5098 DECLR0CALLBACKMEMBER(void, pfnQueueInsert,(PPDMDEVINS pDevIns, PDMQUEUEHANDLE hQueue, PPDMQUEUEITEMCORE pItem));
5099 DECLR0CALLBACKMEMBER(void, pfnQueueInsertEx,(PPDMDEVINS pDevIns, PDMQUEUEHANDLE hQueue, PPDMQUEUEITEMCORE pItem, uint64_t cNanoMaxDelay));
5100 DECLR0CALLBACKMEMBER(bool, pfnQueueFlushIfNecessary,(PPDMDEVINS pDevIns, PDMQUEUEHANDLE hQueue));
5101 /** @} */
5102
5103 /** @name PDM Task
5104 * @{ */
5105 /**
5106 * Triggers the running the given task.
5107 *
5108 * @returns VBox status code.
5109 * @retval VINF_ALREADY_POSTED is the task is already pending.
5110 * @param pDevIns The device instance.
5111 * @param hTask The task to trigger.
5112 * @thread Any thread.
5113 */
5114 DECLR0CALLBACKMEMBER(int, pfnTaskTrigger,(PPDMDEVINS pDevIns, PDMTASKHANDLE hTask));
5115 /** @} */
5116
5117 /** @name SUP Event Semaphore Wrappers (single release / auto reset)
5118 * These semaphores can be signalled from ring-0.
5119 * @{ */
5120 /** @sa SUPSemEventSignal */
5121 DECLR0CALLBACKMEMBER(int, pfnSUPSemEventSignal,(PPDMDEVINS pDevIns, SUPSEMEVENT hEvent));
5122 /** @sa SUPSemEventWaitNoResume */
5123 DECLR0CALLBACKMEMBER(int, pfnSUPSemEventWaitNoResume,(PPDMDEVINS pDevIns, SUPSEMEVENT hEvent, uint32_t cMillies));
5124 /** @sa SUPSemEventWaitNsAbsIntr */
5125 DECLR0CALLBACKMEMBER(int, pfnSUPSemEventWaitNsAbsIntr,(PPDMDEVINS pDevIns, SUPSEMEVENT hEvent, uint64_t uNsTimeout));
5126 /** @sa SUPSemEventWaitNsRelIntr */
5127 DECLR0CALLBACKMEMBER(int, pfnSUPSemEventWaitNsRelIntr,(PPDMDEVINS pDevIns, SUPSEMEVENT hEvent, uint64_t cNsTimeout));
5128 /** @sa SUPSemEventGetResolution */
5129 DECLR0CALLBACKMEMBER(uint32_t, pfnSUPSemEventGetResolution,(PPDMDEVINS pDevIns));
5130 /** @} */
5131
5132 /** @name SUP Multi Event Semaphore Wrappers (multiple release / manual reset)
5133 * These semaphores can be signalled from ring-0.
5134 * @{ */
5135 /** @sa SUPSemEventMultiSignal */
5136 DECLR0CALLBACKMEMBER(int, pfnSUPSemEventMultiSignal,(PPDMDEVINS pDevIns, SUPSEMEVENTMULTI hEventMulti));
5137 /** @sa SUPSemEventMultiReset */
5138 DECLR0CALLBACKMEMBER(int, pfnSUPSemEventMultiReset,(PPDMDEVINS pDevIns, SUPSEMEVENTMULTI hEventMulti));
5139 /** @sa SUPSemEventMultiWaitNoResume */
5140 DECLR0CALLBACKMEMBER(int, pfnSUPSemEventMultiWaitNoResume,(PPDMDEVINS pDevIns, SUPSEMEVENTMULTI hEventMulti, uint32_t cMillies));
5141 /** @sa SUPSemEventMultiWaitNsAbsIntr */
5142 DECLR0CALLBACKMEMBER(int, pfnSUPSemEventMultiWaitNsAbsIntr,(PPDMDEVINS pDevIns, SUPSEMEVENTMULTI hEventMulti, uint64_t uNsTimeout));
5143 /** @sa SUPSemEventMultiWaitNsRelIntr */
5144 DECLR0CALLBACKMEMBER(int, pfnSUPSemEventMultiWaitNsRelIntr,(PPDMDEVINS pDevIns, SUPSEMEVENTMULTI hEventMulti, uint64_t cNsTimeout));
5145 /** @sa SUPSemEventMultiGetResolution */
5146 DECLR0CALLBACKMEMBER(uint32_t, pfnSUPSemEventMultiGetResolution,(PPDMDEVINS pDevIns));
5147 /** @} */
5148
5149 /**
5150 * Gets the NOP critical section.
5151 *
5152 * @returns The ring-3 address of the NOP critical section.
5153 * @param pDevIns The device instance.
5154 */
5155 DECLR0CALLBACKMEMBER(PPDMCRITSECT, pfnCritSectGetNop,(PPDMDEVINS pDevIns));
5156
5157 /**
5158 * Changes the device level critical section from the automatically created
5159 * default to one desired by the device constructor.
5160 *
5161 * Must first be done in ring-3.
5162 *
5163 * @returns VBox status code.
5164 * @param pDevIns The device instance.
5165 * @param pCritSect The critical section to use. NULL is not
5166 * valid, instead use the NOP critical
5167 * section.
5168 */
5169 DECLR0CALLBACKMEMBER(int, pfnSetDeviceCritSect,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect));
5170
5171 /** @name Exported PDM Critical Section Functions
5172 * @{ */
5173 DECLR0CALLBACKMEMBER(int, pfnCritSectEnter,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, int rcBusy));
5174 DECLR0CALLBACKMEMBER(int, pfnCritSectEnterDebug,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, int rcBusy, RTHCUINTPTR uId, RT_SRC_POS_DECL));
5175 DECLR0CALLBACKMEMBER(int, pfnCritSectTryEnter,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect));
5176 DECLR0CALLBACKMEMBER(int, pfnCritSectTryEnterDebug,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, RTHCUINTPTR uId, RT_SRC_POS_DECL));
5177 DECLR0CALLBACKMEMBER(int, pfnCritSectLeave,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect));
5178 DECLR0CALLBACKMEMBER(bool, pfnCritSectIsOwner,(PPDMDEVINS pDevIns, PCPDMCRITSECT pCritSect));
5179 DECLR0CALLBACKMEMBER(bool, pfnCritSectIsInitialized,(PPDMDEVINS pDevIns, PCPDMCRITSECT pCritSect));
5180 DECLR0CALLBACKMEMBER(bool, pfnCritSectHasWaiters,(PPDMDEVINS pDevIns, PCPDMCRITSECT pCritSect));
5181 DECLR0CALLBACKMEMBER(uint32_t, pfnCritSectGetRecursion,(PPDMDEVINS pDevIns, PCPDMCRITSECT pCritSect));
5182 DECLR0CALLBACKMEMBER(int, pfnCritSectScheduleExitEvent,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, SUPSEMEVENT hEventToSignal));
5183 /** @} */
5184
5185 /**
5186 * Gets the trace buffer handle.
5187 *
5188 * This is used by the macros found in VBox/vmm/dbgftrace.h and is not
5189 * really inteded for direct usage, thus no inline wrapper function.
5190 *
5191 * @returns Trace buffer handle or NIL_RTTRACEBUF.
5192 * @param pDevIns The device instance.
5193 */
5194 DECLR0CALLBACKMEMBER(RTTRACEBUF, pfnDBGFTraceBuf,(PPDMDEVINS pDevIns));
5195
5196 /**
5197 * Sets up the PCI bus for the ring-0 context.
5198 *
5199 * This must be called after ring-3 has registered the PCI bus using
5200 * PDMDevHlpPCIBusRegister().
5201 *
5202 * @returns VBox status code.
5203 * @param pDevIns The device instance.
5204 * @param pPciBusReg The PCI bus registration information for ring-0,
5205 * considered volatile and copied.
5206 * @param ppPciHlp Where to return the ring-0 PCI bus helpers.
5207 */
5208 DECLR0CALLBACKMEMBER(int, pfnPCIBusSetUpContext,(PPDMDEVINS pDevIns, PPDMPCIBUSREGR0 pPciBusReg, PCPDMPCIHLPR0 *ppPciHlp));
5209
5210 /**
5211 * Sets up the IOMMU for the ring-0 context.
5212 *
5213 * This must be called after ring-3 has registered the IOMMU using
5214 * PDMDevHlpIommuRegister().
5215 *
5216 * @returns VBox status code.
5217 * @param pDevIns The device instance.
5218 * @param pIommuReg The IOMMU registration information for ring-0,
5219 * considered volatile and copied.
5220 * @param ppIommuHlp Where to return the ring-0 IOMMU helpers.
5221 */
5222 DECLR0CALLBACKMEMBER(int, pfnIommuSetUpContext,(PPDMDEVINS pDevIns, PPDMIOMMUREGR0 pIommuReg, PCPDMIOMMUHLPR0 *ppIommuHlp));
5223
5224 /**
5225 * Sets up the PIC for the ring-0 context.
5226 *
5227 * This must be called after ring-3 has registered the PIC using
5228 * PDMDevHlpPICRegister().
5229 *
5230 * @returns VBox status code.
5231 * @param pDevIns The device instance.
5232 * @param pPicReg The PIC registration information for ring-0,
5233 * considered volatile and copied.
5234 * @param ppPicHlp Where to return the ring-0 PIC helpers.
5235 */
5236 DECLR0CALLBACKMEMBER(int, pfnPICSetUpContext,(PPDMDEVINS pDevIns, PPDMPICREG pPicReg, PCPDMPICHLP *ppPicHlp));
5237
5238 /**
5239 * Sets up the APIC for the ring-0 context.
5240 *
5241 * This must be called after ring-3 has registered the APIC using
5242 * PDMDevHlpApicRegister().
5243 *
5244 * @returns VBox status code.
5245 * @param pDevIns The device instance.
5246 */
5247 DECLR0CALLBACKMEMBER(int, pfnApicSetUpContext,(PPDMDEVINS pDevIns));
5248
5249 /**
5250 * Sets up the IOAPIC for the ring-0 context.
5251 *
5252 * This must be called after ring-3 has registered the PIC using
5253 * PDMDevHlpIoApicRegister().
5254 *
5255 * @returns VBox status code.
5256 * @param pDevIns The device instance.
5257 * @param pIoApicReg The PIC registration information for ring-0,
5258 * considered volatile and copied.
5259 * @param ppIoApicHlp Where to return the ring-0 IOAPIC helpers.
5260 */
5261 DECLR0CALLBACKMEMBER(int, pfnIoApicSetUpContext,(PPDMDEVINS pDevIns, PPDMIOAPICREG pIoApicReg, PCPDMIOAPICHLP *ppIoApicHlp));
5262
5263 /**
5264 * Sets up the HPET for the ring-0 context.
5265 *
5266 * This must be called after ring-3 has registered the PIC using
5267 * PDMDevHlpHpetRegister().
5268 *
5269 * @returns VBox status code.
5270 * @param pDevIns The device instance.
5271 * @param pHpetReg The PIC registration information for ring-0,
5272 * considered volatile and copied.
5273 * @param ppHpetHlp Where to return the ring-0 HPET helpers.
5274 */
5275 DECLR0CALLBACKMEMBER(int, pfnHpetSetUpContext,(PPDMDEVINS pDevIns, PPDMHPETREG pHpetReg, PCPDMHPETHLPR0 *ppHpetHlp));
5276
5277 /** Space reserved for future members.
5278 * @{ */
5279 DECLR0CALLBACKMEMBER(void, pfnReserved1,(void));
5280 DECLR0CALLBACKMEMBER(void, pfnReserved2,(void));
5281 DECLR0CALLBACKMEMBER(void, pfnReserved3,(void));
5282 DECLR0CALLBACKMEMBER(void, pfnReserved4,(void));
5283 DECLR0CALLBACKMEMBER(void, pfnReserved5,(void));
5284 DECLR0CALLBACKMEMBER(void, pfnReserved6,(void));
5285 DECLR0CALLBACKMEMBER(void, pfnReserved7,(void));
5286 DECLR0CALLBACKMEMBER(void, pfnReserved8,(void));
5287 DECLR0CALLBACKMEMBER(void, pfnReserved9,(void));
5288 DECLR0CALLBACKMEMBER(void, pfnReserved10,(void));
5289 /** @} */
5290
5291 /** Just a safety precaution. */
5292 uint32_t u32TheEnd;
5293} PDMDEVHLPR0;
5294/** Pointer PDM Device R0 API. */
5295typedef R0PTRTYPE(struct PDMDEVHLPR0 *) PPDMDEVHLPR0;
5296/** Pointer PDM Device GC API. */
5297typedef R0PTRTYPE(const struct PDMDEVHLPR0 *) PCPDMDEVHLPR0;
5298
5299/** Current PDMDEVHLP version number. */
5300#define PDM_DEVHLPR0_VERSION PDM_VERSION_MAKE(0xffe5, 17, 0)
5301
5302
5303/**
5304 * PDM Device Instance.
5305 */
5306typedef struct PDMDEVINSR3
5307{
5308 /** Structure version. PDM_DEVINSR3_VERSION defines the current version. */
5309 uint32_t u32Version;
5310 /** Device instance number. */
5311 uint32_t iInstance;
5312 /** Size of the ring-3, raw-mode and shared bits. */
5313 uint32_t cbRing3;
5314 /** Set if ring-0 context is enabled. */
5315 bool fR0Enabled;
5316 /** Set if raw-mode context is enabled. */
5317 bool fRCEnabled;
5318 /** Alignment padding. */
5319 bool afReserved[2];
5320 /** Pointer the HC PDM Device API. */
5321 PCPDMDEVHLPR3 pHlpR3;
5322 /** Pointer to the shared device instance data. */
5323 RTR3PTR pvInstanceDataR3;
5324 /** Pointer to the device instance data for ring-3. */
5325 RTR3PTR pvInstanceDataForR3;
5326 /** The critical section for the device.
5327 *
5328 * TM and IOM will enter this critical section before calling into the device
5329 * code. PDM will when doing power on, power off, reset, suspend and resume
5330 * notifications. SSM will currently not, but this will be changed later on.
5331 *
5332 * The device gets a critical section automatically assigned to it before
5333 * the constructor is called. If the constructor wishes to use a different
5334 * critical section, it calls PDMDevHlpSetDeviceCritSect() to change it
5335 * very early on.
5336 */
5337 R3PTRTYPE(PPDMCRITSECT) pCritSectRoR3;
5338 /** Pointer to device registration structure. */
5339 R3PTRTYPE(PCPDMDEVREG) pReg;
5340 /** Configuration handle. */
5341 R3PTRTYPE(PCFGMNODE) pCfg;
5342 /** The base interface of the device.
5343 *
5344 * The device constructor initializes this if it has any
5345 * device level interfaces to export. To obtain this interface
5346 * call PDMR3QueryDevice(). */
5347 PDMIBASE IBase;
5348
5349 /** Tracing indicator. */
5350 uint32_t fTracing;
5351 /** The tracing ID of this device. */
5352 uint32_t idTracing;
5353
5354 /** Ring-3 pointer to the raw-mode device instance. */
5355 R3PTRTYPE(struct PDMDEVINSRC *) pDevInsForRCR3;
5356 /** Raw-mode address of the raw-mode device instance. */
5357 RTRGPTR pDevInsForRC;
5358 /** Ring-3 pointer to the raw-mode instance data. */
5359 RTR3PTR pvInstanceDataForRCR3;
5360
5361 /** PCI device structure size. */
5362 uint32_t cbPciDev;
5363 /** Number of PCI devices in apPciDevs. */
5364 uint32_t cPciDevs;
5365 /** Pointer to the PCI devices for this device.
5366 * (Allocated after the shared instance data.)
5367 * @note If we want to extend this beyond 8 sub-functions/devices, those 1 or
5368 * two devices ever needing it can use cbPciDev and do the address
5369 * calculations that for entries 8+. */
5370 R3PTRTYPE(struct PDMPCIDEV *) apPciDevs[8];
5371
5372 /** Temporarily. */
5373 R0PTRTYPE(struct PDMDEVINSR0 *) pDevInsR0RemoveMe;
5374 /** Temporarily. */
5375 RTR0PTR pvInstanceDataR0;
5376 /** Temporarily. */
5377 RTRCPTR pvInstanceDataRC;
5378 /** Align the internal data more naturally. */
5379 uint32_t au32Padding[HC_ARCH_BITS == 32 ? 13 : 11];
5380
5381 /** Internal data. */
5382 union
5383 {
5384#ifdef PDMDEVINSINT_DECLARED
5385 PDMDEVINSINTR3 s;
5386#endif
5387 uint8_t padding[HC_ARCH_BITS == 32 ? 0x40 : 0x90];
5388 } Internal;
5389
5390 /** Device instance data for ring-3. The size of this area is defined
5391 * in the PDMDEVREG::cbInstanceR3 field. */
5392 char achInstanceData[8];
5393} PDMDEVINSR3;
5394
5395/** Current PDMDEVINSR3 version number. */
5396#define PDM_DEVINSR3_VERSION PDM_VERSION_MAKE(0xff82, 4, 0)
5397
5398/** Converts a pointer to the PDMDEVINSR3::IBase to a pointer to PDMDEVINS. */
5399#define PDMIBASE_2_PDMDEV(pInterface) ( (PPDMDEVINS)((char *)(pInterface) - RT_UOFFSETOF(PDMDEVINS, IBase)) )
5400
5401
5402/**
5403 * PDM ring-0 device instance.
5404 */
5405typedef struct PDMDEVINSR0
5406{
5407 /** Structure version. PDM_DEVINSR0_VERSION defines the current version. */
5408 uint32_t u32Version;
5409 /** Device instance number. */
5410 uint32_t iInstance;
5411
5412 /** Pointer the HC PDM Device API. */
5413 PCPDMDEVHLPR0 pHlpR0;
5414 /** Pointer to the shared device instance data. */
5415 RTR0PTR pvInstanceDataR0;
5416 /** Pointer to the device instance data for ring-0. */
5417 RTR0PTR pvInstanceDataForR0;
5418 /** The critical section for the device.
5419 *
5420 * TM and IOM will enter this critical section before calling into the device
5421 * code. PDM will when doing power on, power off, reset, suspend and resume
5422 * notifications. SSM will currently not, but this will be changed later on.
5423 *
5424 * The device gets a critical section automatically assigned to it before
5425 * the constructor is called. If the constructor wishes to use a different
5426 * critical section, it calls PDMDevHlpSetDeviceCritSect() to change it
5427 * very early on.
5428 */
5429 R0PTRTYPE(PPDMCRITSECT) pCritSectRoR0;
5430 /** Pointer to the ring-0 device registration structure. */
5431 R0PTRTYPE(PCPDMDEVREGR0) pReg;
5432 /** Ring-3 address of the ring-3 device instance. */
5433 R3PTRTYPE(struct PDMDEVINSR3 *) pDevInsForR3;
5434 /** Ring-0 pointer to the ring-3 device instance. */
5435 R0PTRTYPE(struct PDMDEVINSR3 *) pDevInsForR3R0;
5436 /** Ring-0 pointer to the ring-3 instance data. */
5437 RTR0PTR pvInstanceDataForR3R0;
5438 /** Raw-mode address of the raw-mode device instance. */
5439 RGPTRTYPE(struct PDMDEVINSRC *) pDevInsForRC;
5440 /** Ring-0 pointer to the raw-mode device instance. */
5441 R0PTRTYPE(struct PDMDEVINSRC *) pDevInsForRCR0;
5442 /** Ring-0 pointer to the raw-mode instance data. */
5443 RTR0PTR pvInstanceDataForRCR0;
5444
5445 /** PCI device structure size. */
5446 uint32_t cbPciDev;
5447 /** Number of PCI devices in apPciDevs. */
5448 uint32_t cPciDevs;
5449 /** Pointer to the PCI devices for this device.
5450 * (Allocated after the shared instance data.)
5451 * @note If we want to extend this beyond 8 sub-functions/devices, those 1 or
5452 * two devices ever needing it can use cbPciDev and do the address
5453 * calculations that for entries 8+. */
5454 R0PTRTYPE(struct PDMPCIDEV *) apPciDevs[8];
5455
5456 /** Align the internal data more naturally. */
5457 uint32_t au32Padding[HC_ARCH_BITS == 32 ? 3 : 2 + 4];
5458
5459 /** Internal data. */
5460 union
5461 {
5462#ifdef PDMDEVINSINT_DECLARED
5463 PDMDEVINSINTR0 s;
5464#endif
5465 uint8_t padding[HC_ARCH_BITS == 32 ? 0x40 : 0x80];
5466 } Internal;
5467
5468 /** Device instance data for ring-0. The size of this area is defined
5469 * in the PDMDEVREG::cbInstanceR0 field. */
5470 char achInstanceData[8];
5471} PDMDEVINSR0;
5472
5473/** Current PDMDEVINSR0 version number. */
5474#define PDM_DEVINSR0_VERSION PDM_VERSION_MAKE(0xff83, 4, 0)
5475
5476
5477/**
5478 * PDM raw-mode device instance.
5479 */
5480typedef struct PDMDEVINSRC
5481{
5482 /** Structure version. PDM_DEVINSRC_VERSION defines the current version. */
5483 uint32_t u32Version;
5484 /** Device instance number. */
5485 uint32_t iInstance;
5486
5487 /** Pointer the HC PDM Device API. */
5488 PCPDMDEVHLPRC pHlpRC;
5489 /** Pointer to the shared device instance data. */
5490 RTRGPTR pvInstanceDataRC;
5491 /** Pointer to the device instance data for raw-mode. */
5492 RTRGPTR pvInstanceDataForRC;
5493 /** The critical section for the device.
5494 *
5495 * TM and IOM will enter this critical section before calling into the device
5496 * code. PDM will when doing power on, power off, reset, suspend and resume
5497 * notifications. SSM will currently not, but this will be changed later on.
5498 *
5499 * The device gets a critical section automatically assigned to it before
5500 * the constructor is called. If the constructor wishes to use a different
5501 * critical section, it calls PDMDevHlpSetDeviceCritSect() to change it
5502 * very early on.
5503 */
5504 RGPTRTYPE(PPDMCRITSECT) pCritSectRoRC;
5505 /** Pointer to the raw-mode device registration structure. */
5506 RGPTRTYPE(PCPDMDEVREGRC) pReg;
5507
5508 /** PCI device structure size. */
5509 uint32_t cbPciDev;
5510 /** Number of PCI devices in apPciDevs. */
5511 uint32_t cPciDevs;
5512 /** Pointer to the PCI devices for this device.
5513 * (Allocated after the shared instance data.) */
5514 RGPTRTYPE(struct PDMPCIDEV *) apPciDevs[8];
5515
5516 /** Align the internal data more naturally. */
5517 uint32_t au32Padding[14];
5518
5519 /** Internal data. */
5520 union
5521 {
5522#ifdef PDMDEVINSINT_DECLARED
5523 PDMDEVINSINTRC s;
5524#endif
5525 uint8_t padding[0x10];
5526 } Internal;
5527
5528 /** Device instance data for ring-0. The size of this area is defined
5529 * in the PDMDEVREG::cbInstanceR0 field. */
5530 char achInstanceData[8];
5531} PDMDEVINSRC;
5532
5533/** Current PDMDEVINSR0 version number. */
5534#define PDM_DEVINSRC_VERSION PDM_VERSION_MAKE(0xff84, 4, 0)
5535
5536
5537/** @def PDM_DEVINS_VERSION
5538 * Current PDMDEVINS version number. */
5539/** @typedef PDMDEVINS
5540 * The device instance structure for the current context. */
5541#ifdef IN_RING3
5542# define PDM_DEVINS_VERSION PDM_DEVINSR3_VERSION
5543typedef PDMDEVINSR3 PDMDEVINS;
5544#elif defined(IN_RING0)
5545# define PDM_DEVINS_VERSION PDM_DEVINSR0_VERSION
5546typedef PDMDEVINSR0 PDMDEVINS;
5547#elif defined(IN_RC)
5548# define PDM_DEVINS_VERSION PDM_DEVINSRC_VERSION
5549typedef PDMDEVINSRC PDMDEVINS;
5550#else
5551# error "Missing context defines: IN_RING0, IN_RING3, IN_RC"
5552#endif
5553
5554/**
5555 * Get the pointer to an PCI device.
5556 * @note Returns NULL if @a a_idxPciDev is out of bounds.
5557 */
5558#define PDMDEV_GET_PPCIDEV(a_pDevIns, a_idxPciDev) \
5559 ( (uintptr_t)(a_idxPciDev) < RT_ELEMENTS((a_pDevIns)->apPciDevs) ? (a_pDevIns)->apPciDevs[(uintptr_t)(a_idxPciDev)] \
5560 : PDMDEV_CALC_PPCIDEV(a_pDevIns, a_idxPciDev) )
5561
5562/**
5563 * Calc the pointer to of a given PCI device.
5564 * @note Returns NULL if @a a_idxPciDev is out of bounds.
5565 */
5566#define PDMDEV_CALC_PPCIDEV(a_pDevIns, a_idxPciDev) \
5567 ( (uintptr_t)(a_idxPciDev) < (a_pDevIns)->cPciDevs \
5568 ? (PPDMPCIDEV)((uint8_t *)((a_pDevIns)->apPciDevs[0]) + (a_pDevIns->cbPciDev) * (uintptr_t)(a_idxPciDev)) \
5569 : (PPDMPCIDEV)NULL )
5570
5571
5572/**
5573 * Checks the structure versions of the device instance and device helpers,
5574 * returning if they are incompatible.
5575 *
5576 * This is for use in the constructor.
5577 *
5578 * @param pDevIns The device instance pointer.
5579 */
5580#define PDMDEV_CHECK_VERSIONS_RETURN(pDevIns) \
5581 do \
5582 { \
5583 PPDMDEVINS pDevInsTypeCheck = (pDevIns); NOREF(pDevInsTypeCheck); \
5584 AssertLogRelMsgReturn(PDM_VERSION_ARE_COMPATIBLE((pDevIns)->u32Version, PDM_DEVINS_VERSION), \
5585 ("DevIns=%#x mine=%#x\n", (pDevIns)->u32Version, PDM_DEVINS_VERSION), \
5586 VERR_PDM_DEVINS_VERSION_MISMATCH); \
5587 AssertLogRelMsgReturn(PDM_VERSION_ARE_COMPATIBLE((pDevIns)->CTX_SUFF(pHlp)->u32Version, CTX_MID(PDM_DEVHLP,_VERSION)), \
5588 ("DevHlp=%#x mine=%#x\n", (pDevIns)->CTX_SUFF(pHlp)->u32Version, CTX_MID(PDM_DEVHLP,_VERSION)), \
5589 VERR_PDM_DEVHLP_VERSION_MISMATCH); \
5590 } while (0)
5591
5592/**
5593 * Quietly checks the structure versions of the device instance and device
5594 * helpers, returning if they are incompatible.
5595 *
5596 * This is for use in the destructor.
5597 *
5598 * @param pDevIns The device instance pointer.
5599 */
5600#define PDMDEV_CHECK_VERSIONS_RETURN_QUIET(pDevIns) \
5601 do \
5602 { \
5603 PPDMDEVINS pDevInsTypeCheck = (pDevIns); NOREF(pDevInsTypeCheck); \
5604 if (RT_LIKELY(PDM_VERSION_ARE_COMPATIBLE((pDevIns)->u32Version, PDM_DEVINS_VERSION) )) \
5605 { /* likely */ } else return VERR_PDM_DEVINS_VERSION_MISMATCH; \
5606 if (RT_LIKELY(PDM_VERSION_ARE_COMPATIBLE((pDevIns)->CTX_SUFF(pHlp)->u32Version, CTX_MID(PDM_DEVHLP,_VERSION)) )) \
5607 { /* likely */ } else return VERR_PDM_DEVHLP_VERSION_MISMATCH; \
5608 } while (0)
5609
5610/**
5611 * Wrapper around CFGMR3ValidateConfig for the root config for use in the
5612 * constructor - returns on failure.
5613 *
5614 * This should be invoked after having initialized the instance data
5615 * sufficiently for the correct operation of the destructor. The destructor is
5616 * always called!
5617 *
5618 * @param pDevIns Pointer to the PDM device instance.
5619 * @param pszValidValues Patterns describing the valid value names. See
5620 * RTStrSimplePatternMultiMatch for details on the
5621 * pattern syntax.
5622 * @param pszValidNodes Patterns describing the valid node (key) names.
5623 * Pass empty string if no valid nodes.
5624 */
5625#define PDMDEV_VALIDATE_CONFIG_RETURN(pDevIns, pszValidValues, pszValidNodes) \
5626 do \
5627 { \
5628 int rcValCfg = pDevIns->pHlpR3->pfnCFGMValidateConfig((pDevIns)->pCfg, "/", pszValidValues, pszValidNodes, \
5629 (pDevIns)->pReg->szName, (pDevIns)->iInstance); \
5630 if (RT_SUCCESS(rcValCfg)) \
5631 { /* likely */ } else return rcValCfg; \
5632 } while (0)
5633
5634/** @def PDMDEV_ASSERT_EMT
5635 * Assert that the current thread is the emulation thread.
5636 */
5637#ifdef VBOX_STRICT
5638# define PDMDEV_ASSERT_EMT(pDevIns) pDevIns->pHlpR3->pfnAssertEMT(pDevIns, __FILE__, __LINE__, __FUNCTION__)
5639#else
5640# define PDMDEV_ASSERT_EMT(pDevIns) do { } while (0)
5641#endif
5642
5643/** @def PDMDEV_ASSERT_OTHER
5644 * Assert that the current thread is NOT the emulation thread.
5645 */
5646#ifdef VBOX_STRICT
5647# define PDMDEV_ASSERT_OTHER(pDevIns) pDevIns->pHlpR3->pfnAssertOther(pDevIns, __FILE__, __LINE__, __FUNCTION__)
5648#else
5649# define PDMDEV_ASSERT_OTHER(pDevIns) do { } while (0)
5650#endif
5651
5652/** @def PDMDEV_ASSERT_VMLOCK_OWNER
5653 * Assert that the current thread is owner of the VM lock.
5654 */
5655#ifdef VBOX_STRICT
5656# define PDMDEV_ASSERT_VMLOCK_OWNER(pDevIns) pDevIns->pHlpR3->pfnAssertVMLock(pDevIns, __FILE__, __LINE__, __FUNCTION__)
5657#else
5658# define PDMDEV_ASSERT_VMLOCK_OWNER(pDevIns) do { } while (0)
5659#endif
5660
5661/** @def PDMDEV_SET_ERROR
5662 * Set the VM error. See PDMDevHlpVMSetError() for printf like message formatting.
5663 */
5664#define PDMDEV_SET_ERROR(pDevIns, rc, pszError) \
5665 PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS, "%s", pszError)
5666
5667/** @def PDMDEV_SET_RUNTIME_ERROR
5668 * Set the VM runtime error. See PDMDevHlpVMSetRuntimeError() for printf like message formatting.
5669 */
5670#define PDMDEV_SET_RUNTIME_ERROR(pDevIns, fFlags, pszErrorId, pszError) \
5671 PDMDevHlpVMSetRuntimeError(pDevIns, fFlags, pszErrorId, "%s", pszError)
5672
5673/** @def PDMDEVINS_2_RCPTR
5674 * Converts a PDM Device instance pointer a RC PDM Device instance pointer.
5675 */
5676#ifdef IN_RC
5677# define PDMDEVINS_2_RCPTR(pDevIns) (pDevIns)
5678#else
5679# define PDMDEVINS_2_RCPTR(pDevIns) ( (pDevIns)->pDevInsForRC )
5680#endif
5681
5682/** @def PDMDEVINS_2_R3PTR
5683 * Converts a PDM Device instance pointer a R3 PDM Device instance pointer.
5684 */
5685#ifdef IN_RING3
5686# define PDMDEVINS_2_R3PTR(pDevIns) (pDevIns)
5687#else
5688# define PDMDEVINS_2_R3PTR(pDevIns) ( (pDevIns)->pDevInsForR3 )
5689#endif
5690
5691/** @def PDMDEVINS_2_R0PTR
5692 * Converts a PDM Device instance pointer a R0 PDM Device instance pointer.
5693 */
5694#ifdef IN_RING0
5695# define PDMDEVINS_2_R0PTR(pDevIns) (pDevIns)
5696#else
5697# define PDMDEVINS_2_R0PTR(pDevIns) ( (pDevIns)->pDevInsR0RemoveMe )
5698#endif
5699
5700/** @def PDMDEVINS_DATA_2_R0_REMOVE_ME
5701 * Converts a PDM device instance data pointer to a ring-0 one.
5702 * @deprecated
5703 */
5704#ifdef IN_RING0
5705# define PDMDEVINS_DATA_2_R0_REMOVE_ME(pDevIns, pvCC) (pvCC)
5706#else
5707# define PDMDEVINS_DATA_2_R0_REMOVE_ME(pDevIns, pvCC) ( (pDevIns)->pvInstanceDataR0 + (uintptr_t)(pvCC) - (uintptr_t)(pDevIns)->CTX_SUFF(pvInstanceData) )
5708#endif
5709
5710
5711/** @def PDMDEVINS_2_DATA
5712 * This is a safer edition of PDMINS_2_DATA that checks that the size of the
5713 * target type is same as PDMDEVREG::cbInstanceShared in strict builds.
5714 *
5715 * @note Do no use this macro in common code working on a core structure which
5716 * device specific code has expanded.
5717 */
5718#if defined(VBOX_STRICT) && defined(RT_COMPILER_SUPPORTS_LAMBDA)
5719# define PDMDEVINS_2_DATA(a_pDevIns, a_PtrType) \
5720 ([](PPDMDEVINS a_pLambdaDevIns) -> a_PtrType \
5721 { \
5722 a_PtrType pLambdaRet = (a_PtrType)(a_pLambdaDevIns)->CTX_SUFF(pvInstanceData); \
5723 Assert(sizeof(*pLambdaRet) == a_pLambdaDevIns->pReg->cbInstanceShared); \
5724 return pLambdaRet; \
5725 }(a_pDevIns))
5726#else
5727# define PDMDEVINS_2_DATA(a_pDevIns, a_PtrType) ( (a_PtrType)(a_pDevIns)->CTX_SUFF(pvInstanceData) )
5728#endif
5729
5730/** @def PDMDEVINS_2_DATA_CC
5731 * This is a safer edition of PDMINS_2_DATA_CC that checks that the size of the
5732 * target type is same as PDMDEVREG::cbInstanceCC in strict builds.
5733 *
5734 * @note Do no use this macro in common code working on a core structure which
5735 * device specific code has expanded.
5736 */
5737#if defined(VBOX_STRICT) && defined(RT_COMPILER_SUPPORTS_LAMBDA)
5738# define PDMDEVINS_2_DATA_CC(a_pDevIns, a_PtrType) \
5739 ([](PPDMDEVINS a_pLambdaDevIns) -> a_PtrType \
5740 { \
5741 a_PtrType pLambdaRet = (a_PtrType)&(a_pLambdaDevIns)->achInstanceData[0]; \
5742 Assert(sizeof(*pLambdaRet) == a_pLambdaDevIns->pReg->cbInstanceCC); \
5743 return pLambdaRet; \
5744 }(a_pDevIns))
5745#else
5746# define PDMDEVINS_2_DATA_CC(a_pDevIns, a_PtrType) ( (a_PtrType)(void *)&(a_pDevIns)->achInstanceData[0] )
5747#endif
5748
5749
5750#ifdef IN_RING3
5751
5752/**
5753 * Combines PDMDevHlpIoPortCreate() & PDMDevHlpIoPortMap().
5754 */
5755DECLINLINE(int) PDMDevHlpIoPortCreateAndMap(PPDMDEVINS pDevIns, RTIOPORT Port, RTIOPORT cPorts, PFNIOMIOPORTNEWOUT pfnOut,
5756 PFNIOMIOPORTNEWIN pfnIn, const char *pszDesc, PCIOMIOPORTDESC paExtDescs,
5757 PIOMIOPORTHANDLE phIoPorts)
5758{
5759 int rc = pDevIns->pHlpR3->pfnIoPortCreateEx(pDevIns, cPorts, 0, NULL, UINT32_MAX,
5760 pfnOut, pfnIn, NULL, NULL, NULL, pszDesc, paExtDescs, phIoPorts);
5761 if (RT_SUCCESS(rc))
5762 rc = pDevIns->pHlpR3->pfnIoPortMap(pDevIns, *phIoPorts, Port);
5763 return rc;
5764}
5765
5766/**
5767 * Combines PDMDevHlpIoPortCreate() & PDMDevHlpIoPortMap(), but with pvUser.
5768 */
5769DECLINLINE(int) PDMDevHlpIoPortCreateUAndMap(PPDMDEVINS pDevIns, RTIOPORT Port, RTIOPORT cPorts, PFNIOMIOPORTNEWOUT pfnOut,
5770 PFNIOMIOPORTNEWIN pfnIn, void *pvUser,
5771 const char *pszDesc, PCIOMIOPORTDESC paExtDescs, PIOMIOPORTHANDLE phIoPorts)
5772{
5773 int rc = pDevIns->pHlpR3->pfnIoPortCreateEx(pDevIns, cPorts, 0, NULL, UINT32_MAX,
5774 pfnOut, pfnIn, NULL, NULL, pvUser, pszDesc, paExtDescs, phIoPorts);
5775 if (RT_SUCCESS(rc))
5776 rc = pDevIns->pHlpR3->pfnIoPortMap(pDevIns, *phIoPorts, Port);
5777 return rc;
5778}
5779
5780/**
5781 * Combines PDMDevHlpIoPortCreate() & PDMDevHlpIoPortMap(), but with flags.
5782 */
5783DECLINLINE(int) PDMDevHlpIoPortCreateFlagsAndMap(PPDMDEVINS pDevIns, RTIOPORT Port, RTIOPORT cPorts, uint32_t fFlags,
5784 PFNIOMIOPORTNEWOUT pfnOut, PFNIOMIOPORTNEWIN pfnIn,
5785 const char *pszDesc, PCIOMIOPORTDESC paExtDescs, PIOMIOPORTHANDLE phIoPorts)
5786{
5787 int rc = pDevIns->pHlpR3->pfnIoPortCreateEx(pDevIns, cPorts, fFlags, NULL, UINT32_MAX,
5788 pfnOut, pfnIn, NULL, NULL, NULL, pszDesc, paExtDescs, phIoPorts);
5789 if (RT_SUCCESS(rc))
5790 rc = pDevIns->pHlpR3->pfnIoPortMap(pDevIns, *phIoPorts, Port);
5791 return rc;
5792}
5793
5794/**
5795 * Combines PDMDevHlpIoPortCreateEx() & PDMDevHlpIoPortMap().
5796 */
5797DECLINLINE(int) PDMDevHlpIoPortCreateExAndMap(PPDMDEVINS pDevIns, RTIOPORT Port, RTIOPORT cPorts, uint32_t fFlags,
5798 PFNIOMIOPORTNEWOUT pfnOut, PFNIOMIOPORTNEWIN pfnIn,
5799 PFNIOMIOPORTNEWOUTSTRING pfnOutStr, PFNIOMIOPORTNEWINSTRING pfnInStr, void *pvUser,
5800 const char *pszDesc, PCIOMIOPORTDESC paExtDescs, PIOMIOPORTHANDLE phIoPorts)
5801{
5802 int rc = pDevIns->pHlpR3->pfnIoPortCreateEx(pDevIns, cPorts, fFlags, NULL, UINT32_MAX,
5803 pfnOut, pfnIn, pfnOutStr, pfnInStr, pvUser, pszDesc, paExtDescs, phIoPorts);
5804 if (RT_SUCCESS(rc))
5805 rc = pDevIns->pHlpR3->pfnIoPortMap(pDevIns, *phIoPorts, Port);
5806 return rc;
5807}
5808
5809/**
5810 * @sa PDMDevHlpIoPortCreateEx
5811 */
5812DECLINLINE(int) PDMDevHlpIoPortCreate(PPDMDEVINS pDevIns, RTIOPORT cPorts, PPDMPCIDEV pPciDev, uint32_t iPciRegion,
5813 PFNIOMIOPORTNEWOUT pfnOut, PFNIOMIOPORTNEWIN pfnIn, void *pvUser, const char *pszDesc,
5814 PCIOMIOPORTDESC paExtDescs, PIOMIOPORTHANDLE phIoPorts)
5815{
5816 return pDevIns->pHlpR3->pfnIoPortCreateEx(pDevIns, cPorts, 0, pPciDev, iPciRegion,
5817 pfnOut, pfnIn, NULL, NULL, pvUser, pszDesc, paExtDescs, phIoPorts);
5818}
5819
5820
5821/**
5822 * @sa PDMDevHlpIoPortCreateEx
5823 */
5824DECLINLINE(int) PDMDevHlpIoPortCreateIsa(PPDMDEVINS pDevIns, RTIOPORT cPorts, PFNIOMIOPORTNEWOUT pfnOut,
5825 PFNIOMIOPORTNEWIN pfnIn, void *pvUser, const char *pszDesc,
5826 PCIOMIOPORTDESC paExtDescs, PIOMIOPORTHANDLE phIoPorts)
5827{
5828 return pDevIns->pHlpR3->pfnIoPortCreateEx(pDevIns, cPorts, 0, NULL, UINT32_MAX,
5829 pfnOut, pfnIn, NULL, NULL, pvUser, pszDesc, paExtDescs, phIoPorts);
5830}
5831
5832/**
5833 * @copydoc PDMDEVHLPR3::pfnIoPortCreateEx
5834 */
5835DECLINLINE(int) PDMDevHlpIoPortCreateEx(PPDMDEVINS pDevIns, RTIOPORT cPorts, uint32_t fFlags, PPDMPCIDEV pPciDev,
5836 uint32_t iPciRegion, PFNIOMIOPORTNEWOUT pfnOut, PFNIOMIOPORTNEWIN pfnIn,
5837 PFNIOMIOPORTNEWOUTSTRING pfnOutStr, PFNIOMIOPORTNEWINSTRING pfnInStr, void *pvUser,
5838 const char *pszDesc, PCIOMIOPORTDESC paExtDescs, PIOMIOPORTHANDLE phIoPorts)
5839{
5840 return pDevIns->pHlpR3->pfnIoPortCreateEx(pDevIns, cPorts, fFlags, pPciDev, iPciRegion,
5841 pfnOut, pfnIn, pfnOutStr, pfnInStr, pvUser, pszDesc, paExtDescs, phIoPorts);
5842}
5843
5844/**
5845 * @copydoc PDMDEVHLPR3::pfnIoPortMap
5846 */
5847DECLINLINE(int) PDMDevHlpIoPortMap(PPDMDEVINS pDevIns, IOMIOPORTHANDLE hIoPorts, RTIOPORT Port)
5848{
5849 return pDevIns->pHlpR3->pfnIoPortMap(pDevIns, hIoPorts, Port);
5850}
5851
5852/**
5853 * @copydoc PDMDEVHLPR3::pfnIoPortUnmap
5854 */
5855DECLINLINE(int) PDMDevHlpIoPortUnmap(PPDMDEVINS pDevIns, IOMIOPORTHANDLE hIoPorts)
5856{
5857 return pDevIns->pHlpR3->pfnIoPortUnmap(pDevIns, hIoPorts);
5858}
5859
5860/**
5861 * @copydoc PDMDEVHLPR3::pfnIoPortGetMappingAddress
5862 */
5863DECLINLINE(uint32_t) PDMDevHlpIoPortGetMappingAddress(PPDMDEVINS pDevIns, IOMIOPORTHANDLE hIoPorts)
5864{
5865 return pDevIns->pHlpR3->pfnIoPortGetMappingAddress(pDevIns, hIoPorts);
5866}
5867
5868
5869#endif /* IN_RING3 */
5870#if !defined(IN_RING3) || defined(DOXYGEN_RUNNING)
5871
5872/**
5873 * @sa PDMDevHlpIoPortSetUpContextEx
5874 */
5875DECLINLINE(int) PDMDevHlpIoPortSetUpContext(PPDMDEVINS pDevIns, IOMIOPORTHANDLE hIoPorts,
5876 PFNIOMIOPORTNEWOUT pfnOut, PFNIOMIOPORTNEWIN pfnIn, void *pvUser)
5877{
5878 return pDevIns->CTX_SUFF(pHlp)->pfnIoPortSetUpContextEx(pDevIns, hIoPorts, pfnOut, pfnIn, NULL, NULL, pvUser);
5879}
5880
5881/**
5882 * @copydoc PDMDEVHLPR0::pfnIoPortSetUpContextEx
5883 */
5884DECLINLINE(int) PDMDevHlpIoPortSetUpContextEx(PPDMDEVINS pDevIns, IOMIOPORTHANDLE hIoPorts,
5885 PFNIOMIOPORTNEWOUT pfnOut, PFNIOMIOPORTNEWIN pfnIn,
5886 PFNIOMIOPORTNEWOUTSTRING pfnOutStr, PFNIOMIOPORTNEWINSTRING pfnInStr, void *pvUser)
5887{
5888 return pDevIns->CTX_SUFF(pHlp)->pfnIoPortSetUpContextEx(pDevIns, hIoPorts, pfnOut, pfnIn, pfnOutStr, pfnInStr, pvUser);
5889}
5890
5891#endif /* !IN_RING3 || DOXYGEN_RUNNING */
5892#ifdef IN_RING3
5893
5894/**
5895 * @sa PDMDevHlpMmioCreateEx
5896 */
5897DECLINLINE(int) PDMDevHlpMmioCreate(PPDMDEVINS pDevIns, RTGCPHYS cbRegion, PPDMPCIDEV pPciDev, uint32_t iPciRegion,
5898 PFNIOMMMIONEWWRITE pfnWrite, PFNIOMMMIONEWREAD pfnRead, void *pvUser,
5899 uint32_t fFlags, const char *pszDesc, PIOMMMIOHANDLE phRegion)
5900{
5901 return pDevIns->pHlpR3->pfnMmioCreateEx(pDevIns, cbRegion, fFlags, pPciDev, iPciRegion,
5902 pfnWrite, pfnRead, NULL, pvUser, pszDesc, phRegion);
5903}
5904
5905/**
5906 * @copydoc PDMDEVHLPR3::pfnMmioCreateEx
5907 */
5908DECLINLINE(int) PDMDevHlpMmioCreateEx(PPDMDEVINS pDevIns, RTGCPHYS cbRegion,
5909 uint32_t fFlags, PPDMPCIDEV pPciDev, uint32_t iPciRegion,
5910 PFNIOMMMIONEWWRITE pfnWrite, PFNIOMMMIONEWREAD pfnRead, PFNIOMMMIONEWFILL pfnFill,
5911 void *pvUser, const char *pszDesc, PIOMMMIOHANDLE phRegion)
5912{
5913 return pDevIns->pHlpR3->pfnMmioCreateEx(pDevIns, cbRegion, fFlags, pPciDev, iPciRegion,
5914 pfnWrite, pfnRead, pfnFill, pvUser, pszDesc, phRegion);
5915}
5916
5917/**
5918 * @sa PDMDevHlpMmioCreate and PDMDevHlpMmioMap
5919 */
5920DECLINLINE(int) PDMDevHlpMmioCreateAndMap(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTGCPHYS cbRegion,
5921 PFNIOMMMIONEWWRITE pfnWrite, PFNIOMMMIONEWREAD pfnRead,
5922 uint32_t fFlags, const char *pszDesc, PIOMMMIOHANDLE phRegion)
5923{
5924 int rc = pDevIns->pHlpR3->pfnMmioCreateEx(pDevIns, cbRegion, fFlags, NULL /*pPciDev*/, UINT32_MAX /*iPciRegion*/,
5925 pfnWrite, pfnRead, NULL /*pfnFill*/, NULL /*pvUser*/, pszDesc, phRegion);
5926 if (RT_SUCCESS(rc))
5927 rc = pDevIns->pHlpR3->pfnMmioMap(pDevIns, *phRegion, GCPhys);
5928 return rc;
5929}
5930
5931/**
5932 * @sa PDMDevHlpMmioCreateEx and PDMDevHlpMmioMap
5933 */
5934DECLINLINE(int) PDMDevHlpMmioCreateExAndMap(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTGCPHYS cbRegion, uint32_t fFlags,
5935 PPDMPCIDEV pPciDev, uint32_t iPciRegion, PFNIOMMMIONEWWRITE pfnWrite,
5936 PFNIOMMMIONEWREAD pfnRead, PFNIOMMMIONEWFILL pfnFill, void *pvUser,
5937 const char *pszDesc, PIOMMMIOHANDLE phRegion)
5938{
5939 int rc = pDevIns->pHlpR3->pfnMmioCreateEx(pDevIns, cbRegion, fFlags, pPciDev, iPciRegion,
5940 pfnWrite, pfnRead, pfnFill, pvUser, pszDesc, phRegion);
5941 if (RT_SUCCESS(rc))
5942 rc = pDevIns->pHlpR3->pfnMmioMap(pDevIns, *phRegion, GCPhys);
5943 return rc;
5944}
5945
5946/**
5947 * @copydoc PDMDEVHLPR3::pfnMmioMap
5948 */
5949DECLINLINE(int) PDMDevHlpMmioMap(PPDMDEVINS pDevIns, IOMMMIOHANDLE hRegion, RTGCPHYS GCPhys)
5950{
5951 return pDevIns->pHlpR3->pfnMmioMap(pDevIns, hRegion, GCPhys);
5952}
5953
5954/**
5955 * @copydoc PDMDEVHLPR3::pfnMmioUnmap
5956 */
5957DECLINLINE(int) PDMDevHlpMmioUnmap(PPDMDEVINS pDevIns, IOMMMIOHANDLE hRegion)
5958{
5959 return pDevIns->pHlpR3->pfnMmioUnmap(pDevIns, hRegion);
5960}
5961
5962/**
5963 * @copydoc PDMDEVHLPR3::pfnMmioReduce
5964 */
5965DECLINLINE(int) PDMDevHlpMmioReduce(PPDMDEVINS pDevIns, IOMMMIOHANDLE hRegion, RTGCPHYS cbRegion)
5966{
5967 return pDevIns->pHlpR3->pfnMmioReduce(pDevIns, hRegion, cbRegion);
5968}
5969
5970/**
5971 * @copydoc PDMDEVHLPR3::pfnMmioGetMappingAddress
5972 */
5973DECLINLINE(RTGCPHYS) PDMDevHlpMmioGetMappingAddress(PPDMDEVINS pDevIns, IOMMMIOHANDLE hRegion)
5974{
5975 return pDevIns->pHlpR3->pfnMmioGetMappingAddress(pDevIns, hRegion);
5976}
5977
5978#endif /* IN_RING3 */
5979#if !defined(IN_RING3) || defined(DOXYGEN_RUNNING)
5980
5981/**
5982 * @sa PDMDevHlpMmioSetUpContextEx
5983 */
5984DECLINLINE(int) PDMDevHlpMmioSetUpContext(PPDMDEVINS pDevIns, IOMMMIOHANDLE hRegion,
5985 PFNIOMMMIONEWWRITE pfnWrite, PFNIOMMMIONEWREAD pfnRead, void *pvUser)
5986{
5987 return pDevIns->CTX_SUFF(pHlp)->pfnMmioSetUpContextEx(pDevIns, hRegion, pfnWrite, pfnRead, NULL, pvUser);
5988}
5989
5990/**
5991 * @copydoc PDMDEVHLPR0::pfnMmioSetUpContextEx
5992 */
5993DECLINLINE(int) PDMDevHlpMmioSetUpContextEx(PPDMDEVINS pDevIns, IOMMMIOHANDLE hRegion, PFNIOMMMIONEWWRITE pfnWrite,
5994 PFNIOMMMIONEWREAD pfnRead, PFNIOMMMIONEWFILL pfnFill, void *pvUser)
5995{
5996 return pDevIns->CTX_SUFF(pHlp)->pfnMmioSetUpContextEx(pDevIns, hRegion, pfnWrite, pfnRead, pfnFill, pvUser);
5997}
5998
5999#endif /* !IN_RING3 || DOXYGEN_RUNNING */
6000#ifdef IN_RING3
6001
6002/**
6003 * @copydoc PDMDEVHLPR3::pfnMmio2Create
6004 */
6005DECLINLINE(int) PDMDevHlpMmio2Create(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iPciRegion, RTGCPHYS cbRegion,
6006 uint32_t fFlags, const char *pszDesc, void **ppvMapping, PPGMMMIO2HANDLE phRegion)
6007{
6008 return pDevIns->pHlpR3->pfnMmio2Create(pDevIns, pPciDev, iPciRegion, cbRegion, fFlags, pszDesc, ppvMapping, phRegion);
6009}
6010
6011/**
6012 * @copydoc PDMDEVHLPR3::pfnMmio2Map
6013 */
6014DECLINLINE(int) PDMDevHlpMmio2Map(PPDMDEVINS pDevIns, PGMMMIO2HANDLE hRegion, RTGCPHYS GCPhys)
6015{
6016 return pDevIns->pHlpR3->pfnMmio2Map(pDevIns, hRegion, GCPhys);
6017}
6018
6019/**
6020 * @copydoc PDMDEVHLPR3::pfnMmio2Unmap
6021 */
6022DECLINLINE(int) PDMDevHlpMmio2Unmap(PPDMDEVINS pDevIns, PGMMMIO2HANDLE hRegion)
6023{
6024 return pDevIns->pHlpR3->pfnMmio2Unmap(pDevIns, hRegion);
6025}
6026
6027/**
6028 * @copydoc PDMDEVHLPR3::pfnMmio2Reduce
6029 */
6030DECLINLINE(int) PDMDevHlpMmio2Reduce(PPDMDEVINS pDevIns, PGMMMIO2HANDLE hRegion, RTGCPHYS cbRegion)
6031{
6032 return pDevIns->pHlpR3->pfnMmio2Reduce(pDevIns, hRegion, cbRegion);
6033}
6034
6035/**
6036 * @copydoc PDMDEVHLPR3::pfnMmio2GetMappingAddress
6037 */
6038DECLINLINE(RTGCPHYS) PDMDevHlpMmio2GetMappingAddress(PPDMDEVINS pDevIns, PGMMMIO2HANDLE hRegion)
6039{
6040 return pDevIns->pHlpR3->pfnMmio2GetMappingAddress(pDevIns, hRegion);
6041}
6042
6043#endif /* IN_RING3 */
6044#if !defined(IN_RING3) || defined(DOXYGEN_RUNNING)
6045
6046/**
6047 * @copydoc PDMDEVHLPR0::pfnMmio2SetUpContext
6048 */
6049DECLINLINE(int) PDMDevHlpMmio2SetUpContext(PPDMDEVINS pDevIns, PGMMMIO2HANDLE hRegion,
6050 size_t offSub, size_t cbSub, void **ppvMapping)
6051{
6052 return pDevIns->CTX_SUFF(pHlp)->pfnMmio2SetUpContext(pDevIns, hRegion, offSub, cbSub, ppvMapping);
6053}
6054
6055#endif /* !IN_RING3 || DOXYGEN_RUNNING */
6056#ifdef IN_RING3
6057
6058/**
6059 * @copydoc PDMDEVHLPR3::pfnROMRegister
6060 */
6061DECLINLINE(int) PDMDevHlpROMRegister(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, uint32_t cbRange,
6062 const void *pvBinary, uint32_t cbBinary, uint32_t fFlags, const char *pszDesc)
6063{
6064 return pDevIns->pHlpR3->pfnROMRegister(pDevIns, GCPhysStart, cbRange, pvBinary, cbBinary, fFlags, pszDesc);
6065}
6066
6067/**
6068 * @copydoc PDMDEVHLPR3::pfnROMProtectShadow
6069 */
6070DECLINLINE(int) PDMDevHlpROMProtectShadow(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, uint32_t cbRange, PGMROMPROT enmProt)
6071{
6072 return pDevIns->pHlpR3->pfnROMProtectShadow(pDevIns, GCPhysStart, cbRange, enmProt);
6073}
6074
6075/**
6076 * Register a save state data unit.
6077 *
6078 * @returns VBox status.
6079 * @param pDevIns The device instance.
6080 * @param uVersion Data layout version number.
6081 * @param cbGuess The approximate amount of data in the unit.
6082 * Only for progress indicators.
6083 * @param pfnSaveExec Execute save callback, optional.
6084 * @param pfnLoadExec Execute load callback, optional.
6085 */
6086DECLINLINE(int) PDMDevHlpSSMRegister(PPDMDEVINS pDevIns, uint32_t uVersion, size_t cbGuess,
6087 PFNSSMDEVSAVEEXEC pfnSaveExec, PFNSSMDEVLOADEXEC pfnLoadExec)
6088{
6089 return pDevIns->pHlpR3->pfnSSMRegister(pDevIns, uVersion, cbGuess, NULL /*pszBefore*/,
6090 NULL /*pfnLivePrep*/, NULL /*pfnLiveExec*/, NULL /*pfnLiveDone*/,
6091 NULL /*pfnSavePrep*/, pfnSaveExec, NULL /*pfnSaveDone*/,
6092 NULL /*pfnLoadPrep*/, pfnLoadExec, NULL /*pfnLoadDone*/);
6093}
6094
6095/**
6096 * Register a save state data unit with a live save callback as well.
6097 *
6098 * @returns VBox status.
6099 * @param pDevIns The device instance.
6100 * @param uVersion Data layout version number.
6101 * @param cbGuess The approximate amount of data in the unit.
6102 * Only for progress indicators.
6103 * @param pfnLiveExec Execute live callback, optional.
6104 * @param pfnSaveExec Execute save callback, optional.
6105 * @param pfnLoadExec Execute load callback, optional.
6106 */
6107DECLINLINE(int) PDMDevHlpSSMRegister3(PPDMDEVINS pDevIns, uint32_t uVersion, size_t cbGuess,
6108 PFNSSMDEVLIVEEXEC pfnLiveExec, PFNSSMDEVSAVEEXEC pfnSaveExec, PFNSSMDEVLOADEXEC pfnLoadExec)
6109{
6110 return pDevIns->pHlpR3->pfnSSMRegister(pDevIns, uVersion, cbGuess, NULL /*pszBefore*/,
6111 NULL /*pfnLivePrep*/, pfnLiveExec, NULL /*pfnLiveDone*/,
6112 NULL /*pfnSavePrep*/, pfnSaveExec, NULL /*pfnSaveDone*/,
6113 NULL /*pfnLoadPrep*/, pfnLoadExec, NULL /*pfnLoadDone*/);
6114}
6115
6116/**
6117 * @copydoc PDMDEVHLPR3::pfnSSMRegister
6118 */
6119DECLINLINE(int) PDMDevHlpSSMRegisterEx(PPDMDEVINS pDevIns, uint32_t uVersion, size_t cbGuess, const char *pszBefore,
6120 PFNSSMDEVLIVEPREP pfnLivePrep, PFNSSMDEVLIVEEXEC pfnLiveExec, PFNSSMDEVLIVEVOTE pfnLiveVote,
6121 PFNSSMDEVSAVEPREP pfnSavePrep, PFNSSMDEVSAVEEXEC pfnSaveExec, PFNSSMDEVSAVEDONE pfnSaveDone,
6122 PFNSSMDEVLOADPREP pfnLoadPrep, PFNSSMDEVLOADEXEC pfnLoadExec, PFNSSMDEVLOADDONE pfnLoadDone)
6123{
6124 return pDevIns->pHlpR3->pfnSSMRegister(pDevIns, uVersion, cbGuess, pszBefore,
6125 pfnLivePrep, pfnLiveExec, pfnLiveVote,
6126 pfnSavePrep, pfnSaveExec, pfnSaveDone,
6127 pfnLoadPrep, pfnLoadExec, pfnLoadDone);
6128}
6129
6130/**
6131 * @copydoc PDMDEVHLPR3::pfnTMTimerCreate
6132 */
6133DECLINLINE(int) PDMDevHlpTMTimerCreate(PPDMDEVINS pDevIns, TMCLOCK enmClock, PFNTMTIMERDEV pfnCallback, void *pvUser,
6134 uint32_t fFlags, const char *pszDesc, PPTMTIMERR3 ppTimer)
6135{
6136 return pDevIns->pHlpR3->pfnTMTimerCreate(pDevIns, enmClock, pfnCallback, pvUser, fFlags, pszDesc, ppTimer);
6137}
6138
6139/**
6140 * @copydoc PDMDEVHLPR3::pfnTimerCreate
6141 */
6142DECLINLINE(int) PDMDevHlpTimerCreate(PPDMDEVINS pDevIns, TMCLOCK enmClock, PFNTMTIMERDEV pfnCallback, void *pvUser,
6143 uint32_t fFlags, const char *pszDesc, PTMTIMERHANDLE phTimer)
6144{
6145 return pDevIns->pHlpR3->pfnTimerCreate(pDevIns, enmClock, pfnCallback, pvUser, fFlags, pszDesc, phTimer);
6146}
6147
6148#endif /* IN_RING3 */
6149
6150/**
6151 * @copydoc PDMDEVHLPR3::pfnTimerToPtr
6152 */
6153DECLINLINE(PTMTIMER) PDMDevHlpTimerToPtr(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer)
6154{
6155 return pDevIns->CTX_SUFF(pHlp)->pfnTimerToPtr(pDevIns, hTimer);
6156}
6157
6158/**
6159 * @copydoc PDMDEVHLPR3::pfnTimerFromMicro
6160 */
6161DECLINLINE(uint64_t) PDMDevHlpTimerFromMicro(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint64_t cMicroSecs)
6162{
6163 return pDevIns->CTX_SUFF(pHlp)->pfnTimerFromMicro(pDevIns, hTimer, cMicroSecs);
6164}
6165
6166/**
6167 * @copydoc PDMDEVHLPR3::pfnTimerFromMilli
6168 */
6169DECLINLINE(uint64_t) PDMDevHlpTimerFromMilli(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint64_t cMilliSecs)
6170{
6171 return pDevIns->CTX_SUFF(pHlp)->pfnTimerFromMilli(pDevIns, hTimer, cMilliSecs);
6172}
6173
6174/**
6175 * @copydoc PDMDEVHLPR3::pfnTimerFromNano
6176 */
6177DECLINLINE(uint64_t) PDMDevHlpTimerFromNano(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint64_t cNanoSecs)
6178{
6179 return pDevIns->CTX_SUFF(pHlp)->pfnTimerFromNano(pDevIns, hTimer, cNanoSecs);
6180}
6181
6182/**
6183 * @copydoc PDMDEVHLPR3::pfnTimerGet
6184 */
6185DECLINLINE(uint64_t) PDMDevHlpTimerGet(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer)
6186{
6187 return pDevIns->CTX_SUFF(pHlp)->pfnTimerGet(pDevIns, hTimer);
6188}
6189
6190/**
6191 * @copydoc PDMDEVHLPR3::pfnTimerGetFreq
6192 */
6193DECLINLINE(uint64_t) PDMDevHlpTimerGetFreq(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer)
6194{
6195 return pDevIns->CTX_SUFF(pHlp)->pfnTimerGetFreq(pDevIns, hTimer);
6196}
6197
6198/**
6199 * @copydoc PDMDEVHLPR3::pfnTimerGetNano
6200 */
6201DECLINLINE(uint64_t) PDMDevHlpTimerGetNano(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer)
6202{
6203 return pDevIns->CTX_SUFF(pHlp)->pfnTimerGetNano(pDevIns, hTimer);
6204}
6205
6206/**
6207 * @copydoc PDMDEVHLPR3::pfnTimerIsActive
6208 */
6209DECLINLINE(bool) PDMDevHlpTimerIsActive(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer)
6210{
6211 return pDevIns->CTX_SUFF(pHlp)->pfnTimerIsActive(pDevIns, hTimer);
6212}
6213
6214/**
6215 * @copydoc PDMDEVHLPR3::pfnTimerIsLockOwner
6216 */
6217DECLINLINE(bool) PDMDevHlpTimerIsLockOwner(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer)
6218{
6219 return pDevIns->CTX_SUFF(pHlp)->pfnTimerIsLockOwner(pDevIns, hTimer);
6220}
6221
6222/**
6223 * @copydoc PDMDEVHLPR3::pfnTimerLockClock
6224 */
6225DECLINLINE(VBOXSTRICTRC) PDMDevHlpTimerLockClock(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, int rcBusy)
6226{
6227 return pDevIns->CTX_SUFF(pHlp)->pfnTimerLockClock(pDevIns, hTimer, rcBusy);
6228}
6229
6230/**
6231 * @copydoc PDMDEVHLPR3::pfnTimerLockClock2
6232 */
6233DECLINLINE(VBOXSTRICTRC) PDMDevHlpTimerLockClock2(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, PPDMCRITSECT pCritSect, int rcBusy)
6234{
6235 return pDevIns->CTX_SUFF(pHlp)->pfnTimerLockClock2(pDevIns, hTimer, pCritSect, rcBusy);
6236}
6237
6238/**
6239 * @copydoc PDMDEVHLPR3::pfnTimerSet
6240 */
6241DECLINLINE(int) PDMDevHlpTimerSet(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint64_t uExpire)
6242{
6243 return pDevIns->CTX_SUFF(pHlp)->pfnTimerSet(pDevIns, hTimer, uExpire);
6244}
6245
6246/**
6247 * @copydoc PDMDEVHLPR3::pfnTimerSetFrequencyHint
6248 */
6249DECLINLINE(int) PDMDevHlpTimerSetFrequencyHint(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint32_t uHz)
6250{
6251 return pDevIns->CTX_SUFF(pHlp)->pfnTimerSetFrequencyHint(pDevIns, hTimer, uHz);
6252}
6253
6254/**
6255 * @copydoc PDMDEVHLPR3::pfnTimerSetMicro
6256 */
6257DECLINLINE(int) PDMDevHlpTimerSetMicro(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint64_t cMicrosToNext)
6258{
6259 return pDevIns->CTX_SUFF(pHlp)->pfnTimerSetMicro(pDevIns, hTimer, cMicrosToNext);
6260}
6261
6262/**
6263 * @copydoc PDMDEVHLPR3::pfnTimerSetMillies
6264 */
6265DECLINLINE(int) PDMDevHlpTimerSetMillies(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint64_t cMilliesToNext)
6266{
6267 return pDevIns->CTX_SUFF(pHlp)->pfnTimerSetMillies(pDevIns, hTimer, cMilliesToNext);
6268}
6269
6270/**
6271 * @copydoc PDMDEVHLPR3::pfnTimerSetNano
6272 */
6273DECLINLINE(int) PDMDevHlpTimerSetNano(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint64_t cNanosToNext)
6274{
6275 return pDevIns->CTX_SUFF(pHlp)->pfnTimerSetNano(pDevIns, hTimer, cNanosToNext);
6276}
6277
6278/**
6279 * @copydoc PDMDEVHLPR3::pfnTimerSetRelative
6280 */
6281DECLINLINE(int) PDMDevHlpTimerSetRelative(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint64_t cTicksToNext, uint64_t *pu64Now)
6282{
6283 return pDevIns->CTX_SUFF(pHlp)->pfnTimerSetRelative(pDevIns, hTimer, cTicksToNext, pu64Now);
6284}
6285
6286/**
6287 * @copydoc PDMDEVHLPR3::pfnTimerStop
6288 */
6289DECLINLINE(int) PDMDevHlpTimerStop(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer)
6290{
6291 return pDevIns->CTX_SUFF(pHlp)->pfnTimerStop(pDevIns, hTimer);
6292}
6293
6294/**
6295 * @copydoc PDMDEVHLPR3::pfnTimerUnlockClock
6296 */
6297DECLINLINE(void) PDMDevHlpTimerUnlockClock(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer)
6298{
6299 pDevIns->CTX_SUFF(pHlp)->pfnTimerUnlockClock(pDevIns, hTimer);
6300}
6301
6302/**
6303 * @copydoc PDMDEVHLPR3::pfnTimerUnlockClock2
6304 */
6305DECLINLINE(void) PDMDevHlpTimerUnlockClock2(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, PPDMCRITSECT pCritSect)
6306{
6307 pDevIns->CTX_SUFF(pHlp)->pfnTimerUnlockClock2(pDevIns, hTimer, pCritSect);
6308}
6309
6310#ifdef IN_RING3
6311
6312/**
6313 * @copydoc PDMDEVHLPR3::pfnTimerSetCritSect
6314 */
6315DECLINLINE(int) PDMDevHlpTimerSetCritSect(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, PPDMCRITSECT pCritSect)
6316{
6317 return pDevIns->pHlpR3->pfnTimerSetCritSect(pDevIns, hTimer, pCritSect);
6318}
6319
6320/**
6321 * @copydoc PDMDEVHLPR3::pfnTimerSave
6322 */
6323DECLINLINE(int) PDMDevHlpTimerSave(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, PSSMHANDLE pSSM)
6324{
6325 return pDevIns->pHlpR3->pfnTimerSave(pDevIns, hTimer, pSSM);
6326}
6327
6328/**
6329 * @copydoc PDMDEVHLPR3::pfnTimerLoad
6330 */
6331DECLINLINE(int) PDMDevHlpTimerLoad(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, PSSMHANDLE pSSM)
6332{
6333 return pDevIns->pHlpR3->pfnTimerLoad(pDevIns, hTimer, pSSM);
6334}
6335
6336/**
6337 * @copydoc PDMDEVHLPR3::pfnTimerDestroy
6338 */
6339DECLINLINE(int) PDMDevHlpTimerDestroy(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer)
6340{
6341 return pDevIns->pHlpR3->pfnTimerDestroy(pDevIns, hTimer);
6342}
6343
6344/**
6345 * @copydoc PDMDEVHLPR3::pfnTMUtcNow
6346 */
6347DECLINLINE(PRTTIMESPEC) PDMDevHlpTMUtcNow(PPDMDEVINS pDevIns, PRTTIMESPEC pTime)
6348{
6349 return pDevIns->pHlpR3->pfnTMUtcNow(pDevIns, pTime);
6350}
6351
6352#endif
6353
6354/**
6355 * Read physical memory - unknown data usage.
6356 *
6357 * @returns VINF_SUCCESS (for now).
6358 * @param pDevIns The device instance.
6359 * @param GCPhys Physical address start reading from.
6360 * @param pvBuf Where to put the read bits.
6361 * @param cbRead How many bytes to read.
6362 * @thread Any thread, but the call may involve the emulation thread.
6363 */
6364DECLINLINE(int) PDMDevHlpPhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)
6365{
6366 return pDevIns->CTX_SUFF(pHlp)->pfnPhysRead(pDevIns, GCPhys, pvBuf, cbRead, PDM_DEVHLP_PHYS_RW_F_DEFAULT);
6367}
6368
6369/**
6370 * Write to physical memory - unknown data usage.
6371 *
6372 * @returns VINF_SUCCESS for now, and later maybe VERR_EM_MEMORY.
6373 * @param pDevIns The device instance.
6374 * @param GCPhys Physical address to write to.
6375 * @param pvBuf What to write.
6376 * @param cbWrite How many bytes to write.
6377 * @thread Any thread, but the call may involve the emulation thread.
6378 */
6379DECLINLINE(int) PDMDevHlpPhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)
6380{
6381 return pDevIns->CTX_SUFF(pHlp)->pfnPhysWrite(pDevIns, GCPhys, pvBuf, cbWrite, PDM_DEVHLP_PHYS_RW_F_DEFAULT);
6382}
6383
6384/**
6385 * Read physical memory - reads meta data processed by the device.
6386 *
6387 * @returns VINF_SUCCESS (for now).
6388 * @param pDevIns The device instance.
6389 * @param GCPhys Physical address start reading from.
6390 * @param pvBuf Where to put the read bits.
6391 * @param cbRead How many bytes to read.
6392 * @thread Any thread, but the call may involve the emulation thread.
6393 */
6394DECLINLINE(int) PDMDevHlpPhysReadMeta(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)
6395{
6396 return pDevIns->CTX_SUFF(pHlp)->pfnPhysRead(pDevIns, GCPhys, pvBuf, cbRead, PDM_DEVHLP_PHYS_RW_F_DATA_META);
6397}
6398
6399/**
6400 * Write to physical memory - written data was created/altered by the device.
6401 *
6402 * @returns VINF_SUCCESS for now, and later maybe VERR_EM_MEMORY.
6403 * @param pDevIns The device instance.
6404 * @param GCPhys Physical address to write to.
6405 * @param pvBuf What to write.
6406 * @param cbWrite How many bytes to write.
6407 * @thread Any thread, but the call may involve the emulation thread.
6408 */
6409DECLINLINE(int) PDMDevHlpPhysWriteMeta(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)
6410{
6411 return pDevIns->CTX_SUFF(pHlp)->pfnPhysWrite(pDevIns, GCPhys, pvBuf, cbWrite, PDM_DEVHLP_PHYS_RW_F_DATA_META);
6412}
6413
6414/**
6415 * Read physical memory - read data will not be touched by the device.
6416 *
6417 * @returns VINF_SUCCESS (for now).
6418 * @param pDevIns The device instance.
6419 * @param GCPhys Physical address start reading from.
6420 * @param pvBuf Where to put the read bits.
6421 * @param cbRead How many bytes to read.
6422 * @thread Any thread, but the call may involve the emulation thread.
6423 */
6424DECLINLINE(int) PDMDevHlpPhysReadUser(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)
6425{
6426 return pDevIns->CTX_SUFF(pHlp)->pfnPhysRead(pDevIns, GCPhys, pvBuf, cbRead, PDM_DEVHLP_PHYS_RW_F_DATA_USER);
6427}
6428
6429/**
6430 * Write to physical memory - written data was not touched/created by the device.
6431 *
6432 * @returns VINF_SUCCESS for now, and later maybe VERR_EM_MEMORY.
6433 * @param pDevIns The device instance.
6434 * @param GCPhys Physical address to write to.
6435 * @param pvBuf What to write.
6436 * @param cbWrite How many bytes to write.
6437 * @thread Any thread, but the call may involve the emulation thread.
6438 */
6439DECLINLINE(int) PDMDevHlpPhysWriteUser(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)
6440{
6441 return pDevIns->CTX_SUFF(pHlp)->pfnPhysWrite(pDevIns, GCPhys, pvBuf, cbWrite, PDM_DEVHLP_PHYS_RW_F_DATA_USER);
6442}
6443
6444#ifdef IN_RING3
6445
6446/**
6447 * @copydoc PDMDEVHLPR3::pfnPhysGCPhys2CCPtr
6448 */
6449DECLINLINE(int) PDMDevHlpPhysGCPhys2CCPtr(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, uint32_t fFlags, void **ppv, PPGMPAGEMAPLOCK pLock)
6450{
6451 return pDevIns->CTX_SUFF(pHlp)->pfnPhysGCPhys2CCPtr(pDevIns, GCPhys, fFlags, ppv, pLock);
6452}
6453
6454/**
6455 * @copydoc PDMDEVHLPR3::pfnPhysGCPhys2CCPtrReadOnly
6456 */
6457DECLINLINE(int) PDMDevHlpPhysGCPhys2CCPtrReadOnly(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, uint32_t fFlags, void const **ppv,
6458 PPGMPAGEMAPLOCK pLock)
6459{
6460 return pDevIns->CTX_SUFF(pHlp)->pfnPhysGCPhys2CCPtrReadOnly(pDevIns, GCPhys, fFlags, ppv, pLock);
6461}
6462
6463/**
6464 * @copydoc PDMDEVHLPR3::pfnPhysReleasePageMappingLock
6465 */
6466DECLINLINE(void) PDMDevHlpPhysReleasePageMappingLock(PPDMDEVINS pDevIns, PPGMPAGEMAPLOCK pLock)
6467{
6468 pDevIns->CTX_SUFF(pHlp)->pfnPhysReleasePageMappingLock(pDevIns, pLock);
6469}
6470
6471/**
6472 * @copydoc PDMDEVHLPR3::pfnPhysBulkGCPhys2CCPtr
6473 */
6474DECLINLINE(int) PDMDevHlpPhysBulkGCPhys2CCPtr(PPDMDEVINS pDevIns, uint32_t cPages, PCRTGCPHYS paGCPhysPages,
6475 uint32_t fFlags, void **papvPages, PPGMPAGEMAPLOCK paLocks)
6476{
6477 return pDevIns->CTX_SUFF(pHlp)->pfnPhysBulkGCPhys2CCPtr(pDevIns, cPages, paGCPhysPages, fFlags, papvPages, paLocks);
6478}
6479
6480/**
6481 * @copydoc PDMDEVHLPR3::pfnPhysBulkGCPhys2CCPtrReadOnly
6482 */
6483DECLINLINE(int) PDMDevHlpPhysBulkGCPhys2CCPtrReadOnly(PPDMDEVINS pDevIns, uint32_t cPages, PCRTGCPHYS paGCPhysPages,
6484 uint32_t fFlags, void const **papvPages, PPGMPAGEMAPLOCK paLocks)
6485{
6486 return pDevIns->CTX_SUFF(pHlp)->pfnPhysBulkGCPhys2CCPtrReadOnly(pDevIns, cPages, paGCPhysPages, fFlags, papvPages, paLocks);
6487}
6488
6489/**
6490 * @copydoc PDMDEVHLPR3::pfnPhysBulkReleasePageMappingLocks
6491 */
6492DECLINLINE(void) PDMDevHlpPhysBulkReleasePageMappingLocks(PPDMDEVINS pDevIns, uint32_t cPages, PPGMPAGEMAPLOCK paLocks)
6493{
6494 pDevIns->CTX_SUFF(pHlp)->pfnPhysBulkReleasePageMappingLocks(pDevIns, cPages, paLocks);
6495}
6496
6497/**
6498 * @copydoc PDMDEVHLPR3::pfnCpuGetGuestMicroarch
6499 */
6500DECLINLINE(CPUMMICROARCH) PDMDevHlpCpuGetGuestMicroarch(PPDMDEVINS pDevIns)
6501{
6502 return pDevIns->CTX_SUFF(pHlp)->pfnCpuGetGuestMicroarch(pDevIns);
6503}
6504
6505/**
6506 * @copydoc PDMDEVHLPR3::pfnPhysReadGCVirt
6507 */
6508DECLINLINE(int) PDMDevHlpPhysReadGCVirt(PPDMDEVINS pDevIns, void *pvDst, RTGCPTR GCVirtSrc, size_t cb)
6509{
6510 return pDevIns->pHlpR3->pfnPhysReadGCVirt(pDevIns, pvDst, GCVirtSrc, cb);
6511}
6512
6513/**
6514 * @copydoc PDMDEVHLPR3::pfnPhysWriteGCVirt
6515 */
6516DECLINLINE(int) PDMDevHlpPhysWriteGCVirt(PPDMDEVINS pDevIns, RTGCPTR GCVirtDst, const void *pvSrc, size_t cb)
6517{
6518 return pDevIns->pHlpR3->pfnPhysWriteGCVirt(pDevIns, GCVirtDst, pvSrc, cb);
6519}
6520
6521/**
6522 * @copydoc PDMDEVHLPR3::pfnPhysGCPtr2GCPhys
6523 */
6524DECLINLINE(int) PDMDevHlpPhysGCPtr2GCPhys(PPDMDEVINS pDevIns, RTGCPTR GCPtr, PRTGCPHYS pGCPhys)
6525{
6526 return pDevIns->pHlpR3->pfnPhysGCPtr2GCPhys(pDevIns, GCPtr, pGCPhys);
6527}
6528
6529/**
6530 * @copydoc PDMDEVHLPR3::pfnMMHeapAlloc
6531 */
6532DECLINLINE(void *) PDMDevHlpMMHeapAlloc(PPDMDEVINS pDevIns, size_t cb)
6533{
6534 return pDevIns->pHlpR3->pfnMMHeapAlloc(pDevIns, cb);
6535}
6536
6537/**
6538 * @copydoc PDMDEVHLPR3::pfnMMHeapAllocZ
6539 */
6540DECLINLINE(void *) PDMDevHlpMMHeapAllocZ(PPDMDEVINS pDevIns, size_t cb)
6541{
6542 return pDevIns->pHlpR3->pfnMMHeapAllocZ(pDevIns, cb);
6543}
6544
6545/**
6546 * @copydoc PDMDEVHLPR3::pfnMMHeapFree
6547 */
6548DECLINLINE(void) PDMDevHlpMMHeapFree(PPDMDEVINS pDevIns, void *pv)
6549{
6550 pDevIns->pHlpR3->pfnMMHeapFree(pDevIns, pv);
6551}
6552#endif /* IN_RING3 */
6553
6554/**
6555 * @copydoc PDMDEVHLPR3::pfnVMState
6556 */
6557DECLINLINE(VMSTATE) PDMDevHlpVMState(PPDMDEVINS pDevIns)
6558{
6559 return pDevIns->CTX_SUFF(pHlp)->pfnVMState(pDevIns);
6560}
6561
6562#ifdef IN_RING3
6563/**
6564 * @copydoc PDMDEVHLPR3::pfnVMTeleportedAndNotFullyResumedYet
6565 */
6566DECLINLINE(bool) PDMDevHlpVMTeleportedAndNotFullyResumedYet(PPDMDEVINS pDevIns)
6567{
6568 return pDevIns->pHlpR3->pfnVMTeleportedAndNotFullyResumedYet(pDevIns);
6569}
6570#endif /* IN_RING3 */
6571
6572/**
6573 * @copydoc PDMDEVHLPR3::pfnVMSetError
6574 */
6575DECLINLINE(int) RT_IPRT_FORMAT_ATTR(6, 7) PDMDevHlpVMSetError(PPDMDEVINS pDevIns, const int rc, RT_SRC_POS_DECL,
6576 const char *pszFormat, ...)
6577{
6578 va_list va;
6579 va_start(va, pszFormat);
6580 pDevIns->CTX_SUFF(pHlp)->pfnVMSetErrorV(pDevIns, rc, RT_SRC_POS_ARGS, pszFormat, va);
6581 va_end(va);
6582 return rc;
6583}
6584
6585/**
6586 * @copydoc PDMDEVHLPR3::pfnVMSetRuntimeError
6587 */
6588DECLINLINE(int) RT_IPRT_FORMAT_ATTR(4, 5) PDMDevHlpVMSetRuntimeError(PPDMDEVINS pDevIns, uint32_t fFlags, const char *pszErrorId,
6589 const char *pszFormat, ...)
6590{
6591 va_list va;
6592 int rc;
6593 va_start(va, pszFormat);
6594 rc = pDevIns->CTX_SUFF(pHlp)->pfnVMSetRuntimeErrorV(pDevIns, fFlags, pszErrorId, pszFormat, va);
6595 va_end(va);
6596 return rc;
6597}
6598
6599/**
6600 * VBOX_STRICT wrapper for pHlp->pfnDBGFStopV.
6601 *
6602 * @returns VBox status code which must be passed up to the VMM. This will be
6603 * VINF_SUCCESS in non-strict builds.
6604 * @param pDevIns The device instance.
6605 * @param SRC_POS Use RT_SRC_POS.
6606 * @param pszFormat Message. (optional)
6607 * @param ... Message parameters.
6608 */
6609DECLINLINE(int) RT_IPRT_FORMAT_ATTR(5, 6) PDMDevHlpDBGFStop(PPDMDEVINS pDevIns, RT_SRC_POS_DECL, const char *pszFormat, ...)
6610{
6611#ifdef VBOX_STRICT
6612# ifdef IN_RING3
6613 int rc;
6614 va_list args;
6615 va_start(args, pszFormat);
6616 rc = pDevIns->pHlpR3->pfnDBGFStopV(pDevIns, RT_SRC_POS_ARGS, pszFormat, args);
6617 va_end(args);
6618 return rc;
6619# else
6620 NOREF(pDevIns);
6621 NOREF(pszFile);
6622 NOREF(iLine);
6623 NOREF(pszFunction);
6624 NOREF(pszFormat);
6625 return VINF_EM_DBG_STOP;
6626# endif
6627#else
6628 NOREF(pDevIns);
6629 NOREF(pszFile);
6630 NOREF(iLine);
6631 NOREF(pszFunction);
6632 NOREF(pszFormat);
6633 return VINF_SUCCESS;
6634#endif
6635}
6636
6637#ifdef IN_RING3
6638
6639/**
6640 * @copydoc PDMDEVHLPR3::pfnDBGFInfoRegister
6641 */
6642DECLINLINE(int) PDMDevHlpDBGFInfoRegister(PPDMDEVINS pDevIns, const char *pszName, const char *pszDesc, PFNDBGFHANDLERDEV pfnHandler)
6643{
6644 return pDevIns->pHlpR3->pfnDBGFInfoRegister(pDevIns, pszName, pszDesc, pfnHandler);
6645}
6646
6647/**
6648 * @copydoc PDMDEVHLPR3::pfnDBGFInfoRegisterArgv
6649 */
6650DECLINLINE(int) PDMDevHlpDBGFInfoRegisterArgv(PPDMDEVINS pDevIns, const char *pszName, const char *pszDesc, PFNDBGFINFOARGVDEV pfnHandler)
6651{
6652 return pDevIns->pHlpR3->pfnDBGFInfoRegisterArgv(pDevIns, pszName, pszDesc, pfnHandler);
6653}
6654
6655/**
6656 * @copydoc PDMDEVHLPR3::pfnDBGFRegRegister
6657 */
6658DECLINLINE(int) PDMDevHlpDBGFRegRegister(PPDMDEVINS pDevIns, PCDBGFREGDESC paRegisters)
6659{
6660 return pDevIns->pHlpR3->pfnDBGFRegRegister(pDevIns, paRegisters);
6661}
6662
6663/**
6664 * @copydoc PDMDEVHLPR3::pfnSTAMRegister
6665 */
6666DECLINLINE(void) PDMDevHlpSTAMRegister(PPDMDEVINS pDevIns, void *pvSample, STAMTYPE enmType, const char *pszName, STAMUNIT enmUnit, const char *pszDesc)
6667{
6668 pDevIns->pHlpR3->pfnSTAMRegister(pDevIns, pvSample, enmType, pszName, enmUnit, pszDesc);
6669}
6670
6671/**
6672 * Same as pfnSTAMRegister except that the name is specified in a
6673 * RTStrPrintf like fashion.
6674 *
6675 * @returns VBox status.
6676 * @param pDevIns Device instance of the DMA.
6677 * @param pvSample Pointer to the sample.
6678 * @param enmType Sample type. This indicates what pvSample is
6679 * pointing at.
6680 * @param enmVisibility Visibility type specifying whether unused
6681 * statistics should be visible or not.
6682 * @param enmUnit Sample unit.
6683 * @param pszDesc Sample description.
6684 * @param pszName Sample name format string, unix path style. If
6685 * this does not start with a '/', the default
6686 * prefix will be prepended, otherwise it will be
6687 * used as-is.
6688 * @param ... Arguments to the format string.
6689 */
6690DECLINLINE(void) RT_IPRT_FORMAT_ATTR(7, 8) PDMDevHlpSTAMRegisterF(PPDMDEVINS pDevIns, void *pvSample, STAMTYPE enmType,
6691 STAMVISIBILITY enmVisibility, STAMUNIT enmUnit,
6692 const char *pszDesc, const char *pszName, ...)
6693{
6694 va_list va;
6695 va_start(va, pszName);
6696 pDevIns->pHlpR3->pfnSTAMRegisterV(pDevIns, pvSample, enmType, enmVisibility, enmUnit, pszDesc, pszName, va);
6697 va_end(va);
6698}
6699
6700/**
6701 * Registers the device with the default PCI bus.
6702 *
6703 * @returns VBox status code.
6704 * @param pDevIns The device instance.
6705 * @param pPciDev The PCI device structure.
6706 * This must be kept in the instance data.
6707 * The PCI configuration must be initialized before registration.
6708 */
6709DECLINLINE(int) PDMDevHlpPCIRegister(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev)
6710{
6711 return pDevIns->pHlpR3->pfnPCIRegister(pDevIns, pPciDev, 0 /*fFlags*/,
6712 PDMPCIDEVREG_DEV_NO_FIRST_UNUSED, PDMPCIDEVREG_FUN_NO_FIRST_UNUSED, NULL);
6713}
6714
6715/**
6716 * @copydoc PDMDEVHLPR3::pfnPCIRegister
6717 */
6718DECLINLINE(int) PDMDevHlpPCIRegisterEx(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t fFlags,
6719 uint8_t uPciDevNo, uint8_t uPciFunNo, const char *pszName)
6720{
6721 return pDevIns->pHlpR3->pfnPCIRegister(pDevIns, pPciDev, fFlags, uPciDevNo, uPciFunNo, pszName);
6722}
6723
6724/**
6725 * Initialize MSI emulation support for the first PCI device.
6726 *
6727 * @returns VBox status code.
6728 * @param pDevIns The device instance.
6729 * @param pMsiReg MSI emulation registration structure.
6730 */
6731DECLINLINE(int) PDMDevHlpPCIRegisterMsi(PPDMDEVINS pDevIns, PPDMMSIREG pMsiReg)
6732{
6733 return pDevIns->pHlpR3->pfnPCIRegisterMsi(pDevIns, NULL, pMsiReg);
6734}
6735
6736/**
6737 * @copydoc PDMDEVHLPR3::pfnPCIRegisterMsi
6738 */
6739DECLINLINE(int) PDMDevHlpPCIRegisterMsiEx(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, PPDMMSIREG pMsiReg)
6740{
6741 return pDevIns->pHlpR3->pfnPCIRegisterMsi(pDevIns, pPciDev, pMsiReg);
6742}
6743
6744/**
6745 * Registers a I/O port region for the default PCI device.
6746 *
6747 * @returns VBox status code.
6748 * @param pDevIns The device instance.
6749 * @param iRegion The region number.
6750 * @param cbRegion Size of the region.
6751 * @param hIoPorts Handle to the I/O port region.
6752 */
6753DECLINLINE(int) PDMDevHlpPCIIORegionRegisterIo(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS cbRegion, IOMIOPORTHANDLE hIoPorts)
6754{
6755 return pDevIns->pHlpR3->pfnPCIIORegionRegister(pDevIns, NULL, iRegion, cbRegion, PCI_ADDRESS_SPACE_IO,
6756 PDMPCIDEV_IORGN_F_IOPORT_HANDLE | PDMPCIDEV_IORGN_F_NEW_STYLE, hIoPorts, NULL);
6757}
6758
6759/**
6760 * Registers a I/O port region for the default PCI device, custom map/unmap.
6761 *
6762 * @returns VBox status code.
6763 * @param pDevIns The device instance.
6764 * @param iRegion The region number.
6765 * @param cbRegion Size of the region.
6766 * @param pfnMapUnmap Callback for doing the mapping, optional. The
6767 * callback will be invoked holding only the PDM lock.
6768 * The device lock will _not_ be taken (due to lock
6769 * order).
6770 */
6771DECLINLINE(int) PDMDevHlpPCIIORegionRegisterIoCustom(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS cbRegion,
6772 PFNPCIIOREGIONMAP pfnMapUnmap)
6773{
6774 return pDevIns->pHlpR3->pfnPCIIORegionRegister(pDevIns, NULL, iRegion, cbRegion, PCI_ADDRESS_SPACE_IO,
6775 PDMPCIDEV_IORGN_F_NO_HANDLE | PDMPCIDEV_IORGN_F_NEW_STYLE,
6776 UINT64_MAX, pfnMapUnmap);
6777}
6778
6779/**
6780 * Combines PDMDevHlpIoPortCreate and PDMDevHlpPCIIORegionRegisterIo, creating
6781 * and registering an I/O port region for the default PCI device.
6782 *
6783 * @returns VBox status code.
6784 * @param pDevIns The device instance to register the ports with.
6785 * @param cPorts The count of I/O ports in the region (the size).
6786 * @param iPciRegion The PCI device region.
6787 * @param pfnOut Pointer to function which is gonna handle OUT
6788 * operations. Optional.
6789 * @param pfnIn Pointer to function which is gonna handle IN operations.
6790 * Optional.
6791 * @param pvUser User argument to pass to the callbacks.
6792 * @param pszDesc Pointer to description string. This must not be freed.
6793 * @param paExtDescs Extended per-port descriptions, optional. Partial range
6794 * coverage is allowed. This must not be freed.
6795 * @param phIoPorts Where to return the I/O port range handle.
6796 *
6797 */
6798DECLINLINE(int) PDMDevHlpPCIIORegionCreateIo(PPDMDEVINS pDevIns, uint32_t iPciRegion, RTIOPORT cPorts,
6799 PFNIOMIOPORTNEWOUT pfnOut, PFNIOMIOPORTNEWIN pfnIn, void *pvUser,
6800 const char *pszDesc, PCIOMIOPORTDESC paExtDescs, PIOMIOPORTHANDLE phIoPorts)
6801
6802{
6803 int rc = pDevIns->pHlpR3->pfnIoPortCreateEx(pDevIns, cPorts, 0 /*fFlags*/, pDevIns->apPciDevs[0], iPciRegion << 16,
6804 pfnOut, pfnIn, NULL, NULL, pvUser, pszDesc, paExtDescs, phIoPorts);
6805 if (RT_SUCCESS(rc))
6806 rc = pDevIns->pHlpR3->pfnPCIIORegionRegister(pDevIns, pDevIns->apPciDevs[0], iPciRegion, cPorts, PCI_ADDRESS_SPACE_IO,
6807 PDMPCIDEV_IORGN_F_IOPORT_HANDLE | PDMPCIDEV_IORGN_F_NEW_STYLE,
6808 *phIoPorts, NULL /*pfnMapUnmap*/);
6809 return rc;
6810}
6811
6812/**
6813 * Registers an MMIO region for the default PCI device.
6814 *
6815 * @returns VBox status code.
6816 * @param pDevIns The device instance.
6817 * @param iRegion The region number.
6818 * @param cbRegion Size of the region.
6819 * @param enmType PCI_ADDRESS_SPACE_MEM or
6820 * PCI_ADDRESS_SPACE_MEM_PREFETCH, optionally or-ing in
6821 * PCI_ADDRESS_SPACE_BAR64 or PCI_ADDRESS_SPACE_BAR32.
6822 * @param hMmioRegion Handle to the MMIO region.
6823 * @param pfnMapUnmap Callback for doing the mapping, optional. The
6824 * callback will be invoked holding only the PDM lock.
6825 * The device lock will _not_ be taken (due to lock
6826 * order).
6827 */
6828DECLINLINE(int) PDMDevHlpPCIIORegionRegisterMmio(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS cbRegion, PCIADDRESSSPACE enmType,
6829 IOMMMIOHANDLE hMmioRegion, PFNPCIIOREGIONMAP pfnMapUnmap)
6830{
6831 return pDevIns->pHlpR3->pfnPCIIORegionRegister(pDevIns, NULL, iRegion, cbRegion, enmType,
6832 PDMPCIDEV_IORGN_F_MMIO_HANDLE | PDMPCIDEV_IORGN_F_NEW_STYLE,
6833 hMmioRegion, pfnMapUnmap);
6834}
6835
6836/**
6837 * Registers an MMIO region for the default PCI device, extended version.
6838 *
6839 * @returns VBox status code.
6840 * @param pDevIns The device instance.
6841 * @param pPciDev The PCI device structure.
6842 * @param iRegion The region number.
6843 * @param cbRegion Size of the region.
6844 * @param enmType PCI_ADDRESS_SPACE_MEM or
6845 * PCI_ADDRESS_SPACE_MEM_PREFETCH, optionally or-ing in
6846 * PCI_ADDRESS_SPACE_BAR64 or PCI_ADDRESS_SPACE_BAR32.
6847 * @param hMmioRegion Handle to the MMIO region.
6848 * @param pfnMapUnmap Callback for doing the mapping, optional. The
6849 * callback will be invoked holding only the PDM lock.
6850 * The device lock will _not_ be taken (due to lock
6851 * order).
6852 */
6853DECLINLINE(int) PDMDevHlpPCIIORegionRegisterMmioEx(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion,
6854 RTGCPHYS cbRegion, PCIADDRESSSPACE enmType, IOMMMIOHANDLE hMmioRegion,
6855 PFNPCIIOREGIONMAP pfnMapUnmap)
6856{
6857 return pDevIns->pHlpR3->pfnPCIIORegionRegister(pDevIns, pPciDev, iRegion, cbRegion, enmType,
6858 PDMPCIDEV_IORGN_F_MMIO_HANDLE | PDMPCIDEV_IORGN_F_NEW_STYLE,
6859 hMmioRegion, pfnMapUnmap);
6860}
6861
6862/**
6863 * Combines PDMDevHlpMmioCreate and PDMDevHlpPCIIORegionRegisterMmio, creating
6864 * and registering an MMIO region for the default PCI device.
6865 *
6866 * @returns VBox status code.
6867 * @param pDevIns The device instance to register the ports with.
6868 * @param cbRegion The size of the region in bytes.
6869 * @param iPciRegion The PCI device region.
6870 * @param enmType PCI_ADDRESS_SPACE_MEM or
6871 * PCI_ADDRESS_SPACE_MEM_PREFETCH, optionally or-ing in
6872 * PCI_ADDRESS_SPACE_BAR64 or PCI_ADDRESS_SPACE_BAR32.
6873 * @param fFlags Flags, IOMMMIO_FLAGS_XXX.
6874 * @param pfnWrite Pointer to function which is gonna handle Write
6875 * operations.
6876 * @param pfnRead Pointer to function which is gonna handle Read
6877 * operations.
6878 * @param pvUser User argument to pass to the callbacks.
6879 * @param pszDesc Pointer to description string. This must not be freed.
6880 * @param phRegion Where to return the MMIO region handle.
6881 *
6882 */
6883DECLINLINE(int) PDMDevHlpPCIIORegionCreateMmio(PPDMDEVINS pDevIns, uint32_t iPciRegion, RTGCPHYS cbRegion, PCIADDRESSSPACE enmType,
6884 PFNIOMMMIONEWWRITE pfnWrite, PFNIOMMMIONEWREAD pfnRead, void *pvUser,
6885 uint32_t fFlags, const char *pszDesc, PIOMMMIOHANDLE phRegion)
6886
6887{
6888 int rc = pDevIns->pHlpR3->pfnMmioCreateEx(pDevIns, cbRegion, fFlags, pDevIns->apPciDevs[0], iPciRegion << 16,
6889 pfnWrite, pfnRead, NULL /*pfnFill*/, pvUser, pszDesc, phRegion);
6890 if (RT_SUCCESS(rc))
6891 rc = pDevIns->pHlpR3->pfnPCIIORegionRegister(pDevIns, pDevIns->apPciDevs[0], iPciRegion, cbRegion, enmType,
6892 PDMPCIDEV_IORGN_F_MMIO_HANDLE | PDMPCIDEV_IORGN_F_NEW_STYLE,
6893 *phRegion, NULL /*pfnMapUnmap*/);
6894 return rc;
6895}
6896
6897
6898/**
6899 * Registers an MMIO2 region for the default PCI device.
6900 *
6901 * @returns VBox status code.
6902 * @param pDevIns The device instance.
6903 * @param iRegion The region number.
6904 * @param cbRegion Size of the region.
6905 * @param enmType PCI_ADDRESS_SPACE_MEM or
6906 * PCI_ADDRESS_SPACE_MEM_PREFETCH, optionally or-ing in
6907 * PCI_ADDRESS_SPACE_BAR64 or PCI_ADDRESS_SPACE_BAR32.
6908 * @param hMmio2Region Handle to the MMIO2 region.
6909 */
6910DECLINLINE(int) PDMDevHlpPCIIORegionRegisterMmio2(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS cbRegion,
6911 PCIADDRESSSPACE enmType, PGMMMIO2HANDLE hMmio2Region)
6912{
6913 return pDevIns->pHlpR3->pfnPCIIORegionRegister(pDevIns, NULL, iRegion, cbRegion, enmType,
6914 PDMPCIDEV_IORGN_F_MMIO2_HANDLE | PDMPCIDEV_IORGN_F_NEW_STYLE,
6915 hMmio2Region, NULL);
6916}
6917
6918/**
6919 * Combines PDMDevHlpMmio2Create and PDMDevHlpPCIIORegionRegisterMmio2, creating
6920 * and registering an MMIO2 region for the default PCI device, extended edition.
6921 *
6922 * @returns VBox status code.
6923 * @param pDevIns The device instance to register the ports with.
6924 * @param cbRegion The size of the region in bytes.
6925 * @param iPciRegion The PCI device region.
6926 * @param enmType PCI_ADDRESS_SPACE_MEM or
6927 * PCI_ADDRESS_SPACE_MEM_PREFETCH, optionally or-ing in
6928 * PCI_ADDRESS_SPACE_BAR64 or PCI_ADDRESS_SPACE_BAR32.
6929 * @param pszDesc Pointer to description string. This must not be freed.
6930 * @param ppvMapping Where to store the address of the ring-3 mapping of
6931 * the memory.
6932 * @param phRegion Where to return the MMIO2 region handle.
6933 *
6934 */
6935DECLINLINE(int) PDMDevHlpPCIIORegionCreateMmio2(PPDMDEVINS pDevIns, uint32_t iPciRegion, RTGCPHYS cbRegion,
6936 PCIADDRESSSPACE enmType, const char *pszDesc,
6937 void **ppvMapping, PPGMMMIO2HANDLE phRegion)
6938
6939{
6940 int rc = pDevIns->pHlpR3->pfnMmio2Create(pDevIns, pDevIns->apPciDevs[0], iPciRegion << 16, cbRegion, 0 /*fFlags*/,
6941 pszDesc, ppvMapping, phRegion);
6942 if (RT_SUCCESS(rc))
6943 rc = pDevIns->pHlpR3->pfnPCIIORegionRegister(pDevIns, pDevIns->apPciDevs[0], iPciRegion, cbRegion, enmType,
6944 PDMPCIDEV_IORGN_F_MMIO2_HANDLE | PDMPCIDEV_IORGN_F_NEW_STYLE,
6945 *phRegion, NULL /*pfnCallback*/);
6946 return rc;
6947}
6948
6949/**
6950 * Combines PDMDevHlpMmio2Create and PDMDevHlpPCIIORegionRegisterMmio2, creating
6951 * and registering an MMIO2 region for the default PCI device.
6952 *
6953 * @returns VBox status code.
6954 * @param pDevIns The device instance to register the ports with.
6955 * @param cbRegion The size of the region in bytes.
6956 * @param iPciRegion The PCI device region.
6957 * @param enmType PCI_ADDRESS_SPACE_MEM or
6958 * PCI_ADDRESS_SPACE_MEM_PREFETCH, optionally or-ing in
6959 * PCI_ADDRESS_SPACE_BAR64 or PCI_ADDRESS_SPACE_BAR32.
6960 * @param fMmio2Flags To be defined, must be zero.
6961 * @param pfnMapUnmap Callback for doing the mapping, optional. The
6962 * callback will be invoked holding only the PDM lock.
6963 * The device lock will _not_ be taken (due to lock
6964 * order).
6965 * @param pszDesc Pointer to description string. This must not be freed.
6966 * @param ppvMapping Where to store the address of the ring-3 mapping of
6967 * the memory.
6968 * @param phRegion Where to return the MMIO2 region handle.
6969 *
6970 */
6971DECLINLINE(int) PDMDevHlpPCIIORegionCreateMmio2Ex(PPDMDEVINS pDevIns, uint32_t iPciRegion, RTGCPHYS cbRegion,
6972 PCIADDRESSSPACE enmType, uint32_t fMmio2Flags, PFNPCIIOREGIONMAP pfnMapUnmap,
6973 const char *pszDesc, void **ppvMapping, PPGMMMIO2HANDLE phRegion)
6974
6975{
6976 int rc = pDevIns->pHlpR3->pfnMmio2Create(pDevIns, pDevIns->apPciDevs[0], iPciRegion << 16, cbRegion, fMmio2Flags,
6977 pszDesc, ppvMapping, phRegion);
6978 if (RT_SUCCESS(rc))
6979 rc = pDevIns->pHlpR3->pfnPCIIORegionRegister(pDevIns, pDevIns->apPciDevs[0], iPciRegion, cbRegion, enmType,
6980 PDMPCIDEV_IORGN_F_MMIO2_HANDLE | PDMPCIDEV_IORGN_F_NEW_STYLE,
6981 *phRegion, pfnMapUnmap);
6982 return rc;
6983}
6984
6985/**
6986 * @copydoc PDMDEVHLPR3::pfnPCIInterceptConfigAccesses
6987 */
6988DECLINLINE(int) PDMDevHlpPCIInterceptConfigAccesses(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev,
6989 PFNPCICONFIGREAD pfnRead, PFNPCICONFIGWRITE pfnWrite)
6990{
6991 return pDevIns->pHlpR3->pfnPCIInterceptConfigAccesses(pDevIns, pPciDev, pfnRead, pfnWrite);
6992}
6993
6994/**
6995 * @copydoc PDMDEVHLPR3::pfnPCIConfigRead
6996 */
6997DECLINLINE(VBOXSTRICTRC) PDMDevHlpPCIConfigRead(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t uAddress,
6998 unsigned cb, uint32_t *pu32Value)
6999{
7000 return pDevIns->pHlpR3->pfnPCIConfigRead(pDevIns, pPciDev, uAddress, cb, pu32Value);
7001}
7002
7003/**
7004 * @copydoc PDMDEVHLPR3::pfnPCIConfigWrite
7005 */
7006DECLINLINE(VBOXSTRICTRC) PDMDevHlpPCIConfigWrite(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t uAddress,
7007 unsigned cb, uint32_t u32Value)
7008{
7009 return pDevIns->pHlpR3->pfnPCIConfigWrite(pDevIns, pPciDev, uAddress, cb, u32Value);
7010}
7011
7012#endif /* IN_RING3 */
7013
7014/**
7015 * Bus master physical memory read from the default PCI device.
7016 *
7017 * @returns VINF_SUCCESS or VERR_PGM_PCI_PHYS_READ_BM_DISABLED, later maybe
7018 * VERR_EM_MEMORY. The informational status shall NOT be propagated!
7019 * @param pDevIns The device instance.
7020 * @param GCPhys Physical address start reading from.
7021 * @param pvBuf Where to put the read bits.
7022 * @param cbRead How many bytes to read.
7023 * @thread Any thread, but the call may involve the emulation thread.
7024 */
7025DECLINLINE(int) PDMDevHlpPCIPhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)
7026{
7027 return pDevIns->CTX_SUFF(pHlp)->pfnPCIPhysRead(pDevIns, NULL, GCPhys, pvBuf, cbRead, PDM_DEVHLP_PHYS_RW_F_DEFAULT);
7028}
7029
7030/**
7031 * Bus master physical memory read - unknown data usage.
7032 *
7033 * @returns VINF_SUCCESS or VERR_PGM_PCI_PHYS_READ_BM_DISABLED, later maybe
7034 * VERR_EM_MEMORY. The informational status shall NOT be propagated!
7035 * @param pDevIns The device instance.
7036 * @param pPciDev The PCI device structure. If NULL the default
7037 * PCI device for this device instance is used.
7038 * @param GCPhys Physical address start reading from.
7039 * @param pvBuf Where to put the read bits.
7040 * @param cbRead How many bytes to read.
7041 * @thread Any thread, but the call may involve the emulation thread.
7042 */
7043DECLINLINE(int) PDMDevHlpPCIPhysReadEx(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)
7044{
7045 return pDevIns->CTX_SUFF(pHlp)->pfnPCIPhysRead(pDevIns, pPciDev, GCPhys, pvBuf, cbRead, PDM_DEVHLP_PHYS_RW_F_DEFAULT);
7046}
7047
7048/**
7049 * Bus master physical memory read from the default PCI device.
7050 *
7051 * @returns VINF_SUCCESS or VERR_PGM_PCI_PHYS_READ_BM_DISABLED, later maybe
7052 * VERR_EM_MEMORY. The informational status shall NOT be propagated!
7053 * @param pDevIns The device instance.
7054 * @param GCPhys Physical address start reading from.
7055 * @param pvBuf Where to put the read bits.
7056 * @param cbRead How many bytes to read.
7057 * @thread Any thread, but the call may involve the emulation thread.
7058 */
7059DECLINLINE(int) PDMDevHlpPCIPhysReadMeta(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)
7060{
7061 return pDevIns->CTX_SUFF(pHlp)->pfnPCIPhysRead(pDevIns, NULL, GCPhys, pvBuf, cbRead, PDM_DEVHLP_PHYS_RW_F_DATA_META);
7062}
7063
7064/**
7065 * Bus master physical memory read - reads meta data processed by the device.
7066 *
7067 * @returns VINF_SUCCESS or VERR_PGM_PCI_PHYS_READ_BM_DISABLED, later maybe
7068 * VERR_EM_MEMORY. The informational status shall NOT be propagated!
7069 * @param pDevIns The device instance.
7070 * @param pPciDev The PCI device structure. If NULL the default
7071 * PCI device for this device instance is used.
7072 * @param GCPhys Physical address start reading from.
7073 * @param pvBuf Where to put the read bits.
7074 * @param cbRead How many bytes to read.
7075 * @thread Any thread, but the call may involve the emulation thread.
7076 */
7077DECLINLINE(int) PDMDevHlpPCIPhysReadMetaEx(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)
7078{
7079 return pDevIns->CTX_SUFF(pHlp)->pfnPCIPhysRead(pDevIns, pPciDev, GCPhys, pvBuf, cbRead, PDM_DEVHLP_PHYS_RW_F_DATA_META);
7080}
7081
7082/**
7083 * Bus master physical memory read from the default PCI device - read data will not be touched by the device.
7084 *
7085 * @returns VINF_SUCCESS or VERR_PGM_PCI_PHYS_READ_BM_DISABLED, later maybe
7086 * VERR_EM_MEMORY. The informational status shall NOT be propagated!
7087 * @param pDevIns The device instance.
7088 * @param GCPhys Physical address start reading from.
7089 * @param pvBuf Where to put the read bits.
7090 * @param cbRead How many bytes to read.
7091 * @thread Any thread, but the call may involve the emulation thread.
7092 */
7093DECLINLINE(int) PDMDevHlpPCIPhysReadUser(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)
7094{
7095 return pDevIns->CTX_SUFF(pHlp)->pfnPCIPhysRead(pDevIns, NULL, GCPhys, pvBuf, cbRead, PDM_DEVHLP_PHYS_RW_F_DATA_USER);
7096}
7097
7098/**
7099 * Bus master physical memory read - read data will not be touched by the device.
7100 *
7101 * @returns VINF_SUCCESS or VERR_PGM_PCI_PHYS_READ_BM_DISABLED, later maybe
7102 * VERR_EM_MEMORY. The informational status shall NOT be propagated!
7103 * @param pDevIns The device instance.
7104 * @param pPciDev The PCI device structure. If NULL the default
7105 * PCI device for this device instance is used.
7106 * @param GCPhys Physical address start reading from.
7107 * @param pvBuf Where to put the read bits.
7108 * @param cbRead How many bytes to read.
7109 * @thread Any thread, but the call may involve the emulation thread.
7110 */
7111DECLINLINE(int) PDMDevHlpPCIPhysReadUserEx(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)
7112{
7113 return pDevIns->CTX_SUFF(pHlp)->pfnPCIPhysRead(pDevIns, pPciDev, GCPhys, pvBuf, cbRead, PDM_DEVHLP_PHYS_RW_F_DATA_USER);
7114}
7115
7116/**
7117 * Bus master physical memory write from the default PCI device - unknown data usage.
7118 *
7119 * @returns VINF_SUCCESS or VERR_PGM_PCI_PHYS_WRITE_BM_DISABLED, later maybe
7120 * VERR_EM_MEMORY. The informational status shall NOT be propagated!
7121 * @param pDevIns The device instance.
7122 * @param GCPhys Physical address to write to.
7123 * @param pvBuf What to write.
7124 * @param cbWrite How many bytes to write.
7125 * @thread Any thread, but the call may involve the emulation thread.
7126 */
7127DECLINLINE(int) PDMDevHlpPCIPhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)
7128{
7129 return pDevIns->CTX_SUFF(pHlp)->pfnPCIPhysWrite(pDevIns, NULL, GCPhys, pvBuf, cbWrite, PDM_DEVHLP_PHYS_RW_F_DEFAULT);
7130}
7131
7132/**
7133 * Bus master physical memory write - unknown data usage.
7134 *
7135 * @returns VINF_SUCCESS or VERR_PGM_PCI_PHYS_WRITE_BM_DISABLED, later maybe
7136 * VERR_EM_MEMORY. The informational status shall NOT be propagated!
7137 * @param pDevIns The device instance.
7138 * @param pPciDev The PCI device structure. If NULL the default
7139 * PCI device for this device instance is used.
7140 * @param GCPhys Physical address to write to.
7141 * @param pvBuf What to write.
7142 * @param cbWrite How many bytes to write.
7143 * @thread Any thread, but the call may involve the emulation thread.
7144 */
7145DECLINLINE(int) PDMDevHlpPCIPhysWriteEx(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)
7146{
7147 return pDevIns->CTX_SUFF(pHlp)->pfnPCIPhysWrite(pDevIns, pPciDev, GCPhys, pvBuf, cbWrite, PDM_DEVHLP_PHYS_RW_F_DEFAULT);
7148}
7149
7150/**
7151 * Bus master physical memory write from the default PCI device.
7152 *
7153 * @returns VINF_SUCCESS or VERR_PGM_PCI_PHYS_WRITE_BM_DISABLED, later maybe
7154 * VERR_EM_MEMORY. The informational status shall NOT be propagated!
7155 * @param pDevIns The device instance.
7156 * @param GCPhys Physical address to write to.
7157 * @param pvBuf What to write.
7158 * @param cbWrite How many bytes to write.
7159 * @thread Any thread, but the call may involve the emulation thread.
7160 */
7161DECLINLINE(int) PDMDevHlpPCIPhysWriteMeta(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)
7162{
7163 return pDevIns->CTX_SUFF(pHlp)->pfnPCIPhysWrite(pDevIns, NULL, GCPhys, pvBuf, cbWrite, PDM_DEVHLP_PHYS_RW_F_DATA_META);
7164}
7165
7166/**
7167 * Bus master physical memory write - written data was created/altered by the device.
7168 *
7169 * @returns VINF_SUCCESS or VERR_PGM_PCI_PHYS_WRITE_BM_DISABLED, later maybe
7170 * VERR_EM_MEMORY. The informational status shall NOT be propagated!
7171 * @param pDevIns The device instance.
7172 * @param pPciDev The PCI device structure. If NULL the default
7173 * PCI device for this device instance is used.
7174 * @param GCPhys Physical address to write to.
7175 * @param pvBuf What to write.
7176 * @param cbWrite How many bytes to write.
7177 * @thread Any thread, but the call may involve the emulation thread.
7178 */
7179DECLINLINE(int) PDMDevHlpPCIPhysWriteMetaEx(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)
7180{
7181 return pDevIns->CTX_SUFF(pHlp)->pfnPCIPhysWrite(pDevIns, pPciDev, GCPhys, pvBuf, cbWrite, PDM_DEVHLP_PHYS_RW_F_DATA_META);
7182}
7183
7184/**
7185 * Bus master physical memory write from the default PCI device.
7186 *
7187 * @returns VINF_SUCCESS or VERR_PGM_PCI_PHYS_WRITE_BM_DISABLED, later maybe
7188 * VERR_EM_MEMORY. The informational status shall NOT be propagated!
7189 * @param pDevIns The device instance.
7190 * @param GCPhys Physical address to write to.
7191 * @param pvBuf What to write.
7192 * @param cbWrite How many bytes to write.
7193 * @thread Any thread, but the call may involve the emulation thread.
7194 */
7195DECLINLINE(int) PDMDevHlpPCIPhysWriteUser(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)
7196{
7197 return pDevIns->CTX_SUFF(pHlp)->pfnPCIPhysWrite(pDevIns, NULL, GCPhys, pvBuf, cbWrite, PDM_DEVHLP_PHYS_RW_F_DATA_USER);
7198}
7199
7200/**
7201 * Bus master physical memory write - written data was not touched/created by the device.
7202 *
7203 * @returns VINF_SUCCESS or VERR_PGM_PCI_PHYS_WRITE_BM_DISABLED, later maybe
7204 * VERR_EM_MEMORY. The informational status shall NOT be propagated!
7205 * @param pDevIns The device instance.
7206 * @param pPciDev The PCI device structure. If NULL the default
7207 * PCI device for this device instance is used.
7208 * @param GCPhys Physical address to write to.
7209 * @param pvBuf What to write.
7210 * @param cbWrite How many bytes to write.
7211 * @thread Any thread, but the call may involve the emulation thread.
7212 */
7213DECLINLINE(int) PDMDevHlpPCIPhysWriteUserEx(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)
7214{
7215 return pDevIns->CTX_SUFF(pHlp)->pfnPCIPhysWrite(pDevIns, pPciDev, GCPhys, pvBuf, cbWrite, PDM_DEVHLP_PHYS_RW_F_DATA_USER);
7216}
7217
7218/**
7219 * Sets the IRQ for the default PCI device.
7220 *
7221 * @param pDevIns The device instance.
7222 * @param iIrq IRQ number to set.
7223 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
7224 * @thread Any thread, but will involve the emulation thread.
7225 */
7226DECLINLINE(void) PDMDevHlpPCISetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel)
7227{
7228 pDevIns->CTX_SUFF(pHlp)->pfnPCISetIrq(pDevIns, NULL, iIrq, iLevel);
7229}
7230
7231/**
7232 * @copydoc PDMDEVHLPR3::pfnPCISetIrq
7233 */
7234DECLINLINE(void) PDMDevHlpPCISetIrqEx(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iIrq, int iLevel)
7235{
7236 pDevIns->CTX_SUFF(pHlp)->pfnPCISetIrq(pDevIns, pPciDev, iIrq, iLevel);
7237}
7238
7239/**
7240 * Sets the IRQ for the given PCI device, but doesn't wait for EMT to process
7241 * the request when not called from EMT.
7242 *
7243 * @param pDevIns The device instance.
7244 * @param iIrq IRQ number to set.
7245 * @param iLevel IRQ level.
7246 * @thread Any thread, but will involve the emulation thread.
7247 */
7248DECLINLINE(void) PDMDevHlpPCISetIrqNoWait(PPDMDEVINS pDevIns, int iIrq, int iLevel)
7249{
7250 pDevIns->CTX_SUFF(pHlp)->pfnPCISetIrq(pDevIns, NULL, iIrq, iLevel);
7251}
7252
7253/**
7254 * @copydoc PDMDEVHLPR3::pfnPCISetIrqNoWait
7255 */
7256DECLINLINE(void) PDMDevHlpPCISetIrqNoWaitEx(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iIrq, int iLevel)
7257{
7258 pDevIns->CTX_SUFF(pHlp)->pfnPCISetIrq(pDevIns, pPciDev, iIrq, iLevel);
7259}
7260
7261/**
7262 * @copydoc PDMDEVHLPR3::pfnISASetIrq
7263 */
7264DECLINLINE(void) PDMDevHlpISASetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel)
7265{
7266 pDevIns->CTX_SUFF(pHlp)->pfnISASetIrq(pDevIns, iIrq, iLevel);
7267}
7268
7269/**
7270 * @copydoc PDMDEVHLPR3::pfnISASetIrqNoWait
7271 */
7272DECLINLINE(void) PDMDevHlpISASetIrqNoWait(PPDMDEVINS pDevIns, int iIrq, int iLevel)
7273{
7274 pDevIns->CTX_SUFF(pHlp)->pfnISASetIrq(pDevIns, iIrq, iLevel);
7275}
7276
7277#ifdef IN_RING3
7278
7279/**
7280 * @copydoc PDMDEVHLPR3::pfnDriverAttach
7281 */
7282DECLINLINE(int) PDMDevHlpDriverAttach(PPDMDEVINS pDevIns, uint32_t iLun, PPDMIBASE pBaseInterface, PPDMIBASE *ppBaseInterface, const char *pszDesc)
7283{
7284 return pDevIns->pHlpR3->pfnDriverAttach(pDevIns, iLun, pBaseInterface, ppBaseInterface, pszDesc);
7285}
7286
7287/**
7288 * @copydoc PDMDEVHLPR3::pfnDriverDetach
7289 */
7290DECLINLINE(int) PDMDevHlpDriverDetach(PPDMDEVINS pDevIns, PPDMDRVINS pDrvIns, uint32_t fFlags)
7291{
7292 return pDevIns->pHlpR3->pfnDriverDetach(pDevIns, pDrvIns, fFlags);
7293}
7294
7295/**
7296 * @copydoc PDMDEVHLPR3::pfnDriverReconfigure
7297 */
7298DECLINLINE(int) PDMDevHlpDriverReconfigure(PPDMDEVINS pDevIns, uint32_t iLun, uint32_t cDepth,
7299 const char * const *papszDrivers, PCFGMNODE *papConfigs, uint32_t fFlags)
7300{
7301 return pDevIns->pHlpR3->pfnDriverReconfigure(pDevIns, iLun, cDepth, papszDrivers, papConfigs, fFlags);
7302}
7303
7304/**
7305 * Reconfigures with a single driver reattachement, no config, noflags.
7306 * @sa PDMDevHlpDriverReconfigure
7307 */
7308DECLINLINE(int) PDMDevHlpDriverReconfigure1(PPDMDEVINS pDevIns, uint32_t iLun, const char *pszDriver0)
7309{
7310 return pDevIns->pHlpR3->pfnDriverReconfigure(pDevIns, iLun, 1, &pszDriver0, NULL, 0);
7311}
7312
7313/**
7314 * Reconfigures with a two drivers reattachement, no config, noflags.
7315 * @sa PDMDevHlpDriverReconfigure
7316 */
7317DECLINLINE(int) PDMDevHlpDriverReconfigure2(PPDMDEVINS pDevIns, uint32_t iLun, const char *pszDriver0, const char *pszDriver1)
7318{
7319 char const * apszDrivers[2];
7320 apszDrivers[0] = pszDriver0;
7321 apszDrivers[1] = pszDriver1;
7322 return pDevIns->pHlpR3->pfnDriverReconfigure(pDevIns, iLun, 2, apszDrivers, NULL, 0);
7323}
7324
7325/**
7326 * @copydoc PDMDEVHLPR3::pfnQueueCreatePtr
7327 */
7328DECLINLINE(int) PDMDevHlpQueueCreate(PPDMDEVINS pDevIns, size_t cbItem, uint32_t cItems, uint32_t cMilliesInterval,
7329 PFNPDMQUEUEDEV pfnCallback, bool fRZEnabled, const char *pszName, PPDMQUEUE *ppQueue)
7330{
7331 return pDevIns->pHlpR3->pfnQueueCreatePtr(pDevIns, cbItem, cItems, cMilliesInterval, pfnCallback, fRZEnabled, pszName, ppQueue);
7332}
7333
7334/**
7335 * @copydoc PDMDEVHLPR3::pfnQueueCreate
7336 */
7337DECLINLINE(int) PDMDevHlpQueueCreateNew(PPDMDEVINS pDevIns, size_t cbItem, uint32_t cItems, uint32_t cMilliesInterval,
7338 PFNPDMQUEUEDEV pfnCallback, bool fRZEnabled, const char *pszName, PDMQUEUEHANDLE *phQueue)
7339{
7340 return pDevIns->pHlpR3->pfnQueueCreate(pDevIns, cbItem, cItems, cMilliesInterval, pfnCallback, fRZEnabled, pszName, phQueue);
7341}
7342
7343#endif /* IN_RING3 */
7344
7345/**
7346 * @copydoc PDMDEVHLPR3::pfnQueueAlloc
7347 */
7348DECLINLINE(PPDMQUEUEITEMCORE) PDMDevHlpQueueAlloc(PPDMDEVINS pDevIns, PDMQUEUEHANDLE hQueue)
7349{
7350 return pDevIns->CTX_SUFF(pHlp)->pfnQueueAlloc(pDevIns, hQueue);
7351}
7352
7353/**
7354 * @copydoc PDMDEVHLPR3::pfnQueueInsert
7355 */
7356DECLINLINE(void) PDMDevHlpQueueInsert(PPDMDEVINS pDevIns, PDMQUEUEHANDLE hQueue, PPDMQUEUEITEMCORE pItem)
7357{
7358 pDevIns->CTX_SUFF(pHlp)->pfnQueueInsert(pDevIns, hQueue, pItem);
7359}
7360
7361/**
7362 * @copydoc PDMDEVHLPR3::pfnQueueInsertEx
7363 */
7364DECLINLINE(void) PDMDevHlpQueueInsertEx(PPDMDEVINS pDevIns, PDMQUEUEHANDLE hQueue, PPDMQUEUEITEMCORE pItem, uint64_t cNanoMaxDelay)
7365{
7366 pDevIns->CTX_SUFF(pHlp)->pfnQueueInsertEx(pDevIns, hQueue, pItem, cNanoMaxDelay);
7367}
7368
7369/**
7370 * @copydoc PDMDEVHLPR3::pfnQueueFlushIfNecessary
7371 */
7372DECLINLINE(bool) PDMDevHlpQueueFlushIfNecessary(PPDMDEVINS pDevIns, PDMQUEUEHANDLE hQueue)
7373{
7374 return pDevIns->CTX_SUFF(pHlp)->pfnQueueFlushIfNecessary(pDevIns, hQueue);
7375}
7376
7377#ifdef IN_RING3
7378/**
7379 * @copydoc PDMDEVHLPR3::pfnTaskCreate
7380 */
7381DECLINLINE(int) PDMDevHlpTaskCreate(PPDMDEVINS pDevIns, uint32_t fFlags, const char *pszName,
7382 PFNPDMTASKDEV pfnCallback, void *pvUser, PDMTASKHANDLE *phTask)
7383{
7384 return pDevIns->pHlpR3->pfnTaskCreate(pDevIns, fFlags, pszName, pfnCallback, pvUser, phTask);
7385}
7386#endif
7387
7388/**
7389 * @copydoc PDMDEVHLPR3::pfnTaskTrigger
7390 */
7391DECLINLINE(int) PDMDevHlpTaskTrigger(PPDMDEVINS pDevIns, PDMTASKHANDLE hTask)
7392{
7393 return pDevIns->CTX_SUFF(pHlp)->pfnTaskTrigger(pDevIns, hTask);
7394}
7395
7396#ifdef IN_RING3
7397
7398/**
7399 * @copydoc PDMDEVHLPR3::pfnSUPSemEventCreate
7400 */
7401DECLINLINE(int) PDMDevHlpSUPSemEventCreate(PPDMDEVINS pDevIns, PSUPSEMEVENT phEvent)
7402{
7403 return pDevIns->pHlpR3->pfnSUPSemEventCreate(pDevIns, phEvent);
7404}
7405
7406/**
7407 * @copydoc PDMDEVHLPR3::pfnSUPSemEventClose
7408 */
7409DECLINLINE(int) PDMDevHlpSUPSemEventClose(PPDMDEVINS pDevIns, SUPSEMEVENT hEvent)
7410{
7411 return pDevIns->pHlpR3->pfnSUPSemEventClose(pDevIns, hEvent);
7412}
7413
7414#endif /* IN_RING3 */
7415
7416/**
7417 * @copydoc PDMDEVHLPR3::pfnSUPSemEventSignal
7418 */
7419DECLINLINE(int) PDMDevHlpSUPSemEventSignal(PPDMDEVINS pDevIns, SUPSEMEVENT hEvent)
7420{
7421 return pDevIns->CTX_SUFF(pHlp)->pfnSUPSemEventSignal(pDevIns, hEvent);
7422}
7423
7424/**
7425 * @copydoc PDMDEVHLPR3::pfnSUPSemEventWaitNoResume
7426 */
7427DECLINLINE(int) PDMDevHlpSUPSemEventWaitNoResume(PPDMDEVINS pDevIns, SUPSEMEVENT hEvent, uint32_t cMillies)
7428{
7429 return pDevIns->CTX_SUFF(pHlp)->pfnSUPSemEventWaitNoResume(pDevIns, hEvent, cMillies);
7430}
7431
7432/**
7433 * @copydoc PDMDEVHLPR3::pfnSUPSemEventWaitNsAbsIntr
7434 */
7435DECLINLINE(int) PDMDevHlpSUPSemEventWaitNsAbsIntr(PPDMDEVINS pDevIns, SUPSEMEVENT hEvent, uint64_t uNsTimeout)
7436{
7437 return pDevIns->CTX_SUFF(pHlp)->pfnSUPSemEventWaitNsAbsIntr(pDevIns, hEvent, uNsTimeout);
7438}
7439
7440/**
7441 * @copydoc PDMDEVHLPR3::pfnSUPSemEventWaitNsRelIntr
7442 */
7443DECLINLINE(int) PDMDevHlpSUPSemEventWaitNsRelIntr(PPDMDEVINS pDevIns, SUPSEMEVENT hEvent, uint64_t cNsTimeout)
7444{
7445 return pDevIns->CTX_SUFF(pHlp)->pfnSUPSemEventWaitNsRelIntr(pDevIns, hEvent, cNsTimeout);
7446}
7447
7448/**
7449 * @copydoc PDMDEVHLPR3::pfnSUPSemEventGetResolution
7450 */
7451DECLINLINE(uint32_t) PDMDevHlpSUPSemEventGetResolution(PPDMDEVINS pDevIns)
7452{
7453 return pDevIns->CTX_SUFF(pHlp)->pfnSUPSemEventGetResolution(pDevIns);
7454}
7455
7456#ifdef IN_RING3
7457
7458/**
7459 * @copydoc PDMDEVHLPR3::pfnSUPSemEventMultiCreate
7460 */
7461DECLINLINE(int) PDMDevHlpSUPSemEventMultiCreate(PPDMDEVINS pDevIns, PSUPSEMEVENTMULTI phEventMulti)
7462{
7463 return pDevIns->pHlpR3->pfnSUPSemEventMultiCreate(pDevIns, phEventMulti);
7464}
7465
7466/**
7467 * @copydoc PDMDEVHLPR3::pfnSUPSemEventMultiClose
7468 */
7469DECLINLINE(int) PDMDevHlpSUPSemEventMultiClose(PPDMDEVINS pDevIns, SUPSEMEVENTMULTI hEventMulti)
7470{
7471 return pDevIns->pHlpR3->pfnSUPSemEventMultiClose(pDevIns, hEventMulti);
7472}
7473
7474#endif /* IN_RING3 */
7475
7476/**
7477 * @copydoc PDMDEVHLPR3::pfnSUPSemEventMultiSignal
7478 */
7479DECLINLINE(int) PDMDevHlpSUPSemEventMultiSignal(PPDMDEVINS pDevIns, SUPSEMEVENTMULTI hEventMulti)
7480{
7481 return pDevIns->CTX_SUFF(pHlp)->pfnSUPSemEventMultiSignal(pDevIns, hEventMulti);
7482}
7483
7484/**
7485 * @copydoc PDMDEVHLPR3::pfnSUPSemEventMultiReset
7486 */
7487DECLINLINE(int) PDMDevHlpSUPSemEventMultiReset(PPDMDEVINS pDevIns, SUPSEMEVENTMULTI hEventMulti)
7488{
7489 return pDevIns->CTX_SUFF(pHlp)->pfnSUPSemEventMultiReset(pDevIns, hEventMulti);
7490}
7491
7492/**
7493 * @copydoc PDMDEVHLPR3::pfnSUPSemEventMultiWaitNoResume
7494 */
7495DECLINLINE(int) PDMDevHlpSUPSemEventMultiWaitNoResume(PPDMDEVINS pDevIns, SUPSEMEVENTMULTI hEventMulti, uint32_t cMillies)
7496{
7497 return pDevIns->CTX_SUFF(pHlp)->pfnSUPSemEventMultiWaitNsRelIntr(pDevIns, hEventMulti, cMillies);
7498}
7499
7500/**
7501 * @copydoc PDMDEVHLPR3::pfnSUPSemEventMultiWaitNsAbsIntr
7502 */
7503DECLINLINE(int) PDMDevHlpSUPSemEventMultiWaitNsAbsIntr(PPDMDEVINS pDevIns, SUPSEMEVENTMULTI hEventMulti, uint64_t uNsTimeout)
7504{
7505 return pDevIns->CTX_SUFF(pHlp)->pfnSUPSemEventMultiWaitNsAbsIntr(pDevIns, hEventMulti, uNsTimeout);
7506}
7507
7508/**
7509 * @copydoc PDMDEVHLPR3::pfnSUPSemEventMultiWaitNsRelIntr
7510 */
7511DECLINLINE(int) PDMDevHlpSUPSemEventMultiWaitNsRelIntr(PPDMDEVINS pDevIns, SUPSEMEVENTMULTI hEventMulti, uint64_t cNsTimeout)
7512{
7513 return pDevIns->CTX_SUFF(pHlp)->pfnSUPSemEventMultiWaitNsRelIntr(pDevIns, hEventMulti, cNsTimeout);
7514}
7515
7516/**
7517 * @copydoc PDMDEVHLPR3::pfnSUPSemEventMultiGetResolution
7518 */
7519DECLINLINE(uint32_t) PDMDevHlpSUPSemEventMultiGetResolution(PPDMDEVINS pDevIns)
7520{
7521 return pDevIns->CTX_SUFF(pHlp)->pfnSUPSemEventMultiGetResolution(pDevIns);
7522}
7523
7524#ifdef IN_RING3
7525
7526/**
7527 * Initializes a PDM critical section.
7528 *
7529 * The PDM critical sections are derived from the IPRT critical sections, but
7530 * works in RC and R0 as well.
7531 *
7532 * @returns VBox status code.
7533 * @param pDevIns The device instance.
7534 * @param pCritSect Pointer to the critical section.
7535 * @param SRC_POS Use RT_SRC_POS.
7536 * @param pszNameFmt Format string for naming the critical section.
7537 * For statistics and lock validation.
7538 * @param ... Arguments for the format string.
7539 */
7540DECLINLINE(int) RT_IPRT_FORMAT_ATTR(6, 7) PDMDevHlpCritSectInit(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, RT_SRC_POS_DECL,
7541 const char *pszNameFmt, ...)
7542{
7543 int rc;
7544 va_list va;
7545 va_start(va, pszNameFmt);
7546 rc = pDevIns->pHlpR3->pfnCritSectInit(pDevIns, pCritSect, RT_SRC_POS_ARGS, pszNameFmt, va);
7547 va_end(va);
7548 return rc;
7549}
7550
7551#endif /* IN_RING3 */
7552
7553/**
7554 * @copydoc PDMDEVHLPR3::pfnCritSectGetNop
7555 */
7556DECLINLINE(PPDMCRITSECT) PDMDevHlpCritSectGetNop(PPDMDEVINS pDevIns)
7557{
7558 return pDevIns->CTX_SUFF(pHlp)->pfnCritSectGetNop(pDevIns);
7559}
7560
7561#ifdef IN_RING3
7562
7563/**
7564 * @copydoc PDMDEVHLPR3::pfnCritSectGetNopR0
7565 */
7566DECLINLINE(R0PTRTYPE(PPDMCRITSECT)) PDMDevHlpCritSectGetNopR0(PPDMDEVINS pDevIns)
7567{
7568 return pDevIns->pHlpR3->pfnCritSectGetNopR0(pDevIns);
7569}
7570
7571/**
7572 * @copydoc PDMDEVHLPR3::pfnCritSectGetNopRC
7573 */
7574DECLINLINE(RCPTRTYPE(PPDMCRITSECT)) PDMDevHlpCritSectGetNopRC(PPDMDEVINS pDevIns)
7575{
7576 return pDevIns->pHlpR3->pfnCritSectGetNopRC(pDevIns);
7577}
7578
7579#endif /* IN_RING3 */
7580
7581/**
7582 * @copydoc PDMDEVHLPR3::pfnSetDeviceCritSect
7583 */
7584DECLINLINE(int) PDMDevHlpSetDeviceCritSect(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect)
7585{
7586 return pDevIns->CTX_SUFF(pHlp)->pfnSetDeviceCritSect(pDevIns, pCritSect);
7587}
7588
7589/**
7590 * @copydoc PDMCritSectEnter
7591 * @param pDevIns The device instance.
7592 */
7593DECLINLINE(int) PDMDevHlpCritSectEnter(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, int rcBusy)
7594{
7595 return pDevIns->CTX_SUFF(pHlp)->pfnCritSectEnter(pDevIns, pCritSect, rcBusy);
7596}
7597
7598/**
7599 * @copydoc PDMCritSectEnterDebug
7600 * @param pDevIns The device instance.
7601 */
7602DECLINLINE(int) PDMDevHlpCritSectEnterDebug(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, int rcBusy, RTHCUINTPTR uId, RT_SRC_POS_DECL)
7603{
7604 return pDevIns->CTX_SUFF(pHlp)->pfnCritSectEnterDebug(pDevIns, pCritSect, rcBusy, uId, RT_SRC_POS_ARGS);
7605}
7606
7607/**
7608 * @copydoc PDMCritSectTryEnter
7609 * @param pDevIns The device instance.
7610 */
7611DECLINLINE(int) PDMDevHlpCritSectTryEnter(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect)
7612{
7613 return pDevIns->CTX_SUFF(pHlp)->pfnCritSectTryEnter(pDevIns, pCritSect);
7614}
7615
7616/**
7617 * @copydoc PDMCritSectTryEnterDebug
7618 * @param pDevIns The device instance.
7619 */
7620DECLINLINE(int) PDMDevHlpCritSectTryEnterDebug(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, RTHCUINTPTR uId, RT_SRC_POS_DECL)
7621{
7622 return pDevIns->CTX_SUFF(pHlp)->pfnCritSectTryEnterDebug(pDevIns, pCritSect, uId, RT_SRC_POS_ARGS);
7623}
7624
7625/**
7626 * @copydoc PDMCritSectLeave
7627 * @param pDevIns The device instance.
7628 */
7629DECLINLINE(int) PDMDevHlpCritSectLeave(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect)
7630{
7631 return pDevIns->CTX_SUFF(pHlp)->pfnCritSectLeave(pDevIns, pCritSect);
7632}
7633
7634/**
7635 * @copydoc PDMCritSectIsOwner
7636 * @param pDevIns The device instance.
7637 */
7638DECLINLINE(bool) PDMDevHlpCritSectIsOwner(PPDMDEVINS pDevIns, PCPDMCRITSECT pCritSect)
7639{
7640 return pDevIns->CTX_SUFF(pHlp)->pfnCritSectIsOwner(pDevIns, pCritSect);
7641}
7642
7643/**
7644 * @copydoc PDMCritSectIsInitialized
7645 * @param pDevIns The device instance.
7646 */
7647DECLINLINE(bool) PDMDevHlpCritSectIsInitialized(PPDMDEVINS pDevIns, PCPDMCRITSECT pCritSect)
7648{
7649 return pDevIns->CTX_SUFF(pHlp)->pfnCritSectIsInitialized(pDevIns, pCritSect);
7650}
7651
7652/**
7653 * @copydoc PDMCritSectHasWaiters
7654 * @param pDevIns The device instance.
7655 */
7656DECLINLINE(bool) PDMDevHlpCritSectHasWaiters(PPDMDEVINS pDevIns, PCPDMCRITSECT pCritSect)
7657{
7658 return pDevIns->CTX_SUFF(pHlp)->pfnCritSectHasWaiters(pDevIns, pCritSect);
7659}
7660
7661/**
7662 * @copydoc PDMCritSectGetRecursion
7663 * @param pDevIns The device instance.
7664 */
7665DECLINLINE(uint32_t) PDMDevHlpCritSectGetRecursion(PPDMDEVINS pDevIns, PCPDMCRITSECT pCritSect)
7666{
7667 return pDevIns->CTX_SUFF(pHlp)->pfnCritSectGetRecursion(pDevIns, pCritSect);
7668}
7669
7670#if defined(IN_RING3) || defined(IN_RING0)
7671/**
7672 * @copydoc PDMHCCritSectScheduleExitEvent
7673 * @param pDevIns The device instance.
7674 */
7675DECLINLINE(int) PDMDevHlpCritSectScheduleExitEvent(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, SUPSEMEVENT hEventToSignal)
7676{
7677 return pDevIns->CTX_SUFF(pHlp)->pfnCritSectScheduleExitEvent(pDevIns, pCritSect, hEventToSignal);
7678}
7679#endif
7680
7681/* Strict build: Remap the two enter calls to the debug versions. */
7682#ifdef VBOX_STRICT
7683# ifdef IPRT_INCLUDED_asm_h
7684# define PDMDevHlpCritSectEnter(pDevIns, pCritSect, rcBusy) PDMDevHlpCritSectEnterDebug((pDevIns), (pCritSect), (rcBusy), (uintptr_t)ASMReturnAddress(), RT_SRC_POS)
7685# define PDMDevHlpCritSectTryEnter(pDevIns, pCritSect) PDMDevHlpCritSectTryEnterDebug((pDevIns), (pCritSect), (uintptr_t)ASMReturnAddress(), RT_SRC_POS)
7686# else
7687# define PDMDevHlpCritSectEnter(pDevIns, pCritSect, rcBusy) PDMDevHlpCritSectEnterDebug((pDevIns), (pCritSect), (rcBusy), 0, RT_SRC_POS)
7688# define PDMDevHlpCritSectTryEnter(pDevIns, pCritSect) PDMDevHlpCritSectTryEnterDebug((pDevIns), (pCritSect), 0, RT_SRC_POS)
7689# endif
7690#endif
7691
7692#if defined(IN_RING3) || defined(DOXYGEN_RUNNING)
7693
7694/**
7695 * @copydoc PDMR3CritSectDelete
7696 * @param pDevIns The device instance.
7697 */
7698DECLINLINE(int) PDMDevHlpCritSectDelete(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect)
7699{
7700 return pDevIns->pHlpR3->pfnCritSectDelete(pDevIns, pCritSect);
7701}
7702
7703/**
7704 * @copydoc PDMDEVHLPR3::pfnThreadCreate
7705 */
7706DECLINLINE(int) PDMDevHlpThreadCreate(PPDMDEVINS pDevIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADDEV pfnThread,
7707 PFNPDMTHREADWAKEUPDEV pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName)
7708{
7709 return pDevIns->pHlpR3->pfnThreadCreate(pDevIns, ppThread, pvUser, pfnThread, pfnWakeup, cbStack, enmType, pszName);
7710}
7711
7712/**
7713 * @copydoc PDMR3ThreadDestroy
7714 * @param pDevIns The device instance.
7715 */
7716DECLINLINE(int) PDMDevHlpThreadDestroy(PPDMDEVINS pDevIns, PPDMTHREAD pThread, int *pRcThread)
7717{
7718 return pDevIns->pHlpR3->pfnThreadDestroy(pThread, pRcThread);
7719}
7720
7721/**
7722 * @copydoc PDMR3ThreadIAmSuspending
7723 * @param pDevIns The device instance.
7724 */
7725DECLINLINE(int) PDMDevHlpThreadIAmSuspending(PPDMDEVINS pDevIns, PPDMTHREAD pThread)
7726{
7727 return pDevIns->pHlpR3->pfnThreadIAmSuspending(pThread);
7728}
7729
7730/**
7731 * @copydoc PDMR3ThreadIAmRunning
7732 * @param pDevIns The device instance.
7733 */
7734DECLINLINE(int) PDMDevHlpThreadIAmRunning(PPDMDEVINS pDevIns, PPDMTHREAD pThread)
7735{
7736 return pDevIns->pHlpR3->pfnThreadIAmRunning(pThread);
7737}
7738
7739/**
7740 * @copydoc PDMR3ThreadSleep
7741 * @param pDevIns The device instance.
7742 */
7743DECLINLINE(int) PDMDevHlpThreadSleep(PPDMDEVINS pDevIns, PPDMTHREAD pThread, RTMSINTERVAL cMillies)
7744{
7745 return pDevIns->pHlpR3->pfnThreadSleep(pThread, cMillies);
7746}
7747
7748/**
7749 * @copydoc PDMR3ThreadSuspend
7750 * @param pDevIns The device instance.
7751 */
7752DECLINLINE(int) PDMDevHlpThreadSuspend(PPDMDEVINS pDevIns, PPDMTHREAD pThread)
7753{
7754 return pDevIns->pHlpR3->pfnThreadSuspend(pThread);
7755}
7756
7757/**
7758 * @copydoc PDMR3ThreadResume
7759 * @param pDevIns The device instance.
7760 */
7761DECLINLINE(int) PDMDevHlpThreadResume(PPDMDEVINS pDevIns, PPDMTHREAD pThread)
7762{
7763 return pDevIns->pHlpR3->pfnThreadResume(pThread);
7764}
7765
7766/**
7767 * @copydoc PDMDEVHLPR3::pfnSetAsyncNotification
7768 */
7769DECLINLINE(int) PDMDevHlpSetAsyncNotification(PPDMDEVINS pDevIns, PFNPDMDEVASYNCNOTIFY pfnAsyncNotify)
7770{
7771 return pDevIns->pHlpR3->pfnSetAsyncNotification(pDevIns, pfnAsyncNotify);
7772}
7773
7774/**
7775 * @copydoc PDMDEVHLPR3::pfnAsyncNotificationCompleted
7776 */
7777DECLINLINE(void) PDMDevHlpAsyncNotificationCompleted(PPDMDEVINS pDevIns)
7778{
7779 pDevIns->pHlpR3->pfnAsyncNotificationCompleted(pDevIns);
7780}
7781
7782/**
7783 * @copydoc PDMDEVHLPR3::pfnA20Set
7784 */
7785DECLINLINE(void) PDMDevHlpA20Set(PPDMDEVINS pDevIns, bool fEnable)
7786{
7787 pDevIns->pHlpR3->pfnA20Set(pDevIns, fEnable);
7788}
7789
7790/**
7791 * @copydoc PDMDEVHLPR3::pfnRTCRegister
7792 */
7793DECLINLINE(int) PDMDevHlpRTCRegister(PPDMDEVINS pDevIns, PCPDMRTCREG pRtcReg, PCPDMRTCHLP *ppRtcHlp)
7794{
7795 return pDevIns->pHlpR3->pfnRTCRegister(pDevIns, pRtcReg, ppRtcHlp);
7796}
7797
7798/**
7799 * @copydoc PDMDEVHLPR3::pfnPCIBusRegister
7800 */
7801DECLINLINE(int) PDMDevHlpPCIBusRegister(PPDMDEVINS pDevIns, PPDMPCIBUSREGR3 pPciBusReg, PCPDMPCIHLPR3 *ppPciHlp, uint32_t *piBus)
7802{
7803 return pDevIns->pHlpR3->pfnPCIBusRegister(pDevIns, pPciBusReg, ppPciHlp, piBus);
7804}
7805
7806/**
7807 * @copydoc PDMDEVHLPR3::pfnIommuRegister
7808 */
7809DECLINLINE(int) PDMDevHlpIommuRegister(PPDMDEVINS pDevIns, PPDMIOMMUREGR3 pIommuReg, PCPDMIOMMUHLPR3 *ppIommuHlp, uint32_t *pidxIommu)
7810{
7811 return pDevIns->pHlpR3->pfnIommuRegister(pDevIns, pIommuReg, ppIommuHlp, pidxIommu);
7812}
7813
7814/**
7815 * @copydoc PDMDEVHLPR3::pfnPICRegister
7816 */
7817DECLINLINE(int) PDMDevHlpPICRegister(PPDMDEVINS pDevIns, PPDMPICREG pPicReg, PCPDMPICHLP *ppPicHlp)
7818{
7819 return pDevIns->pHlpR3->pfnPICRegister(pDevIns, pPicReg, ppPicHlp);
7820}
7821
7822/**
7823 * @copydoc PDMDEVHLPR3::pfnApicRegister
7824 */
7825DECLINLINE(int) PDMDevHlpApicRegister(PPDMDEVINS pDevIns)
7826{
7827 return pDevIns->pHlpR3->pfnApicRegister(pDevIns);
7828}
7829
7830/**
7831 * @copydoc PDMDEVHLPR3::pfnIoApicRegister
7832 */
7833DECLINLINE(int) PDMDevHlpIoApicRegister(PPDMDEVINS pDevIns, PPDMIOAPICREG pIoApicReg, PCPDMIOAPICHLP *ppIoApicHlp)
7834{
7835 return pDevIns->pHlpR3->pfnIoApicRegister(pDevIns, pIoApicReg, ppIoApicHlp);
7836}
7837
7838/**
7839 * @copydoc PDMDEVHLPR3::pfnHpetRegister
7840 */
7841DECLINLINE(int) PDMDevHlpHpetRegister(PPDMDEVINS pDevIns, PPDMHPETREG pHpetReg, PCPDMHPETHLPR3 *ppHpetHlpR3)
7842{
7843 return pDevIns->pHlpR3->pfnHpetRegister(pDevIns, pHpetReg, ppHpetHlpR3);
7844}
7845
7846/**
7847 * @copydoc PDMDEVHLPR3::pfnPciRawRegister
7848 */
7849DECLINLINE(int) PDMDevHlpPciRawRegister(PPDMDEVINS pDevIns, PPDMPCIRAWREG pPciRawReg, PCPDMPCIRAWHLPR3 *ppPciRawHlpR3)
7850{
7851 return pDevIns->pHlpR3->pfnPciRawRegister(pDevIns, pPciRawReg, ppPciRawHlpR3);
7852}
7853
7854/**
7855 * @copydoc PDMDEVHLPR3::pfnDMACRegister
7856 */
7857DECLINLINE(int) PDMDevHlpDMACRegister(PPDMDEVINS pDevIns, PPDMDMACREG pDmacReg, PCPDMDMACHLP *ppDmacHlp)
7858{
7859 return pDevIns->pHlpR3->pfnDMACRegister(pDevIns, pDmacReg, ppDmacHlp);
7860}
7861
7862/**
7863 * @copydoc PDMDEVHLPR3::pfnDMARegister
7864 */
7865DECLINLINE(int) PDMDevHlpDMARegister(PPDMDEVINS pDevIns, unsigned uChannel, PFNDMATRANSFERHANDLER pfnTransferHandler, void *pvUser)
7866{
7867 return pDevIns->pHlpR3->pfnDMARegister(pDevIns, uChannel, pfnTransferHandler, pvUser);
7868}
7869
7870/**
7871 * @copydoc PDMDEVHLPR3::pfnDMAReadMemory
7872 */
7873DECLINLINE(int) PDMDevHlpDMAReadMemory(PPDMDEVINS pDevIns, unsigned uChannel, void *pvBuffer, uint32_t off, uint32_t cbBlock, uint32_t *pcbRead)
7874{
7875 return pDevIns->pHlpR3->pfnDMAReadMemory(pDevIns, uChannel, pvBuffer, off, cbBlock, pcbRead);
7876}
7877
7878/**
7879 * @copydoc PDMDEVHLPR3::pfnDMAWriteMemory
7880 */
7881DECLINLINE(int) PDMDevHlpDMAWriteMemory(PPDMDEVINS pDevIns, unsigned uChannel, const void *pvBuffer, uint32_t off, uint32_t cbBlock, uint32_t *pcbWritten)
7882{
7883 return pDevIns->pHlpR3->pfnDMAWriteMemory(pDevIns, uChannel, pvBuffer, off, cbBlock, pcbWritten);
7884}
7885
7886/**
7887 * @copydoc PDMDEVHLPR3::pfnDMASetDREQ
7888 */
7889DECLINLINE(int) PDMDevHlpDMASetDREQ(PPDMDEVINS pDevIns, unsigned uChannel, unsigned uLevel)
7890{
7891 return pDevIns->pHlpR3->pfnDMASetDREQ(pDevIns, uChannel, uLevel);
7892}
7893
7894/**
7895 * @copydoc PDMDEVHLPR3::pfnDMAGetChannelMode
7896 */
7897DECLINLINE(uint8_t) PDMDevHlpDMAGetChannelMode(PPDMDEVINS pDevIns, unsigned uChannel)
7898{
7899 return pDevIns->pHlpR3->pfnDMAGetChannelMode(pDevIns, uChannel);
7900}
7901
7902/**
7903 * @copydoc PDMDEVHLPR3::pfnDMASchedule
7904 */
7905DECLINLINE(void) PDMDevHlpDMASchedule(PPDMDEVINS pDevIns)
7906{
7907 pDevIns->pHlpR3->pfnDMASchedule(pDevIns);
7908}
7909
7910/**
7911 * @copydoc PDMDEVHLPR3::pfnCMOSWrite
7912 */
7913DECLINLINE(int) PDMDevHlpCMOSWrite(PPDMDEVINS pDevIns, unsigned iReg, uint8_t u8Value)
7914{
7915 return pDevIns->pHlpR3->pfnCMOSWrite(pDevIns, iReg, u8Value);
7916}
7917
7918/**
7919 * @copydoc PDMDEVHLPR3::pfnCMOSRead
7920 */
7921DECLINLINE(int) PDMDevHlpCMOSRead(PPDMDEVINS pDevIns, unsigned iReg, uint8_t *pu8Value)
7922{
7923 return pDevIns->pHlpR3->pfnCMOSRead(pDevIns, iReg, pu8Value);
7924}
7925
7926/**
7927 * @copydoc PDMDEVHLPR3::pfnCallR0
7928 */
7929DECLINLINE(int) PDMDevHlpCallR0(PPDMDEVINS pDevIns, uint32_t uOperation, uint64_t u64Arg)
7930{
7931 return pDevIns->pHlpR3->pfnCallR0(pDevIns, uOperation, u64Arg);
7932}
7933
7934/**
7935 * @copydoc PDMDEVHLPR3::pfnVMGetSuspendReason
7936 */
7937DECLINLINE(VMSUSPENDREASON) PDMDevHlpVMGetSuspendReason(PPDMDEVINS pDevIns)
7938{
7939 return pDevIns->pHlpR3->pfnVMGetSuspendReason(pDevIns);
7940}
7941
7942/**
7943 * @copydoc PDMDEVHLPR3::pfnVMGetResumeReason
7944 */
7945DECLINLINE(VMRESUMEREASON) PDMDevHlpVMGetResumeReason(PPDMDEVINS pDevIns)
7946{
7947 return pDevIns->pHlpR3->pfnVMGetResumeReason(pDevIns);
7948}
7949
7950/**
7951 * @copydoc PDMDEVHLPR3::pfnGetUVM
7952 */
7953DECLINLINE(PUVM) PDMDevHlpGetUVM(PPDMDEVINS pDevIns)
7954{
7955 return pDevIns->CTX_SUFF(pHlp)->pfnGetUVM(pDevIns);
7956}
7957
7958#endif /* IN_RING3 || DOXYGEN_RUNNING */
7959
7960#if !defined(IN_RING3) || defined(DOXYGEN_RUNNING)
7961
7962/**
7963 * @copydoc PDMDEVHLPR0::pfnPCIBusSetUpContext
7964 */
7965DECLINLINE(int) PDMDevHlpPCIBusSetUpContext(PPDMDEVINS pDevIns, CTX_SUFF(PPDMPCIBUSREG) pPciBusReg, CTX_SUFF(PCPDMPCIHLP) *ppPciHlp)
7966{
7967 return pDevIns->CTX_SUFF(pHlp)->pfnPCIBusSetUpContext(pDevIns, pPciBusReg, ppPciHlp);
7968}
7969
7970/**
7971 * @copydoc PDMDEVHLPR0::pfnIommuSetUpContext
7972 */
7973DECLINLINE(int) PDMDevHlpIommuSetUpContext(PPDMDEVINS pDevIns, CTX_SUFF(PPDMIOMMUREG) pIommuReg, CTX_SUFF(PCPDMIOMMUHLP) *ppIommuHlp)
7974{
7975 return pDevIns->CTX_SUFF(pHlp)->pfnIommuSetUpContext(pDevIns, pIommuReg, ppIommuHlp);
7976}
7977
7978/**
7979 * @copydoc PDMDEVHLPR0::pfnPICSetUpContext
7980 */
7981DECLINLINE(int) PDMDevHlpPICSetUpContext(PPDMDEVINS pDevIns, PPDMPICREG pPicReg, PCPDMPICHLP *ppPicHlp)
7982{
7983 return pDevIns->CTX_SUFF(pHlp)->pfnPICSetUpContext(pDevIns, pPicReg, ppPicHlp);
7984}
7985
7986/**
7987 * @copydoc PDMDEVHLPR0::pfnApicSetUpContext
7988 */
7989DECLINLINE(int) PDMDevHlpApicSetUpContext(PPDMDEVINS pDevIns)
7990{
7991 return pDevIns->CTX_SUFF(pHlp)->pfnApicSetUpContext(pDevIns);
7992}
7993
7994/**
7995 * @copydoc PDMDEVHLPR0::pfnIoApicSetUpContext
7996 */
7997DECLINLINE(int) PDMDevHlpIoApicSetUpContext(PPDMDEVINS pDevIns, PPDMIOAPICREG pIoApicReg, PCPDMIOAPICHLP *ppIoApicHlp)
7998{
7999 return pDevIns->CTX_SUFF(pHlp)->pfnIoApicSetUpContext(pDevIns, pIoApicReg, ppIoApicHlp);
8000}
8001
8002/**
8003 * @copydoc PDMDEVHLPR0::pfnHpetSetUpContext
8004 */
8005DECLINLINE(int) PDMDevHlpHpetSetUpContext(PPDMDEVINS pDevIns, PPDMHPETREG pHpetReg, CTX_SUFF(PCPDMHPETHLP) *ppHpetHlp)
8006{
8007 return pDevIns->CTX_SUFF(pHlp)->pfnHpetSetUpContext(pDevIns, pHpetReg, ppHpetHlp);
8008}
8009
8010#endif /* !IN_RING3 || DOXYGEN_RUNNING */
8011
8012/**
8013 * @copydoc PDMDEVHLPR3::pfnGetVM
8014 */
8015DECLINLINE(PVMCC) PDMDevHlpGetVM(PPDMDEVINS pDevIns)
8016{
8017 return pDevIns->CTX_SUFF(pHlp)->pfnGetVM(pDevIns);
8018}
8019
8020/**
8021 * @copydoc PDMDEVHLPR3::pfnGetVMCPU
8022 */
8023DECLINLINE(PVMCPUCC) PDMDevHlpGetVMCPU(PPDMDEVINS pDevIns)
8024{
8025 return pDevIns->CTX_SUFF(pHlp)->pfnGetVMCPU(pDevIns);
8026}
8027
8028/**
8029 * @copydoc PDMDEVHLPR3::pfnGetCurrentCpuId
8030 */
8031DECLINLINE(VMCPUID) PDMDevHlpGetCurrentCpuId(PPDMDEVINS pDevIns)
8032{
8033 return pDevIns->CTX_SUFF(pHlp)->pfnGetCurrentCpuId(pDevIns);
8034}
8035
8036/**
8037 * @copydoc PDMDEVHLPR3::pfnTMTimeVirtGet
8038 */
8039DECLINLINE(uint64_t) PDMDevHlpTMTimeVirtGet(PPDMDEVINS pDevIns)
8040{
8041 return pDevIns->CTX_SUFF(pHlp)->pfnTMTimeVirtGet(pDevIns);
8042}
8043
8044/**
8045 * @copydoc PDMDEVHLPR3::pfnTMTimeVirtGetFreq
8046 */
8047DECLINLINE(uint64_t) PDMDevHlpTMTimeVirtGetFreq(PPDMDEVINS pDevIns)
8048{
8049 return pDevIns->CTX_SUFF(pHlp)->pfnTMTimeVirtGetFreq(pDevIns);
8050}
8051
8052/**
8053 * @copydoc PDMDEVHLPR3::pfnTMTimeVirtGetFreq
8054 */
8055DECLINLINE(uint64_t) PDMDevHlpTMTimeVirtGetNano(PPDMDEVINS pDevIns)
8056{
8057 return pDevIns->CTX_SUFF(pHlp)->pfnTMTimeVirtGetNano(pDevIns);
8058}
8059
8060#ifdef IN_RING3
8061
8062/**
8063 * @copydoc PDMDEVHLPR3::pfnRegisterVMMDevHeap
8064 */
8065DECLINLINE(int) PDMDevHlpRegisterVMMDevHeap(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTR3PTR pvHeap, unsigned cbHeap)
8066{
8067 return pDevIns->pHlpR3->pfnRegisterVMMDevHeap(pDevIns, GCPhys, pvHeap, cbHeap);
8068}
8069
8070/**
8071 * @copydoc PDMDEVHLPR3::pfnFirmwareRegister
8072 */
8073DECLINLINE(int) PDMDevHlpFirmwareRegister(PPDMDEVINS pDevIns, PCPDMFWREG pFwReg, PCPDMFWHLPR3 *ppFwHlp)
8074{
8075 return pDevIns->pHlpR3->pfnFirmwareRegister(pDevIns, pFwReg, ppFwHlp);
8076}
8077
8078/**
8079 * @copydoc PDMDEVHLPR3::pfnVMReset
8080 */
8081DECLINLINE(int) PDMDevHlpVMReset(PPDMDEVINS pDevIns, uint32_t fFlags)
8082{
8083 return pDevIns->pHlpR3->pfnVMReset(pDevIns, fFlags);
8084}
8085
8086/**
8087 * @copydoc PDMDEVHLPR3::pfnVMSuspend
8088 */
8089DECLINLINE(int) PDMDevHlpVMSuspend(PPDMDEVINS pDevIns)
8090{
8091 return pDevIns->pHlpR3->pfnVMSuspend(pDevIns);
8092}
8093
8094/**
8095 * @copydoc PDMDEVHLPR3::pfnVMSuspendSaveAndPowerOff
8096 */
8097DECLINLINE(int) PDMDevHlpVMSuspendSaveAndPowerOff(PPDMDEVINS pDevIns)
8098{
8099 return pDevIns->pHlpR3->pfnVMSuspendSaveAndPowerOff(pDevIns);
8100}
8101
8102/**
8103 * @copydoc PDMDEVHLPR3::pfnVMPowerOff
8104 */
8105DECLINLINE(int) PDMDevHlpVMPowerOff(PPDMDEVINS pDevIns)
8106{
8107 return pDevIns->pHlpR3->pfnVMPowerOff(pDevIns);
8108}
8109
8110#endif /* IN_RING3 */
8111
8112/**
8113 * @copydoc PDMDEVHLPR3::pfnA20IsEnabled
8114 */
8115DECLINLINE(bool) PDMDevHlpA20IsEnabled(PPDMDEVINS pDevIns)
8116{
8117 return pDevIns->CTX_SUFF(pHlp)->pfnA20IsEnabled(pDevIns);
8118}
8119
8120#ifdef IN_RING3
8121
8122/**
8123 * @copydoc PDMDEVHLPR3::pfnGetCpuId
8124 */
8125DECLINLINE(void) PDMDevHlpGetCpuId(PPDMDEVINS pDevIns, uint32_t iLeaf, uint32_t *pEax, uint32_t *pEbx, uint32_t *pEcx, uint32_t *pEdx)
8126{
8127 pDevIns->pHlpR3->pfnGetCpuId(pDevIns, iLeaf, pEax, pEbx, pEcx, pEdx);
8128}
8129
8130/**
8131 * @copydoc PDMDEVHLPR3::pfnGetSupDrvSession
8132 */
8133DECLINLINE(PSUPDRVSESSION) PDMDevHlpGetSupDrvSession(PPDMDEVINS pDevIns)
8134{
8135 return pDevIns->pHlpR3->pfnGetSupDrvSession(pDevIns);
8136}
8137
8138/**
8139 * @copydoc PDMDEVHLPR3::pfnQueryGenericUserObject
8140 */
8141DECLINLINE(void *) PDMDevHlpQueryGenericUserObject(PPDMDEVINS pDevIns, PCRTUUID pUuid)
8142{
8143 return pDevIns->pHlpR3->pfnQueryGenericUserObject(pDevIns, pUuid);
8144}
8145
8146/**
8147 * @copydoc PDMDEVHLPR3::pfnPGMHandlerPhysicalTypeRegister
8148 */
8149DECLINLINE(int) PDMDevHlpPGMHandlerPhysicalTypeRegister(PPDMDEVINS pDevIns, PGMPHYSHANDLERKIND enmKind,
8150 R3PTRTYPE(PFNPGMPHYSHANDLER) pfnHandlerR3,
8151 const char *pszHandlerR0, const char *pszPfHandlerR0,
8152 const char *pszHandlerRC, const char *pszPfHandlerRC,
8153 const char *pszDesc, PPGMPHYSHANDLERTYPE phType)
8154{
8155 return pDevIns->pHlpR3->pfnPGMHandlerPhysicalTypeRegister(pDevIns, enmKind, pfnHandlerR3,
8156 pszHandlerR0, pszPfHandlerR0,
8157 pszHandlerRC, pszPfHandlerRC,
8158 pszDesc, phType);
8159}
8160
8161/** Wrapper around SSMR3GetU32 for simplifying getting enum values saved as uint32_t. */
8162# define PDMDEVHLP_SSM_GET_ENUM32_RET(a_pHlp, a_pSSM, a_enmDst, a_EnumType) \
8163 do { \
8164 uint32_t u32GetEnumTmp = 0; \
8165 int rcGetEnum32Tmp = (a_pHlp)->pfnSSMGetU32((a_pSSM), &u32GetEnumTmp); \
8166 AssertRCReturn(rcGetEnum32Tmp, rcGetEnum32Tmp); \
8167 (a_enmDst) = (a_EnumType)u32GetEnumTmp; \
8168 AssertCompile(sizeof(a_EnumType) == sizeof(u32GetEnumTmp)); \
8169 } while (0)
8170
8171/** Wrapper around SSMR3GetU8 for simplifying getting enum values saved as uint8_t. */
8172# define PDMDEVHLP_SSM_GET_ENUM8_RET(a_pHlp, a_pSSM, a_enmDst, a_EnumType) \
8173 do { \
8174 uint8_t bGetEnumTmp = 0; \
8175 int rcGetEnum32Tmp = (a_pHlp)->pfnSSMGetU8((a_pSSM), &bGetEnumTmp); \
8176 AssertRCReturn(rcGetEnum32Tmp, rcGetEnum32Tmp); \
8177 (a_enmDst) = (a_EnumType)bGetEnumTmp; \
8178 } while (0)
8179
8180#endif /* IN_RING3 */
8181
8182/** Pointer to callbacks provided to the VBoxDeviceRegister() call. */
8183typedef struct PDMDEVREGCB *PPDMDEVREGCB;
8184
8185/**
8186 * Callbacks for VBoxDeviceRegister().
8187 */
8188typedef struct PDMDEVREGCB
8189{
8190 /** Interface version.
8191 * This is set to PDM_DEVREG_CB_VERSION. */
8192 uint32_t u32Version;
8193
8194 /**
8195 * Registers a device with the current VM instance.
8196 *
8197 * @returns VBox status code.
8198 * @param pCallbacks Pointer to the callback table.
8199 * @param pReg Pointer to the device registration record.
8200 * This data must be permanent and readonly.
8201 */
8202 DECLR3CALLBACKMEMBER(int, pfnRegister,(PPDMDEVREGCB pCallbacks, PCPDMDEVREG pReg));
8203} PDMDEVREGCB;
8204
8205/** Current version of the PDMDEVREGCB structure. */
8206#define PDM_DEVREG_CB_VERSION PDM_VERSION_MAKE(0xffe3, 1, 0)
8207
8208
8209/**
8210 * The VBoxDevicesRegister callback function.
8211 *
8212 * PDM will invoke this function after loading a device module and letting
8213 * the module decide which devices to register and how to handle conflicts.
8214 *
8215 * @returns VBox status code.
8216 * @param pCallbacks Pointer to the callback table.
8217 * @param u32Version VBox version number.
8218 */
8219typedef DECLCALLBACK(int) FNPDMVBOXDEVICESREGISTER(PPDMDEVREGCB pCallbacks, uint32_t u32Version);
8220
8221/** @} */
8222
8223RT_C_DECLS_END
8224
8225#endif /* !VBOX_INCLUDED_vmm_pdmdev_h */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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