VirtualBox

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

Last change on this file since 92449 was 92162, checked in by vboxsync, 3 years ago

VMM/PGM,DevVGA: Baked MMIO2 dirty page tracking into PGM, moving it out of DevVGA. Using the handler state to record a page as dirty (PGM_PAGE_HNDL_PHYS_STATE_DISABLED). bugref:10122

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