VirtualBox

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

Last change on this file since 83109 was 82968, checked in by vboxsync, 5 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 313.6 KB
Line 
1/** @file
2 * PDM - Pluggable Device Manager, Devices.
3 */
4
5/*
6 * Copyright (C) 2006-2020 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef VBOX_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, 5, 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 * Acquires the PDM lock.
1208 *
1209 * @returns VINF_SUCCESS on success.
1210 * @returns Fatal error on failure.
1211 * @param pDevIns The PCI device instance.
1212 * @param rc Dummy for making the interface identical to the RC and R0 versions.
1213 */
1214 DECLR3CALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
1215
1216 /**
1217 * Releases the PDM lock.
1218 *
1219 * @param pDevIns The PCI device instance.
1220 */
1221 DECLR3CALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
1222
1223 /**
1224 * Gets a bus by it's PDM ordinal (typically the parent bus).
1225 *
1226 * @returns Pointer to the device instance of the bus.
1227 * @param pDevIns The PCI bus device instance.
1228 * @param idxPdmBus The PDM ordinal value of the bus to get.
1229 */
1230 DECLR3CALLBACKMEMBER(PPDMDEVINS, pfnGetBusByNo,(PPDMDEVINS pDevIns, uint32_t idxPdmBus));
1231
1232 /** Just a safety precaution. */
1233 uint32_t u32TheEnd;
1234} PDMPCIHLPR3;
1235/** Pointer to PCI helpers. */
1236typedef R3PTRTYPE(PDMPCIHLPR3 *) PPDMPCIHLPR3;
1237/** Pointer to const PCI helpers. */
1238typedef R3PTRTYPE(const PDMPCIHLPR3 *) PCPDMPCIHLPR3;
1239
1240/** Current PDMPCIHLPR3 version number. */
1241#define PDM_PCIHLPR3_VERSION PDM_VERSION_MAKE(0xfffb, 4, 0)
1242
1243
1244/**
1245 * Programmable Interrupt Controller registration structure (all contexts).
1246 */
1247typedef struct PDMPICREG
1248{
1249 /** Structure version number. PDM_PICREG_VERSION defines the current version. */
1250 uint32_t u32Version;
1251
1252 /**
1253 * Set the an IRQ.
1254 *
1255 * @param pDevIns Device instance of the PIC.
1256 * @param iIrq IRQ number to set.
1257 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
1258 * @param uTagSrc The IRQ tag and source (for tracing).
1259 * @remarks Caller enters the PDM critical section.
1260 */
1261 DECLCALLBACKMEMBER(void, pfnSetIrq)(PPDMDEVINS pDevIns, int iIrq, int iLevel, uint32_t uTagSrc);
1262
1263 /**
1264 * Get a pending interrupt.
1265 *
1266 * @returns Pending interrupt number.
1267 * @param pDevIns Device instance of the PIC.
1268 * @param puTagSrc Where to return the IRQ tag and source.
1269 * @remarks Caller enters the PDM critical section.
1270 */
1271 DECLCALLBACKMEMBER(int, pfnGetInterrupt)(PPDMDEVINS pDevIns, uint32_t *puTagSrc);
1272
1273 /** Just a safety precaution. */
1274 uint32_t u32TheEnd;
1275} PDMPICREG;
1276/** Pointer to a PIC registration structure. */
1277typedef PDMPICREG *PPDMPICREG;
1278
1279/** Current PDMPICREG version number. */
1280#define PDM_PICREG_VERSION PDM_VERSION_MAKE(0xfffa, 3, 0)
1281
1282/**
1283 * PIC helpers, same in all contexts.
1284 */
1285typedef struct PDMPICHLP
1286{
1287 /** Structure version. PDM_PICHLP_VERSION defines the current version. */
1288 uint32_t u32Version;
1289
1290 /**
1291 * Set the interrupt force action flag.
1292 *
1293 * @param pDevIns Device instance of the PIC.
1294 */
1295 DECLCALLBACKMEMBER(void, pfnSetInterruptFF)(PPDMDEVINS pDevIns);
1296
1297 /**
1298 * Clear the interrupt force action flag.
1299 *
1300 * @param pDevIns Device instance of the PIC.
1301 */
1302 DECLCALLBACKMEMBER(void, pfnClearInterruptFF)(PPDMDEVINS pDevIns);
1303
1304 /**
1305 * Acquires the PDM lock.
1306 *
1307 * @returns VINF_SUCCESS on success.
1308 * @returns rc if we failed to acquire the lock.
1309 * @param pDevIns The PIC device instance.
1310 * @param rc What to return if we fail to acquire the lock.
1311 */
1312 DECLCALLBACKMEMBER(int, pfnLock)(PPDMDEVINS pDevIns, int rc);
1313
1314 /**
1315 * Releases the PDM lock.
1316 *
1317 * @param pDevIns The PIC device instance.
1318 */
1319 DECLCALLBACKMEMBER(void, pfnUnlock)(PPDMDEVINS pDevIns);
1320
1321 /** Just a safety precaution. */
1322 uint32_t u32TheEnd;
1323} PDMPICHLP;
1324/** Pointer to PIC helpers. */
1325typedef PDMPICHLP *PPDMPICHLP;
1326/** Pointer to const PIC helpers. */
1327typedef const PDMPICHLP *PCPDMPICHLP;
1328
1329/** Current PDMPICHLP version number. */
1330#define PDM_PICHLP_VERSION PDM_VERSION_MAKE(0xfff9, 3, 0)
1331
1332
1333/**
1334 * Firmware registration structure.
1335 */
1336typedef struct PDMFWREG
1337{
1338 /** Struct version+magic number (PDM_FWREG_VERSION). */
1339 uint32_t u32Version;
1340
1341 /**
1342 * Checks whether this is a hard or soft reset.
1343 *
1344 * The current definition of soft reset is what the PC BIOS does when CMOS[0xF]
1345 * is 5, 9 or 0xA.
1346 *
1347 * @returns true if hard reset, false if soft.
1348 * @param pDevIns Device instance of the firmware.
1349 * @param fFlags PDMRESET_F_XXX passed to the PDMDevHlpVMReset API.
1350 */
1351 DECLR3CALLBACKMEMBER(bool, pfnIsHardReset,(PPDMDEVINS pDevIns, uint32_t fFlags));
1352
1353 /** Just a safety precaution. */
1354 uint32_t u32TheEnd;
1355} PDMFWREG;
1356/** Pointer to a FW registration structure. */
1357typedef PDMFWREG *PPDMFWREG;
1358/** Pointer to a const FW registration structure. */
1359typedef PDMFWREG const *PCPDMFWREG;
1360
1361/** Current PDMFWREG version number. */
1362#define PDM_FWREG_VERSION PDM_VERSION_MAKE(0xffdd, 1, 0)
1363
1364/**
1365 * Firmware R3 helpers.
1366 */
1367typedef struct PDMFWHLPR3
1368{
1369 /** Structure version. PDM_FWHLP_VERSION defines the current version. */
1370 uint32_t u32Version;
1371
1372 /** Just a safety precaution. */
1373 uint32_t u32TheEnd;
1374} PDMFWHLPR3;
1375
1376/** Pointer to FW R3 helpers. */
1377typedef R3PTRTYPE(PDMFWHLPR3 *) PPDMFWHLPR3;
1378/** Pointer to const FW R3 helpers. */
1379typedef R3PTRTYPE(const PDMFWHLPR3 *) PCPDMFWHLPR3;
1380
1381/** Current PDMFWHLPR3 version number. */
1382#define PDM_FWHLPR3_VERSION PDM_VERSION_MAKE(0xffdb, 1, 0)
1383
1384
1385/**
1386 * APIC mode argument for apicR3SetCpuIdFeatureLevel.
1387 *
1388 * Also used in saved-states, CFGM don't change existing values.
1389 */
1390typedef enum PDMAPICMODE
1391{
1392 /** Invalid 0 entry. */
1393 PDMAPICMODE_INVALID = 0,
1394 /** No APIC. */
1395 PDMAPICMODE_NONE,
1396 /** Standard APIC (X86_CPUID_FEATURE_EDX_APIC). */
1397 PDMAPICMODE_APIC,
1398 /** Intel X2APIC (X86_CPUID_FEATURE_ECX_X2APIC). */
1399 PDMAPICMODE_X2APIC,
1400 /** The usual 32-bit paranoia. */
1401 PDMAPICMODE_32BIT_HACK = 0x7fffffff
1402} PDMAPICMODE;
1403
1404/**
1405 * APIC irq argument for pfnSetInterruptFF and pfnClearInterruptFF.
1406 */
1407typedef enum PDMAPICIRQ
1408{
1409 /** Invalid 0 entry. */
1410 PDMAPICIRQ_INVALID = 0,
1411 /** Normal hardware interrupt. */
1412 PDMAPICIRQ_HARDWARE,
1413 /** NMI. */
1414 PDMAPICIRQ_NMI,
1415 /** SMI. */
1416 PDMAPICIRQ_SMI,
1417 /** ExtINT (HW interrupt via PIC). */
1418 PDMAPICIRQ_EXTINT,
1419 /** Interrupt arrived, needs to be updated to the IRR. */
1420 PDMAPICIRQ_UPDATE_PENDING,
1421 /** The usual 32-bit paranoia. */
1422 PDMAPICIRQ_32BIT_HACK = 0x7fffffff
1423} PDMAPICIRQ;
1424
1425
1426/**
1427 * I/O APIC registration structure (all contexts).
1428 */
1429typedef struct PDMIOAPICREG
1430{
1431 /** Struct version+magic number (PDM_IOAPICREG_VERSION). */
1432 uint32_t u32Version;
1433
1434 /**
1435 * Set an IRQ.
1436 *
1437 * @param pDevIns Device instance of the I/O APIC.
1438 * @param iIrq IRQ number to set.
1439 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
1440 * @param uTagSrc The IRQ tag and source (for tracing).
1441 *
1442 * @remarks Caller enters the PDM critical section
1443 * Actually, as per 2018-07-21 this isn't true (bird).
1444 */
1445 DECLCALLBACKMEMBER(void, pfnSetIrq)(PPDMDEVINS pDevIns, int iIrq, int iLevel, uint32_t uTagSrc);
1446
1447 /**
1448 * Send a MSI.
1449 *
1450 * @param pDevIns Device instance of the I/O APIC.
1451 * @param GCPhys Request address.
1452 * @param uValue Request value.
1453 * @param uTagSrc The IRQ tag and source (for tracing).
1454 *
1455 * @remarks Caller enters the PDM critical section
1456 * Actually, as per 2018-07-21 this isn't true (bird).
1457 */
1458 DECLCALLBACKMEMBER(void, pfnSendMsi)(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, uint32_t uValue, uint32_t uTagSrc);
1459
1460 /**
1461 * Set the EOI for an interrupt vector.
1462 *
1463 * @returns Strict VBox status code - only the following informational status codes:
1464 * @retval VINF_IOM_R3_MMIO_WRITE if the I/O APIC lock is contenteded and we're in R0 or RC.
1465 * @retval VINF_SUCCESS
1466 *
1467 * @param pDevIns Device instance of the I/O APIC.
1468 * @param u8Vector The vector.
1469 *
1470 * @remarks Caller enters the PDM critical section
1471 * Actually, as per 2018-07-21 this isn't true (bird).
1472 */
1473 DECLCALLBACKMEMBER(VBOXSTRICTRC, pfnSetEoi)(PPDMDEVINS pDevIns, uint8_t u8Vector);
1474
1475 /** Just a safety precaution. */
1476 uint32_t u32TheEnd;
1477} PDMIOAPICREG;
1478/** Pointer to an APIC registration structure. */
1479typedef PDMIOAPICREG *PPDMIOAPICREG;
1480
1481/** Current PDMAPICREG version number. */
1482#define PDM_IOAPICREG_VERSION PDM_VERSION_MAKE(0xfff2, 6, 0)
1483
1484
1485/**
1486 * IOAPIC helpers, same in all contexts.
1487 */
1488typedef struct PDMIOAPICHLP
1489{
1490 /** Structure version. PDM_IOAPICHLP_VERSION defines the current version. */
1491 uint32_t u32Version;
1492
1493 /**
1494 * Private interface between the IOAPIC and APIC.
1495 *
1496 * @returns status code.
1497 * @param pDevIns Device instance of the IOAPIC.
1498 * @param u8Dest See APIC implementation.
1499 * @param u8DestMode See APIC implementation.
1500 * @param u8DeliveryMode See APIC implementation.
1501 * @param uVector See APIC implementation.
1502 * @param u8Polarity See APIC implementation.
1503 * @param u8TriggerMode See APIC implementation.
1504 * @param uTagSrc The IRQ tag and source (for tracing).
1505 *
1506 * @sa APICBusDeliver()
1507 */
1508 DECLCALLBACKMEMBER(int, pfnApicBusDeliver)(PPDMDEVINS pDevIns, uint8_t u8Dest, uint8_t u8DestMode, uint8_t u8DeliveryMode,
1509 uint8_t uVector, uint8_t u8Polarity, uint8_t u8TriggerMode, uint32_t uTagSrc);
1510
1511 /**
1512 * Acquires the PDM lock.
1513 *
1514 * @returns VINF_SUCCESS on success.
1515 * @returns rc if we failed to acquire the lock.
1516 * @param pDevIns The IOAPIC device instance.
1517 * @param rc What to return if we fail to acquire the lock.
1518 */
1519 DECLCALLBACKMEMBER(int, pfnLock)(PPDMDEVINS pDevIns, int rc);
1520
1521 /**
1522 * Releases the PDM lock.
1523 *
1524 * @param pDevIns The IOAPIC device instance.
1525 */
1526 DECLCALLBACKMEMBER(void, pfnUnlock)(PPDMDEVINS pDevIns);
1527
1528 /** Just a safety precaution. */
1529 uint32_t u32TheEnd;
1530} PDMIOAPICHLP;
1531/** Pointer to IOAPIC helpers. */
1532typedef PDMIOAPICHLP * PPDMIOAPICHLP;
1533/** Pointer to const IOAPIC helpers. */
1534typedef const PDMIOAPICHLP * PCPDMIOAPICHLP;
1535
1536/** Current PDMIOAPICHLP version number. */
1537#define PDM_IOAPICHLP_VERSION PDM_VERSION_MAKE(0xfff0, 2, 0)
1538
1539
1540/**
1541 * HPET registration structure.
1542 */
1543typedef struct PDMHPETREG
1544{
1545 /** Struct version+magic number (PDM_HPETREG_VERSION). */
1546 uint32_t u32Version;
1547} PDMHPETREG;
1548/** Pointer to an HPET registration structure. */
1549typedef PDMHPETREG *PPDMHPETREG;
1550
1551/** Current PDMHPETREG version number. */
1552#define PDM_HPETREG_VERSION PDM_VERSION_MAKE(0xffe2, 1, 0)
1553
1554/**
1555 * HPET RC helpers.
1556 *
1557 * @remarks Keep this around in case HPET will need PDM interaction in again RC
1558 * at some later point.
1559 */
1560typedef struct PDMHPETHLPRC
1561{
1562 /** Structure version. PDM_HPETHLPRC_VERSION defines the current version. */
1563 uint32_t u32Version;
1564
1565 /** Just a safety precaution. */
1566 uint32_t u32TheEnd;
1567} PDMHPETHLPRC;
1568
1569/** Pointer to HPET RC helpers. */
1570typedef RCPTRTYPE(PDMHPETHLPRC *) PPDMHPETHLPRC;
1571/** Pointer to const HPET RC helpers. */
1572typedef RCPTRTYPE(const PDMHPETHLPRC *) PCPDMHPETHLPRC;
1573
1574/** Current PDMHPETHLPRC version number. */
1575#define PDM_HPETHLPRC_VERSION PDM_VERSION_MAKE(0xffee, 2, 0)
1576
1577
1578/**
1579 * HPET R0 helpers.
1580 *
1581 * @remarks Keep this around in case HPET will need PDM interaction in again R0
1582 * at some later point.
1583 */
1584typedef struct PDMHPETHLPR0
1585{
1586 /** Structure version. PDM_HPETHLPR0_VERSION defines the current version. */
1587 uint32_t u32Version;
1588
1589 /** Just a safety precaution. */
1590 uint32_t u32TheEnd;
1591} PDMHPETHLPR0;
1592
1593/** Pointer to HPET R0 helpers. */
1594typedef R0PTRTYPE(PDMHPETHLPR0 *) PPDMHPETHLPR0;
1595/** Pointer to const HPET R0 helpers. */
1596typedef R0PTRTYPE(const PDMHPETHLPR0 *) PCPDMHPETHLPR0;
1597
1598/** Current PDMHPETHLPR0 version number. */
1599#define PDM_HPETHLPR0_VERSION PDM_VERSION_MAKE(0xffed, 2, 0)
1600
1601/**
1602 * HPET R3 helpers.
1603 */
1604typedef struct PDMHPETHLPR3
1605{
1606 /** Structure version. PDM_HPETHLP_VERSION defines the current version. */
1607 uint32_t u32Version;
1608
1609 /**
1610 * Set legacy mode on PIT and RTC.
1611 *
1612 * @returns VINF_SUCCESS on success.
1613 * @returns rc if we failed to set legacy mode.
1614 * @param pDevIns Device instance of the HPET.
1615 * @param fActivated Whether legacy mode is activated or deactivated.
1616 */
1617 DECLR3CALLBACKMEMBER(int, pfnSetLegacyMode,(PPDMDEVINS pDevIns, bool fActivated));
1618
1619
1620 /**
1621 * Set IRQ, bypassing ISA bus override rules.
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 iIrq IRQ number to set.
1627 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
1628 */
1629 DECLR3CALLBACKMEMBER(int, pfnSetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
1630
1631 /** Just a safety precaution. */
1632 uint32_t u32TheEnd;
1633} PDMHPETHLPR3;
1634
1635/** Pointer to HPET R3 helpers. */
1636typedef R3PTRTYPE(PDMHPETHLPR3 *) PPDMHPETHLPR3;
1637/** Pointer to const HPET R3 helpers. */
1638typedef R3PTRTYPE(const PDMHPETHLPR3 *) PCPDMHPETHLPR3;
1639
1640/** Current PDMHPETHLPR3 version number. */
1641#define PDM_HPETHLPR3_VERSION PDM_VERSION_MAKE(0xffec, 3, 0)
1642
1643
1644/**
1645 * Raw PCI device registration structure.
1646 */
1647typedef struct PDMPCIRAWREG
1648{
1649 /** Struct version+magic number (PDM_PCIRAWREG_VERSION). */
1650 uint32_t u32Version;
1651 /** Just a safety precaution. */
1652 uint32_t u32TheEnd;
1653} PDMPCIRAWREG;
1654/** Pointer to a raw PCI registration structure. */
1655typedef PDMPCIRAWREG *PPDMPCIRAWREG;
1656
1657/** Current PDMPCIRAWREG version number. */
1658#define PDM_PCIRAWREG_VERSION PDM_VERSION_MAKE(0xffe1, 1, 0)
1659
1660/**
1661 * Raw PCI device raw-mode context helpers.
1662 */
1663typedef struct PDMPCIRAWHLPRC
1664{
1665 /** Structure version and magic number (PDM_PCIRAWHLPRC_VERSION). */
1666 uint32_t u32Version;
1667 /** Just a safety precaution. */
1668 uint32_t u32TheEnd;
1669} PDMPCIRAWHLPRC;
1670/** Pointer to a raw PCI deviec raw-mode context helper structure. */
1671typedef RCPTRTYPE(PDMPCIRAWHLPRC *) PPDMPCIRAWHLPRC;
1672/** Pointer to a const raw PCI deviec raw-mode context helper structure. */
1673typedef RCPTRTYPE(const PDMPCIRAWHLPRC *) PCPDMPCIRAWHLPRC;
1674
1675/** Current PDMPCIRAWHLPRC version number. */
1676#define PDM_PCIRAWHLPRC_VERSION PDM_VERSION_MAKE(0xffe0, 1, 0)
1677
1678/**
1679 * Raw PCI device ring-0 context helpers.
1680 */
1681typedef struct PDMPCIRAWHLPR0
1682{
1683 /** Structure version and magic number (PDM_PCIRAWHLPR0_VERSION). */
1684 uint32_t u32Version;
1685 /** Just a safety precaution. */
1686 uint32_t u32TheEnd;
1687} PDMPCIRAWHLPR0;
1688/** Pointer to a raw PCI deviec ring-0 context helper structure. */
1689typedef R0PTRTYPE(PDMPCIRAWHLPR0 *) PPDMPCIRAWHLPR0;
1690/** Pointer to a const raw PCI deviec ring-0 context helper structure. */
1691typedef R0PTRTYPE(const PDMPCIRAWHLPR0 *) PCPDMPCIRAWHLPR0;
1692
1693/** Current PDMPCIRAWHLPR0 version number. */
1694#define PDM_PCIRAWHLPR0_VERSION PDM_VERSION_MAKE(0xffdf, 1, 0)
1695
1696
1697/**
1698 * Raw PCI device ring-3 context helpers.
1699 */
1700typedef struct PDMPCIRAWHLPR3
1701{
1702 /** Undefined structure version and magic number. */
1703 uint32_t u32Version;
1704
1705 /**
1706 * Gets the address of the RC raw PCI device helpers.
1707 *
1708 * This should be called at both construction and relocation time to obtain
1709 * the correct address of the RC helpers.
1710 *
1711 * @returns RC pointer to the raw PCI device helpers.
1712 * @param pDevIns Device instance of the raw PCI device.
1713 */
1714 DECLR3CALLBACKMEMBER(PCPDMPCIRAWHLPRC, pfnGetRCHelpers,(PPDMDEVINS pDevIns));
1715
1716 /**
1717 * Gets the address of the R0 raw PCI device helpers.
1718 *
1719 * This should be called at both construction and relocation time to obtain
1720 * the correct address of the R0 helpers.
1721 *
1722 * @returns R0 pointer to the raw PCI device helpers.
1723 * @param pDevIns Device instance of the raw PCI device.
1724 */
1725 DECLR3CALLBACKMEMBER(PCPDMPCIRAWHLPR0, pfnGetR0Helpers,(PPDMDEVINS pDevIns));
1726
1727 /** Just a safety precaution. */
1728 uint32_t u32TheEnd;
1729} PDMPCIRAWHLPR3;
1730/** Pointer to raw PCI R3 helpers. */
1731typedef R3PTRTYPE(PDMPCIRAWHLPR3 *) PPDMPCIRAWHLPR3;
1732/** Pointer to const raw PCI R3 helpers. */
1733typedef R3PTRTYPE(const PDMPCIRAWHLPR3 *) PCPDMPCIRAWHLPR3;
1734
1735/** Current PDMPCIRAWHLPR3 version number. */
1736#define PDM_PCIRAWHLPR3_VERSION PDM_VERSION_MAKE(0xffde, 1, 0)
1737
1738
1739#ifdef IN_RING3
1740
1741/**
1742 * DMA Transfer Handler.
1743 *
1744 * @returns Number of bytes transferred.
1745 * @param pDevIns Device instance of the DMA.
1746 * @param pvUser User pointer.
1747 * @param uChannel Channel number.
1748 * @param off DMA position.
1749 * @param cb Block size.
1750 * @remarks The device lock is not taken, however, the DMA device lock is held.
1751 */
1752typedef DECLCALLBACK(uint32_t) FNDMATRANSFERHANDLER(PPDMDEVINS pDevIns, void *pvUser, unsigned uChannel, uint32_t off, uint32_t cb);
1753/** Pointer to a FNDMATRANSFERHANDLER(). */
1754typedef FNDMATRANSFERHANDLER *PFNDMATRANSFERHANDLER;
1755
1756/**
1757 * DMA Controller registration structure.
1758 */
1759typedef struct PDMDMAREG
1760{
1761 /** Structure version number. PDM_DMACREG_VERSION defines the current version. */
1762 uint32_t u32Version;
1763
1764 /**
1765 * Execute pending transfers.
1766 *
1767 * @returns A more work indiciator. I.e. 'true' if there is more to be done, and 'false' if all is done.
1768 * @param pDevIns Device instance of the DMAC.
1769 * @remarks No locks held, called on EMT(0) as a form of serialization.
1770 */
1771 DECLR3CALLBACKMEMBER(bool, pfnRun,(PPDMDEVINS pDevIns));
1772
1773 /**
1774 * Register transfer function for DMA channel.
1775 *
1776 * @param pDevIns Device instance of the DMAC.
1777 * @param uChannel Channel number.
1778 * @param pfnTransferHandler Device specific transfer function.
1779 * @param pvUser User pointer to be passed to the callback.
1780 * @remarks No locks held, called on an EMT.
1781 */
1782 DECLR3CALLBACKMEMBER(void, pfnRegister,(PPDMDEVINS pDevIns, unsigned uChannel, PFNDMATRANSFERHANDLER pfnTransferHandler, void *pvUser));
1783
1784 /**
1785 * Read memory
1786 *
1787 * @returns Number of bytes read.
1788 * @param pDevIns Device instance of the DMAC.
1789 * @param uChannel Channel number.
1790 * @param pvBuffer Pointer to target buffer.
1791 * @param off DMA position.
1792 * @param cbBlock Block size.
1793 * @remarks No locks held, called on an EMT.
1794 */
1795 DECLR3CALLBACKMEMBER(uint32_t, pfnReadMemory,(PPDMDEVINS pDevIns, unsigned uChannel, void *pvBuffer, uint32_t off, uint32_t cbBlock));
1796
1797 /**
1798 * Write memory
1799 *
1800 * @returns Number of bytes written.
1801 * @param pDevIns Device instance of the DMAC.
1802 * @param uChannel Channel number.
1803 * @param pvBuffer Memory to write.
1804 * @param off DMA position.
1805 * @param cbBlock Block size.
1806 * @remarks No locks held, called on an EMT.
1807 */
1808 DECLR3CALLBACKMEMBER(uint32_t, pfnWriteMemory,(PPDMDEVINS pDevIns, unsigned uChannel, const void *pvBuffer, uint32_t off, uint32_t cbBlock));
1809
1810 /**
1811 * Set the DREQ line.
1812 *
1813 * @param pDevIns Device instance of the DMAC.
1814 * @param uChannel Channel number.
1815 * @param uLevel Level of the line.
1816 * @remarks No locks held, called on an EMT.
1817 */
1818 DECLR3CALLBACKMEMBER(void, pfnSetDREQ,(PPDMDEVINS pDevIns, unsigned uChannel, unsigned uLevel));
1819
1820 /**
1821 * Get channel mode
1822 *
1823 * @returns Channel mode.
1824 * @param pDevIns Device instance of the DMAC.
1825 * @param uChannel Channel number.
1826 * @remarks No locks held, called on an EMT.
1827 */
1828 DECLR3CALLBACKMEMBER(uint8_t, pfnGetChannelMode,(PPDMDEVINS pDevIns, unsigned uChannel));
1829
1830} PDMDMACREG;
1831/** Pointer to a DMAC registration structure. */
1832typedef PDMDMACREG *PPDMDMACREG;
1833
1834/** Current PDMDMACREG version number. */
1835#define PDM_DMACREG_VERSION PDM_VERSION_MAKE(0xffeb, 1, 0)
1836
1837
1838/**
1839 * DMA Controller device helpers.
1840 */
1841typedef struct PDMDMACHLP
1842{
1843 /** Structure version. PDM_DMACHLP_VERSION defines the current version. */
1844 uint32_t u32Version;
1845
1846 /* to-be-defined */
1847
1848} PDMDMACHLP;
1849/** Pointer to DMAC helpers. */
1850typedef PDMDMACHLP *PPDMDMACHLP;
1851/** Pointer to const DMAC helpers. */
1852typedef const PDMDMACHLP *PCPDMDMACHLP;
1853
1854/** Current PDMDMACHLP version number. */
1855#define PDM_DMACHLP_VERSION PDM_VERSION_MAKE(0xffea, 1, 0)
1856
1857#endif /* IN_RING3 */
1858
1859
1860
1861/**
1862 * RTC registration structure.
1863 */
1864typedef struct PDMRTCREG
1865{
1866 /** Structure version number. PDM_RTCREG_VERSION defines the current version. */
1867 uint32_t u32Version;
1868 uint32_t u32Alignment; /**< structure size alignment. */
1869
1870 /**
1871 * Write to a CMOS register and update the checksum if necessary.
1872 *
1873 * @returns VBox status code.
1874 * @param pDevIns Device instance of the RTC.
1875 * @param iReg The CMOS register index.
1876 * @param u8Value The CMOS register value.
1877 * @remarks Caller enters the device critical section.
1878 */
1879 DECLR3CALLBACKMEMBER(int, pfnWrite,(PPDMDEVINS pDevIns, unsigned iReg, uint8_t u8Value));
1880
1881 /**
1882 * Read a CMOS register.
1883 *
1884 * @returns VBox status code.
1885 * @param pDevIns Device instance of the RTC.
1886 * @param iReg The CMOS register index.
1887 * @param pu8Value Where to store the CMOS register value.
1888 * @remarks Caller enters the device critical section.
1889 */
1890 DECLR3CALLBACKMEMBER(int, pfnRead,(PPDMDEVINS pDevIns, unsigned iReg, uint8_t *pu8Value));
1891
1892} PDMRTCREG;
1893/** Pointer to a RTC registration structure. */
1894typedef PDMRTCREG *PPDMRTCREG;
1895/** Pointer to a const RTC registration structure. */
1896typedef const PDMRTCREG *PCPDMRTCREG;
1897
1898/** Current PDMRTCREG version number. */
1899#define PDM_RTCREG_VERSION PDM_VERSION_MAKE(0xffe9, 2, 0)
1900
1901
1902/**
1903 * RTC device helpers.
1904 */
1905typedef struct PDMRTCHLP
1906{
1907 /** Structure version. PDM_RTCHLP_VERSION defines the current version. */
1908 uint32_t u32Version;
1909
1910 /* to-be-defined */
1911
1912} PDMRTCHLP;
1913/** Pointer to RTC helpers. */
1914typedef PDMRTCHLP *PPDMRTCHLP;
1915/** Pointer to const RTC helpers. */
1916typedef const PDMRTCHLP *PCPDMRTCHLP;
1917
1918/** Current PDMRTCHLP version number. */
1919#define PDM_RTCHLP_VERSION PDM_VERSION_MAKE(0xffe8, 1, 0)
1920
1921
1922
1923/** @name Flags for PCI I/O region registration
1924 * @{ */
1925/** No handle is passed. */
1926#define PDMPCIDEV_IORGN_F_NO_HANDLE UINT32_C(0x00000000)
1927/** An I/O port handle is passed. */
1928#define PDMPCIDEV_IORGN_F_IOPORT_HANDLE UINT32_C(0x00000001)
1929/** An MMIO range handle is passed. */
1930#define PDMPCIDEV_IORGN_F_MMIO_HANDLE UINT32_C(0x00000002)
1931/** An MMIO2 handle is passed. */
1932#define PDMPCIDEV_IORGN_F_MMIO2_HANDLE UINT32_C(0x00000003)
1933/** Handle type mask. */
1934#define PDMPCIDEV_IORGN_F_HANDLE_MASK UINT32_C(0x00000003)
1935/** New-style (mostly wrt callbacks). */
1936#define PDMPCIDEV_IORGN_F_NEW_STYLE UINT32_C(0x00000004)
1937/** Mask of valid flags. */
1938#define PDMPCIDEV_IORGN_F_VALID_MASK UINT32_C(0x00000007)
1939/** @} */
1940
1941
1942#ifdef IN_RING3
1943
1944/** @name Special values for PDMDEVHLPR3::pfnPCIRegister parameters.
1945 * @{ */
1946/** Same device number (and bus) as the previous PCI device registered with the PDM device.
1947 * This is handy when registering multiple PCI device functions and the device
1948 * number is left up to the PCI bus. In order to facilitate one PDM device
1949 * instance for each PCI function, this searches earlier PDM device
1950 * instances as well. */
1951# define PDMPCIDEVREG_DEV_NO_SAME_AS_PREV UINT8_C(0xfd)
1952/** Use the first unused device number (all functions must be unused). */
1953# define PDMPCIDEVREG_DEV_NO_FIRST_UNUSED UINT8_C(0xfe)
1954/** Use the first unused device function. */
1955# define PDMPCIDEVREG_FUN_NO_FIRST_UNUSED UINT8_C(0xff)
1956
1957/** The device and function numbers are not mandatory, just suggestions. */
1958# define PDMPCIDEVREG_F_NOT_MANDATORY_NO RT_BIT_32(0)
1959/** Registering a PCI bridge device. */
1960# define PDMPCIDEVREG_F_PCI_BRIDGE RT_BIT_32(1)
1961/** Valid flag mask. */
1962# define PDMPCIDEVREG_F_VALID_MASK UINT32_C(0x00000003)
1963/** @} */
1964
1965/** Current PDMDEVHLPR3 version number. */
1966#define PDM_DEVHLPR3_VERSION PDM_VERSION_MAKE_PP(0xffe7, 41, 0)
1967
1968/**
1969 * PDM Device API.
1970 */
1971typedef struct PDMDEVHLPR3
1972{
1973 /** Structure version. PDM_DEVHLPR3_VERSION defines the current version. */
1974 uint32_t u32Version;
1975
1976 /** @name I/O ports
1977 * @{ */
1978 /**
1979 * Creates a range of I/O ports for a device.
1980 *
1981 * The I/O port range must be mapped in a separately call. Any ring-0 and
1982 * raw-mode context callback handlers needs to be set up in the respective
1983 * contexts.
1984 *
1985 * @returns VBox status.
1986 * @param pDevIns The device instance to register the ports with.
1987 * @param cPorts Number of ports to register.
1988 * @param fFlags IOM_IOPORT_F_XXX.
1989 * @param pPciDev The PCI device the range is associated with, if
1990 * applicable.
1991 * @param iPciRegion The PCI device region in the high 16-bit word and
1992 * sub-region in the low 16-bit word. UINT32_MAX if NA.
1993 * @param pfnOut Pointer to function which is gonna handle OUT
1994 * operations. Optional.
1995 * @param pfnIn Pointer to function which is gonna handle IN operations.
1996 * Optional.
1997 * @param pfnOutStr Pointer to function which is gonna handle string OUT
1998 * operations. Optional.
1999 * @param pfnInStr Pointer to function which is gonna handle string IN
2000 * operations. Optional.
2001 * @param pvUser User argument to pass to the callbacks.
2002 * @param pszDesc Pointer to description string. This must not be freed.
2003 * @param paExtDescs Extended per-port descriptions, optional. Partial range
2004 * coverage is allowed. This must not be freed.
2005 * @param phIoPorts Where to return the I/O port range handle.
2006 *
2007 * @remarks Caller enters the device critical section prior to invoking the
2008 * registered callback methods.
2009 *
2010 * @sa PDMDevHlpIoPortSetUpContext, PDMDevHlpIoPortMap,
2011 * PDMDevHlpIoPortUnmap.
2012 */
2013 DECLR3CALLBACKMEMBER(int, pfnIoPortCreateEx,(PPDMDEVINS pDevIns, RTIOPORT cPorts, uint32_t fFlags, PPDMPCIDEV pPciDev,
2014 uint32_t iPciRegion, PFNIOMIOPORTNEWOUT pfnOut, PFNIOMIOPORTNEWIN pfnIn,
2015 PFNIOMIOPORTNEWOUTSTRING pfnOutStr, PFNIOMIOPORTNEWINSTRING pfnInStr, RTR3PTR pvUser,
2016 const char *pszDesc, PCIOMIOPORTDESC paExtDescs, PIOMIOPORTHANDLE phIoPorts));
2017
2018 /**
2019 * Maps an I/O port range.
2020 *
2021 * @returns VBox status.
2022 * @param pDevIns The device instance to register the ports with.
2023 * @param hIoPorts The I/O port range handle.
2024 * @param Port Where to map the range.
2025 * @sa PDMDevHlpIoPortUnmap, PDMDevHlpIoPortSetUpContext,
2026 * PDMDevHlpIoPortCreate, PDMDevHlpIoPortCreateEx.
2027 */
2028 DECLR3CALLBACKMEMBER(int, pfnIoPortMap,(PPDMDEVINS pDevIns, IOMIOPORTHANDLE hIoPorts, RTIOPORT Port));
2029
2030 /**
2031 * Unmaps an I/O port range.
2032 *
2033 * @returns VBox status.
2034 * @param pDevIns The device instance to register the ports with.
2035 * @param hIoPorts The I/O port range handle.
2036 * @sa PDMDevHlpIoPortMap, PDMDevHlpIoPortSetUpContext,
2037 * PDMDevHlpIoPortCreate, PDMDevHlpIoPortCreateEx.
2038 */
2039 DECLR3CALLBACKMEMBER(int, pfnIoPortUnmap,(PPDMDEVINS pDevIns, IOMIOPORTHANDLE hIoPorts));
2040
2041 /**
2042 * Gets the mapping address of the I/O port range @a hIoPorts.
2043 *
2044 * @returns Mapping address (0..65535) or UINT32_MAX if not mapped (or invalid
2045 * parameters).
2046 * @param pDevIns The device instance to register the ports with.
2047 * @param hIoPorts The I/O port range handle.
2048 */
2049 DECLR3CALLBACKMEMBER(uint32_t, pfnIoPortGetMappingAddress,(PPDMDEVINS pDevIns, IOMIOPORTHANDLE hIoPorts));
2050 /** @} */
2051
2052 /** @name MMIO
2053 * @{ */
2054 /**
2055 * Creates a memory mapped I/O (MMIO) region for a device.
2056 *
2057 * The MMIO region must be mapped in a separately call. Any ring-0 and
2058 * raw-mode context callback handlers needs to be set up in the respective
2059 * contexts.
2060 *
2061 * @returns VBox status.
2062 * @param pDevIns The device instance to register the ports with.
2063 * @param cbRegion The size of the region in bytes.
2064 * @param fFlags Flags, IOMMMIO_FLAGS_XXX.
2065 * @param pPciDev The PCI device the range is associated with, if
2066 * applicable.
2067 * @param iPciRegion The PCI device region in the high 16-bit word and
2068 * sub-region in the low 16-bit word. UINT32_MAX if NA.
2069 * @param pfnWrite Pointer to function which is gonna handle Write
2070 * operations.
2071 * @param pfnRead Pointer to function which is gonna handle Read
2072 * operations.
2073 * @param pfnFill Pointer to function which is gonna handle Fill/memset
2074 * operations. (optional)
2075 * @param pvUser User argument to pass to the callbacks.
2076 * @param pszDesc Pointer to description string. This must not be freed.
2077 * @param phRegion Where to return the MMIO region handle.
2078 *
2079 * @remarks Caller enters the device critical section prior to invoking the
2080 * registered callback methods.
2081 *
2082 * @sa PDMDevHlpMmioSetUpContext, PDMDevHlpMmioMap, PDMDevHlpMmioUnmap.
2083 */
2084 DECLR3CALLBACKMEMBER(int, pfnMmioCreateEx,(PPDMDEVINS pDevIns, RTGCPHYS cbRegion,
2085 uint32_t fFlags, PPDMPCIDEV pPciDev, uint32_t iPciRegion,
2086 PFNIOMMMIONEWWRITE pfnWrite, PFNIOMMMIONEWREAD pfnRead, PFNIOMMMIONEWFILL pfnFill,
2087 void *pvUser, const char *pszDesc, PIOMMMIOHANDLE phRegion));
2088
2089 /**
2090 * Maps a memory mapped I/O (MMIO) region (into the guest physical address space).
2091 *
2092 * @returns VBox status.
2093 * @param pDevIns The device instance the region is associated with.
2094 * @param hRegion The MMIO region handle.
2095 * @param GCPhys Where to map the region.
2096 * @note An MMIO range may overlap with base memory if a lot of RAM is
2097 * configured for the VM, in which case we'll drop the base memory
2098 * pages. Presently we will make no attempt to preserve anything that
2099 * happens to be present in the base memory that is replaced, this is
2100 * technically incorrect but it's just not worth the effort to do
2101 * right, at least not at this point.
2102 * @sa PDMDevHlpMmioUnmap, PDMDevHlpMmioCreate, PDMDevHlpMmioCreateEx,
2103 * PDMDevHlpMmioSetUpContext
2104 */
2105 DECLR3CALLBACKMEMBER(int, pfnMmioMap,(PPDMDEVINS pDevIns, IOMMMIOHANDLE hRegion, RTGCPHYS GCPhys));
2106
2107 /**
2108 * Unmaps a memory mapped I/O (MMIO) region.
2109 *
2110 * @returns VBox status.
2111 * @param pDevIns The device instance the region is associated with.
2112 * @param hRegion The MMIO region handle.
2113 * @sa PDMDevHlpMmioMap, PDMDevHlpMmioCreate, PDMDevHlpMmioCreateEx,
2114 * PDMDevHlpMmioSetUpContext
2115 */
2116 DECLR3CALLBACKMEMBER(int, pfnMmioUnmap,(PPDMDEVINS pDevIns, IOMMMIOHANDLE hRegion));
2117
2118 /**
2119 * Reduces the length of a MMIO range.
2120 *
2121 * This is for implementations of PDMPCIDEV::pfnRegionLoadChangeHookR3 and will
2122 * only work during saved state restore. It will not call the PCI bus code, as
2123 * that is expected to restore the saved resource configuration.
2124 *
2125 * It just adjusts the mapping length of the region so that when pfnMmioMap is
2126 * called it will only map @a cbRegion bytes and not the value set during
2127 * registration.
2128 *
2129 * @return VBox status code.
2130 * @param pDevIns The device owning the range.
2131 * @param hRegion The MMIO region handle.
2132 * @param cbRegion The new size, must be smaller.
2133 */
2134 DECLR3CALLBACKMEMBER(int, pfnMmioReduce,(PPDMDEVINS pDevIns, IOMMMIOHANDLE hRegion, RTGCPHYS cbRegion));
2135
2136 /**
2137 * Gets the mapping address of the MMIO region @a hRegion.
2138 *
2139 * @returns Mapping address, NIL_RTGCPHYS if not mapped (or invalid parameters).
2140 * @param pDevIns The device instance to register the ports with.
2141 * @param hRegion The MMIO region handle.
2142 */
2143 DECLR3CALLBACKMEMBER(RTGCPHYS, pfnMmioGetMappingAddress,(PPDMDEVINS pDevIns, IOMMMIOHANDLE hRegion));
2144 /** @} */
2145
2146 /** @name MMIO2
2147 * @{ */
2148 /**
2149 * Creates a MMIO2 region.
2150 *
2151 * As mentioned elsewhere, MMIO2 is just RAM spelled differently. It's RAM
2152 * associated with a device. It is also non-shared memory with a permanent
2153 * ring-3 mapping and page backing (presently).
2154 *
2155 * @returns VBox status.
2156 * @param pDevIns The device instance.
2157 * @param pPciDev The PCI device the region is associated with, or
2158 * NULL if no PCI device association.
2159 * @param iPciRegion The region number. Use the PCI region number as
2160 * this must be known to the PCI bus device too. If
2161 * it's not associated with the PCI device, then
2162 * any number up to UINT8_MAX is fine.
2163 * @param cbRegion The size (in bytes) of the region.
2164 * @param fFlags Reserved for future use, must be zero.
2165 * @param pszDesc Pointer to description string. This must not be
2166 * freed.
2167 * @param ppvMapping Where to store the address of the ring-3 mapping
2168 * of the memory.
2169 * @param phRegion Where to return the MMIO2 region handle.
2170 *
2171 * @thread EMT(0)
2172 */
2173 DECLR3CALLBACKMEMBER(int, pfnMmio2Create,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iPciRegion, RTGCPHYS cbRegion,
2174 uint32_t fFlags, const char *pszDesc, void **ppvMapping, PPGMMMIO2HANDLE phRegion));
2175
2176 /**
2177 * Destroys a MMIO2 region, unmapping it and freeing the memory.
2178 *
2179 * Any physical access handlers registered for the region must be deregistered
2180 * before calling this function.
2181 *
2182 * @returns VBox status code.
2183 * @param pDevIns The device instance.
2184 * @param hRegion The MMIO2 region handle.
2185 * @thread EMT.
2186 */
2187 DECLR3CALLBACKMEMBER(int, pfnMmio2Destroy,(PPDMDEVINS pDevIns, PGMMMIO2HANDLE hRegion));
2188
2189 /**
2190 * Maps a MMIO2 region (into the guest physical address space).
2191 *
2192 * @returns VBox status.
2193 * @param pDevIns The device instance the region is associated with.
2194 * @param hRegion The MMIO2 region handle.
2195 * @param GCPhys Where to map the region.
2196 * @note A MMIO2 region overlap with base memory if a lot of RAM is
2197 * configured for the VM, in which case we'll drop the base memory
2198 * pages. Presently we will make no attempt to preserve anything that
2199 * happens to be present in the base memory that is replaced, this is
2200 * technically incorrect but it's just not worth the effort to do
2201 * right, at least not at this point.
2202 * @sa PDMDevHlpMmio2Unmap, PDMDevHlpMmio2Create, PDMDevHlpMmio2SetUpContext
2203 */
2204 DECLR3CALLBACKMEMBER(int, pfnMmio2Map,(PPDMDEVINS pDevIns, PGMMMIO2HANDLE hRegion, RTGCPHYS GCPhys));
2205
2206 /**
2207 * Unmaps a MMIO2 region.
2208 *
2209 * @returns VBox status.
2210 * @param pDevIns The device instance the region is associated with.
2211 * @param hRegion The MMIO2 region handle.
2212 * @sa PDMDevHlpMmio2Map, PDMDevHlpMmio2Create, PDMDevHlpMmio2SetUpContext
2213 */
2214 DECLR3CALLBACKMEMBER(int, pfnMmio2Unmap,(PPDMDEVINS pDevIns, PGMMMIO2HANDLE hRegion));
2215
2216 /**
2217 * Reduces the length of a MMIO range.
2218 *
2219 * This is for implementations of PDMPCIDEV::pfnRegionLoadChangeHookR3 and will
2220 * only work during saved state restore. It will not call the PCI bus code, as
2221 * that is expected to restore the saved resource configuration.
2222 *
2223 * It just adjusts the mapping length of the region so that when pfnMmioMap is
2224 * called it will only map @a cbRegion bytes and not the value set during
2225 * registration.
2226 *
2227 * @return VBox status code.
2228 * @param pDevIns The device owning the range.
2229 * @param hRegion The MMIO2 region handle.
2230 * @param cbRegion The new size, must be smaller.
2231 */
2232 DECLR3CALLBACKMEMBER(int, pfnMmio2Reduce,(PPDMDEVINS pDevIns, PGMMMIO2HANDLE hRegion, RTGCPHYS cbRegion));
2233
2234 /**
2235 * Gets the mapping address of the MMIO region @a hRegion.
2236 *
2237 * @returns Mapping address, NIL_RTGCPHYS if not mapped (or invalid parameters).
2238 * @param pDevIns The device instance to register the ports with.
2239 * @param hRegion The MMIO2 region handle.
2240 */
2241 DECLR3CALLBACKMEMBER(RTGCPHYS, pfnMmio2GetMappingAddress,(PPDMDEVINS pDevIns, PGMMMIO2HANDLE hRegion));
2242
2243 /**
2244 * Changes the number of an MMIO2 or pre-registered MMIO region.
2245 *
2246 * This should only be used to deal with saved state problems, so there is no
2247 * convenience inline wrapper for this method.
2248 *
2249 * @returns VBox status code.
2250 * @param pDevIns The device instance.
2251 * @param hRegion The MMIO2 region handle.
2252 * @param iNewRegion The new region index.
2253 *
2254 * @sa @bugref{9359}
2255 */
2256 DECLR3CALLBACKMEMBER(int, pfnMmio2ChangeRegionNo,(PPDMDEVINS pDevIns, PGMMMIO2HANDLE hRegion, uint32_t iNewRegion));
2257 /** @} */
2258
2259 /**
2260 * Register a ROM (BIOS) region.
2261 *
2262 * It goes without saying that this is read-only memory. The memory region must be
2263 * in unassigned memory. I.e. from the top of the address space or on the PC in
2264 * the 0xa0000-0xfffff range.
2265 *
2266 * @returns VBox status.
2267 * @param pDevIns The device instance owning the ROM region.
2268 * @param GCPhysStart First physical address in the range.
2269 * Must be page aligned!
2270 * @param cbRange The size of the range (in bytes).
2271 * Must be page aligned!
2272 * @param pvBinary Pointer to the binary data backing the ROM image.
2273 * @param cbBinary The size of the binary pointer. This must
2274 * be equal or smaller than @a cbRange.
2275 * @param fFlags Shadow ROM flags, PGMPHYS_ROM_FLAGS_* in pgm.h.
2276 * @param pszDesc Pointer to description string. This must not be freed.
2277 *
2278 * @remark There is no way to remove the rom, automatically on device cleanup or
2279 * manually from the device yet. At present I doubt we need such features...
2280 */
2281 DECLR3CALLBACKMEMBER(int, pfnROMRegister,(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, uint32_t cbRange,
2282 const void *pvBinary, uint32_t cbBinary, uint32_t fFlags, const char *pszDesc));
2283
2284 /**
2285 * Changes the protection of shadowed ROM mapping.
2286 *
2287 * This is intented for use by the system BIOS, chipset or device in question to
2288 * change the protection of shadowed ROM code after init and on reset.
2289 *
2290 * @param pDevIns The device instance.
2291 * @param GCPhysStart Where the mapping starts.
2292 * @param cbRange The size of the mapping.
2293 * @param enmProt The new protection type.
2294 */
2295 DECLR3CALLBACKMEMBER(int, pfnROMProtectShadow,(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, uint32_t cbRange, PGMROMPROT enmProt));
2296
2297 /**
2298 * Register a save state data unit.
2299 *
2300 * @returns VBox status.
2301 * @param pDevIns The device instance.
2302 * @param uVersion Data layout version number.
2303 * @param cbGuess The approximate amount of data in the unit.
2304 * Only for progress indicators.
2305 * @param pszBefore Name of data unit which we should be put in
2306 * front of. Optional (NULL).
2307 *
2308 * @param pfnLivePrep Prepare live save callback, optional.
2309 * @param pfnLiveExec Execute live save callback, optional.
2310 * @param pfnLiveVote Vote live save callback, optional.
2311 *
2312 * @param pfnSavePrep Prepare save callback, optional.
2313 * @param pfnSaveExec Execute save callback, optional.
2314 * @param pfnSaveDone Done save callback, optional.
2315 *
2316 * @param pfnLoadPrep Prepare load callback, optional.
2317 * @param pfnLoadExec Execute load callback, optional.
2318 * @param pfnLoadDone Done load callback, optional.
2319 * @remarks Caller enters the device critical section prior to invoking the
2320 * registered callback methods.
2321 */
2322 DECLR3CALLBACKMEMBER(int, pfnSSMRegister,(PPDMDEVINS pDevIns, uint32_t uVersion, size_t cbGuess, const char *pszBefore,
2323 PFNSSMDEVLIVEPREP pfnLivePrep, PFNSSMDEVLIVEEXEC pfnLiveExec, PFNSSMDEVLIVEVOTE pfnLiveVote,
2324 PFNSSMDEVSAVEPREP pfnSavePrep, PFNSSMDEVSAVEEXEC pfnSaveExec, PFNSSMDEVSAVEDONE pfnSaveDone,
2325 PFNSSMDEVLOADPREP pfnLoadPrep, PFNSSMDEVLOADEXEC pfnLoadExec, PFNSSMDEVLOADDONE pfnLoadDone));
2326
2327 /** @name Exported SSM Functions
2328 * @{ */
2329 DECLR3CALLBACKMEMBER(int, pfnSSMPutStruct,(PSSMHANDLE pSSM, const void *pvStruct, PCSSMFIELD paFields));
2330 DECLR3CALLBACKMEMBER(int, pfnSSMPutStructEx,(PSSMHANDLE pSSM, const void *pvStruct, size_t cbStruct, uint32_t fFlags, PCSSMFIELD paFields, void *pvUser));
2331 DECLR3CALLBACKMEMBER(int, pfnSSMPutBool,(PSSMHANDLE pSSM, bool fBool));
2332 DECLR3CALLBACKMEMBER(int, pfnSSMPutU8,(PSSMHANDLE pSSM, uint8_t u8));
2333 DECLR3CALLBACKMEMBER(int, pfnSSMPutS8,(PSSMHANDLE pSSM, int8_t i8));
2334 DECLR3CALLBACKMEMBER(int, pfnSSMPutU16,(PSSMHANDLE pSSM, uint16_t u16));
2335 DECLR3CALLBACKMEMBER(int, pfnSSMPutS16,(PSSMHANDLE pSSM, int16_t i16));
2336 DECLR3CALLBACKMEMBER(int, pfnSSMPutU32,(PSSMHANDLE pSSM, uint32_t u32));
2337 DECLR3CALLBACKMEMBER(int, pfnSSMPutS32,(PSSMHANDLE pSSM, int32_t i32));
2338 DECLR3CALLBACKMEMBER(int, pfnSSMPutU64,(PSSMHANDLE pSSM, uint64_t u64));
2339 DECLR3CALLBACKMEMBER(int, pfnSSMPutS64,(PSSMHANDLE pSSM, int64_t i64));
2340 DECLR3CALLBACKMEMBER(int, pfnSSMPutU128,(PSSMHANDLE pSSM, uint128_t u128));
2341 DECLR3CALLBACKMEMBER(int, pfnSSMPutS128,(PSSMHANDLE pSSM, int128_t i128));
2342 DECLR3CALLBACKMEMBER(int, pfnSSMPutUInt,(PSSMHANDLE pSSM, RTUINT u));
2343 DECLR3CALLBACKMEMBER(int, pfnSSMPutSInt,(PSSMHANDLE pSSM, RTINT i));
2344 DECLR3CALLBACKMEMBER(int, pfnSSMPutGCUInt,(PSSMHANDLE pSSM, RTGCUINT u));
2345 DECLR3CALLBACKMEMBER(int, pfnSSMPutGCUIntReg,(PSSMHANDLE pSSM, RTGCUINTREG u));
2346 DECLR3CALLBACKMEMBER(int, pfnSSMPutGCPhys32,(PSSMHANDLE pSSM, RTGCPHYS32 GCPhys));
2347 DECLR3CALLBACKMEMBER(int, pfnSSMPutGCPhys64,(PSSMHANDLE pSSM, RTGCPHYS64 GCPhys));
2348 DECLR3CALLBACKMEMBER(int, pfnSSMPutGCPhys,(PSSMHANDLE pSSM, RTGCPHYS GCPhys));
2349 DECLR3CALLBACKMEMBER(int, pfnSSMPutGCPtr,(PSSMHANDLE pSSM, RTGCPTR GCPtr));
2350 DECLR3CALLBACKMEMBER(int, pfnSSMPutGCUIntPtr,(PSSMHANDLE pSSM, RTGCUINTPTR GCPtr));
2351 DECLR3CALLBACKMEMBER(int, pfnSSMPutRCPtr,(PSSMHANDLE pSSM, RTRCPTR RCPtr));
2352 DECLR3CALLBACKMEMBER(int, pfnSSMPutIOPort,(PSSMHANDLE pSSM, RTIOPORT IOPort));
2353 DECLR3CALLBACKMEMBER(int, pfnSSMPutSel,(PSSMHANDLE pSSM, RTSEL Sel));
2354 DECLR3CALLBACKMEMBER(int, pfnSSMPutMem,(PSSMHANDLE pSSM, const void *pv, size_t cb));
2355 DECLR3CALLBACKMEMBER(int, pfnSSMPutStrZ,(PSSMHANDLE pSSM, const char *psz));
2356 DECLR3CALLBACKMEMBER(int, pfnSSMGetStruct,(PSSMHANDLE pSSM, void *pvStruct, PCSSMFIELD paFields));
2357 DECLR3CALLBACKMEMBER(int, pfnSSMGetStructEx,(PSSMHANDLE pSSM, void *pvStruct, size_t cbStruct, uint32_t fFlags, PCSSMFIELD paFields, void *pvUser));
2358 DECLR3CALLBACKMEMBER(int, pfnSSMGetBool,(PSSMHANDLE pSSM, bool *pfBool));
2359 DECLR3CALLBACKMEMBER(int, pfnSSMGetBoolV,(PSSMHANDLE pSSM, bool volatile *pfBool));
2360 DECLR3CALLBACKMEMBER(int, pfnSSMGetU8,(PSSMHANDLE pSSM, uint8_t *pu8));
2361 DECLR3CALLBACKMEMBER(int, pfnSSMGetU8V,(PSSMHANDLE pSSM, uint8_t volatile *pu8));
2362 DECLR3CALLBACKMEMBER(int, pfnSSMGetS8,(PSSMHANDLE pSSM, int8_t *pi8));
2363 DECLR3CALLBACKMEMBER(int, pfnSSMGetS8V,(PSSMHANDLE pSSM, int8_t volatile *pi8));
2364 DECLR3CALLBACKMEMBER(int, pfnSSMGetU16,(PSSMHANDLE pSSM, uint16_t *pu16));
2365 DECLR3CALLBACKMEMBER(int, pfnSSMGetU16V,(PSSMHANDLE pSSM, uint16_t volatile *pu16));
2366 DECLR3CALLBACKMEMBER(int, pfnSSMGetS16,(PSSMHANDLE pSSM, int16_t *pi16));
2367 DECLR3CALLBACKMEMBER(int, pfnSSMGetS16V,(PSSMHANDLE pSSM, int16_t volatile *pi16));
2368 DECLR3CALLBACKMEMBER(int, pfnSSMGetU32,(PSSMHANDLE pSSM, uint32_t *pu32));
2369 DECLR3CALLBACKMEMBER(int, pfnSSMGetU32V,(PSSMHANDLE pSSM, uint32_t volatile *pu32));
2370 DECLR3CALLBACKMEMBER(int, pfnSSMGetS32,(PSSMHANDLE pSSM, int32_t *pi32));
2371 DECLR3CALLBACKMEMBER(int, pfnSSMGetS32V,(PSSMHANDLE pSSM, int32_t volatile *pi32));
2372 DECLR3CALLBACKMEMBER(int, pfnSSMGetU64,(PSSMHANDLE pSSM, uint64_t *pu64));
2373 DECLR3CALLBACKMEMBER(int, pfnSSMGetU64V,(PSSMHANDLE pSSM, uint64_t volatile *pu64));
2374 DECLR3CALLBACKMEMBER(int, pfnSSMGetS64,(PSSMHANDLE pSSM, int64_t *pi64));
2375 DECLR3CALLBACKMEMBER(int, pfnSSMGetS64V,(PSSMHANDLE pSSM, int64_t volatile *pi64));
2376 DECLR3CALLBACKMEMBER(int, pfnSSMGetU128,(PSSMHANDLE pSSM, uint128_t *pu128));
2377 DECLR3CALLBACKMEMBER(int, pfnSSMGetU128V,(PSSMHANDLE pSSM, uint128_t volatile *pu128));
2378 DECLR3CALLBACKMEMBER(int, pfnSSMGetS128,(PSSMHANDLE pSSM, int128_t *pi128));
2379 DECLR3CALLBACKMEMBER(int, pfnSSMGetS128V,(PSSMHANDLE pSSM, int128_t volatile *pi128));
2380 DECLR3CALLBACKMEMBER(int, pfnSSMGetGCPhys32,(PSSMHANDLE pSSM, PRTGCPHYS32 pGCPhys));
2381 DECLR3CALLBACKMEMBER(int, pfnSSMGetGCPhys32V,(PSSMHANDLE pSSM, RTGCPHYS32 volatile *pGCPhys));
2382 DECLR3CALLBACKMEMBER(int, pfnSSMGetGCPhys64,(PSSMHANDLE pSSM, PRTGCPHYS64 pGCPhys));
2383 DECLR3CALLBACKMEMBER(int, pfnSSMGetGCPhys64V,(PSSMHANDLE pSSM, RTGCPHYS64 volatile *pGCPhys));
2384 DECLR3CALLBACKMEMBER(int, pfnSSMGetGCPhys,(PSSMHANDLE pSSM, PRTGCPHYS pGCPhys));
2385 DECLR3CALLBACKMEMBER(int, pfnSSMGetGCPhysV,(PSSMHANDLE pSSM, RTGCPHYS volatile *pGCPhys));
2386 DECLR3CALLBACKMEMBER(int, pfnSSMGetUInt,(PSSMHANDLE pSSM, PRTUINT pu));
2387 DECLR3CALLBACKMEMBER(int, pfnSSMGetSInt,(PSSMHANDLE pSSM, PRTINT pi));
2388 DECLR3CALLBACKMEMBER(int, pfnSSMGetGCUInt,(PSSMHANDLE pSSM, PRTGCUINT pu));
2389 DECLR3CALLBACKMEMBER(int, pfnSSMGetGCUIntReg,(PSSMHANDLE pSSM, PRTGCUINTREG pu));
2390 DECLR3CALLBACKMEMBER(int, pfnSSMGetGCPtr,(PSSMHANDLE pSSM, PRTGCPTR pGCPtr));
2391 DECLR3CALLBACKMEMBER(int, pfnSSMGetGCUIntPtr,(PSSMHANDLE pSSM, PRTGCUINTPTR pGCPtr));
2392 DECLR3CALLBACKMEMBER(int, pfnSSMGetRCPtr,(PSSMHANDLE pSSM, PRTRCPTR pRCPtr));
2393 DECLR3CALLBACKMEMBER(int, pfnSSMGetIOPort,(PSSMHANDLE pSSM, PRTIOPORT pIOPort));
2394 DECLR3CALLBACKMEMBER(int, pfnSSMGetSel,(PSSMHANDLE pSSM, PRTSEL pSel));
2395 DECLR3CALLBACKMEMBER(int, pfnSSMGetMem,(PSSMHANDLE pSSM, void *pv, size_t cb));
2396 DECLR3CALLBACKMEMBER(int, pfnSSMGetStrZ,(PSSMHANDLE pSSM, char *psz, size_t cbMax));
2397 DECLR3CALLBACKMEMBER(int, pfnSSMGetStrZEx,(PSSMHANDLE pSSM, char *psz, size_t cbMax, size_t *pcbStr));
2398 DECLR3CALLBACKMEMBER(int, pfnSSMSkip,(PSSMHANDLE pSSM, size_t cb));
2399 DECLR3CALLBACKMEMBER(int, pfnSSMSkipToEndOfUnit,(PSSMHANDLE pSSM));
2400 DECLR3CALLBACKMEMBER(int, pfnSSMSetLoadError,(PSSMHANDLE pSSM, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(6, 7));
2401 DECLR3CALLBACKMEMBER(int, pfnSSMSetLoadErrorV,(PSSMHANDLE pSSM, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(6, 0));
2402 DECLR3CALLBACKMEMBER(int, pfnSSMSetCfgError,(PSSMHANDLE pSSM, RT_SRC_POS_DECL, const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(5, 6));
2403 DECLR3CALLBACKMEMBER(int, pfnSSMSetCfgErrorV,(PSSMHANDLE pSSM, RT_SRC_POS_DECL, const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(5, 0));
2404 DECLR3CALLBACKMEMBER(int, pfnSSMHandleGetStatus,(PSSMHANDLE pSSM));
2405 DECLR3CALLBACKMEMBER(SSMAFTER, pfnSSMHandleGetAfter,(PSSMHANDLE pSSM));
2406 DECLR3CALLBACKMEMBER(bool, pfnSSMHandleIsLiveSave,(PSSMHANDLE pSSM));
2407 DECLR3CALLBACKMEMBER(uint32_t, pfnSSMHandleMaxDowntime,(PSSMHANDLE pSSM));
2408 DECLR3CALLBACKMEMBER(uint32_t, pfnSSMHandleHostBits,(PSSMHANDLE pSSM));
2409 DECLR3CALLBACKMEMBER(uint32_t, pfnSSMHandleRevision,(PSSMHANDLE pSSM));
2410 DECLR3CALLBACKMEMBER(uint32_t, pfnSSMHandleVersion,(PSSMHANDLE pSSM));
2411 DECLR3CALLBACKMEMBER(const char *, pfnSSMHandleHostOSAndArch,(PSSMHANDLE pSSM));
2412 /** @} */
2413
2414 /**
2415 * Creates a timer.
2416 *
2417 * @returns VBox status.
2418 * @param pDevIns The device instance.
2419 * @param enmClock The clock to use on this timer.
2420 * @param pfnCallback Callback function.
2421 * @param pvUser User argument for the callback.
2422 * @param fFlags Flags, see TMTIMER_FLAGS_*.
2423 * @param pszDesc Pointer to description string which must stay around
2424 * until the timer is fully destroyed (i.e. a bit after TMTimerDestroy()).
2425 * @param ppTimer Where to store the timer on success.
2426 * @remarks Caller enters the device critical section prior to invoking the
2427 * callback.
2428 */
2429 DECLR3CALLBACKMEMBER(int, pfnTMTimerCreate,(PPDMDEVINS pDevIns, TMCLOCK enmClock, PFNTMTIMERDEV pfnCallback,
2430 void *pvUser, uint32_t fFlags, const char *pszDesc, PPTMTIMERR3 ppTimer));
2431
2432 /**
2433 * Creates a timer w/ a cross context handle.
2434 *
2435 * @returns VBox status.
2436 * @param pDevIns The device instance.
2437 * @param enmClock The clock to use on this timer.
2438 * @param pfnCallback Callback function.
2439 * @param pvUser User argument for the callback.
2440 * @param fFlags Flags, see TMTIMER_FLAGS_*.
2441 * @param pszDesc Pointer to description string which must stay around
2442 * until the timer is fully destroyed (i.e. a bit after TMTimerDestroy()).
2443 * @param phTimer Where to store the timer handle on success.
2444 * @remarks Caller enters the device critical section prior to invoking the
2445 * callback.
2446 */
2447 DECLR3CALLBACKMEMBER(int, pfnTimerCreate,(PPDMDEVINS pDevIns, TMCLOCK enmClock, PFNTMTIMERDEV pfnCallback,
2448 void *pvUser, uint32_t fFlags, const char *pszDesc, PTMTIMERHANDLE phTimer));
2449
2450 /**
2451 * Translates a timer handle to a pointer.
2452 *
2453 * @returns The time address.
2454 * @param pDevIns The device instance.
2455 * @param hTimer The timer handle.
2456 */
2457 DECLR3CALLBACKMEMBER(PTMTIMERR3, pfnTimerToPtr,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer));
2458
2459 /** @name Timer handle method wrappers
2460 * @{ */
2461 DECLR3CALLBACKMEMBER(uint64_t, pfnTimerFromMicro,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint64_t cMicroSecs));
2462 DECLR3CALLBACKMEMBER(uint64_t, pfnTimerFromMilli,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint64_t cMilliSecs));
2463 DECLR3CALLBACKMEMBER(uint64_t, pfnTimerFromNano,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint64_t cNanoSecs));
2464 DECLR3CALLBACKMEMBER(uint64_t, pfnTimerGet,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer));
2465 DECLR3CALLBACKMEMBER(uint64_t, pfnTimerGetFreq,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer));
2466 DECLR3CALLBACKMEMBER(uint64_t, pfnTimerGetNano,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer));
2467 DECLR3CALLBACKMEMBER(bool, pfnTimerIsActive,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer));
2468 DECLR3CALLBACKMEMBER(bool, pfnTimerIsLockOwner,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer));
2469 DECLR3CALLBACKMEMBER(VBOXSTRICTRC, pfnTimerLockClock,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, int rcBusy));
2470 /** Takes the clock lock then enters the specified critical section. */
2471 DECLR3CALLBACKMEMBER(VBOXSTRICTRC, pfnTimerLockClock2,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, PPDMCRITSECT pCritSect, int rcBusy));
2472 DECLR3CALLBACKMEMBER(int, pfnTimerSet,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint64_t uExpire));
2473 DECLR3CALLBACKMEMBER(int, pfnTimerSetFrequencyHint,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint32_t uHz));
2474 DECLR3CALLBACKMEMBER(int, pfnTimerSetMicro,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint64_t cMicrosToNext));
2475 DECLR3CALLBACKMEMBER(int, pfnTimerSetMillies,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint64_t cMilliesToNext));
2476 DECLR3CALLBACKMEMBER(int, pfnTimerSetNano,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint64_t cNanosToNext));
2477 DECLR3CALLBACKMEMBER(int, pfnTimerSetRelative,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint64_t cTicksToNext, uint64_t *pu64Now));
2478 DECLR3CALLBACKMEMBER(int, pfnTimerStop,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer));
2479 DECLR3CALLBACKMEMBER(void, pfnTimerUnlockClock,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer));
2480 DECLR3CALLBACKMEMBER(void, pfnTimerUnlockClock2,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, PPDMCRITSECT pCritSect));
2481 DECLR3CALLBACKMEMBER(int, pfnTimerSetCritSect,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, PPDMCRITSECT pCritSect));
2482 DECLR3CALLBACKMEMBER(int, pfnTimerSave,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, PSSMHANDLE pSSM));
2483 DECLR3CALLBACKMEMBER(int, pfnTimerLoad,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, PSSMHANDLE pSSM));
2484 DECLR3CALLBACKMEMBER(int, pfnTimerDestroy,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer));
2485 /** @sa TMR3TimerSkip */
2486 DECLR3CALLBACKMEMBER(int, pfnTimerSkipLoad,(PSSMHANDLE pSSM, bool *pfActive));
2487 /** @} */
2488
2489 /**
2490 * Get the real world UTC time adjusted for VM lag, user offset and warpdrive.
2491 *
2492 * @returns pTime.
2493 * @param pDevIns The device instance.
2494 * @param pTime Where to store the time.
2495 */
2496 DECLR3CALLBACKMEMBER(PRTTIMESPEC, pfnTMUtcNow,(PPDMDEVINS pDevIns, PRTTIMESPEC pTime));
2497
2498 /** @name Exported CFGM Functions.
2499 * @{ */
2500 DECLR3CALLBACKMEMBER(bool, pfnCFGMExists,( PCFGMNODE pNode, const char *pszName));
2501 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryType,( PCFGMNODE pNode, const char *pszName, PCFGMVALUETYPE penmType));
2502 DECLR3CALLBACKMEMBER(int, pfnCFGMQuerySize,( PCFGMNODE pNode, const char *pszName, size_t *pcb));
2503 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryInteger,( PCFGMNODE pNode, const char *pszName, uint64_t *pu64));
2504 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryIntegerDef,( PCFGMNODE pNode, const char *pszName, uint64_t *pu64, uint64_t u64Def));
2505 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryString,( PCFGMNODE pNode, const char *pszName, char *pszString, size_t cchString));
2506 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryStringDef,( PCFGMNODE pNode, const char *pszName, char *pszString, size_t cchString, const char *pszDef));
2507 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryBytes,( PCFGMNODE pNode, const char *pszName, void *pvData, size_t cbData));
2508 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryU64,( PCFGMNODE pNode, const char *pszName, uint64_t *pu64));
2509 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryU64Def,( PCFGMNODE pNode, const char *pszName, uint64_t *pu64, uint64_t u64Def));
2510 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryS64,( PCFGMNODE pNode, const char *pszName, int64_t *pi64));
2511 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryS64Def,( PCFGMNODE pNode, const char *pszName, int64_t *pi64, int64_t i64Def));
2512 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryU32,( PCFGMNODE pNode, const char *pszName, uint32_t *pu32));
2513 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryU32Def,( PCFGMNODE pNode, const char *pszName, uint32_t *pu32, uint32_t u32Def));
2514 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryS32,( PCFGMNODE pNode, const char *pszName, int32_t *pi32));
2515 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryS32Def,( PCFGMNODE pNode, const char *pszName, int32_t *pi32, int32_t i32Def));
2516 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryU16,( PCFGMNODE pNode, const char *pszName, uint16_t *pu16));
2517 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryU16Def,( PCFGMNODE pNode, const char *pszName, uint16_t *pu16, uint16_t u16Def));
2518 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryS16,( PCFGMNODE pNode, const char *pszName, int16_t *pi16));
2519 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryS16Def,( PCFGMNODE pNode, const char *pszName, int16_t *pi16, int16_t i16Def));
2520 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryU8,( PCFGMNODE pNode, const char *pszName, uint8_t *pu8));
2521 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryU8Def,( PCFGMNODE pNode, const char *pszName, uint8_t *pu8, uint8_t u8Def));
2522 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryS8,( PCFGMNODE pNode, const char *pszName, int8_t *pi8));
2523 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryS8Def,( PCFGMNODE pNode, const char *pszName, int8_t *pi8, int8_t i8Def));
2524 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryBool,( PCFGMNODE pNode, const char *pszName, bool *pf));
2525 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryBoolDef,( PCFGMNODE pNode, const char *pszName, bool *pf, bool fDef));
2526 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryPort,( PCFGMNODE pNode, const char *pszName, PRTIOPORT pPort));
2527 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryPortDef,( PCFGMNODE pNode, const char *pszName, PRTIOPORT pPort, RTIOPORT PortDef));
2528 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryUInt,( PCFGMNODE pNode, const char *pszName, unsigned int *pu));
2529 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryUIntDef,( PCFGMNODE pNode, const char *pszName, unsigned int *pu, unsigned int uDef));
2530 DECLR3CALLBACKMEMBER(int, pfnCFGMQuerySInt,( PCFGMNODE pNode, const char *pszName, signed int *pi));
2531 DECLR3CALLBACKMEMBER(int, pfnCFGMQuerySIntDef,( PCFGMNODE pNode, const char *pszName, signed int *pi, signed int iDef));
2532 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryPtr,( PCFGMNODE pNode, const char *pszName, void **ppv));
2533 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryPtrDef,( PCFGMNODE pNode, const char *pszName, void **ppv, void *pvDef));
2534 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryGCPtr,( PCFGMNODE pNode, const char *pszName, PRTGCPTR pGCPtr));
2535 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryGCPtrDef,( PCFGMNODE pNode, const char *pszName, PRTGCPTR pGCPtr, RTGCPTR GCPtrDef));
2536 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryGCPtrU,( PCFGMNODE pNode, const char *pszName, PRTGCUINTPTR pGCPtr));
2537 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryGCPtrUDef,( PCFGMNODE pNode, const char *pszName, PRTGCUINTPTR pGCPtr, RTGCUINTPTR GCPtrDef));
2538 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryGCPtrS,( PCFGMNODE pNode, const char *pszName, PRTGCINTPTR pGCPtr));
2539 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryGCPtrSDef,( PCFGMNODE pNode, const char *pszName, PRTGCINTPTR pGCPtr, RTGCINTPTR GCPtrDef));
2540 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryStringAlloc,( PCFGMNODE pNode, const char *pszName, char **ppszString));
2541 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryStringAllocDef,(PCFGMNODE pNode, const char *pszName, char **ppszString, const char *pszDef));
2542 DECLR3CALLBACKMEMBER(PCFGMNODE, pfnCFGMGetParent,(PCFGMNODE pNode));
2543 DECLR3CALLBACKMEMBER(PCFGMNODE, pfnCFGMGetChild,(PCFGMNODE pNode, const char *pszPath));
2544 DECLR3CALLBACKMEMBER(PCFGMNODE, pfnCFGMGetChildF,(PCFGMNODE pNode, const char *pszPathFormat, ...) RT_IPRT_FORMAT_ATTR(2, 3));
2545 DECLR3CALLBACKMEMBER(PCFGMNODE, pfnCFGMGetChildFV,(PCFGMNODE pNode, const char *pszPathFormat, va_list Args) RT_IPRT_FORMAT_ATTR(3, 0));
2546 DECLR3CALLBACKMEMBER(PCFGMNODE, pfnCFGMGetFirstChild,(PCFGMNODE pNode));
2547 DECLR3CALLBACKMEMBER(PCFGMNODE, pfnCFGMGetNextChild,(PCFGMNODE pCur));
2548 DECLR3CALLBACKMEMBER(int, pfnCFGMGetName,(PCFGMNODE pCur, char *pszName, size_t cchName));
2549 DECLR3CALLBACKMEMBER(size_t, pfnCFGMGetNameLen,(PCFGMNODE pCur));
2550 DECLR3CALLBACKMEMBER(bool, pfnCFGMAreChildrenValid,(PCFGMNODE pNode, const char *pszzValid));
2551 DECLR3CALLBACKMEMBER(PCFGMLEAF, pfnCFGMGetFirstValue,(PCFGMNODE pCur));
2552 DECLR3CALLBACKMEMBER(PCFGMLEAF, pfnCFGMGetNextValue,(PCFGMLEAF pCur));
2553 DECLR3CALLBACKMEMBER(int, pfnCFGMGetValueName,(PCFGMLEAF pCur, char *pszName, size_t cchName));
2554 DECLR3CALLBACKMEMBER(size_t, pfnCFGMGetValueNameLen,(PCFGMLEAF pCur));
2555 DECLR3CALLBACKMEMBER(CFGMVALUETYPE, pfnCFGMGetValueType,(PCFGMLEAF pCur));
2556 DECLR3CALLBACKMEMBER(bool, pfnCFGMAreValuesValid,(PCFGMNODE pNode, const char *pszzValid));
2557 DECLR3CALLBACKMEMBER(int, pfnCFGMValidateConfig,(PCFGMNODE pNode, const char *pszNode,
2558 const char *pszValidValues, const char *pszValidNodes,
2559 const char *pszWho, uint32_t uInstance));
2560 /** @} */
2561
2562 /**
2563 * Read physical memory.
2564 *
2565 * @returns VINF_SUCCESS (for now).
2566 * @param pDevIns The device instance.
2567 * @param GCPhys Physical address start reading from.
2568 * @param pvBuf Where to put the read bits.
2569 * @param cbRead How many bytes to read.
2570 * @thread Any thread, but the call may involve the emulation thread.
2571 */
2572 DECLR3CALLBACKMEMBER(int, pfnPhysRead,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead));
2573
2574 /**
2575 * Write to physical memory.
2576 *
2577 * @returns VINF_SUCCESS for now, and later maybe VERR_EM_MEMORY.
2578 * @param pDevIns The device instance.
2579 * @param GCPhys Physical address to write to.
2580 * @param pvBuf What to write.
2581 * @param cbWrite How many bytes to write.
2582 * @thread Any thread, but the call may involve the emulation thread.
2583 */
2584 DECLR3CALLBACKMEMBER(int, pfnPhysWrite,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite));
2585
2586 /**
2587 * Requests the mapping of a guest page into ring-3.
2588 *
2589 * When you're done with the page, call pfnPhysReleasePageMappingLock() ASAP to
2590 * release it.
2591 *
2592 * This API will assume your intention is to write to the page, and will
2593 * therefore replace shared and zero pages. If you do not intend to modify the
2594 * page, use the pfnPhysGCPhys2CCPtrReadOnly() API.
2595 *
2596 * @returns VBox status code.
2597 * @retval VINF_SUCCESS on success.
2598 * @retval VERR_PGM_PHYS_PAGE_RESERVED it it's a valid page but has no physical
2599 * backing or if the page has any active access handlers. The caller
2600 * must fall back on using PGMR3PhysWriteExternal.
2601 * @retval VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS if it's not a valid physical address.
2602 *
2603 * @param pDevIns The device instance.
2604 * @param GCPhys The guest physical address of the page that
2605 * should be mapped.
2606 * @param fFlags Flags reserved for future use, MBZ.
2607 * @param ppv Where to store the address corresponding to
2608 * GCPhys.
2609 * @param pLock Where to store the lock information that
2610 * pfnPhysReleasePageMappingLock needs.
2611 *
2612 * @remark Avoid calling this API from within critical sections (other than the
2613 * PGM one) because of the deadlock risk when we have to delegating the
2614 * task to an EMT.
2615 * @thread Any.
2616 */
2617 DECLR3CALLBACKMEMBER(int, pfnPhysGCPhys2CCPtr,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, uint32_t fFlags, void **ppv,
2618 PPGMPAGEMAPLOCK pLock));
2619
2620 /**
2621 * Requests the mapping of a guest page into ring-3, external threads.
2622 *
2623 * When you're done with the page, call pfnPhysReleasePageMappingLock() ASAP to
2624 * release it.
2625 *
2626 * @returns VBox status code.
2627 * @retval VINF_SUCCESS on success.
2628 * @retval VERR_PGM_PHYS_PAGE_RESERVED it it's a valid page but has no physical
2629 * backing or if the page as an active ALL access handler. The caller
2630 * must fall back on using PGMPhysRead.
2631 * @retval VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS if it's not a valid physical address.
2632 *
2633 * @param pDevIns The device instance.
2634 * @param GCPhys The guest physical address of the page that
2635 * should be mapped.
2636 * @param fFlags Flags reserved for future use, MBZ.
2637 * @param ppv Where to store the address corresponding to
2638 * GCPhys.
2639 * @param pLock Where to store the lock information that
2640 * pfnPhysReleasePageMappingLock needs.
2641 *
2642 * @remark Avoid calling this API from within critical sections.
2643 * @thread Any.
2644 */
2645 DECLR3CALLBACKMEMBER(int, pfnPhysGCPhys2CCPtrReadOnly,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, uint32_t fFlags,
2646 void const **ppv, PPGMPAGEMAPLOCK pLock));
2647
2648 /**
2649 * Release the mapping of a guest page.
2650 *
2651 * This is the counter part of pfnPhysGCPhys2CCPtr and
2652 * pfnPhysGCPhys2CCPtrReadOnly.
2653 *
2654 * @param pDevIns The device instance.
2655 * @param pLock The lock structure initialized by the mapping
2656 * function.
2657 */
2658 DECLR3CALLBACKMEMBER(void, pfnPhysReleasePageMappingLock,(PPDMDEVINS pDevIns, PPGMPAGEMAPLOCK pLock));
2659
2660 /**
2661 * Read guest physical memory by virtual address.
2662 *
2663 * @param pDevIns The device instance.
2664 * @param pvDst Where to put the read bits.
2665 * @param GCVirtSrc Guest virtual address to start reading from.
2666 * @param cb How many bytes to read.
2667 * @thread The emulation thread.
2668 */
2669 DECLR3CALLBACKMEMBER(int, pfnPhysReadGCVirt,(PPDMDEVINS pDevIns, void *pvDst, RTGCPTR GCVirtSrc, size_t cb));
2670
2671 /**
2672 * Write to guest physical memory by virtual address.
2673 *
2674 * @param pDevIns The device instance.
2675 * @param GCVirtDst Guest virtual address to write to.
2676 * @param pvSrc What to write.
2677 * @param cb How many bytes to write.
2678 * @thread The emulation thread.
2679 */
2680 DECLR3CALLBACKMEMBER(int, pfnPhysWriteGCVirt,(PPDMDEVINS pDevIns, RTGCPTR GCVirtDst, const void *pvSrc, size_t cb));
2681
2682 /**
2683 * Convert a guest virtual address to a guest physical address.
2684 *
2685 * @returns VBox status code.
2686 * @param pDevIns The device instance.
2687 * @param GCPtr Guest virtual address.
2688 * @param pGCPhys Where to store the GC physical address
2689 * corresponding to GCPtr.
2690 * @thread The emulation thread.
2691 * @remark Careful with page boundaries.
2692 */
2693 DECLR3CALLBACKMEMBER(int, pfnPhysGCPtr2GCPhys, (PPDMDEVINS pDevIns, RTGCPTR GCPtr, PRTGCPHYS pGCPhys));
2694
2695 /**
2696 * Allocate memory which is associated with current VM instance
2697 * and automatically freed on it's destruction.
2698 *
2699 * @returns Pointer to allocated memory. The memory is *NOT* zero-ed.
2700 * @param pDevIns The device instance.
2701 * @param cb Number of bytes to allocate.
2702 */
2703 DECLR3CALLBACKMEMBER(void *, pfnMMHeapAlloc,(PPDMDEVINS pDevIns, size_t cb));
2704
2705 /**
2706 * Allocate memory which is associated with current VM instance
2707 * and automatically freed on it's destruction. The memory is ZEROed.
2708 *
2709 * @returns Pointer to allocated memory. The memory is *NOT* zero-ed.
2710 * @param pDevIns The device instance.
2711 * @param cb Number of bytes to allocate.
2712 */
2713 DECLR3CALLBACKMEMBER(void *, pfnMMHeapAllocZ,(PPDMDEVINS pDevIns, size_t cb));
2714
2715 /**
2716 * Free memory allocated with pfnMMHeapAlloc() and pfnMMHeapAllocZ().
2717 *
2718 * @param pDevIns The device instance.
2719 * @param pv Pointer to the memory to free.
2720 */
2721 DECLR3CALLBACKMEMBER(void, pfnMMHeapFree,(PPDMDEVINS pDevIns, void *pv));
2722
2723 /**
2724 * Gets the VM state.
2725 *
2726 * @returns VM state.
2727 * @param pDevIns The device instance.
2728 * @thread Any thread (just keep in mind that it's volatile info).
2729 */
2730 DECLR3CALLBACKMEMBER(VMSTATE, pfnVMState, (PPDMDEVINS pDevIns));
2731
2732 /**
2733 * Checks if the VM was teleported and hasn't been fully resumed yet.
2734 *
2735 * @returns true / false.
2736 * @param pDevIns The device instance.
2737 * @thread Any thread.
2738 */
2739 DECLR3CALLBACKMEMBER(bool, pfnVMTeleportedAndNotFullyResumedYet,(PPDMDEVINS pDevIns));
2740
2741 /**
2742 * Set the VM error message
2743 *
2744 * @returns rc.
2745 * @param pDevIns The device instance.
2746 * @param rc VBox status code.
2747 * @param SRC_POS Use RT_SRC_POS.
2748 * @param pszFormat Error message format string.
2749 * @param ... Error message arguments.
2750 */
2751 DECLR3CALLBACKMEMBER(int, pfnVMSetError,(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL,
2752 const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(6, 7));
2753
2754 /**
2755 * Set the VM error message
2756 *
2757 * @returns rc.
2758 * @param pDevIns The device instance.
2759 * @param rc VBox status code.
2760 * @param SRC_POS Use RT_SRC_POS.
2761 * @param pszFormat Error message format string.
2762 * @param va Error message arguments.
2763 */
2764 DECLR3CALLBACKMEMBER(int, pfnVMSetErrorV,(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL,
2765 const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(6, 0));
2766
2767 /**
2768 * Set the VM runtime error message
2769 *
2770 * @returns VBox status code.
2771 * @param pDevIns The device instance.
2772 * @param fFlags The action flags. See VMSETRTERR_FLAGS_*.
2773 * @param pszErrorId Error ID string.
2774 * @param pszFormat Error message format string.
2775 * @param ... Error message arguments.
2776 */
2777 DECLR3CALLBACKMEMBER(int, pfnVMSetRuntimeError,(PPDMDEVINS pDevIns, uint32_t fFlags, const char *pszErrorId,
2778 const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(4, 5));
2779
2780 /**
2781 * Set the VM runtime error message
2782 *
2783 * @returns VBox status code.
2784 * @param pDevIns The device instance.
2785 * @param fFlags The action flags. See VMSETRTERR_FLAGS_*.
2786 * @param pszErrorId Error ID string.
2787 * @param pszFormat Error message format string.
2788 * @param va Error message arguments.
2789 */
2790 DECLR3CALLBACKMEMBER(int, pfnVMSetRuntimeErrorV,(PPDMDEVINS pDevIns, uint32_t fFlags, const char *pszErrorId,
2791 const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(4, 0));
2792
2793 /**
2794 * Stops the VM and enters the debugger to look at the guest state.
2795 *
2796 * Use the PDMDeviceDBGFStop() inline function with the RT_SRC_POS macro instead of
2797 * invoking this function directly.
2798 *
2799 * @returns VBox status code which must be passed up to the VMM.
2800 * @param pDevIns The device instance.
2801 * @param pszFile Filename of the assertion location.
2802 * @param iLine The linenumber of the assertion location.
2803 * @param pszFunction Function of the assertion location.
2804 * @param pszFormat Message. (optional)
2805 * @param args Message parameters.
2806 */
2807 DECLR3CALLBACKMEMBER(int, pfnDBGFStopV,(PPDMDEVINS pDevIns, const char *pszFile, unsigned iLine, const char *pszFunction,
2808 const char *pszFormat, va_list args) RT_IPRT_FORMAT_ATTR(5, 0));
2809
2810 /**
2811 * Register a info handler with DBGF.
2812 *
2813 * @returns VBox status code.
2814 * @param pDevIns The device instance.
2815 * @param pszName The identifier of the info.
2816 * @param pszDesc The description of the info and any arguments
2817 * the handler may take.
2818 * @param pfnHandler The handler function to be called to display the
2819 * info.
2820 */
2821 DECLR3CALLBACKMEMBER(int, pfnDBGFInfoRegister,(PPDMDEVINS pDevIns, const char *pszName, const char *pszDesc, PFNDBGFHANDLERDEV pfnHandler));
2822
2823 /**
2824 * Register a info handler with DBGF, argv style.
2825 *
2826 * @returns VBox status code.
2827 * @param pDevIns The device instance.
2828 * @param pszName The identifier of the info.
2829 * @param pszDesc The description of the info and any arguments
2830 * the handler may take.
2831 * @param pfnHandler The handler function to be called to display the
2832 * info.
2833 */
2834 DECLR3CALLBACKMEMBER(int, pfnDBGFInfoRegisterArgv,(PPDMDEVINS pDevIns, const char *pszName, const char *pszDesc, PFNDBGFINFOARGVDEV pfnHandler));
2835
2836 /**
2837 * Registers a set of registers for a device.
2838 *
2839 * The @a pvUser argument of the getter and setter callbacks will be
2840 * @a pDevIns. The register names will be prefixed by the device name followed
2841 * immediately by the instance number.
2842 *
2843 * @returns VBox status code.
2844 * @param pDevIns The device instance.
2845 * @param paRegisters The register descriptors.
2846 *
2847 * @remarks The device critical section is NOT entered prior to working the
2848 * callbacks registered via this helper!
2849 */
2850 DECLR3CALLBACKMEMBER(int, pfnDBGFRegRegister,(PPDMDEVINS pDevIns, PCDBGFREGDESC paRegisters));
2851
2852 /**
2853 * Gets the trace buffer handle.
2854 *
2855 * This is used by the macros found in VBox/vmm/dbgftrace.h and is not
2856 * really inteded for direct usage, thus no inline wrapper function.
2857 *
2858 * @returns Trace buffer handle or NIL_RTTRACEBUF.
2859 * @param pDevIns The device instance.
2860 */
2861 DECLR3CALLBACKMEMBER(RTTRACEBUF, pfnDBGFTraceBuf,(PPDMDEVINS pDevIns));
2862
2863 /**
2864 * Registers a statistics sample.
2865 *
2866 * @param pDevIns Device instance of the DMA.
2867 * @param pvSample Pointer to the sample.
2868 * @param enmType Sample type. This indicates what pvSample is
2869 * pointing at.
2870 * @param pszName Sample name, unix path style. If this does not
2871 * start with a '/', the default prefix will be
2872 * prepended, otherwise it will be used as-is.
2873 * @param enmUnit Sample unit.
2874 * @param pszDesc Sample description.
2875 */
2876 DECLR3CALLBACKMEMBER(void, pfnSTAMRegister,(PPDMDEVINS pDevIns, void *pvSample, STAMTYPE enmType, const char *pszName, STAMUNIT enmUnit, const char *pszDesc));
2877
2878 /**
2879 * Same as pfnSTAMRegister except that the name is specified in a
2880 * RTStrPrintfV like fashion.
2881 *
2882 * @returns VBox status.
2883 * @param pDevIns Device instance of the DMA.
2884 * @param pvSample Pointer to the sample.
2885 * @param enmType Sample type. This indicates what pvSample is
2886 * pointing at.
2887 * @param enmVisibility Visibility type specifying whether unused
2888 * statistics should be visible or not.
2889 * @param enmUnit Sample unit.
2890 * @param pszDesc Sample description.
2891 * @param pszName Sample name format string, unix path style. If
2892 * this does not start with a '/', the default
2893 * prefix will be prepended, otherwise it will be
2894 * used as-is.
2895 * @param args Arguments to the format string.
2896 */
2897 DECLR3CALLBACKMEMBER(void, pfnSTAMRegisterV,(PPDMDEVINS pDevIns, void *pvSample, STAMTYPE enmType,
2898 STAMVISIBILITY enmVisibility, STAMUNIT enmUnit, const char *pszDesc,
2899 const char *pszName, va_list args) RT_IPRT_FORMAT_ATTR(7, 0));
2900
2901 /**
2902 * Registers a PCI device with the default PCI bus.
2903 *
2904 * If a PDM device has more than one PCI device, they must be registered in the
2905 * order of PDMDEVINSR3::apPciDevs.
2906 *
2907 * @returns VBox status code.
2908 * @param pDevIns The device instance.
2909 * @param pPciDev The PCI device structure.
2910 * This must be kept in the instance data.
2911 * The PCI configuration must be initialized before registration.
2912 * @param fFlags 0, PDMPCIDEVREG_F_PCI_BRIDGE or
2913 * PDMPCIDEVREG_F_NOT_MANDATORY_NO.
2914 * @param uPciDevNo PDMPCIDEVREG_DEV_NO_FIRST_UNUSED,
2915 * PDMPCIDEVREG_DEV_NO_SAME_AS_PREV, or a specific
2916 * device number (0-31). This will be ignored if
2917 * the CFGM configuration contains a PCIDeviceNo
2918 * value.
2919 * @param uPciFunNo PDMPCIDEVREG_FUN_NO_FIRST_UNUSED, or a specific
2920 * function number (0-7). This will be ignored if
2921 * the CFGM configuration contains a PCIFunctionNo
2922 * value.
2923 * @param pszName Device name, if NULL PDMDEVREG::szName is used.
2924 * The pointer is saved, so don't free or changed.
2925 * @note The PCI device configuration is now implicit from the apPciDevs
2926 * index, meaning that the zero'th entry is the primary one and
2927 * subsequent uses CFGM subkeys "PciDev1", "PciDev2" and so on.
2928 */
2929 DECLR3CALLBACKMEMBER(int, pfnPCIRegister,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t fFlags,
2930 uint8_t uPciDevNo, uint8_t uPciFunNo, const char *pszName));
2931
2932 /**
2933 * Initialize MSI or MSI-X emulation support for the given PCI device.
2934 *
2935 * @see PDMPCIBUSREG::pfnRegisterMsiR3 for details.
2936 *
2937 * @returns VBox status code.
2938 * @param pDevIns The device instance.
2939 * @param pPciDev The PCI device. NULL is an alias for the first
2940 * one registered.
2941 * @param pMsiReg MSI emulation registration structure.
2942 */
2943 DECLR3CALLBACKMEMBER(int, pfnPCIRegisterMsi,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, PPDMMSIREG pMsiReg));
2944
2945 /**
2946 * Registers a I/O region (memory mapped or I/O ports) for a PCI device.
2947 *
2948 * @returns VBox status code.
2949 * @param pDevIns The device instance.
2950 * @param pPciDev The PCI device structure. If NULL the default
2951 * PCI device for this device instance is used.
2952 * @param iRegion The region number.
2953 * @param cbRegion Size of the region.
2954 * @param enmType PCI_ADDRESS_SPACE_MEM, PCI_ADDRESS_SPACE_IO or PCI_ADDRESS_SPACE_MEM_PREFETCH.
2955 * @param fFlags PDMPCIDEV_IORGN_F_XXX.
2956 * @param hHandle An I/O port, MMIO or MMIO2 handle according to
2957 * @a fFlags, UINT64_MAX if no handle is passed
2958 * (old style).
2959 * @param pfnMapUnmap Callback for doing the mapping, optional when a
2960 * handle is specified. The callback will be
2961 * invoked holding only the PDM lock. The device
2962 * lock will _not_ be taken (due to lock order).
2963 */
2964 DECLR3CALLBACKMEMBER(int, pfnPCIIORegionRegister,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion,
2965 RTGCPHYS cbRegion, PCIADDRESSSPACE enmType, uint32_t fFlags,
2966 uint64_t hHandle, PFNPCIIOREGIONMAP pfnMapUnmap));
2967
2968 /**
2969 * Register PCI configuration space read/write callbacks.
2970 *
2971 * @returns VBox status code.
2972 * @param pDevIns The device instance.
2973 * @param pPciDev The PCI device structure. If NULL the default
2974 * PCI device for this device instance is used.
2975 * @param pfnRead Pointer to the user defined PCI config read function.
2976 * to call default PCI config read function. Can be NULL.
2977 * @param pfnWrite Pointer to the user defined PCI config write function.
2978 * @remarks The callbacks will be invoked holding the PDM lock. The device lock
2979 * is NOT take because that is very likely be a lock order violation.
2980 * @thread EMT(0)
2981 * @note Only callable during VM creation.
2982 * @sa PDMDevHlpPCIConfigRead, PDMDevHlpPCIConfigWrite
2983 */
2984 DECLR3CALLBACKMEMBER(int, pfnPCIInterceptConfigAccesses,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev,
2985 PFNPCICONFIGREAD pfnRead, PFNPCICONFIGWRITE pfnWrite));
2986
2987 /**
2988 * Perform a PCI configuration space write.
2989 *
2990 * This is for devices that make use of PDMDevHlpPCIInterceptConfigAccesses().
2991 *
2992 * @returns Strict VBox status code (mainly DBGFSTOP).
2993 * @param pDevIns The device instance.
2994 * @param pPciDev The PCI device which config space is being read.
2995 * @param uAddress The config space address.
2996 * @param cb The size of the read: 1, 2 or 4 bytes.
2997 * @param u32Value The value to write.
2998 */
2999 DECLR3CALLBACKMEMBER(VBOXSTRICTRC, pfnPCIConfigWrite,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev,
3000 uint32_t uAddress, unsigned cb, uint32_t u32Value));
3001
3002 /**
3003 * Perform a PCI configuration space read.
3004 *
3005 * This is for devices that make use of PDMDevHlpPCIInterceptConfigAccesses().
3006 *
3007 * @returns Strict VBox status code (mainly DBGFSTOP).
3008 * @param pDevIns The device instance.
3009 * @param pPciDev The PCI device which config space is being read.
3010 * @param uAddress The config space address.
3011 * @param cb The size of the read: 1, 2 or 4 bytes.
3012 * @param pu32Value Where to return the value.
3013 */
3014 DECLR3CALLBACKMEMBER(VBOXSTRICTRC, pfnPCIConfigRead,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev,
3015 uint32_t uAddress, unsigned cb, uint32_t *pu32Value));
3016
3017 /**
3018 * Bus master physical memory read.
3019 *
3020 * @returns VINF_SUCCESS or VERR_PGM_PCI_PHYS_READ_BM_DISABLED, later maybe
3021 * VERR_EM_MEMORY. The informational status shall NOT be propagated!
3022 * @param pDevIns The device instance.
3023 * @param pPciDev The PCI device structure. If NULL the default
3024 * PCI device for this device instance is used.
3025 * @param GCPhys Physical address start reading from.
3026 * @param pvBuf Where to put the read bits.
3027 * @param cbRead How many bytes to read.
3028 * @thread Any thread, but the call may involve the emulation thread.
3029 */
3030 DECLR3CALLBACKMEMBER(int, pfnPCIPhysRead,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead));
3031
3032 /**
3033 * Bus master physical memory write.
3034 *
3035 * @returns VINF_SUCCESS or VERR_PGM_PCI_PHYS_WRITE_BM_DISABLED, later maybe
3036 * VERR_EM_MEMORY. The informational status shall NOT be propagated!
3037 * @param pDevIns The device instance.
3038 * @param pPciDev The PCI device structure. If NULL the default
3039 * PCI device for this device instance is used.
3040 * @param GCPhys Physical address to write to.
3041 * @param pvBuf What to write.
3042 * @param cbWrite How many bytes to write.
3043 * @thread Any thread, but the call may involve the emulation thread.
3044 */
3045 DECLR3CALLBACKMEMBER(int, pfnPCIPhysWrite,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite));
3046
3047 /**
3048 * Sets the IRQ for the given PCI device.
3049 *
3050 * @param pDevIns The device instance.
3051 * @param pPciDev The PCI device structure. If NULL the default
3052 * PCI device for this device instance is used.
3053 * @param iIrq IRQ number to set.
3054 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
3055 * @thread Any thread, but will involve the emulation thread.
3056 */
3057 DECLR3CALLBACKMEMBER(void, pfnPCISetIrq,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iIrq, int iLevel));
3058
3059 /**
3060 * Sets the IRQ for the given PCI device, but doesn't wait for EMT to process
3061 * the request when not called from EMT.
3062 *
3063 * @param pDevIns The device instance.
3064 * @param pPciDev The PCI device structure. If NULL the default
3065 * PCI device for this device instance is used.
3066 * @param iIrq IRQ number to set.
3067 * @param iLevel IRQ level.
3068 * @thread Any thread, but will involve the emulation thread.
3069 */
3070 DECLR3CALLBACKMEMBER(void, pfnPCISetIrqNoWait,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iIrq, int iLevel));
3071
3072 /**
3073 * Set ISA IRQ for a device.
3074 *
3075 * @param pDevIns The device instance.
3076 * @param iIrq IRQ number to set.
3077 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
3078 * @thread Any thread, but will involve the emulation thread.
3079 */
3080 DECLR3CALLBACKMEMBER(void, pfnISASetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
3081
3082 /**
3083 * Set the ISA IRQ for a device, but don't wait for EMT to process
3084 * the request when not called from EMT.
3085 *
3086 * @param pDevIns The device instance.
3087 * @param iIrq IRQ number to set.
3088 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
3089 * @thread Any thread, but will involve the emulation thread.
3090 */
3091 DECLR3CALLBACKMEMBER(void, pfnISASetIrqNoWait,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
3092
3093 /**
3094 * Send an MSI straight to the I/O APIC.
3095 *
3096 * @param pDevIns PCI device instance.
3097 * @param GCPhys Physical address MSI request was written.
3098 * @param uValue Value written.
3099 * @thread Any thread, but will involve the emulation thread.
3100 */
3101 DECLR3CALLBACKMEMBER(void, pfnIoApicSendMsi,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, uint32_t uValue));
3102
3103 /**
3104 * Attaches a driver (chain) to the device.
3105 *
3106 * The first call for a LUN this will serve as a registration of the LUN. The pBaseInterface and
3107 * the pszDesc string will be registered with that LUN and kept around for PDMR3QueryDeviceLun().
3108 *
3109 * @returns VBox status code.
3110 * @param pDevIns The device instance.
3111 * @param iLun The logical unit to attach.
3112 * @param pBaseInterface Pointer to the base interface for that LUN. (device side / down)
3113 * @param ppBaseInterface Where to store the pointer to the base interface. (driver side / up)
3114 * @param pszDesc Pointer to a string describing the LUN. This string must remain valid
3115 * for the live of the device instance.
3116 */
3117 DECLR3CALLBACKMEMBER(int, pfnDriverAttach,(PPDMDEVINS pDevIns, uint32_t iLun, PPDMIBASE pBaseInterface,
3118 PPDMIBASE *ppBaseInterface, const char *pszDesc));
3119
3120 /**
3121 * Detaches an attached driver (chain) from the device again.
3122 *
3123 * @returns VBox status code.
3124 * @param pDevIns The device instance.
3125 * @param pDrvIns The driver instance to detach.
3126 * @param fFlags Flags, combination of the PDMDEVATT_FLAGS_* \#defines.
3127 */
3128 DECLR3CALLBACKMEMBER(int, pfnDriverDetach,(PPDMDEVINS pDevIns, PPDMDRVINS pDrvIns, uint32_t fFlags));
3129
3130 /**
3131 * Reconfigures the driver chain for a LUN, detaching any driver currently
3132 * present there.
3133 *
3134 * Caller will have attach it, of course.
3135 *
3136 * @returns VBox status code.
3137 * @param pDevIns The device instance.
3138 * @param iLun The logical unit to reconfigure.
3139 * @param cDepth The depth of the driver chain. Determins the
3140 * size of @a papszDrivers and @a papConfigs.
3141 * @param papszDrivers The names of the drivers to configure in the
3142 * chain, first entry is the one immediately
3143 * below the device/LUN
3144 * @param papConfigs The configurations for each of the drivers
3145 * in @a papszDrivers array. NULL entries
3146 * corresponds to empty 'Config' nodes. This
3147 * function will take ownership of non-NULL
3148 * CFGM sub-trees and set the array member to
3149 * NULL, so the caller can do cleanups on
3150 * failure. This parameter is optional.
3151 * @param fFlags Reserved, MBZ.
3152 */
3153 DECLR3CALLBACKMEMBER(int, pfnDriverReconfigure,(PPDMDEVINS pDevIns, uint32_t iLun, uint32_t cDepth,
3154 const char * const *papszDrivers, PCFGMNODE *papConfigs, uint32_t fFlags));
3155
3156 /** @name Exported PDM Queue Functions
3157 * @{ */
3158 /**
3159 * Create a queue.
3160 *
3161 * @returns VBox status code.
3162 * @param pDevIns The device instance.
3163 * @param cbItem The size of a queue item.
3164 * @param cItems The number of items in the queue.
3165 * @param cMilliesInterval The number of milliseconds between polling the queue.
3166 * If 0 then the emulation thread will be notified whenever an item arrives.
3167 * @param pfnCallback The consumer function.
3168 * @param fRZEnabled Set if the queue should work in RC and R0.
3169 * @param pszName The queue base name. The instance number will be
3170 * appended automatically.
3171 * @param ppQueue Where to store the queue pointer on success.
3172 * @thread The emulation thread.
3173 * @remarks The device critical section will NOT be entered before calling the
3174 * callback. No locks will be held, but for now it's safe to assume
3175 * that only one EMT will do queue callbacks at any one time.
3176 */
3177 DECLR3CALLBACKMEMBER(int, pfnQueueCreatePtr,(PPDMDEVINS pDevIns, size_t cbItem, uint32_t cItems, uint32_t cMilliesInterval,
3178 PFNPDMQUEUEDEV pfnCallback, bool fRZEnabled, const char *pszName,
3179 PPDMQUEUE *ppQueue));
3180
3181 /**
3182 * Create a queue.
3183 *
3184 * @returns VBox status code.
3185 * @param pDevIns The device instance.
3186 * @param cbItem The size of a queue item.
3187 * @param cItems The number of items in the queue.
3188 * @param cMilliesInterval The number of milliseconds between polling the queue.
3189 * If 0 then the emulation thread will be notified whenever an item arrives.
3190 * @param pfnCallback The consumer function.
3191 * @param fRZEnabled Set if the queue should work in RC and R0.
3192 * @param pszName The queue base name. The instance number will be
3193 * appended automatically.
3194 * @param phQueue Where to store the queue handle on success.
3195 * @thread EMT(0)
3196 * @remarks The device critical section will NOT be entered before calling the
3197 * callback. No locks will be held, but for now it's safe to assume
3198 * that only one EMT will do queue callbacks at any one time.
3199 */
3200 DECLR3CALLBACKMEMBER(int, pfnQueueCreate,(PPDMDEVINS pDevIns, size_t cbItem, uint32_t cItems, uint32_t cMilliesInterval,
3201 PFNPDMQUEUEDEV pfnCallback, bool fRZEnabled, const char *pszName,
3202 PDMQUEUEHANDLE *phQueue));
3203
3204 DECLR3CALLBACKMEMBER(PPDMQUEUE, pfnQueueToPtr,(PPDMDEVINS pDevIns, PDMQUEUEHANDLE hQueue));
3205 DECLR3CALLBACKMEMBER(PPDMQUEUEITEMCORE, pfnQueueAlloc,(PPDMDEVINS pDevIns, PDMQUEUEHANDLE hQueue));
3206 DECLR3CALLBACKMEMBER(void, pfnQueueInsert,(PPDMDEVINS pDevIns, PDMQUEUEHANDLE hQueue, PPDMQUEUEITEMCORE pItem));
3207 DECLR3CALLBACKMEMBER(void, pfnQueueInsertEx,(PPDMDEVINS pDevIns, PDMQUEUEHANDLE hQueue, PPDMQUEUEITEMCORE pItem, uint64_t cNanoMaxDelay));
3208 DECLR3CALLBACKMEMBER(bool, pfnQueueFlushIfNecessary,(PPDMDEVINS pDevIns, PDMQUEUEHANDLE hQueue));
3209 /** @} */
3210
3211 /** @name PDM Task
3212 * @{ */
3213 /**
3214 * Create an asynchronous ring-3 task.
3215 *
3216 * @returns VBox status code.
3217 * @param pDevIns The device instance.
3218 * @param fFlags PDMTASK_F_XXX
3219 * @param pszName The function name or similar. Used for statistics,
3220 * so no slashes.
3221 * @param pfnCallback The task function.
3222 * @param pvUser User argument for the task function.
3223 * @param phTask Where to return the task handle.
3224 * @thread EMT(0)
3225 */
3226 DECLR3CALLBACKMEMBER(int, pfnTaskCreate,(PPDMDEVINS pDevIns, uint32_t fFlags, const char *pszName,
3227 PFNPDMTASKDEV pfnCallback, void *pvUser, PDMTASKHANDLE *phTask));
3228 /**
3229 * Triggers the running the given task.
3230 *
3231 * @returns VBox status code.
3232 * @retval VINF_ALREADY_POSTED is the task is already pending.
3233 * @param pDevIns The device instance.
3234 * @param hTask The task to trigger.
3235 * @thread Any thread.
3236 */
3237 DECLR3CALLBACKMEMBER(int, pfnTaskTrigger,(PPDMDEVINS pDevIns, PDMTASKHANDLE hTask));
3238 /** @} */
3239
3240 /** @name SUP Event Semaphore Wrappers (single release / auto reset)
3241 * These semaphores can be signalled from ring-0.
3242 * @{ */
3243 /** @sa SUPSemEventCreate */
3244 DECLR3CALLBACKMEMBER(int, pfnSUPSemEventCreate,(PPDMDEVINS pDevIns, PSUPSEMEVENT phEvent));
3245 /** @sa SUPSemEventClose */
3246 DECLR3CALLBACKMEMBER(int, pfnSUPSemEventClose,(PPDMDEVINS pDevIns, SUPSEMEVENT hEvent));
3247 /** @sa SUPSemEventSignal */
3248 DECLR3CALLBACKMEMBER(int, pfnSUPSemEventSignal,(PPDMDEVINS pDevIns, SUPSEMEVENT hEvent));
3249 /** @sa SUPSemEventWaitNoResume */
3250 DECLR3CALLBACKMEMBER(int, pfnSUPSemEventWaitNoResume,(PPDMDEVINS pDevIns, SUPSEMEVENT hEvent, uint32_t cMillies));
3251 /** @sa SUPSemEventWaitNsAbsIntr */
3252 DECLR3CALLBACKMEMBER(int, pfnSUPSemEventWaitNsAbsIntr,(PPDMDEVINS pDevIns, SUPSEMEVENT hEvent, uint64_t uNsTimeout));
3253 /** @sa SUPSemEventWaitNsRelIntr */
3254 DECLR3CALLBACKMEMBER(int, pfnSUPSemEventWaitNsRelIntr,(PPDMDEVINS pDevIns, SUPSEMEVENT hEvent, uint64_t cNsTimeout));
3255 /** @sa SUPSemEventGetResolution */
3256 DECLR3CALLBACKMEMBER(uint32_t, pfnSUPSemEventGetResolution,(PPDMDEVINS pDevIns));
3257 /** @} */
3258
3259 /** @name SUP Multi Event Semaphore Wrappers (multiple release / manual reset)
3260 * These semaphores can be signalled from ring-0.
3261 * @{ */
3262 /** @sa SUPSemEventMultiCreate */
3263 DECLR3CALLBACKMEMBER(int, pfnSUPSemEventMultiCreate,(PPDMDEVINS pDevIns, PSUPSEMEVENTMULTI phEventMulti));
3264 /** @sa SUPSemEventMultiClose */
3265 DECLR3CALLBACKMEMBER(int, pfnSUPSemEventMultiClose,(PPDMDEVINS pDevIns, SUPSEMEVENTMULTI hEventMulti));
3266 /** @sa SUPSemEventMultiSignal */
3267 DECLR3CALLBACKMEMBER(int, pfnSUPSemEventMultiSignal,(PPDMDEVINS pDevIns, SUPSEMEVENTMULTI hEventMulti));
3268 /** @sa SUPSemEventMultiReset */
3269 DECLR3CALLBACKMEMBER(int, pfnSUPSemEventMultiReset,(PPDMDEVINS pDevIns, SUPSEMEVENTMULTI hEventMulti));
3270 /** @sa SUPSemEventMultiWaitNoResume */
3271 DECLR3CALLBACKMEMBER(int, pfnSUPSemEventMultiWaitNoResume,(PPDMDEVINS pDevIns, SUPSEMEVENTMULTI hEventMulti, uint32_t cMillies));
3272 /** @sa SUPSemEventMultiWaitNsAbsIntr */
3273 DECLR3CALLBACKMEMBER(int, pfnSUPSemEventMultiWaitNsAbsIntr,(PPDMDEVINS pDevIns, SUPSEMEVENTMULTI hEventMulti, uint64_t uNsTimeout));
3274 /** @sa SUPSemEventMultiWaitNsRelIntr */
3275 DECLR3CALLBACKMEMBER(int, pfnSUPSemEventMultiWaitNsRelIntr,(PPDMDEVINS pDevIns, SUPSEMEVENTMULTI hEventMulti, uint64_t cNsTimeout));
3276 /** @sa SUPSemEventMultiGetResolution */
3277 DECLR3CALLBACKMEMBER(uint32_t, pfnSUPSemEventMultiGetResolution,(PPDMDEVINS pDevIns));
3278 /** @} */
3279
3280 /**
3281 * Initializes a PDM critical section.
3282 *
3283 * The PDM critical sections are derived from the IPRT critical sections, but
3284 * works in RC and R0 as well.
3285 *
3286 * @returns VBox status code.
3287 * @param pDevIns The device instance.
3288 * @param pCritSect Pointer to the critical section.
3289 * @param SRC_POS Use RT_SRC_POS.
3290 * @param pszNameFmt Format string for naming the critical section.
3291 * For statistics and lock validation.
3292 * @param va Arguments for the format string.
3293 */
3294 DECLR3CALLBACKMEMBER(int, pfnCritSectInit,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, RT_SRC_POS_DECL,
3295 const char *pszNameFmt, va_list va) RT_IPRT_FORMAT_ATTR(6, 0));
3296
3297 /**
3298 * Gets the NOP critical section.
3299 *
3300 * @returns The ring-3 address of the NOP critical section.
3301 * @param pDevIns The device instance.
3302 */
3303 DECLR3CALLBACKMEMBER(PPDMCRITSECT, pfnCritSectGetNop,(PPDMDEVINS pDevIns));
3304
3305 /**
3306 * Gets the NOP critical section.
3307 *
3308 * @returns The ring-0 address of the NOP critical section.
3309 * @param pDevIns The device instance.
3310 * @deprecated
3311 */
3312 DECLR3CALLBACKMEMBER(R0PTRTYPE(PPDMCRITSECT), pfnCritSectGetNopR0,(PPDMDEVINS pDevIns));
3313
3314 /**
3315 * Gets the NOP critical section.
3316 *
3317 * @returns The raw-mode context address of the NOP critical section.
3318 * @param pDevIns The device instance.
3319 * @deprecated
3320 */
3321 DECLR3CALLBACKMEMBER(RCPTRTYPE(PPDMCRITSECT), pfnCritSectGetNopRC,(PPDMDEVINS pDevIns));
3322
3323 /**
3324 * Changes the device level critical section from the automatically created
3325 * default to one desired by the device constructor.
3326 *
3327 * For ring-0 and raw-mode capable devices, the call must be repeated in each of
3328 * the additional contexts.
3329 *
3330 * @returns VBox status code.
3331 * @param pDevIns The device instance.
3332 * @param pCritSect The critical section to use. NULL is not
3333 * valid, instead use the NOP critical
3334 * section.
3335 */
3336 DECLR3CALLBACKMEMBER(int, pfnSetDeviceCritSect,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect));
3337
3338 /** @name Exported PDM Critical Section Functions
3339 * @{ */
3340 DECLR3CALLBACKMEMBER(bool, pfnCritSectYield,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect));
3341 DECLR3CALLBACKMEMBER(int, pfnCritSectEnter,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, int rcBusy));
3342 DECLR3CALLBACKMEMBER(int, pfnCritSectEnterDebug,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, int rcBusy, RTHCUINTPTR uId, RT_SRC_POS_DECL));
3343 DECLR3CALLBACKMEMBER(int, pfnCritSectTryEnter,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect));
3344 DECLR3CALLBACKMEMBER(int, pfnCritSectTryEnterDebug,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, RTHCUINTPTR uId, RT_SRC_POS_DECL));
3345 DECLR3CALLBACKMEMBER(int, pfnCritSectLeave,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect));
3346 DECLR3CALLBACKMEMBER(bool, pfnCritSectIsOwner,(PPDMDEVINS pDevIns, PCPDMCRITSECT pCritSect));
3347 DECLR3CALLBACKMEMBER(bool, pfnCritSectIsInitialized,(PPDMDEVINS pDevIns, PCPDMCRITSECT pCritSect));
3348 DECLR3CALLBACKMEMBER(bool, pfnCritSectHasWaiters,(PPDMDEVINS pDevIns, PCPDMCRITSECT pCritSect));
3349 DECLR3CALLBACKMEMBER(uint32_t, pfnCritSectGetRecursion,(PPDMDEVINS pDevIns, PCPDMCRITSECT pCritSect));
3350 DECLR3CALLBACKMEMBER(int, pfnCritSectScheduleExitEvent,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, SUPSEMEVENT hEventToSignal));
3351 DECLR3CALLBACKMEMBER(int, pfnCritSectDelete,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect));
3352 /** @} */
3353
3354 /**
3355 * Creates a PDM thread.
3356 *
3357 * This differs from the RTThreadCreate() API in that PDM takes care of suspending,
3358 * resuming, and destroying the thread as the VM state changes.
3359 *
3360 * @returns VBox status code.
3361 * @param pDevIns The device instance.
3362 * @param ppThread Where to store the thread 'handle'.
3363 * @param pvUser The user argument to the thread function.
3364 * @param pfnThread The thread function.
3365 * @param pfnWakeup The wakup callback. This is called on the EMT
3366 * thread when a state change is pending.
3367 * @param cbStack See RTThreadCreate.
3368 * @param enmType See RTThreadCreate.
3369 * @param pszName See RTThreadCreate.
3370 * @remarks The device critical section will NOT be entered prior to invoking
3371 * the function pointers.
3372 */
3373 DECLR3CALLBACKMEMBER(int, pfnThreadCreate,(PPDMDEVINS pDevIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADDEV pfnThread,
3374 PFNPDMTHREADWAKEUPDEV pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName));
3375
3376 /** @name Exported PDM Thread Functions
3377 * @{ */
3378 DECLR3CALLBACKMEMBER(int, pfnThreadDestroy,(PPDMTHREAD pThread, int *pRcThread));
3379 DECLR3CALLBACKMEMBER(int, pfnThreadIAmSuspending,(PPDMTHREAD pThread));
3380 DECLR3CALLBACKMEMBER(int, pfnThreadIAmRunning,(PPDMTHREAD pThread));
3381 DECLR3CALLBACKMEMBER(int, pfnThreadSleep,(PPDMTHREAD pThread, RTMSINTERVAL cMillies));
3382 DECLR3CALLBACKMEMBER(int, pfnThreadSuspend,(PPDMTHREAD pThread));
3383 DECLR3CALLBACKMEMBER(int, pfnThreadResume,(PPDMTHREAD pThread));
3384 /** @} */
3385
3386 /**
3387 * Set up asynchronous handling of a suspend, reset or power off notification.
3388 *
3389 * This shall only be called when getting the notification. It must be called
3390 * for each one.
3391 *
3392 * @returns VBox status code.
3393 * @param pDevIns The device instance.
3394 * @param pfnAsyncNotify The callback.
3395 * @thread EMT(0)
3396 * @remarks The caller will enter the device critical section prior to invoking
3397 * the callback.
3398 */
3399 DECLR3CALLBACKMEMBER(int, pfnSetAsyncNotification, (PPDMDEVINS pDevIns, PFNPDMDEVASYNCNOTIFY pfnAsyncNotify));
3400
3401 /**
3402 * Notify EMT(0) that the device has completed the asynchronous notification
3403 * handling.
3404 *
3405 * This can be called at any time, spurious calls will simply be ignored.
3406 *
3407 * @param pDevIns The device instance.
3408 * @thread Any
3409 */
3410 DECLR3CALLBACKMEMBER(void, pfnAsyncNotificationCompleted, (PPDMDEVINS pDevIns));
3411
3412 /**
3413 * Register the RTC device.
3414 *
3415 * @returns VBox status code.
3416 * @param pDevIns The device instance.
3417 * @param pRtcReg Pointer to a RTC registration structure.
3418 * @param ppRtcHlp Where to store the pointer to the helper
3419 * functions.
3420 */
3421 DECLR3CALLBACKMEMBER(int, pfnRTCRegister,(PPDMDEVINS pDevIns, PCPDMRTCREG pRtcReg, PCPDMRTCHLP *ppRtcHlp));
3422
3423 /**
3424 * Register a PCI Bus.
3425 *
3426 * @returns VBox status code, but the positive values 0..31 are used to indicate
3427 * bus number rather than informational status codes.
3428 * @param pDevIns The device instance.
3429 * @param pPciBusReg Pointer to PCI bus registration structure.
3430 * @param ppPciHlp Where to store the pointer to the PCI Bus
3431 * helpers.
3432 * @param piBus Where to return the PDM bus number. Optional.
3433 */
3434 DECLR3CALLBACKMEMBER(int, pfnPCIBusRegister,(PPDMDEVINS pDevIns, PPDMPCIBUSREGR3 pPciBusReg,
3435 PCPDMPCIHLPR3 *ppPciHlp, uint32_t *piBus));
3436
3437 /**
3438 * Register the PIC device.
3439 *
3440 * @returns VBox status code.
3441 * @param pDevIns The device instance.
3442 * @param pPicReg Pointer to a PIC registration structure.
3443 * @param ppPicHlp Where to store the pointer to the ring-3 PIC
3444 * helpers.
3445 * @sa PDMDevHlpPICSetUpContext
3446 */
3447 DECLR3CALLBACKMEMBER(int, pfnPICRegister,(PPDMDEVINS pDevIns, PPDMPICREG pPicReg, PCPDMPICHLP *ppPicHlp));
3448
3449 /**
3450 * Register the APIC device.
3451 *
3452 * @returns VBox status code.
3453 * @param pDevIns The device instance.
3454 */
3455 DECLR3CALLBACKMEMBER(int, pfnApicRegister,(PPDMDEVINS pDevIns));
3456
3457 /**
3458 * Register the I/O APIC device.
3459 *
3460 * @returns VBox status code.
3461 * @param pDevIns The device instance.
3462 * @param pIoApicReg Pointer to a I/O APIC registration structure.
3463 * @param ppIoApicHlp Where to store the pointer to the IOAPIC
3464 * helpers.
3465 */
3466 DECLR3CALLBACKMEMBER(int, pfnIoApicRegister,(PPDMDEVINS pDevIns, PPDMIOAPICREG pIoApicReg, PCPDMIOAPICHLP *ppIoApicHlp));
3467
3468 /**
3469 * Register the HPET device.
3470 *
3471 * @returns VBox status code.
3472 * @param pDevIns The device instance.
3473 * @param pHpetReg Pointer to a HPET registration structure.
3474 * @param ppHpetHlpR3 Where to store the pointer to the HPET
3475 * helpers.
3476 */
3477 DECLR3CALLBACKMEMBER(int, pfnHpetRegister,(PPDMDEVINS pDevIns, PPDMHPETREG pHpetReg, PCPDMHPETHLPR3 *ppHpetHlpR3));
3478
3479 /**
3480 * Register a raw PCI device.
3481 *
3482 * @returns VBox status code.
3483 * @param pDevIns The device instance.
3484 * @param pPciRawReg Pointer to a raw PCI registration structure.
3485 * @param ppPciRawHlpR3 Where to store the pointer to the raw PCI
3486 * device helpers.
3487 */
3488 DECLR3CALLBACKMEMBER(int, pfnPciRawRegister,(PPDMDEVINS pDevIns, PPDMPCIRAWREG pPciRawReg, PCPDMPCIRAWHLPR3 *ppPciRawHlpR3));
3489
3490 /**
3491 * Register the DMA device.
3492 *
3493 * @returns VBox status code.
3494 * @param pDevIns The device instance.
3495 * @param pDmacReg Pointer to a DMAC registration structure.
3496 * @param ppDmacHlp Where to store the pointer to the DMA helpers.
3497 */
3498 DECLR3CALLBACKMEMBER(int, pfnDMACRegister,(PPDMDEVINS pDevIns, PPDMDMACREG pDmacReg, PCPDMDMACHLP *ppDmacHlp));
3499
3500 /**
3501 * Register transfer function for DMA channel.
3502 *
3503 * @returns VBox status code.
3504 * @param pDevIns The device instance.
3505 * @param uChannel Channel number.
3506 * @param pfnTransferHandler Device specific transfer callback function.
3507 * @param pvUser User pointer to pass to the callback.
3508 * @thread EMT
3509 */
3510 DECLR3CALLBACKMEMBER(int, pfnDMARegister,(PPDMDEVINS pDevIns, unsigned uChannel, PFNDMATRANSFERHANDLER pfnTransferHandler, void *pvUser));
3511
3512 /**
3513 * Read memory.
3514 *
3515 * @returns VBox status code.
3516 * @param pDevIns The device instance.
3517 * @param uChannel Channel number.
3518 * @param pvBuffer Pointer to target buffer.
3519 * @param off DMA position.
3520 * @param cbBlock Block size.
3521 * @param pcbRead Where to store the number of bytes which was
3522 * read. optional.
3523 * @thread EMT
3524 */
3525 DECLR3CALLBACKMEMBER(int, pfnDMAReadMemory,(PPDMDEVINS pDevIns, unsigned uChannel, void *pvBuffer, uint32_t off, uint32_t cbBlock, uint32_t *pcbRead));
3526
3527 /**
3528 * Write memory.
3529 *
3530 * @returns VBox status code.
3531 * @param pDevIns The device instance.
3532 * @param uChannel Channel number.
3533 * @param pvBuffer Memory to write.
3534 * @param off DMA position.
3535 * @param cbBlock Block size.
3536 * @param pcbWritten Where to store the number of bytes which was
3537 * written. optional.
3538 * @thread EMT
3539 */
3540 DECLR3CALLBACKMEMBER(int, pfnDMAWriteMemory,(PPDMDEVINS pDevIns, unsigned uChannel, const void *pvBuffer, uint32_t off, uint32_t cbBlock, uint32_t *pcbWritten));
3541
3542 /**
3543 * Set the DREQ line.
3544 *
3545 * @returns VBox status code.
3546 * @param pDevIns Device instance.
3547 * @param uChannel Channel number.
3548 * @param uLevel Level of the line.
3549 * @thread EMT
3550 */
3551 DECLR3CALLBACKMEMBER(int, pfnDMASetDREQ,(PPDMDEVINS pDevIns, unsigned uChannel, unsigned uLevel));
3552
3553 /**
3554 * Get channel mode.
3555 *
3556 * @returns Channel mode. See specs.
3557 * @param pDevIns The device instance.
3558 * @param uChannel Channel number.
3559 * @thread EMT
3560 */
3561 DECLR3CALLBACKMEMBER(uint8_t, pfnDMAGetChannelMode,(PPDMDEVINS pDevIns, unsigned uChannel));
3562
3563 /**
3564 * Schedule DMA execution.
3565 *
3566 * @param pDevIns The device instance.
3567 * @thread Any thread.
3568 */
3569 DECLR3CALLBACKMEMBER(void, pfnDMASchedule,(PPDMDEVINS pDevIns));
3570
3571 /**
3572 * Write CMOS value and update the checksum(s).
3573 *
3574 * @returns VBox status code.
3575 * @param pDevIns The device instance.
3576 * @param iReg The CMOS register index.
3577 * @param u8Value The CMOS register value.
3578 * @thread EMT
3579 */
3580 DECLR3CALLBACKMEMBER(int, pfnCMOSWrite,(PPDMDEVINS pDevIns, unsigned iReg, uint8_t u8Value));
3581
3582 /**
3583 * Read CMOS value.
3584 *
3585 * @returns VBox status code.
3586 * @param pDevIns The device instance.
3587 * @param iReg The CMOS register index.
3588 * @param pu8Value Where to store the CMOS register value.
3589 * @thread EMT
3590 */
3591 DECLR3CALLBACKMEMBER(int, pfnCMOSRead,(PPDMDEVINS pDevIns, unsigned iReg, uint8_t *pu8Value));
3592
3593 /**
3594 * Assert that the current thread is the emulation thread.
3595 *
3596 * @returns True if correct.
3597 * @returns False if wrong.
3598 * @param pDevIns The device instance.
3599 * @param pszFile Filename of the assertion location.
3600 * @param iLine The linenumber of the assertion location.
3601 * @param pszFunction Function of the assertion location.
3602 */
3603 DECLR3CALLBACKMEMBER(bool, pfnAssertEMT,(PPDMDEVINS pDevIns, const char *pszFile, unsigned iLine, const char *pszFunction));
3604
3605 /**
3606 * Assert that the current thread is NOT the emulation thread.
3607 *
3608 * @returns True if correct.
3609 * @returns False if wrong.
3610 * @param pDevIns The device instance.
3611 * @param pszFile Filename of the assertion location.
3612 * @param iLine The linenumber of the assertion location.
3613 * @param pszFunction Function of the assertion location.
3614 */
3615 DECLR3CALLBACKMEMBER(bool, pfnAssertOther,(PPDMDEVINS pDevIns, const char *pszFile, unsigned iLine, const char *pszFunction));
3616
3617 /**
3618 * Resolves the symbol for a raw-mode context interface.
3619 *
3620 * @returns VBox status code.
3621 * @param pDevIns The device instance.
3622 * @param pvInterface The interface structure.
3623 * @param cbInterface The size of the interface structure.
3624 * @param pszSymPrefix What to prefix the symbols in the list with
3625 * before resolving them. This must start with
3626 * 'dev' and contain the driver name.
3627 * @param pszSymList List of symbols corresponding to the interface.
3628 * There is generally a there is generally a define
3629 * holding this list associated with the interface
3630 * definition (INTERFACE_SYM_LIST). For more
3631 * details see PDMR3LdrGetInterfaceSymbols.
3632 * @thread EMT
3633 */
3634 DECLR3CALLBACKMEMBER(int, pfnLdrGetRCInterfaceSymbols,(PPDMDEVINS pDevIns, void *pvInterface, size_t cbInterface,
3635 const char *pszSymPrefix, const char *pszSymList));
3636
3637 /**
3638 * Resolves the symbol for a ring-0 context interface.
3639 *
3640 * @returns VBox status code.
3641 * @param pDevIns The device instance.
3642 * @param pvInterface The interface structure.
3643 * @param cbInterface The size of the interface structure.
3644 * @param pszSymPrefix What to prefix the symbols in the list with
3645 * before resolving them. This must start with
3646 * 'dev' and contain the driver name.
3647 * @param pszSymList List of symbols corresponding to the interface.
3648 * There is generally a there is generally a define
3649 * holding this list associated with the interface
3650 * definition (INTERFACE_SYM_LIST). For more
3651 * details see PDMR3LdrGetInterfaceSymbols.
3652 * @thread EMT
3653 */
3654 DECLR3CALLBACKMEMBER(int, pfnLdrGetR0InterfaceSymbols,(PPDMDEVINS pDevIns, void *pvInterface, size_t cbInterface,
3655 const char *pszSymPrefix, const char *pszSymList));
3656
3657 /**
3658 * Calls the PDMDEVREGR0::pfnRequest callback (in ring-0 context).
3659 *
3660 * @returns VBox status code.
3661 * @retval VERR_INVALID_FUNCTION if the callback member is NULL.
3662 * @retval VERR_ACCESS_DENIED if the device isn't ring-0 capable.
3663 *
3664 * @param pDevIns The device instance.
3665 * @param uOperation The operation to perform.
3666 * @param u64Arg 64-bit integer argument.
3667 * @thread EMT
3668 */
3669 DECLR3CALLBACKMEMBER(int, pfnCallR0,(PPDMDEVINS pDevIns, uint32_t uOperation, uint64_t u64Arg));
3670
3671 /**
3672 * Gets the reason for the most recent VM suspend.
3673 *
3674 * @returns The suspend reason. VMSUSPENDREASON_INVALID is returned if no
3675 * suspend has been made or if the pDevIns is invalid.
3676 * @param pDevIns The device instance.
3677 */
3678 DECLR3CALLBACKMEMBER(VMSUSPENDREASON, pfnVMGetSuspendReason,(PPDMDEVINS pDevIns));
3679
3680 /**
3681 * Gets the reason for the most recent VM resume.
3682 *
3683 * @returns The resume reason. VMRESUMEREASON_INVALID is returned if no
3684 * resume has been made or if the pDevIns is invalid.
3685 * @param pDevIns The device instance.
3686 */
3687 DECLR3CALLBACKMEMBER(VMRESUMEREASON, pfnVMGetResumeReason,(PPDMDEVINS pDevIns));
3688
3689 /**
3690 * Requests the mapping of multiple guest page into ring-3.
3691 *
3692 * When you're done with the pages, call pfnPhysBulkReleasePageMappingLocks()
3693 * ASAP to release them.
3694 *
3695 * This API will assume your intention is to write to the pages, and will
3696 * therefore replace shared and zero pages. If you do not intend to modify the
3697 * pages, use the pfnPhysBulkGCPhys2CCPtrReadOnly() API.
3698 *
3699 * @returns VBox status code.
3700 * @retval VINF_SUCCESS on success.
3701 * @retval VERR_PGM_PHYS_PAGE_RESERVED if any of the pages has no physical
3702 * backing or if any of the pages the page has any active access
3703 * handlers. The caller must fall back on using PGMR3PhysWriteExternal.
3704 * @retval VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS if @a paGCPhysPages contains
3705 * an invalid physical address.
3706 *
3707 * @param pDevIns The device instance.
3708 * @param cPages Number of pages to lock.
3709 * @param paGCPhysPages The guest physical address of the pages that
3710 * should be mapped (@a cPages entries).
3711 * @param fFlags Flags reserved for future use, MBZ.
3712 * @param papvPages Where to store the ring-3 mapping addresses
3713 * corresponding to @a paGCPhysPages.
3714 * @param paLocks Where to store the locking information that
3715 * pfnPhysBulkReleasePageMappingLock needs (@a cPages
3716 * in length).
3717 *
3718 * @remark Avoid calling this API from within critical sections (other than the
3719 * PGM one) because of the deadlock risk when we have to delegating the
3720 * task to an EMT.
3721 * @thread Any.
3722 * @since 6.0.6
3723 */
3724 DECLR3CALLBACKMEMBER(int, pfnPhysBulkGCPhys2CCPtr,(PPDMDEVINS pDevIns, uint32_t cPages, PCRTGCPHYS paGCPhysPages,
3725 uint32_t fFlags, void **papvPages, PPGMPAGEMAPLOCK paLocks));
3726
3727 /**
3728 * Requests the mapping of multiple guest page into ring-3, for reading only.
3729 *
3730 * When you're done with the pages, call pfnPhysBulkReleasePageMappingLocks()
3731 * ASAP to release them.
3732 *
3733 * @returns VBox status code.
3734 * @retval VINF_SUCCESS on success.
3735 * @retval VERR_PGM_PHYS_PAGE_RESERVED if any of the pages has no physical
3736 * backing or if any of the pages the page has an active ALL access
3737 * handler. The caller must fall back on using PGMR3PhysWriteExternal.
3738 * @retval VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS if @a paGCPhysPages contains
3739 * an invalid physical address.
3740 *
3741 * @param pDevIns The device instance.
3742 * @param cPages Number of pages to lock.
3743 * @param paGCPhysPages The guest physical address of the pages that
3744 * should be mapped (@a cPages entries).
3745 * @param fFlags Flags reserved for future use, MBZ.
3746 * @param papvPages Where to store the ring-3 mapping addresses
3747 * corresponding to @a paGCPhysPages.
3748 * @param paLocks Where to store the lock information that
3749 * pfnPhysReleasePageMappingLock needs (@a cPages
3750 * in length).
3751 *
3752 * @remark Avoid calling this API from within critical sections.
3753 * @thread Any.
3754 * @since 6.0.6
3755 */
3756 DECLR3CALLBACKMEMBER(int, pfnPhysBulkGCPhys2CCPtrReadOnly,(PPDMDEVINS pDevIns, uint32_t cPages, PCRTGCPHYS paGCPhysPages,
3757 uint32_t fFlags, void const **papvPages, PPGMPAGEMAPLOCK paLocks));
3758
3759 /**
3760 * Release the mappings of multiple guest pages.
3761 *
3762 * This is the counter part of pfnPhysBulkGCPhys2CCPtr and
3763 * pfnPhysBulkGCPhys2CCPtrReadOnly.
3764 *
3765 * @param pDevIns The device instance.
3766 * @param cPages Number of pages to unlock.
3767 * @param paLocks The lock structures initialized by the mapping
3768 * function (@a cPages in length).
3769 * @thread Any.
3770 * @since 6.0.6
3771 */
3772 DECLR3CALLBACKMEMBER(void, pfnPhysBulkReleasePageMappingLocks,(PPDMDEVINS pDevIns, uint32_t cPages, PPGMPAGEMAPLOCK paLocks));
3773
3774 /** Space reserved for future members.
3775 * @{ */
3776 DECLR3CALLBACKMEMBER(void, pfnReserved1,(void));
3777 DECLR3CALLBACKMEMBER(void, pfnReserved2,(void));
3778 DECLR3CALLBACKMEMBER(void, pfnReserved3,(void));
3779 DECLR3CALLBACKMEMBER(void, pfnReserved4,(void));
3780 DECLR3CALLBACKMEMBER(void, pfnReserved5,(void));
3781 DECLR3CALLBACKMEMBER(void, pfnReserved6,(void));
3782 DECLR3CALLBACKMEMBER(void, pfnReserved7,(void));
3783 DECLR3CALLBACKMEMBER(void, pfnReserved8,(void));
3784 DECLR3CALLBACKMEMBER(void, pfnReserved9,(void));
3785 DECLR3CALLBACKMEMBER(void, pfnReserved10,(void));
3786 /** @} */
3787
3788
3789 /** API available to trusted devices only.
3790 *
3791 * These APIs are providing unrestricted access to the guest and the VM,
3792 * or they are interacting intimately with PDM.
3793 *
3794 * @{
3795 */
3796
3797 /**
3798 * Gets the user mode VM handle. Restricted API.
3799 *
3800 * @returns User mode VM Handle.
3801 * @param pDevIns The device instance.
3802 */
3803 DECLR3CALLBACKMEMBER(PUVM, pfnGetUVM,(PPDMDEVINS pDevIns));
3804
3805 /**
3806 * Gets the global VM handle. Restricted API.
3807 *
3808 * @returns VM Handle.
3809 * @param pDevIns The device instance.
3810 */
3811 DECLR3CALLBACKMEMBER(PVMCC, pfnGetVM,(PPDMDEVINS pDevIns));
3812
3813 /**
3814 * Gets the VMCPU handle. Restricted API.
3815 *
3816 * @returns VMCPU Handle.
3817 * @param pDevIns The device instance.
3818 */
3819 DECLR3CALLBACKMEMBER(PVMCPU, pfnGetVMCPU,(PPDMDEVINS pDevIns));
3820
3821 /**
3822 * The the VM CPU ID of the current thread (restricted API).
3823 *
3824 * @returns The VMCPUID of the calling thread, NIL_VMCPUID if not EMT.
3825 * @param pDevIns The device instance.
3826 */
3827 DECLR3CALLBACKMEMBER(VMCPUID, pfnGetCurrentCpuId,(PPDMDEVINS pDevIns));
3828
3829 /**
3830 * Registers the VMM device heap or notifies about mapping/unmapping.
3831 *
3832 * This interface serves three purposes:
3833 *
3834 * -# Register the VMM device heap during device construction
3835 * for the HM to use.
3836 * -# Notify PDM/HM that it's mapped into guest address
3837 * space (i.e. usable).
3838 * -# Notify PDM/HM that it is being unmapped from the guest
3839 * address space (i.e. not usable).
3840 *
3841 * @returns VBox status code.
3842 * @param pDevIns The device instance.
3843 * @param GCPhys The physical address if mapped, NIL_RTGCPHYS if
3844 * not mapped.
3845 * @param pvHeap Ring 3 heap pointer.
3846 * @param cbHeap Size of the heap.
3847 * @thread EMT.
3848 */
3849 DECLR3CALLBACKMEMBER(int, pfnRegisterVMMDevHeap,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTR3PTR pvHeap, unsigned cbHeap));
3850
3851 /**
3852 * Registers the firmware (BIOS, EFI) device with PDM.
3853 *
3854 * The firmware provides a callback table and gets a special PDM helper table.
3855 * There can only be one firmware device for a VM.
3856 *
3857 * @returns VBox status code.
3858 * @param pDevIns The device instance.
3859 * @param pFwReg Firmware registration structure.
3860 * @param ppFwHlp Where to return the firmware helper structure.
3861 * @remarks Only valid during device construction.
3862 * @thread EMT(0)
3863 */
3864 DECLR3CALLBACKMEMBER(int, pfnFirmwareRegister,(PPDMDEVINS pDevIns, PCPDMFWREG pFwReg, PCPDMFWHLPR3 *ppFwHlp));
3865
3866 /**
3867 * Resets the VM.
3868 *
3869 * @returns The appropriate VBox status code to pass around on reset.
3870 * @param pDevIns The device instance.
3871 * @param fFlags PDMVMRESET_F_XXX flags.
3872 * @thread The emulation thread.
3873 */
3874 DECLR3CALLBACKMEMBER(int, pfnVMReset,(PPDMDEVINS pDevIns, uint32_t fFlags));
3875
3876 /**
3877 * Suspends the VM.
3878 *
3879 * @returns The appropriate VBox status code to pass around on suspend.
3880 * @param pDevIns The device instance.
3881 * @thread The emulation thread.
3882 */
3883 DECLR3CALLBACKMEMBER(int, pfnVMSuspend,(PPDMDEVINS pDevIns));
3884
3885 /**
3886 * Suspends, saves and powers off the VM.
3887 *
3888 * @returns The appropriate VBox status code to pass around.
3889 * @param pDevIns The device instance.
3890 * @thread An emulation thread.
3891 */
3892 DECLR3CALLBACKMEMBER(int, pfnVMSuspendSaveAndPowerOff,(PPDMDEVINS pDevIns));
3893
3894 /**
3895 * Power off the VM.
3896 *
3897 * @returns The appropriate VBox status code to pass around on power off.
3898 * @param pDevIns The device instance.
3899 * @thread The emulation thread.
3900 */
3901 DECLR3CALLBACKMEMBER(int, pfnVMPowerOff,(PPDMDEVINS pDevIns));
3902
3903 /**
3904 * Checks if the Gate A20 is enabled or not.
3905 *
3906 * @returns true if A20 is enabled.
3907 * @returns false if A20 is disabled.
3908 * @param pDevIns The device instance.
3909 * @thread The emulation thread.
3910 */
3911 DECLR3CALLBACKMEMBER(bool, pfnA20IsEnabled,(PPDMDEVINS pDevIns));
3912
3913 /**
3914 * Enables or disables the Gate A20.
3915 *
3916 * @param pDevIns The device instance.
3917 * @param fEnable Set this flag to enable the Gate A20; clear it
3918 * to disable.
3919 * @thread The emulation thread.
3920 */
3921 DECLR3CALLBACKMEMBER(void, pfnA20Set,(PPDMDEVINS pDevIns, bool fEnable));
3922
3923 /**
3924 * Get the specified CPUID leaf for the virtual CPU associated with the calling
3925 * thread.
3926 *
3927 * @param pDevIns The device instance.
3928 * @param iLeaf The CPUID leaf to get.
3929 * @param pEax Where to store the EAX value.
3930 * @param pEbx Where to store the EBX value.
3931 * @param pEcx Where to store the ECX value.
3932 * @param pEdx Where to store the EDX value.
3933 * @thread EMT.
3934 */
3935 DECLR3CALLBACKMEMBER(void, pfnGetCpuId,(PPDMDEVINS pDevIns, uint32_t iLeaf, uint32_t *pEax, uint32_t *pEbx, uint32_t *pEcx, uint32_t *pEdx));
3936
3937 /**
3938 * Get the current virtual clock time in a VM. The clock frequency must be
3939 * queried separately.
3940 *
3941 * @returns Current clock time.
3942 * @param pDevIns The device instance.
3943 */
3944 DECLR3CALLBACKMEMBER(uint64_t, pfnTMTimeVirtGet,(PPDMDEVINS pDevIns));
3945
3946 /**
3947 * Get the frequency of the virtual clock.
3948 *
3949 * @returns The clock frequency (not variable at run-time).
3950 * @param pDevIns The device instance.
3951 */
3952 DECLR3CALLBACKMEMBER(uint64_t, pfnTMTimeVirtGetFreq,(PPDMDEVINS pDevIns));
3953
3954 /**
3955 * Get the current virtual clock time in a VM, in nanoseconds.
3956 *
3957 * @returns Current clock time (in ns).
3958 * @param pDevIns The device instance.
3959 */
3960 DECLR3CALLBACKMEMBER(uint64_t, pfnTMTimeVirtGetNano,(PPDMDEVINS pDevIns));
3961
3962 /**
3963 * Gets the support driver session.
3964 *
3965 * This is intended for working with the semaphore API.
3966 *
3967 * @returns Support driver session handle.
3968 * @param pDevIns The device instance.
3969 */
3970 DECLR3CALLBACKMEMBER(PSUPDRVSESSION, pfnGetSupDrvSession,(PPDMDEVINS pDevIns));
3971
3972 /**
3973 * Queries a generic object from the VMM user.
3974 *
3975 * @returns Pointer to the object if found, NULL if not.
3976 * @param pDevIns The device instance.
3977 * @param pUuid The UUID of what's being queried. The UUIDs and
3978 * the usage conventions are defined by the user.
3979 *
3980 * @note It is strictly forbidden to call this internally in VBox! This
3981 * interface is exclusively for hacks in externally developed devices.
3982 */
3983 DECLR3CALLBACKMEMBER(void *, pfnQueryGenericUserObject,(PPDMDEVINS pDevIns, PCRTUUID pUuid));
3984
3985 /** @} */
3986
3987 /** Just a safety precaution. (PDM_DEVHLPR3_VERSION) */
3988 uint32_t u32TheEnd;
3989} PDMDEVHLPR3;
3990#endif /* !IN_RING3 || DOXYGEN_RUNNING */
3991/** Pointer to the R3 PDM Device API. */
3992typedef R3PTRTYPE(struct PDMDEVHLPR3 *) PPDMDEVHLPR3;
3993/** Pointer to the R3 PDM Device API, const variant. */
3994typedef R3PTRTYPE(const struct PDMDEVHLPR3 *) PCPDMDEVHLPR3;
3995
3996
3997/**
3998 * PDM Device API - RC Variant.
3999 */
4000typedef struct PDMDEVHLPRC
4001{
4002 /** Structure version. PDM_DEVHLPRC_VERSION defines the current version. */
4003 uint32_t u32Version;
4004
4005 /**
4006 * Sets up raw-mode context callback handlers for an I/O port range.
4007 *
4008 * The range must have been registered in ring-3 first using
4009 * PDMDevHlpIoPortCreate() or PDMDevHlpIoPortCreateEx().
4010 *
4011 * @returns VBox status.
4012 * @param pDevIns The device instance to register the ports with.
4013 * @param hIoPorts The I/O port range handle.
4014 * @param pfnOut Pointer to function which is gonna handle OUT
4015 * operations. Optional.
4016 * @param pfnIn Pointer to function which is gonna handle IN operations.
4017 * Optional.
4018 * @param pfnOutStr Pointer to function which is gonna handle string OUT
4019 * operations. Optional.
4020 * @param pfnInStr Pointer to function which is gonna handle string IN
4021 * operations. Optional.
4022 * @param pvUser User argument to pass to the callbacks.
4023 *
4024 * @remarks Caller enters the device critical section prior to invoking the
4025 * registered callback methods.
4026 *
4027 * @sa PDMDevHlpIoPortCreate, PDMDevHlpIoPortCreateEx, PDMDevHlpIoPortMap,
4028 * PDMDevHlpIoPortUnmap.
4029 */
4030 DECLRCCALLBACKMEMBER(int, pfnIoPortSetUpContextEx,(PPDMDEVINS pDevIns, IOMIOPORTHANDLE hIoPorts,
4031 PFNIOMIOPORTNEWOUT pfnOut, PFNIOMIOPORTNEWIN pfnIn,
4032 PFNIOMIOPORTNEWOUTSTRING pfnOutStr, PFNIOMIOPORTNEWINSTRING pfnInStr,
4033 void *pvUser));
4034
4035 /**
4036 * Sets up raw-mode context callback handlers for an MMIO region.
4037 *
4038 * The region must have been registered in ring-3 first using
4039 * PDMDevHlpMmioCreate() or PDMDevHlpMmioCreateEx().
4040 *
4041 * @returns VBox status.
4042 * @param pDevIns The device instance to register the ports with.
4043 * @param hRegion The MMIO region handle.
4044 * @param pfnWrite Pointer to function which is gonna handle Write
4045 * operations.
4046 * @param pfnRead Pointer to function which is gonna handle Read
4047 * operations.
4048 * @param pfnFill Pointer to function which is gonna handle Fill/memset
4049 * operations. (optional)
4050 * @param pvUser User argument to pass to the callbacks.
4051 *
4052 * @remarks Caller enters the device critical section prior to invoking the
4053 * registered callback methods.
4054 *
4055 * @sa PDMDevHlpMmioCreate, PDMDevHlpMmioCreateEx, PDMDevHlpMmioMap,
4056 * PDMDevHlpMmioUnmap.
4057 */
4058 DECLRCCALLBACKMEMBER(int, pfnMmioSetUpContextEx,(PPDMDEVINS pDevIns, IOMMMIOHANDLE hRegion, PFNIOMMMIONEWWRITE pfnWrite,
4059 PFNIOMMMIONEWREAD pfnRead, PFNIOMMMIONEWFILL pfnFill, void *pvUser));
4060
4061 /**
4062 * Sets up a raw-mode mapping for an MMIO2 region.
4063 *
4064 * The region must have been created in ring-3 first using
4065 * PDMDevHlpMmio2Create().
4066 *
4067 * @returns VBox status.
4068 * @param pDevIns The device instance to register the ports with.
4069 * @param hRegion The MMIO2 region handle.
4070 * @param offSub Start of what to map into raw-mode. Must be page aligned.
4071 * @param cbSub Number of bytes to map into raw-mode. Must be page
4072 * aligned. Zero is an alias for everything.
4073 * @param ppvMapping Where to return the mapping corresponding to @a offSub.
4074 * @thread EMT(0)
4075 * @note Only available at VM creation time.
4076 *
4077 * @sa PDMDevHlpMmio2Create().
4078 */
4079 DECLRCCALLBACKMEMBER(int, pfnMmio2SetUpContext,(PPDMDEVINS pDevIns, PGMMMIO2HANDLE hRegion,
4080 size_t offSub, size_t cbSub, void **ppvMapping));
4081
4082 /**
4083 * Bus master physical memory read from the given PCI device.
4084 *
4085 * @returns VINF_SUCCESS or VERR_PGM_PCI_PHYS_READ_BM_DISABLED, later maybe
4086 * VERR_EM_MEMORY. The informational status shall NOT be propagated!
4087 * @param pDevIns The device instance.
4088 * @param pPciDev The PCI device structure. If NULL the default
4089 * PCI device for this device instance is used.
4090 * @param GCPhys Physical address start reading from.
4091 * @param pvBuf Where to put the read bits.
4092 * @param cbRead How many bytes to read.
4093 * @thread Any thread, but the call may involve the emulation thread.
4094 */
4095 DECLRCCALLBACKMEMBER(int, pfnPCIPhysRead,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, RTGCPHYS GCPhys,
4096 void *pvBuf, size_t cbRead));
4097
4098 /**
4099 * Bus master physical memory write from the given PCI device.
4100 *
4101 * @returns VINF_SUCCESS or VERR_PGM_PCI_PHYS_WRITE_BM_DISABLED, later maybe
4102 * VERR_EM_MEMORY. The informational status shall NOT be propagated!
4103 * @param pDevIns The device instance.
4104 * @param pPciDev The PCI device structure. If NULL the default
4105 * PCI device for this device instance is used.
4106 * @param GCPhys Physical address to write to.
4107 * @param pvBuf What to write.
4108 * @param cbWrite How many bytes to write.
4109 * @thread Any thread, but the call may involve the emulation thread.
4110 */
4111 DECLRCCALLBACKMEMBER(int, pfnPCIPhysWrite,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, RTGCPHYS GCPhys,
4112 const void *pvBuf, size_t cbWrite));
4113
4114 /**
4115 * Set the IRQ for the given PCI device.
4116 *
4117 * @param pDevIns Device instance.
4118 * @param pPciDev The PCI device structure. If NULL the default
4119 * PCI device for this device instance is used.
4120 * @param iIrq IRQ number to set.
4121 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
4122 * @thread Any thread, but will involve the emulation thread.
4123 */
4124 DECLRCCALLBACKMEMBER(void, pfnPCISetIrq,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iIrq, int iLevel));
4125
4126 /**
4127 * Set ISA IRQ for a device.
4128 *
4129 * @param pDevIns Device instance.
4130 * @param iIrq IRQ number to set.
4131 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
4132 * @thread Any thread, but will involve the emulation thread.
4133 */
4134 DECLRCCALLBACKMEMBER(void, pfnISASetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
4135
4136 /**
4137 * Send an MSI straight to the I/O APIC.
4138 *
4139 * @param pDevIns PCI device instance.
4140 * @param GCPhys Physical address MSI request was written.
4141 * @param uValue Value written.
4142 * @thread Any thread, but will involve the emulation thread.
4143 */
4144 DECLRCCALLBACKMEMBER(void, pfnIoApicSendMsi,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, uint32_t uValue));
4145
4146 /**
4147 * Read physical memory.
4148 *
4149 * @returns VINF_SUCCESS (for now).
4150 * @param pDevIns Device instance.
4151 * @param GCPhys Physical address start reading from.
4152 * @param pvBuf Where to put the read bits.
4153 * @param cbRead How many bytes to read.
4154 */
4155 DECLRCCALLBACKMEMBER(int, pfnPhysRead,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead));
4156
4157 /**
4158 * Write to physical memory.
4159 *
4160 * @returns VINF_SUCCESS for now, and later maybe VERR_EM_MEMORY.
4161 * @param pDevIns Device instance.
4162 * @param GCPhys Physical address to write to.
4163 * @param pvBuf What to write.
4164 * @param cbWrite How many bytes to write.
4165 */
4166 DECLRCCALLBACKMEMBER(int, pfnPhysWrite,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite));
4167
4168 /**
4169 * Checks if the Gate A20 is enabled or not.
4170 *
4171 * @returns true if A20 is enabled.
4172 * @returns false if A20 is disabled.
4173 * @param pDevIns Device instance.
4174 * @thread The emulation thread.
4175 */
4176 DECLRCCALLBACKMEMBER(bool, pfnA20IsEnabled,(PPDMDEVINS pDevIns));
4177
4178 /**
4179 * Gets the VM state.
4180 *
4181 * @returns VM state.
4182 * @param pDevIns The device instance.
4183 * @thread Any thread (just keep in mind that it's volatile info).
4184 */
4185 DECLRCCALLBACKMEMBER(VMSTATE, pfnVMState, (PPDMDEVINS pDevIns));
4186
4187 /**
4188 * Set the VM error message
4189 *
4190 * @returns rc.
4191 * @param pDevIns Driver instance.
4192 * @param rc VBox status code.
4193 * @param SRC_POS Use RT_SRC_POS.
4194 * @param pszFormat Error message format string.
4195 * @param ... Error message arguments.
4196 */
4197 DECLRCCALLBACKMEMBER(int, pfnVMSetError,(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL,
4198 const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(6, 7));
4199
4200 /**
4201 * Set the VM error message
4202 *
4203 * @returns rc.
4204 * @param pDevIns Driver instance.
4205 * @param rc VBox status code.
4206 * @param SRC_POS Use RT_SRC_POS.
4207 * @param pszFormat Error message format string.
4208 * @param va Error message arguments.
4209 */
4210 DECLRCCALLBACKMEMBER(int, pfnVMSetErrorV,(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL,
4211 const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(6, 0));
4212
4213 /**
4214 * Set the VM runtime error message
4215 *
4216 * @returns VBox status code.
4217 * @param pDevIns Device instance.
4218 * @param fFlags The action flags. See VMSETRTERR_FLAGS_*.
4219 * @param pszErrorId Error ID string.
4220 * @param pszFormat Error message format string.
4221 * @param ... Error message arguments.
4222 */
4223 DECLRCCALLBACKMEMBER(int, pfnVMSetRuntimeError,(PPDMDEVINS pDevIns, uint32_t fFlags, const char *pszErrorId,
4224 const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(4, 5));
4225
4226 /**
4227 * Set the VM runtime error message
4228 *
4229 * @returns VBox status code.
4230 * @param pDevIns Device instance.
4231 * @param fFlags The action flags. See VMSETRTERR_FLAGS_*.
4232 * @param pszErrorId Error ID string.
4233 * @param pszFormat Error message format string.
4234 * @param va Error message arguments.
4235 */
4236 DECLRCCALLBACKMEMBER(int, pfnVMSetRuntimeErrorV,(PPDMDEVINS pDevIns, uint32_t fFlags, const char *pszErrorId,
4237 const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(4, 0));
4238
4239 /**
4240 * Gets the VM handle. Restricted API.
4241 *
4242 * @returns VM Handle.
4243 * @param pDevIns Device instance.
4244 */
4245 DECLRCCALLBACKMEMBER(PVMCC, pfnGetVM,(PPDMDEVINS pDevIns));
4246
4247 /**
4248 * Gets the VMCPU handle. Restricted API.
4249 *
4250 * @returns VMCPU Handle.
4251 * @param pDevIns The device instance.
4252 */
4253 DECLRCCALLBACKMEMBER(PVMCPUCC, pfnGetVMCPU,(PPDMDEVINS pDevIns));
4254
4255 /**
4256 * The the VM CPU ID of the current thread (restricted API).
4257 *
4258 * @returns The VMCPUID of the calling thread, NIL_VMCPUID if not EMT.
4259 * @param pDevIns The device instance.
4260 */
4261 DECLRCCALLBACKMEMBER(VMCPUID, pfnGetCurrentCpuId,(PPDMDEVINS pDevIns));
4262
4263 /**
4264 * Get the current virtual clock time in a VM. The clock frequency must be
4265 * queried separately.
4266 *
4267 * @returns Current clock time.
4268 * @param pDevIns The device instance.
4269 */
4270 DECLRCCALLBACKMEMBER(uint64_t, pfnTMTimeVirtGet,(PPDMDEVINS pDevIns));
4271
4272 /**
4273 * Get the frequency of the virtual clock.
4274 *
4275 * @returns The clock frequency (not variable at run-time).
4276 * @param pDevIns The device instance.
4277 */
4278 DECLRCCALLBACKMEMBER(uint64_t, pfnTMTimeVirtGetFreq,(PPDMDEVINS pDevIns));
4279
4280 /**
4281 * Get the current virtual clock time in a VM, in nanoseconds.
4282 *
4283 * @returns Current clock time (in ns).
4284 * @param pDevIns The device instance.
4285 */
4286 DECLRCCALLBACKMEMBER(uint64_t, pfnTMTimeVirtGetNano,(PPDMDEVINS pDevIns));
4287
4288 /**
4289 * Gets the NOP critical section.
4290 *
4291 * @returns The ring-3 address of the NOP critical section.
4292 * @param pDevIns The device instance.
4293 */
4294 DECLRCCALLBACKMEMBER(PPDMCRITSECT, pfnCritSectGetNop,(PPDMDEVINS pDevIns));
4295
4296 /**
4297 * Changes the device level critical section from the automatically created
4298 * default to one desired by the device constructor.
4299 *
4300 * Must first be done in ring-3.
4301 *
4302 * @returns VBox status code.
4303 * @param pDevIns The device instance.
4304 * @param pCritSect The critical section to use. NULL is not
4305 * valid, instead use the NOP critical
4306 * section.
4307 */
4308 DECLRCCALLBACKMEMBER(int, pfnSetDeviceCritSect,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect));
4309
4310 /** @name Exported PDM Critical Section Functions
4311 * @{ */
4312 DECLRCCALLBACKMEMBER(int, pfnCritSectEnter,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, int rcBusy));
4313 DECLRCCALLBACKMEMBER(int, pfnCritSectEnterDebug,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, int rcBusy, RTHCUINTPTR uId, RT_SRC_POS_DECL));
4314 DECLRCCALLBACKMEMBER(int, pfnCritSectTryEnter,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect));
4315 DECLRCCALLBACKMEMBER(int, pfnCritSectTryEnterDebug,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, RTHCUINTPTR uId, RT_SRC_POS_DECL));
4316 DECLRCCALLBACKMEMBER(int, pfnCritSectLeave,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect));
4317 DECLRCCALLBACKMEMBER(bool, pfnCritSectIsOwner,(PPDMDEVINS pDevIns, PCPDMCRITSECT pCritSect));
4318 DECLRCCALLBACKMEMBER(bool, pfnCritSectIsInitialized,(PPDMDEVINS pDevIns, PCPDMCRITSECT pCritSect));
4319 DECLRCCALLBACKMEMBER(bool, pfnCritSectHasWaiters,(PPDMDEVINS pDevIns, PCPDMCRITSECT pCritSect));
4320 DECLRCCALLBACKMEMBER(uint32_t, pfnCritSectGetRecursion,(PPDMDEVINS pDevIns, PCPDMCRITSECT pCritSect));
4321 /** @} */
4322
4323 /**
4324 * Gets the trace buffer handle.
4325 *
4326 * This is used by the macros found in VBox/vmm/dbgftrace.h and is not
4327 * really inteded for direct usage, thus no inline wrapper function.
4328 *
4329 * @returns Trace buffer handle or NIL_RTTRACEBUF.
4330 * @param pDevIns The device instance.
4331 */
4332 DECLRCCALLBACKMEMBER(RTTRACEBUF, pfnDBGFTraceBuf,(PPDMDEVINS pDevIns));
4333
4334 /**
4335 * Sets up the PCI bus for the raw-mode context.
4336 *
4337 * This must be called after ring-3 has registered the PCI bus using
4338 * PDMDevHlpPCIBusRegister().
4339 *
4340 * @returns VBox status code.
4341 * @param pDevIns The device instance.
4342 * @param pPciBusReg The PCI bus registration information for raw-mode,
4343 * considered volatile.
4344 * @param ppPciHlp Where to return the raw-mode PCI bus helpers.
4345 */
4346 DECLRCCALLBACKMEMBER(int, pfnPCIBusSetUpContext,(PPDMDEVINS pDevIns, PPDMPCIBUSREGRC pPciBusReg, PCPDMPCIHLPRC *ppPciHlp));
4347
4348 /**
4349 * Sets up the PIC for the ring-0 context.
4350 *
4351 * This must be called after ring-3 has registered the PIC using
4352 * PDMDevHlpPICRegister().
4353 *
4354 * @returns VBox status code.
4355 * @param pDevIns The device instance.
4356 * @param pPicReg The PIC registration information for ring-0,
4357 * considered volatile and copied.
4358 * @param ppPicHlp Where to return the ring-0 PIC helpers.
4359 */
4360 DECLRCCALLBACKMEMBER(int, pfnPICSetUpContext,(PPDMDEVINS pDevIns, PPDMPICREG pPicReg, PCPDMPICHLP *ppPicHlp));
4361
4362 /**
4363 * Sets up the APIC for the raw-mode context.
4364 *
4365 * This must be called after ring-3 has registered the APIC using
4366 * PDMDevHlpApicRegister().
4367 *
4368 * @returns VBox status code.
4369 * @param pDevIns The device instance.
4370 */
4371 DECLRCCALLBACKMEMBER(int, pfnApicSetUpContext,(PPDMDEVINS pDevIns));
4372
4373 /**
4374 * Sets up the IOAPIC for the ring-0 context.
4375 *
4376 * This must be called after ring-3 has registered the PIC using
4377 * PDMDevHlpIoApicRegister().
4378 *
4379 * @returns VBox status code.
4380 * @param pDevIns The device instance.
4381 * @param pIoApicReg The PIC registration information for ring-0,
4382 * considered volatile and copied.
4383 * @param ppIoApicHlp Where to return the ring-0 IOAPIC helpers.
4384 */
4385 DECLRCCALLBACKMEMBER(int, pfnIoApicSetUpContext,(PPDMDEVINS pDevIns, PPDMIOAPICREG pIoApicReg, PCPDMIOAPICHLP *ppIoApicHlp));
4386
4387 /**
4388 * Sets up the HPET for the raw-mode context.
4389 *
4390 * This must be called after ring-3 has registered the PIC using
4391 * PDMDevHlpHpetRegister().
4392 *
4393 * @returns VBox status code.
4394 * @param pDevIns The device instance.
4395 * @param pHpetReg The PIC registration information for raw-mode,
4396 * considered volatile and copied.
4397 * @param ppHpetHlp Where to return the raw-mode HPET helpers.
4398 */
4399 DECLRCCALLBACKMEMBER(int, pfnHpetSetUpContext,(PPDMDEVINS pDevIns, PPDMHPETREG pHpetReg, PCPDMHPETHLPRC *ppHpetHlp));
4400
4401 /** Space reserved for future members.
4402 * @{ */
4403 DECLRCCALLBACKMEMBER(void, pfnReserved1,(void));
4404 DECLRCCALLBACKMEMBER(void, pfnReserved2,(void));
4405 DECLRCCALLBACKMEMBER(void, pfnReserved3,(void));
4406 DECLRCCALLBACKMEMBER(void, pfnReserved4,(void));
4407 DECLRCCALLBACKMEMBER(void, pfnReserved5,(void));
4408 DECLRCCALLBACKMEMBER(void, pfnReserved6,(void));
4409 DECLRCCALLBACKMEMBER(void, pfnReserved7,(void));
4410 DECLRCCALLBACKMEMBER(void, pfnReserved8,(void));
4411 DECLRCCALLBACKMEMBER(void, pfnReserved9,(void));
4412 DECLRCCALLBACKMEMBER(void, pfnReserved10,(void));
4413 /** @} */
4414
4415 /** Just a safety precaution. */
4416 uint32_t u32TheEnd;
4417} PDMDEVHLPRC;
4418/** Pointer PDM Device RC API. */
4419typedef RGPTRTYPE(struct PDMDEVHLPRC *) PPDMDEVHLPRC;
4420/** Pointer PDM Device RC API. */
4421typedef RGPTRTYPE(const struct PDMDEVHLPRC *) PCPDMDEVHLPRC;
4422
4423/** Current PDMDEVHLP version number. */
4424#define PDM_DEVHLPRC_VERSION PDM_VERSION_MAKE(0xffe6, 14, 0)
4425
4426
4427/**
4428 * PDM Device API - R0 Variant.
4429 */
4430typedef struct PDMDEVHLPR0
4431{
4432 /** Structure version. PDM_DEVHLPR0_VERSION defines the current version. */
4433 uint32_t u32Version;
4434
4435 /**
4436 * Sets up ring-0 callback handlers for an I/O port range.
4437 *
4438 * The range must have been created in ring-3 first using
4439 * PDMDevHlpIoPortCreate() or PDMDevHlpIoPortCreateEx().
4440 *
4441 * @returns VBox status.
4442 * @param pDevIns The device instance to register the ports with.
4443 * @param hIoPorts The I/O port range handle.
4444 * @param pfnOut Pointer to function which is gonna handle OUT
4445 * operations. Optional.
4446 * @param pfnIn Pointer to function which is gonna handle IN operations.
4447 * Optional.
4448 * @param pfnOutStr Pointer to function which is gonna handle string OUT
4449 * operations. Optional.
4450 * @param pfnInStr Pointer to function which is gonna handle string IN
4451 * operations. Optional.
4452 * @param pvUser User argument to pass to the callbacks.
4453 *
4454 * @remarks Caller enters the device critical section prior to invoking the
4455 * registered callback methods.
4456 *
4457 * @sa PDMDevHlpIoPortCreate(), PDMDevHlpIoPortCreateEx(),
4458 * PDMDevHlpIoPortMap(), PDMDevHlpIoPortUnmap().
4459 */
4460 DECLR0CALLBACKMEMBER(int, pfnIoPortSetUpContextEx,(PPDMDEVINS pDevIns, IOMIOPORTHANDLE hIoPorts,
4461 PFNIOMIOPORTNEWOUT pfnOut, PFNIOMIOPORTNEWIN pfnIn,
4462 PFNIOMIOPORTNEWOUTSTRING pfnOutStr, PFNIOMIOPORTNEWINSTRING pfnInStr,
4463 void *pvUser));
4464
4465 /**
4466 * Sets up ring-0 callback handlers for an MMIO region.
4467 *
4468 * The region must have been created in ring-3 first using
4469 * PDMDevHlpMmioCreate(), PDMDevHlpMmioCreateEx(), PDMDevHlpMmioCreateAndMap(),
4470 * PDMDevHlpMmioCreateExAndMap() or PDMDevHlpPCIIORegionCreateMmio().
4471 *
4472 * @returns VBox status.
4473 * @param pDevIns The device instance to register the ports with.
4474 * @param hRegion The MMIO region handle.
4475 * @param pfnWrite Pointer to function which is gonna handle Write
4476 * operations.
4477 * @param pfnRead Pointer to function which is gonna handle Read
4478 * operations.
4479 * @param pfnFill Pointer to function which is gonna handle Fill/memset
4480 * operations. (optional)
4481 * @param pvUser User argument to pass to the callbacks.
4482 *
4483 * @remarks Caller enters the device critical section prior to invoking the
4484 * registered callback methods.
4485 *
4486 * @sa PDMDevHlpMmioCreate(), PDMDevHlpMmioCreateEx(), PDMDevHlpMmioMap(),
4487 * PDMDevHlpMmioUnmap().
4488 */
4489 DECLR0CALLBACKMEMBER(int, pfnMmioSetUpContextEx,(PPDMDEVINS pDevIns, IOMMMIOHANDLE hRegion, PFNIOMMMIONEWWRITE pfnWrite,
4490 PFNIOMMMIONEWREAD pfnRead, PFNIOMMMIONEWFILL pfnFill, void *pvUser));
4491
4492 /**
4493 * Sets up a ring-0 mapping for an MMIO2 region.
4494 *
4495 * The region must have been created in ring-3 first using
4496 * PDMDevHlpMmio2Create().
4497 *
4498 * @returns VBox status.
4499 * @param pDevIns The device instance to register the ports with.
4500 * @param hRegion The MMIO2 region handle.
4501 * @param offSub Start of what to map into ring-0. Must be page aligned.
4502 * @param cbSub Number of bytes to map into ring-0. Must be page
4503 * aligned. Zero is an alias for everything.
4504 * @param ppvMapping Where to return the mapping corresponding to @a offSub.
4505 *
4506 * @thread EMT(0)
4507 * @note Only available at VM creation time.
4508 *
4509 * @sa PDMDevHlpMmio2Create().
4510 */
4511 DECLR0CALLBACKMEMBER(int, pfnMmio2SetUpContext,(PPDMDEVINS pDevIns, PGMMMIO2HANDLE hRegion, size_t offSub, size_t cbSub,
4512 void **ppvMapping));
4513
4514 /**
4515 * Bus master physical memory read from the given PCI device.
4516 *
4517 * @returns VINF_SUCCESS or VERR_PDM_NOT_PCI_BUS_MASTER, later maybe
4518 * VERR_EM_MEMORY.
4519 * @param pDevIns The device instance.
4520 * @param pPciDev The PCI device structure. If NULL the default
4521 * PCI device for this device instance is used.
4522 * @param GCPhys Physical address start reading from.
4523 * @param pvBuf Where to put the read bits.
4524 * @param cbRead How many bytes to read.
4525 * @thread Any thread, but the call may involve the emulation thread.
4526 */
4527 DECLR0CALLBACKMEMBER(int, pfnPCIPhysRead,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, RTGCPHYS GCPhys,
4528 void *pvBuf, size_t cbRead));
4529
4530 /**
4531 * Bus master physical memory write from the given PCI device.
4532 *
4533 * @returns VINF_SUCCESS or VERR_PDM_NOT_PCI_BUS_MASTER, later maybe
4534 * VERR_EM_MEMORY.
4535 * @param pDevIns The device instance.
4536 * @param pPciDev The PCI device structure. If NULL the default
4537 * PCI device for this device instance is used.
4538 * @param GCPhys Physical address to write to.
4539 * @param pvBuf What to write.
4540 * @param cbWrite How many bytes to write.
4541 * @thread Any thread, but the call may involve the emulation thread.
4542 */
4543 DECLR0CALLBACKMEMBER(int, pfnPCIPhysWrite,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, RTGCPHYS GCPhys,
4544 const void *pvBuf, size_t cbWrite));
4545
4546 /**
4547 * Set the IRQ for the given PCI device.
4548 *
4549 * @param pDevIns Device instance.
4550 * @param pPciDev The PCI device structure. If NULL the default
4551 * PCI device for this device instance is used.
4552 * @param iIrq IRQ number to set.
4553 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
4554 * @thread Any thread, but will involve the emulation thread.
4555 */
4556 DECLR0CALLBACKMEMBER(void, pfnPCISetIrq,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iIrq, int iLevel));
4557
4558 /**
4559 * Set ISA IRQ for a device.
4560 *
4561 * @param pDevIns Device instance.
4562 * @param iIrq IRQ number to set.
4563 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
4564 * @thread Any thread, but will involve the emulation thread.
4565 */
4566 DECLR0CALLBACKMEMBER(void, pfnISASetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
4567
4568 /**
4569 * Send an MSI straight to the I/O APIC.
4570 *
4571 * @param pDevIns PCI device instance.
4572 * @param GCPhys Physical address MSI request was written.
4573 * @param uValue Value written.
4574 * @thread Any thread, but will involve the emulation thread.
4575 */
4576 DECLR0CALLBACKMEMBER(void, pfnIoApicSendMsi,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, uint32_t uValue));
4577
4578 /**
4579 * Read physical memory.
4580 *
4581 * @returns VINF_SUCCESS (for now).
4582 * @param pDevIns Device instance.
4583 * @param GCPhys Physical address start reading from.
4584 * @param pvBuf Where to put the read bits.
4585 * @param cbRead How many bytes to read.
4586 */
4587 DECLR0CALLBACKMEMBER(int, pfnPhysRead,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead));
4588
4589 /**
4590 * Write to physical memory.
4591 *
4592 * @returns VINF_SUCCESS for now, and later maybe VERR_EM_MEMORY.
4593 * @param pDevIns Device instance.
4594 * @param GCPhys Physical address to write to.
4595 * @param pvBuf What to write.
4596 * @param cbWrite How many bytes to write.
4597 */
4598 DECLR0CALLBACKMEMBER(int, pfnPhysWrite,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite));
4599
4600 /**
4601 * Checks if the Gate A20 is enabled or not.
4602 *
4603 * @returns true if A20 is enabled.
4604 * @returns false if A20 is disabled.
4605 * @param pDevIns Device instance.
4606 * @thread The emulation thread.
4607 */
4608 DECLR0CALLBACKMEMBER(bool, pfnA20IsEnabled,(PPDMDEVINS pDevIns));
4609
4610 /**
4611 * Gets the VM state.
4612 *
4613 * @returns VM state.
4614 * @param pDevIns The device instance.
4615 * @thread Any thread (just keep in mind that it's volatile info).
4616 */
4617 DECLR0CALLBACKMEMBER(VMSTATE, pfnVMState, (PPDMDEVINS pDevIns));
4618
4619 /**
4620 * Set the VM error message
4621 *
4622 * @returns rc.
4623 * @param pDevIns Driver instance.
4624 * @param rc VBox status code.
4625 * @param SRC_POS Use RT_SRC_POS.
4626 * @param pszFormat Error message format string.
4627 * @param ... Error message arguments.
4628 */
4629 DECLR0CALLBACKMEMBER(int, pfnVMSetError,(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL,
4630 const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(6, 7));
4631
4632 /**
4633 * Set the VM error message
4634 *
4635 * @returns rc.
4636 * @param pDevIns Driver instance.
4637 * @param rc VBox status code.
4638 * @param SRC_POS Use RT_SRC_POS.
4639 * @param pszFormat Error message format string.
4640 * @param va Error message arguments.
4641 */
4642 DECLR0CALLBACKMEMBER(int, pfnVMSetErrorV,(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL,
4643 const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(6, 0));
4644
4645 /**
4646 * Set the VM runtime error message
4647 *
4648 * @returns VBox status code.
4649 * @param pDevIns Device instance.
4650 * @param fFlags The action flags. See VMSETRTERR_FLAGS_*.
4651 * @param pszErrorId Error ID string.
4652 * @param pszFormat Error message format string.
4653 * @param ... Error message arguments.
4654 */
4655 DECLR0CALLBACKMEMBER(int, pfnVMSetRuntimeError,(PPDMDEVINS pDevIns, uint32_t fFlags, const char *pszErrorId,
4656 const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(4, 5));
4657
4658 /**
4659 * Set the VM runtime error message
4660 *
4661 * @returns VBox status code.
4662 * @param pDevIns Device instance.
4663 * @param fFlags The action flags. See VMSETRTERR_FLAGS_*.
4664 * @param pszErrorId Error ID string.
4665 * @param pszFormat Error message format string.
4666 * @param va Error message arguments.
4667 */
4668 DECLR0CALLBACKMEMBER(int, pfnVMSetRuntimeErrorV,(PPDMDEVINS pDevIns, uint32_t fFlags, const char *pszErrorId,
4669 const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(4, 0));
4670
4671 /**
4672 * Gets the VM handle. Restricted API.
4673 *
4674 * @returns VM Handle.
4675 * @param pDevIns Device instance.
4676 */
4677 DECLR0CALLBACKMEMBER(PVMCC, pfnGetVM,(PPDMDEVINS pDevIns));
4678
4679 /**
4680 * Gets the VMCPU handle. Restricted API.
4681 *
4682 * @returns VMCPU Handle.
4683 * @param pDevIns The device instance.
4684 */
4685 DECLR0CALLBACKMEMBER(PVMCPUCC, pfnGetVMCPU,(PPDMDEVINS pDevIns));
4686
4687 /**
4688 * The the VM CPU ID of the current thread (restricted API).
4689 *
4690 * @returns The VMCPUID of the calling thread, NIL_VMCPUID if not EMT.
4691 * @param pDevIns The device instance.
4692 */
4693 DECLR0CALLBACKMEMBER(VMCPUID, pfnGetCurrentCpuId,(PPDMDEVINS pDevIns));
4694
4695 /**
4696 * Translates a timer handle to a pointer.
4697 *
4698 * @returns The time address.
4699 * @param pDevIns The device instance.
4700 * @param hTimer The timer handle.
4701 */
4702 DECLR0CALLBACKMEMBER(PTMTIMERR0, pfnTimerToPtr,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer));
4703
4704 /** @name Timer handle method wrappers
4705 * @{ */
4706 DECLR0CALLBACKMEMBER(uint64_t, pfnTimerFromMicro,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint64_t cMicroSecs));
4707 DECLR0CALLBACKMEMBER(uint64_t, pfnTimerFromMilli,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint64_t cMilliSecs));
4708 DECLR0CALLBACKMEMBER(uint64_t, pfnTimerFromNano,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint64_t cNanoSecs));
4709 DECLR0CALLBACKMEMBER(uint64_t, pfnTimerGet,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer));
4710 DECLR0CALLBACKMEMBER(uint64_t, pfnTimerGetFreq,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer));
4711 DECLR0CALLBACKMEMBER(uint64_t, pfnTimerGetNano,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer));
4712 DECLR0CALLBACKMEMBER(bool, pfnTimerIsActive,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer));
4713 DECLR0CALLBACKMEMBER(bool, pfnTimerIsLockOwner,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer));
4714 DECLR0CALLBACKMEMBER(VBOXSTRICTRC, pfnTimerLockClock,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, int rcBusy));
4715 /** Takes the clock lock then enters the specified critical section. */
4716 DECLR0CALLBACKMEMBER(VBOXSTRICTRC, pfnTimerLockClock2,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, PPDMCRITSECT pCritSect, int rcBusy));
4717 DECLR0CALLBACKMEMBER(int, pfnTimerSet,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint64_t uExpire));
4718 DECLR0CALLBACKMEMBER(int, pfnTimerSetFrequencyHint,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint32_t uHz));
4719 DECLR0CALLBACKMEMBER(int, pfnTimerSetMicro,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint64_t cMicrosToNext));
4720 DECLR0CALLBACKMEMBER(int, pfnTimerSetMillies,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint64_t cMilliesToNext));
4721 DECLR0CALLBACKMEMBER(int, pfnTimerSetNano,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint64_t cNanosToNext));
4722 DECLR0CALLBACKMEMBER(int, pfnTimerSetRelative,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint64_t cTicksToNext, uint64_t *pu64Now));
4723 DECLR0CALLBACKMEMBER(int, pfnTimerStop,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer));
4724 DECLR0CALLBACKMEMBER(void, pfnTimerUnlockClock,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer));
4725 DECLR0CALLBACKMEMBER(void, pfnTimerUnlockClock2,(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, PPDMCRITSECT pCritSect));
4726 /** @} */
4727
4728 /**
4729 * Get the current virtual clock time in a VM. The clock frequency must be
4730 * queried separately.
4731 *
4732 * @returns Current clock time.
4733 * @param pDevIns The device instance.
4734 */
4735 DECLR0CALLBACKMEMBER(uint64_t, pfnTMTimeVirtGet,(PPDMDEVINS pDevIns));
4736
4737 /**
4738 * Get the frequency of the virtual clock.
4739 *
4740 * @returns The clock frequency (not variable at run-time).
4741 * @param pDevIns The device instance.
4742 */
4743 DECLR0CALLBACKMEMBER(uint64_t, pfnTMTimeVirtGetFreq,(PPDMDEVINS pDevIns));
4744
4745 /**
4746 * Get the current virtual clock time in a VM, in nanoseconds.
4747 *
4748 * @returns Current clock time (in ns).
4749 * @param pDevIns The device instance.
4750 */
4751 DECLR0CALLBACKMEMBER(uint64_t, pfnTMTimeVirtGetNano,(PPDMDEVINS pDevIns));
4752
4753 /** @name Exported PDM Queue Functions
4754 * @{ */
4755 DECLR0CALLBACKMEMBER(PPDMQUEUE, pfnQueueToPtr,(PPDMDEVINS pDevIns, PDMQUEUEHANDLE hQueue));
4756 DECLR0CALLBACKMEMBER(PPDMQUEUEITEMCORE, pfnQueueAlloc,(PPDMDEVINS pDevIns, PDMQUEUEHANDLE hQueue));
4757 DECLR0CALLBACKMEMBER(void, pfnQueueInsert,(PPDMDEVINS pDevIns, PDMQUEUEHANDLE hQueue, PPDMQUEUEITEMCORE pItem));
4758 DECLR0CALLBACKMEMBER(void, pfnQueueInsertEx,(PPDMDEVINS pDevIns, PDMQUEUEHANDLE hQueue, PPDMQUEUEITEMCORE pItem, uint64_t cNanoMaxDelay));
4759 DECLR0CALLBACKMEMBER(bool, pfnQueueFlushIfNecessary,(PPDMDEVINS pDevIns, PDMQUEUEHANDLE hQueue));
4760 /** @} */
4761
4762 /** @name PDM Task
4763 * @{ */
4764 /**
4765 * Triggers the running the given task.
4766 *
4767 * @returns VBox status code.
4768 * @retval VINF_ALREADY_POSTED is the task is already pending.
4769 * @param pDevIns The device instance.
4770 * @param hTask The task to trigger.
4771 * @thread Any thread.
4772 */
4773 DECLR0CALLBACKMEMBER(int, pfnTaskTrigger,(PPDMDEVINS pDevIns, PDMTASKHANDLE hTask));
4774 /** @} */
4775
4776 /** @name SUP Event Semaphore Wrappers (single release / auto reset)
4777 * These semaphores can be signalled from ring-0.
4778 * @{ */
4779 /** @sa SUPSemEventSignal */
4780 DECLR0CALLBACKMEMBER(int, pfnSUPSemEventSignal,(PPDMDEVINS pDevIns, SUPSEMEVENT hEvent));
4781 /** @sa SUPSemEventWaitNoResume */
4782 DECLR0CALLBACKMEMBER(int, pfnSUPSemEventWaitNoResume,(PPDMDEVINS pDevIns, SUPSEMEVENT hEvent, uint32_t cMillies));
4783 /** @sa SUPSemEventWaitNsAbsIntr */
4784 DECLR0CALLBACKMEMBER(int, pfnSUPSemEventWaitNsAbsIntr,(PPDMDEVINS pDevIns, SUPSEMEVENT hEvent, uint64_t uNsTimeout));
4785 /** @sa SUPSemEventWaitNsRelIntr */
4786 DECLR0CALLBACKMEMBER(int, pfnSUPSemEventWaitNsRelIntr,(PPDMDEVINS pDevIns, SUPSEMEVENT hEvent, uint64_t cNsTimeout));
4787 /** @sa SUPSemEventGetResolution */
4788 DECLR0CALLBACKMEMBER(uint32_t, pfnSUPSemEventGetResolution,(PPDMDEVINS pDevIns));
4789 /** @} */
4790
4791 /** @name SUP Multi Event Semaphore Wrappers (multiple release / manual reset)
4792 * These semaphores can be signalled from ring-0.
4793 * @{ */
4794 /** @sa SUPSemEventMultiSignal */
4795 DECLR0CALLBACKMEMBER(int, pfnSUPSemEventMultiSignal,(PPDMDEVINS pDevIns, SUPSEMEVENTMULTI hEventMulti));
4796 /** @sa SUPSemEventMultiReset */
4797 DECLR0CALLBACKMEMBER(int, pfnSUPSemEventMultiReset,(PPDMDEVINS pDevIns, SUPSEMEVENTMULTI hEventMulti));
4798 /** @sa SUPSemEventMultiWaitNoResume */
4799 DECLR0CALLBACKMEMBER(int, pfnSUPSemEventMultiWaitNoResume,(PPDMDEVINS pDevIns, SUPSEMEVENTMULTI hEventMulti, uint32_t cMillies));
4800 /** @sa SUPSemEventMultiWaitNsAbsIntr */
4801 DECLR0CALLBACKMEMBER(int, pfnSUPSemEventMultiWaitNsAbsIntr,(PPDMDEVINS pDevIns, SUPSEMEVENTMULTI hEventMulti, uint64_t uNsTimeout));
4802 /** @sa SUPSemEventMultiWaitNsRelIntr */
4803 DECLR0CALLBACKMEMBER(int, pfnSUPSemEventMultiWaitNsRelIntr,(PPDMDEVINS pDevIns, SUPSEMEVENTMULTI hEventMulti, uint64_t cNsTimeout));
4804 /** @sa SUPSemEventMultiGetResolution */
4805 DECLR0CALLBACKMEMBER(uint32_t, pfnSUPSemEventMultiGetResolution,(PPDMDEVINS pDevIns));
4806 /** @} */
4807
4808 /**
4809 * Gets the NOP critical section.
4810 *
4811 * @returns The ring-3 address of the NOP critical section.
4812 * @param pDevIns The device instance.
4813 */
4814 DECLR0CALLBACKMEMBER(PPDMCRITSECT, pfnCritSectGetNop,(PPDMDEVINS pDevIns));
4815
4816 /**
4817 * Changes the device level critical section from the automatically created
4818 * default to one desired by the device constructor.
4819 *
4820 * Must first be done in ring-3.
4821 *
4822 * @returns VBox status code.
4823 * @param pDevIns The device instance.
4824 * @param pCritSect The critical section to use. NULL is not
4825 * valid, instead use the NOP critical
4826 * section.
4827 */
4828 DECLR0CALLBACKMEMBER(int, pfnSetDeviceCritSect,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect));
4829
4830 /** @name Exported PDM Critical Section Functions
4831 * @{ */
4832 DECLR0CALLBACKMEMBER(int, pfnCritSectEnter,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, int rcBusy));
4833 DECLR0CALLBACKMEMBER(int, pfnCritSectEnterDebug,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, int rcBusy, RTHCUINTPTR uId, RT_SRC_POS_DECL));
4834 DECLR0CALLBACKMEMBER(int, pfnCritSectTryEnter,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect));
4835 DECLR0CALLBACKMEMBER(int, pfnCritSectTryEnterDebug,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, RTHCUINTPTR uId, RT_SRC_POS_DECL));
4836 DECLR0CALLBACKMEMBER(int, pfnCritSectLeave,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect));
4837 DECLR0CALLBACKMEMBER(bool, pfnCritSectIsOwner,(PPDMDEVINS pDevIns, PCPDMCRITSECT pCritSect));
4838 DECLR0CALLBACKMEMBER(bool, pfnCritSectIsInitialized,(PPDMDEVINS pDevIns, PCPDMCRITSECT pCritSect));
4839 DECLR0CALLBACKMEMBER(bool, pfnCritSectHasWaiters,(PPDMDEVINS pDevIns, PCPDMCRITSECT pCritSect));
4840 DECLR0CALLBACKMEMBER(uint32_t, pfnCritSectGetRecursion,(PPDMDEVINS pDevIns, PCPDMCRITSECT pCritSect));
4841 DECLR0CALLBACKMEMBER(int, pfnCritSectScheduleExitEvent,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, SUPSEMEVENT hEventToSignal));
4842 /** @} */
4843
4844 /**
4845 * Gets the trace buffer handle.
4846 *
4847 * This is used by the macros found in VBox/vmm/dbgftrace.h and is not
4848 * really inteded for direct usage, thus no inline wrapper function.
4849 *
4850 * @returns Trace buffer handle or NIL_RTTRACEBUF.
4851 * @param pDevIns The device instance.
4852 */
4853 DECLR0CALLBACKMEMBER(RTTRACEBUF, pfnDBGFTraceBuf,(PPDMDEVINS pDevIns));
4854
4855 /**
4856 * Sets up the PCI bus for the ring-0 context.
4857 *
4858 * This must be called after ring-3 has registered the PCI bus using
4859 * PDMDevHlpPCIBusRegister().
4860 *
4861 * @returns VBox status code.
4862 * @param pDevIns The device instance.
4863 * @param pPciBusReg The PCI bus registration information for ring-0,
4864 * considered volatile and copied.
4865 * @param ppPciHlp Where to return the ring-0 PCI bus helpers.
4866 */
4867 DECLR0CALLBACKMEMBER(int, pfnPCIBusSetUpContext,(PPDMDEVINS pDevIns, PPDMPCIBUSREGR0 pPciBusReg, PCPDMPCIHLPR0 *ppPciHlp));
4868
4869 /**
4870 * Sets up the PIC for the ring-0 context.
4871 *
4872 * This must be called after ring-3 has registered the PIC using
4873 * PDMDevHlpPICRegister().
4874 *
4875 * @returns VBox status code.
4876 * @param pDevIns The device instance.
4877 * @param pPicReg The PIC registration information for ring-0,
4878 * considered volatile and copied.
4879 * @param ppPicHlp Where to return the ring-0 PIC helpers.
4880 */
4881 DECLR0CALLBACKMEMBER(int, pfnPICSetUpContext,(PPDMDEVINS pDevIns, PPDMPICREG pPicReg, PCPDMPICHLP *ppPicHlp));
4882
4883 /**
4884 * Sets up the APIC for the ring-0 context.
4885 *
4886 * This must be called after ring-3 has registered the APIC using
4887 * PDMDevHlpApicRegister().
4888 *
4889 * @returns VBox status code.
4890 * @param pDevIns The device instance.
4891 */
4892 DECLR0CALLBACKMEMBER(int, pfnApicSetUpContext,(PPDMDEVINS pDevIns));
4893
4894 /**
4895 * Sets up the IOAPIC for the ring-0 context.
4896 *
4897 * This must be called after ring-3 has registered the PIC using
4898 * PDMDevHlpIoApicRegister().
4899 *
4900 * @returns VBox status code.
4901 * @param pDevIns The device instance.
4902 * @param pIoApicReg The PIC registration information for ring-0,
4903 * considered volatile and copied.
4904 * @param ppIoApicHlp Where to return the ring-0 IOAPIC helpers.
4905 */
4906 DECLR0CALLBACKMEMBER(int, pfnIoApicSetUpContext,(PPDMDEVINS pDevIns, PPDMIOAPICREG pIoApicReg, PCPDMIOAPICHLP *ppIoApicHlp));
4907
4908 /**
4909 * Sets up the HPET for the ring-0 context.
4910 *
4911 * This must be called after ring-3 has registered the PIC using
4912 * PDMDevHlpHpetRegister().
4913 *
4914 * @returns VBox status code.
4915 * @param pDevIns The device instance.
4916 * @param pHpetReg The PIC registration information for ring-0,
4917 * considered volatile and copied.
4918 * @param ppHpetHlp Where to return the ring-0 HPET helpers.
4919 */
4920 DECLR0CALLBACKMEMBER(int, pfnHpetSetUpContext,(PPDMDEVINS pDevIns, PPDMHPETREG pHpetReg, PCPDMHPETHLPR0 *ppHpetHlp));
4921
4922 /** Space reserved for future members.
4923 * @{ */
4924 DECLR0CALLBACKMEMBER(void, pfnReserved1,(void));
4925 DECLR0CALLBACKMEMBER(void, pfnReserved2,(void));
4926 DECLR0CALLBACKMEMBER(void, pfnReserved3,(void));
4927 DECLR0CALLBACKMEMBER(void, pfnReserved4,(void));
4928 DECLR0CALLBACKMEMBER(void, pfnReserved5,(void));
4929 DECLR0CALLBACKMEMBER(void, pfnReserved6,(void));
4930 DECLR0CALLBACKMEMBER(void, pfnReserved7,(void));
4931 DECLR0CALLBACKMEMBER(void, pfnReserved8,(void));
4932 DECLR0CALLBACKMEMBER(void, pfnReserved9,(void));
4933 DECLR0CALLBACKMEMBER(void, pfnReserved10,(void));
4934 /** @} */
4935
4936 /** Just a safety precaution. */
4937 uint32_t u32TheEnd;
4938} PDMDEVHLPR0;
4939/** Pointer PDM Device R0 API. */
4940typedef R0PTRTYPE(struct PDMDEVHLPR0 *) PPDMDEVHLPR0;
4941/** Pointer PDM Device GC API. */
4942typedef R0PTRTYPE(const struct PDMDEVHLPR0 *) PCPDMDEVHLPR0;
4943
4944/** Current PDMDEVHLP version number. */
4945#define PDM_DEVHLPR0_VERSION PDM_VERSION_MAKE(0xffe5, 16, 0)
4946
4947
4948/**
4949 * PDM Device Instance.
4950 */
4951typedef struct PDMDEVINSR3
4952{
4953 /** Structure version. PDM_DEVINSR3_VERSION defines the current version. */
4954 uint32_t u32Version;
4955 /** Device instance number. */
4956 uint32_t iInstance;
4957 /** Size of the ring-3, raw-mode and shared bits. */
4958 uint32_t cbRing3;
4959 /** Set if ring-0 context is enabled. */
4960 bool fR0Enabled;
4961 /** Set if raw-mode context is enabled. */
4962 bool fRCEnabled;
4963 /** Alignment padding. */
4964 bool afReserved[2];
4965 /** Pointer the HC PDM Device API. */
4966 PCPDMDEVHLPR3 pHlpR3;
4967 /** Pointer to the shared device instance data. */
4968 RTR3PTR pvInstanceDataR3;
4969 /** Pointer to the device instance data for ring-3. */
4970 RTR3PTR pvInstanceDataForR3;
4971 /** The critical section for the device.
4972 *
4973 * TM and IOM will enter this critical section before calling into the device
4974 * code. PDM will when doing power on, power off, reset, suspend and resume
4975 * notifications. SSM will currently not, but this will be changed later on.
4976 *
4977 * The device gets a critical section automatically assigned to it before
4978 * the constructor is called. If the constructor wishes to use a different
4979 * critical section, it calls PDMDevHlpSetDeviceCritSect() to change it
4980 * very early on.
4981 */
4982 R3PTRTYPE(PPDMCRITSECT) pCritSectRoR3;
4983 /** Pointer to device registration structure. */
4984 R3PTRTYPE(PCPDMDEVREG) pReg;
4985 /** Configuration handle. */
4986 R3PTRTYPE(PCFGMNODE) pCfg;
4987 /** The base interface of the device.
4988 *
4989 * The device constructor initializes this if it has any
4990 * device level interfaces to export. To obtain this interface
4991 * call PDMR3QueryDevice(). */
4992 PDMIBASE IBase;
4993
4994 /** Tracing indicator. */
4995 uint32_t fTracing;
4996 /** The tracing ID of this device. */
4997 uint32_t idTracing;
4998
4999 /** Ring-3 pointer to the raw-mode device instance. */
5000 R3PTRTYPE(struct PDMDEVINSRC *) pDevInsForRCR3;
5001 /** Raw-mode address of the raw-mode device instance. */
5002 RTRGPTR pDevInsForRC;
5003 /** Ring-3 pointer to the raw-mode instance data. */
5004 RTR3PTR pvInstanceDataForRCR3;
5005
5006 /** PCI device structure size. */
5007 uint32_t cbPciDev;
5008 /** Number of PCI devices in apPciDevs. */
5009 uint32_t cPciDevs;
5010 /** Pointer to the PCI devices for this device.
5011 * (Allocated after the shared instance data.)
5012 * @note If we want to extend this beyond 8 sub-functions/devices, those 1 or
5013 * two devices ever needing it can use cbPciDev and do the address
5014 * calculations that for entries 8+. */
5015 R3PTRTYPE(struct PDMPCIDEV *) apPciDevs[8];
5016
5017 /** Temporarily. */
5018 R0PTRTYPE(struct PDMDEVINSR0 *) pDevInsR0RemoveMe;
5019 /** Temporarily. */
5020 RTR0PTR pvInstanceDataR0;
5021 /** Temporarily. */
5022 RTRCPTR pvInstanceDataRC;
5023 /** Align the internal data more naturally. */
5024 uint32_t au32Padding[HC_ARCH_BITS == 32 ? 13 : 11];
5025
5026 /** Internal data. */
5027 union
5028 {
5029#ifdef PDMDEVINSINT_DECLARED
5030 PDMDEVINSINTR3 s;
5031#endif
5032 uint8_t padding[HC_ARCH_BITS == 32 ? 0x30 : 0x50];
5033 } Internal;
5034
5035 /** Device instance data for ring-3. The size of this area is defined
5036 * in the PDMDEVREG::cbInstanceR3 field. */
5037 char achInstanceData[8];
5038} PDMDEVINSR3;
5039
5040/** Current PDMDEVINSR3 version number. */
5041#define PDM_DEVINSR3_VERSION PDM_VERSION_MAKE(0xff82, 4, 0)
5042
5043/** Converts a pointer to the PDMDEVINSR3::IBase to a pointer to PDMDEVINS. */
5044#define PDMIBASE_2_PDMDEV(pInterface) ( (PPDMDEVINS)((char *)(pInterface) - RT_UOFFSETOF(PDMDEVINS, IBase)) )
5045
5046
5047/**
5048 * PDM ring-0 device instance.
5049 */
5050typedef struct PDMDEVINSR0
5051{
5052 /** Structure version. PDM_DEVINSR0_VERSION defines the current version. */
5053 uint32_t u32Version;
5054 /** Device instance number. */
5055 uint32_t iInstance;
5056
5057 /** Pointer the HC PDM Device API. */
5058 PCPDMDEVHLPR0 pHlpR0;
5059 /** Pointer to the shared device instance data. */
5060 RTR0PTR pvInstanceDataR0;
5061 /** Pointer to the device instance data for ring-0. */
5062 RTR0PTR pvInstanceDataForR0;
5063 /** The critical section for the device.
5064 *
5065 * TM and IOM will enter this critical section before calling into the device
5066 * code. PDM will when doing power on, power off, reset, suspend and resume
5067 * notifications. SSM will currently not, but this will be changed later on.
5068 *
5069 * The device gets a critical section automatically assigned to it before
5070 * the constructor is called. If the constructor wishes to use a different
5071 * critical section, it calls PDMDevHlpSetDeviceCritSect() to change it
5072 * very early on.
5073 */
5074 R0PTRTYPE(PPDMCRITSECT) pCritSectRoR0;
5075 /** Pointer to the ring-0 device registration structure. */
5076 R0PTRTYPE(PCPDMDEVREGR0) pReg;
5077 /** Ring-3 address of the ring-3 device instance. */
5078 R3PTRTYPE(struct PDMDEVINSR3 *) pDevInsForR3;
5079 /** Ring-0 pointer to the ring-3 device instance. */
5080 R0PTRTYPE(struct PDMDEVINSR3 *) pDevInsForR3R0;
5081 /** Ring-0 pointer to the ring-3 instance data. */
5082 RTR0PTR pvInstanceDataForR3R0;
5083 /** Raw-mode address of the raw-mode device instance. */
5084 RGPTRTYPE(struct PDMDEVINSRC *) pDevInsForRC;
5085 /** Ring-0 pointer to the raw-mode device instance. */
5086 R0PTRTYPE(struct PDMDEVINSRC *) pDevInsForRCR0;
5087 /** Ring-0 pointer to the raw-mode instance data. */
5088 RTR0PTR pvInstanceDataForRCR0;
5089
5090 /** PCI device structure size. */
5091 uint32_t cbPciDev;
5092 /** Number of PCI devices in apPciDevs. */
5093 uint32_t cPciDevs;
5094 /** Pointer to the PCI devices for this device.
5095 * (Allocated after the shared instance data.)
5096 * @note If we want to extend this beyond 8 sub-functions/devices, those 1 or
5097 * two devices ever needing it can use cbPciDev and do the address
5098 * calculations that for entries 8+. */
5099 R0PTRTYPE(struct PDMPCIDEV *) apPciDevs[8];
5100
5101 /** Align the internal data more naturally. */
5102 uint32_t au32Padding[HC_ARCH_BITS == 32 ? 3 : 2 + 4];
5103
5104 /** Internal data. */
5105 union
5106 {
5107#ifdef PDMDEVINSINT_DECLARED
5108 PDMDEVINSINTR0 s;
5109#endif
5110 uint8_t padding[HC_ARCH_BITS == 32 ? 0x20 : 0x40];
5111 } Internal;
5112
5113 /** Device instance data for ring-0. The size of this area is defined
5114 * in the PDMDEVREG::cbInstanceR0 field. */
5115 char achInstanceData[8];
5116} PDMDEVINSR0;
5117
5118/** Current PDMDEVINSR0 version number. */
5119#define PDM_DEVINSR0_VERSION PDM_VERSION_MAKE(0xff83, 4, 0)
5120
5121
5122/**
5123 * PDM raw-mode device instance.
5124 */
5125typedef struct PDMDEVINSRC
5126{
5127 /** Structure version. PDM_DEVINSRC_VERSION defines the current version. */
5128 uint32_t u32Version;
5129 /** Device instance number. */
5130 uint32_t iInstance;
5131
5132 /** Pointer the HC PDM Device API. */
5133 PCPDMDEVHLPRC pHlpRC;
5134 /** Pointer to the shared device instance data. */
5135 RTRGPTR pvInstanceDataRC;
5136 /** Pointer to the device instance data for raw-mode. */
5137 RTRGPTR pvInstanceDataForRC;
5138 /** The critical section for the device.
5139 *
5140 * TM and IOM will enter this critical section before calling into the device
5141 * code. PDM will when doing power on, power off, reset, suspend and resume
5142 * notifications. SSM will currently not, but this will be changed later on.
5143 *
5144 * The device gets a critical section automatically assigned to it before
5145 * the constructor is called. If the constructor wishes to use a different
5146 * critical section, it calls PDMDevHlpSetDeviceCritSect() to change it
5147 * very early on.
5148 */
5149 RGPTRTYPE(PPDMCRITSECT) pCritSectRoRC;
5150 /** Pointer to the raw-mode device registration structure. */
5151 RGPTRTYPE(PCPDMDEVREGRC) pReg;
5152
5153 /** PCI device structure size. */
5154 uint32_t cbPciDev;
5155 /** Number of PCI devices in apPciDevs. */
5156 uint32_t cPciDevs;
5157 /** Pointer to the PCI devices for this device.
5158 * (Allocated after the shared instance data.) */
5159 RGPTRTYPE(struct PDMPCIDEV *) apPciDevs[8];
5160
5161 /** Align the internal data more naturally. */
5162 uint32_t au32Padding[14];
5163
5164 /** Internal data. */
5165 union
5166 {
5167#ifdef PDMDEVINSINT_DECLARED
5168 PDMDEVINSINTRC s;
5169#endif
5170 uint8_t padding[0x10];
5171 } Internal;
5172
5173 /** Device instance data for ring-0. The size of this area is defined
5174 * in the PDMDEVREG::cbInstanceR0 field. */
5175 char achInstanceData[8];
5176} PDMDEVINSRC;
5177
5178/** Current PDMDEVINSR0 version number. */
5179#define PDM_DEVINSRC_VERSION PDM_VERSION_MAKE(0xff84, 4, 0)
5180
5181
5182/** @def PDM_DEVINS_VERSION
5183 * Current PDMDEVINS version number. */
5184/** @typedef PDMDEVINS
5185 * The device instance structure for the current context. */
5186#ifdef IN_RING3
5187# define PDM_DEVINS_VERSION PDM_DEVINSR3_VERSION
5188typedef PDMDEVINSR3 PDMDEVINS;
5189#elif defined(IN_RING0)
5190# define PDM_DEVINS_VERSION PDM_DEVINSR0_VERSION
5191typedef PDMDEVINSR0 PDMDEVINS;
5192#elif defined(IN_RC)
5193# define PDM_DEVINS_VERSION PDM_DEVINSRC_VERSION
5194typedef PDMDEVINSRC PDMDEVINS;
5195#else
5196# error "Missing context defines: IN_RING0, IN_RING3, IN_RC"
5197#endif
5198
5199/**
5200 * Get the pointer to an PCI device.
5201 * @note Returns NULL if @a a_idxPciDev is out of bounds.
5202 */
5203#define PDMDEV_GET_PPCIDEV(a_pDevIns, a_idxPciDev) \
5204 ( (uintptr_t)(a_idxPciDev) < RT_ELEMENTS((a_pDevIns)->apPciDevs) ? (a_pDevIns)->apPciDevs[(uintptr_t)(a_idxPciDev)] \
5205 : PDMDEV_CALC_PPCIDEV(a_pDevIns, a_idxPciDev) )
5206
5207/**
5208 * Calc the pointer to of a given PCI device.
5209 * @note Returns NULL if @a a_idxPciDev is out of bounds.
5210 */
5211#define PDMDEV_CALC_PPCIDEV(a_pDevIns, a_idxPciDev) \
5212 ( (uintptr_t)(a_idxPciDev) < (a_pDevIns)->cPciDevs \
5213 ? (PPDMPCIDEV)((uint8_t *)((a_pDevIns)->apPciDevs[0]) + (a_pDevIns->cbPciDev) * (uintptr_t)(a_idxPciDev)) \
5214 : (PPDMPCIDEV)NULL )
5215
5216
5217/**
5218 * Checks the structure versions of the device instance and device helpers,
5219 * returning if they are incompatible.
5220 *
5221 * This is for use in the constructor.
5222 *
5223 * @param pDevIns The device instance pointer.
5224 */
5225#define PDMDEV_CHECK_VERSIONS_RETURN(pDevIns) \
5226 do \
5227 { \
5228 PPDMDEVINS pDevInsTypeCheck = (pDevIns); NOREF(pDevInsTypeCheck); \
5229 AssertLogRelMsgReturn(PDM_VERSION_ARE_COMPATIBLE((pDevIns)->u32Version, PDM_DEVINS_VERSION), \
5230 ("DevIns=%#x mine=%#x\n", (pDevIns)->u32Version, PDM_DEVINS_VERSION), \
5231 VERR_PDM_DEVINS_VERSION_MISMATCH); \
5232 AssertLogRelMsgReturn(PDM_VERSION_ARE_COMPATIBLE((pDevIns)->CTX_SUFF(pHlp)->u32Version, CTX_MID(PDM_DEVHLP,_VERSION)), \
5233 ("DevHlp=%#x mine=%#x\n", (pDevIns)->CTX_SUFF(pHlp)->u32Version, CTX_MID(PDM_DEVHLP,_VERSION)), \
5234 VERR_PDM_DEVHLP_VERSION_MISMATCH); \
5235 } while (0)
5236
5237/**
5238 * Quietly checks the structure versions of the device instance and device
5239 * helpers, returning if they are incompatible.
5240 *
5241 * This is for use in the destructor.
5242 *
5243 * @param pDevIns The device instance pointer.
5244 */
5245#define PDMDEV_CHECK_VERSIONS_RETURN_QUIET(pDevIns) \
5246 do \
5247 { \
5248 PPDMDEVINS pDevInsTypeCheck = (pDevIns); NOREF(pDevInsTypeCheck); \
5249 if (RT_LIKELY(PDM_VERSION_ARE_COMPATIBLE((pDevIns)->u32Version, PDM_DEVINS_VERSION) )) \
5250 { /* likely */ } else return VERR_PDM_DEVINS_VERSION_MISMATCH; \
5251 if (RT_LIKELY(PDM_VERSION_ARE_COMPATIBLE((pDevIns)->CTX_SUFF(pHlp)->u32Version, CTX_MID(PDM_DEVHLP,_VERSION)) )) \
5252 { /* likely */ } else return VERR_PDM_DEVHLP_VERSION_MISMATCH; \
5253 } while (0)
5254
5255/**
5256 * Wrapper around CFGMR3ValidateConfig for the root config for use in the
5257 * constructor - returns on failure.
5258 *
5259 * This should be invoked after having initialized the instance data
5260 * sufficiently for the correct operation of the destructor. The destructor is
5261 * always called!
5262 *
5263 * @param pDevIns Pointer to the PDM device instance.
5264 * @param pszValidValues Patterns describing the valid value names. See
5265 * RTStrSimplePatternMultiMatch for details on the
5266 * pattern syntax.
5267 * @param pszValidNodes Patterns describing the valid node (key) names.
5268 * Pass empty string if no valid nodes.
5269 */
5270#define PDMDEV_VALIDATE_CONFIG_RETURN(pDevIns, pszValidValues, pszValidNodes) \
5271 do \
5272 { \
5273 int rcValCfg = pDevIns->pHlpR3->pfnCFGMValidateConfig((pDevIns)->pCfg, "/", pszValidValues, pszValidNodes, \
5274 (pDevIns)->pReg->szName, (pDevIns)->iInstance); \
5275 if (RT_SUCCESS(rcValCfg)) \
5276 { /* likely */ } else return rcValCfg; \
5277 } while (0)
5278
5279/** @def PDMDEV_ASSERT_EMT
5280 * Assert that the current thread is the emulation thread.
5281 */
5282#ifdef VBOX_STRICT
5283# define PDMDEV_ASSERT_EMT(pDevIns) pDevIns->pHlpR3->pfnAssertEMT(pDevIns, __FILE__, __LINE__, __FUNCTION__)
5284#else
5285# define PDMDEV_ASSERT_EMT(pDevIns) do { } while (0)
5286#endif
5287
5288/** @def PDMDEV_ASSERT_OTHER
5289 * Assert that the current thread is NOT the emulation thread.
5290 */
5291#ifdef VBOX_STRICT
5292# define PDMDEV_ASSERT_OTHER(pDevIns) pDevIns->pHlpR3->pfnAssertOther(pDevIns, __FILE__, __LINE__, __FUNCTION__)
5293#else
5294# define PDMDEV_ASSERT_OTHER(pDevIns) do { } while (0)
5295#endif
5296
5297/** @def PDMDEV_ASSERT_VMLOCK_OWNER
5298 * Assert that the current thread is owner of the VM lock.
5299 */
5300#ifdef VBOX_STRICT
5301# define PDMDEV_ASSERT_VMLOCK_OWNER(pDevIns) pDevIns->pHlpR3->pfnAssertVMLock(pDevIns, __FILE__, __LINE__, __FUNCTION__)
5302#else
5303# define PDMDEV_ASSERT_VMLOCK_OWNER(pDevIns) do { } while (0)
5304#endif
5305
5306/** @def PDMDEV_SET_ERROR
5307 * Set the VM error. See PDMDevHlpVMSetError() for printf like message formatting.
5308 */
5309#define PDMDEV_SET_ERROR(pDevIns, rc, pszError) \
5310 PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS, "%s", pszError)
5311
5312/** @def PDMDEV_SET_RUNTIME_ERROR
5313 * Set the VM runtime error. See PDMDevHlpVMSetRuntimeError() for printf like message formatting.
5314 */
5315#define PDMDEV_SET_RUNTIME_ERROR(pDevIns, fFlags, pszErrorId, pszError) \
5316 PDMDevHlpVMSetRuntimeError(pDevIns, fFlags, pszErrorId, "%s", pszError)
5317
5318/** @def PDMDEVINS_2_RCPTR
5319 * Converts a PDM Device instance pointer a RC PDM Device instance pointer.
5320 */
5321#ifdef IN_RC
5322# define PDMDEVINS_2_RCPTR(pDevIns) (pDevIns)
5323#else
5324# define PDMDEVINS_2_RCPTR(pDevIns) ( (pDevIns)->pDevInsForRC )
5325#endif
5326
5327/** @def PDMDEVINS_2_R3PTR
5328 * Converts a PDM Device instance pointer a R3 PDM Device instance pointer.
5329 */
5330#ifdef IN_RING3
5331# define PDMDEVINS_2_R3PTR(pDevIns) (pDevIns)
5332#else
5333# define PDMDEVINS_2_R3PTR(pDevIns) ( (pDevIns)->pDevInsForR3 )
5334#endif
5335
5336/** @def PDMDEVINS_2_R0PTR
5337 * Converts a PDM Device instance pointer a R0 PDM Device instance pointer.
5338 */
5339#ifdef IN_RING0
5340# define PDMDEVINS_2_R0PTR(pDevIns) (pDevIns)
5341#else
5342# define PDMDEVINS_2_R0PTR(pDevIns) ( (pDevIns)->pDevInsR0RemoveMe )
5343#endif
5344
5345/** @def PDMDEVINS_DATA_2_R0_REMOVE_ME
5346 * Converts a PDM device instance data pointer to a ring-0 one.
5347 * @deprecated
5348 */
5349#ifdef IN_RING0
5350# define PDMDEVINS_DATA_2_R0_REMOVE_ME(pDevIns, pvCC) (pvCC)
5351#else
5352# define PDMDEVINS_DATA_2_R0_REMOVE_ME(pDevIns, pvCC) ( (pDevIns)->pvInstanceDataR0 + (uintptr_t)(pvCC) - (uintptr_t)(pDevIns)->CTX_SUFF(pvInstanceData) )
5353#endif
5354
5355
5356/** @def PDMDEVINS_2_DATA
5357 * This is a safer edition of PDMINS_2_DATA that checks that the size of the
5358 * target type is same as PDMDEVREG::cbInstanceShared in strict builds.
5359 *
5360 * @note Do no use this macro in common code working on a core structure which
5361 * device specific code has expanded.
5362 */
5363#if defined(VBOX_STRICT) && defined(RT_COMPILER_SUPPORTS_LAMBDA)
5364# define PDMDEVINS_2_DATA(a_pDevIns, a_PtrType) \
5365 ([](PPDMDEVINS a_pLambdaDevIns) -> a_PtrType \
5366 { \
5367 a_PtrType pLambdaRet = (a_PtrType)(a_pLambdaDevIns)->CTX_SUFF(pvInstanceData); \
5368 Assert(sizeof(*pLambdaRet) == a_pLambdaDevIns->pReg->cbInstanceShared); \
5369 return pLambdaRet; \
5370 }(a_pDevIns))
5371#else
5372# define PDMDEVINS_2_DATA(a_pDevIns, a_PtrType) ( (a_PtrType)(a_pDevIns)->CTX_SUFF(pvInstanceData) )
5373#endif
5374
5375/** @def PDMDEVINS_2_DATA_CC
5376 * This is a safer edition of PDMINS_2_DATA_CC that checks that the size of the
5377 * target type is same as PDMDEVREG::cbInstanceCC in strict builds.
5378 *
5379 * @note Do no use this macro in common code working on a core structure which
5380 * device specific code has expanded.
5381 */
5382#if defined(VBOX_STRICT) && defined(RT_COMPILER_SUPPORTS_LAMBDA)
5383# define PDMDEVINS_2_DATA_CC(a_pDevIns, a_PtrType) \
5384 ([](PPDMDEVINS a_pLambdaDevIns) -> a_PtrType \
5385 { \
5386 a_PtrType pLambdaRet = (a_PtrType)&(a_pLambdaDevIns)->achInstanceData[0]; \
5387 Assert(sizeof(*pLambdaRet) == a_pLambdaDevIns->pReg->cbInstanceCC); \
5388 return pLambdaRet; \
5389 }(a_pDevIns))
5390#else
5391# define PDMDEVINS_2_DATA_CC(a_pDevIns, a_PtrType) ( (a_PtrType)(void *)&(a_pDevIns)->achInstanceData[0] )
5392#endif
5393
5394
5395#ifdef IN_RING3
5396
5397/**
5398 * Combines PDMDevHlpIoPortCreate() & PDMDevHlpIoPortMap().
5399 */
5400DECLINLINE(int) PDMDevHlpIoPortCreateAndMap(PPDMDEVINS pDevIns, RTIOPORT Port, RTIOPORT cPorts, PFNIOMIOPORTNEWOUT pfnOut,
5401 PFNIOMIOPORTNEWIN pfnIn, const char *pszDesc, PCIOMIOPORTDESC paExtDescs,
5402 PIOMIOPORTHANDLE phIoPorts)
5403{
5404 int rc = pDevIns->pHlpR3->pfnIoPortCreateEx(pDevIns, cPorts, 0, NULL, UINT32_MAX,
5405 pfnOut, pfnIn, NULL, NULL, NULL, pszDesc, paExtDescs, phIoPorts);
5406 if (RT_SUCCESS(rc))
5407 rc = pDevIns->pHlpR3->pfnIoPortMap(pDevIns, *phIoPorts, Port);
5408 return rc;
5409}
5410
5411/**
5412 * Combines PDMDevHlpIoPortCreate() & PDMDevHlpIoPortMap(), but with pvUser.
5413 */
5414DECLINLINE(int) PDMDevHlpIoPortCreateUAndMap(PPDMDEVINS pDevIns, RTIOPORT Port, RTIOPORT cPorts, PFNIOMIOPORTNEWOUT pfnOut,
5415 PFNIOMIOPORTNEWIN pfnIn, void *pvUser,
5416 const char *pszDesc, PCIOMIOPORTDESC paExtDescs, PIOMIOPORTHANDLE phIoPorts)
5417{
5418 int rc = pDevIns->pHlpR3->pfnIoPortCreateEx(pDevIns, cPorts, 0, NULL, UINT32_MAX,
5419 pfnOut, pfnIn, NULL, NULL, pvUser, pszDesc, paExtDescs, phIoPorts);
5420 if (RT_SUCCESS(rc))
5421 rc = pDevIns->pHlpR3->pfnIoPortMap(pDevIns, *phIoPorts, Port);
5422 return rc;
5423}
5424
5425/**
5426 * Combines PDMDevHlpIoPortCreate() & PDMDevHlpIoPortMap(), but with flags.
5427 */
5428DECLINLINE(int) PDMDevHlpIoPortCreateFlagsAndMap(PPDMDEVINS pDevIns, RTIOPORT Port, RTIOPORT cPorts, uint32_t fFlags,
5429 PFNIOMIOPORTNEWOUT pfnOut, PFNIOMIOPORTNEWIN pfnIn,
5430 const char *pszDesc, PCIOMIOPORTDESC paExtDescs, PIOMIOPORTHANDLE phIoPorts)
5431{
5432 int rc = pDevIns->pHlpR3->pfnIoPortCreateEx(pDevIns, cPorts, fFlags, NULL, UINT32_MAX,
5433 pfnOut, pfnIn, NULL, NULL, NULL, pszDesc, paExtDescs, phIoPorts);
5434 if (RT_SUCCESS(rc))
5435 rc = pDevIns->pHlpR3->pfnIoPortMap(pDevIns, *phIoPorts, Port);
5436 return rc;
5437}
5438
5439/**
5440 * Combines PDMDevHlpIoPortCreateEx() & PDMDevHlpIoPortMap().
5441 */
5442DECLINLINE(int) PDMDevHlpIoPortCreateExAndMap(PPDMDEVINS pDevIns, RTIOPORT Port, RTIOPORT cPorts, uint32_t fFlags,
5443 PFNIOMIOPORTNEWOUT pfnOut, PFNIOMIOPORTNEWIN pfnIn,
5444 PFNIOMIOPORTNEWOUTSTRING pfnOutStr, PFNIOMIOPORTNEWINSTRING pfnInStr, void *pvUser,
5445 const char *pszDesc, PCIOMIOPORTDESC paExtDescs, PIOMIOPORTHANDLE phIoPorts)
5446{
5447 int rc = pDevIns->pHlpR3->pfnIoPortCreateEx(pDevIns, cPorts, fFlags, NULL, UINT32_MAX,
5448 pfnOut, pfnIn, pfnOutStr, pfnInStr, pvUser, pszDesc, paExtDescs, phIoPorts);
5449 if (RT_SUCCESS(rc))
5450 rc = pDevIns->pHlpR3->pfnIoPortMap(pDevIns, *phIoPorts, Port);
5451 return rc;
5452}
5453
5454/**
5455 * @sa PDMDevHlpIoPortCreateEx
5456 */
5457DECLINLINE(int) PDMDevHlpIoPortCreate(PPDMDEVINS pDevIns, RTIOPORT cPorts, PPDMPCIDEV pPciDev, uint32_t iPciRegion,
5458 PFNIOMIOPORTNEWOUT pfnOut, PFNIOMIOPORTNEWIN pfnIn, void *pvUser, const char *pszDesc,
5459 PCIOMIOPORTDESC paExtDescs, PIOMIOPORTHANDLE phIoPorts)
5460{
5461 return pDevIns->pHlpR3->pfnIoPortCreateEx(pDevIns, cPorts, 0, pPciDev, iPciRegion,
5462 pfnOut, pfnIn, NULL, NULL, pvUser, pszDesc, paExtDescs, phIoPorts);
5463}
5464
5465
5466/**
5467 * @sa PDMDevHlpIoPortCreateEx
5468 */
5469DECLINLINE(int) PDMDevHlpIoPortCreateIsa(PPDMDEVINS pDevIns, RTIOPORT cPorts, PFNIOMIOPORTNEWOUT pfnOut,
5470 PFNIOMIOPORTNEWIN pfnIn, void *pvUser, const char *pszDesc,
5471 PCIOMIOPORTDESC paExtDescs, PIOMIOPORTHANDLE phIoPorts)
5472{
5473 return pDevIns->pHlpR3->pfnIoPortCreateEx(pDevIns, cPorts, 0, NULL, UINT32_MAX,
5474 pfnOut, pfnIn, NULL, NULL, pvUser, pszDesc, paExtDescs, phIoPorts);
5475}
5476
5477/**
5478 * @copydoc PDMDEVHLPR3::pfnIoPortCreateEx
5479 */
5480DECLINLINE(int) PDMDevHlpIoPortCreateEx(PPDMDEVINS pDevIns, RTIOPORT cPorts, uint32_t fFlags, PPDMPCIDEV pPciDev,
5481 uint32_t iPciRegion, PFNIOMIOPORTNEWOUT pfnOut, PFNIOMIOPORTNEWIN pfnIn,
5482 PFNIOMIOPORTNEWOUTSTRING pfnOutStr, PFNIOMIOPORTNEWINSTRING pfnInStr, void *pvUser,
5483 const char *pszDesc, PCIOMIOPORTDESC paExtDescs, PIOMIOPORTHANDLE phIoPorts)
5484{
5485 return pDevIns->pHlpR3->pfnIoPortCreateEx(pDevIns, cPorts, fFlags, pPciDev, iPciRegion,
5486 pfnOut, pfnIn, pfnOutStr, pfnInStr, pvUser, pszDesc, paExtDescs, phIoPorts);
5487}
5488
5489/**
5490 * @copydoc PDMDEVHLPR3::pfnIoPortMap
5491 */
5492DECLINLINE(int) PDMDevHlpIoPortMap(PPDMDEVINS pDevIns, IOMIOPORTHANDLE hIoPorts, RTIOPORT Port)
5493{
5494 return pDevIns->pHlpR3->pfnIoPortMap(pDevIns, hIoPorts, Port);
5495}
5496
5497/**
5498 * @copydoc PDMDEVHLPR3::pfnIoPortUnmap
5499 */
5500DECLINLINE(int) PDMDevHlpIoPortUnmap(PPDMDEVINS pDevIns, IOMIOPORTHANDLE hIoPorts)
5501{
5502 return pDevIns->pHlpR3->pfnIoPortUnmap(pDevIns, hIoPorts);
5503}
5504
5505/**
5506 * @copydoc PDMDEVHLPR3::pfnIoPortGetMappingAddress
5507 */
5508DECLINLINE(uint32_t) PDMDevHlpIoPortGetMappingAddress(PPDMDEVINS pDevIns, IOMIOPORTHANDLE hIoPorts)
5509{
5510 return pDevIns->pHlpR3->pfnIoPortGetMappingAddress(pDevIns, hIoPorts);
5511}
5512
5513
5514#endif /* IN_RING3 */
5515#if !defined(IN_RING3) || defined(DOXYGEN_RUNNING)
5516
5517/**
5518 * @sa PDMDevHlpIoPortSetUpContextEx
5519 */
5520DECLINLINE(int) PDMDevHlpIoPortSetUpContext(PPDMDEVINS pDevIns, IOMIOPORTHANDLE hIoPorts,
5521 PFNIOMIOPORTNEWOUT pfnOut, PFNIOMIOPORTNEWIN pfnIn, void *pvUser)
5522{
5523 return pDevIns->CTX_SUFF(pHlp)->pfnIoPortSetUpContextEx(pDevIns, hIoPorts, pfnOut, pfnIn, NULL, NULL, pvUser);
5524}
5525
5526/**
5527 * @copydoc PDMDEVHLPR0::pfnIoPortSetUpContextEx
5528 */
5529DECLINLINE(int) PDMDevHlpIoPortSetUpContextEx(PPDMDEVINS pDevIns, IOMIOPORTHANDLE hIoPorts,
5530 PFNIOMIOPORTNEWOUT pfnOut, PFNIOMIOPORTNEWIN pfnIn,
5531 PFNIOMIOPORTNEWOUTSTRING pfnOutStr, PFNIOMIOPORTNEWINSTRING pfnInStr, void *pvUser)
5532{
5533 return pDevIns->CTX_SUFF(pHlp)->pfnIoPortSetUpContextEx(pDevIns, hIoPorts, pfnOut, pfnIn, pfnOutStr, pfnInStr, pvUser);
5534}
5535
5536#endif /* !IN_RING3 || DOXYGEN_RUNNING */
5537#ifdef IN_RING3
5538
5539/**
5540 * @sa PDMDevHlpMmioCreateEx
5541 */
5542DECLINLINE(int) PDMDevHlpMmioCreate(PPDMDEVINS pDevIns, RTGCPHYS cbRegion, PPDMPCIDEV pPciDev, uint32_t iPciRegion,
5543 PFNIOMMMIONEWWRITE pfnWrite, PFNIOMMMIONEWREAD pfnRead, void *pvUser,
5544 uint32_t fFlags, const char *pszDesc, PIOMMMIOHANDLE phRegion)
5545{
5546 return pDevIns->pHlpR3->pfnMmioCreateEx(pDevIns, cbRegion, fFlags, pPciDev, iPciRegion,
5547 pfnWrite, pfnRead, NULL, pvUser, pszDesc, phRegion);
5548}
5549
5550/**
5551 * @copydoc PDMDEVHLPR3::pfnMmioCreateEx
5552 */
5553DECLINLINE(int) PDMDevHlpMmioCreateEx(PPDMDEVINS pDevIns, RTGCPHYS cbRegion,
5554 uint32_t fFlags, PPDMPCIDEV pPciDev, uint32_t iPciRegion,
5555 PFNIOMMMIONEWWRITE pfnWrite, PFNIOMMMIONEWREAD pfnRead, PFNIOMMMIONEWFILL pfnFill,
5556 void *pvUser, const char *pszDesc, PIOMMMIOHANDLE phRegion)
5557{
5558 return pDevIns->pHlpR3->pfnMmioCreateEx(pDevIns, cbRegion, fFlags, pPciDev, iPciRegion,
5559 pfnWrite, pfnRead, pfnFill, pvUser, pszDesc, phRegion);
5560}
5561
5562/**
5563 * @sa PDMDevHlpMmioCreate and PDMDevHlpMmioMap
5564 */
5565DECLINLINE(int) PDMDevHlpMmioCreateAndMap(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTGCPHYS cbRegion,
5566 PFNIOMMMIONEWWRITE pfnWrite, PFNIOMMMIONEWREAD pfnRead,
5567 uint32_t fFlags, const char *pszDesc, PIOMMMIOHANDLE phRegion)
5568{
5569 int rc = pDevIns->pHlpR3->pfnMmioCreateEx(pDevIns, cbRegion, fFlags, NULL /*pPciDev*/, UINT32_MAX /*iPciRegion*/,
5570 pfnWrite, pfnRead, NULL /*pfnFill*/, NULL /*pvUser*/, pszDesc, phRegion);
5571 if (RT_SUCCESS(rc))
5572 rc = pDevIns->pHlpR3->pfnMmioMap(pDevIns, *phRegion, GCPhys);
5573 return rc;
5574}
5575
5576/**
5577 * @sa PDMDevHlpMmioCreateEx and PDMDevHlpMmioMap
5578 */
5579DECLINLINE(int) PDMDevHlpMmioCreateExAndMap(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTGCPHYS cbRegion, uint32_t fFlags,
5580 PPDMPCIDEV pPciDev, uint32_t iPciRegion, PFNIOMMMIONEWWRITE pfnWrite,
5581 PFNIOMMMIONEWREAD pfnRead, PFNIOMMMIONEWFILL pfnFill, void *pvUser,
5582 const char *pszDesc, PIOMMMIOHANDLE phRegion)
5583{
5584 int rc = pDevIns->pHlpR3->pfnMmioCreateEx(pDevIns, cbRegion, fFlags, pPciDev, iPciRegion,
5585 pfnWrite, pfnRead, pfnFill, pvUser, pszDesc, phRegion);
5586 if (RT_SUCCESS(rc))
5587 rc = pDevIns->pHlpR3->pfnMmioMap(pDevIns, *phRegion, GCPhys);
5588 return rc;
5589}
5590
5591/**
5592 * @copydoc PDMDEVHLPR3::pfnMmioMap
5593 */
5594DECLINLINE(int) PDMDevHlpMmioMap(PPDMDEVINS pDevIns, IOMMMIOHANDLE hRegion, RTGCPHYS GCPhys)
5595{
5596 return pDevIns->pHlpR3->pfnMmioMap(pDevIns, hRegion, GCPhys);
5597}
5598
5599/**
5600 * @copydoc PDMDEVHLPR3::pfnMmioUnmap
5601 */
5602DECLINLINE(int) PDMDevHlpMmioUnmap(PPDMDEVINS pDevIns, IOMMMIOHANDLE hRegion)
5603{
5604 return pDevIns->pHlpR3->pfnMmioUnmap(pDevIns, hRegion);
5605}
5606
5607/**
5608 * @copydoc PDMDEVHLPR3::pfnMmioReduce
5609 */
5610DECLINLINE(int) PDMDevHlpMmioReduce(PPDMDEVINS pDevIns, IOMMMIOHANDLE hRegion, RTGCPHYS cbRegion)
5611{
5612 return pDevIns->pHlpR3->pfnMmioReduce(pDevIns, hRegion, cbRegion);
5613}
5614
5615/**
5616 * @copydoc PDMDEVHLPR3::pfnMmioGetMappingAddress
5617 */
5618DECLINLINE(RTGCPHYS) PDMDevHlpMmioGetMappingAddress(PPDMDEVINS pDevIns, IOMMMIOHANDLE hRegion)
5619{
5620 return pDevIns->pHlpR3->pfnMmioGetMappingAddress(pDevIns, hRegion);
5621}
5622
5623#endif /* IN_RING3 */
5624#if !defined(IN_RING3) || defined(DOXYGEN_RUNNING)
5625
5626/**
5627 * @sa PDMDevHlpMmioSetUpContextEx
5628 */
5629DECLINLINE(int) PDMDevHlpMmioSetUpContext(PPDMDEVINS pDevIns, IOMMMIOHANDLE hRegion,
5630 PFNIOMMMIONEWWRITE pfnWrite, PFNIOMMMIONEWREAD pfnRead, void *pvUser)
5631{
5632 return pDevIns->CTX_SUFF(pHlp)->pfnMmioSetUpContextEx(pDevIns, hRegion, pfnWrite, pfnRead, NULL, pvUser);
5633}
5634
5635/**
5636 * @copydoc PDMDEVHLPR0::pfnMmioSetUpContextEx
5637 */
5638DECLINLINE(int) PDMDevHlpMmioSetUpContextEx(PPDMDEVINS pDevIns, IOMMMIOHANDLE hRegion, PFNIOMMMIONEWWRITE pfnWrite,
5639 PFNIOMMMIONEWREAD pfnRead, PFNIOMMMIONEWFILL pfnFill, void *pvUser)
5640{
5641 return pDevIns->CTX_SUFF(pHlp)->pfnMmioSetUpContextEx(pDevIns, hRegion, pfnWrite, pfnRead, pfnFill, pvUser);
5642}
5643
5644#endif /* !IN_RING3 || DOXYGEN_RUNNING */
5645#ifdef IN_RING3
5646
5647/**
5648 * @copydoc PDMDEVHLPR3::pfnMmio2Create
5649 */
5650DECLINLINE(int) PDMDevHlpMmio2Create(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iPciRegion, RTGCPHYS cbRegion,
5651 uint32_t fFlags, const char *pszDesc, void **ppvMapping, PPGMMMIO2HANDLE phRegion)
5652{
5653 return pDevIns->pHlpR3->pfnMmio2Create(pDevIns, pPciDev, iPciRegion, cbRegion, fFlags, pszDesc, ppvMapping, phRegion);
5654}
5655
5656/**
5657 * @copydoc PDMDEVHLPR3::pfnMmio2Map
5658 */
5659DECLINLINE(int) PDMDevHlpMmio2Map(PPDMDEVINS pDevIns, PGMMMIO2HANDLE hRegion, RTGCPHYS GCPhys)
5660{
5661 return pDevIns->pHlpR3->pfnMmio2Map(pDevIns, hRegion, GCPhys);
5662}
5663
5664/**
5665 * @copydoc PDMDEVHLPR3::pfnMmio2Unmap
5666 */
5667DECLINLINE(int) PDMDevHlpMmio2Unmap(PPDMDEVINS pDevIns, PGMMMIO2HANDLE hRegion)
5668{
5669 return pDevIns->pHlpR3->pfnMmio2Unmap(pDevIns, hRegion);
5670}
5671
5672/**
5673 * @copydoc PDMDEVHLPR3::pfnMmio2Reduce
5674 */
5675DECLINLINE(int) PDMDevHlpMmio2Reduce(PPDMDEVINS pDevIns, PGMMMIO2HANDLE hRegion, RTGCPHYS cbRegion)
5676{
5677 return pDevIns->pHlpR3->pfnMmio2Reduce(pDevIns, hRegion, cbRegion);
5678}
5679
5680/**
5681 * @copydoc PDMDEVHLPR3::pfnMmio2GetMappingAddress
5682 */
5683DECLINLINE(RTGCPHYS) PDMDevHlpMmio2GetMappingAddress(PPDMDEVINS pDevIns, PGMMMIO2HANDLE hRegion)
5684{
5685 return pDevIns->pHlpR3->pfnMmio2GetMappingAddress(pDevIns, hRegion);
5686}
5687
5688#endif /* IN_RING3 */
5689#if !defined(IN_RING3) || defined(DOXYGEN_RUNNING)
5690
5691/**
5692 * @copydoc PDMDEVHLPR0::pfnMmio2SetUpContext
5693 */
5694DECLINLINE(int) PDMDevHlpMmio2SetUpContext(PPDMDEVINS pDevIns, PGMMMIO2HANDLE hRegion,
5695 size_t offSub, size_t cbSub, void **ppvMapping)
5696{
5697 return pDevIns->CTX_SUFF(pHlp)->pfnMmio2SetUpContext(pDevIns, hRegion, offSub, cbSub, ppvMapping);
5698}
5699
5700#endif /* !IN_RING3 || DOXYGEN_RUNNING */
5701#ifdef IN_RING3
5702
5703/**
5704 * @copydoc PDMDEVHLPR3::pfnROMRegister
5705 */
5706DECLINLINE(int) PDMDevHlpROMRegister(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, uint32_t cbRange,
5707 const void *pvBinary, uint32_t cbBinary, uint32_t fFlags, const char *pszDesc)
5708{
5709 return pDevIns->pHlpR3->pfnROMRegister(pDevIns, GCPhysStart, cbRange, pvBinary, cbBinary, fFlags, pszDesc);
5710}
5711
5712/**
5713 * @copydoc PDMDEVHLPR3::pfnROMProtectShadow
5714 */
5715DECLINLINE(int) PDMDevHlpROMProtectShadow(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, uint32_t cbRange, PGMROMPROT enmProt)
5716{
5717 return pDevIns->pHlpR3->pfnROMProtectShadow(pDevIns, GCPhysStart, cbRange, enmProt);
5718}
5719
5720/**
5721 * Register a save state data unit.
5722 *
5723 * @returns VBox status.
5724 * @param pDevIns The device instance.
5725 * @param uVersion Data layout version number.
5726 * @param cbGuess The approximate amount of data in the unit.
5727 * Only for progress indicators.
5728 * @param pfnSaveExec Execute save callback, optional.
5729 * @param pfnLoadExec Execute load callback, optional.
5730 */
5731DECLINLINE(int) PDMDevHlpSSMRegister(PPDMDEVINS pDevIns, uint32_t uVersion, size_t cbGuess,
5732 PFNSSMDEVSAVEEXEC pfnSaveExec, PFNSSMDEVLOADEXEC pfnLoadExec)
5733{
5734 return pDevIns->pHlpR3->pfnSSMRegister(pDevIns, uVersion, cbGuess, NULL /*pszBefore*/,
5735 NULL /*pfnLivePrep*/, NULL /*pfnLiveExec*/, NULL /*pfnLiveDone*/,
5736 NULL /*pfnSavePrep*/, pfnSaveExec, NULL /*pfnSaveDone*/,
5737 NULL /*pfnLoadPrep*/, pfnLoadExec, NULL /*pfnLoadDone*/);
5738}
5739
5740/**
5741 * Register a save state data unit with a live save callback as well.
5742 *
5743 * @returns VBox status.
5744 * @param pDevIns The device instance.
5745 * @param uVersion Data layout version number.
5746 * @param cbGuess The approximate amount of data in the unit.
5747 * Only for progress indicators.
5748 * @param pfnLiveExec Execute live callback, optional.
5749 * @param pfnSaveExec Execute save callback, optional.
5750 * @param pfnLoadExec Execute load callback, optional.
5751 */
5752DECLINLINE(int) PDMDevHlpSSMRegister3(PPDMDEVINS pDevIns, uint32_t uVersion, size_t cbGuess,
5753 PFNSSMDEVLIVEEXEC pfnLiveExec, PFNSSMDEVSAVEEXEC pfnSaveExec, PFNSSMDEVLOADEXEC pfnLoadExec)
5754{
5755 return pDevIns->pHlpR3->pfnSSMRegister(pDevIns, uVersion, cbGuess, NULL /*pszBefore*/,
5756 NULL /*pfnLivePrep*/, pfnLiveExec, NULL /*pfnLiveDone*/,
5757 NULL /*pfnSavePrep*/, pfnSaveExec, NULL /*pfnSaveDone*/,
5758 NULL /*pfnLoadPrep*/, pfnLoadExec, NULL /*pfnLoadDone*/);
5759}
5760
5761/**
5762 * @copydoc PDMDEVHLPR3::pfnSSMRegister
5763 */
5764DECLINLINE(int) PDMDevHlpSSMRegisterEx(PPDMDEVINS pDevIns, uint32_t uVersion, size_t cbGuess, const char *pszBefore,
5765 PFNSSMDEVLIVEPREP pfnLivePrep, PFNSSMDEVLIVEEXEC pfnLiveExec, PFNSSMDEVLIVEVOTE pfnLiveVote,
5766 PFNSSMDEVSAVEPREP pfnSavePrep, PFNSSMDEVSAVEEXEC pfnSaveExec, PFNSSMDEVSAVEDONE pfnSaveDone,
5767 PFNSSMDEVLOADPREP pfnLoadPrep, PFNSSMDEVLOADEXEC pfnLoadExec, PFNSSMDEVLOADDONE pfnLoadDone)
5768{
5769 return pDevIns->pHlpR3->pfnSSMRegister(pDevIns, uVersion, cbGuess, pszBefore,
5770 pfnLivePrep, pfnLiveExec, pfnLiveVote,
5771 pfnSavePrep, pfnSaveExec, pfnSaveDone,
5772 pfnLoadPrep, pfnLoadExec, pfnLoadDone);
5773}
5774
5775/**
5776 * @copydoc PDMDEVHLPR3::pfnTMTimerCreate
5777 */
5778DECLINLINE(int) PDMDevHlpTMTimerCreate(PPDMDEVINS pDevIns, TMCLOCK enmClock, PFNTMTIMERDEV pfnCallback, void *pvUser,
5779 uint32_t fFlags, const char *pszDesc, PPTMTIMERR3 ppTimer)
5780{
5781 return pDevIns->pHlpR3->pfnTMTimerCreate(pDevIns, enmClock, pfnCallback, pvUser, fFlags, pszDesc, ppTimer);
5782}
5783
5784/**
5785 * @copydoc PDMDEVHLPR3::pfnTimerCreate
5786 */
5787DECLINLINE(int) PDMDevHlpTimerCreate(PPDMDEVINS pDevIns, TMCLOCK enmClock, PFNTMTIMERDEV pfnCallback, void *pvUser,
5788 uint32_t fFlags, const char *pszDesc, PTMTIMERHANDLE phTimer)
5789{
5790 return pDevIns->pHlpR3->pfnTimerCreate(pDevIns, enmClock, pfnCallback, pvUser, fFlags, pszDesc, phTimer);
5791}
5792
5793#endif /* IN_RING3 */
5794
5795/**
5796 * @copydoc PDMDEVHLPR3::pfnTimerToPtr
5797 */
5798DECLINLINE(PTMTIMER) PDMDevHlpTimerToPtr(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer)
5799{
5800 return pDevIns->CTX_SUFF(pHlp)->pfnTimerToPtr(pDevIns, hTimer);
5801}
5802
5803/**
5804 * @copydoc PDMDEVHLPR3::pfnTimerFromMicro
5805 */
5806DECLINLINE(uint64_t) PDMDevHlpTimerFromMicro(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint64_t cMicroSecs)
5807{
5808 return pDevIns->CTX_SUFF(pHlp)->pfnTimerFromMicro(pDevIns, hTimer, cMicroSecs);
5809}
5810
5811/**
5812 * @copydoc PDMDEVHLPR3::pfnTimerFromMilli
5813 */
5814DECLINLINE(uint64_t) PDMDevHlpTimerFromMilli(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint64_t cMilliSecs)
5815{
5816 return pDevIns->CTX_SUFF(pHlp)->pfnTimerFromMilli(pDevIns, hTimer, cMilliSecs);
5817}
5818
5819/**
5820 * @copydoc PDMDEVHLPR3::pfnTimerFromNano
5821 */
5822DECLINLINE(uint64_t) PDMDevHlpTimerFromNano(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint64_t cNanoSecs)
5823{
5824 return pDevIns->CTX_SUFF(pHlp)->pfnTimerFromNano(pDevIns, hTimer, cNanoSecs);
5825}
5826
5827/**
5828 * @copydoc PDMDEVHLPR3::pfnTimerGet
5829 */
5830DECLINLINE(uint64_t) PDMDevHlpTimerGet(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer)
5831{
5832 return pDevIns->CTX_SUFF(pHlp)->pfnTimerGet(pDevIns, hTimer);
5833}
5834
5835/**
5836 * @copydoc PDMDEVHLPR3::pfnTimerGetFreq
5837 */
5838DECLINLINE(uint64_t) PDMDevHlpTimerGetFreq(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer)
5839{
5840 return pDevIns->CTX_SUFF(pHlp)->pfnTimerGetFreq(pDevIns, hTimer);
5841}
5842
5843/**
5844 * @copydoc PDMDEVHLPR3::pfnTimerGetNano
5845 */
5846DECLINLINE(uint64_t) PDMDevHlpTimerGetNano(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer)
5847{
5848 return pDevIns->CTX_SUFF(pHlp)->pfnTimerGetNano(pDevIns, hTimer);
5849}
5850
5851/**
5852 * @copydoc PDMDEVHLPR3::pfnTimerIsActive
5853 */
5854DECLINLINE(bool) PDMDevHlpTimerIsActive(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer)
5855{
5856 return pDevIns->CTX_SUFF(pHlp)->pfnTimerIsActive(pDevIns, hTimer);
5857}
5858
5859/**
5860 * @copydoc PDMDEVHLPR3::pfnTimerIsLockOwner
5861 */
5862DECLINLINE(bool) PDMDevHlpTimerIsLockOwner(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer)
5863{
5864 return pDevIns->CTX_SUFF(pHlp)->pfnTimerIsLockOwner(pDevIns, hTimer);
5865}
5866
5867/**
5868 * @copydoc PDMDEVHLPR3::pfnTimerLockClock
5869 */
5870DECLINLINE(VBOXSTRICTRC) PDMDevHlpTimerLockClock(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, int rcBusy)
5871{
5872 return pDevIns->CTX_SUFF(pHlp)->pfnTimerLockClock(pDevIns, hTimer, rcBusy);
5873}
5874
5875/**
5876 * @copydoc PDMDEVHLPR3::pfnTimerLockClock2
5877 */
5878DECLINLINE(VBOXSTRICTRC) PDMDevHlpTimerLockClock2(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, PPDMCRITSECT pCritSect, int rcBusy)
5879{
5880 return pDevIns->CTX_SUFF(pHlp)->pfnTimerLockClock2(pDevIns, hTimer, pCritSect, rcBusy);
5881}
5882
5883/**
5884 * @copydoc PDMDEVHLPR3::pfnTimerSet
5885 */
5886DECLINLINE(int) PDMDevHlpTimerSet(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint64_t uExpire)
5887{
5888 return pDevIns->CTX_SUFF(pHlp)->pfnTimerSet(pDevIns, hTimer, uExpire);
5889}
5890
5891/**
5892 * @copydoc PDMDEVHLPR3::pfnTimerSetFrequencyHint
5893 */
5894DECLINLINE(int) PDMDevHlpTimerSetFrequencyHint(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint32_t uHz)
5895{
5896 return pDevIns->CTX_SUFF(pHlp)->pfnTimerSetFrequencyHint(pDevIns, hTimer, uHz);
5897}
5898
5899/**
5900 * @copydoc PDMDEVHLPR3::pfnTimerSetMicro
5901 */
5902DECLINLINE(int) PDMDevHlpTimerSetMicro(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint64_t cMicrosToNext)
5903{
5904 return pDevIns->CTX_SUFF(pHlp)->pfnTimerSetMicro(pDevIns, hTimer, cMicrosToNext);
5905}
5906
5907/**
5908 * @copydoc PDMDEVHLPR3::pfnTimerSetMillies
5909 */
5910DECLINLINE(int) PDMDevHlpTimerSetMillies(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint64_t cMilliesToNext)
5911{
5912 return pDevIns->CTX_SUFF(pHlp)->pfnTimerSetMillies(pDevIns, hTimer, cMilliesToNext);
5913}
5914
5915/**
5916 * @copydoc PDMDEVHLPR3::pfnTimerSetNano
5917 */
5918DECLINLINE(int) PDMDevHlpTimerSetNano(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint64_t cNanosToNext)
5919{
5920 return pDevIns->CTX_SUFF(pHlp)->pfnTimerSetNano(pDevIns, hTimer, cNanosToNext);
5921}
5922
5923/**
5924 * @copydoc PDMDEVHLPR3::pfnTimerSetRelative
5925 */
5926DECLINLINE(int) PDMDevHlpTimerSetRelative(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, uint64_t cTicksToNext, uint64_t *pu64Now)
5927{
5928 return pDevIns->CTX_SUFF(pHlp)->pfnTimerSetRelative(pDevIns, hTimer, cTicksToNext, pu64Now);
5929}
5930
5931/**
5932 * @copydoc PDMDEVHLPR3::pfnTimerStop
5933 */
5934DECLINLINE(int) PDMDevHlpTimerStop(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer)
5935{
5936 return pDevIns->CTX_SUFF(pHlp)->pfnTimerStop(pDevIns, hTimer);
5937}
5938
5939/**
5940 * @copydoc PDMDEVHLPR3::pfnTimerUnlockClock
5941 */
5942DECLINLINE(void) PDMDevHlpTimerUnlockClock(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer)
5943{
5944 pDevIns->CTX_SUFF(pHlp)->pfnTimerUnlockClock(pDevIns, hTimer);
5945}
5946
5947/**
5948 * @copydoc PDMDEVHLPR3::pfnTimerUnlockClock2
5949 */
5950DECLINLINE(void) PDMDevHlpTimerUnlockClock2(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, PPDMCRITSECT pCritSect)
5951{
5952 pDevIns->CTX_SUFF(pHlp)->pfnTimerUnlockClock2(pDevIns, hTimer, pCritSect);
5953}
5954
5955#ifdef IN_RING3
5956
5957/**
5958 * @copydoc PDMDEVHLPR3::pfnTimerSetCritSect
5959 */
5960DECLINLINE(int) PDMDevHlpTimerSetCritSect(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, PPDMCRITSECT pCritSect)
5961{
5962 return pDevIns->pHlpR3->pfnTimerSetCritSect(pDevIns, hTimer, pCritSect);
5963}
5964
5965/**
5966 * @copydoc PDMDEVHLPR3::pfnTimerSave
5967 */
5968DECLINLINE(int) PDMDevHlpTimerSave(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, PSSMHANDLE pSSM)
5969{
5970 return pDevIns->pHlpR3->pfnTimerSave(pDevIns, hTimer, pSSM);
5971}
5972
5973/**
5974 * @copydoc PDMDEVHLPR3::pfnTimerLoad
5975 */
5976DECLINLINE(int) PDMDevHlpTimerLoad(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, PSSMHANDLE pSSM)
5977{
5978 return pDevIns->pHlpR3->pfnTimerLoad(pDevIns, hTimer, pSSM);
5979}
5980
5981/**
5982 * @copydoc PDMDEVHLPR3::pfnTimerDestroy
5983 */
5984DECLINLINE(int) PDMDevHlpTimerDestroy(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer)
5985{
5986 return pDevIns->pHlpR3->pfnTimerDestroy(pDevIns, hTimer);
5987}
5988
5989/**
5990 * @copydoc PDMDEVHLPR3::pfnTMUtcNow
5991 */
5992DECLINLINE(PRTTIMESPEC) PDMDevHlpTMUtcNow(PPDMDEVINS pDevIns, PRTTIMESPEC pTime)
5993{
5994 return pDevIns->pHlpR3->pfnTMUtcNow(pDevIns, pTime);
5995}
5996
5997#endif
5998
5999/**
6000 * @copydoc PDMDEVHLPR3::pfnPhysRead
6001 */
6002DECLINLINE(int) PDMDevHlpPhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)
6003{
6004 return pDevIns->CTX_SUFF(pHlp)->pfnPhysRead(pDevIns, GCPhys, pvBuf, cbRead);
6005}
6006
6007/**
6008 * @copydoc PDMDEVHLPR3::pfnPhysWrite
6009 */
6010DECLINLINE(int) PDMDevHlpPhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)
6011{
6012 return pDevIns->CTX_SUFF(pHlp)->pfnPhysWrite(pDevIns, GCPhys, pvBuf, cbWrite);
6013}
6014
6015#ifdef IN_RING3
6016
6017/**
6018 * @copydoc PDMDEVHLPR3::pfnPhysGCPhys2CCPtr
6019 */
6020DECLINLINE(int) PDMDevHlpPhysGCPhys2CCPtr(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, uint32_t fFlags, void **ppv, PPGMPAGEMAPLOCK pLock)
6021{
6022 return pDevIns->CTX_SUFF(pHlp)->pfnPhysGCPhys2CCPtr(pDevIns, GCPhys, fFlags, ppv, pLock);
6023}
6024
6025/**
6026 * @copydoc PDMDEVHLPR3::pfnPhysGCPhys2CCPtrReadOnly
6027 */
6028DECLINLINE(int) PDMDevHlpPhysGCPhys2CCPtrReadOnly(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, uint32_t fFlags, void const **ppv,
6029 PPGMPAGEMAPLOCK pLock)
6030{
6031 return pDevIns->CTX_SUFF(pHlp)->pfnPhysGCPhys2CCPtrReadOnly(pDevIns, GCPhys, fFlags, ppv, pLock);
6032}
6033
6034/**
6035 * @copydoc PDMDEVHLPR3::pfnPhysReleasePageMappingLock
6036 */
6037DECLINLINE(void) PDMDevHlpPhysReleasePageMappingLock(PPDMDEVINS pDevIns, PPGMPAGEMAPLOCK pLock)
6038{
6039 pDevIns->CTX_SUFF(pHlp)->pfnPhysReleasePageMappingLock(pDevIns, pLock);
6040}
6041
6042/**
6043 * @copydoc PDMDEVHLPR3::pfnPhysBulkGCPhys2CCPtr
6044 */
6045DECLINLINE(int) PDMDevHlpPhysBulkGCPhys2CCPtr(PPDMDEVINS pDevIns, uint32_t cPages, PCRTGCPHYS paGCPhysPages,
6046 uint32_t fFlags, void **papvPages, PPGMPAGEMAPLOCK paLocks)
6047{
6048 return pDevIns->CTX_SUFF(pHlp)->pfnPhysBulkGCPhys2CCPtr(pDevIns, cPages, paGCPhysPages, fFlags, papvPages, paLocks);
6049}
6050
6051/**
6052 * @copydoc PDMDEVHLPR3::pfnPhysBulkGCPhys2CCPtrReadOnly
6053 */
6054DECLINLINE(int) PDMDevHlpPhysBulkGCPhys2CCPtrReadOnly(PPDMDEVINS pDevIns, uint32_t cPages, PCRTGCPHYS paGCPhysPages,
6055 uint32_t fFlags, void const **papvPages, PPGMPAGEMAPLOCK paLocks)
6056{
6057 return pDevIns->CTX_SUFF(pHlp)->pfnPhysBulkGCPhys2CCPtrReadOnly(pDevIns, cPages, paGCPhysPages, fFlags, papvPages, paLocks);
6058}
6059
6060/**
6061 * @copydoc PDMDEVHLPR3::pfnPhysBulkReleasePageMappingLocks
6062 */
6063DECLINLINE(void) PDMDevHlpPhysBulkReleasePageMappingLocks(PPDMDEVINS pDevIns, uint32_t cPages, PPGMPAGEMAPLOCK paLocks)
6064{
6065 pDevIns->CTX_SUFF(pHlp)->pfnPhysBulkReleasePageMappingLocks(pDevIns, cPages, paLocks);
6066}
6067
6068/**
6069 * @copydoc PDMDEVHLPR3::pfnPhysReadGCVirt
6070 */
6071DECLINLINE(int) PDMDevHlpPhysReadGCVirt(PPDMDEVINS pDevIns, void *pvDst, RTGCPTR GCVirtSrc, size_t cb)
6072{
6073 return pDevIns->pHlpR3->pfnPhysReadGCVirt(pDevIns, pvDst, GCVirtSrc, cb);
6074}
6075
6076/**
6077 * @copydoc PDMDEVHLPR3::pfnPhysWriteGCVirt
6078 */
6079DECLINLINE(int) PDMDevHlpPhysWriteGCVirt(PPDMDEVINS pDevIns, RTGCPTR GCVirtDst, const void *pvSrc, size_t cb)
6080{
6081 return pDevIns->pHlpR3->pfnPhysWriteGCVirt(pDevIns, GCVirtDst, pvSrc, cb);
6082}
6083
6084/**
6085 * @copydoc PDMDEVHLPR3::pfnPhysGCPtr2GCPhys
6086 */
6087DECLINLINE(int) PDMDevHlpPhysGCPtr2GCPhys(PPDMDEVINS pDevIns, RTGCPTR GCPtr, PRTGCPHYS pGCPhys)
6088{
6089 return pDevIns->pHlpR3->pfnPhysGCPtr2GCPhys(pDevIns, GCPtr, pGCPhys);
6090}
6091
6092/**
6093 * @copydoc PDMDEVHLPR3::pfnMMHeapAlloc
6094 */
6095DECLINLINE(void *) PDMDevHlpMMHeapAlloc(PPDMDEVINS pDevIns, size_t cb)
6096{
6097 return pDevIns->pHlpR3->pfnMMHeapAlloc(pDevIns, cb);
6098}
6099
6100/**
6101 * @copydoc PDMDEVHLPR3::pfnMMHeapAllocZ
6102 */
6103DECLINLINE(void *) PDMDevHlpMMHeapAllocZ(PPDMDEVINS pDevIns, size_t cb)
6104{
6105 return pDevIns->pHlpR3->pfnMMHeapAllocZ(pDevIns, cb);
6106}
6107
6108/**
6109 * @copydoc PDMDEVHLPR3::pfnMMHeapFree
6110 */
6111DECLINLINE(void) PDMDevHlpMMHeapFree(PPDMDEVINS pDevIns, void *pv)
6112{
6113 pDevIns->pHlpR3->pfnMMHeapFree(pDevIns, pv);
6114}
6115#endif /* IN_RING3 */
6116
6117/**
6118 * @copydoc PDMDEVHLPR3::pfnVMState
6119 */
6120DECLINLINE(VMSTATE) PDMDevHlpVMState(PPDMDEVINS pDevIns)
6121{
6122 return pDevIns->CTX_SUFF(pHlp)->pfnVMState(pDevIns);
6123}
6124
6125#ifdef IN_RING3
6126/**
6127 * @copydoc PDMDEVHLPR3::pfnVMTeleportedAndNotFullyResumedYet
6128 */
6129DECLINLINE(bool) PDMDevHlpVMTeleportedAndNotFullyResumedYet(PPDMDEVINS pDevIns)
6130{
6131 return pDevIns->pHlpR3->pfnVMTeleportedAndNotFullyResumedYet(pDevIns);
6132}
6133#endif /* IN_RING3 */
6134
6135/**
6136 * @copydoc PDMDEVHLPR3::pfnVMSetError
6137 */
6138DECLINLINE(int) RT_IPRT_FORMAT_ATTR(6, 7) PDMDevHlpVMSetError(PPDMDEVINS pDevIns, const int rc, RT_SRC_POS_DECL,
6139 const char *pszFormat, ...)
6140{
6141 va_list va;
6142 va_start(va, pszFormat);
6143 pDevIns->CTX_SUFF(pHlp)->pfnVMSetErrorV(pDevIns, rc, RT_SRC_POS_ARGS, pszFormat, va);
6144 va_end(va);
6145 return rc;
6146}
6147
6148/**
6149 * @copydoc PDMDEVHLPR3::pfnVMSetRuntimeError
6150 */
6151DECLINLINE(int) RT_IPRT_FORMAT_ATTR(4, 5) PDMDevHlpVMSetRuntimeError(PPDMDEVINS pDevIns, uint32_t fFlags, const char *pszErrorId,
6152 const char *pszFormat, ...)
6153{
6154 va_list va;
6155 int rc;
6156 va_start(va, pszFormat);
6157 rc = pDevIns->CTX_SUFF(pHlp)->pfnVMSetRuntimeErrorV(pDevIns, fFlags, pszErrorId, pszFormat, va);
6158 va_end(va);
6159 return rc;
6160}
6161
6162/**
6163 * VBOX_STRICT wrapper for pHlp->pfnDBGFStopV.
6164 *
6165 * @returns VBox status code which must be passed up to the VMM. This will be
6166 * VINF_SUCCESS in non-strict builds.
6167 * @param pDevIns The device instance.
6168 * @param SRC_POS Use RT_SRC_POS.
6169 * @param pszFormat Message. (optional)
6170 * @param ... Message parameters.
6171 */
6172DECLINLINE(int) RT_IPRT_FORMAT_ATTR(5, 6) PDMDevHlpDBGFStop(PPDMDEVINS pDevIns, RT_SRC_POS_DECL, const char *pszFormat, ...)
6173{
6174#ifdef VBOX_STRICT
6175# ifdef IN_RING3
6176 int rc;
6177 va_list args;
6178 va_start(args, pszFormat);
6179 rc = pDevIns->pHlpR3->pfnDBGFStopV(pDevIns, RT_SRC_POS_ARGS, pszFormat, args);
6180 va_end(args);
6181 return rc;
6182# else
6183 NOREF(pDevIns);
6184 NOREF(pszFile);
6185 NOREF(iLine);
6186 NOREF(pszFunction);
6187 NOREF(pszFormat);
6188 return VINF_EM_DBG_STOP;
6189# endif
6190#else
6191 NOREF(pDevIns);
6192 NOREF(pszFile);
6193 NOREF(iLine);
6194 NOREF(pszFunction);
6195 NOREF(pszFormat);
6196 return VINF_SUCCESS;
6197#endif
6198}
6199
6200#ifdef IN_RING3
6201
6202/**
6203 * @copydoc PDMDEVHLPR3::pfnDBGFInfoRegister
6204 */
6205DECLINLINE(int) PDMDevHlpDBGFInfoRegister(PPDMDEVINS pDevIns, const char *pszName, const char *pszDesc, PFNDBGFHANDLERDEV pfnHandler)
6206{
6207 return pDevIns->pHlpR3->pfnDBGFInfoRegister(pDevIns, pszName, pszDesc, pfnHandler);
6208}
6209
6210/**
6211 * @copydoc PDMDEVHLPR3::pfnDBGFInfoRegisterArgv
6212 */
6213DECLINLINE(int) PDMDevHlpDBGFInfoRegisterArgv(PPDMDEVINS pDevIns, const char *pszName, const char *pszDesc, PFNDBGFINFOARGVDEV pfnHandler)
6214{
6215 return pDevIns->pHlpR3->pfnDBGFInfoRegisterArgv(pDevIns, pszName, pszDesc, pfnHandler);
6216}
6217
6218/**
6219 * @copydoc PDMDEVHLPR3::pfnDBGFRegRegister
6220 */
6221DECLINLINE(int) PDMDevHlpDBGFRegRegister(PPDMDEVINS pDevIns, PCDBGFREGDESC paRegisters)
6222{
6223 return pDevIns->pHlpR3->pfnDBGFRegRegister(pDevIns, paRegisters);
6224}
6225
6226/**
6227 * @copydoc PDMDEVHLPR3::pfnSTAMRegister
6228 */
6229DECLINLINE(void) PDMDevHlpSTAMRegister(PPDMDEVINS pDevIns, void *pvSample, STAMTYPE enmType, const char *pszName, STAMUNIT enmUnit, const char *pszDesc)
6230{
6231 pDevIns->pHlpR3->pfnSTAMRegister(pDevIns, pvSample, enmType, pszName, enmUnit, pszDesc);
6232}
6233
6234/**
6235 * Same as pfnSTAMRegister except that the name is specified in a
6236 * RTStrPrintf like fashion.
6237 *
6238 * @returns VBox status.
6239 * @param pDevIns Device instance of the DMA.
6240 * @param pvSample Pointer to the sample.
6241 * @param enmType Sample type. This indicates what pvSample is
6242 * pointing at.
6243 * @param enmVisibility Visibility type specifying whether unused
6244 * statistics should be visible or not.
6245 * @param enmUnit Sample unit.
6246 * @param pszDesc Sample description.
6247 * @param pszName Sample name format string, unix path style. If
6248 * this does not start with a '/', the default
6249 * prefix will be prepended, otherwise it will be
6250 * used as-is.
6251 * @param ... Arguments to the format string.
6252 */
6253DECLINLINE(void) RT_IPRT_FORMAT_ATTR(7, 8) PDMDevHlpSTAMRegisterF(PPDMDEVINS pDevIns, void *pvSample, STAMTYPE enmType,
6254 STAMVISIBILITY enmVisibility, STAMUNIT enmUnit,
6255 const char *pszDesc, const char *pszName, ...)
6256{
6257 va_list va;
6258 va_start(va, pszName);
6259 pDevIns->pHlpR3->pfnSTAMRegisterV(pDevIns, pvSample, enmType, enmVisibility, enmUnit, pszDesc, pszName, va);
6260 va_end(va);
6261}
6262
6263/**
6264 * Registers the device with the default PCI bus.
6265 *
6266 * @returns VBox status code.
6267 * @param pDevIns The device instance.
6268 * @param pPciDev The PCI device structure.
6269 * This must be kept in the instance data.
6270 * The PCI configuration must be initialized before registration.
6271 */
6272DECLINLINE(int) PDMDevHlpPCIRegister(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev)
6273{
6274 return pDevIns->pHlpR3->pfnPCIRegister(pDevIns, pPciDev, 0 /*fFlags*/,
6275 PDMPCIDEVREG_DEV_NO_FIRST_UNUSED, PDMPCIDEVREG_FUN_NO_FIRST_UNUSED, NULL);
6276}
6277
6278/**
6279 * @copydoc PDMDEVHLPR3::pfnPCIRegister
6280 */
6281DECLINLINE(int) PDMDevHlpPCIRegisterEx(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t fFlags,
6282 uint8_t uPciDevNo, uint8_t uPciFunNo, const char *pszName)
6283{
6284 return pDevIns->pHlpR3->pfnPCIRegister(pDevIns, pPciDev, fFlags, uPciDevNo, uPciFunNo, pszName);
6285}
6286
6287/**
6288 * Initialize MSI emulation support for the first PCI device.
6289 *
6290 * @returns VBox status code.
6291 * @param pDevIns The device instance.
6292 * @param pMsiReg MSI emulation registration structure.
6293 */
6294DECLINLINE(int) PDMDevHlpPCIRegisterMsi(PPDMDEVINS pDevIns, PPDMMSIREG pMsiReg)
6295{
6296 return pDevIns->pHlpR3->pfnPCIRegisterMsi(pDevIns, NULL, pMsiReg);
6297}
6298
6299/**
6300 * @copydoc PDMDEVHLPR3::pfnPCIRegisterMsi
6301 */
6302DECLINLINE(int) PDMDevHlpPCIRegisterMsiEx(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, PPDMMSIREG pMsiReg)
6303{
6304 return pDevIns->pHlpR3->pfnPCIRegisterMsi(pDevIns, pPciDev, pMsiReg);
6305}
6306
6307/**
6308 * Registers a I/O port region for the default PCI device.
6309 *
6310 * @returns VBox status code.
6311 * @param pDevIns The device instance.
6312 * @param iRegion The region number.
6313 * @param cbRegion Size of the region.
6314 * @param hIoPorts Handle to the I/O port region.
6315 */
6316DECLINLINE(int) PDMDevHlpPCIIORegionRegisterIo(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS cbRegion, IOMIOPORTHANDLE hIoPorts)
6317{
6318 return pDevIns->pHlpR3->pfnPCIIORegionRegister(pDevIns, NULL, iRegion, cbRegion, PCI_ADDRESS_SPACE_IO,
6319 PDMPCIDEV_IORGN_F_IOPORT_HANDLE | PDMPCIDEV_IORGN_F_NEW_STYLE, hIoPorts, NULL);
6320}
6321
6322/**
6323 * Registers a I/O port region for the default PCI device, custom map/unmap.
6324 *
6325 * @returns VBox status code.
6326 * @param pDevIns The device instance.
6327 * @param iRegion The region number.
6328 * @param cbRegion Size of the region.
6329 * @param pfnMapUnmap Callback for doing the mapping, optional. The
6330 * callback will be invoked holding only the PDM lock.
6331 * The device lock will _not_ be taken (due to lock
6332 * order).
6333 */
6334DECLINLINE(int) PDMDevHlpPCIIORegionRegisterIoCustom(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS cbRegion,
6335 PFNPCIIOREGIONMAP pfnMapUnmap)
6336{
6337 return pDevIns->pHlpR3->pfnPCIIORegionRegister(pDevIns, NULL, iRegion, cbRegion, PCI_ADDRESS_SPACE_IO,
6338 PDMPCIDEV_IORGN_F_NO_HANDLE | PDMPCIDEV_IORGN_F_NEW_STYLE,
6339 UINT64_MAX, pfnMapUnmap);
6340}
6341
6342/**
6343 * Combines PDMDevHlpIoPortCreate and PDMDevHlpPCIIORegionRegisterIo, creating
6344 * and registering an I/O port region for the default PCI device.
6345 *
6346 * @returns VBox status code.
6347 * @param pDevIns The device instance to register the ports with.
6348 * @param cPorts The count of I/O ports in the region (the size).
6349 * @param iPciRegion The PCI device region.
6350 * @param pfnOut Pointer to function which is gonna handle OUT
6351 * operations. Optional.
6352 * @param pfnIn Pointer to function which is gonna handle IN operations.
6353 * Optional.
6354 * @param pvUser User argument to pass to the callbacks.
6355 * @param pszDesc Pointer to description string. This must not be freed.
6356 * @param paExtDescs Extended per-port descriptions, optional. Partial range
6357 * coverage is allowed. This must not be freed.
6358 * @param phIoPorts Where to return the I/O port range handle.
6359 *
6360 */
6361DECLINLINE(int) PDMDevHlpPCIIORegionCreateIo(PPDMDEVINS pDevIns, uint32_t iPciRegion, RTIOPORT cPorts,
6362 PFNIOMIOPORTNEWOUT pfnOut, PFNIOMIOPORTNEWIN pfnIn, void *pvUser,
6363 const char *pszDesc, PCIOMIOPORTDESC paExtDescs, PIOMIOPORTHANDLE phIoPorts)
6364
6365{
6366 int rc = pDevIns->pHlpR3->pfnIoPortCreateEx(pDevIns, cPorts, 0 /*fFlags*/, pDevIns->apPciDevs[0], iPciRegion << 16,
6367 pfnOut, pfnIn, NULL, NULL, pvUser, pszDesc, paExtDescs, phIoPorts);
6368 if (RT_SUCCESS(rc))
6369 rc = pDevIns->pHlpR3->pfnPCIIORegionRegister(pDevIns, pDevIns->apPciDevs[0], iPciRegion, cPorts, PCI_ADDRESS_SPACE_IO,
6370 PDMPCIDEV_IORGN_F_IOPORT_HANDLE | PDMPCIDEV_IORGN_F_NEW_STYLE,
6371 *phIoPorts, NULL /*pfnMapUnmap*/);
6372 return rc;
6373}
6374
6375/**
6376 * Registers an MMIO region for the default PCI device.
6377 *
6378 * @returns VBox status code.
6379 * @param pDevIns The device instance.
6380 * @param iRegion The region number.
6381 * @param cbRegion Size of the region.
6382 * @param enmType PCI_ADDRESS_SPACE_MEM or
6383 * PCI_ADDRESS_SPACE_MEM_PREFETCH, optionally or-ing in
6384 * PCI_ADDRESS_SPACE_BAR64 or PCI_ADDRESS_SPACE_BAR32.
6385 * @param hMmioRegion Handle to the MMIO region.
6386 * @param pfnMapUnmap Callback for doing the mapping, optional. The
6387 * callback will be invoked holding only the PDM lock.
6388 * The device lock will _not_ be taken (due to lock
6389 * order).
6390 */
6391DECLINLINE(int) PDMDevHlpPCIIORegionRegisterMmio(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS cbRegion, PCIADDRESSSPACE enmType,
6392 IOMMMIOHANDLE hMmioRegion, PFNPCIIOREGIONMAP pfnMapUnmap)
6393{
6394 return pDevIns->pHlpR3->pfnPCIIORegionRegister(pDevIns, NULL, iRegion, cbRegion, enmType,
6395 PDMPCIDEV_IORGN_F_MMIO_HANDLE | PDMPCIDEV_IORGN_F_NEW_STYLE,
6396 hMmioRegion, pfnMapUnmap);
6397}
6398
6399/**
6400 * Registers an MMIO region for the default PCI device, extended version.
6401 *
6402 * @returns VBox status code.
6403 * @param pDevIns The device instance.
6404 * @param pPciDev The PCI device structure.
6405 * @param iRegion The region number.
6406 * @param cbRegion Size of the region.
6407 * @param enmType PCI_ADDRESS_SPACE_MEM or
6408 * PCI_ADDRESS_SPACE_MEM_PREFETCH, optionally or-ing in
6409 * PCI_ADDRESS_SPACE_BAR64 or PCI_ADDRESS_SPACE_BAR32.
6410 * @param hMmioRegion Handle to the MMIO region.
6411 * @param pfnMapUnmap Callback for doing the mapping, optional. The
6412 * callback will be invoked holding only the PDM lock.
6413 * The device lock will _not_ be taken (due to lock
6414 * order).
6415 */
6416DECLINLINE(int) PDMDevHlpPCIIORegionRegisterMmioEx(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion,
6417 RTGCPHYS cbRegion, PCIADDRESSSPACE enmType, IOMMMIOHANDLE hMmioRegion,
6418 PFNPCIIOREGIONMAP pfnMapUnmap)
6419{
6420 return pDevIns->pHlpR3->pfnPCIIORegionRegister(pDevIns, pPciDev, iRegion, cbRegion, enmType,
6421 PDMPCIDEV_IORGN_F_MMIO_HANDLE | PDMPCIDEV_IORGN_F_NEW_STYLE,
6422 hMmioRegion, pfnMapUnmap);
6423}
6424
6425/**
6426 * Combines PDMDevHlpMmioCreate and PDMDevHlpPCIIORegionRegisterMmio, creating
6427 * and registering an MMIO region for the default PCI device.
6428 *
6429 * @returns VBox status code.
6430 * @param pDevIns The device instance to register the ports with.
6431 * @param cbRegion The size of the region in bytes.
6432 * @param iPciRegion The PCI device region.
6433 * @param enmType PCI_ADDRESS_SPACE_MEM or
6434 * PCI_ADDRESS_SPACE_MEM_PREFETCH, optionally or-ing in
6435 * PCI_ADDRESS_SPACE_BAR64 or PCI_ADDRESS_SPACE_BAR32.
6436 * @param fFlags Flags, IOMMMIO_FLAGS_XXX.
6437 * @param pfnWrite Pointer to function which is gonna handle Write
6438 * operations.
6439 * @param pfnRead Pointer to function which is gonna handle Read
6440 * operations.
6441 * @param pvUser User argument to pass to the callbacks.
6442 * @param pszDesc Pointer to description string. This must not be freed.
6443 * @param phRegion Where to return the MMIO region handle.
6444 *
6445 */
6446DECLINLINE(int) PDMDevHlpPCIIORegionCreateMmio(PPDMDEVINS pDevIns, uint32_t iPciRegion, RTGCPHYS cbRegion, PCIADDRESSSPACE enmType,
6447 PFNIOMMMIONEWWRITE pfnWrite, PFNIOMMMIONEWREAD pfnRead, void *pvUser,
6448 uint32_t fFlags, const char *pszDesc, PIOMMMIOHANDLE phRegion)
6449
6450{
6451 int rc = pDevIns->pHlpR3->pfnMmioCreateEx(pDevIns, cbRegion, fFlags, pDevIns->apPciDevs[0], iPciRegion << 16,
6452 pfnWrite, pfnRead, NULL /*pfnFill*/, pvUser, pszDesc, phRegion);
6453 if (RT_SUCCESS(rc))
6454 rc = pDevIns->pHlpR3->pfnPCIIORegionRegister(pDevIns, pDevIns->apPciDevs[0], iPciRegion, cbRegion, enmType,
6455 PDMPCIDEV_IORGN_F_MMIO_HANDLE | PDMPCIDEV_IORGN_F_NEW_STYLE,
6456 *phRegion, NULL /*pfnMapUnmap*/);
6457 return rc;
6458}
6459
6460
6461/**
6462 * Registers an MMIO2 region for the default PCI device.
6463 *
6464 * @returns VBox status code.
6465 * @param pDevIns The device instance.
6466 * @param iRegion The region number.
6467 * @param cbRegion Size of the region.
6468 * @param enmType PCI_ADDRESS_SPACE_MEM or
6469 * PCI_ADDRESS_SPACE_MEM_PREFETCH, optionally or-ing in
6470 * PCI_ADDRESS_SPACE_BAR64 or PCI_ADDRESS_SPACE_BAR32.
6471 * @param hMmio2Region Handle to the MMIO2 region.
6472 */
6473DECLINLINE(int) PDMDevHlpPCIIORegionRegisterMmio2(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS cbRegion,
6474 PCIADDRESSSPACE enmType, PGMMMIO2HANDLE hMmio2Region)
6475{
6476 return pDevIns->pHlpR3->pfnPCIIORegionRegister(pDevIns, NULL, iRegion, cbRegion, enmType,
6477 PDMPCIDEV_IORGN_F_MMIO2_HANDLE | PDMPCIDEV_IORGN_F_NEW_STYLE,
6478 hMmio2Region, NULL);
6479}
6480
6481/**
6482 * Combines PDMDevHlpMmio2Create and PDMDevHlpPCIIORegionRegisterMmio2, creating
6483 * and registering an MMIO2 region for the default PCI device, extended edition.
6484 *
6485 * @returns VBox status code.
6486 * @param pDevIns The device instance to register the ports with.
6487 * @param cbRegion The size of the region in bytes.
6488 * @param iPciRegion The PCI device region.
6489 * @param enmType PCI_ADDRESS_SPACE_MEM or
6490 * PCI_ADDRESS_SPACE_MEM_PREFETCH, optionally or-ing in
6491 * PCI_ADDRESS_SPACE_BAR64 or PCI_ADDRESS_SPACE_BAR32.
6492 * @param pszDesc Pointer to description string. This must not be freed.
6493 * @param ppvMapping Where to store the address of the ring-3 mapping of
6494 * the memory.
6495 * @param phRegion Where to return the MMIO2 region handle.
6496 *
6497 */
6498DECLINLINE(int) PDMDevHlpPCIIORegionCreateMmio2(PPDMDEVINS pDevIns, uint32_t iPciRegion, RTGCPHYS cbRegion,
6499 PCIADDRESSSPACE enmType, const char *pszDesc,
6500 void **ppvMapping, PPGMMMIO2HANDLE phRegion)
6501
6502{
6503 int rc = pDevIns->pHlpR3->pfnMmio2Create(pDevIns, pDevIns->apPciDevs[0], iPciRegion << 16, cbRegion, 0 /*fFlags*/,
6504 pszDesc, ppvMapping, phRegion);
6505 if (RT_SUCCESS(rc))
6506 rc = pDevIns->pHlpR3->pfnPCIIORegionRegister(pDevIns, pDevIns->apPciDevs[0], iPciRegion, cbRegion, enmType,
6507 PDMPCIDEV_IORGN_F_MMIO2_HANDLE | PDMPCIDEV_IORGN_F_NEW_STYLE,
6508 *phRegion, NULL /*pfnCallback*/);
6509 return rc;
6510}
6511
6512/**
6513 * Combines PDMDevHlpMmio2Create and PDMDevHlpPCIIORegionRegisterMmio2, creating
6514 * and registering an MMIO2 region for the default PCI device.
6515 *
6516 * @returns VBox status code.
6517 * @param pDevIns The device instance to register the ports with.
6518 * @param cbRegion The size of the region in bytes.
6519 * @param iPciRegion The PCI device region.
6520 * @param enmType PCI_ADDRESS_SPACE_MEM or
6521 * PCI_ADDRESS_SPACE_MEM_PREFETCH, optionally or-ing in
6522 * PCI_ADDRESS_SPACE_BAR64 or PCI_ADDRESS_SPACE_BAR32.
6523 * @param fMmio2Flags To be defined, must be zero.
6524 * @param pfnMapUnmap Callback for doing the mapping, optional. The
6525 * callback will be invoked holding only the PDM lock.
6526 * The device lock will _not_ be taken (due to lock
6527 * order).
6528 * @param pszDesc Pointer to description string. This must not be freed.
6529 * @param ppvMapping Where to store the address of the ring-3 mapping of
6530 * the memory.
6531 * @param phRegion Where to return the MMIO2 region handle.
6532 *
6533 */
6534DECLINLINE(int) PDMDevHlpPCIIORegionCreateMmio2Ex(PPDMDEVINS pDevIns, uint32_t iPciRegion, RTGCPHYS cbRegion,
6535 PCIADDRESSSPACE enmType, uint32_t fMmio2Flags, PFNPCIIOREGIONMAP pfnMapUnmap,
6536 const char *pszDesc, void **ppvMapping, PPGMMMIO2HANDLE phRegion)
6537
6538{
6539 int rc = pDevIns->pHlpR3->pfnMmio2Create(pDevIns, pDevIns->apPciDevs[0], iPciRegion << 16, cbRegion, fMmio2Flags,
6540 pszDesc, ppvMapping, phRegion);
6541 if (RT_SUCCESS(rc))
6542 rc = pDevIns->pHlpR3->pfnPCIIORegionRegister(pDevIns, pDevIns->apPciDevs[0], iPciRegion, cbRegion, enmType,
6543 PDMPCIDEV_IORGN_F_MMIO2_HANDLE | PDMPCIDEV_IORGN_F_NEW_STYLE,
6544 *phRegion, pfnMapUnmap);
6545 return rc;
6546}
6547
6548/**
6549 * @copydoc PDMDEVHLPR3::pfnPCIInterceptConfigAccesses
6550 */
6551DECLINLINE(int) PDMDevHlpPCIInterceptConfigAccesses(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev,
6552 PFNPCICONFIGREAD pfnRead, PFNPCICONFIGWRITE pfnWrite)
6553{
6554 return pDevIns->pHlpR3->pfnPCIInterceptConfigAccesses(pDevIns, pPciDev, pfnRead, pfnWrite);
6555}
6556
6557/**
6558 * @copydoc PDMDEVHLPR3::pfnPCIConfigRead
6559 */
6560DECLINLINE(VBOXSTRICTRC) PDMDevHlpPCIConfigRead(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t uAddress,
6561 unsigned cb, uint32_t *pu32Value)
6562{
6563 return pDevIns->pHlpR3->pfnPCIConfigRead(pDevIns, pPciDev, uAddress, cb, pu32Value);
6564}
6565
6566/**
6567 * @copydoc PDMDEVHLPR3::pfnPCIConfigWrite
6568 */
6569DECLINLINE(VBOXSTRICTRC) PDMDevHlpPCIConfigWrite(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t uAddress,
6570 unsigned cb, uint32_t u32Value)
6571{
6572 return pDevIns->pHlpR3->pfnPCIConfigWrite(pDevIns, pPciDev, uAddress, cb, u32Value);
6573}
6574
6575#endif /* IN_RING3 */
6576
6577/**
6578 * Bus master physical memory read from the default PCI device.
6579 *
6580 * @returns VINF_SUCCESS or VERR_PGM_PCI_PHYS_READ_BM_DISABLED, later maybe
6581 * VERR_EM_MEMORY. The informational status shall NOT be propagated!
6582 * @param pDevIns The device instance.
6583 * @param GCPhys Physical address start reading from.
6584 * @param pvBuf Where to put the read bits.
6585 * @param cbRead How many bytes to read.
6586 * @thread Any thread, but the call may involve the emulation thread.
6587 */
6588DECLINLINE(int) PDMDevHlpPCIPhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)
6589{
6590 return pDevIns->CTX_SUFF(pHlp)->pfnPCIPhysRead(pDevIns, NULL, GCPhys, pvBuf, cbRead);
6591}
6592
6593/**
6594 * @copydoc PDMDEVHLPR3::pfnPCIPhysRead
6595 */
6596DECLINLINE(int) PDMDevHlpPCIPhysReadEx(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)
6597{
6598 return pDevIns->CTX_SUFF(pHlp)->pfnPCIPhysRead(pDevIns, pPciDev, GCPhys, pvBuf, cbRead);
6599}
6600
6601/**
6602 * Bus master physical memory write from the default PCI device.
6603 *
6604 * @returns VINF_SUCCESS or VERR_PGM_PCI_PHYS_WRITE_BM_DISABLED, later maybe
6605 * VERR_EM_MEMORY. The informational status shall NOT be propagated!
6606 * @param pDevIns The device instance.
6607 * @param GCPhys Physical address to write to.
6608 * @param pvBuf What to write.
6609 * @param cbWrite How many bytes to write.
6610 * @thread Any thread, but the call may involve the emulation thread.
6611 */
6612DECLINLINE(int) PDMDevHlpPCIPhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)
6613{
6614 return pDevIns->CTX_SUFF(pHlp)->pfnPCIPhysWrite(pDevIns, NULL, GCPhys, pvBuf, cbWrite);
6615}
6616
6617/**
6618 * @copydoc PDMDEVHLPR3::pfnPCIPhysWrite
6619 */
6620DECLINLINE(int) PDMDevHlpPCIPhysWriteEx(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)
6621{
6622 return pDevIns->CTX_SUFF(pHlp)->pfnPCIPhysWrite(pDevIns, pPciDev, GCPhys, pvBuf, cbWrite);
6623}
6624
6625/**
6626 * Sets the IRQ for the default PCI device.
6627 *
6628 * @param pDevIns The device instance.
6629 * @param iIrq IRQ number to set.
6630 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
6631 * @thread Any thread, but will involve the emulation thread.
6632 */
6633DECLINLINE(void) PDMDevHlpPCISetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel)
6634{
6635 pDevIns->CTX_SUFF(pHlp)->pfnPCISetIrq(pDevIns, NULL, iIrq, iLevel);
6636}
6637
6638/**
6639 * @copydoc PDMDEVHLPR3::pfnPCISetIrq
6640 */
6641DECLINLINE(void) PDMDevHlpPCISetIrqEx(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iIrq, int iLevel)
6642{
6643 pDevIns->CTX_SUFF(pHlp)->pfnPCISetIrq(pDevIns, pPciDev, iIrq, iLevel);
6644}
6645
6646/**
6647 * Sets the IRQ for the given PCI device, but doesn't wait for EMT to process
6648 * the request when not called from EMT.
6649 *
6650 * @param pDevIns The device instance.
6651 * @param iIrq IRQ number to set.
6652 * @param iLevel IRQ level.
6653 * @thread Any thread, but will involve the emulation thread.
6654 */
6655DECLINLINE(void) PDMDevHlpPCISetIrqNoWait(PPDMDEVINS pDevIns, int iIrq, int iLevel)
6656{
6657 pDevIns->CTX_SUFF(pHlp)->pfnPCISetIrq(pDevIns, NULL, iIrq, iLevel);
6658}
6659
6660/**
6661 * @copydoc PDMDEVHLPR3::pfnPCISetIrqNoWait
6662 */
6663DECLINLINE(void) PDMDevHlpPCISetIrqNoWaitEx(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iIrq, int iLevel)
6664{
6665 pDevIns->CTX_SUFF(pHlp)->pfnPCISetIrq(pDevIns, pPciDev, iIrq, iLevel);
6666}
6667
6668/**
6669 * @copydoc PDMDEVHLPR3::pfnISASetIrq
6670 */
6671DECLINLINE(void) PDMDevHlpISASetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel)
6672{
6673 pDevIns->CTX_SUFF(pHlp)->pfnISASetIrq(pDevIns, iIrq, iLevel);
6674}
6675
6676/**
6677 * @copydoc PDMDEVHLPR3::pfnISASetIrqNoWait
6678 */
6679DECLINLINE(void) PDMDevHlpISASetIrqNoWait(PPDMDEVINS pDevIns, int iIrq, int iLevel)
6680{
6681 pDevIns->CTX_SUFF(pHlp)->pfnISASetIrq(pDevIns, iIrq, iLevel);
6682}
6683
6684/**
6685 * @copydoc PDMDEVHLPR3::pfnIoApicSendMsi
6686 */
6687DECLINLINE(void) PDMDevHlpIoApicSendMsi(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, uint32_t uValue)
6688{
6689 pDevIns->CTX_SUFF(pHlp)->pfnIoApicSendMsi(pDevIns, GCPhys, uValue);
6690}
6691
6692#ifdef IN_RING3
6693
6694/**
6695 * @copydoc PDMDEVHLPR3::pfnDriverAttach
6696 */
6697DECLINLINE(int) PDMDevHlpDriverAttach(PPDMDEVINS pDevIns, uint32_t iLun, PPDMIBASE pBaseInterface, PPDMIBASE *ppBaseInterface, const char *pszDesc)
6698{
6699 return pDevIns->pHlpR3->pfnDriverAttach(pDevIns, iLun, pBaseInterface, ppBaseInterface, pszDesc);
6700}
6701
6702/**
6703 * @copydoc PDMDEVHLPR3::pfnDriverDetach
6704 */
6705DECLINLINE(int) PDMDevHlpDriverDetach(PPDMDEVINS pDevIns, PPDMDRVINS pDrvIns, uint32_t fFlags)
6706{
6707 return pDevIns->pHlpR3->pfnDriverDetach(pDevIns, pDrvIns, fFlags);
6708}
6709
6710/**
6711 * @copydoc PDMDEVHLPR3::pfnDriverReconfigure
6712 */
6713DECLINLINE(int) PDMDevHlpDriverReconfigure(PPDMDEVINS pDevIns, uint32_t iLun, uint32_t cDepth,
6714 const char * const *papszDrivers, PCFGMNODE *papConfigs, uint32_t fFlags)
6715{
6716 return pDevIns->pHlpR3->pfnDriverReconfigure(pDevIns, iLun, cDepth, papszDrivers, papConfigs, fFlags);
6717}
6718
6719/**
6720 * Reconfigures with a single driver reattachement, no config, noflags.
6721 * @sa PDMDevHlpDriverReconfigure
6722 */
6723DECLINLINE(int) PDMDevHlpDriverReconfigure1(PPDMDEVINS pDevIns, uint32_t iLun, const char *pszDriver0)
6724{
6725 return pDevIns->pHlpR3->pfnDriverReconfigure(pDevIns, iLun, 1, &pszDriver0, NULL, 0);
6726}
6727
6728/**
6729 * Reconfigures with a two drivers reattachement, no config, noflags.
6730 * @sa PDMDevHlpDriverReconfigure
6731 */
6732DECLINLINE(int) PDMDevHlpDriverReconfigure2(PPDMDEVINS pDevIns, uint32_t iLun, const char *pszDriver0, const char *pszDriver1)
6733{
6734 char const * apszDrivers[2];
6735 apszDrivers[0] = pszDriver0;
6736 apszDrivers[1] = pszDriver1;
6737 return pDevIns->pHlpR3->pfnDriverReconfigure(pDevIns, iLun, 2, apszDrivers, NULL, 0);
6738}
6739
6740/**
6741 * @copydoc PDMDEVHLPR3::pfnQueueCreatePtr
6742 */
6743DECLINLINE(int) PDMDevHlpQueueCreate(PPDMDEVINS pDevIns, size_t cbItem, uint32_t cItems, uint32_t cMilliesInterval,
6744 PFNPDMQUEUEDEV pfnCallback, bool fRZEnabled, const char *pszName, PPDMQUEUE *ppQueue)
6745{
6746 return pDevIns->pHlpR3->pfnQueueCreatePtr(pDevIns, cbItem, cItems, cMilliesInterval, pfnCallback, fRZEnabled, pszName, ppQueue);
6747}
6748
6749/**
6750 * @copydoc PDMDEVHLPR3::pfnQueueCreate
6751 */
6752DECLINLINE(int) PDMDevHlpQueueCreateNew(PPDMDEVINS pDevIns, size_t cbItem, uint32_t cItems, uint32_t cMilliesInterval,
6753 PFNPDMQUEUEDEV pfnCallback, bool fRZEnabled, const char *pszName, PDMQUEUEHANDLE *phQueue)
6754{
6755 return pDevIns->pHlpR3->pfnQueueCreate(pDevIns, cbItem, cItems, cMilliesInterval, pfnCallback, fRZEnabled, pszName, phQueue);
6756}
6757
6758#endif /* IN_RING3 */
6759
6760/**
6761 * @copydoc PDMDEVHLPR3::pfnQueueAlloc
6762 */
6763DECLINLINE(PPDMQUEUEITEMCORE) PDMDevHlpQueueAlloc(PPDMDEVINS pDevIns, PDMQUEUEHANDLE hQueue)
6764{
6765 return pDevIns->CTX_SUFF(pHlp)->pfnQueueAlloc(pDevIns, hQueue);
6766}
6767
6768/**
6769 * @copydoc PDMDEVHLPR3::pfnQueueInsert
6770 */
6771DECLINLINE(void) PDMDevHlpQueueInsert(PPDMDEVINS pDevIns, PDMQUEUEHANDLE hQueue, PPDMQUEUEITEMCORE pItem)
6772{
6773 pDevIns->CTX_SUFF(pHlp)->pfnQueueInsert(pDevIns, hQueue, pItem);
6774}
6775
6776/**
6777 * @copydoc PDMDEVHLPR3::pfnQueueInsertEx
6778 */
6779DECLINLINE(void) PDMDevHlpQueueInsertEx(PPDMDEVINS pDevIns, PDMQUEUEHANDLE hQueue, PPDMQUEUEITEMCORE pItem, uint64_t cNanoMaxDelay)
6780{
6781 pDevIns->CTX_SUFF(pHlp)->pfnQueueInsertEx(pDevIns, hQueue, pItem, cNanoMaxDelay);
6782}
6783
6784/**
6785 * @copydoc PDMDEVHLPR3::pfnQueueFlushIfNecessary
6786 */
6787DECLINLINE(bool) PDMDevHlpQueueFlushIfNecessary(PPDMDEVINS pDevIns, PDMQUEUEHANDLE hQueue)
6788{
6789 return pDevIns->CTX_SUFF(pHlp)->pfnQueueFlushIfNecessary(pDevIns, hQueue);
6790}
6791
6792#ifdef IN_RING3
6793/**
6794 * @copydoc PDMDEVHLPR3::pfnTaskCreate
6795 */
6796DECLINLINE(int) PDMDevHlpTaskCreate(PPDMDEVINS pDevIns, uint32_t fFlags, const char *pszName,
6797 PFNPDMTASKDEV pfnCallback, void *pvUser, PDMTASKHANDLE *phTask)
6798{
6799 return pDevIns->pHlpR3->pfnTaskCreate(pDevIns, fFlags, pszName, pfnCallback, pvUser, phTask);
6800}
6801#endif
6802
6803/**
6804 * @copydoc PDMDEVHLPR3::pfnTaskTrigger
6805 */
6806DECLINLINE(int) PDMDevHlpTaskTrigger(PPDMDEVINS pDevIns, PDMTASKHANDLE hTask)
6807{
6808 return pDevIns->CTX_SUFF(pHlp)->pfnTaskTrigger(pDevIns, hTask);
6809}
6810
6811#ifdef IN_RING3
6812
6813/**
6814 * @copydoc PDMDEVHLPR3::pfnSUPSemEventCreate
6815 */
6816DECLINLINE(int) PDMDevHlpSUPSemEventCreate(PPDMDEVINS pDevIns, PSUPSEMEVENT phEvent)
6817{
6818 return pDevIns->pHlpR3->pfnSUPSemEventCreate(pDevIns, phEvent);
6819}
6820
6821/**
6822 * @copydoc PDMDEVHLPR3::pfnSUPSemEventClose
6823 */
6824DECLINLINE(int) PDMDevHlpSUPSemEventClose(PPDMDEVINS pDevIns, SUPSEMEVENT hEvent)
6825{
6826 return pDevIns->pHlpR3->pfnSUPSemEventClose(pDevIns, hEvent);
6827}
6828
6829#endif /* IN_RING3 */
6830
6831/**
6832 * @copydoc PDMDEVHLPR3::pfnSUPSemEventSignal
6833 */
6834DECLINLINE(int) PDMDevHlpSUPSemEventSignal(PPDMDEVINS pDevIns, SUPSEMEVENT hEvent)
6835{
6836 return pDevIns->CTX_SUFF(pHlp)->pfnSUPSemEventSignal(pDevIns, hEvent);
6837}
6838
6839/**
6840 * @copydoc PDMDEVHLPR3::pfnSUPSemEventWaitNoResume
6841 */
6842DECLINLINE(int) PDMDevHlpSUPSemEventWaitNoResume(PPDMDEVINS pDevIns, SUPSEMEVENT hEvent, uint32_t cMillies)
6843{
6844 return pDevIns->CTX_SUFF(pHlp)->pfnSUPSemEventWaitNoResume(pDevIns, hEvent, cMillies);
6845}
6846
6847/**
6848 * @copydoc PDMDEVHLPR3::pfnSUPSemEventWaitNsAbsIntr
6849 */
6850DECLINLINE(int) PDMDevHlpSUPSemEventWaitNsAbsIntr(PPDMDEVINS pDevIns, SUPSEMEVENT hEvent, uint64_t uNsTimeout)
6851{
6852 return pDevIns->CTX_SUFF(pHlp)->pfnSUPSemEventWaitNsAbsIntr(pDevIns, hEvent, uNsTimeout);
6853}
6854
6855/**
6856 * @copydoc PDMDEVHLPR3::pfnSUPSemEventWaitNsRelIntr
6857 */
6858DECLINLINE(int) PDMDevHlpSUPSemEventWaitNsRelIntr(PPDMDEVINS pDevIns, SUPSEMEVENT hEvent, uint64_t cNsTimeout)
6859{
6860 return pDevIns->CTX_SUFF(pHlp)->pfnSUPSemEventWaitNsRelIntr(pDevIns, hEvent, cNsTimeout);
6861}
6862
6863/**
6864 * @copydoc PDMDEVHLPR3::pfnSUPSemEventGetResolution
6865 */
6866DECLINLINE(uint32_t) PDMDevHlpSUPSemEventGetResolution(PPDMDEVINS pDevIns)
6867{
6868 return pDevIns->CTX_SUFF(pHlp)->pfnSUPSemEventGetResolution(pDevIns);
6869}
6870
6871#ifdef IN_RING3
6872
6873/**
6874 * @copydoc PDMDEVHLPR3::pfnSUPSemEventMultiCreate
6875 */
6876DECLINLINE(int) PDMDevHlpSUPSemEventMultiCreate(PPDMDEVINS pDevIns, PSUPSEMEVENTMULTI phEventMulti)
6877{
6878 return pDevIns->pHlpR3->pfnSUPSemEventMultiCreate(pDevIns, phEventMulti);
6879}
6880
6881/**
6882 * @copydoc PDMDEVHLPR3::pfnSUPSemEventMultiClose
6883 */
6884DECLINLINE(int) PDMDevHlpSUPSemEventMultiClose(PPDMDEVINS pDevIns, SUPSEMEVENTMULTI hEventMulti)
6885{
6886 return pDevIns->pHlpR3->pfnSUPSemEventMultiClose(pDevIns, hEventMulti);
6887}
6888
6889#endif /* IN_RING3 */
6890
6891/**
6892 * @copydoc PDMDEVHLPR3::pfnSUPSemEventMultiSignal
6893 */
6894DECLINLINE(int) PDMDevHlpSUPSemEventMultiSignal(PPDMDEVINS pDevIns, SUPSEMEVENTMULTI hEventMulti)
6895{
6896 return pDevIns->CTX_SUFF(pHlp)->pfnSUPSemEventMultiSignal(pDevIns, hEventMulti);
6897}
6898
6899/**
6900 * @copydoc PDMDEVHLPR3::pfnSUPSemEventMultiReset
6901 */
6902DECLINLINE(int) PDMDevHlpSUPSemEventMultiReset(PPDMDEVINS pDevIns, SUPSEMEVENTMULTI hEventMulti)
6903{
6904 return pDevIns->CTX_SUFF(pHlp)->pfnSUPSemEventMultiReset(pDevIns, hEventMulti);
6905}
6906
6907/**
6908 * @copydoc PDMDEVHLPR3::pfnSUPSemEventMultiWaitNoResume
6909 */
6910DECLINLINE(int) PDMDevHlpSUPSemEventMultiWaitNoResume(PPDMDEVINS pDevIns, SUPSEMEVENTMULTI hEventMulti, uint32_t cMillies)
6911{
6912 return pDevIns->CTX_SUFF(pHlp)->pfnSUPSemEventMultiWaitNsRelIntr(pDevIns, hEventMulti, cMillies);
6913}
6914
6915/**
6916 * @copydoc PDMDEVHLPR3::pfnSUPSemEventMultiWaitNsAbsIntr
6917 */
6918DECLINLINE(int) PDMDevHlpSUPSemEventMultiWaitNsAbsIntr(PPDMDEVINS pDevIns, SUPSEMEVENTMULTI hEventMulti, uint64_t uNsTimeout)
6919{
6920 return pDevIns->CTX_SUFF(pHlp)->pfnSUPSemEventMultiWaitNsAbsIntr(pDevIns, hEventMulti, uNsTimeout);
6921}
6922
6923/**
6924 * @copydoc PDMDEVHLPR3::pfnSUPSemEventMultiWaitNsRelIntr
6925 */
6926DECLINLINE(int) PDMDevHlpSUPSemEventMultiWaitNsRelIntr(PPDMDEVINS pDevIns, SUPSEMEVENTMULTI hEventMulti, uint64_t cNsTimeout)
6927{
6928 return pDevIns->CTX_SUFF(pHlp)->pfnSUPSemEventMultiWaitNsRelIntr(pDevIns, hEventMulti, cNsTimeout);
6929}
6930
6931/**
6932 * @copydoc PDMDEVHLPR3::pfnSUPSemEventMultiGetResolution
6933 */
6934DECLINLINE(uint32_t) PDMDevHlpSUPSemEventMultiGetResolution(PPDMDEVINS pDevIns)
6935{
6936 return pDevIns->CTX_SUFF(pHlp)->pfnSUPSemEventMultiGetResolution(pDevIns);
6937}
6938
6939#ifdef IN_RING3
6940
6941/**
6942 * Initializes a PDM critical section.
6943 *
6944 * The PDM critical sections are derived from the IPRT critical sections, but
6945 * works in RC and R0 as well.
6946 *
6947 * @returns VBox status code.
6948 * @param pDevIns The device instance.
6949 * @param pCritSect Pointer to the critical section.
6950 * @param SRC_POS Use RT_SRC_POS.
6951 * @param pszNameFmt Format string for naming the critical section.
6952 * For statistics and lock validation.
6953 * @param ... Arguments for the format string.
6954 */
6955DECLINLINE(int) RT_IPRT_FORMAT_ATTR(6, 7) PDMDevHlpCritSectInit(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, RT_SRC_POS_DECL,
6956 const char *pszNameFmt, ...)
6957{
6958 int rc;
6959 va_list va;
6960 va_start(va, pszNameFmt);
6961 rc = pDevIns->pHlpR3->pfnCritSectInit(pDevIns, pCritSect, RT_SRC_POS_ARGS, pszNameFmt, va);
6962 va_end(va);
6963 return rc;
6964}
6965
6966#endif /* IN_RING3 */
6967
6968/**
6969 * @copydoc PDMDEVHLPR3::pfnCritSectGetNop
6970 */
6971DECLINLINE(PPDMCRITSECT) PDMDevHlpCritSectGetNop(PPDMDEVINS pDevIns)
6972{
6973 return pDevIns->CTX_SUFF(pHlp)->pfnCritSectGetNop(pDevIns);
6974}
6975
6976#ifdef IN_RING3
6977
6978/**
6979 * @copydoc PDMDEVHLPR3::pfnCritSectGetNopR0
6980 */
6981DECLINLINE(R0PTRTYPE(PPDMCRITSECT)) PDMDevHlpCritSectGetNopR0(PPDMDEVINS pDevIns)
6982{
6983 return pDevIns->pHlpR3->pfnCritSectGetNopR0(pDevIns);
6984}
6985
6986/**
6987 * @copydoc PDMDEVHLPR3::pfnCritSectGetNopRC
6988 */
6989DECLINLINE(RCPTRTYPE(PPDMCRITSECT)) PDMDevHlpCritSectGetNopRC(PPDMDEVINS pDevIns)
6990{
6991 return pDevIns->pHlpR3->pfnCritSectGetNopRC(pDevIns);
6992}
6993
6994#endif /* IN_RING3 */
6995
6996/**
6997 * @copydoc PDMDEVHLPR3::pfnSetDeviceCritSect
6998 */
6999DECLINLINE(int) PDMDevHlpSetDeviceCritSect(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect)
7000{
7001 return pDevIns->CTX_SUFF(pHlp)->pfnSetDeviceCritSect(pDevIns, pCritSect);
7002}
7003
7004/**
7005 * @copydoc PDMCritSectEnter
7006 * @param pDevIns The device instance.
7007 */
7008DECLINLINE(int) PDMDevHlpCritSectEnter(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, int rcBusy)
7009{
7010 return pDevIns->CTX_SUFF(pHlp)->pfnCritSectEnter(pDevIns, pCritSect, rcBusy);
7011}
7012
7013/**
7014 * @copydoc PDMCritSectEnterDebug
7015 * @param pDevIns The device instance.
7016 */
7017DECLINLINE(int) PDMDevHlpCritSectEnterDebug(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, int rcBusy, RTHCUINTPTR uId, RT_SRC_POS_DECL)
7018{
7019 return pDevIns->CTX_SUFF(pHlp)->pfnCritSectEnterDebug(pDevIns, pCritSect, rcBusy, uId, RT_SRC_POS_ARGS);
7020}
7021
7022/**
7023 * @copydoc PDMCritSectTryEnter
7024 * @param pDevIns The device instance.
7025 */
7026DECLINLINE(int) PDMDevHlpCritSectTryEnter(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect)
7027{
7028 return pDevIns->CTX_SUFF(pHlp)->pfnCritSectTryEnter(pDevIns, pCritSect);
7029}
7030
7031/**
7032 * @copydoc PDMCritSectTryEnterDebug
7033 * @param pDevIns The device instance.
7034 */
7035DECLINLINE(int) PDMDevHlpCritSectTryEnterDebug(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, RTHCUINTPTR uId, RT_SRC_POS_DECL)
7036{
7037 return pDevIns->CTX_SUFF(pHlp)->pfnCritSectTryEnterDebug(pDevIns, pCritSect, uId, RT_SRC_POS_ARGS);
7038}
7039
7040/**
7041 * @copydoc PDMCritSectLeave
7042 * @param pDevIns The device instance.
7043 */
7044DECLINLINE(int) PDMDevHlpCritSectLeave(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect)
7045{
7046 return pDevIns->CTX_SUFF(pHlp)->pfnCritSectLeave(pDevIns, pCritSect);
7047}
7048
7049/**
7050 * @copydoc PDMCritSectIsOwner
7051 * @param pDevIns The device instance.
7052 */
7053DECLINLINE(bool) PDMDevHlpCritSectIsOwner(PPDMDEVINS pDevIns, PCPDMCRITSECT pCritSect)
7054{
7055 return pDevIns->CTX_SUFF(pHlp)->pfnCritSectIsOwner(pDevIns, pCritSect);
7056}
7057
7058/**
7059 * @copydoc PDMCritSectIsInitialized
7060 * @param pDevIns The device instance.
7061 */
7062DECLINLINE(bool) PDMDevHlpCritSectIsInitialized(PPDMDEVINS pDevIns, PCPDMCRITSECT pCritSect)
7063{
7064 return pDevIns->CTX_SUFF(pHlp)->pfnCritSectIsInitialized(pDevIns, pCritSect);
7065}
7066
7067/**
7068 * @copydoc PDMCritSectHasWaiters
7069 * @param pDevIns The device instance.
7070 */
7071DECLINLINE(bool) PDMDevHlpCritSectHasWaiters(PPDMDEVINS pDevIns, PCPDMCRITSECT pCritSect)
7072{
7073 return pDevIns->CTX_SUFF(pHlp)->pfnCritSectHasWaiters(pDevIns, pCritSect);
7074}
7075
7076/**
7077 * @copydoc PDMCritSectGetRecursion
7078 * @param pDevIns The device instance.
7079 */
7080DECLINLINE(uint32_t) PDMDevHlpCritSectGetRecursion(PPDMDEVINS pDevIns, PCPDMCRITSECT pCritSect)
7081{
7082 return pDevIns->CTX_SUFF(pHlp)->pfnCritSectGetRecursion(pDevIns, pCritSect);
7083}
7084
7085#if defined(IN_RING3) || defined(IN_RING0)
7086/**
7087 * @copydoc PDMHCCritSectScheduleExitEvent
7088 * @param pDevIns The device instance.
7089 */
7090DECLINLINE(int) PDMDevHlpCritSectScheduleExitEvent(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, SUPSEMEVENT hEventToSignal)
7091{
7092 return pDevIns->CTX_SUFF(pHlp)->pfnCritSectScheduleExitEvent(pDevIns, pCritSect, hEventToSignal);
7093}
7094#endif
7095
7096/* Strict build: Remap the two enter calls to the debug versions. */
7097#ifdef VBOX_STRICT
7098# ifdef IPRT_INCLUDED_asm_h
7099# define PDMDevHlpCritSectEnter(pDevIns, pCritSect, rcBusy) PDMDevHlpCritSectEnterDebug((pDevIns), (pCritSect), (rcBusy), (uintptr_t)ASMReturnAddress(), RT_SRC_POS)
7100# define PDMDevHlpCritSectTryEnter(pDevIns, pCritSect) PDMDevHlpCritSectTryEnterDebug((pDevIns), (pCritSect), (uintptr_t)ASMReturnAddress(), RT_SRC_POS)
7101# else
7102# define PDMDevHlpCritSectEnter(pDevIns, pCritSect, rcBusy) PDMDevHlpCritSectEnterDebug((pDevIns), (pCritSect), (rcBusy), 0, RT_SRC_POS)
7103# define PDMDevHlpCritSectTryEnter(pDevIns, pCritSect) PDMDevHlpCritSectTryEnterDebug((pDevIns), (pCritSect), 0, RT_SRC_POS)
7104# endif
7105#endif
7106
7107#if defined(IN_RING3) || defined(DOXYGEN_RUNNING)
7108
7109/**
7110 * @copydoc PDMR3CritSectDelete
7111 * @param pDevIns The device instance.
7112 */
7113DECLINLINE(int) PDMDevHlpCritSectDelete(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect)
7114{
7115 return pDevIns->pHlpR3->pfnCritSectDelete(pDevIns, pCritSect);
7116}
7117
7118/**
7119 * @copydoc PDMDEVHLPR3::pfnThreadCreate
7120 */
7121DECLINLINE(int) PDMDevHlpThreadCreate(PPDMDEVINS pDevIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADDEV pfnThread,
7122 PFNPDMTHREADWAKEUPDEV pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName)
7123{
7124 return pDevIns->pHlpR3->pfnThreadCreate(pDevIns, ppThread, pvUser, pfnThread, pfnWakeup, cbStack, enmType, pszName);
7125}
7126
7127/**
7128 * @copydoc PDMR3ThreadDestroy
7129 * @param pDevIns The device instance.
7130 */
7131DECLINLINE(int) PDMDevHlpThreadDestroy(PPDMDEVINS pDevIns, PPDMTHREAD pThread, int *pRcThread)
7132{
7133 return pDevIns->pHlpR3->pfnThreadDestroy(pThread, pRcThread);
7134}
7135
7136/**
7137 * @copydoc PDMR3ThreadIAmSuspending
7138 * @param pDevIns The device instance.
7139 */
7140DECLINLINE(int) PDMDevHlpThreadIAmSuspending(PPDMDEVINS pDevIns, PPDMTHREAD pThread)
7141{
7142 return pDevIns->pHlpR3->pfnThreadIAmSuspending(pThread);
7143}
7144
7145/**
7146 * @copydoc PDMR3ThreadIAmRunning
7147 * @param pDevIns The device instance.
7148 */
7149DECLINLINE(int) PDMDevHlpThreadIAmRunning(PPDMDEVINS pDevIns, PPDMTHREAD pThread)
7150{
7151 return pDevIns->pHlpR3->pfnThreadIAmRunning(pThread);
7152}
7153
7154/**
7155 * @copydoc PDMR3ThreadSleep
7156 * @param pDevIns The device instance.
7157 */
7158DECLINLINE(int) PDMDevHlpThreadSleep(PPDMDEVINS pDevIns, PPDMTHREAD pThread, RTMSINTERVAL cMillies)
7159{
7160 return pDevIns->pHlpR3->pfnThreadSleep(pThread, cMillies);
7161}
7162
7163/**
7164 * @copydoc PDMR3ThreadSuspend
7165 * @param pDevIns The device instance.
7166 */
7167DECLINLINE(int) PDMDevHlpThreadSuspend(PPDMDEVINS pDevIns, PPDMTHREAD pThread)
7168{
7169 return pDevIns->pHlpR3->pfnThreadSuspend(pThread);
7170}
7171
7172/**
7173 * @copydoc PDMR3ThreadResume
7174 * @param pDevIns The device instance.
7175 */
7176DECLINLINE(int) PDMDevHlpThreadResume(PPDMDEVINS pDevIns, PPDMTHREAD pThread)
7177{
7178 return pDevIns->pHlpR3->pfnThreadResume(pThread);
7179}
7180
7181/**
7182 * @copydoc PDMDEVHLPR3::pfnSetAsyncNotification
7183 */
7184DECLINLINE(int) PDMDevHlpSetAsyncNotification(PPDMDEVINS pDevIns, PFNPDMDEVASYNCNOTIFY pfnAsyncNotify)
7185{
7186 return pDevIns->pHlpR3->pfnSetAsyncNotification(pDevIns, pfnAsyncNotify);
7187}
7188
7189/**
7190 * @copydoc PDMDEVHLPR3::pfnAsyncNotificationCompleted
7191 */
7192DECLINLINE(void) PDMDevHlpAsyncNotificationCompleted(PPDMDEVINS pDevIns)
7193{
7194 pDevIns->pHlpR3->pfnAsyncNotificationCompleted(pDevIns);
7195}
7196
7197/**
7198 * @copydoc PDMDEVHLPR3::pfnA20Set
7199 */
7200DECLINLINE(void) PDMDevHlpA20Set(PPDMDEVINS pDevIns, bool fEnable)
7201{
7202 pDevIns->pHlpR3->pfnA20Set(pDevIns, fEnable);
7203}
7204
7205/**
7206 * @copydoc PDMDEVHLPR3::pfnRTCRegister
7207 */
7208DECLINLINE(int) PDMDevHlpRTCRegister(PPDMDEVINS pDevIns, PCPDMRTCREG pRtcReg, PCPDMRTCHLP *ppRtcHlp)
7209{
7210 return pDevIns->pHlpR3->pfnRTCRegister(pDevIns, pRtcReg, ppRtcHlp);
7211}
7212
7213/**
7214 * @copydoc PDMDEVHLPR3::pfnPCIBusRegister
7215 */
7216DECLINLINE(int) PDMDevHlpPCIBusRegister(PPDMDEVINS pDevIns, PPDMPCIBUSREGR3 pPciBusReg, PCPDMPCIHLPR3 *ppPciHlp, uint32_t *piBus)
7217{
7218 return pDevIns->pHlpR3->pfnPCIBusRegister(pDevIns, pPciBusReg, ppPciHlp, piBus);
7219}
7220
7221/**
7222 * @copydoc PDMDEVHLPR3::pfnPICRegister
7223 */
7224DECLINLINE(int) PDMDevHlpPICRegister(PPDMDEVINS pDevIns, PPDMPICREG pPicReg, PCPDMPICHLP *ppPicHlp)
7225{
7226 return pDevIns->pHlpR3->pfnPICRegister(pDevIns, pPicReg, ppPicHlp);
7227}
7228
7229/**
7230 * @copydoc PDMDEVHLPR3::pfnApicRegister
7231 */
7232DECLINLINE(int) PDMDevHlpApicRegister(PPDMDEVINS pDevIns)
7233{
7234 return pDevIns->pHlpR3->pfnApicRegister(pDevIns);
7235}
7236
7237/**
7238 * @copydoc PDMDEVHLPR3::pfnIoApicRegister
7239 */
7240DECLINLINE(int) PDMDevHlpIoApicRegister(PPDMDEVINS pDevIns, PPDMIOAPICREG pIoApicReg, PCPDMIOAPICHLP *ppIoApicHlp)
7241{
7242 return pDevIns->pHlpR3->pfnIoApicRegister(pDevIns, pIoApicReg, ppIoApicHlp);
7243}
7244
7245/**
7246 * @copydoc PDMDEVHLPR3::pfnHpetRegister
7247 */
7248DECLINLINE(int) PDMDevHlpHpetRegister(PPDMDEVINS pDevIns, PPDMHPETREG pHpetReg, PCPDMHPETHLPR3 *ppHpetHlpR3)
7249{
7250 return pDevIns->pHlpR3->pfnHpetRegister(pDevIns, pHpetReg, ppHpetHlpR3);
7251}
7252
7253/**
7254 * @copydoc PDMDEVHLPR3::pfnPciRawRegister
7255 */
7256DECLINLINE(int) PDMDevHlpPciRawRegister(PPDMDEVINS pDevIns, PPDMPCIRAWREG pPciRawReg, PCPDMPCIRAWHLPR3 *ppPciRawHlpR3)
7257{
7258 return pDevIns->pHlpR3->pfnPciRawRegister(pDevIns, pPciRawReg, ppPciRawHlpR3);
7259}
7260
7261/**
7262 * @copydoc PDMDEVHLPR3::pfnDMACRegister
7263 */
7264DECLINLINE(int) PDMDevHlpDMACRegister(PPDMDEVINS pDevIns, PPDMDMACREG pDmacReg, PCPDMDMACHLP *ppDmacHlp)
7265{
7266 return pDevIns->pHlpR3->pfnDMACRegister(pDevIns, pDmacReg, ppDmacHlp);
7267}
7268
7269/**
7270 * @copydoc PDMDEVHLPR3::pfnDMARegister
7271 */
7272DECLINLINE(int) PDMDevHlpDMARegister(PPDMDEVINS pDevIns, unsigned uChannel, PFNDMATRANSFERHANDLER pfnTransferHandler, void *pvUser)
7273{
7274 return pDevIns->pHlpR3->pfnDMARegister(pDevIns, uChannel, pfnTransferHandler, pvUser);
7275}
7276
7277/**
7278 * @copydoc PDMDEVHLPR3::pfnDMAReadMemory
7279 */
7280DECLINLINE(int) PDMDevHlpDMAReadMemory(PPDMDEVINS pDevIns, unsigned uChannel, void *pvBuffer, uint32_t off, uint32_t cbBlock, uint32_t *pcbRead)
7281{
7282 return pDevIns->pHlpR3->pfnDMAReadMemory(pDevIns, uChannel, pvBuffer, off, cbBlock, pcbRead);
7283}
7284
7285/**
7286 * @copydoc PDMDEVHLPR3::pfnDMAWriteMemory
7287 */
7288DECLINLINE(int) PDMDevHlpDMAWriteMemory(PPDMDEVINS pDevIns, unsigned uChannel, const void *pvBuffer, uint32_t off, uint32_t cbBlock, uint32_t *pcbWritten)
7289{
7290 return pDevIns->pHlpR3->pfnDMAWriteMemory(pDevIns, uChannel, pvBuffer, off, cbBlock, pcbWritten);
7291}
7292
7293/**
7294 * @copydoc PDMDEVHLPR3::pfnDMASetDREQ
7295 */
7296DECLINLINE(int) PDMDevHlpDMASetDREQ(PPDMDEVINS pDevIns, unsigned uChannel, unsigned uLevel)
7297{
7298 return pDevIns->pHlpR3->pfnDMASetDREQ(pDevIns, uChannel, uLevel);
7299}
7300
7301/**
7302 * @copydoc PDMDEVHLPR3::pfnDMAGetChannelMode
7303 */
7304DECLINLINE(uint8_t) PDMDevHlpDMAGetChannelMode(PPDMDEVINS pDevIns, unsigned uChannel)
7305{
7306 return pDevIns->pHlpR3->pfnDMAGetChannelMode(pDevIns, uChannel);
7307}
7308
7309/**
7310 * @copydoc PDMDEVHLPR3::pfnDMASchedule
7311 */
7312DECLINLINE(void) PDMDevHlpDMASchedule(PPDMDEVINS pDevIns)
7313{
7314 pDevIns->pHlpR3->pfnDMASchedule(pDevIns);
7315}
7316
7317/**
7318 * @copydoc PDMDEVHLPR3::pfnCMOSWrite
7319 */
7320DECLINLINE(int) PDMDevHlpCMOSWrite(PPDMDEVINS pDevIns, unsigned iReg, uint8_t u8Value)
7321{
7322 return pDevIns->pHlpR3->pfnCMOSWrite(pDevIns, iReg, u8Value);
7323}
7324
7325/**
7326 * @copydoc PDMDEVHLPR3::pfnCMOSRead
7327 */
7328DECLINLINE(int) PDMDevHlpCMOSRead(PPDMDEVINS pDevIns, unsigned iReg, uint8_t *pu8Value)
7329{
7330 return pDevIns->pHlpR3->pfnCMOSRead(pDevIns, iReg, pu8Value);
7331}
7332
7333/**
7334 * @copydoc PDMDEVHLPR3::pfnCallR0
7335 */
7336DECLINLINE(int) PDMDevHlpCallR0(PPDMDEVINS pDevIns, uint32_t uOperation, uint64_t u64Arg)
7337{
7338 return pDevIns->pHlpR3->pfnCallR0(pDevIns, uOperation, u64Arg);
7339}
7340
7341/**
7342 * @copydoc PDMDEVHLPR3::pfnVMGetSuspendReason
7343 */
7344DECLINLINE(VMSUSPENDREASON) PDMDevHlpVMGetSuspendReason(PPDMDEVINS pDevIns)
7345{
7346 return pDevIns->pHlpR3->pfnVMGetSuspendReason(pDevIns);
7347}
7348
7349/**
7350 * @copydoc PDMDEVHLPR3::pfnVMGetResumeReason
7351 */
7352DECLINLINE(VMRESUMEREASON) PDMDevHlpVMGetResumeReason(PPDMDEVINS pDevIns)
7353{
7354 return pDevIns->pHlpR3->pfnVMGetResumeReason(pDevIns);
7355}
7356
7357/**
7358 * @copydoc PDMDEVHLPR3::pfnGetUVM
7359 */
7360DECLINLINE(PUVM) PDMDevHlpGetUVM(PPDMDEVINS pDevIns)
7361{
7362 return pDevIns->CTX_SUFF(pHlp)->pfnGetUVM(pDevIns);
7363}
7364
7365#endif /* IN_RING3 || DOXYGEN_RUNNING */
7366
7367#if !defined(IN_RING3) || defined(DOXYGEN_RUNNING)
7368
7369/**
7370 * @copydoc PDMDEVHLPR0::pfnPCIBusSetUpContext
7371 */
7372DECLINLINE(int) PDMDevHlpPCIBusSetUpContext(PPDMDEVINS pDevIns, CTX_SUFF(PPDMPCIBUSREG) pPciBusReg, CTX_SUFF(PCPDMPCIHLP) *ppPciHlp)
7373{
7374 return pDevIns->CTX_SUFF(pHlp)->pfnPCIBusSetUpContext(pDevIns, pPciBusReg, ppPciHlp);
7375}
7376
7377/**
7378 * @copydoc PDMDEVHLPR0::pfnPICSetUpContext
7379 */
7380DECLINLINE(int) PDMDevHlpPICSetUpContext(PPDMDEVINS pDevIns, PPDMPICREG pPicReg, PCPDMPICHLP *ppPicHlp)
7381{
7382 return pDevIns->CTX_SUFF(pHlp)->pfnPICSetUpContext(pDevIns, pPicReg, ppPicHlp);
7383}
7384
7385/**
7386 * @copydoc PDMDEVHLPR0::pfnApicSetUpContext
7387 */
7388DECLINLINE(int) PDMDevHlpApicSetUpContext(PPDMDEVINS pDevIns)
7389{
7390 return pDevIns->CTX_SUFF(pHlp)->pfnApicSetUpContext(pDevIns);
7391}
7392
7393/**
7394 * @copydoc PDMDEVHLPR0::pfnIoApicSetUpContext
7395 */
7396DECLINLINE(int) PDMDevHlpIoApicSetUpContext(PPDMDEVINS pDevIns, PPDMIOAPICREG pIoApicReg, PCPDMIOAPICHLP *ppIoApicHlp)
7397{
7398 return pDevIns->CTX_SUFF(pHlp)->pfnIoApicSetUpContext(pDevIns, pIoApicReg, ppIoApicHlp);
7399}
7400
7401/**
7402 * @copydoc PDMDEVHLPR0::pfnHpetSetUpContext
7403 */
7404DECLINLINE(int) PDMDevHlpHpetSetUpContext(PPDMDEVINS pDevIns, PPDMHPETREG pHpetReg, CTX_SUFF(PCPDMHPETHLP) *ppHpetHlp)
7405{
7406 return pDevIns->CTX_SUFF(pHlp)->pfnHpetSetUpContext(pDevIns, pHpetReg, ppHpetHlp);
7407}
7408
7409#endif /* !IN_RING3 || DOXYGEN_RUNNING */
7410
7411/**
7412 * @copydoc PDMDEVHLPR3::pfnGetVM
7413 */
7414DECLINLINE(PVMCC) PDMDevHlpGetVM(PPDMDEVINS pDevIns)
7415{
7416 return pDevIns->CTX_SUFF(pHlp)->pfnGetVM(pDevIns);
7417}
7418
7419/**
7420 * @copydoc PDMDEVHLPR3::pfnGetVMCPU
7421 */
7422DECLINLINE(PVMCPUCC) PDMDevHlpGetVMCPU(PPDMDEVINS pDevIns)
7423{
7424 return pDevIns->CTX_SUFF(pHlp)->pfnGetVMCPU(pDevIns);
7425}
7426
7427/**
7428 * @copydoc PDMDEVHLPR3::pfnGetCurrentCpuId
7429 */
7430DECLINLINE(VMCPUID) PDMDevHlpGetCurrentCpuId(PPDMDEVINS pDevIns)
7431{
7432 return pDevIns->CTX_SUFF(pHlp)->pfnGetCurrentCpuId(pDevIns);
7433}
7434
7435/**
7436 * @copydoc PDMDEVHLPR3::pfnTMTimeVirtGet
7437 */
7438DECLINLINE(uint64_t) PDMDevHlpTMTimeVirtGet(PPDMDEVINS pDevIns)
7439{
7440 return pDevIns->CTX_SUFF(pHlp)->pfnTMTimeVirtGet(pDevIns);
7441}
7442
7443/**
7444 * @copydoc PDMDEVHLPR3::pfnTMTimeVirtGetFreq
7445 */
7446DECLINLINE(uint64_t) PDMDevHlpTMTimeVirtGetFreq(PPDMDEVINS pDevIns)
7447{
7448 return pDevIns->CTX_SUFF(pHlp)->pfnTMTimeVirtGetFreq(pDevIns);
7449}
7450
7451/**
7452 * @copydoc PDMDEVHLPR3::pfnTMTimeVirtGetFreq
7453 */
7454DECLINLINE(uint64_t) PDMDevHlpTMTimeVirtGetNano(PPDMDEVINS pDevIns)
7455{
7456 return pDevIns->CTX_SUFF(pHlp)->pfnTMTimeVirtGetNano(pDevIns);
7457}
7458
7459#ifdef IN_RING3
7460
7461/**
7462 * @copydoc PDMDEVHLPR3::pfnRegisterVMMDevHeap
7463 */
7464DECLINLINE(int) PDMDevHlpRegisterVMMDevHeap(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTR3PTR pvHeap, unsigned cbHeap)
7465{
7466 return pDevIns->pHlpR3->pfnRegisterVMMDevHeap(pDevIns, GCPhys, pvHeap, cbHeap);
7467}
7468
7469/**
7470 * @copydoc PDMDEVHLPR3::pfnFirmwareRegister
7471 */
7472DECLINLINE(int) PDMDevHlpFirmwareRegister(PPDMDEVINS pDevIns, PCPDMFWREG pFwReg, PCPDMFWHLPR3 *ppFwHlp)
7473{
7474 return pDevIns->pHlpR3->pfnFirmwareRegister(pDevIns, pFwReg, ppFwHlp);
7475}
7476
7477/**
7478 * @copydoc PDMDEVHLPR3::pfnVMReset
7479 */
7480DECLINLINE(int) PDMDevHlpVMReset(PPDMDEVINS pDevIns, uint32_t fFlags)
7481{
7482 return pDevIns->pHlpR3->pfnVMReset(pDevIns, fFlags);
7483}
7484
7485/**
7486 * @copydoc PDMDEVHLPR3::pfnVMSuspend
7487 */
7488DECLINLINE(int) PDMDevHlpVMSuspend(PPDMDEVINS pDevIns)
7489{
7490 return pDevIns->pHlpR3->pfnVMSuspend(pDevIns);
7491}
7492
7493/**
7494 * @copydoc PDMDEVHLPR3::pfnVMSuspendSaveAndPowerOff
7495 */
7496DECLINLINE(int) PDMDevHlpVMSuspendSaveAndPowerOff(PPDMDEVINS pDevIns)
7497{
7498 return pDevIns->pHlpR3->pfnVMSuspendSaveAndPowerOff(pDevIns);
7499}
7500
7501/**
7502 * @copydoc PDMDEVHLPR3::pfnVMPowerOff
7503 */
7504DECLINLINE(int) PDMDevHlpVMPowerOff(PPDMDEVINS pDevIns)
7505{
7506 return pDevIns->pHlpR3->pfnVMPowerOff(pDevIns);
7507}
7508
7509#endif /* IN_RING3 */
7510
7511/**
7512 * @copydoc PDMDEVHLPR3::pfnA20IsEnabled
7513 */
7514DECLINLINE(bool) PDMDevHlpA20IsEnabled(PPDMDEVINS pDevIns)
7515{
7516 return pDevIns->CTX_SUFF(pHlp)->pfnA20IsEnabled(pDevIns);
7517}
7518
7519#ifdef IN_RING3
7520
7521/**
7522 * @copydoc PDMDEVHLPR3::pfnGetCpuId
7523 */
7524DECLINLINE(void) PDMDevHlpGetCpuId(PPDMDEVINS pDevIns, uint32_t iLeaf, uint32_t *pEax, uint32_t *pEbx, uint32_t *pEcx, uint32_t *pEdx)
7525{
7526 pDevIns->pHlpR3->pfnGetCpuId(pDevIns, iLeaf, pEax, pEbx, pEcx, pEdx);
7527}
7528
7529/**
7530 * @copydoc PDMDEVHLPR3::pfnGetSupDrvSession
7531 */
7532DECLINLINE(PSUPDRVSESSION) PDMDevHlpGetSupDrvSession(PPDMDEVINS pDevIns)
7533{
7534 return pDevIns->pHlpR3->pfnGetSupDrvSession(pDevIns);
7535}
7536
7537/**
7538 * @copydoc PDMDEVHLPR3::pfnQueryGenericUserObject
7539 */
7540DECLINLINE(void *) PDMDevHlpQueryGenericUserObject(PPDMDEVINS pDevIns, PCRTUUID pUuid)
7541{
7542 return pDevIns->pHlpR3->pfnQueryGenericUserObject(pDevIns, pUuid);
7543}
7544
7545/** Wrapper around SSMR3GetU32 for simplifying getting enum values saved as uint32_t. */
7546# define PDMDEVHLP_SSM_GET_ENUM32_RET(a_pHlp, a_pSSM, a_enmDst, a_EnumType) \
7547 do { \
7548 uint32_t u32GetEnumTmp = 0; \
7549 int rcGetEnum32Tmp = (a_pHlp)->pfnSSMGetU32((a_pSSM), &u32GetEnumTmp); \
7550 AssertRCReturn(rcGetEnum32Tmp, rcGetEnum32Tmp); \
7551 (a_enmDst) = (a_EnumType)u32GetEnumTmp; \
7552 AssertCompile(sizeof(a_EnumType) == sizeof(u32GetEnumTmp)); \
7553 } while (0)
7554
7555/** Wrapper around SSMR3GetU8 for simplifying getting enum values saved as uint8_t. */
7556# define PDMDEVHLP_SSM_GET_ENUM8_RET(a_pHlp, a_pSSM, a_enmDst, a_EnumType) \
7557 do { \
7558 uint8_t bGetEnumTmp = 0; \
7559 int rcGetEnum32Tmp = (a_pHlp)->pfnSSMGetU8((a_pSSM), &bGetEnumTmp); \
7560 AssertRCReturn(rcGetEnum32Tmp, rcGetEnum32Tmp); \
7561 (a_enmDst) = (a_EnumType)bGetEnumTmp; \
7562 } while (0)
7563
7564#endif /* IN_RING3 */
7565
7566/** Pointer to callbacks provided to the VBoxDeviceRegister() call. */
7567typedef struct PDMDEVREGCB *PPDMDEVREGCB;
7568
7569/**
7570 * Callbacks for VBoxDeviceRegister().
7571 */
7572typedef struct PDMDEVREGCB
7573{
7574 /** Interface version.
7575 * This is set to PDM_DEVREG_CB_VERSION. */
7576 uint32_t u32Version;
7577
7578 /**
7579 * Registers a device with the current VM instance.
7580 *
7581 * @returns VBox status code.
7582 * @param pCallbacks Pointer to the callback table.
7583 * @param pReg Pointer to the device registration record.
7584 * This data must be permanent and readonly.
7585 */
7586 DECLR3CALLBACKMEMBER(int, pfnRegister,(PPDMDEVREGCB pCallbacks, PCPDMDEVREG pReg));
7587} PDMDEVREGCB;
7588
7589/** Current version of the PDMDEVREGCB structure. */
7590#define PDM_DEVREG_CB_VERSION PDM_VERSION_MAKE(0xffe3, 1, 0)
7591
7592
7593/**
7594 * The VBoxDevicesRegister callback function.
7595 *
7596 * PDM will invoke this function after loading a device module and letting
7597 * the module decide which devices to register and how to handle conflicts.
7598 *
7599 * @returns VBox status code.
7600 * @param pCallbacks Pointer to the callback table.
7601 * @param u32Version VBox version number.
7602 */
7603typedef DECLCALLBACK(int) FNPDMVBOXDEVICESREGISTER(PPDMDEVREGCB pCallbacks, uint32_t u32Version);
7604
7605/** @} */
7606
7607RT_C_DECLS_END
7608
7609#endif /* !VBOX_INCLUDED_vmm_pdmdev_h */
Note: See TracBrowser for help on using the repository browser.

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