VirtualBox

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

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

PDMDevHlp: Adding SSMR3HandleHostOSAndArch. bugref:9218

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

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