VirtualBox

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

最後變更 在這個檔案從64696是 64696,由 vboxsync 提交於 8 年 前

DevPCI*,PDM: Get internal bus number from PDM.

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

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