VirtualBox

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

Last change on this file since 65787 was 65299, checked in by vboxsync, 8 years ago

PGM,PDM: Added API for reducing the size a MMIO2 or pre-registered MMIO region when loading saved state.

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

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