VirtualBox

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

Last change on this file since 41788 was 41349, checked in by vboxsync, 13 years ago

pdmdev.h: warning

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

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