VirtualBox

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

Last change on this file since 64879 was 64844, checked in by vboxsync, 8 years ago

PDMPCIDEVREG_DEV_NO_SAME_AS_PREV: Include default bus number.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 209.9 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 iType 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 pfnWriteOld 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. */
1879#define PDM_DEVHLPR3_VERSION PDM_VERSION_MAKE_PP(0xffe7, 19, 1)
1880//#define PDM_DEVHLPR3_VERSION PDM_VERSION_MAKE_PP(0xffe7, 20, 0)
1881
1882/**
1883 * PDM Device API.
1884 */
1885typedef struct PDMDEVHLPR3
1886{
1887 /** Structure version. PDM_DEVHLPR3_VERSION defines the current version. */
1888 uint32_t u32Version;
1889
1890 /**
1891 * Register a number of I/O ports with a device.
1892 *
1893 * These callbacks are of course for the host context (HC).
1894 * Register HC handlers before guest context (GC) handlers! There must be a
1895 * HC handler for every GC handler!
1896 *
1897 * @returns VBox status.
1898 * @param pDevIns The device instance to register the ports with.
1899 * @param Port First port number in the range.
1900 * @param cPorts Number of ports to register.
1901 * @param pvUser User argument.
1902 * @param pfnOut Pointer to function which is gonna handle OUT operations.
1903 * @param pfnIn Pointer to function which is gonna handle IN operations.
1904 * @param pfnOutStr Pointer to function which is gonna handle string OUT operations.
1905 * @param pfnInStr Pointer to function which is gonna handle string IN operations.
1906 * @param pszDesc Pointer to description string. This must not be freed.
1907 * @remarks Caller enters the device critical section prior to invoking the
1908 * registered callback methods.
1909 */
1910 DECLR3CALLBACKMEMBER(int, pfnIOPortRegister,(PPDMDEVINS pDevIns, RTIOPORT Port, RTIOPORT cPorts, RTHCPTR pvUser,
1911 PFNIOMIOPORTOUT pfnOut, PFNIOMIOPORTIN pfnIn,
1912 PFNIOMIOPORTOUTSTRING pfnOutStr, PFNIOMIOPORTINSTRING pfnInStr, const char *pszDesc));
1913
1914 /**
1915 * Register a number of I/O ports with a device for RC.
1916 *
1917 * These callbacks are for the raw-mode context (RC). Register ring-3 context
1918 * (R3) handlers before raw-mode context handlers! There must be a R3 handler
1919 * for every RC handler!
1920 *
1921 * @returns VBox status.
1922 * @param pDevIns The device instance to register the ports with
1923 * and which RC module to resolve the names
1924 * against.
1925 * @param Port First port number in the range.
1926 * @param cPorts Number of ports to register.
1927 * @param pvUser User argument.
1928 * @param pszOut Name of the RC function which is gonna handle OUT operations.
1929 * @param pszIn Name of the RC function which is gonna handle IN operations.
1930 * @param pszOutStr Name of the RC function which is gonna handle string OUT operations.
1931 * @param pszInStr Name of the RC function which is gonna handle string IN operations.
1932 * @param pszDesc Pointer to description string. This must not be freed.
1933 * @remarks Caller enters the device critical section prior to invoking the
1934 * registered callback methods.
1935 */
1936 DECLR3CALLBACKMEMBER(int, pfnIOPortRegisterRC,(PPDMDEVINS pDevIns, RTIOPORT Port, RTIOPORT cPorts, RTRCPTR pvUser,
1937 const char *pszOut, const char *pszIn,
1938 const char *pszOutStr, const char *pszInStr, const char *pszDesc));
1939
1940 /**
1941 * Register a number of I/O ports with a device.
1942 *
1943 * These callbacks are of course for the ring-0 host context (R0).
1944 * Register R3 (HC) handlers before R0 (R0) handlers! There must be a R3 (HC) handler for every R0 handler!
1945 *
1946 * @returns VBox status.
1947 * @param pDevIns The device instance to register the ports with.
1948 * @param Port First port number in the range.
1949 * @param cPorts Number of ports to register.
1950 * @param pvUser User argument. (if pointer, then it must be in locked memory!)
1951 * @param pszOut Name of the R0 function which is gonna handle OUT operations.
1952 * @param pszIn Name of the R0 function which is gonna handle IN operations.
1953 * @param pszOutStr Name of the R0 function which is gonna handle string OUT operations.
1954 * @param pszInStr Name of the R0 function which is gonna handle string IN operations.
1955 * @param pszDesc Pointer to description string. This must not be freed.
1956 * @remarks Caller enters the device critical section prior to invoking the
1957 * registered callback methods.
1958 */
1959 DECLR3CALLBACKMEMBER(int, pfnIOPortRegisterR0,(PPDMDEVINS pDevIns, RTIOPORT Port, RTIOPORT cPorts, RTR0PTR pvUser,
1960 const char *pszOut, const char *pszIn,
1961 const char *pszOutStr, const char *pszInStr, const char *pszDesc));
1962
1963 /**
1964 * Deregister I/O ports.
1965 *
1966 * This naturally affects both guest context (GC), ring-0 (R0) and ring-3 (R3/HC) handlers.
1967 *
1968 * @returns VBox status.
1969 * @param pDevIns The device instance owning the ports.
1970 * @param Port First port number in the range.
1971 * @param cPorts Number of ports to deregister.
1972 */
1973 DECLR3CALLBACKMEMBER(int, pfnIOPortDeregister,(PPDMDEVINS pDevIns, RTIOPORT Port, RTIOPORT cPorts));
1974
1975 /**
1976 * Register a Memory Mapped I/O (MMIO) region.
1977 *
1978 * These callbacks are of course for the ring-3 context (R3). Register HC
1979 * handlers before raw-mode context (RC) and ring-0 context (R0) handlers! There
1980 * must be a R3 handler for every RC and R0 handler!
1981 *
1982 * @returns VBox status.
1983 * @param pDevIns The device instance to register the MMIO with.
1984 * @param GCPhysStart First physical address in the range.
1985 * @param cbRange The size of the range (in bytes).
1986 * @param pvUser User argument.
1987 * @param pfnWrite Pointer to function which is gonna handle Write operations.
1988 * @param pfnRead Pointer to function which is gonna handle Read operations.
1989 * @param pfnFill Pointer to function which is gonna handle Fill/memset operations. (optional)
1990 * @param fFlags Flags, IOMMMIO_FLAGS_XXX.
1991 * @param pszDesc Pointer to description string. This must not be freed.
1992 * @remarks Caller enters the device critical section prior to invoking the
1993 * registered callback methods.
1994 */
1995 DECLR3CALLBACKMEMBER(int, pfnMMIORegister,(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTGCPHYS cbRange, RTHCPTR pvUser,
1996 PFNIOMMMIOWRITE pfnWrite, PFNIOMMMIOREAD pfnRead, PFNIOMMMIOFILL pfnFill,
1997 uint32_t fFlags, const char *pszDesc));
1998
1999 /**
2000 * Register a Memory Mapped I/O (MMIO) region for RC.
2001 *
2002 * These callbacks are for the raw-mode context (RC). Register ring-3 context
2003 * (R3) handlers before guest context handlers! There must be a R3 handler for
2004 * every RC handler!
2005 *
2006 * @returns VBox status.
2007 * @param pDevIns The device instance to register the MMIO with.
2008 * @param GCPhysStart First physical address in the range.
2009 * @param cbRange The size of the range (in bytes).
2010 * @param pvUser User argument.
2011 * @param pszWrite Name of the RC function which is gonna handle Write operations.
2012 * @param pszRead Name of the RC function which is gonna handle Read operations.
2013 * @param pszFill Name of the RC function which is gonna handle Fill/memset operations. (optional)
2014 * @remarks Caller enters the device critical section prior to invoking the
2015 * registered callback methods.
2016 */
2017 DECLR3CALLBACKMEMBER(int, pfnMMIORegisterRC,(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTGCPHYS cbRange, RTRCPTR pvUser,
2018 const char *pszWrite, const char *pszRead, const char *pszFill));
2019
2020 /**
2021 * Register a Memory Mapped I/O (MMIO) region for R0.
2022 *
2023 * These callbacks are for the ring-0 host context (R0). Register ring-3
2024 * constext (R3) handlers before R0 handlers! There must be a R3 handler for
2025 * every R0 handler!
2026 *
2027 * @returns VBox status.
2028 * @param pDevIns The device instance to register the MMIO with.
2029 * @param GCPhysStart First physical address in the range.
2030 * @param cbRange The size of the range (in bytes).
2031 * @param pvUser User argument. (if pointer, then it must be in locked memory!)
2032 * @param pszWrite Name of the RC function which is gonna handle Write operations.
2033 * @param pszRead Name of the RC function which is gonna handle Read operations.
2034 * @param pszFill Name of the RC function which is gonna handle Fill/memset operations. (optional)
2035 * @remarks Caller enters the device critical section prior to invoking the
2036 * registered callback methods.
2037 */
2038 DECLR3CALLBACKMEMBER(int, pfnMMIORegisterR0,(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTGCPHYS cbRange, RTR0PTR pvUser,
2039 const char *pszWrite, const char *pszRead, const char *pszFill));
2040
2041 /**
2042 * Deregister a Memory Mapped I/O (MMIO) region.
2043 *
2044 * This naturally affects both guest context (GC), ring-0 (R0) and ring-3 (R3/HC) handlers.
2045 *
2046 * @returns VBox status.
2047 * @param pDevIns The device instance owning the MMIO region(s).
2048 * @param GCPhysStart First physical address in the range.
2049 * @param cbRange The size of the range (in bytes).
2050 */
2051 DECLR3CALLBACKMEMBER(int, pfnMMIODeregister,(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTGCPHYS cbRange));
2052
2053 /**
2054 * Allocate and register a MMIO2 region.
2055 *
2056 * As mentioned elsewhere, MMIO2 is just RAM spelled differently. It's
2057 * RAM associated with a device. It is also non-shared memory with a
2058 * permanent ring-3 mapping and page backing (presently).
2059 *
2060 * @returns VBox status.
2061 * @param pDevIns The device instance.
2062 * @param pPciDev The PCI device the region is associated with, or
2063 * NULL if no PCI device association.
2064 * @param iRegion The region number. Use the PCI region number as
2065 * this must be known to the PCI bus device too. If
2066 * it's not associated with the PCI device, then
2067 * any number up to UINT8_MAX is fine.
2068 * @param cb The size (in bytes) of the region.
2069 * @param fFlags Reserved for future use, must be zero.
2070 * @param ppv Where to store the address of the ring-3 mapping
2071 * of the memory.
2072 * @param pszDesc Pointer to description string. This must not be
2073 * freed.
2074 * @thread EMT.
2075 */
2076 DECLR3CALLBACKMEMBER(int, pfnMMIO2Register,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion, RTGCPHYS cb,
2077 uint32_t fFlags, void **ppv, const char *pszDesc));
2078
2079 /**
2080 * Pre-register a Memory Mapped I/O (MMIO) region.
2081 *
2082 * This API must be used for large PCI MMIO regions, as it handles these much
2083 * more efficiently and with greater flexibility when it comes to heap usage.
2084 * It is only available during device construction.
2085 *
2086 * To map and unmap the pre-registered region into and our of guest address
2087 * space, use the PDMDevHlpMMIOExMap and PDMDevHlpMMIOExUnmap helpers.
2088 *
2089 * You may call PDMDevHlpMMIOExDeregister from the destructor to free the region
2090 * for reasons of symmetry, but it will be automatically deregistered by PDM
2091 * once the destructor returns.
2092 *
2093 * @returns VBox status.
2094 * @param pDevIns The device instance to register the MMIO with.
2095 * @param pPciDev The PCI device to associate the region with, use
2096 * NULL to not associate it with any device.
2097 * @param iRegion The PCI region number. When @a pPciDev is NULL,
2098 * this is a unique number between 0 and UINT8_MAX.
2099 * @param cbRegion The size of the range (in bytes).
2100 * @param fFlags Flags, IOMMMIO_FLAGS_XXX.
2101 * @param pszDesc Pointer to description string. This must not be freed.
2102 * @param pvUser Ring-3 user argument.
2103 * @param pfnWrite Pointer to function which is gonna handle Write operations.
2104 * @param pfnRead Pointer to function which is gonna handle Read operations.
2105 * @param pfnFill Pointer to function which is gonna handle Fill/memset operations. (optional)
2106 * @param pvUserR0 Ring-0 user argument. Optional.
2107 * @param pszWriteR0 The name of the ring-0 write handler method. Optional.
2108 * @param pszReadR0 The name of the ring-0 read handler method. Optional.
2109 * @param pszFillR0 The name of the ring-0 fill/memset handler method. Optional.
2110 * @param pvUserRC Raw-mode context user argument. Optional. If
2111 * unsigned value is 0x10000 or higher, it will be
2112 * automatically relocated with the hypervisor
2113 * guest mapping.
2114 * @param pszWriteRC The name of the raw-mode context write handler method. Optional.
2115 * @param pszReadRC The name of the raw-mode context read handler method. Optional.
2116 * @param pszFillRC The name of the raw-mode context fill/memset handler method. Optional.
2117 * @thread EMT
2118 *
2119 * @remarks Caller enters the device critical section prior to invoking the
2120 * registered callback methods.
2121 * @sa PDMDevHlpMMIOExMap, PDMDevHlpMMIOExUnmap, PDMDevHlpMMIOExDeregister,
2122 * PDMDevHlpMMIORegisterEx
2123 */
2124 DECLR3CALLBACKMEMBER(int, pfnMMIOExPreRegister,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion, RTGCPHYS cbRegion,
2125 uint32_t fFlags, const char *pszDesc, RTHCPTR pvUser,
2126 PFNIOMMMIOWRITE pfnWrite, PFNIOMMMIOREAD pfnRead, PFNIOMMMIOFILL pfnFill,
2127 RTR0PTR pvUserR0, const char *pszWriteR0, const char *pszReadR0, const char *pszFillR0,
2128 RTRCPTR pvUserRC, const char *pszWriteRC, const char *pszReadRC, const char *pszFillRC));
2129
2130 /**
2131 * Deregisters and frees a MMIO or MMIO2 region.
2132 *
2133 * Any physical (and virtual) access handlers registered for the region must
2134 * be deregistered before calling this function (MMIO2 only).
2135 *
2136 * @returns VBox status code.
2137 * @param pDevIns The device instance.
2138 * @param pPciDev The PCI device the region is associated with, or
2139 * NULL if not associated with any.
2140 * @param iRegion The region number used during registration.
2141 * @thread EMT.
2142 */
2143 DECLR3CALLBACKMEMBER(int, pfnMMIOExDeregister,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion));
2144
2145 /**
2146 * Maps a MMIO or MMIO2 region into the physical memory space.
2147 *
2148 * A MMIO2 range or a pre-registered MMIO range may overlap with base memory if
2149 * a lot of RAM is configured for the VM, in which case we'll drop the base
2150 * memory pages. Presently we will make no attempt to preserve anything that
2151 * happens to be present in the base memory that is replaced, this is of course
2152 * incorrect but it's too much effort.
2153 *
2154 * @returns VBox status code.
2155 * @param pDevIns The device instance.
2156 * @param pPciDev The PCI device the region is associated with, or
2157 * NULL if not associated with any.
2158 * @param iRegion The region number used during registration.
2159 * @param GCPhys The physical address to map it at.
2160 * @thread EMT.
2161 */
2162 DECLR3CALLBACKMEMBER(int, pfnMMIOExMap,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion, RTGCPHYS GCPhys));
2163
2164 /**
2165 * Unmaps a MMIO or MMIO2 region previously mapped using pfnMMIOExMap.
2166 *
2167 * @returns VBox status code.
2168 * @param pDevIns The device instance.
2169 * @param pPciDev The PCI device the region is associated with, or
2170 * NULL if not associated with any.
2171 * @param iRegion The region number used during registration.
2172 * @param GCPhys The physical address it's currently mapped at.
2173 * @thread EMT.
2174 */
2175 DECLR3CALLBACKMEMBER(int, pfnMMIOExUnmap,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion, RTGCPHYS GCPhys));
2176
2177 /**
2178 * Maps a portion of an MMIO2 region into the hypervisor region.
2179 *
2180 * Callers of this API must never deregister the MMIO2 region before the
2181 * VM is powered off.
2182 *
2183 * @return VBox status code.
2184 * @param pDevIns The device owning the MMIO2 memory.
2185 * @param pPciDev The PCI device the region is associated with, or
2186 * NULL if not associated with any.
2187 * @param iRegion The region.
2188 * @param off The offset into the region. Will be rounded down
2189 * to closest page boundary.
2190 * @param cb The number of bytes to map. Will be rounded up
2191 * to the closest page boundary.
2192 * @param pszDesc Mapping description.
2193 * @param pRCPtr Where to store the RC address.
2194 */
2195 DECLR3CALLBACKMEMBER(int, pfnMMHyperMapMMIO2,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion, RTGCPHYS off,
2196 RTGCPHYS cb, const char *pszDesc, PRTRCPTR pRCPtr));
2197
2198 /**
2199 * Maps a portion of an MMIO2 region into kernel space (host).
2200 *
2201 * The kernel mapping will become invalid when the MMIO2 memory is deregistered
2202 * or the VM is terminated.
2203 *
2204 * @return VBox status code.
2205 * @param pDevIns The device owning the MMIO2 memory.
2206 * @param pPciDev The PCI device the region is associated with, or
2207 * NULL if not associated with any.
2208 * @param iRegion The region.
2209 * @param off The offset into the region. Must be page
2210 * aligned.
2211 * @param cb The number of bytes to map. Must be page
2212 * aligned.
2213 * @param pszDesc Mapping description.
2214 * @param pR0Ptr Where to store the R0 address.
2215 */
2216 DECLR3CALLBACKMEMBER(int, pfnMMIO2MapKernel,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion, RTGCPHYS off,
2217 RTGCPHYS cb, const char *pszDesc, PRTR0PTR pR0Ptr));
2218
2219 /**
2220 * Register a ROM (BIOS) region.
2221 *
2222 * It goes without saying that this is read-only memory. The memory region must be
2223 * in unassigned memory. I.e. from the top of the address space or on the PC in
2224 * the 0xa0000-0xfffff range.
2225 *
2226 * @returns VBox status.
2227 * @param pDevIns The device instance owning the ROM region.
2228 * @param GCPhysStart First physical address in the range.
2229 * Must be page aligned!
2230 * @param cbRange The size of the range (in bytes).
2231 * Must be page aligned!
2232 * @param pvBinary Pointer to the binary data backing the ROM image.
2233 * @param cbBinary The size of the binary pointer. This must
2234 * be equal or smaller than @a cbRange.
2235 * @param fFlags Shadow ROM flags, PGMPHYS_ROM_FLAGS_* in pgm.h.
2236 * @param pszDesc Pointer to description string. This must not be freed.
2237 *
2238 * @remark There is no way to remove the rom, automatically on device cleanup or
2239 * manually from the device yet. At present I doubt we need such features...
2240 */
2241 DECLR3CALLBACKMEMBER(int, pfnROMRegister,(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, uint32_t cbRange,
2242 const void *pvBinary, uint32_t cbBinary, uint32_t fFlags, const char *pszDesc));
2243
2244 /**
2245 * Changes the protection of shadowed ROM mapping.
2246 *
2247 * This is intented for use by the system BIOS, chipset or device in question to
2248 * change the protection of shadowed ROM code after init and on reset.
2249 *
2250 * @param pDevIns The device instance.
2251 * @param GCPhysStart Where the mapping starts.
2252 * @param cbRange The size of the mapping.
2253 * @param enmProt The new protection type.
2254 */
2255 DECLR3CALLBACKMEMBER(int, pfnROMProtectShadow,(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, uint32_t cbRange, PGMROMPROT enmProt));
2256
2257 /**
2258 * Register a save state data unit.
2259 *
2260 * @returns VBox status.
2261 * @param pDevIns The device instance.
2262 * @param uVersion Data layout version number.
2263 * @param cbGuess The approximate amount of data in the unit.
2264 * Only for progress indicators.
2265 * @param pszBefore Name of data unit which we should be put in
2266 * front of. Optional (NULL).
2267 *
2268 * @param pfnLivePrep Prepare live save callback, optional.
2269 * @param pfnLiveExec Execute live save callback, optional.
2270 * @param pfnLiveVote Vote live save callback, optional.
2271 *
2272 * @param pfnSavePrep Prepare save callback, optional.
2273 * @param pfnSaveExec Execute save callback, optional.
2274 * @param pfnSaveDone Done save callback, optional.
2275 *
2276 * @param pfnLoadPrep Prepare load callback, optional.
2277 * @param pfnLoadExec Execute load callback, optional.
2278 * @param pfnLoadDone Done load callback, optional.
2279 * @remarks Caller enters the device critical section prior to invoking the
2280 * registered callback methods.
2281 */
2282 DECLR3CALLBACKMEMBER(int, pfnSSMRegister,(PPDMDEVINS pDevIns, uint32_t uVersion, size_t cbGuess, const char *pszBefore,
2283 PFNSSMDEVLIVEPREP pfnLivePrep, PFNSSMDEVLIVEEXEC pfnLiveExec, PFNSSMDEVLIVEVOTE pfnLiveVote,
2284 PFNSSMDEVSAVEPREP pfnSavePrep, PFNSSMDEVSAVEEXEC pfnSaveExec, PFNSSMDEVSAVEDONE pfnSaveDone,
2285 PFNSSMDEVLOADPREP pfnLoadPrep, PFNSSMDEVLOADEXEC pfnLoadExec, PFNSSMDEVLOADDONE pfnLoadDone));
2286
2287 /**
2288 * Creates a timer.
2289 *
2290 * @returns VBox status.
2291 * @param pDevIns The device instance.
2292 * @param enmClock The clock to use on this timer.
2293 * @param pfnCallback Callback function.
2294 * @param pvUser User argument for the callback.
2295 * @param fFlags Flags, see TMTIMER_FLAGS_*.
2296 * @param pszDesc Pointer to description string which must stay around
2297 * until the timer is fully destroyed (i.e. a bit after TMTimerDestroy()).
2298 * @param ppTimer Where to store the timer on success.
2299 * @remarks Caller enters the device critical section prior to invoking the
2300 * callback.
2301 */
2302 DECLR3CALLBACKMEMBER(int, pfnTMTimerCreate,(PPDMDEVINS pDevIns, TMCLOCK enmClock, PFNTMTIMERDEV pfnCallback,
2303 void *pvUser, uint32_t fFlags, const char *pszDesc, PPTMTIMERR3 ppTimer));
2304
2305 /**
2306 * Get the real world UTC time adjusted for VM lag, user offset and warpdrive.
2307 *
2308 * @returns pTime.
2309 * @param pDevIns The device instance.
2310 * @param pTime Where to store the time.
2311 */
2312 DECLR3CALLBACKMEMBER(PRTTIMESPEC, pfnTMUtcNow,(PPDMDEVINS pDevIns, PRTTIMESPEC pTime));
2313
2314 /**
2315 * Read physical memory.
2316 *
2317 * @returns VINF_SUCCESS (for now).
2318 * @param pDevIns The device instance.
2319 * @param GCPhys Physical address start reading from.
2320 * @param pvBuf Where to put the read bits.
2321 * @param cbRead How many bytes to read.
2322 * @thread Any thread, but the call may involve the emulation thread.
2323 */
2324 DECLR3CALLBACKMEMBER(int, pfnPhysRead,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead));
2325
2326 /**
2327 * Write to physical memory.
2328 *
2329 * @returns VINF_SUCCESS for now, and later maybe VERR_EM_MEMORY.
2330 * @param pDevIns The device instance.
2331 * @param GCPhys Physical address to write to.
2332 * @param pvBuf What to write.
2333 * @param cbWrite How many bytes to write.
2334 * @thread Any thread, but the call may involve the emulation thread.
2335 */
2336 DECLR3CALLBACKMEMBER(int, pfnPhysWrite,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite));
2337
2338 /**
2339 * Requests the mapping of a guest page into ring-3.
2340 *
2341 * When you're done with the page, call pfnPhysReleasePageMappingLock() ASAP to
2342 * release it.
2343 *
2344 * This API will assume your intention is to write to the page, and will
2345 * therefore replace shared and zero pages. If you do not intend to modify the
2346 * page, use the pfnPhysGCPhys2CCPtrReadOnly() API.
2347 *
2348 * @returns VBox status code.
2349 * @retval VINF_SUCCESS on success.
2350 * @retval VERR_PGM_PHYS_PAGE_RESERVED it it's a valid page but has no physical
2351 * backing or if the page has any active access handlers. The caller
2352 * must fall back on using PGMR3PhysWriteExternal.
2353 * @retval VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS if it's not a valid physical address.
2354 *
2355 * @param pDevIns The device instance.
2356 * @param GCPhys The guest physical address of the page that
2357 * should be mapped.
2358 * @param fFlags Flags reserved for future use, MBZ.
2359 * @param ppv Where to store the address corresponding to
2360 * GCPhys.
2361 * @param pLock Where to store the lock information that
2362 * pfnPhysReleasePageMappingLock needs.
2363 *
2364 * @remark Avoid calling this API from within critical sections (other than the
2365 * PGM one) because of the deadlock risk when we have to delegating the
2366 * task to an EMT.
2367 * @thread Any.
2368 */
2369 DECLR3CALLBACKMEMBER(int, pfnPhysGCPhys2CCPtr,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, uint32_t fFlags, void **ppv,
2370 PPGMPAGEMAPLOCK pLock));
2371
2372 /**
2373 * Requests the mapping of a guest page into ring-3, external threads.
2374 *
2375 * When you're done with the page, call pfnPhysReleasePageMappingLock() ASAP to
2376 * release it.
2377 *
2378 * @returns VBox status code.
2379 * @retval VINF_SUCCESS on success.
2380 * @retval VERR_PGM_PHYS_PAGE_RESERVED it it's a valid page but has no physical
2381 * backing or if the page as an active ALL access handler. The caller
2382 * must fall back on using PGMPhysRead.
2383 * @retval VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS if it's not a valid physical address.
2384 *
2385 * @param pDevIns The device instance.
2386 * @param GCPhys The guest physical address of the page that
2387 * should be mapped.
2388 * @param fFlags Flags reserved for future use, MBZ.
2389 * @param ppv Where to store the address corresponding to
2390 * GCPhys.
2391 * @param pLock Where to store the lock information that
2392 * pfnPhysReleasePageMappingLock needs.
2393 *
2394 * @remark Avoid calling this API from within critical sections.
2395 * @thread Any.
2396 */
2397 DECLR3CALLBACKMEMBER(int, pfnPhysGCPhys2CCPtrReadOnly,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, uint32_t fFlags,
2398 void const **ppv, PPGMPAGEMAPLOCK pLock));
2399
2400 /**
2401 * Release the mapping of a guest page.
2402 *
2403 * This is the counter part of pfnPhysGCPhys2CCPtr and
2404 * pfnPhysGCPhys2CCPtrReadOnly.
2405 *
2406 * @param pDevIns The device instance.
2407 * @param pLock The lock structure initialized by the mapping
2408 * function.
2409 */
2410 DECLR3CALLBACKMEMBER(void, pfnPhysReleasePageMappingLock,(PPDMDEVINS pDevIns, PPGMPAGEMAPLOCK pLock));
2411
2412 /**
2413 * Read guest physical memory by virtual address.
2414 *
2415 * @param pDevIns The device instance.
2416 * @param pvDst Where to put the read bits.
2417 * @param GCVirtSrc Guest virtual address to start reading from.
2418 * @param cb How many bytes to read.
2419 * @thread The emulation thread.
2420 */
2421 DECLR3CALLBACKMEMBER(int, pfnPhysReadGCVirt,(PPDMDEVINS pDevIns, void *pvDst, RTGCPTR GCVirtSrc, size_t cb));
2422
2423 /**
2424 * Write to guest physical memory by virtual address.
2425 *
2426 * @param pDevIns The device instance.
2427 * @param GCVirtDst Guest virtual address to write to.
2428 * @param pvSrc What to write.
2429 * @param cb How many bytes to write.
2430 * @thread The emulation thread.
2431 */
2432 DECLR3CALLBACKMEMBER(int, pfnPhysWriteGCVirt,(PPDMDEVINS pDevIns, RTGCPTR GCVirtDst, const void *pvSrc, size_t cb));
2433
2434 /**
2435 * Convert a guest virtual address to a guest physical address.
2436 *
2437 * @returns VBox status code.
2438 * @param pDevIns The device instance.
2439 * @param GCPtr Guest virtual address.
2440 * @param pGCPhys Where to store the GC physical address
2441 * corresponding to GCPtr.
2442 * @thread The emulation thread.
2443 * @remark Careful with page boundaries.
2444 */
2445 DECLR3CALLBACKMEMBER(int, pfnPhysGCPtr2GCPhys, (PPDMDEVINS pDevIns, RTGCPTR GCPtr, PRTGCPHYS pGCPhys));
2446
2447 /**
2448 * Allocate memory which is associated with current VM instance
2449 * and automatically freed on it's destruction.
2450 *
2451 * @returns Pointer to allocated memory. The memory is *NOT* zero-ed.
2452 * @param pDevIns The device instance.
2453 * @param cb Number of bytes to allocate.
2454 */
2455 DECLR3CALLBACKMEMBER(void *, pfnMMHeapAlloc,(PPDMDEVINS pDevIns, size_t cb));
2456
2457 /**
2458 * Allocate memory which is associated with current VM instance
2459 * and automatically freed on it's destruction. The memory is ZEROed.
2460 *
2461 * @returns Pointer to allocated memory. The memory is *NOT* zero-ed.
2462 * @param pDevIns The device instance.
2463 * @param cb Number of bytes to allocate.
2464 */
2465 DECLR3CALLBACKMEMBER(void *, pfnMMHeapAllocZ,(PPDMDEVINS pDevIns, size_t cb));
2466
2467 /**
2468 * Free memory allocated with pfnMMHeapAlloc() and pfnMMHeapAllocZ().
2469 *
2470 * @param pDevIns The device instance.
2471 * @param pv Pointer to the memory to free.
2472 */
2473 DECLR3CALLBACKMEMBER(void, pfnMMHeapFree,(PPDMDEVINS pDevIns, void *pv));
2474
2475 /**
2476 * Gets the VM state.
2477 *
2478 * @returns VM state.
2479 * @param pDevIns The device instance.
2480 * @thread Any thread (just keep in mind that it's volatile info).
2481 */
2482 DECLR3CALLBACKMEMBER(VMSTATE, pfnVMState, (PPDMDEVINS pDevIns));
2483
2484 /**
2485 * Checks if the VM was teleported and hasn't been fully resumed yet.
2486 *
2487 * @returns true / false.
2488 * @param pDevIns The device instance.
2489 * @thread Any thread.
2490 */
2491 DECLR3CALLBACKMEMBER(bool, pfnVMTeleportedAndNotFullyResumedYet,(PPDMDEVINS pDevIns));
2492
2493 /**
2494 * Set the VM error message
2495 *
2496 * @returns rc.
2497 * @param pDevIns The device instance.
2498 * @param rc VBox status code.
2499 * @param SRC_POS Use RT_SRC_POS.
2500 * @param pszFormat Error message format string.
2501 * @param ... Error message arguments.
2502 */
2503 DECLR3CALLBACKMEMBER(int, pfnVMSetError,(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL,
2504 const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(6, 7));
2505
2506 /**
2507 * Set the VM error message
2508 *
2509 * @returns rc.
2510 * @param pDevIns The device instance.
2511 * @param rc VBox status code.
2512 * @param SRC_POS Use RT_SRC_POS.
2513 * @param pszFormat Error message format string.
2514 * @param va Error message arguments.
2515 */
2516 DECLR3CALLBACKMEMBER(int, pfnVMSetErrorV,(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL,
2517 const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(6, 0));
2518
2519 /**
2520 * Set the VM runtime error message
2521 *
2522 * @returns VBox status code.
2523 * @param pDevIns The device instance.
2524 * @param fFlags The action flags. See VMSETRTERR_FLAGS_*.
2525 * @param pszErrorId Error ID string.
2526 * @param pszFormat Error message format string.
2527 * @param ... Error message arguments.
2528 */
2529 DECLR3CALLBACKMEMBER(int, pfnVMSetRuntimeError,(PPDMDEVINS pDevIns, uint32_t fFlags, const char *pszErrorId,
2530 const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(4, 5));
2531
2532 /**
2533 * Set the VM runtime error message
2534 *
2535 * @returns VBox status code.
2536 * @param pDevIns The device instance.
2537 * @param fFlags The action flags. See VMSETRTERR_FLAGS_*.
2538 * @param pszErrorId Error ID string.
2539 * @param pszFormat Error message format string.
2540 * @param va Error message arguments.
2541 */
2542 DECLR3CALLBACKMEMBER(int, pfnVMSetRuntimeErrorV,(PPDMDEVINS pDevIns, uint32_t fFlags, const char *pszErrorId,
2543 const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(4, 0));
2544
2545 /**
2546 * Stops the VM and enters the debugger to look at the guest state.
2547 *
2548 * Use the PDMDeviceDBGFStop() inline function with the RT_SRC_POS macro instead of
2549 * invoking this function directly.
2550 *
2551 * @returns VBox status code which must be passed up to the VMM.
2552 * @param pDevIns The device instance.
2553 * @param pszFile Filename of the assertion location.
2554 * @param iLine The linenumber of the assertion location.
2555 * @param pszFunction Function of the assertion location.
2556 * @param pszFormat Message. (optional)
2557 * @param args Message parameters.
2558 */
2559 DECLR3CALLBACKMEMBER(int, pfnDBGFStopV,(PPDMDEVINS pDevIns, const char *pszFile, unsigned iLine, const char *pszFunction,
2560 const char *pszFormat, va_list args) RT_IPRT_FORMAT_ATTR(5, 0));
2561
2562 /**
2563 * Register a info handler with DBGF,
2564 *
2565 * @returns VBox status code.
2566 * @param pDevIns The device instance.
2567 * @param pszName The identifier of the info.
2568 * @param pszDesc The description of the info and any arguments
2569 * the handler may take.
2570 * @param pfnHandler The handler function to be called to display the
2571 * info.
2572 */
2573 DECLR3CALLBACKMEMBER(int, pfnDBGFInfoRegister,(PPDMDEVINS pDevIns, const char *pszName, const char *pszDesc, PFNDBGFHANDLERDEV pfnHandler));
2574
2575 /**
2576 * Registers a set of registers for a device.
2577 *
2578 * The @a pvUser argument of the getter and setter callbacks will be
2579 * @a pDevIns. The register names will be prefixed by the device name followed
2580 * immediately by the instance number.
2581 *
2582 * @returns VBox status code.
2583 * @param pDevIns The device instance.
2584 * @param paRegisters The register descriptors.
2585 *
2586 * @remarks The device critical section is NOT entered prior to working the
2587 * callbacks registered via this helper!
2588 */
2589 DECLR3CALLBACKMEMBER(int, pfnDBGFRegRegister,(PPDMDEVINS pDevIns, PCDBGFREGDESC paRegisters));
2590
2591 /**
2592 * Gets the trace buffer handle.
2593 *
2594 * This is used by the macros found in VBox/vmm/dbgftrace.h and is not
2595 * really inteded for direct usage, thus no inline wrapper function.
2596 *
2597 * @returns Trace buffer handle or NIL_RTTRACEBUF.
2598 * @param pDevIns The device instance.
2599 */
2600 DECLR3CALLBACKMEMBER(RTTRACEBUF, pfnDBGFTraceBuf,(PPDMDEVINS pDevIns));
2601
2602 /**
2603 * Registers a statistics sample if statistics are enabled.
2604 *
2605 * @param pDevIns Device instance of the DMA.
2606 * @param pvSample Pointer to the sample.
2607 * @param enmType Sample type. This indicates what pvSample is
2608 * pointing at.
2609 * @param pszName Sample name. The name is on this form
2610 * "/<component>/<sample>". Further nesting is
2611 * possible.
2612 * @param enmUnit Sample unit.
2613 * @param pszDesc Sample description.
2614 */
2615 DECLR3CALLBACKMEMBER(void, pfnSTAMRegister,(PPDMDEVINS pDevIns, void *pvSample, STAMTYPE enmType, const char *pszName, STAMUNIT enmUnit, const char *pszDesc));
2616
2617 /**
2618 * Same as pfnSTAMRegister except that the name is specified in a
2619 * RTStrPrintf like fashion.
2620 *
2621 * @returns VBox status.
2622 * @param pDevIns Device instance of the DMA.
2623 * @param pvSample Pointer to the sample.
2624 * @param enmType Sample type. This indicates what pvSample is
2625 * pointing at.
2626 * @param enmVisibility Visibility type specifying whether unused
2627 * statistics should be visible or not.
2628 * @param enmUnit Sample unit.
2629 * @param pszDesc Sample description.
2630 * @param pszName The sample name format string.
2631 * @param ... Arguments to the format string.
2632 */
2633 DECLR3CALLBACKMEMBER(void, pfnSTAMRegisterF,(PPDMDEVINS pDevIns, void *pvSample, STAMTYPE enmType,
2634 STAMVISIBILITY enmVisibility, STAMUNIT enmUnit, const char *pszDesc,
2635 const char *pszName, ...) RT_IPRT_FORMAT_ATTR(7, 8));
2636
2637 /**
2638 * Same as pfnSTAMRegister except that the name is specified in a
2639 * RTStrPrintfV like fashion.
2640 *
2641 * @returns VBox status.
2642 * @param pDevIns Device instance of the DMA.
2643 * @param pvSample Pointer to the sample.
2644 * @param enmType Sample type. This indicates what pvSample is
2645 * pointing at.
2646 * @param enmVisibility Visibility type specifying whether unused
2647 * statistics should be visible or not.
2648 * @param enmUnit Sample unit.
2649 * @param pszDesc Sample description.
2650 * @param pszName The sample name format string.
2651 * @param args Arguments to the format string.
2652 */
2653 DECLR3CALLBACKMEMBER(void, pfnSTAMRegisterV,(PPDMDEVINS pDevIns, void *pvSample, STAMTYPE enmType,
2654 STAMVISIBILITY enmVisibility, STAMUNIT enmUnit, const char *pszDesc,
2655 const char *pszName, va_list args) RT_IPRT_FORMAT_ATTR(7, 0));
2656
2657 /**
2658 * Registers a PCI device with the default PCI bus.
2659 *
2660 * @returns VBox status code.
2661 * @param pDevIns The device instance.
2662 * @param pPciDev The PCI device structure.
2663 * This must be kept in the instance data.
2664 * The PCI configuration must be initialized before registration.
2665 * @param idxDevCfg The CFGM configuration index to use for this
2666 * device.
2667 * Zero indicates the default configuration
2668 * (PDMPCIDEVREG_CFG_PRIMARY), whereas 1 to 255
2669 * references subkeys "PciDev1" thru "PciDev255".
2670 * Pass PDMPCIDEVREG_CFG_NEXT to use the next
2671 * number in the sequence (last + 1).
2672 * @param fFlags Reserved for future use, PDMPCIDEVREG_F_MBZ.
2673 * @param uPciDevNo PDMPCIDEVREG_DEV_NO_FIRST_UNUSED,
2674 * PDMPCIDEVREG_DEV_NO_SAME_AS_PREV, or a specific
2675 * device number (0-31). This will be ignored if
2676 * the CFGM configuration contains a PCIDeviceNo
2677 * value.
2678 * @param uPciFunNo PDMPCIDEVREG_FUN_NO_FIRST_UNUSED, or a specific
2679 * function number (0-7). This will be ignored if
2680 * the CFGM configuration contains a PCIFunctionNo
2681 * value.
2682 * @param pszName Device name, if NULL PDMDEVREG::szName is used.
2683 * The pointer is saved, so don't free or changed.
2684 */
2685 DECLR3CALLBACKMEMBER(int, pfnPCIRegister,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t idxDevCfg, uint32_t fFlags,
2686 uint8_t uPciDevNo, uint8_t uPciFunNo, const char *pszName));
2687
2688 /**
2689 * Initialize MSI support for the given PCI device.
2690 *
2691 * @returns VBox status code.
2692 * @param pDevIns The device instance.
2693 * @param pPciDev The PCI device. NULL is an alias for the first
2694 * one registered.
2695 * @param pMsiReg MSI registartion structure.
2696 */
2697 DECLR3CALLBACKMEMBER(int, pfnPCIRegisterMsi,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, PPDMMSIREG pMsiReg));
2698
2699 /**
2700 * Registers a I/O region (memory mapped or I/O ports) for a PCI device.
2701 *
2702 * @returns VBox status code.
2703 * @param pDevIns The device instance.
2704 * @param pPciDev The PCI device structure. If NULL the default
2705 * PCI device for this device instance is used.
2706 * @param iRegion The region number.
2707 * @param cbRegion Size of the region.
2708 * @param enmType PCI_ADDRESS_SPACE_MEM, PCI_ADDRESS_SPACE_IO or PCI_ADDRESS_SPACE_MEM_PREFETCH.
2709 * @param pfnCallback Callback for doing the mapping.
2710 * @remarks The callback will be invoked holding the PDM lock. The device lock
2711 * is NOT take because that is very likely be a lock order violation.
2712 */
2713 DECLR3CALLBACKMEMBER(int, pfnPCIIORegionRegister,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion, RTGCPHYS cbRegion,
2714 PCIADDRESSSPACE enmType, PFNPCIIOREGIONMAP pfnCallback));
2715
2716 /**
2717 * Register PCI configuration space read/write callbacks.
2718 *
2719 * @param pDevIns The device instance.
2720 * @param pPciDev The PCI device structure. If NULL the default
2721 * PCI device for this device instance is used.
2722 * @param pfnRead Pointer to the user defined PCI config read function.
2723 * @param ppfnReadOld Pointer to function pointer which will receive the old (default)
2724 * PCI config read function. This way, user can decide when (and if)
2725 * to call default PCI config read function. Can be NULL.
2726 * @param pfnWrite Pointer to the user defined PCI config write function.
2727 * @param ppfnWriteOld Pointer to function pointer which will receive
2728 * the old (default) PCI config write function.
2729 * This way, user can decide when (and if) to call
2730 * default PCI config write function. Can be NULL.
2731 * @remarks The callbacks will be invoked holding the PDM lock. The device lock
2732 * is NOT take because that is very likely be a lock order violation.
2733 * @thread EMT
2734 */
2735 DECLR3CALLBACKMEMBER(void, pfnPCISetConfigCallbacks,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev,
2736 PFNPCICONFIGREAD pfnRead, PPFNPCICONFIGREAD ppfnReadOld,
2737 PFNPCICONFIGWRITE pfnWrite, PPFNPCICONFIGWRITE ppfnWriteOld));
2738
2739 /**
2740 * Bus master physical memory read.
2741 *
2742 * @returns VINF_SUCCESS or VERR_PGM_PCI_PHYS_READ_BM_DISABLED, later maybe
2743 * VERR_EM_MEMORY. The informational status shall NOT be propagated!
2744 * @param pDevIns The device instance.
2745 * @param pPciDev The PCI device structure. If NULL the default
2746 * PCI device for this device instance is used.
2747 * @param GCPhys Physical address start reading from.
2748 * @param pvBuf Where to put the read bits.
2749 * @param cbRead How many bytes to read.
2750 * @thread Any thread, but the call may involve the emulation thread.
2751 */
2752 DECLR3CALLBACKMEMBER(int, pfnPCIPhysRead,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead));
2753
2754 /**
2755 * Bus master physical memory write.
2756 *
2757 * @returns VINF_SUCCESS or VERR_PGM_PCI_PHYS_WRITE_BM_DISABLED, later maybe
2758 * VERR_EM_MEMORY. The informational status shall NOT be propagated!
2759 * @param pDevIns The device instance.
2760 * @param pPciDev The PCI device structure. If NULL the default
2761 * PCI device for this device instance is used.
2762 * @param GCPhys Physical address to write to.
2763 * @param pvBuf What to write.
2764 * @param cbWrite How many bytes to write.
2765 * @thread Any thread, but the call may involve the emulation thread.
2766 */
2767 DECLR3CALLBACKMEMBER(int, pfnPCIPhysWrite,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite));
2768
2769 /**
2770 * Sets the IRQ for the given PCI device.
2771 *
2772 * @param pDevIns The device instance.
2773 * @param pPciDev The PCI device structure. If NULL the default
2774 * PCI device for this device instance is used.
2775 * @param iIrq IRQ number to set.
2776 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
2777 * @thread Any thread, but will involve the emulation thread.
2778 */
2779 DECLR3CALLBACKMEMBER(void, pfnPCISetIrq,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iIrq, int iLevel));
2780
2781 /**
2782 * Sets the IRQ for the given PCI device, but doesn't wait for EMT to process
2783 * the request when not called from EMT.
2784 *
2785 * @param pDevIns The device instance.
2786 * @param pPciDev The PCI device structure. If NULL the default
2787 * PCI device for this device instance is used.
2788 * @param iIrq IRQ number to set.
2789 * @param iLevel IRQ level.
2790 * @thread Any thread, but will involve the emulation thread.
2791 */
2792 DECLR3CALLBACKMEMBER(void, pfnPCISetIrqNoWait,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iIrq, int iLevel));
2793
2794 /**
2795 * Set ISA IRQ for a device.
2796 *
2797 * @param pDevIns The device instance.
2798 * @param iIrq IRQ number to set.
2799 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
2800 * @thread Any thread, but will involve the emulation thread.
2801 */
2802 DECLR3CALLBACKMEMBER(void, pfnISASetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
2803
2804 /**
2805 * Set the ISA IRQ for a device, but don't wait for EMT to process
2806 * the request when not called from EMT.
2807 *
2808 * @param pDevIns The device instance.
2809 * @param iIrq IRQ number to set.
2810 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
2811 * @thread Any thread, but will involve the emulation thread.
2812 */
2813 DECLR3CALLBACKMEMBER(void, pfnISASetIrqNoWait,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
2814
2815 /**
2816 * Attaches a driver (chain) to the device.
2817 *
2818 * The first call for a LUN this will serve as a registartion of the LUN. The pBaseInterface and
2819 * the pszDesc string will be registered with that LUN and kept around for PDMR3QueryDeviceLun().
2820 *
2821 * @returns VBox status code.
2822 * @param pDevIns The device instance.
2823 * @param iLun The logical unit to attach.
2824 * @param pBaseInterface Pointer to the base interface for that LUN. (device side / down)
2825 * @param ppBaseInterface Where to store the pointer to the base interface. (driver side / up)
2826 * @param pszDesc Pointer to a string describing the LUN. This string must remain valid
2827 * for the live of the device instance.
2828 */
2829 DECLR3CALLBACKMEMBER(int, pfnDriverAttach,(PPDMDEVINS pDevIns, uint32_t iLun, PPDMIBASE pBaseInterface,
2830 PPDMIBASE *ppBaseInterface, const char *pszDesc));
2831
2832 /**
2833 * Detaches an attached driver (chain) from the device again.
2834 *
2835 * @returns VBox status code.
2836 * @param pDevIns The device instance.
2837 * @param pDrvIns The driver instance to detach.
2838 * @param fFlags Flags, combination of the PDMDEVATT_FLAGS_* \#defines.
2839 */
2840 DECLR3CALLBACKMEMBER(int, pfnDriverDetach,(PPDMDEVINS pDevIns, PPDMDRVINS pDrvIns, uint32_t fFlags));
2841
2842 /**
2843 * Create a queue.
2844 *
2845 * @returns VBox status code.
2846 * @param pDevIns The device instance.
2847 * @param cbItem The size of a queue item.
2848 * @param cItems The number of items in the queue.
2849 * @param cMilliesInterval The number of milliseconds between polling the queue.
2850 * If 0 then the emulation thread will be notified whenever an item arrives.
2851 * @param pfnCallback The consumer function.
2852 * @param fRZEnabled Set if the queue should work in RC and R0.
2853 * @param pszName The queue base name. The instance number will be
2854 * appended automatically.
2855 * @param ppQueue Where to store the queue handle on success.
2856 * @thread The emulation thread.
2857 * @remarks The device critical section will NOT be entered before calling the
2858 * callback. No locks will be held, but for now it's safe to assume
2859 * that only one EMT will do queue callbacks at any one time.
2860 */
2861 DECLR3CALLBACKMEMBER(int, pfnQueueCreate,(PPDMDEVINS pDevIns, size_t cbItem, uint32_t cItems, uint32_t cMilliesInterval,
2862 PFNPDMQUEUEDEV pfnCallback, bool fRZEnabled, const char *pszName, PPDMQUEUE *ppQueue));
2863
2864 /**
2865 * Initializes a PDM critical section.
2866 *
2867 * The PDM critical sections are derived from the IPRT critical sections, but
2868 * works in RC and R0 as well.
2869 *
2870 * @returns VBox status code.
2871 * @param pDevIns The device instance.
2872 * @param pCritSect Pointer to the critical section.
2873 * @param SRC_POS Use RT_SRC_POS.
2874 * @param pszNameFmt Format string for naming the critical section.
2875 * For statistics and lock validation.
2876 * @param va Arguments for the format string.
2877 */
2878 DECLR3CALLBACKMEMBER(int, pfnCritSectInit,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, RT_SRC_POS_DECL,
2879 const char *pszNameFmt, va_list va) RT_IPRT_FORMAT_ATTR(6, 0));
2880
2881 /**
2882 * Gets the NOP critical section.
2883 *
2884 * @returns The ring-3 address of the NOP critical section.
2885 * @param pDevIns The device instance.
2886 */
2887 DECLR3CALLBACKMEMBER(PPDMCRITSECT, pfnCritSectGetNop,(PPDMDEVINS pDevIns));
2888
2889 /**
2890 * Gets the NOP critical section.
2891 *
2892 * @returns The ring-0 address of the NOP critical section.
2893 * @param pDevIns The device instance.
2894 */
2895 DECLR3CALLBACKMEMBER(R0PTRTYPE(PPDMCRITSECT), pfnCritSectGetNopR0,(PPDMDEVINS pDevIns));
2896
2897 /**
2898 * Gets the NOP critical section.
2899 *
2900 * @returns The raw-mode context address of the NOP critical section.
2901 * @param pDevIns The device instance.
2902 */
2903 DECLR3CALLBACKMEMBER(RCPTRTYPE(PPDMCRITSECT), pfnCritSectGetNopRC,(PPDMDEVINS pDevIns));
2904
2905 /**
2906 * Changes the device level critical section from the automatically created
2907 * default to one desired by the device constructor.
2908 *
2909 * @returns VBox status code.
2910 * @param pDevIns The device instance.
2911 * @param pCritSect The critical section to use. NULL is not
2912 * valid, instead use the NOP critical
2913 * section.
2914 */
2915 DECLR3CALLBACKMEMBER(int, pfnSetDeviceCritSect,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect));
2916
2917 /**
2918 * Creates a PDM thread.
2919 *
2920 * This differs from the RTThreadCreate() API in that PDM takes care of suspending,
2921 * resuming, and destroying the thread as the VM state changes.
2922 *
2923 * @returns VBox status code.
2924 * @param pDevIns The device instance.
2925 * @param ppThread Where to store the thread 'handle'.
2926 * @param pvUser The user argument to the thread function.
2927 * @param pfnThread The thread function.
2928 * @param pfnWakeup The wakup callback. This is called on the EMT
2929 * thread when a state change is pending.
2930 * @param cbStack See RTThreadCreate.
2931 * @param enmType See RTThreadCreate.
2932 * @param pszName See RTThreadCreate.
2933 * @remarks The device critical section will NOT be entered prior to invoking
2934 * the function pointers.
2935 */
2936 DECLR3CALLBACKMEMBER(int, pfnThreadCreate,(PPDMDEVINS pDevIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADDEV pfnThread,
2937 PFNPDMTHREADWAKEUPDEV pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName));
2938
2939 /**
2940 * Set up asynchronous handling of a suspend, reset or power off notification.
2941 *
2942 * This shall only be called when getting the notification. It must be called
2943 * for each one.
2944 *
2945 * @returns VBox status code.
2946 * @param pDevIns The device instance.
2947 * @param pfnAsyncNotify The callback.
2948 * @thread EMT(0)
2949 * @remarks The caller will enter the device critical section prior to invoking
2950 * the callback.
2951 */
2952 DECLR3CALLBACKMEMBER(int, pfnSetAsyncNotification, (PPDMDEVINS pDevIns, PFNPDMDEVASYNCNOTIFY pfnAsyncNotify));
2953
2954 /**
2955 * Notify EMT(0) that the device has completed the asynchronous notification
2956 * handling.
2957 *
2958 * This can be called at any time, spurious calls will simply be ignored.
2959 *
2960 * @param pDevIns The device instance.
2961 * @thread Any
2962 */
2963 DECLR3CALLBACKMEMBER(void, pfnAsyncNotificationCompleted, (PPDMDEVINS pDevIns));
2964
2965 /**
2966 * Register the RTC device.
2967 *
2968 * @returns VBox status code.
2969 * @param pDevIns The device instance.
2970 * @param pRtcReg Pointer to a RTC registration structure.
2971 * @param ppRtcHlp Where to store the pointer to the helper
2972 * functions.
2973 */
2974 DECLR3CALLBACKMEMBER(int, pfnRTCRegister,(PPDMDEVINS pDevIns, PCPDMRTCREG pRtcReg, PCPDMRTCHLP *ppRtcHlp));
2975
2976#if PDM_DEVHLPR3_VERSION >= PDM_VERSION_MAKE_PP(0xffe7, 20, 0)
2977 /**
2978 * Register a PCI Bus.
2979 *
2980 * @returns VBox status code, but the positive values 0..31 are used to indicate
2981 * bus number rather than informational status codes.
2982 * @param pDevIns The device instance.
2983 * @param pPciBusReg Pointer to PCI bus registration structure.
2984 * @param ppPciHlpR3 Where to store the pointer to the PCI Bus
2985 * helpers.
2986 * @param piBus Where to return the PDM bus number. Optional.
2987 */
2988 DECLR3CALLBACKMEMBER(int, pfnPCIBusRegister,(PPDMDEVINS pDevIns, PPDMPCIBUSREG pPciBusReg,
2989 PCPDMPCIHLPR3 *ppPciHlpR3, uint32_t *piBus));
2990#else
2991 /**
2992 * Register a PCI Bus.
2993 *
2994 * @returns VBox status code, but the positive values 0..31 are used to indicate
2995 * bus number rather than informational status codes.
2996 * @param pDevIns The device instance.
2997 * @param pPciBusReg Pointer to PCI bus registration structure.
2998 * @param ppPciHlpR3 Where to store the pointer to the PCI Bus
2999 * helpers.
3000 */
3001 DECLR3CALLBACKMEMBER(int, pfnPCIBusRegister,(PPDMDEVINS pDevIns, PPDMPCIBUSREG pPciBusReg, PCPDMPCIHLPR3 *ppPciHlpR3));
3002#endif
3003
3004 /**
3005 * Register the PIC device.
3006 *
3007 * @returns VBox status code.
3008 * @param pDevIns The device instance.
3009 * @param pPicReg Pointer to a PIC registration structure.
3010 * @param ppPicHlpR3 Where to store the pointer to the PIC HC
3011 * helpers.
3012 */
3013 DECLR3CALLBACKMEMBER(int, pfnPICRegister,(PPDMDEVINS pDevIns, PPDMPICREG pPicReg, PCPDMPICHLPR3 *ppPicHlpR3));
3014
3015 /**
3016 * Register the APIC device.
3017 *
3018 * @returns VBox status code.
3019 * @param pDevIns The device instance.
3020 */
3021 DECLR3CALLBACKMEMBER(int, pfnAPICRegister,(PPDMDEVINS pDevIns));
3022
3023 /**
3024 * Register the I/O APIC device.
3025 *
3026 * @returns VBox status code.
3027 * @param pDevIns The device instance.
3028 * @param pIoApicReg Pointer to a I/O APIC registration structure.
3029 * @param ppIoApicHlpR3 Where to store the pointer to the IOAPIC
3030 * helpers.
3031 */
3032 DECLR3CALLBACKMEMBER(int, pfnIOAPICRegister,(PPDMDEVINS pDevIns, PPDMIOAPICREG pIoApicReg, PCPDMIOAPICHLPR3 *ppIoApicHlpR3));
3033
3034 /**
3035 * Register the HPET device.
3036 *
3037 * @returns VBox status code.
3038 * @param pDevIns The device instance.
3039 * @param pHpetReg Pointer to a HPET registration structure.
3040 * @param ppHpetHlpR3 Where to store the pointer to the HPET
3041 * helpers.
3042 */
3043 DECLR3CALLBACKMEMBER(int, pfnHPETRegister,(PPDMDEVINS pDevIns, PPDMHPETREG pHpetReg, PCPDMHPETHLPR3 *ppHpetHlpR3));
3044
3045 /**
3046 * Register a raw PCI device.
3047 *
3048 * @returns VBox status code.
3049 * @param pDevIns The device instance.
3050 * @param pPciRawReg Pointer to a raw PCI registration structure.
3051 * @param ppPciRawHlpR3 Where to store the pointer to the raw PCI
3052 * device helpers.
3053 */
3054 DECLR3CALLBACKMEMBER(int, pfnPciRawRegister,(PPDMDEVINS pDevIns, PPDMPCIRAWREG pPciRawReg, PCPDMPCIRAWHLPR3 *ppPciRawHlpR3));
3055
3056 /**
3057 * Register the DMA device.
3058 *
3059 * @returns VBox status code.
3060 * @param pDevIns The device instance.
3061 * @param pDmacReg Pointer to a DMAC registration structure.
3062 * @param ppDmacHlp Where to store the pointer to the DMA helpers.
3063 */
3064 DECLR3CALLBACKMEMBER(int, pfnDMACRegister,(PPDMDEVINS pDevIns, PPDMDMACREG pDmacReg, PCPDMDMACHLP *ppDmacHlp));
3065
3066 /**
3067 * Register transfer function for DMA channel.
3068 *
3069 * @returns VBox status code.
3070 * @param pDevIns The device instance.
3071 * @param uChannel Channel number.
3072 * @param pfnTransferHandler Device specific transfer callback function.
3073 * @param pvUser User pointer to pass to the callback.
3074 * @thread EMT
3075 */
3076 DECLR3CALLBACKMEMBER(int, pfnDMARegister,(PPDMDEVINS pDevIns, unsigned uChannel, PFNDMATRANSFERHANDLER pfnTransferHandler, void *pvUser));
3077
3078 /**
3079 * Read memory.
3080 *
3081 * @returns VBox status code.
3082 * @param pDevIns The device instance.
3083 * @param uChannel Channel number.
3084 * @param pvBuffer Pointer to target buffer.
3085 * @param off DMA position.
3086 * @param cbBlock Block size.
3087 * @param pcbRead Where to store the number of bytes which was
3088 * read. optional.
3089 * @thread EMT
3090 */
3091 DECLR3CALLBACKMEMBER(int, pfnDMAReadMemory,(PPDMDEVINS pDevIns, unsigned uChannel, void *pvBuffer, uint32_t off, uint32_t cbBlock, uint32_t *pcbRead));
3092
3093 /**
3094 * Write memory.
3095 *
3096 * @returns VBox status code.
3097 * @param pDevIns The device instance.
3098 * @param uChannel Channel number.
3099 * @param pvBuffer Memory to write.
3100 * @param off DMA position.
3101 * @param cbBlock Block size.
3102 * @param pcbWritten Where to store the number of bytes which was
3103 * written. optional.
3104 * @thread EMT
3105 */
3106 DECLR3CALLBACKMEMBER(int, pfnDMAWriteMemory,(PPDMDEVINS pDevIns, unsigned uChannel, const void *pvBuffer, uint32_t off, uint32_t cbBlock, uint32_t *pcbWritten));
3107
3108 /**
3109 * Set the DREQ line.
3110 *
3111 * @returns VBox status code.
3112 * @param pDevIns Device instance.
3113 * @param uChannel Channel number.
3114 * @param uLevel Level of the line.
3115 * @thread EMT
3116 */
3117 DECLR3CALLBACKMEMBER(int, pfnDMASetDREQ,(PPDMDEVINS pDevIns, unsigned uChannel, unsigned uLevel));
3118
3119 /**
3120 * Get channel mode.
3121 *
3122 * @returns Channel mode. See specs.
3123 * @param pDevIns The device instance.
3124 * @param uChannel Channel number.
3125 * @thread EMT
3126 */
3127 DECLR3CALLBACKMEMBER(uint8_t, pfnDMAGetChannelMode,(PPDMDEVINS pDevIns, unsigned uChannel));
3128
3129 /**
3130 * Schedule DMA execution.
3131 *
3132 * @param pDevIns The device instance.
3133 * @thread Any thread.
3134 */
3135 DECLR3CALLBACKMEMBER(void, pfnDMASchedule,(PPDMDEVINS pDevIns));
3136
3137 /**
3138 * Write CMOS value and update the checksum(s).
3139 *
3140 * @returns VBox status code.
3141 * @param pDevIns The device instance.
3142 * @param iReg The CMOS register index.
3143 * @param u8Value The CMOS register value.
3144 * @thread EMT
3145 */
3146 DECLR3CALLBACKMEMBER(int, pfnCMOSWrite,(PPDMDEVINS pDevIns, unsigned iReg, uint8_t u8Value));
3147
3148 /**
3149 * Read CMOS value.
3150 *
3151 * @returns VBox status code.
3152 * @param pDevIns The device instance.
3153 * @param iReg The CMOS register index.
3154 * @param pu8Value Where to store the CMOS register value.
3155 * @thread EMT
3156 */
3157 DECLR3CALLBACKMEMBER(int, pfnCMOSRead,(PPDMDEVINS pDevIns, unsigned iReg, uint8_t *pu8Value));
3158
3159 /**
3160 * Assert that the current thread is the emulation thread.
3161 *
3162 * @returns True if correct.
3163 * @returns False if wrong.
3164 * @param pDevIns The device instance.
3165 * @param pszFile Filename of the assertion location.
3166 * @param iLine The linenumber of the assertion location.
3167 * @param pszFunction Function of the assertion location.
3168 */
3169 DECLR3CALLBACKMEMBER(bool, pfnAssertEMT,(PPDMDEVINS pDevIns, const char *pszFile, unsigned iLine, const char *pszFunction));
3170
3171 /**
3172 * Assert that the current thread is NOT the emulation thread.
3173 *
3174 * @returns True if correct.
3175 * @returns False if wrong.
3176 * @param pDevIns The device instance.
3177 * @param pszFile Filename of the assertion location.
3178 * @param iLine The linenumber of the assertion location.
3179 * @param pszFunction Function of the assertion location.
3180 */
3181 DECLR3CALLBACKMEMBER(bool, pfnAssertOther,(PPDMDEVINS pDevIns, const char *pszFile, unsigned iLine, const char *pszFunction));
3182
3183 /**
3184 * Resolves the symbol for a raw-mode context interface.
3185 *
3186 * @returns VBox status code.
3187 * @param pDevIns The device instance.
3188 * @param pvInterface The interface structure.
3189 * @param cbInterface The size of the interface structure.
3190 * @param pszSymPrefix What to prefix the symbols in the list with
3191 * before resolving them. This must start with
3192 * 'dev' and contain the driver name.
3193 * @param pszSymList List of symbols corresponding to the interface.
3194 * There is generally a there is generally a define
3195 * holding this list associated with the interface
3196 * definition (INTERFACE_SYM_LIST). For more
3197 * details see PDMR3LdrGetInterfaceSymbols.
3198 * @thread EMT
3199 */
3200 DECLR3CALLBACKMEMBER(int, pfnLdrGetRCInterfaceSymbols,(PPDMDEVINS pDevIns, void *pvInterface, size_t cbInterface,
3201 const char *pszSymPrefix, const char *pszSymList));
3202
3203 /**
3204 * Resolves the symbol for a ring-0 context interface.
3205 *
3206 * @returns VBox status code.
3207 * @param pDevIns The device instance.
3208 * @param pvInterface The interface structure.
3209 * @param cbInterface The size of the interface structure.
3210 * @param pszSymPrefix What to prefix the symbols in the list with
3211 * before resolving them. This must start with
3212 * 'dev' and contain the driver name.
3213 * @param pszSymList List of symbols corresponding to the interface.
3214 * There is generally a there is generally a define
3215 * holding this list associated with the interface
3216 * definition (INTERFACE_SYM_LIST). For more
3217 * details see PDMR3LdrGetInterfaceSymbols.
3218 * @thread EMT
3219 */
3220 DECLR3CALLBACKMEMBER(int, pfnLdrGetR0InterfaceSymbols,(PPDMDEVINS pDevIns, void *pvInterface, size_t cbInterface,
3221 const char *pszSymPrefix, const char *pszSymList));
3222
3223 /**
3224 * Call the ring-0 request handler routine of the device.
3225 *
3226 * For this to work, the device must be ring-0 enabled and export a request
3227 * handler function. The name of the function must be the device name in
3228 * the PDMDRVREG struct prefixed with 'drvR0' and suffixed with
3229 * 'ReqHandler'. The device name will be captialized. It shall take the
3230 * exact same arguments as this function and be declared using
3231 * PDMBOTHCBDECL. See FNPDMDEVREQHANDLERR0.
3232 *
3233 * Unlike PDMDrvHlpCallR0, this is current unsuitable for more than a call
3234 * or two as the handler address will be resolved on each invocation. This
3235 * is the reason for the EMT only restriction as well.
3236 *
3237 * @returns VBox status code.
3238 * @retval VERR_SYMBOL_NOT_FOUND if the device doesn't export the required
3239 * handler function.
3240 * @retval VERR_ACCESS_DENIED if the device isn't ring-0 capable.
3241 *
3242 * @param pDevIns The device instance.
3243 * @param uOperation The operation to perform.
3244 * @param u64Arg 64-bit integer argument.
3245 * @thread EMT
3246 */
3247 DECLR3CALLBACKMEMBER(int, pfnCallR0,(PPDMDEVINS pDevIns, uint32_t uOperation, uint64_t u64Arg));
3248
3249 /**
3250 * Gets the reason for the most recent VM suspend.
3251 *
3252 * @returns The suspend reason. VMSUSPENDREASON_INVALID is returned if no
3253 * suspend has been made or if the pDevIns is invalid.
3254 * @param pDevIns The device instance.
3255 */
3256 DECLR3CALLBACKMEMBER(VMSUSPENDREASON, pfnVMGetSuspendReason,(PPDMDEVINS pDevIns));
3257
3258 /**
3259 * Gets the reason for the most recent VM resume.
3260 *
3261 * @returns The resume reason. VMRESUMEREASON_INVALID is returned if no
3262 * resume has been made or if the pDevIns is invalid.
3263 * @param pDevIns The device instance.
3264 */
3265 DECLR3CALLBACKMEMBER(VMRESUMEREASON, pfnVMGetResumeReason,(PPDMDEVINS pDevIns));
3266
3267 /** Space reserved for future members.
3268 * @{ */
3269 DECLR3CALLBACKMEMBER(void, pfnReserved1,(void));
3270 DECLR3CALLBACKMEMBER(void, pfnReserved2,(void));
3271 DECLR3CALLBACKMEMBER(void, pfnReserved3,(void));
3272 DECLR3CALLBACKMEMBER(void, pfnReserved4,(void));
3273 DECLR3CALLBACKMEMBER(void, pfnReserved5,(void));
3274 DECLR3CALLBACKMEMBER(void, pfnReserved6,(void));
3275 DECLR3CALLBACKMEMBER(void, pfnReserved7,(void));
3276 DECLR3CALLBACKMEMBER(void, pfnReserved8,(void));
3277 DECLR3CALLBACKMEMBER(void, pfnReserved9,(void));
3278 DECLR3CALLBACKMEMBER(void, pfnReserved10,(void));
3279 /** @} */
3280
3281
3282 /** API available to trusted devices only.
3283 *
3284 * These APIs are providing unrestricted access to the guest and the VM,
3285 * or they are interacting intimately with PDM.
3286 *
3287 * @{
3288 */
3289
3290 /**
3291 * Gets the user mode VM handle. Restricted API.
3292 *
3293 * @returns User mode VM Handle.
3294 * @param pDevIns The device instance.
3295 */
3296 DECLR3CALLBACKMEMBER(PUVM, pfnGetUVM,(PPDMDEVINS pDevIns));
3297
3298 /**
3299 * Gets the global VM handle. Restricted API.
3300 *
3301 * @returns VM Handle.
3302 * @param pDevIns The device instance.
3303 */
3304 DECLR3CALLBACKMEMBER(PVM, pfnGetVM,(PPDMDEVINS pDevIns));
3305
3306 /**
3307 * Gets the VMCPU handle. Restricted API.
3308 *
3309 * @returns VMCPU Handle.
3310 * @param pDevIns The device instance.
3311 */
3312 DECLR3CALLBACKMEMBER(PVMCPU, pfnGetVMCPU,(PPDMDEVINS pDevIns));
3313
3314 /**
3315 * The the VM CPU ID of the current thread (restricted API).
3316 *
3317 * @returns The VMCPUID of the calling thread, NIL_CPUID if not EMT.
3318 * @param pDevIns The device instance.
3319 */
3320 DECLR3CALLBACKMEMBER(VMCPUID, pfnGetCurrentCpuId,(PPDMDEVINS pDevIns));
3321
3322 /**
3323 * Registers the VMM device heap or notifies about mapping/unmapping.
3324 *
3325 * This interface serves three purposes:
3326 *
3327 * -# Register the VMM device heap during device construction
3328 * for the HM to use.
3329 * -# Notify PDM/HM that it's mapped into guest address
3330 * space (i.e. usable).
3331 * -# Notify PDM/HM that it is being unmapped from the guest
3332 * address space (i.e. not usable).
3333 *
3334 * @returns VBox status code.
3335 * @param pDevIns The device instance.
3336 * @param GCPhys The physical address if mapped, NIL_RTGCPHYS if
3337 * not mapped.
3338 * @param pvHeap Ring 3 heap pointer.
3339 * @param cbHeap Size of the heap.
3340 * @thread EMT.
3341 */
3342 DECLR3CALLBACKMEMBER(int, pfnRegisterVMMDevHeap,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTR3PTR pvHeap, unsigned cbHeap));
3343
3344 /**
3345 * Registers the firmware (BIOS, EFI) device with PDM.
3346 *
3347 * The firmware provides a callback table and gets a special PDM helper table.
3348 * There can only be one firmware device for a VM.
3349 *
3350 * @returns VBox status code.
3351 * @param pDevIns The device instance.
3352 * @param pFwReg Firmware registration structure.
3353 * @param ppFwHlp Where to return the firmware helper structure.
3354 * @remarks Only valid during device construction.
3355 * @thread EMT(0)
3356 */
3357 DECLR3CALLBACKMEMBER(int, pfnFirmwareRegister,(PPDMDEVINS pDevIns, PCPDMFWREG pFwReg, PCPDMFWHLPR3 *ppFwHlp));
3358
3359 /**
3360 * Resets the VM.
3361 *
3362 * @returns The appropriate VBox status code to pass around on reset.
3363 * @param pDevIns The device instance.
3364 * @param fFlags PDMVMRESET_F_XXX flags.
3365 * @thread The emulation thread.
3366 */
3367 DECLR3CALLBACKMEMBER(int, pfnVMReset,(PPDMDEVINS pDevIns, uint32_t fFlags));
3368
3369 /**
3370 * Suspends the VM.
3371 *
3372 * @returns The appropriate VBox status code to pass around on suspend.
3373 * @param pDevIns The device instance.
3374 * @thread The emulation thread.
3375 */
3376 DECLR3CALLBACKMEMBER(int, pfnVMSuspend,(PPDMDEVINS pDevIns));
3377
3378 /**
3379 * Suspends, saves and powers off the VM.
3380 *
3381 * @returns The appropriate VBox status code to pass around.
3382 * @param pDevIns The device instance.
3383 * @thread An emulation thread.
3384 */
3385 DECLR3CALLBACKMEMBER(int, pfnVMSuspendSaveAndPowerOff,(PPDMDEVINS pDevIns));
3386
3387 /**
3388 * Power off the VM.
3389 *
3390 * @returns The appropriate VBox status code to pass around on power off.
3391 * @param pDevIns The device instance.
3392 * @thread The emulation thread.
3393 */
3394 DECLR3CALLBACKMEMBER(int, pfnVMPowerOff,(PPDMDEVINS pDevIns));
3395
3396 /**
3397 * Checks if the Gate A20 is enabled or not.
3398 *
3399 * @returns true if A20 is enabled.
3400 * @returns false if A20 is disabled.
3401 * @param pDevIns The device instance.
3402 * @thread The emulation thread.
3403 */
3404 DECLR3CALLBACKMEMBER(bool, pfnA20IsEnabled,(PPDMDEVINS pDevIns));
3405
3406 /**
3407 * Enables or disables the Gate A20.
3408 *
3409 * @param pDevIns The device instance.
3410 * @param fEnable Set this flag to enable the Gate A20; clear it
3411 * to disable.
3412 * @thread The emulation thread.
3413 */
3414 DECLR3CALLBACKMEMBER(void, pfnA20Set,(PPDMDEVINS pDevIns, bool fEnable));
3415
3416 /**
3417 * Get the specified CPUID leaf for the virtual CPU associated with the calling
3418 * thread.
3419 *
3420 * @param pDevIns The device instance.
3421 * @param iLeaf The CPUID leaf to get.
3422 * @param pEax Where to store the EAX value.
3423 * @param pEbx Where to store the EBX value.
3424 * @param pEcx Where to store the ECX value.
3425 * @param pEdx Where to store the EDX value.
3426 * @thread EMT.
3427 */
3428 DECLR3CALLBACKMEMBER(void, pfnGetCpuId,(PPDMDEVINS pDevIns, uint32_t iLeaf, uint32_t *pEax, uint32_t *pEbx, uint32_t *pEcx, uint32_t *pEdx));
3429
3430 /**
3431 * Get the current virtual clock time in a VM. The clock frequency must be
3432 * queried separately.
3433 *
3434 * @returns Current clock time.
3435 * @param pDevIns The device instance.
3436 */
3437 DECLR3CALLBACKMEMBER(uint64_t, pfnTMTimeVirtGet,(PPDMDEVINS pDevIns));
3438
3439 /**
3440 * Get the frequency of the virtual clock.
3441 *
3442 * @returns The clock frequency (not variable at run-time).
3443 * @param pDevIns The device instance.
3444 */
3445 DECLR3CALLBACKMEMBER(uint64_t, pfnTMTimeVirtGetFreq,(PPDMDEVINS pDevIns));
3446
3447 /**
3448 * Get the current virtual clock time in a VM, in nanoseconds.
3449 *
3450 * @returns Current clock time (in ns).
3451 * @param pDevIns The device instance.
3452 */
3453 DECLR3CALLBACKMEMBER(uint64_t, pfnTMTimeVirtGetNano,(PPDMDEVINS pDevIns));
3454
3455 /**
3456 * Gets the support driver session.
3457 *
3458 * This is intended for working with the semaphore API.
3459 *
3460 * @returns Support driver session handle.
3461 * @param pDevIns The device instance.
3462 */
3463 DECLR3CALLBACKMEMBER(PSUPDRVSESSION, pfnGetSupDrvSession,(PPDMDEVINS pDevIns));
3464
3465 /** @} */
3466
3467 /** Just a safety precaution. (PDM_DEVHLPR3_VERSION) */
3468 uint32_t u32TheEnd;
3469} PDMDEVHLPR3;
3470#endif /* !IN_RING3 */
3471/** Pointer to the R3 PDM Device API. */
3472typedef R3PTRTYPE(struct PDMDEVHLPR3 *) PPDMDEVHLPR3;
3473/** Pointer to the R3 PDM Device API, const variant. */
3474typedef R3PTRTYPE(const struct PDMDEVHLPR3 *) PCPDMDEVHLPR3;
3475
3476
3477/**
3478 * PDM Device API - RC Variant.
3479 */
3480typedef struct PDMDEVHLPRC
3481{
3482 /** Structure version. PDM_DEVHLPRC_VERSION defines the current version. */
3483 uint32_t u32Version;
3484
3485 /**
3486 * Bus master physical memory read from the given PCI device.
3487 *
3488 * @returns VINF_SUCCESS or VERR_PGM_PCI_PHYS_READ_BM_DISABLED, later maybe
3489 * VERR_EM_MEMORY. The informational status shall NOT be propagated!
3490 * @param pDevIns The device instance.
3491 * @param pPciDev The PCI device structure. If NULL the default
3492 * PCI device for this device instance is used.
3493 * @param GCPhys Physical address start reading from.
3494 * @param pvBuf Where to put the read bits.
3495 * @param cbRead How many bytes to read.
3496 * @thread Any thread, but the call may involve the emulation thread.
3497 */
3498 DECLRCCALLBACKMEMBER(int, pfnPCIPhysRead,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, RTGCPHYS GCPhys,
3499 void *pvBuf, size_t cbRead));
3500
3501 /**
3502 * Bus master physical memory write from the given PCI device.
3503 *
3504 * @returns VINF_SUCCESS or VERR_PGM_PCI_PHYS_WRITE_BM_DISABLED, later maybe
3505 * VERR_EM_MEMORY. The informational status shall NOT be propagated!
3506 * @param pDevIns The device instance.
3507 * @param pPciDev The PCI device structure. If NULL the default
3508 * PCI device for this device instance is used.
3509 * @param GCPhys Physical address to write to.
3510 * @param pvBuf What to write.
3511 * @param cbWrite How many bytes to write.
3512 * @thread Any thread, but the call may involve the emulation thread.
3513 */
3514 DECLRCCALLBACKMEMBER(int, pfnPCIPhysWrite,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, RTGCPHYS GCPhys,
3515 const void *pvBuf, size_t cbWrite));
3516
3517 /**
3518 * Set the IRQ for the given PCI device.
3519 *
3520 * @param pDevIns Device instance.
3521 * @param pPciDev The PCI device structure. If NULL the default
3522 * PCI device for this device instance is used.
3523 * @param iIrq IRQ number to set.
3524 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
3525 * @thread Any thread, but will involve the emulation thread.
3526 */
3527 DECLRCCALLBACKMEMBER(void, pfnPCISetIrq,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iIrq, int iLevel));
3528
3529 /**
3530 * Set ISA IRQ for a device.
3531 *
3532 * @param pDevIns Device instance.
3533 * @param iIrq IRQ number to set.
3534 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
3535 * @thread Any thread, but will involve the emulation thread.
3536 */
3537 DECLRCCALLBACKMEMBER(void, pfnISASetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
3538
3539 /**
3540 * Read physical memory.
3541 *
3542 * @returns VINF_SUCCESS (for now).
3543 * @param pDevIns Device instance.
3544 * @param GCPhys Physical address start reading from.
3545 * @param pvBuf Where to put the read bits.
3546 * @param cbRead How many bytes to read.
3547 */
3548 DECLRCCALLBACKMEMBER(int, pfnPhysRead,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead));
3549
3550 /**
3551 * Write to physical memory.
3552 *
3553 * @returns VINF_SUCCESS for now, and later maybe VERR_EM_MEMORY.
3554 * @param pDevIns Device instance.
3555 * @param GCPhys Physical address to write to.
3556 * @param pvBuf What to write.
3557 * @param cbWrite How many bytes to write.
3558 */
3559 DECLRCCALLBACKMEMBER(int, pfnPhysWrite,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite));
3560
3561 /**
3562 * Checks if the Gate A20 is enabled or not.
3563 *
3564 * @returns true if A20 is enabled.
3565 * @returns false if A20 is disabled.
3566 * @param pDevIns Device instance.
3567 * @thread The emulation thread.
3568 */
3569 DECLRCCALLBACKMEMBER(bool, pfnA20IsEnabled,(PPDMDEVINS pDevIns));
3570
3571 /**
3572 * Gets the VM state.
3573 *
3574 * @returns VM state.
3575 * @param pDevIns The device instance.
3576 * @thread Any thread (just keep in mind that it's volatile info).
3577 */
3578 DECLRCCALLBACKMEMBER(VMSTATE, pfnVMState, (PPDMDEVINS pDevIns));
3579
3580 /**
3581 * Set the VM error message
3582 *
3583 * @returns rc.
3584 * @param pDevIns Driver instance.
3585 * @param rc VBox status code.
3586 * @param SRC_POS Use RT_SRC_POS.
3587 * @param pszFormat Error message format string.
3588 * @param ... Error message arguments.
3589 */
3590 DECLRCCALLBACKMEMBER(int, pfnVMSetError,(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL,
3591 const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(6, 7));
3592
3593 /**
3594 * Set the VM error message
3595 *
3596 * @returns rc.
3597 * @param pDevIns Driver instance.
3598 * @param rc VBox status code.
3599 * @param SRC_POS Use RT_SRC_POS.
3600 * @param pszFormat Error message format string.
3601 * @param va Error message arguments.
3602 */
3603 DECLRCCALLBACKMEMBER(int, pfnVMSetErrorV,(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL,
3604 const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(6, 0));
3605
3606 /**
3607 * Set the VM runtime error message
3608 *
3609 * @returns VBox status code.
3610 * @param pDevIns Device instance.
3611 * @param fFlags The action flags. See VMSETRTERR_FLAGS_*.
3612 * @param pszErrorId Error ID string.
3613 * @param pszFormat Error message format string.
3614 * @param ... Error message arguments.
3615 */
3616 DECLRCCALLBACKMEMBER(int, pfnVMSetRuntimeError,(PPDMDEVINS pDevIns, uint32_t fFlags, const char *pszErrorId,
3617 const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(4, 5));
3618
3619 /**
3620 * Set the VM runtime error message
3621 *
3622 * @returns VBox status code.
3623 * @param pDevIns Device instance.
3624 * @param fFlags The action flags. See VMSETRTERR_FLAGS_*.
3625 * @param pszErrorId Error ID string.
3626 * @param pszFormat Error message format string.
3627 * @param va Error message arguments.
3628 */
3629 DECLRCCALLBACKMEMBER(int, pfnVMSetRuntimeErrorV,(PPDMDEVINS pDevIns, uint32_t fFlags, const char *pszErrorId,
3630 const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(4, 0));
3631
3632 /**
3633 * Set parameters for pending MMIO patch operation
3634 *
3635 * @returns VBox status code.
3636 * @param pDevIns Device instance.
3637 * @param GCPhys MMIO physical address
3638 * @param pCachedData GC pointer to cached data
3639 */
3640 DECLRCCALLBACKMEMBER(int, pfnPATMSetMMIOPatchInfo,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTGCPTR pCachedData));
3641
3642 /**
3643 * Gets the VM handle. Restricted API.
3644 *
3645 * @returns VM Handle.
3646 * @param pDevIns Device instance.
3647 */
3648 DECLRCCALLBACKMEMBER(PVM, pfnGetVM,(PPDMDEVINS pDevIns));
3649
3650 /**
3651 * Gets the VMCPU handle. Restricted API.
3652 *
3653 * @returns VMCPU Handle.
3654 * @param pDevIns The device instance.
3655 */
3656 DECLRCCALLBACKMEMBER(PVMCPU, pfnGetVMCPU,(PPDMDEVINS pDevIns));
3657
3658 /**
3659 * The the VM CPU ID of the current thread (restricted API).
3660 *
3661 * @returns The VMCPUID of the calling thread, NIL_CPUID if not EMT.
3662 * @param pDevIns The device instance.
3663 */
3664 DECLRCCALLBACKMEMBER(VMCPUID, pfnGetCurrentCpuId,(PPDMDEVINS pDevIns));
3665
3666 /**
3667 * Get the current virtual clock time in a VM. The clock frequency must be
3668 * queried separately.
3669 *
3670 * @returns Current clock time.
3671 * @param pDevIns The device instance.
3672 */
3673 DECLRCCALLBACKMEMBER(uint64_t, pfnTMTimeVirtGet,(PPDMDEVINS pDevIns));
3674
3675 /**
3676 * Get the frequency of the virtual clock.
3677 *
3678 * @returns The clock frequency (not variable at run-time).
3679 * @param pDevIns The device instance.
3680 */
3681 DECLRCCALLBACKMEMBER(uint64_t, pfnTMTimeVirtGetFreq,(PPDMDEVINS pDevIns));
3682
3683 /**
3684 * Get the current virtual clock time in a VM, in nanoseconds.
3685 *
3686 * @returns Current clock time (in ns).
3687 * @param pDevIns The device instance.
3688 */
3689 DECLRCCALLBACKMEMBER(uint64_t, pfnTMTimeVirtGetNano,(PPDMDEVINS pDevIns));
3690
3691 /**
3692 * Gets the trace buffer handle.
3693 *
3694 * This is used by the macros found in VBox/vmm/dbgftrace.h and is not
3695 * really inteded for direct usage, thus no inline wrapper function.
3696 *
3697 * @returns Trace buffer handle or NIL_RTTRACEBUF.
3698 * @param pDevIns The device instance.
3699 */
3700 DECLRCCALLBACKMEMBER(RTTRACEBUF, pfnDBGFTraceBuf,(PPDMDEVINS pDevIns));
3701
3702 /** Space reserved for future members.
3703 * @{ */
3704 DECLRCCALLBACKMEMBER(void, pfnReserved1,(void));
3705 DECLRCCALLBACKMEMBER(void, pfnReserved2,(void));
3706 DECLRCCALLBACKMEMBER(void, pfnReserved3,(void));
3707 DECLRCCALLBACKMEMBER(void, pfnReserved4,(void));
3708 DECLRCCALLBACKMEMBER(void, pfnReserved5,(void));
3709 DECLRCCALLBACKMEMBER(void, pfnReserved6,(void));
3710 DECLRCCALLBACKMEMBER(void, pfnReserved7,(void));
3711 DECLRCCALLBACKMEMBER(void, pfnReserved8,(void));
3712 DECLRCCALLBACKMEMBER(void, pfnReserved9,(void));
3713 DECLRCCALLBACKMEMBER(void, pfnReserved10,(void));
3714 /** @} */
3715
3716 /** Just a safety precaution. */
3717 uint32_t u32TheEnd;
3718} PDMDEVHLPRC;
3719/** Pointer PDM Device RC API. */
3720typedef RCPTRTYPE(struct PDMDEVHLPRC *) PPDMDEVHLPRC;
3721/** Pointer PDM Device RC API. */
3722typedef RCPTRTYPE(const struct PDMDEVHLPRC *) PCPDMDEVHLPRC;
3723
3724/** Current PDMDEVHLP version number. */
3725#define PDM_DEVHLPRC_VERSION PDM_VERSION_MAKE(0xffe6, 5, 0)
3726
3727
3728/**
3729 * PDM Device API - R0 Variant.
3730 */
3731typedef struct PDMDEVHLPR0
3732{
3733 /** Structure version. PDM_DEVHLPR0_VERSION defines the current version. */
3734 uint32_t u32Version;
3735
3736 /**
3737 * Bus master physical memory read from the given PCI device.
3738 *
3739 * @returns VINF_SUCCESS or VERR_PDM_NOT_PCI_BUS_MASTER, later maybe
3740 * VERR_EM_MEMORY.
3741 * @param pDevIns The device instance.
3742 * @param pPciDev The PCI device structure. If NULL the default
3743 * PCI device for this device instance is used.
3744 * @param GCPhys Physical address start reading from.
3745 * @param pvBuf Where to put the read bits.
3746 * @param cbRead How many bytes to read.
3747 * @thread Any thread, but the call may involve the emulation thread.
3748 */
3749 DECLR0CALLBACKMEMBER(int, pfnPCIPhysRead,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, RTGCPHYS GCPhys,
3750 void *pvBuf, size_t cbRead));
3751
3752 /**
3753 * Bus master physical memory write from the given PCI device.
3754 *
3755 * @returns VINF_SUCCESS or VERR_PDM_NOT_PCI_BUS_MASTER, later maybe
3756 * VERR_EM_MEMORY.
3757 * @param pDevIns The device instance.
3758 * @param pPciDev The PCI device structure. If NULL the default
3759 * PCI device for this device instance is used.
3760 * @param GCPhys Physical address to write to.
3761 * @param pvBuf What to write.
3762 * @param cbWrite How many bytes to write.
3763 * @thread Any thread, but the call may involve the emulation thread.
3764 */
3765 DECLR0CALLBACKMEMBER(int, pfnPCIPhysWrite,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, RTGCPHYS GCPhys,
3766 const void *pvBuf, size_t cbWrite));
3767
3768 /**
3769 * Set the IRQ for the given PCI device.
3770 *
3771 * @param pDevIns Device instance.
3772 * @param pPciDev The PCI device structure. If NULL the default
3773 * PCI device for this device instance is used.
3774 * @param iIrq IRQ number to set.
3775 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
3776 * @thread Any thread, but will involve the emulation thread.
3777 */
3778 DECLR0CALLBACKMEMBER(void, pfnPCISetIrq,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iIrq, int iLevel));
3779
3780 /**
3781 * Set ISA IRQ for a device.
3782 *
3783 * @param pDevIns Device instance.
3784 * @param iIrq IRQ number to set.
3785 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
3786 * @thread Any thread, but will involve the emulation thread.
3787 */
3788 DECLR0CALLBACKMEMBER(void, pfnISASetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
3789
3790 /**
3791 * Read physical memory.
3792 *
3793 * @returns VINF_SUCCESS (for now).
3794 * @param pDevIns Device instance.
3795 * @param GCPhys Physical address start reading from.
3796 * @param pvBuf Where to put the read bits.
3797 * @param cbRead How many bytes to read.
3798 */
3799 DECLR0CALLBACKMEMBER(int, pfnPhysRead,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead));
3800
3801 /**
3802 * Write to physical memory.
3803 *
3804 * @returns VINF_SUCCESS for now, and later maybe VERR_EM_MEMORY.
3805 * @param pDevIns Device instance.
3806 * @param GCPhys Physical address to write to.
3807 * @param pvBuf What to write.
3808 * @param cbWrite How many bytes to write.
3809 */
3810 DECLR0CALLBACKMEMBER(int, pfnPhysWrite,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite));
3811
3812 /**
3813 * Checks if the Gate A20 is enabled or not.
3814 *
3815 * @returns true if A20 is enabled.
3816 * @returns false if A20 is disabled.
3817 * @param pDevIns Device instance.
3818 * @thread The emulation thread.
3819 */
3820 DECLR0CALLBACKMEMBER(bool, pfnA20IsEnabled,(PPDMDEVINS pDevIns));
3821
3822 /**
3823 * Gets the VM state.
3824 *
3825 * @returns VM state.
3826 * @param pDevIns The device instance.
3827 * @thread Any thread (just keep in mind that it's volatile info).
3828 */
3829 DECLR0CALLBACKMEMBER(VMSTATE, pfnVMState, (PPDMDEVINS pDevIns));
3830
3831 /**
3832 * Set the VM error message
3833 *
3834 * @returns rc.
3835 * @param pDevIns Driver instance.
3836 * @param rc VBox status code.
3837 * @param SRC_POS Use RT_SRC_POS.
3838 * @param pszFormat Error message format string.
3839 * @param ... Error message arguments.
3840 */
3841 DECLR0CALLBACKMEMBER(int, pfnVMSetError,(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL,
3842 const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(6, 7));
3843
3844 /**
3845 * Set the VM error message
3846 *
3847 * @returns rc.
3848 * @param pDevIns Driver instance.
3849 * @param rc VBox status code.
3850 * @param SRC_POS Use RT_SRC_POS.
3851 * @param pszFormat Error message format string.
3852 * @param va Error message arguments.
3853 */
3854 DECLR0CALLBACKMEMBER(int, pfnVMSetErrorV,(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL,
3855 const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(6, 0));
3856
3857 /**
3858 * Set the VM runtime error message
3859 *
3860 * @returns VBox status code.
3861 * @param pDevIns Device instance.
3862 * @param fFlags The action flags. See VMSETRTERR_FLAGS_*.
3863 * @param pszErrorId Error ID string.
3864 * @param pszFormat Error message format string.
3865 * @param ... Error message arguments.
3866 */
3867 DECLR0CALLBACKMEMBER(int, pfnVMSetRuntimeError,(PPDMDEVINS pDevIns, uint32_t fFlags, const char *pszErrorId,
3868 const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(4, 5));
3869
3870 /**
3871 * Set the VM runtime error message
3872 *
3873 * @returns VBox status code.
3874 * @param pDevIns Device instance.
3875 * @param fFlags The action flags. See VMSETRTERR_FLAGS_*.
3876 * @param pszErrorId Error ID string.
3877 * @param pszFormat Error message format string.
3878 * @param va Error message arguments.
3879 */
3880 DECLR0CALLBACKMEMBER(int, pfnVMSetRuntimeErrorV,(PPDMDEVINS pDevIns, uint32_t fFlags, const char *pszErrorId,
3881 const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(4, 0));
3882
3883 /**
3884 * Set parameters for pending MMIO patch operation
3885 *
3886 * @returns rc.
3887 * @param pDevIns Device instance.
3888 * @param GCPhys MMIO physical address
3889 * @param pCachedData GC pointer to cached data
3890 */
3891 DECLR0CALLBACKMEMBER(int, pfnPATMSetMMIOPatchInfo,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTGCPTR pCachedData));
3892
3893 /**
3894 * Gets the VM handle. Restricted API.
3895 *
3896 * @returns VM Handle.
3897 * @param pDevIns Device instance.
3898 */
3899 DECLR0CALLBACKMEMBER(PVM, pfnGetVM,(PPDMDEVINS pDevIns));
3900
3901 /**
3902 * Checks if our current CPU state allows for IO block emulation fallback to the recompiler
3903 *
3904 * @returns true = yes, false = no
3905 * @param pDevIns Device instance.
3906 */
3907 DECLR0CALLBACKMEMBER(bool, pfnCanEmulateIoBlock,(PPDMDEVINS pDevIns));
3908
3909 /**
3910 * Gets the VMCPU handle. Restricted API.
3911 *
3912 * @returns VMCPU Handle.
3913 * @param pDevIns The device instance.
3914 */
3915 DECLR0CALLBACKMEMBER(PVMCPU, pfnGetVMCPU,(PPDMDEVINS pDevIns));
3916
3917 /**
3918 * The the VM CPU ID of the current thread (restricted API).
3919 *
3920 * @returns The VMCPUID of the calling thread, NIL_CPUID if not EMT.
3921 * @param pDevIns The device instance.
3922 */
3923 DECLR0CALLBACKMEMBER(VMCPUID, pfnGetCurrentCpuId,(PPDMDEVINS pDevIns));
3924
3925 /**
3926 * Get the current virtual clock time in a VM. The clock frequency must be
3927 * queried separately.
3928 *
3929 * @returns Current clock time.
3930 * @param pDevIns The device instance.
3931 */
3932 DECLR0CALLBACKMEMBER(uint64_t, pfnTMTimeVirtGet,(PPDMDEVINS pDevIns));
3933
3934 /**
3935 * Get the frequency of the virtual clock.
3936 *
3937 * @returns The clock frequency (not variable at run-time).
3938 * @param pDevIns The device instance.
3939 */
3940 DECLR0CALLBACKMEMBER(uint64_t, pfnTMTimeVirtGetFreq,(PPDMDEVINS pDevIns));
3941
3942 /**
3943 * Get the current virtual clock time in a VM, in nanoseconds.
3944 *
3945 * @returns Current clock time (in ns).
3946 * @param pDevIns The device instance.
3947 */
3948 DECLR0CALLBACKMEMBER(uint64_t, pfnTMTimeVirtGetNano,(PPDMDEVINS pDevIns));
3949
3950 /**
3951 * Gets the trace buffer handle.
3952 *
3953 * This is used by the macros found in VBox/vmm/dbgftrace.h and is not
3954 * really inteded for direct usage, thus no inline wrapper function.
3955 *
3956 * @returns Trace buffer handle or NIL_RTTRACEBUF.
3957 * @param pDevIns The device instance.
3958 */
3959 DECLR0CALLBACKMEMBER(RTTRACEBUF, pfnDBGFTraceBuf,(PPDMDEVINS pDevIns));
3960
3961 /** Space reserved for future members.
3962 * @{ */
3963 DECLR0CALLBACKMEMBER(void, pfnReserved1,(void));
3964 DECLR0CALLBACKMEMBER(void, pfnReserved2,(void));
3965 DECLR0CALLBACKMEMBER(void, pfnReserved3,(void));
3966 DECLR0CALLBACKMEMBER(void, pfnReserved4,(void));
3967 DECLR0CALLBACKMEMBER(void, pfnReserved5,(void));
3968 DECLR0CALLBACKMEMBER(void, pfnReserved6,(void));
3969 DECLR0CALLBACKMEMBER(void, pfnReserved7,(void));
3970 DECLR0CALLBACKMEMBER(void, pfnReserved8,(void));
3971 DECLR0CALLBACKMEMBER(void, pfnReserved9,(void));
3972 DECLR0CALLBACKMEMBER(void, pfnReserved10,(void));
3973 /** @} */
3974
3975 /** Just a safety precaution. */
3976 uint32_t u32TheEnd;
3977} PDMDEVHLPR0;
3978/** Pointer PDM Device R0 API. */
3979typedef R0PTRTYPE(struct PDMDEVHLPR0 *) PPDMDEVHLPR0;
3980/** Pointer PDM Device GC API. */
3981typedef R0PTRTYPE(const struct PDMDEVHLPR0 *) PCPDMDEVHLPR0;
3982
3983/** Current PDMDEVHLP version number. */
3984#define PDM_DEVHLPR0_VERSION PDM_VERSION_MAKE(0xffe5, 5, 0)
3985
3986
3987
3988/**
3989 * PDM Device Instance.
3990 */
3991typedef struct PDMDEVINS
3992{
3993 /** Structure version. PDM_DEVINS_VERSION defines the current version. */
3994 uint32_t u32Version;
3995 /** Device instance number. */
3996 uint32_t iInstance;
3997
3998 /** Pointer the GC PDM Device API. */
3999 PCPDMDEVHLPRC pHlpRC;
4000 /** Pointer to device instance data. */
4001 RTRCPTR pvInstanceDataRC;
4002 /** The critical section for the device, see pCritSectXR3. */
4003 RCPTRTYPE(PPDMCRITSECT) pCritSectRoRC;
4004 /** Alignment padding. */
4005 RTRCPTR pAlignmentRC;
4006
4007 /** Pointer the R0 PDM Device API. */
4008 PCPDMDEVHLPR0 pHlpR0;
4009 /** Pointer to device instance data (R0). */
4010 RTR0PTR pvInstanceDataR0;
4011 /** The critical section for the device, see pCritSectXR3. */
4012 R0PTRTYPE(PPDMCRITSECT) pCritSectRoR0;
4013
4014 /** Pointer the HC PDM Device API. */
4015 PCPDMDEVHLPR3 pHlpR3;
4016 /** Pointer to device instance data. */
4017 RTR3PTR pvInstanceDataR3;
4018 /** The critical section for the device.
4019 *
4020 * TM and IOM will enter this critical section before calling into the device
4021 * code. PDM will when doing power on, power off, reset, suspend and resume
4022 * notifications. SSM will currently not, but this will be changed later on.
4023 *
4024 * The device gets a critical section automatically assigned to it before
4025 * the constructor is called. If the constructor wishes to use a different
4026 * critical section, it calls PDMDevHlpSetDeviceCritSect() to change it
4027 * very early on.
4028 */
4029 R3PTRTYPE(PPDMCRITSECT) pCritSectRoR3;
4030
4031 /** Pointer to device registration structure. */
4032 R3PTRTYPE(PCPDMDEVREG) pReg;
4033 /** Configuration handle. */
4034 R3PTRTYPE(PCFGMNODE) pCfg;
4035
4036 /** The base interface of the device.
4037 *
4038 * The device constructor initializes this if it has any
4039 * device level interfaces to export. To obtain this interface
4040 * call PDMR3QueryDevice(). */
4041 PDMIBASE IBase;
4042
4043 /** Tracing indicator. */
4044 uint32_t fTracing;
4045 /** The tracing ID of this device. */
4046 uint32_t idTracing;
4047#if HC_ARCH_BITS == 32
4048 /** Align the internal data more naturally. */
4049 uint32_t au32Padding[HC_ARCH_BITS == 32 ? 13 : 0];
4050#endif
4051
4052 /** Internal data. */
4053 union
4054 {
4055#ifdef PDMDEVINSINT_DECLARED
4056 PDMDEVINSINT s;
4057#endif
4058 uint8_t padding[HC_ARCH_BITS == 32 ? 72 : 112 + 0x28];
4059 } Internal;
4060
4061 /** Device instance data. The size of this area is defined
4062 * in the PDMDEVREG::cbInstanceData field. */
4063 char achInstanceData[8];
4064} PDMDEVINS;
4065
4066/** Current PDMDEVINS version number. */
4067#define PDM_DEVINS_VERSION PDM_VERSION_MAKE(0xffe4, 3, 0)
4068
4069/** Converts a pointer to the PDMDEVINS::IBase to a pointer to PDMDEVINS. */
4070#define PDMIBASE_2_PDMDEV(pInterface) ( (PPDMDEVINS)((char *)(pInterface) - RT_OFFSETOF(PDMDEVINS, IBase)) )
4071
4072/**
4073 * Checks the structure versions of the device instance and device helpers,
4074 * returning if they are incompatible.
4075 *
4076 * This is for use in the constructor.
4077 *
4078 * @param pDevIns The device instance pointer.
4079 */
4080#define PDMDEV_CHECK_VERSIONS_RETURN(pDevIns) \
4081 do \
4082 { \
4083 PPDMDEVINS pDevInsTypeCheck = (pDevIns); NOREF(pDevInsTypeCheck); \
4084 AssertLogRelMsgReturn(PDM_VERSION_ARE_COMPATIBLE((pDevIns)->u32Version, PDM_DEVINS_VERSION), \
4085 ("DevIns=%#x mine=%#x\n", (pDevIns)->u32Version, PDM_DEVINS_VERSION), \
4086 VERR_PDM_DEVINS_VERSION_MISMATCH); \
4087 AssertLogRelMsgReturn(PDM_VERSION_ARE_COMPATIBLE((pDevIns)->pHlpR3->u32Version, PDM_DEVHLPR3_VERSION), \
4088 ("DevHlp=%#x mine=%#x\n", (pDevIns)->pHlpR3->u32Version, PDM_DEVHLPR3_VERSION), \
4089 VERR_PDM_DEVHLPR3_VERSION_MISMATCH); \
4090 } while (0)
4091
4092/**
4093 * Quietly checks the structure versions of the device instance and device
4094 * helpers, returning if they are incompatible.
4095 *
4096 * This is for use in the destructor.
4097 *
4098 * @param pDevIns The device instance pointer.
4099 */
4100#define PDMDEV_CHECK_VERSIONS_RETURN_QUIET(pDevIns) \
4101 do \
4102 { \
4103 PPDMDEVINS pDevInsTypeCheck = (pDevIns); NOREF(pDevInsTypeCheck); \
4104 if (RT_LIKELY(PDM_VERSION_ARE_COMPATIBLE((pDevIns)->u32Version, PDM_DEVINS_VERSION) )) \
4105 { /* likely */ } else return VERR_PDM_DEVINS_VERSION_MISMATCH; \
4106 if (RT_LIKELY(PDM_VERSION_ARE_COMPATIBLE((pDevIns)->pHlpR3->u32Version, PDM_DEVHLPR3_VERSION) )) \
4107 { /* likely */ } else return VERR_PDM_DEVHLPR3_VERSION_MISMATCH; \
4108 } while (0)
4109
4110/**
4111 * Wrapper around CFGMR3ValidateConfig for the root config for use in the
4112 * constructor - returns on failure.
4113 *
4114 * This should be invoked after having initialized the instance data
4115 * sufficiently for the correct operation of the destructor. The destructor is
4116 * always called!
4117 *
4118 * @param pDevIns Pointer to the PDM device instance.
4119 * @param pszValidValues Patterns describing the valid value names. See
4120 * RTStrSimplePatternMultiMatch for details on the
4121 * pattern syntax.
4122 * @param pszValidNodes Patterns describing the valid node (key) names.
4123 * Pass empty string if no valid nodes.
4124 */
4125#define PDMDEV_VALIDATE_CONFIG_RETURN(pDevIns, pszValidValues, pszValidNodes) \
4126 do \
4127 { \
4128 int rcValCfg = CFGMR3ValidateConfig((pDevIns)->pCfg, "/", pszValidValues, pszValidNodes, \
4129 (pDevIns)->pReg->szName, (pDevIns)->iInstance); \
4130 if (RT_SUCCESS(rcValCfg)) \
4131 { /* likely */ } else return rcValCfg; \
4132 } while (0)
4133
4134/** @def PDMDEV_ASSERT_EMT
4135 * Assert that the current thread is the emulation thread.
4136 */
4137#ifdef VBOX_STRICT
4138# define PDMDEV_ASSERT_EMT(pDevIns) pDevIns->pHlpR3->pfnAssertEMT(pDevIns, __FILE__, __LINE__, __FUNCTION__)
4139#else
4140# define PDMDEV_ASSERT_EMT(pDevIns) do { } while (0)
4141#endif
4142
4143/** @def PDMDEV_ASSERT_OTHER
4144 * Assert that the current thread is NOT the emulation thread.
4145 */
4146#ifdef VBOX_STRICT
4147# define PDMDEV_ASSERT_OTHER(pDevIns) pDevIns->pHlpR3->pfnAssertOther(pDevIns, __FILE__, __LINE__, __FUNCTION__)
4148#else
4149# define PDMDEV_ASSERT_OTHER(pDevIns) do { } while (0)
4150#endif
4151
4152/** @def PDMDEV_ASSERT_VMLOCK_OWNER
4153 * Assert that the current thread is owner of the VM lock.
4154 */
4155#ifdef VBOX_STRICT
4156# define PDMDEV_ASSERT_VMLOCK_OWNER(pDevIns) pDevIns->pHlpR3->pfnAssertVMLock(pDevIns, __FILE__, __LINE__, __FUNCTION__)
4157#else
4158# define PDMDEV_ASSERT_VMLOCK_OWNER(pDevIns) do { } while (0)
4159#endif
4160
4161/** @def PDMDEV_SET_ERROR
4162 * Set the VM error. See PDMDevHlpVMSetError() for printf like message formatting.
4163 */
4164#define PDMDEV_SET_ERROR(pDevIns, rc, pszError) \
4165 PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS, "%s", pszError)
4166
4167/** @def PDMDEV_SET_RUNTIME_ERROR
4168 * Set the VM runtime error. See PDMDevHlpVMSetRuntimeError() for printf like message formatting.
4169 */
4170#define PDMDEV_SET_RUNTIME_ERROR(pDevIns, fFlags, pszErrorId, pszError) \
4171 PDMDevHlpVMSetRuntimeError(pDevIns, fFlags, pszErrorId, "%s", pszError)
4172
4173/** @def PDMDEVINS_2_RCPTR
4174 * Converts a PDM Device instance pointer a RC PDM Device instance pointer.
4175 */
4176#define PDMDEVINS_2_RCPTR(pDevIns) ( (RCPTRTYPE(PPDMDEVINS))((RTGCUINTPTR)(pDevIns)->pvInstanceDataRC - RT_OFFSETOF(PDMDEVINS, achInstanceData)) )
4177
4178/** @def PDMDEVINS_2_R3PTR
4179 * Converts a PDM Device instance pointer a R3 PDM Device instance pointer.
4180 */
4181#define PDMDEVINS_2_R3PTR(pDevIns) ( (R3PTRTYPE(PPDMDEVINS))((RTHCUINTPTR)(pDevIns)->pvInstanceDataR3 - RT_OFFSETOF(PDMDEVINS, achInstanceData)) )
4182
4183/** @def PDMDEVINS_2_R0PTR
4184 * Converts a PDM Device instance pointer a R0 PDM Device instance pointer.
4185 */
4186#define PDMDEVINS_2_R0PTR(pDevIns) ( (R0PTRTYPE(PPDMDEVINS))((RTR0UINTPTR)(pDevIns)->pvInstanceDataR0 - RT_OFFSETOF(PDMDEVINS, achInstanceData)) )
4187
4188
4189#ifdef IN_RING3
4190
4191/**
4192 * @copydoc PDMDEVHLPR3::pfnIOPortRegister
4193 */
4194DECLINLINE(int) PDMDevHlpIOPortRegister(PPDMDEVINS pDevIns, RTIOPORT Port, RTIOPORT cPorts, RTHCPTR pvUser,
4195 PFNIOMIOPORTOUT pfnOut, PFNIOMIOPORTIN pfnIn,
4196 PFNIOMIOPORTOUTSTRING pfnOutStr, PFNIOMIOPORTINSTRING pfnInStr, const char *pszDesc)
4197{
4198 return pDevIns->pHlpR3->pfnIOPortRegister(pDevIns, Port, cPorts, pvUser, pfnOut, pfnIn, pfnOutStr, pfnInStr, pszDesc);
4199}
4200
4201/**
4202 * @copydoc PDMDEVHLPR3::pfnIOPortRegisterRC
4203 */
4204DECLINLINE(int) PDMDevHlpIOPortRegisterRC(PPDMDEVINS pDevIns, RTIOPORT Port, RTIOPORT cPorts, RTRCPTR pvUser,
4205 const char *pszOut, const char *pszIn, const char *pszOutStr,
4206 const char *pszInStr, const char *pszDesc)
4207{
4208 return pDevIns->pHlpR3->pfnIOPortRegisterRC(pDevIns, Port, cPorts, pvUser, pszOut, pszIn, pszOutStr, pszInStr, pszDesc);
4209}
4210
4211/**
4212 * @copydoc PDMDEVHLPR3::pfnIOPortRegisterR0
4213 */
4214DECLINLINE(int) PDMDevHlpIOPortRegisterR0(PPDMDEVINS pDevIns, RTIOPORT Port, RTIOPORT cPorts, RTR0PTR pvUser,
4215 const char *pszOut, const char *pszIn, const char *pszOutStr,
4216 const char *pszInStr, const char *pszDesc)
4217{
4218 return pDevIns->pHlpR3->pfnIOPortRegisterR0(pDevIns, Port, cPorts, pvUser, pszOut, pszIn, pszOutStr, pszInStr, pszDesc);
4219}
4220
4221/**
4222 * @copydoc PDMDEVHLPR3::pfnIOPortDeregister
4223 */
4224DECLINLINE(int) PDMDevHlpIOPortDeregister(PPDMDEVINS pDevIns, RTIOPORT Port, RTIOPORT cPorts)
4225{
4226 return pDevIns->pHlpR3->pfnIOPortDeregister(pDevIns, Port, cPorts);
4227}
4228
4229/**
4230 * Register a Memory Mapped I/O (MMIO) region.
4231 *
4232 * These callbacks are of course for the ring-3 context (R3). Register HC
4233 * handlers before raw-mode context (RC) and ring-0 context (R0) handlers! There
4234 * must be a R3 handler for every RC and R0 handler!
4235 *
4236 * @returns VBox status.
4237 * @param pDevIns The device instance to register the MMIO with.
4238 * @param GCPhysStart First physical address in the range.
4239 * @param cbRange The size of the range (in bytes).
4240 * @param pvUser User argument.
4241 * @param fFlags Flags, IOMMMIO_FLAGS_XXX.
4242 * @param pfnWrite Pointer to function which is gonna handle Write operations.
4243 * @param pfnRead Pointer to function which is gonna handle Read operations.
4244 * @param pszDesc Pointer to description string. This must not be freed.
4245 */
4246DECLINLINE(int) PDMDevHlpMMIORegister(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTGCPHYS cbRange, RTHCPTR pvUser,
4247 uint32_t fFlags, PFNIOMMMIOWRITE pfnWrite, PFNIOMMMIOREAD pfnRead, const char *pszDesc)
4248{
4249 return pDevIns->pHlpR3->pfnMMIORegister(pDevIns, GCPhysStart, cbRange, pvUser, pfnWrite, pfnRead, NULL /*pfnFill*/,
4250 fFlags, pszDesc);
4251}
4252
4253/**
4254 * Register a Memory Mapped I/O (MMIO) region for RC.
4255 *
4256 * These callbacks are for the raw-mode context (RC). Register ring-3 context
4257 * (R3) handlers before guest context handlers! There must be a R3 handler for
4258 * every RC handler!
4259 *
4260 * @returns VBox status.
4261 * @param pDevIns The device instance to register the MMIO with.
4262 * @param GCPhysStart First physical address in the range.
4263 * @param cbRange The size of the range (in bytes).
4264 * @param pvUser User argument.
4265 * @param pszWrite Name of the RC function which is gonna handle Write operations.
4266 * @param pszRead Name of the RC function which is gonna handle Read operations.
4267 */
4268DECLINLINE(int) PDMDevHlpMMIORegisterRC(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTGCPHYS cbRange, RTRCPTR pvUser,
4269 const char *pszWrite, const char *pszRead)
4270{
4271 return pDevIns->pHlpR3->pfnMMIORegisterRC(pDevIns, GCPhysStart, cbRange, pvUser, pszWrite, pszRead, NULL /*pszFill*/);
4272}
4273
4274/**
4275 * Register a Memory Mapped I/O (MMIO) region for R0.
4276 *
4277 * These callbacks are for the ring-0 host context (R0). Register ring-3
4278 * constext (R3) handlers before R0 handlers! There must be a R3 handler for
4279 * every R0 handler!
4280 *
4281 * @returns VBox status.
4282 * @param pDevIns The device instance to register the MMIO with.
4283 * @param GCPhysStart First physical address in the range.
4284 * @param cbRange The size of the range (in bytes).
4285 * @param pvUser User argument. (if pointer, then it must be in locked memory!)
4286 * @param pszWrite Name of the RC function which is gonna handle Write operations.
4287 * @param pszRead Name of the RC function which is gonna handle Read operations.
4288 * @remarks Caller enters the device critical section prior to invoking the
4289 * registered callback methods.
4290 */
4291DECLINLINE(int) PDMDevHlpMMIORegisterR0(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTGCPHYS cbRange, RTR0PTR pvUser,
4292 const char *pszWrite, const char *pszRead)
4293{
4294 return pDevIns->pHlpR3->pfnMMIORegisterR0(pDevIns, GCPhysStart, cbRange, pvUser, pszWrite, pszRead, NULL /*pszFill*/);
4295}
4296
4297/**
4298 * @copydoc PDMDEVHLPR3::pfnMMIORegister
4299 */
4300DECLINLINE(int) PDMDevHlpMMIORegisterEx(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTGCPHYS cbRange, RTHCPTR pvUser,
4301 uint32_t fFlags, PFNIOMMMIOWRITE pfnWrite, PFNIOMMMIOREAD pfnRead,
4302 PFNIOMMMIOFILL pfnFill, const char *pszDesc)
4303{
4304 return pDevIns->pHlpR3->pfnMMIORegister(pDevIns, GCPhysStart, cbRange, pvUser, pfnWrite, pfnRead, pfnFill,
4305 fFlags, pszDesc);
4306}
4307
4308/**
4309 * @copydoc PDMDEVHLPR3::pfnMMIORegisterRC
4310 */
4311DECLINLINE(int) PDMDevHlpMMIORegisterRCEx(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTGCPHYS cbRange, RTRCPTR pvUser,
4312 const char *pszWrite, const char *pszRead, const char *pszFill)
4313{
4314 return pDevIns->pHlpR3->pfnMMIORegisterRC(pDevIns, GCPhysStart, cbRange, pvUser, pszWrite, pszRead, pszFill);
4315}
4316
4317/**
4318 * @copydoc PDMDEVHLPR3::pfnMMIORegisterR0
4319 */
4320DECLINLINE(int) PDMDevHlpMMIORegisterR0Ex(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTGCPHYS cbRange, RTR0PTR pvUser,
4321 const char *pszWrite, const char *pszRead, const char *pszFill)
4322{
4323 return pDevIns->pHlpR3->pfnMMIORegisterR0(pDevIns, GCPhysStart, cbRange, pvUser, pszWrite, pszRead, pszFill);
4324}
4325
4326/**
4327 * @copydoc PDMDEVHLPR3::pfnMMIODeregister
4328 */
4329DECLINLINE(int) PDMDevHlpMMIODeregister(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTGCPHYS cbRange)
4330{
4331 return pDevIns->pHlpR3->pfnMMIODeregister(pDevIns, GCPhysStart, cbRange);
4332}
4333
4334/**
4335 * @copydoc PDMDEVHLPR3::pfnMMIO2Register
4336 */
4337DECLINLINE(int) PDMDevHlpMMIO2Register(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion, RTGCPHYS cb,
4338 uint32_t fFlags, void **ppv, const char *pszDesc)
4339{
4340 return pDevIns->pHlpR3->pfnMMIO2Register(pDevIns, pPciDev, iRegion, cb, fFlags, ppv, pszDesc);
4341}
4342
4343/**
4344 * @copydoc PDMDEVHLPR3::pfnMMIOExPreRegister
4345 */
4346DECLINLINE(int) PDMDevHlpMMIOExPreRegister(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion, RTGCPHYS cbRegion,
4347 uint32_t fFlags, const char *pszDesc, RTHCPTR pvUser,
4348 PFNIOMMMIOWRITE pfnWrite, PFNIOMMMIOREAD pfnRead, PFNIOMMMIOFILL pfnFill,
4349 RTR0PTR pvUserR0, const char *pszWriteR0, const char *pszReadR0, const char *pszFillR0,
4350 RTRCPTR pvUserRC, const char *pszWriteRC, const char *pszReadRC, const char *pszFillRC)
4351{
4352 return pDevIns->pHlpR3->pfnMMIOExPreRegister(pDevIns, pPciDev, iRegion, cbRegion, fFlags, pszDesc,
4353 pvUser, pfnWrite, pfnRead, pfnFill,
4354 pvUserR0, pszWriteR0, pszReadR0, pszFillR0,
4355 pvUserRC, pszWriteRC, pszReadRC, pszFillRC);
4356}
4357
4358/**
4359 * @copydoc PDMDEVHLPR3::pfnMMIOExDeregister
4360 * @param pPciDev The PCI device the region is associated with, use
4361 * NULL to indicate it is not associated with a device.
4362 */
4363DECLINLINE(int) PDMDevHlpMMIOExDeregister(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion)
4364{
4365 return pDevIns->pHlpR3->pfnMMIOExDeregister(pDevIns, pPciDev, iRegion);
4366}
4367
4368/**
4369 * @copydoc PDMDEVHLPR3::pfnMMIOExMap
4370 * @param pPciDev The PCI device the region is associated with, use
4371 * NULL to indicate it is not associated with a device.
4372 */
4373DECLINLINE(int) PDMDevHlpMMIOExMap(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion, RTGCPHYS GCPhys)
4374{
4375 return pDevIns->pHlpR3->pfnMMIOExMap(pDevIns, pPciDev, iRegion, GCPhys);
4376}
4377
4378/**
4379 * @copydoc PDMDEVHLPR3::pfnMMIOExUnmap
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) PDMDevHlpMMIOExUnmap(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion, RTGCPHYS GCPhys)
4384{
4385 return pDevIns->pHlpR3->pfnMMIOExUnmap(pDevIns, pPciDev, iRegion, GCPhys);
4386}
4387
4388/**
4389 * @copydoc PDMDEVHLPR3::pfnMMHyperMapMMIO2
4390 */
4391DECLINLINE(int) PDMDevHlpMMHyperMapMMIO2(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion, RTGCPHYS off, RTGCPHYS cb,
4392 const char *pszDesc, PRTRCPTR pRCPtr)
4393{
4394 return pDevIns->pHlpR3->pfnMMHyperMapMMIO2(pDevIns, pPciDev, iRegion, off, cb, pszDesc, pRCPtr);
4395}
4396
4397/**
4398 * @copydoc PDMDEVHLPR3::pfnMMIO2MapKernel
4399 */
4400DECLINLINE(int) PDMDevHlpMMIO2MapKernel(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion, RTGCPHYS off, RTGCPHYS cb,
4401 const char *pszDesc, PRTR0PTR pR0Ptr)
4402{
4403 return pDevIns->pHlpR3->pfnMMIO2MapKernel(pDevIns, pPciDev, iRegion, off, cb, pszDesc, pR0Ptr);
4404}
4405
4406/**
4407 * @copydoc PDMDEVHLPR3::pfnROMRegister
4408 */
4409DECLINLINE(int) PDMDevHlpROMRegister(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, uint32_t cbRange,
4410 const void *pvBinary, uint32_t cbBinary, uint32_t fFlags, const char *pszDesc)
4411{
4412 return pDevIns->pHlpR3->pfnROMRegister(pDevIns, GCPhysStart, cbRange, pvBinary, cbBinary, fFlags, pszDesc);
4413}
4414
4415/**
4416 * @copydoc PDMDEVHLPR3::pfnROMProtectShadow
4417 */
4418DECLINLINE(int) PDMDevHlpROMProtectShadow(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, uint32_t cbRange, PGMROMPROT enmProt)
4419{
4420 return pDevIns->pHlpR3->pfnROMProtectShadow(pDevIns, GCPhysStart, cbRange, enmProt);
4421}
4422
4423/**
4424 * Register a save state data unit.
4425 *
4426 * @returns VBox status.
4427 * @param pDevIns The device instance.
4428 * @param uVersion Data layout version number.
4429 * @param cbGuess The approximate amount of data in the unit.
4430 * Only for progress indicators.
4431 * @param pfnSaveExec Execute save callback, optional.
4432 * @param pfnLoadExec Execute load callback, optional.
4433 */
4434DECLINLINE(int) PDMDevHlpSSMRegister(PPDMDEVINS pDevIns, uint32_t uVersion, size_t cbGuess,
4435 PFNSSMDEVSAVEEXEC pfnSaveExec, PFNSSMDEVLOADEXEC pfnLoadExec)
4436{
4437 return pDevIns->pHlpR3->pfnSSMRegister(pDevIns, uVersion, cbGuess, NULL /*pszBefore*/,
4438 NULL /*pfnLivePrep*/, NULL /*pfnLiveExec*/, NULL /*pfnLiveDone*/,
4439 NULL /*pfnSavePrep*/, pfnSaveExec, NULL /*pfnSaveDone*/,
4440 NULL /*pfnLoadPrep*/, pfnLoadExec, NULL /*pfnLoadDone*/);
4441}
4442
4443/**
4444 * Register a save state data unit with a live save callback as well.
4445 *
4446 * @returns VBox status.
4447 * @param pDevIns The device instance.
4448 * @param uVersion Data layout version number.
4449 * @param cbGuess The approximate amount of data in the unit.
4450 * Only for progress indicators.
4451 * @param pfnLiveExec Execute live callback, optional.
4452 * @param pfnSaveExec Execute save callback, optional.
4453 * @param pfnLoadExec Execute load callback, optional.
4454 */
4455DECLINLINE(int) PDMDevHlpSSMRegister3(PPDMDEVINS pDevIns, uint32_t uVersion, size_t cbGuess,
4456 FNSSMDEVLIVEEXEC pfnLiveExec, PFNSSMDEVSAVEEXEC pfnSaveExec, PFNSSMDEVLOADEXEC pfnLoadExec)
4457{
4458 return pDevIns->pHlpR3->pfnSSMRegister(pDevIns, uVersion, cbGuess, NULL /*pszBefore*/,
4459 NULL /*pfnLivePrep*/, pfnLiveExec, NULL /*pfnLiveDone*/,
4460 NULL /*pfnSavePrep*/, pfnSaveExec, NULL /*pfnSaveDone*/,
4461 NULL /*pfnLoadPrep*/, pfnLoadExec, NULL /*pfnLoadDone*/);
4462}
4463
4464/**
4465 * @copydoc PDMDEVHLPR3::pfnSSMRegister
4466 */
4467DECLINLINE(int) PDMDevHlpSSMRegisterEx(PPDMDEVINS pDevIns, uint32_t uVersion, size_t cbGuess, const char *pszBefore,
4468 PFNSSMDEVLIVEPREP pfnLivePrep, PFNSSMDEVLIVEEXEC pfnLiveExec, PFNSSMDEVLIVEVOTE pfnLiveVote,
4469 PFNSSMDEVSAVEPREP pfnSavePrep, PFNSSMDEVSAVEEXEC pfnSaveExec, PFNSSMDEVSAVEDONE pfnSaveDone,
4470 PFNSSMDEVLOADPREP pfnLoadPrep, PFNSSMDEVLOADEXEC pfnLoadExec, PFNSSMDEVLOADDONE pfnLoadDone)
4471{
4472 return pDevIns->pHlpR3->pfnSSMRegister(pDevIns, uVersion, cbGuess, pszBefore,
4473 pfnLivePrep, pfnLiveExec, pfnLiveVote,
4474 pfnSavePrep, pfnSaveExec, pfnSaveDone,
4475 pfnLoadPrep, pfnLoadExec, pfnLoadDone);
4476}
4477
4478/**
4479 * @copydoc PDMDEVHLPR3::pfnTMTimerCreate
4480 */
4481DECLINLINE(int) PDMDevHlpTMTimerCreate(PPDMDEVINS pDevIns, TMCLOCK enmClock, PFNTMTIMERDEV pfnCallback, void *pvUser, uint32_t fFlags,
4482 const char *pszDesc, PPTMTIMERR3 ppTimer)
4483{
4484 return pDevIns->pHlpR3->pfnTMTimerCreate(pDevIns, enmClock, pfnCallback, pvUser, fFlags, pszDesc, ppTimer);
4485}
4486
4487/**
4488 * @copydoc PDMDEVHLPR3::pfnTMUtcNow
4489 */
4490DECLINLINE(PRTTIMESPEC) PDMDevHlpTMUtcNow(PPDMDEVINS pDevIns, PRTTIMESPEC pTime)
4491{
4492 return pDevIns->pHlpR3->pfnTMUtcNow(pDevIns, pTime);
4493}
4494
4495#endif /* IN_RING3 */
4496
4497/**
4498 * @copydoc PDMDEVHLPR3::pfnPhysRead
4499 */
4500DECLINLINE(int) PDMDevHlpPhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)
4501{
4502 return pDevIns->CTX_SUFF(pHlp)->pfnPhysRead(pDevIns, GCPhys, pvBuf, cbRead);
4503}
4504
4505/**
4506 * @copydoc PDMDEVHLPR3::pfnPhysWrite
4507 */
4508DECLINLINE(int) PDMDevHlpPhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)
4509{
4510 return pDevIns->CTX_SUFF(pHlp)->pfnPhysWrite(pDevIns, GCPhys, pvBuf, cbWrite);
4511}
4512
4513#ifdef IN_RING3
4514
4515/**
4516 * @copydoc PDMDEVHLPR3::pfnPhysGCPhys2CCPtr
4517 */
4518DECLINLINE(int) PDMDevHlpPhysGCPhys2CCPtr(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, uint32_t fFlags, void **ppv, PPGMPAGEMAPLOCK pLock)
4519{
4520 return pDevIns->CTX_SUFF(pHlp)->pfnPhysGCPhys2CCPtr(pDevIns, GCPhys, fFlags, ppv, pLock);
4521}
4522
4523/**
4524 * @copydoc PDMDEVHLPR3::pfnPhysGCPhys2CCPtrReadOnly
4525 */
4526DECLINLINE(int) PDMDevHlpPhysGCPhys2CCPtrReadOnly(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, uint32_t fFlags, void const **ppv,
4527 PPGMPAGEMAPLOCK pLock)
4528{
4529 return pDevIns->CTX_SUFF(pHlp)->pfnPhysGCPhys2CCPtrReadOnly(pDevIns, GCPhys, fFlags, ppv, pLock);
4530}
4531
4532/**
4533 * @copydoc PDMDEVHLPR3::pfnPhysReleasePageMappingLock
4534 */
4535DECLINLINE(void) PDMDevHlpPhysReleasePageMappingLock(PPDMDEVINS pDevIns, PPGMPAGEMAPLOCK pLock)
4536{
4537 pDevIns->CTX_SUFF(pHlp)->pfnPhysReleasePageMappingLock(pDevIns, pLock);
4538}
4539
4540/**
4541 * @copydoc PDMDEVHLPR3::pfnPhysReadGCVirt
4542 */
4543DECLINLINE(int) PDMDevHlpPhysReadGCVirt(PPDMDEVINS pDevIns, void *pvDst, RTGCPTR GCVirtSrc, size_t cb)
4544{
4545 return pDevIns->pHlpR3->pfnPhysReadGCVirt(pDevIns, pvDst, GCVirtSrc, cb);
4546}
4547
4548/**
4549 * @copydoc PDMDEVHLPR3::pfnPhysWriteGCVirt
4550 */
4551DECLINLINE(int) PDMDevHlpPhysWriteGCVirt(PPDMDEVINS pDevIns, RTGCPTR GCVirtDst, const void *pvSrc, size_t cb)
4552{
4553 return pDevIns->pHlpR3->pfnPhysWriteGCVirt(pDevIns, GCVirtDst, pvSrc, cb);
4554}
4555
4556/**
4557 * @copydoc PDMDEVHLPR3::pfnPhysGCPtr2GCPhys
4558 */
4559DECLINLINE(int) PDMDevHlpPhysGCPtr2GCPhys(PPDMDEVINS pDevIns, RTGCPTR GCPtr, PRTGCPHYS pGCPhys)
4560{
4561 return pDevIns->pHlpR3->pfnPhysGCPtr2GCPhys(pDevIns, GCPtr, pGCPhys);
4562}
4563
4564/**
4565 * @copydoc PDMDEVHLPR3::pfnMMHeapAlloc
4566 */
4567DECLINLINE(void *) PDMDevHlpMMHeapAlloc(PPDMDEVINS pDevIns, size_t cb)
4568{
4569 return pDevIns->pHlpR3->pfnMMHeapAlloc(pDevIns, cb);
4570}
4571
4572/**
4573 * @copydoc PDMDEVHLPR3::pfnMMHeapAllocZ
4574 */
4575DECLINLINE(void *) PDMDevHlpMMHeapAllocZ(PPDMDEVINS pDevIns, size_t cb)
4576{
4577 return pDevIns->pHlpR3->pfnMMHeapAllocZ(pDevIns, cb);
4578}
4579
4580/**
4581 * @copydoc PDMDEVHLPR3::pfnMMHeapFree
4582 */
4583DECLINLINE(void) PDMDevHlpMMHeapFree(PPDMDEVINS pDevIns, void *pv)
4584{
4585 pDevIns->pHlpR3->pfnMMHeapFree(pDevIns, pv);
4586}
4587#endif /* IN_RING3 */
4588
4589/**
4590 * @copydoc PDMDEVHLPR3::pfnVMState
4591 */
4592DECLINLINE(VMSTATE) PDMDevHlpVMState(PPDMDEVINS pDevIns)
4593{
4594 return pDevIns->CTX_SUFF(pHlp)->pfnVMState(pDevIns);
4595}
4596
4597#ifdef IN_RING3
4598/**
4599 * @copydoc PDMDEVHLPR3::pfnVMTeleportedAndNotFullyResumedYet
4600 */
4601DECLINLINE(bool) PDMDevHlpVMTeleportedAndNotFullyResumedYet(PPDMDEVINS pDevIns)
4602{
4603 return pDevIns->pHlpR3->pfnVMTeleportedAndNotFullyResumedYet(pDevIns);
4604}
4605#endif /* IN_RING3 */
4606
4607/**
4608 * @copydoc PDMDEVHLPR3::pfnVMSetError
4609 */
4610DECLINLINE(int) RT_IPRT_FORMAT_ATTR(6, 7) PDMDevHlpVMSetError(PPDMDEVINS pDevIns, const int rc, RT_SRC_POS_DECL,
4611 const char *pszFormat, ...)
4612{
4613 va_list va;
4614 va_start(va, pszFormat);
4615 pDevIns->CTX_SUFF(pHlp)->pfnVMSetErrorV(pDevIns, rc, RT_SRC_POS_ARGS, pszFormat, va);
4616 va_end(va);
4617 return rc;
4618}
4619
4620/**
4621 * @copydoc PDMDEVHLPR3::pfnVMSetRuntimeError
4622 */
4623DECLINLINE(int) RT_IPRT_FORMAT_ATTR(4, 5) PDMDevHlpVMSetRuntimeError(PPDMDEVINS pDevIns, uint32_t fFlags, const char *pszErrorId,
4624 const char *pszFormat, ...)
4625{
4626 va_list va;
4627 int rc;
4628 va_start(va, pszFormat);
4629 rc = pDevIns->CTX_SUFF(pHlp)->pfnVMSetRuntimeErrorV(pDevIns, fFlags, pszErrorId, pszFormat, va);
4630 va_end(va);
4631 return rc;
4632}
4633
4634/**
4635 * VBOX_STRICT wrapper for pHlp->pfnDBGFStopV.
4636 *
4637 * @returns VBox status code which must be passed up to the VMM. This will be
4638 * VINF_SUCCESS in non-strict builds.
4639 * @param pDevIns The device instance.
4640 * @param SRC_POS Use RT_SRC_POS.
4641 * @param pszFormat Message. (optional)
4642 * @param ... Message parameters.
4643 */
4644DECLINLINE(int) RT_IPRT_FORMAT_ATTR(5, 6) PDMDevHlpDBGFStop(PPDMDEVINS pDevIns, RT_SRC_POS_DECL, const char *pszFormat, ...)
4645{
4646#ifdef VBOX_STRICT
4647# ifdef IN_RING3
4648 int rc;
4649 va_list args;
4650 va_start(args, pszFormat);
4651 rc = pDevIns->pHlpR3->pfnDBGFStopV(pDevIns, RT_SRC_POS_ARGS, pszFormat, args);
4652 va_end(args);
4653 return rc;
4654# else
4655 NOREF(pDevIns);
4656 NOREF(pszFile);
4657 NOREF(iLine);
4658 NOREF(pszFunction);
4659 NOREF(pszFormat);
4660 return VINF_EM_DBG_STOP;
4661# endif
4662#else
4663 NOREF(pDevIns);
4664 NOREF(pszFile);
4665 NOREF(iLine);
4666 NOREF(pszFunction);
4667 NOREF(pszFormat);
4668 return VINF_SUCCESS;
4669#endif
4670}
4671
4672#ifdef IN_RING3
4673
4674/**
4675 * @copydoc PDMDEVHLPR3::pfnDBGFInfoRegister
4676 */
4677DECLINLINE(int) PDMDevHlpDBGFInfoRegister(PPDMDEVINS pDevIns, const char *pszName, const char *pszDesc, PFNDBGFHANDLERDEV pfnHandler)
4678{
4679 return pDevIns->pHlpR3->pfnDBGFInfoRegister(pDevIns, pszName, pszDesc, pfnHandler);
4680}
4681
4682/**
4683 * @copydoc PDMDEVHLPR3::pfnDBGFRegRegister
4684 */
4685DECLINLINE(int) PDMDevHlpDBGFRegRegister(PPDMDEVINS pDevIns, PCDBGFREGDESC paRegisters)
4686{
4687 return pDevIns->pHlpR3->pfnDBGFRegRegister(pDevIns, paRegisters);
4688}
4689
4690/**
4691 * @copydoc PDMDEVHLPR3::pfnSTAMRegister
4692 */
4693DECLINLINE(void) PDMDevHlpSTAMRegister(PPDMDEVINS pDevIns, void *pvSample, STAMTYPE enmType, const char *pszName, STAMUNIT enmUnit, const char *pszDesc)
4694{
4695 pDevIns->pHlpR3->pfnSTAMRegister(pDevIns, pvSample, enmType, pszName, enmUnit, pszDesc);
4696}
4697
4698/**
4699 * @copydoc PDMDEVHLPR3::pfnSTAMRegisterF
4700 */
4701DECLINLINE(void) RT_IPRT_FORMAT_ATTR(7, 8) PDMDevHlpSTAMRegisterF(PPDMDEVINS pDevIns, void *pvSample, STAMTYPE enmType,
4702 STAMVISIBILITY enmVisibility, STAMUNIT enmUnit,
4703 const char *pszDesc, const char *pszName, ...)
4704{
4705 va_list va;
4706 va_start(va, pszName);
4707 pDevIns->pHlpR3->pfnSTAMRegisterV(pDevIns, pvSample, enmType, enmVisibility, enmUnit, pszDesc, pszName, va);
4708 va_end(va);
4709}
4710
4711/*
4712 * Registers the device with the default PCI bus.
4713 *
4714 * @returns VBox status code.
4715 * @param pDevIns The device instance.
4716 * @param pPciDev The PCI device structure.
4717 * This must be kept in the instance data.
4718 * The PCI configuration must be initialized before registration.
4719 */
4720DECLINLINE(int) PDMDevHlpPCIRegister(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev)
4721{
4722 return pDevIns->pHlpR3->pfnPCIRegister(pDevIns, pPciDev, PDMPCIDEVREG_CFG_NEXT, 0 /*fFlags*/,
4723 PDMPCIDEVREG_DEV_NO_FIRST_UNUSED, PDMPCIDEVREG_FUN_NO_FIRST_UNUSED, NULL);
4724}
4725
4726/**
4727 * @copydoc PDMDEVHLPR3::pfnPCIRegister
4728 */
4729DECLINLINE(int) PDMDevHlpPCIRegisterEx(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t idxDevCfg, uint32_t fFlags,
4730 uint8_t uPciDevNo, uint8_t uPciFunNo, const char *pszName)
4731{
4732 return pDevIns->pHlpR3->pfnPCIRegister(pDevIns, pPciDev, idxDevCfg, fFlags, uPciDevNo, uPciFunNo, pszName);
4733}
4734
4735/**
4736 * Registers a I/O region (memory mapped or I/O ports) for the default PCI
4737 * device.
4738 *
4739 * @returns VBox status code.
4740 * @param pDevIns The device instance.
4741 * @param iRegion The region number.
4742 * @param cbRegion Size of the region.
4743 * @param enmType PCI_ADDRESS_SPACE_MEM, PCI_ADDRESS_SPACE_IO or PCI_ADDRESS_SPACE_MEM_PREFETCH.
4744 * @param pfnCallback Callback for doing the mapping.
4745 * @remarks The callback will be invoked holding the PDM lock. The device lock
4746 * is NOT take because that is very likely be a lock order violation.
4747 */
4748DECLINLINE(int) PDMDevHlpPCIIORegionRegister(PPDMDEVINS pDevIns, int iRegion, RTGCPHYS cbRegion,
4749 PCIADDRESSSPACE enmType, PFNPCIIOREGIONMAP pfnCallback)
4750{
4751 return pDevIns->pHlpR3->pfnPCIIORegionRegister(pDevIns, NULL, iRegion, cbRegion, enmType, pfnCallback);
4752}
4753
4754/**
4755 * @copydoc PDMDEVHLPR3::pfnPCIIORegionRegister
4756 */
4757DECLINLINE(int) PDMDevHlpPCIIORegionRegisterEx(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iRegion, RTGCPHYS cbRegion,
4758 PCIADDRESSSPACE enmType, PFNPCIIOREGIONMAP pfnCallback)
4759{
4760 return pDevIns->pHlpR3->pfnPCIIORegionRegister(pDevIns, pPciDev, iRegion, cbRegion, enmType, pfnCallback);
4761}
4762
4763/**
4764 * Initialize MSI support for the first PCI device.
4765 *
4766 * @returns VBox status code.
4767 * @param pDevIns The device instance.
4768 * @param pMsiReg MSI registartion structure.
4769 */
4770DECLINLINE(int) PDMDevHlpPCIRegisterMsi(PPDMDEVINS pDevIns, PPDMMSIREG pMsiReg)
4771{
4772 return pDevIns->pHlpR3->pfnPCIRegisterMsi(pDevIns, NULL, pMsiReg);
4773}
4774
4775/**
4776 * @copydoc PDMDEVHLPR3::pfnPCIRegisterMsi
4777 */
4778DECLINLINE(int) PDMDevHlpPCIRegisterMsiEx(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, PPDMMSIREG pMsiReg)
4779{
4780 return pDevIns->pHlpR3->pfnPCIRegisterMsi(pDevIns, pPciDev, pMsiReg);
4781}
4782
4783/**
4784 * @copydoc PDMDEVHLPR3::pfnPCISetConfigCallbacks
4785 */
4786DECLINLINE(void) PDMDevHlpPCISetConfigCallbacks(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev,
4787 PFNPCICONFIGREAD pfnRead, PPFNPCICONFIGREAD ppfnReadOld,
4788 PFNPCICONFIGWRITE pfnWrite, PPFNPCICONFIGWRITE ppfnWriteOld)
4789{
4790 pDevIns->pHlpR3->pfnPCISetConfigCallbacks(pDevIns, pPciDev, pfnRead, ppfnReadOld, pfnWrite, ppfnWriteOld);
4791}
4792
4793#endif /* IN_RING3 */
4794
4795/**
4796 * Bus master physical memory read from the default PCI device.
4797 *
4798 * @returns VINF_SUCCESS or VERR_PGM_PCI_PHYS_READ_BM_DISABLED, later maybe
4799 * VERR_EM_MEMORY. The informational status shall NOT be propagated!
4800 * @param pDevIns The device instance.
4801 * @param GCPhys Physical address start reading from.
4802 * @param pvBuf Where to put the read bits.
4803 * @param cbRead How many bytes to read.
4804 * @thread Any thread, but the call may involve the emulation thread.
4805 */
4806DECLINLINE(int) PDMDevHlpPCIPhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)
4807{
4808 return pDevIns->CTX_SUFF(pHlp)->pfnPCIPhysRead(pDevIns, NULL, GCPhys, pvBuf, cbRead);
4809}
4810
4811/**
4812 * @copydoc PDMDEVHLPR3::pfnPCIPhysRead
4813 */
4814DECLINLINE(int) PDMDevHlpPCIPhysReadEx(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)
4815{
4816 return pDevIns->CTX_SUFF(pHlp)->pfnPCIPhysRead(pDevIns, pPciDev, GCPhys, pvBuf, cbRead);
4817}
4818
4819/**
4820 * Bus master physical memory write from the default PCI device.
4821 *
4822 * @returns VINF_SUCCESS or VERR_PGM_PCI_PHYS_WRITE_BM_DISABLED, later maybe
4823 * VERR_EM_MEMORY. The informational status shall NOT be propagated!
4824 * @param pDevIns The device instance.
4825 * @param GCPhys Physical address to write to.
4826 * @param pvBuf What to write.
4827 * @param cbWrite How many bytes to write.
4828 * @thread Any thread, but the call may involve the emulation thread.
4829 */
4830DECLINLINE(int) PDMDevHlpPCIPhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)
4831{
4832 return pDevIns->CTX_SUFF(pHlp)->pfnPCIPhysWrite(pDevIns, NULL, GCPhys, pvBuf, cbWrite);
4833}
4834
4835/**
4836 * @copydoc PDMDEVHLPR3::pfnPCIPhysWrite
4837 */
4838DECLINLINE(int) PDMDevHlpPCIPhysWriteEx(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)
4839{
4840 return pDevIns->CTX_SUFF(pHlp)->pfnPCIPhysWrite(pDevIns, pPciDev, GCPhys, pvBuf, cbWrite);
4841}
4842
4843/**
4844 * Sets the IRQ for the default PCI device.
4845 *
4846 * @param pDevIns The device instance.
4847 * @param iIrq IRQ number to set.
4848 * @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
4849 * @thread Any thread, but will involve the emulation thread.
4850 */
4851DECLINLINE(void) PDMDevHlpPCISetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel)
4852{
4853 pDevIns->CTX_SUFF(pHlp)->pfnPCISetIrq(pDevIns, NULL, iIrq, iLevel);
4854}
4855
4856/**
4857 * @copydoc PDMDEVHLPR3::pfnPCISetIrq
4858 */
4859DECLINLINE(void) PDMDevHlpPCISetIrqEx(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iIrq, int iLevel)
4860{
4861 pDevIns->CTX_SUFF(pHlp)->pfnPCISetIrq(pDevIns, pPciDev, iIrq, iLevel);
4862}
4863
4864/**
4865 * Sets the IRQ for the given PCI device, but doesn't wait for EMT to process
4866 * the request when not called from EMT.
4867 *
4868 * @param pDevIns The device instance.
4869 * @param iIrq IRQ number to set.
4870 * @param iLevel IRQ level.
4871 * @thread Any thread, but will involve the emulation thread.
4872 */
4873DECLINLINE(void) PDMDevHlpPCISetIrqNoWait(PPDMDEVINS pDevIns, int iIrq, int iLevel)
4874{
4875 pDevIns->CTX_SUFF(pHlp)->pfnPCISetIrq(pDevIns, NULL, iIrq, iLevel);
4876}
4877
4878/**
4879 * @copydoc PDMDEVHLPR3::pfnPCISetIrqNoWait
4880 */
4881DECLINLINE(void) PDMDevHlpPCISetIrqNoWaitEx(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iIrq, int iLevel)
4882{
4883 pDevIns->CTX_SUFF(pHlp)->pfnPCISetIrq(pDevIns, pPciDev, iIrq, iLevel);
4884}
4885
4886/**
4887 * @copydoc PDMDEVHLPR3::pfnISASetIrq
4888 */
4889DECLINLINE(void) PDMDevHlpISASetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel)
4890{
4891 pDevIns->CTX_SUFF(pHlp)->pfnISASetIrq(pDevIns, iIrq, iLevel);
4892}
4893
4894/**
4895 * @copydoc PDMDEVHLPR3::pfnISASetIrqNoWait
4896 */
4897DECLINLINE(void) PDMDevHlpISASetIrqNoWait(PPDMDEVINS pDevIns, int iIrq, int iLevel)
4898{
4899 pDevIns->CTX_SUFF(pHlp)->pfnISASetIrq(pDevIns, iIrq, iLevel);
4900}
4901
4902#ifdef IN_RING3
4903
4904/**
4905 * @copydoc PDMDEVHLPR3::pfnDriverAttach
4906 */
4907DECLINLINE(int) PDMDevHlpDriverAttach(PPDMDEVINS pDevIns, uint32_t iLun, PPDMIBASE pBaseInterface, PPDMIBASE *ppBaseInterface, const char *pszDesc)
4908{
4909 return pDevIns->pHlpR3->pfnDriverAttach(pDevIns, iLun, pBaseInterface, ppBaseInterface, pszDesc);
4910}
4911
4912/**
4913 * @copydoc PDMDEVHLPR3::pfnDriverDetach
4914 */
4915DECLINLINE(int) PDMDevHlpDriverDetach(PPDMDEVINS pDevIns, PPDMDRVINS pDrvIns, uint32_t fFlags)
4916{
4917 return pDevIns->pHlpR3->pfnDriverDetach(pDevIns, pDrvIns, fFlags);
4918}
4919
4920/**
4921 * @copydoc PDMDEVHLPR3::pfnQueueCreate
4922 */
4923DECLINLINE(int) PDMDevHlpQueueCreate(PPDMDEVINS pDevIns, size_t cbItem, uint32_t cItems, uint32_t cMilliesInterval,
4924 PFNPDMQUEUEDEV pfnCallback, bool fRZEnabled, const char *pszName, PPDMQUEUE *ppQueue)
4925{
4926 return pDevIns->pHlpR3->pfnQueueCreate(pDevIns, cbItem, cItems, cMilliesInterval, pfnCallback, fRZEnabled, pszName, ppQueue);
4927}
4928
4929/**
4930 * Initializes a PDM critical section.
4931 *
4932 * The PDM critical sections are derived from the IPRT critical sections, but
4933 * works in RC and R0 as well.
4934 *
4935 * @returns VBox status code.
4936 * @param pDevIns The device instance.
4937 * @param pCritSect Pointer to the critical section.
4938 * @param SRC_POS Use RT_SRC_POS.
4939 * @param pszNameFmt Format string for naming the critical section.
4940 * For statistics and lock validation.
4941 * @param ... Arguments for the format string.
4942 */
4943DECLINLINE(int) RT_IPRT_FORMAT_ATTR(6, 7) PDMDevHlpCritSectInit(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, RT_SRC_POS_DECL,
4944 const char *pszNameFmt, ...)
4945{
4946 int rc;
4947 va_list va;
4948 va_start(va, pszNameFmt);
4949 rc = pDevIns->pHlpR3->pfnCritSectInit(pDevIns, pCritSect, RT_SRC_POS_ARGS, pszNameFmt, va);
4950 va_end(va);
4951 return rc;
4952}
4953
4954/**
4955 * @copydoc PDMDEVHLPR3::pfnCritSectGetNop
4956 */
4957DECLINLINE(PPDMCRITSECT) PDMDevHlpCritSectGetNop(PPDMDEVINS pDevIns)
4958{
4959 return pDevIns->pHlpR3->pfnCritSectGetNop(pDevIns);
4960}
4961
4962/**
4963 * @copydoc PDMDEVHLPR3::pfnCritSectGetNopR0
4964 */
4965DECLINLINE(R0PTRTYPE(PPDMCRITSECT)) PDMDevHlpCritSectGetNopR0(PPDMDEVINS pDevIns)
4966{
4967 return pDevIns->pHlpR3->pfnCritSectGetNopR0(pDevIns);
4968}
4969
4970/**
4971 * @copydoc PDMDEVHLPR3::pfnCritSectGetNopRC
4972 */
4973DECLINLINE(RCPTRTYPE(PPDMCRITSECT)) PDMDevHlpCritSectGetNopRC(PPDMDEVINS pDevIns)
4974{
4975 return pDevIns->pHlpR3->pfnCritSectGetNopRC(pDevIns);
4976}
4977
4978/**
4979 * @copydoc PDMDEVHLPR3::pfnSetDeviceCritSect
4980 */
4981DECLINLINE(int) PDMDevHlpSetDeviceCritSect(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect)
4982{
4983 return pDevIns->pHlpR3->pfnSetDeviceCritSect(pDevIns, pCritSect);
4984}
4985
4986/**
4987 * @copydoc PDMDEVHLPR3::pfnThreadCreate
4988 */
4989DECLINLINE(int) PDMDevHlpThreadCreate(PPDMDEVINS pDevIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADDEV pfnThread,
4990 PFNPDMTHREADWAKEUPDEV pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName)
4991{
4992 return pDevIns->pHlpR3->pfnThreadCreate(pDevIns, ppThread, pvUser, pfnThread, pfnWakeup, cbStack, enmType, pszName);
4993}
4994
4995/**
4996 * @copydoc PDMDEVHLPR3::pfnSetAsyncNotification
4997 */
4998DECLINLINE(int) PDMDevHlpSetAsyncNotification(PPDMDEVINS pDevIns, PFNPDMDEVASYNCNOTIFY pfnAsyncNotify)
4999{
5000 return pDevIns->pHlpR3->pfnSetAsyncNotification(pDevIns, pfnAsyncNotify);
5001}
5002
5003/**
5004 * @copydoc PDMDEVHLPR3::pfnAsyncNotificationCompleted
5005 */
5006DECLINLINE(void) PDMDevHlpAsyncNotificationCompleted(PPDMDEVINS pDevIns)
5007{
5008 pDevIns->pHlpR3->pfnAsyncNotificationCompleted(pDevIns);
5009}
5010
5011/**
5012 * @copydoc PDMDEVHLPR3::pfnA20Set
5013 */
5014DECLINLINE(void) PDMDevHlpA20Set(PPDMDEVINS pDevIns, bool fEnable)
5015{
5016 pDevIns->pHlpR3->pfnA20Set(pDevIns, fEnable);
5017}
5018
5019/**
5020 * @copydoc PDMDEVHLPR3::pfnRTCRegister
5021 */
5022DECLINLINE(int) PDMDevHlpRTCRegister(PPDMDEVINS pDevIns, PCPDMRTCREG pRtcReg, PCPDMRTCHLP *ppRtcHlp)
5023{
5024 return pDevIns->pHlpR3->pfnRTCRegister(pDevIns, pRtcReg, ppRtcHlp);
5025}
5026
5027/**
5028 * @copydoc PDMDEVHLPR3::pfnPCIBusRegister
5029 */
5030#if PDM_DEVHLPR3_VERSION >= PDM_VERSION_MAKE_PP(0xffe7, 20, 0)
5031DECLINLINE(int) PDMDevHlpPCIBusRegister(PPDMDEVINS pDevIns, PPDMPCIBUSREG pPciBusReg, PCPDMPCIHLPR3 *ppPciHlpR3, uint32_t *piBus)
5032{
5033 return pDevIns->pHlpR3->pfnPCIBusRegister(pDevIns, pPciBusReg, ppPciHlpR3, piBus);
5034}
5035#else
5036DECLINLINE(int) PDMDevHlpPCIBusRegister(PPDMDEVINS pDevIns, PPDMPCIBUSREG pPciBusReg, PCPDMPCIHLPR3 *ppPciHlpR3)
5037{
5038 return pDevIns->pHlpR3->pfnPCIBusRegister(pDevIns, pPciBusReg, ppPciHlpR3);
5039}
5040#endif
5041
5042/**
5043 * @copydoc PDMDEVHLPR3::pfnPICRegister
5044 */
5045DECLINLINE(int) PDMDevHlpPICRegister(PPDMDEVINS pDevIns, PPDMPICREG pPicReg, PCPDMPICHLPR3 *ppPicHlpR3)
5046{
5047 return pDevIns->pHlpR3->pfnPICRegister(pDevIns, pPicReg, ppPicHlpR3);
5048}
5049
5050/**
5051 * @copydoc PDMDEVHLPR3::pfnAPICRegister
5052 */
5053DECLINLINE(int) PDMDevHlpAPICRegister(PPDMDEVINS pDevIns)
5054{
5055 return pDevIns->pHlpR3->pfnAPICRegister(pDevIns);
5056}
5057
5058/**
5059 * @copydoc PDMDEVHLPR3::pfnIOAPICRegister
5060 */
5061DECLINLINE(int) PDMDevHlpIOAPICRegister(PPDMDEVINS pDevIns, PPDMIOAPICREG pIoApicReg, PCPDMIOAPICHLPR3 *ppIoApicHlpR3)
5062{
5063 return pDevIns->pHlpR3->pfnIOAPICRegister(pDevIns, pIoApicReg, ppIoApicHlpR3);
5064}
5065
5066/**
5067 * @copydoc PDMDEVHLPR3::pfnHPETRegister
5068 */
5069DECLINLINE(int) PDMDevHlpHPETRegister(PPDMDEVINS pDevIns, PPDMHPETREG pHpetReg, PCPDMHPETHLPR3 *ppHpetHlpR3)
5070{
5071 return pDevIns->pHlpR3->pfnHPETRegister(pDevIns, pHpetReg, ppHpetHlpR3);
5072}
5073
5074/**
5075 * @copydoc PDMDEVHLPR3::pfnPciRawRegister
5076 */
5077DECLINLINE(int) PDMDevHlpPciRawRegister(PPDMDEVINS pDevIns, PPDMPCIRAWREG pPciRawReg, PCPDMPCIRAWHLPR3 *ppPciRawHlpR3)
5078{
5079 return pDevIns->pHlpR3->pfnPciRawRegister(pDevIns, pPciRawReg, ppPciRawHlpR3);
5080}
5081
5082/**
5083 * @copydoc PDMDEVHLPR3::pfnDMACRegister
5084 */
5085DECLINLINE(int) PDMDevHlpDMACRegister(PPDMDEVINS pDevIns, PPDMDMACREG pDmacReg, PCPDMDMACHLP *ppDmacHlp)
5086{
5087 return pDevIns->pHlpR3->pfnDMACRegister(pDevIns, pDmacReg, ppDmacHlp);
5088}
5089
5090/**
5091 * @copydoc PDMDEVHLPR3::pfnDMARegister
5092 */
5093DECLINLINE(int) PDMDevHlpDMARegister(PPDMDEVINS pDevIns, unsigned uChannel, PFNDMATRANSFERHANDLER pfnTransferHandler, void *pvUser)
5094{
5095 return pDevIns->pHlpR3->pfnDMARegister(pDevIns, uChannel, pfnTransferHandler, pvUser);
5096}
5097
5098/**
5099 * @copydoc PDMDEVHLPR3::pfnDMAReadMemory
5100 */
5101DECLINLINE(int) PDMDevHlpDMAReadMemory(PPDMDEVINS pDevIns, unsigned uChannel, void *pvBuffer, uint32_t off, uint32_t cbBlock, uint32_t *pcbRead)
5102{
5103 return pDevIns->pHlpR3->pfnDMAReadMemory(pDevIns, uChannel, pvBuffer, off, cbBlock, pcbRead);
5104}
5105
5106/**
5107 * @copydoc PDMDEVHLPR3::pfnDMAWriteMemory
5108 */
5109DECLINLINE(int) PDMDevHlpDMAWriteMemory(PPDMDEVINS pDevIns, unsigned uChannel, const void *pvBuffer, uint32_t off, uint32_t cbBlock, uint32_t *pcbWritten)
5110{
5111 return pDevIns->pHlpR3->pfnDMAWriteMemory(pDevIns, uChannel, pvBuffer, off, cbBlock, pcbWritten);
5112}
5113
5114/**
5115 * @copydoc PDMDEVHLPR3::pfnDMASetDREQ
5116 */
5117DECLINLINE(int) PDMDevHlpDMASetDREQ(PPDMDEVINS pDevIns, unsigned uChannel, unsigned uLevel)
5118{
5119 return pDevIns->pHlpR3->pfnDMASetDREQ(pDevIns, uChannel, uLevel);
5120}
5121
5122/**
5123 * @copydoc PDMDEVHLPR3::pfnDMAGetChannelMode
5124 */
5125DECLINLINE(uint8_t) PDMDevHlpDMAGetChannelMode(PPDMDEVINS pDevIns, unsigned uChannel)
5126{
5127 return pDevIns->pHlpR3->pfnDMAGetChannelMode(pDevIns, uChannel);
5128}
5129
5130/**
5131 * @copydoc PDMDEVHLPR3::pfnDMASchedule
5132 */
5133DECLINLINE(void) PDMDevHlpDMASchedule(PPDMDEVINS pDevIns)
5134{
5135 pDevIns->pHlpR3->pfnDMASchedule(pDevIns);
5136}
5137
5138/**
5139 * @copydoc PDMDEVHLPR3::pfnCMOSWrite
5140 */
5141DECLINLINE(int) PDMDevHlpCMOSWrite(PPDMDEVINS pDevIns, unsigned iReg, uint8_t u8Value)
5142{
5143 return pDevIns->pHlpR3->pfnCMOSWrite(pDevIns, iReg, u8Value);
5144}
5145
5146/**
5147 * @copydoc PDMDEVHLPR3::pfnCMOSRead
5148 */
5149DECLINLINE(int) PDMDevHlpCMOSRead(PPDMDEVINS pDevIns, unsigned iReg, uint8_t *pu8Value)
5150{
5151 return pDevIns->pHlpR3->pfnCMOSRead(pDevIns, iReg, pu8Value);
5152}
5153
5154/**
5155 * @copydoc PDMDEVHLPR3::pfnCallR0
5156 */
5157DECLINLINE(int) PDMDevHlpCallR0(PPDMDEVINS pDevIns, uint32_t uOperation, uint64_t u64Arg)
5158{
5159 return pDevIns->pHlpR3->pfnCallR0(pDevIns, uOperation, u64Arg);
5160}
5161
5162/**
5163 * @copydoc PDMDEVHLPR3::pfnVMGetSuspendReason
5164 */
5165DECLINLINE(VMSUSPENDREASON) PDMDevHlpVMGetSuspendReason(PPDMDEVINS pDevIns)
5166{
5167 return pDevIns->pHlpR3->pfnVMGetSuspendReason(pDevIns);
5168}
5169
5170/**
5171 * @copydoc PDMDEVHLPR3::pfnVMGetResumeReason
5172 */
5173DECLINLINE(VMRESUMEREASON) PDMDevHlpVMGetResumeReason(PPDMDEVINS pDevIns)
5174{
5175 return pDevIns->pHlpR3->pfnVMGetResumeReason(pDevIns);
5176}
5177
5178/**
5179 * @copydoc PDMDEVHLPR3::pfnGetUVM
5180 */
5181DECLINLINE(PUVM) PDMDevHlpGetUVM(PPDMDEVINS pDevIns)
5182{
5183 return pDevIns->CTX_SUFF(pHlp)->pfnGetUVM(pDevIns);
5184}
5185
5186#endif /* IN_RING3 */
5187
5188/**
5189 * @copydoc PDMDEVHLPR3::pfnGetVM
5190 */
5191DECLINLINE(PVM) PDMDevHlpGetVM(PPDMDEVINS pDevIns)
5192{
5193 return pDevIns->CTX_SUFF(pHlp)->pfnGetVM(pDevIns);
5194}
5195
5196/**
5197 * @copydoc PDMDEVHLPR3::pfnGetVMCPU
5198 */
5199DECLINLINE(PVMCPU) PDMDevHlpGetVMCPU(PPDMDEVINS pDevIns)
5200{
5201 return pDevIns->CTX_SUFF(pHlp)->pfnGetVMCPU(pDevIns);
5202}
5203
5204/**
5205 * @copydoc PDMDEVHLPR3::pfnGetCurrentCpuId
5206 */
5207DECLINLINE(VMCPUID) PDMDevHlpGetCurrentCpuId(PPDMDEVINS pDevIns)
5208{
5209 return pDevIns->CTX_SUFF(pHlp)->pfnGetCurrentCpuId(pDevIns);
5210}
5211
5212/**
5213 * @copydoc PDMDEVHLPR3::pfnTMTimeVirtGet
5214 */
5215DECLINLINE(uint64_t) PDMDevHlpTMTimeVirtGet(PPDMDEVINS pDevIns)
5216{
5217 return pDevIns->CTX_SUFF(pHlp)->pfnTMTimeVirtGet(pDevIns);
5218}
5219
5220/**
5221 * @copydoc PDMDEVHLPR3::pfnTMTimeVirtGetFreq
5222 */
5223DECLINLINE(uint64_t) PDMDevHlpTMTimeVirtGetFreq(PPDMDEVINS pDevIns)
5224{
5225 return pDevIns->CTX_SUFF(pHlp)->pfnTMTimeVirtGetFreq(pDevIns);
5226}
5227
5228/**
5229 * @copydoc PDMDEVHLPR3::pfnTMTimeVirtGetFreq
5230 */
5231DECLINLINE(uint64_t) PDMDevHlpTMTimeVirtGetNano(PPDMDEVINS pDevIns)
5232{
5233 return pDevIns->CTX_SUFF(pHlp)->pfnTMTimeVirtGetNano(pDevIns);
5234}
5235
5236#ifdef IN_RING3
5237
5238/**
5239 * @copydoc PDMDEVHLPR3::pfnRegisterVMMDevHeap
5240 */
5241DECLINLINE(int) PDMDevHlpRegisterVMMDevHeap(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTR3PTR pvHeap, unsigned cbHeap)
5242{
5243 return pDevIns->pHlpR3->pfnRegisterVMMDevHeap(pDevIns, GCPhys, pvHeap, cbHeap);
5244}
5245
5246/**
5247 * @copydoc PDMDEVHLPR3::pfnFirmwareRegister
5248 */
5249DECLINLINE(int) PDMDevHlpFirmwareRegister(PPDMDEVINS pDevIns, PCPDMFWREG pFwReg, PCPDMFWHLPR3 *ppFwHlp)
5250{
5251 return pDevIns->pHlpR3->pfnFirmwareRegister(pDevIns, pFwReg, ppFwHlp);
5252}
5253
5254/**
5255 * @copydoc PDMDEVHLPR3::pfnVMReset
5256 */
5257DECLINLINE(int) PDMDevHlpVMReset(PPDMDEVINS pDevIns, uint32_t fFlags)
5258{
5259 return pDevIns->pHlpR3->pfnVMReset(pDevIns, fFlags);
5260}
5261
5262/**
5263 * @copydoc PDMDEVHLPR3::pfnVMSuspend
5264 */
5265DECLINLINE(int) PDMDevHlpVMSuspend(PPDMDEVINS pDevIns)
5266{
5267 return pDevIns->pHlpR3->pfnVMSuspend(pDevIns);
5268}
5269
5270/**
5271 * @copydoc PDMDEVHLPR3::pfnVMSuspendSaveAndPowerOff
5272 */
5273DECLINLINE(int) PDMDevHlpVMSuspendSaveAndPowerOff(PPDMDEVINS pDevIns)
5274{
5275 return pDevIns->pHlpR3->pfnVMSuspendSaveAndPowerOff(pDevIns);
5276}
5277
5278/**
5279 * @copydoc PDMDEVHLPR3::pfnVMPowerOff
5280 */
5281DECLINLINE(int) PDMDevHlpVMPowerOff(PPDMDEVINS pDevIns)
5282{
5283 return pDevIns->pHlpR3->pfnVMPowerOff(pDevIns);
5284}
5285
5286#endif /* IN_RING3 */
5287
5288/**
5289 * @copydoc PDMDEVHLPR3::pfnA20IsEnabled
5290 */
5291DECLINLINE(bool) PDMDevHlpA20IsEnabled(PPDMDEVINS pDevIns)
5292{
5293 return pDevIns->CTX_SUFF(pHlp)->pfnA20IsEnabled(pDevIns);
5294}
5295
5296#ifdef IN_RING3
5297
5298/**
5299 * @copydoc PDMDEVHLPR3::pfnGetCpuId
5300 */
5301DECLINLINE(void) PDMDevHlpGetCpuId(PPDMDEVINS pDevIns, uint32_t iLeaf, uint32_t *pEax, uint32_t *pEbx, uint32_t *pEcx, uint32_t *pEdx)
5302{
5303 pDevIns->pHlpR3->pfnGetCpuId(pDevIns, iLeaf, pEax, pEbx, pEcx, pEdx);
5304}
5305
5306/**
5307 * @copydoc PDMDEVHLPR3::pfnGetSupDrvSession
5308 */
5309DECLINLINE(PSUPDRVSESSION) PDMDevHlpGetSupDrvSession(PPDMDEVINS pDevIns)
5310{
5311 return pDevIns->pHlpR3->pfnGetSupDrvSession(pDevIns);
5312}
5313
5314#endif /* IN_RING3 */
5315#ifdef IN_RING0
5316
5317/**
5318 * @copydoc PDMDEVHLPR0::pfnCanEmulateIoBlock
5319 */
5320DECLINLINE(bool) PDMDevHlpCanEmulateIoBlock(PPDMDEVINS pDevIns)
5321{
5322 return pDevIns->CTX_SUFF(pHlp)->pfnCanEmulateIoBlock(pDevIns);
5323}
5324
5325#endif /* IN_RING0 */
5326
5327
5328
5329
5330/** Pointer to callbacks provided to the VBoxDeviceRegister() call. */
5331typedef struct PDMDEVREGCB *PPDMDEVREGCB;
5332
5333/**
5334 * Callbacks for VBoxDeviceRegister().
5335 */
5336typedef struct PDMDEVREGCB
5337{
5338 /** Interface version.
5339 * This is set to PDM_DEVREG_CB_VERSION. */
5340 uint32_t u32Version;
5341
5342 /**
5343 * Registers a device with the current VM instance.
5344 *
5345 * @returns VBox status code.
5346 * @param pCallbacks Pointer to the callback table.
5347 * @param pReg Pointer to the device registration record.
5348 * This data must be permanent and readonly.
5349 */
5350 DECLR3CALLBACKMEMBER(int, pfnRegister,(PPDMDEVREGCB pCallbacks, PCPDMDEVREG pReg));
5351} PDMDEVREGCB;
5352
5353/** Current version of the PDMDEVREGCB structure. */
5354#define PDM_DEVREG_CB_VERSION PDM_VERSION_MAKE(0xffe3, 1, 0)
5355
5356
5357/**
5358 * The VBoxDevicesRegister callback function.
5359 *
5360 * PDM will invoke this function after loading a device module and letting
5361 * the module decide which devices to register and how to handle conflicts.
5362 *
5363 * @returns VBox status code.
5364 * @param pCallbacks Pointer to the callback table.
5365 * @param u32Version VBox version number.
5366 */
5367typedef DECLCALLBACK(int) FNPDMVBOXDEVICESREGISTER(PPDMDEVREGCB pCallbacks, uint32_t u32Version);
5368
5369/** @} */
5370
5371RT_C_DECLS_END
5372
5373#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