2
* PDM - Pluggable Device Manager, Devices.
6
* Copyright (C) 2006-2007 innotek GmbH
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 as published by the Free Software Foundation,
12
* in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
13
* distribution. VirtualBox OSE is distributed in the hope that it will
14
* be useful, but WITHOUT ANY WARRANTY of any kind.
17
#ifndef ___VBox_pdmdev_h
18
#define ___VBox_pdmdev_h
20
#include <VBox/pdmqueue.h>
21
#include <VBox/pdmcritsect.h>
22
#include <VBox/pdmthread.h>
23
#include <VBox/pdmifs.h>
24
#include <VBox/pdmins.h>
28
#include <VBox/cfgm.h>
29
#include <VBox/dbgf.h>
33
#include <iprt/stdarg.h>
37
/** @defgroup grp_pdm_device Devices
43
* Construct a device instance for a VM.
45
* @returns VBox status.
46
* @param pDevIns The device instance data.
47
* If the registration structure is needed, pDevIns->pDevReg points to it.
48
* @param iInstance Instance number. Use this to figure out which registers and such to use.
49
* The instance number is also found in pDevIns->iInstance, but since it's
50
* likely to be freqently used PDM passes it as parameter.
51
* @param pCfgHandle Configuration node handle for the device. Use this to obtain the configuration
52
* of the device instance. It's also found in pDevIns->pCfgHandle, but since it's
53
* primary usage will in this function it's passed as a parameter.
55
typedef DECLCALLBACK(int) FNPDMDEVCONSTRUCT(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfgHandle);
56
/** Pointer to a FNPDMDEVCONSTRUCT() function. */
57
typedef FNPDMDEVCONSTRUCT *PFNPDMDEVCONSTRUCT;
60
* Destruct a device instance.
62
* Most VM resources are freed by the VM. This callback is provided so that any non-VM
63
* resources can be freed correctly.
65
* @returns VBox status.
66
* @param pDevIns The device instance data.
68
typedef DECLCALLBACK(int) FNPDMDEVDESTRUCT(PPDMDEVINS pDevIns);
69
/** Pointer to a FNPDMDEVDESTRUCT() function. */
70
typedef FNPDMDEVDESTRUCT *PFNPDMDEVDESTRUCT;
73
* Device relocation callback.
75
* When this callback is called the device instance data, and if the
76
* device have a GC component, is being relocated, or/and the selectors
77
* have been changed. The device must use the chance to perform the
78
* necessary pointer relocations and data updates.
80
* Before the GC code is executed the first time, this function will be
81
* called with a 0 delta so GC pointer calculations can be one in one place.
83
* @param pDevIns Pointer to the device instance.
84
* @param offDelta The relocation delta relative to the old location.
86
* @remark A relocation CANNOT fail.
88
typedef DECLCALLBACK(void) FNPDMDEVRELOCATE(PPDMDEVINS pDevIns, RTGCINTPTR offDelta);
89
/** Pointer to a FNPDMDEVRELOCATE() function. */
90
typedef FNPDMDEVRELOCATE *PFNPDMDEVRELOCATE;
94
* Device I/O Control interface.
96
* This is used by external components, such as the COM interface, to
97
* communicate with devices using a class wide interface or a device
100
* @returns VBox status code.
101
* @param pDevIns Pointer to the device instance.
102
* @param uFunction Function to perform.
103
* @param pvIn Pointer to input data.
104
* @param cbIn Size of input data.
105
* @param pvOut Pointer to output data.
106
* @param cbOut Size of output data.
107
* @param pcbOut Where to store the actual size of the output data.
109
typedef DECLCALLBACK(int) FNPDMDEVIOCTL(PPDMDEVINS pDevIns, RTUINT uFunction,
110
void *pvIn, RTUINT cbIn,
111
void *pvOut, RTUINT cbOut, PRTUINT pcbOut);
112
/** Pointer to a FNPDMDEVIOCTL() function. */
113
typedef FNPDMDEVIOCTL *PFNPDMDEVIOCTL;
116
* Power On notification.
118
* @returns VBox status.
119
* @param pDevIns The device instance data.
121
typedef DECLCALLBACK(void) FNPDMDEVPOWERON(PPDMDEVINS pDevIns);
122
/** Pointer to a FNPDMDEVPOWERON() function. */
123
typedef FNPDMDEVPOWERON *PFNPDMDEVPOWERON;
126
* Reset notification.
128
* @returns VBox status.
129
* @param pDevIns The device instance data.
131
typedef DECLCALLBACK(void) FNPDMDEVRESET(PPDMDEVINS pDevIns);
132
/** Pointer to a FNPDMDEVRESET() function. */
133
typedef FNPDMDEVRESET *PFNPDMDEVRESET;
136
* Suspend notification.
138
* @returns VBox status.
139
* @param pDevIns The device instance data.
141
typedef DECLCALLBACK(void) FNPDMDEVSUSPEND(PPDMDEVINS pDevIns);
142
/** Pointer to a FNPDMDEVSUSPEND() function. */
143
typedef FNPDMDEVSUSPEND *PFNPDMDEVSUSPEND;
146
* Resume notification.
148
* @returns VBox status.
149
* @param pDevIns The device instance data.
151
typedef DECLCALLBACK(void) FNPDMDEVRESUME(PPDMDEVINS pDevIns);
152
/** Pointer to a FNPDMDEVRESUME() function. */
153
typedef FNPDMDEVRESUME *PFNPDMDEVRESUME;
156
* Power Off notification.
158
* @param pDevIns The device instance data.
160
typedef DECLCALLBACK(void) FNPDMDEVPOWEROFF(PPDMDEVINS pDevIns);
161
/** Pointer to a FNPDMDEVPOWEROFF() function. */
162
typedef FNPDMDEVPOWEROFF *PFNPDMDEVPOWEROFF;
167
* This is called to let the device attach to a driver for a specified LUN
168
* at runtime. This is not called during VM construction, the device
169
* constructor have to attach to all the available drivers.
171
* This is like plugging in the keyboard or mouse after turning on the PC.
173
* @returns VBox status code.
174
* @param pDevIns The device instance.
175
* @param iLUN The logical unit which is being detached.
177
typedef DECLCALLBACK(int) FNPDMDEVATTACH(PPDMDEVINS pDevIns, unsigned iLUN);
178
/** Pointer to a FNPDMDEVATTACH() function. */
179
typedef FNPDMDEVATTACH *PFNPDMDEVATTACH;
182
* Detach notification.
184
* This is called when a driver is detaching itself from a LUN of the device.
185
* The device should adjust it's state to reflect this.
187
* This is like unplugging the network cable to use it for the laptop or
188
* something while the PC is still running.
190
* @param pDevIns The device instance.
191
* @param iLUN The logical unit which is being detached.
193
typedef DECLCALLBACK(void) FNPDMDEVDETACH(PPDMDEVINS pDevIns, unsigned iLUN);
194
/** Pointer to a FNPDMDEVDETACH() function. */
195
typedef FNPDMDEVDETACH *PFNPDMDEVDETACH;
198
* Query the base interface of a logical unit.
200
* @returns VBOX status code.
201
* @param pDevIns The device instance.
202
* @param iLUN The logicial unit to query.
203
* @param ppBase Where to store the pointer to the base interface of the LUN.
205
typedef DECLCALLBACK(int) FNPDMDEVQUERYINTERFACE(PPDMDEVINS pDevIns, unsigned iLUN, PPDMIBASE *ppBase);
206
/** Pointer to a FNPDMDEVQUERYINTERFACE() function. */
207
typedef FNPDMDEVQUERYINTERFACE *PFNPDMDEVQUERYINTERFACE;
210
* Init complete notification.
211
* This can be done to do communication with other devices and other
212
* initialization which requires everything to be in place.
214
* @returns VBOX status code.
215
* @param pDevIns The device instance.
217
typedef DECLCALLBACK(int) FNPDMDEVINITCOMPLETE(PPDMDEVINS pDevIns);
218
/** Pointer to a FNPDMDEVINITCOMPLETE() function. */
219
typedef FNPDMDEVINITCOMPLETE *PFNPDMDEVINITCOMPLETE;
223
/** PDM Device Registration Structure,
224
* This structure is used when registering a device from
225
* VBoxInitDevices() in HC Ring-3. PDM will continue use till
226
* the VM is terminated.
228
typedef struct PDMDEVREG
230
/** Structure version. PDM_DEVREG_VERSION defines the current version. */
233
char szDeviceName[32];
234
/** Name of guest context module (no path).
235
* Only evalutated if PDM_DEVREG_FLAGS_GC is set. */
237
/** Name of guest context module (no path).
238
* Only evalutated if PDM_DEVREG_FLAGS_GC is set. */
240
/** The description of the device. The UTF-8 string pointed to shall, like this structure,
241
* remain unchanged from registration till VM destruction. */
242
const char *pszDescription;
244
/** Flags, combination of the PDM_DEVREG_FLAGS_* \#defines. */
246
/** Device class(es), combination of the PDM_DEVREG_CLASS_* \#defines. */
248
/** Maximum number of instances (per VM). */
249
RTUINT cMaxInstances;
250
/** Size of the instance data. */
253
/** Construct instance - required. */
254
PFNPDMDEVCONSTRUCT pfnConstruct;
255
/** Destruct instance - optional. */
256
PFNPDMDEVDESTRUCT pfnDestruct;
257
/** Relocation command - optional. */
258
PFNPDMDEVRELOCATE pfnRelocate;
259
/** I/O Control interface - optional. */
260
PFNPDMDEVIOCTL pfnIOCtl;
261
/** Power on notification - optional. */
262
PFNPDMDEVPOWERON pfnPowerOn;
263
/** Reset notification - optional. */
264
PFNPDMDEVRESET pfnReset;
265
/** Suspend notification - optional. */
266
PFNPDMDEVSUSPEND pfnSuspend;
267
/** Resume notification - optional. */
268
PFNPDMDEVRESUME pfnResume;
269
/** Attach command - optional. */
270
PFNPDMDEVATTACH pfnAttach;
271
/** Detach notification - optional. */
272
PFNPDMDEVDETACH pfnDetach;
273
/** Query a LUN base interface - optional. */
274
PFNPDMDEVQUERYINTERFACE pfnQueryInterface;
275
/** Init complete notification - optional. */
276
PFNPDMDEVINITCOMPLETE pfnInitComplete;
277
/** Power off notification - optional. */
278
PFNPDMDEVPOWEROFF pfnPowerOff;
280
/** Pointer to a PDM Device Structure. */
281
typedef PDMDEVREG *PPDMDEVREG;
282
/** Const pointer to a PDM Device Structure. */
283
typedef PDMDEVREG const *PCPDMDEVREG;
285
/** Current DEVREG version number. */
286
#define PDM_DEVREG_VERSION 0xc0010000
288
/** PDM Device Flags.
290
/** This flag is used to indicate that the device has a GC component. */
291
#define PDM_DEVREG_FLAGS_GC 0x00000001
292
/** This flag is used to indicate that the device has a R0 component. */
293
#define PDM_DEVREG_FLAGS_R0 0x00010000
295
/** @def PDM_DEVREG_FLAGS_HOST_BITS_DEFAULT
296
* The bit count for the current host. */
297
#if HC_ARCH_BITS == 32
298
# define PDM_DEVREG_FLAGS_HOST_BITS_DEFAULT 0x00000002
299
#elif HC_ARCH_BITS == 64
300
# define PDM_DEVREG_FLAGS_HOST_BITS_DEFAULT 0x00000004
302
# error Unsupported HC_ARCH_BITS value.
304
/** The host bit count mask. */
305
#define PDM_DEVREG_FLAGS_HOST_BITS_MASK 0x00000006
307
/** The device support only 32-bit guests. */
308
#define PDM_DEVREG_FLAGS_GUEST_BITS_32 0x00000008
309
/** The device support only 64-bit guests. */
310
#define PDM_DEVREG_FLAGS_GUEST_BITS_64 0x00000010
311
/** The device support both 32-bit & 64-bit guests. */
312
#define PDM_DEVREG_FLAGS_GUEST_BITS_32_64 0x00000018
313
/** @def PDM_DEVREG_FLAGS_GUEST_BITS_DEFAULT
314
* The guest bit count for the current compilation. */
315
#if GC_ARCH_BITS == 32
316
# define PDM_DEVREG_FLAGS_GUEST_BITS_DEFAULT PDM_DEVREG_FLAGS_GUEST_BITS_32
317
#elif GC_ARCH_BITS == 64
318
# define PDM_DEVREG_FLAGS_GUEST_BITS_DEFAULT PDM_DEVREG_FLAGS_GUEST_BITS_64
320
# error Unsupported GC_ARCH_BITS value.
322
/** The guest bit count mask. */
323
#define PDM_DEVREG_FLAGS_GUEST_BITS_MASK 0x00000018
325
/** Indicates that the devices support PAE36 on a 32-bit guest. */
326
#define PDM_DEVREG_FLAGS_PAE36 0x00000020
330
/** PDM Device Classes.
331
* The order is important, lower bit earlier instantiation.
333
/** Architecture device. */
334
#define PDM_DEVREG_CLASS_ARCH BIT(0)
335
/** Architecture BIOS device. */
336
#define PDM_DEVREG_CLASS_ARCH_BIOS BIT(1)
337
/** PCI bus brigde. */
338
#define PDM_DEVREG_CLASS_BUS_PCI BIT(2)
339
/** ISA bus brigde. */
340
#define PDM_DEVREG_CLASS_BUS_ISA BIT(3)
341
/** Input device (mouse, keyboard, joystick,..). */
342
#define PDM_DEVREG_CLASS_INPUT BIT(4)
343
/** Interrupt controller (PIC). */
344
#define PDM_DEVREG_CLASS_PIC BIT(5)
345
/** Interval controoler (PIT). */
346
#define PDM_DEVREG_CLASS_PIT BIT(6)
348
#define PDM_DEVREG_CLASS_RTC BIT(7)
349
/** DMA controller. */
350
#define PDM_DEVREG_CLASS_DMA BIT(8)
352
#define PDM_DEVREG_CLASS_VMM_DEV BIT(9)
353
/** Graphics device, like VGA. */
354
#define PDM_DEVREG_CLASS_GRAPHICS BIT(10)
355
/** Storage controller device. */
356
#define PDM_DEVREG_CLASS_STORAGE BIT(11)
357
/** Network interface controller. */
358
#define PDM_DEVREG_CLASS_NETWORK BIT(12)
360
#define PDM_DEVREG_CLASS_AUDIO BIT(13)
362
#define PDM_DEVREG_CLASS_BUS_USB BIT(14)
364
#define PDM_DEVREG_CLASS_ACPI BIT(15)
365
/** Serial controller device. */
366
#define PDM_DEVREG_CLASS_SERIAL BIT(16)
367
/** Parallel controller device */
368
#define PDM_DEVREG_CLASS_PARALLEL BIT(17)
369
/** Misc devices (always last). */
370
#define PDM_DEVREG_CLASS_MISC BIT(31)
374
/** @name IRQ Level for use with the *SetIrq APIs.
377
/** Assert the IRQ (can assume value 1). */
378
#define PDM_IRQ_LEVEL_HIGH BIT(0)
379
/** Deassert the IRQ (can assume value 0). */
380
#define PDM_IRQ_LEVEL_LOW 0
381
/** flip-flop - assert and then deassert it again immediately. */
382
#define PDM_IRQ_LEVEL_FLIP_FLOP (BIT(1) | PDM_IRQ_LEVEL_HIGH)
387
* PCI Bus registaration structure.
388
* All the callbacks, except the PCIBIOS hack, are working on PCI devices.
390
typedef struct PDMPCIBUSREG
392
/** Structure version number. PDM_PCIBUSREG_VERSION defines the current version. */
396
* Registers the device with the default PCI bus.
398
* @returns VBox status code.
399
* @param pDevIns Device instance of the PCI Bus.
400
* @param pPciDev The PCI device structure.
401
* Any PCI enabled device must keep this in it's instance data!
402
* Fill in the PCI data config before registration, please.
403
* @param pszName Pointer to device name (permanent, readonly). For debugging, not unique.
404
* @param iDev The device number ((dev << 3) | function) the device should have on the bus.
405
* If negative, the pci bus device will assign one.
407
DECLR3CALLBACKMEMBER(int, pfnRegisterHC,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, const char *pszName, int iDev));
410
* Registers a I/O region (memory mapped or I/O ports) for a PCI device.
412
* @returns VBox status code.
413
* @param pDevIns Device instance of the PCI Bus.
414
* @param pPciDev The PCI device structure.
415
* @param iRegion The region number.
416
* @param cbRegion Size of the region.
417
* @param iType PCI_ADDRESS_SPACE_MEM, PCI_ADDRESS_SPACE_IO or PCI_ADDRESS_SPACE_MEM_PREFETCH.
418
* @param pfnCallback Callback for doing the mapping.
420
DECLR3CALLBACKMEMBER(int, pfnIORegionRegisterHC,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, int iRegion, uint32_t cbRegion, PCIADDRESSSPACE enmType, PFNPCIIOREGIONMAP pfnCallback));
423
* Register PCI configuration space read/write callbacks.
425
* @param pDevIns Device instance of the PCI Bus.
426
* @param pPciDev The PCI device structure.
427
* @param pfnRead Pointer to the user defined PCI config read function.
428
* @param ppfnReadOld Pointer to function pointer which will receive the old (default)
429
* PCI config read function. This way, user can decide when (and if)
430
* to call default PCI config read function. Can be NULL.
431
* @param pfnWrite Pointer to the user defined PCI config write function.
432
* @param pfnWriteOld Pointer to function pointer which will receive the old (default)
433
* PCI config write function. This way, user can decide when (and if)
434
* to call default PCI config write function. Can be NULL.
437
DECLR3CALLBACKMEMBER(void, pfnSetConfigCallbacksHC,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, PFNPCICONFIGREAD pfnRead, PPFNPCICONFIGREAD ppfnReadOld,
438
PFNPCICONFIGWRITE pfnWrite, PPFNPCICONFIGWRITE ppfnWriteOld));
441
* Set the IRQ for a PCI device.
443
* @param pDevIns Device instance of the PCI Bus.
444
* @param pPciDev The PCI device structure.
445
* @param iIrq IRQ number to set.
446
* @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
448
DECLR3CALLBACKMEMBER(void, pfnSetIrqHC,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, int iIrq, int iLevel));
451
* Saves a state of the PCI device.
453
* @returns VBox status code.
454
* @param pDevIns Device instance of the PCI Bus.
455
* @param pPciDev Pointer to PCI device.
456
* @param pSSMHandle The handle to save the state to.
458
DECLR3CALLBACKMEMBER(int, pfnSaveExecHC,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, PSSMHANDLE pSSMHandle));
461
* Loads a saved PCI device state.
463
* @returns VBox status code.
464
* @param pDevIns Device instance of the PCI Bus.
465
* @param pPciDev Pointer to PCI device.
466
* @param pSSMHandle The handle to the saved state.
468
DECLR3CALLBACKMEMBER(int, pfnLoadExecHC,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, PSSMHANDLE pSSMHandle));
471
* Called to perform the job of the bios.
472
* This is only called for the first PCI Bus - it is expected to
473
* service all the PCI buses.
475
* @returns VBox status.
476
* @param pDevIns Device instance of the first bus.
478
DECLR3CALLBACKMEMBER(int, pfnFakePCIBIOSHC,(PPDMDEVINS pDevIns));
480
/** The name of the SetIrq GC entry point. */
481
const char *pszSetIrqGC;
483
/** The name of the SetIrq R0 entry point. */
484
const char *pszSetIrqR0;
487
/** Pointer to a PCI bus registration structure. */
488
typedef PDMPCIBUSREG *PPDMPCIBUSREG;
490
/** Current PDMPCIBUSREG version number. */
491
#define PDM_PCIBUSREG_VERSION 0xd0020000
494
* PCI Bus GC helpers.
496
typedef struct PDMPCIHLPGC
498
/** Structure version. PDM_PCIHLPGC_VERSION defines the current version. */
504
* @param pDevIns PCI device instance.
505
* @param iIrq IRQ number to set.
506
* @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
509
DECLGCCALLBACKMEMBER(void, pfnIsaSetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
512
* Set an I/O-APIC IRQ.
514
* @param pDevIns PCI device instance.
515
* @param iIrq IRQ number to set.
516
* @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
519
DECLGCCALLBACKMEMBER(void, pfnIoApicSetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
521
#ifdef VBOX_WITH_PDM_LOCK
523
* Acquires the PDM lock.
525
* @returns VINF_SUCCESS on success.
526
* @returns rc if we failed to acquire the lock.
527
* @param pDevIns The PCI device instance.
528
* @param rc What to return if we fail to acquire the lock.
530
DECLGCCALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
533
* Releases the PDM lock.
535
* @param pDevIns The PCI device instance.
537
DECLGCCALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
539
/** Just a safety precaution. */
542
/** Pointer to PCI helpers. */
543
typedef GCPTRTYPE(PDMPCIHLPGC *) PPDMPCIHLPGC;
544
/** Pointer to const PCI helpers. */
545
typedef GCPTRTYPE(const PDMPCIHLPGC *) PCPDMPCIHLPGC;
547
/** Current PDMPCIHLPR3 version number. */
548
#define PDM_PCIHLPGC_VERSION 0xe1010000
552
* PCI Bus R0 helpers.
554
typedef struct PDMPCIHLPR0
556
/** Structure version. PDM_PCIHLPR0_VERSION defines the current version. */
562
* @param pDevIns PCI device instance.
563
* @param iIrq IRQ number to set.
564
* @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
567
DECLR0CALLBACKMEMBER(void, pfnIsaSetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
570
* Set an I/O-APIC IRQ.
572
* @param pDevIns PCI device instance.
573
* @param iIrq IRQ number to set.
574
* @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
577
DECLR0CALLBACKMEMBER(void, pfnIoApicSetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
579
#ifdef VBOX_WITH_PDM_LOCK
581
* Acquires the PDM lock.
583
* @returns VINF_SUCCESS on success.
584
* @returns rc if we failed to acquire the lock.
585
* @param pDevIns The PCI device instance.
586
* @param rc What to return if we fail to acquire the lock.
588
DECLR0CALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
591
* Releases the PDM lock.
593
* @param pDevIns The PCI device instance.
595
DECLR0CALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
598
/** Just a safety precaution. */
601
/** Pointer to PCI helpers. */
602
typedef R0PTRTYPE(PDMPCIHLPR0 *) PPDMPCIHLPR0;
603
/** Pointer to const PCI helpers. */
604
typedef R0PTRTYPE(const PDMPCIHLPR0 *) PCPDMPCIHLPR0;
606
/** Current PDMPCIHLPR0 version number. */
607
#define PDM_PCIHLPR0_VERSION 0xe1010000
610
* PCI device helpers.
612
typedef struct PDMPCIHLPR3
614
/** Structure version. PDM_PCIHLPR3_VERSION defines the current version. */
620
* @param pDevIns The PCI device instance.
621
* @param iIrq IRQ number to set.
622
* @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
625
DECLR3CALLBACKMEMBER(void, pfnIsaSetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
628
* Set an I/O-APIC IRQ.
630
* @param pDevIns The PCI device instance.
631
* @param iIrq IRQ number to set.
632
* @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
635
DECLR3CALLBACKMEMBER(void, pfnIoApicSetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
637
#ifdef VBOX_WITH_PDM_LOCK
639
* Acquires the PDM lock.
641
* @returns VINF_SUCCESS on success.
642
* @returns Fatal error on failure.
643
* @param pDevIns The PCI device instance.
644
* @param rc Dummy for making the interface identical to the GC and R0 versions.
646
DECLR3CALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
649
* Releases the PDM lock.
651
* @param pDevIns The PCI device instance.
653
DECLR3CALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
657
* Gets the address of the GC PCI Bus helpers.
659
* This should be called at both construction and relocation time
660
* to obtain the correct address of the GC helpers.
662
* @returns GC pointer to the PCI Bus helpers.
663
* @param pDevIns Device instance of the PCI Bus.
666
DECLR3CALLBACKMEMBER(PCPDMPCIHLPGC, pfnGetGCHelpers,(PPDMDEVINS pDevIns));
669
* Gets the address of the R0 PCI Bus helpers.
671
* This should be called at both construction and relocation time
672
* to obtain the correct address of the GC helpers.
674
* @returns R0 pointer to the PCI Bus helpers.
675
* @param pDevIns Device instance of the PCI Bus.
678
DECLR3CALLBACKMEMBER(PCPDMPCIHLPR0, pfnGetR0Helpers,(PPDMDEVINS pDevIns));
680
/** Just a safety precaution. */
683
/** Pointer to PCI helpers. */
684
typedef HCPTRTYPE(PDMPCIHLPR3 *) PPDMPCIHLPR3;
685
/** Pointer to const PCI helpers. */
686
typedef HCPTRTYPE(const PDMPCIHLPR3 *) PCPDMPCIHLPR3;
688
/** Current PDMPCIHLPR3 version number. */
689
#define PDM_PCIHLPR3_VERSION 0xf1010000
693
* Programmable Interrupt Controller registration structure.
695
typedef struct PDMPICREG
697
/** Structure version number. PDM_PICREG_VERSION defines the current version. */
703
* @param pDevIns Device instance of the PIC.
704
* @param iIrq IRQ number to set.
705
* @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
707
DECLR3CALLBACKMEMBER(void, pfnSetIrqHC,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
710
* Get a pending interrupt.
712
* @returns Pending interrupt number.
713
* @param pDevIns Device instance of the PIC.
715
DECLR3CALLBACKMEMBER(int, pfnGetInterruptHC,(PPDMDEVINS pDevIns));
717
/** The name of the GC SetIrq entry point. */
718
const char *pszSetIrqGC;
719
/** The name of the GC GetInterrupt entry point. */
720
const char *pszGetInterruptGC;
722
/** The name of the R0 SetIrq entry point. */
723
const char *pszSetIrqR0;
724
/** The name of the R0 GetInterrupt entry point. */
725
const char *pszGetInterruptR0;
727
/** Pointer to a PIC registration structure. */
728
typedef PDMPICREG *PPDMPICREG;
730
/** Current PDMPICREG version number. */
731
#define PDM_PICREG_VERSION 0xe0020000
736
typedef struct PDMPICHLPGC
738
/** Structure version. PDM_PICHLPGC_VERSION defines the current version. */
742
* Set the interrupt force action flag.
744
* @param pDevIns Device instance of the PIC.
746
DECLGCCALLBACKMEMBER(void, pfnSetInterruptFF,(PPDMDEVINS pDevIns));
749
* Clear the interrupt force action flag.
751
* @param pDevIns Device instance of the PIC.
753
DECLGCCALLBACKMEMBER(void, pfnClearInterruptFF,(PPDMDEVINS pDevIns));
755
#ifdef VBOX_WITH_PDM_LOCK
757
* Acquires the PDM lock.
759
* @returns VINF_SUCCESS on success.
760
* @returns rc if we failed to acquire the lock.
761
* @param pDevIns The PIC device instance.
762
* @param rc What to return if we fail to acquire the lock.
764
DECLGCCALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
767
* Releases the PDM lock.
769
* @param pDevIns The PIC device instance.
771
DECLGCCALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
773
/** Just a safety precaution. */
777
/** Pointer to PIC GC helpers. */
778
typedef GCPTRTYPE(PDMPICHLPGC *) PPDMPICHLPGC;
779
/** Pointer to const PIC GC helpers. */
780
typedef GCPTRTYPE(const PDMPICHLPGC *) PCPDMPICHLPGC;
782
/** Current PDMPICHLPGC version number. */
783
#define PDM_PICHLPGC_VERSION 0xfc010000
789
typedef struct PDMPICHLPR0
791
/** Structure version. PDM_PICHLPR0_VERSION defines the current version. */
795
* Set the interrupt force action flag.
797
* @param pDevIns Device instance of the PIC.
799
DECLR0CALLBACKMEMBER(void, pfnSetInterruptFF,(PPDMDEVINS pDevIns));
802
* Clear the interrupt force action flag.
804
* @param pDevIns Device instance of the PIC.
806
DECLR0CALLBACKMEMBER(void, pfnClearInterruptFF,(PPDMDEVINS pDevIns));
808
#ifdef VBOX_WITH_PDM_LOCK
810
* Acquires the PDM lock.
812
* @returns VINF_SUCCESS on success.
813
* @returns rc if we failed to acquire the lock.
814
* @param pDevIns The PIC device instance.
815
* @param rc What to return if we fail to acquire the lock.
817
DECLR0CALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
820
* Releases the PDM lock.
822
* @param pDevIns The PCI device instance.
824
DECLR0CALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
827
/** Just a safety precaution. */
831
/** Pointer to PIC R0 helpers. */
832
typedef R0PTRTYPE(PDMPICHLPR0 *) PPDMPICHLPR0;
833
/** Pointer to const PIC R0 helpers. */
834
typedef R0PTRTYPE(const PDMPICHLPR0 *) PCPDMPICHLPR0;
836
/** Current PDMPICHLPR0 version number. */
837
#define PDM_PICHLPR0_VERSION 0xfc010000
842
typedef struct PDMPICHLPR3
844
/** Structure version. PDM_PICHLP_VERSION defines the current version. */
848
* Set the interrupt force action flag.
850
* @param pDevIns Device instance of the PIC.
852
DECLR3CALLBACKMEMBER(void, pfnSetInterruptFF,(PPDMDEVINS pDevIns));
855
* Clear the interrupt force action flag.
857
* @param pDevIns Device instance of the PIC.
859
DECLR3CALLBACKMEMBER(void, pfnClearInterruptFF,(PPDMDEVINS pDevIns));
861
#ifdef VBOX_WITH_PDM_LOCK
863
* Acquires the PDM lock.
865
* @returns VINF_SUCCESS on success.
866
* @returns Fatal error on failure.
867
* @param pDevIns The PIC device instance.
868
* @param rc Dummy for making the interface identical to the GC and R0 versions.
870
DECLR3CALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
873
* Releases the PDM lock.
875
* @param pDevIns The PIC device instance.
877
DECLR3CALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
881
* Gets the address of the GC PIC helpers.
883
* This should be called at both construction and relocation time
884
* to obtain the correct address of the GC helpers.
886
* @returns GC pointer to the PIC helpers.
887
* @param pDevIns Device instance of the PIC.
889
DECLR3CALLBACKMEMBER(PCPDMPICHLPGC, pfnGetGCHelpers,(PPDMDEVINS pDevIns));
892
* Gets the address of the R0 PIC helpers.
894
* This should be called at both construction and relocation time
895
* to obtain the correct address of the GC helpers.
897
* @returns R0 pointer to the PIC helpers.
898
* @param pDevIns Device instance of the PIC.
900
DECLR3CALLBACKMEMBER(PCPDMPICHLPR0, pfnGetR0Helpers,(PPDMDEVINS pDevIns));
902
/** Just a safety precaution. */
906
/** Pointer to PIC HC helpers. */
907
typedef HCPTRTYPE(PDMPICHLPR3 *) PPDMPICHLPR3;
908
/** Pointer to const PIC HC helpers. */
909
typedef HCPTRTYPE(const PDMPICHLPR3 *) PCPDMPICHLPR3;
911
/** Current PDMPICHLPR3 version number. */
912
#define PDM_PICHLPR3_VERSION 0xf0010000
917
* Advanced Programmable Interrupt Controller registration structure.
919
typedef struct PDMAPICREG
921
/** Structure version number. PDM_APICREG_VERSION defines the current version. */
925
* Get a pending interrupt.
927
* @returns Pending interrupt number.
928
* @param pDevIns Device instance of the APIC.
930
DECLR3CALLBACKMEMBER(int, pfnGetInterruptHC,(PPDMDEVINS pDevIns));
935
* @param pDevIns Device instance of the APIC.
936
* @param u64Base The new base.
938
DECLR3CALLBACKMEMBER(void, pfnSetBaseHC,(PPDMDEVINS pDevIns, uint64_t u64Base));
943
* @returns Current base.
944
* @param pDevIns Device instance of the APIC.
946
DECLR3CALLBACKMEMBER(uint64_t, pfnGetBaseHC,(PPDMDEVINS pDevIns));
949
* Set the TPR (task priority register?).
951
* @param pDevIns Device instance of the APIC.
952
* @param u8TPR The new TPR.
954
DECLR3CALLBACKMEMBER(void, pfnSetTPRHC,(PPDMDEVINS pDevIns, uint8_t u8TPR));
957
* Get the TPR (task priority register?).
959
* @returns The current TPR.
960
* @param pDevIns Device instance of the APIC.
962
DECLR3CALLBACKMEMBER(uint8_t, pfnGetTPRHC,(PPDMDEVINS pDevIns));
965
* Private interface between the IOAPIC and APIC.
967
* This is a low-level, APIC/IOAPIC implementation specific interface
968
* which is registered with PDM only because it makes life so much
969
* simpler right now (GC bits). This is a bad bad hack! The correct
970
* way of doing this would involve some way of querying GC interfaces
971
* and relocating them. Perhaps doing some kind of device init in GC...
973
* @returns The current TPR.
974
* @param pDevIns Device instance of the APIC.
975
* @param u8Dest See APIC implementation.
976
* @param u8DestMode See APIC implementation.
977
* @param u8DeliveryMode See APIC implementation.
978
* @param iVector See APIC implementation.
979
* @param u8Polarity See APIC implementation.
980
* @param u8TriggerMode See APIC implementation.
982
DECLR3CALLBACKMEMBER(void, pfnBusDeliverHC,(PPDMDEVINS pDevIns, uint8_t u8Dest, uint8_t u8DestMode, uint8_t u8DeliveryMode,
983
uint8_t iVector, uint8_t u8Polarity, uint8_t u8TriggerMode));
985
/** The name of the GC GetInterrupt entry point. */
986
const char *pszGetInterruptGC;
987
/** The name of the GC SetBase entry point. */
988
const char *pszSetBaseGC;
989
/** The name of the GC GetBase entry point. */
990
const char *pszGetBaseGC;
991
/** The name of the GC SetTPR entry point. */
992
const char *pszSetTPRGC;
993
/** The name of the GC GetTPR entry point. */
994
const char *pszGetTPRGC;
995
/** The name of the GC BusDeliver entry point. */
996
const char *pszBusDeliverGC;
998
/** The name of the R0 GetInterrupt entry point. */
999
const char *pszGetInterruptR0;
1000
/** The name of the R0 SetBase entry point. */
1001
const char *pszSetBaseR0;
1002
/** The name of the R0 GetBase entry point. */
1003
const char *pszGetBaseR0;
1004
/** The name of the R0 SetTPR entry point. */
1005
const char *pszSetTPRR0;
1006
/** The name of the R0 GetTPR entry point. */
1007
const char *pszGetTPRR0;
1008
/** The name of the R0 BusDeliver entry point. */
1009
const char *pszBusDeliverR0;
1012
/** Pointer to an APIC registration structure. */
1013
typedef PDMAPICREG *PPDMAPICREG;
1015
/** Current PDMAPICREG version number. */
1016
#define PDM_APICREG_VERSION 0x70010000
1022
typedef struct PDMAPICHLPGC
1024
/** Structure version. PDM_APICHLPGC_VERSION defines the current version. */
1025
uint32_t u32Version;
1028
* Set the interrupt force action flag.
1030
* @param pDevIns Device instance of the APIC.
1032
DECLGCCALLBACKMEMBER(void, pfnSetInterruptFF,(PPDMDEVINS pDevIns));
1035
* Clear the interrupt force action flag.
1037
* @param pDevIns Device instance of the APIC.
1039
DECLGCCALLBACKMEMBER(void, pfnClearInterruptFF,(PPDMDEVINS pDevIns));
1042
* Sets or clears the APIC bit in the CPUID feature masks.
1044
* @param pDevIns Device instance of the APIC.
1045
* @param fEnabled If true the bit is set, else cleared.
1047
DECLGCCALLBACKMEMBER(void, pfnChangeFeature,(PPDMDEVINS pDevIns, bool fEnabled));
1049
#ifdef VBOX_WITH_PDM_LOCK
1051
* Acquires the PDM lock.
1053
* @returns VINF_SUCCESS on success.
1054
* @returns rc if we failed to acquire the lock.
1055
* @param pDevIns The APIC device instance.
1056
* @param rc What to return if we fail to acquire the lock.
1058
DECLGCCALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
1061
* Releases the PDM lock.
1063
* @param pDevIns The APIC device instance.
1065
DECLGCCALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
1067
/** Just a safety precaution. */
1070
/** Pointer to APIC GC helpers. */
1071
typedef GCPTRTYPE(PDMAPICHLPGC *) PPDMAPICHLPGC;
1072
/** Pointer to const APIC helpers. */
1073
typedef GCPTRTYPE(const PDMAPICHLPGC *) PCPDMAPICHLPGC;
1075
/** Current PDMAPICHLPGC version number. */
1076
#define PDM_APICHLPGC_VERSION 0x60010000
1082
typedef struct PDMAPICHLPR0
1084
/** Structure version. PDM_APICHLPR0_VERSION defines the current version. */
1085
uint32_t u32Version;
1088
* Set the interrupt force action flag.
1090
* @param pDevIns Device instance of the APIC.
1092
DECLR0CALLBACKMEMBER(void, pfnSetInterruptFF,(PPDMDEVINS pDevIns));
1095
* Clear the interrupt force action flag.
1097
* @param pDevIns Device instance of the APIC.
1099
DECLR0CALLBACKMEMBER(void, pfnClearInterruptFF,(PPDMDEVINS pDevIns));
1102
* Sets or clears the APIC bit in the CPUID feature masks.
1104
* @param pDevIns Device instance of the APIC.
1105
* @param fEnabled If true the bit is set, else cleared.
1107
DECLR0CALLBACKMEMBER(void, pfnChangeFeature,(PPDMDEVINS pDevIns, bool fEnabled));
1109
#ifdef VBOX_WITH_PDM_LOCK
1111
* Acquires the PDM lock.
1113
* @returns VINF_SUCCESS on success.
1114
* @returns rc if we failed to acquire the lock.
1115
* @param pDevIns The APIC device instance.
1116
* @param rc What to return if we fail to acquire the lock.
1118
DECLR0CALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
1121
* Releases the PDM lock.
1123
* @param pDevIns The APIC device instance.
1125
DECLR0CALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
1128
/** Just a safety precaution. */
1131
/** Pointer to APIC GC helpers. */
1132
typedef GCPTRTYPE(PDMAPICHLPR0 *) PPDMAPICHLPR0;
1133
/** Pointer to const APIC helpers. */
1134
typedef R0PTRTYPE(const PDMAPICHLPR0 *) PCPDMAPICHLPR0;
1136
/** Current PDMAPICHLPR0 version number. */
1137
#define PDM_APICHLPR0_VERSION 0x60010000
1142
typedef struct PDMAPICHLPR3
1144
/** Structure version. PDM_APICHLPR3_VERSION defines the current version. */
1145
uint32_t u32Version;
1148
* Set the interrupt force action flag.
1150
* @param pDevIns Device instance of the APIC.
1152
DECLR3CALLBACKMEMBER(void, pfnSetInterruptFF,(PPDMDEVINS pDevIns));
1155
* Clear the interrupt force action flag.
1157
* @param pDevIns Device instance of the APIC.
1159
DECLR3CALLBACKMEMBER(void, pfnClearInterruptFF,(PPDMDEVINS pDevIns));
1162
* Sets or clears the APIC bit in the CPUID feature masks.
1164
* @param pDevIns Device instance of the APIC.
1165
* @param fEnabled If true the bit is set, else cleared.
1167
DECLR3CALLBACKMEMBER(void, pfnChangeFeature,(PPDMDEVINS pDevIns, bool fEnabled));
1169
#ifdef VBOX_WITH_PDM_LOCK
1171
* Acquires the PDM lock.
1173
* @returns VINF_SUCCESS on success.
1174
* @returns Fatal error on failure.
1175
* @param pDevIns The APIC device instance.
1176
* @param rc Dummy for making the interface identical to the GC and R0 versions.
1178
DECLR3CALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
1181
* Releases the PDM lock.
1183
* @param pDevIns The APIC device instance.
1185
DECLR3CALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
1189
* Gets the address of the GC APIC helpers.
1191
* This should be called at both construction and relocation time
1192
* to obtain the correct address of the GC helpers.
1194
* @returns GC pointer to the APIC helpers.
1195
* @param pDevIns Device instance of the APIC.
1197
DECLR3CALLBACKMEMBER(PCPDMAPICHLPGC, pfnGetGCHelpers,(PPDMDEVINS pDevIns));
1200
* Gets the address of the R0 APIC helpers.
1202
* This should be called at both construction and relocation time
1203
* to obtain the correct address of the R0 helpers.
1205
* @returns R0 pointer to the APIC helpers.
1206
* @param pDevIns Device instance of the APIC.
1208
DECLR3CALLBACKMEMBER(PCPDMAPICHLPR0, pfnGetR0Helpers,(PPDMDEVINS pDevIns));
1210
/** Just a safety precaution. */
1213
/** Pointer to APIC helpers. */
1214
typedef HCPTRTYPE(PDMAPICHLPR3 *) PPDMAPICHLPR3;
1215
/** Pointer to const APIC helpers. */
1216
typedef HCPTRTYPE(const PDMAPICHLPR3 *) PCPDMAPICHLPR3;
1218
/** Current PDMAPICHLP version number. */
1219
#define PDM_APICHLPR3_VERSION 0xfd010000
1223
* I/O APIC registration structure.
1225
typedef struct PDMIOAPICREG
1227
/** Struct version+magic number (PDM_IOAPICREG_VERSION). */
1228
uint32_t u32Version;
1233
* @param pDevIns Device instance of the I/O APIC.
1234
* @param iIrq IRQ number to set.
1235
* @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
1237
DECLR3CALLBACKMEMBER(void, pfnSetIrqHC,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
1239
/** The name of the GC SetIrq entry point. */
1240
const char *pszSetIrqGC;
1242
/** The name of the R0 SetIrq entry point. */
1243
const char *pszSetIrqR0;
1245
/** Pointer to an APIC registration structure. */
1246
typedef PDMIOAPICREG *PPDMIOAPICREG;
1248
/** Current PDMAPICREG version number. */
1249
#define PDM_IOAPICREG_VERSION 0x50010000
1253
* IOAPIC GC helpers.
1255
typedef struct PDMIOAPICHLPGC
1257
/** Structure version. PDM_IOAPICHLPGC_VERSION defines the current version. */
1258
uint32_t u32Version;
1261
* Private interface between the IOAPIC and APIC.
1263
* See comments about this hack on PDMAPICREG::pfnBusDeliverHC.
1265
* @returns The current TPR.
1266
* @param pDevIns Device instance of the IOAPIC.
1267
* @param u8Dest See APIC implementation.
1268
* @param u8DestMode See APIC implementation.
1269
* @param u8DeliveryMode See APIC implementation.
1270
* @param iVector See APIC implementation.
1271
* @param u8Polarity See APIC implementation.
1272
* @param u8TriggerMode See APIC implementation.
1274
DECLGCCALLBACKMEMBER(void, pfnApicBusDeliver,(PPDMDEVINS pDevIns, uint8_t u8Dest, uint8_t u8DestMode, uint8_t u8DeliveryMode,
1275
uint8_t iVector, uint8_t u8Polarity, uint8_t u8TriggerMode));
1277
#ifdef VBOX_WITH_PDM_LOCK
1279
* Acquires the PDM lock.
1281
* @returns VINF_SUCCESS on success.
1282
* @returns rc if we failed to acquire the lock.
1283
* @param pDevIns The IOAPIC device instance.
1284
* @param rc What to return if we fail to acquire the lock.
1286
DECLGCCALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
1289
* Releases the PDM lock.
1291
* @param pDevIns The IOAPIC device instance.
1293
DECLGCCALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
1296
/** Just a safety precaution. */
1299
/** Pointer to IOAPIC GC helpers. */
1300
typedef GCPTRTYPE(PDMAPICHLPGC *)PPDMIOAPICHLPGC;
1301
/** Pointer to const IOAPIC helpers. */
1302
typedef GCPTRTYPE(const PDMIOAPICHLPGC *) PCPDMIOAPICHLPGC;
1304
/** Current PDMIOAPICHLPGC version number. */
1305
#define PDM_IOAPICHLPGC_VERSION 0xfe010000
1309
* IOAPIC R0 helpers.
1311
typedef struct PDMIOAPICHLPR0
1313
/** Structure version. PDM_IOAPICHLPR0_VERSION defines the current version. */
1314
uint32_t u32Version;
1317
* Private interface between the IOAPIC and APIC.
1319
* See comments about this hack on PDMAPICREG::pfnBusDeliverHC.
1321
* @returns The current TPR.
1322
* @param pDevIns Device instance of the IOAPIC.
1323
* @param u8Dest See APIC implementation.
1324
* @param u8DestMode See APIC implementation.
1325
* @param u8DeliveryMode See APIC implementation.
1326
* @param iVector See APIC implementation.
1327
* @param u8Polarity See APIC implementation.
1328
* @param u8TriggerMode See APIC implementation.
1330
DECLR0CALLBACKMEMBER(void, pfnApicBusDeliver,(PPDMDEVINS pDevIns, uint8_t u8Dest, uint8_t u8DestMode, uint8_t u8DeliveryMode,
1331
uint8_t iVector, uint8_t u8Polarity, uint8_t u8TriggerMode));
1333
#ifdef VBOX_WITH_PDM_LOCK
1335
* Acquires the PDM lock.
1337
* @returns VINF_SUCCESS on success.
1338
* @returns rc if we failed to acquire the lock.
1339
* @param pDevIns The IOAPIC device instance.
1340
* @param rc What to return if we fail to acquire the lock.
1342
DECLR0CALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
1345
* Releases the PDM lock.
1347
* @param pDevIns The IOAPIC device instance.
1349
DECLR0CALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
1352
/** Just a safety precaution. */
1355
/** Pointer to IOAPIC R0 helpers. */
1356
typedef R0PTRTYPE(PDMAPICHLPGC *) PPDMIOAPICHLPR0;
1357
/** Pointer to const IOAPIC helpers. */
1358
typedef R0PTRTYPE(const PDMIOAPICHLPR0 *) PCPDMIOAPICHLPR0;
1360
/** Current PDMIOAPICHLPR0 version number. */
1361
#define PDM_IOAPICHLPR0_VERSION 0xfe010000
1364
* IOAPIC HC helpers.
1366
typedef struct PDMIOAPICHLPR3
1368
/** Structure version. PDM_IOAPICHLPR3_VERSION defines the current version. */
1369
uint32_t u32Version;
1372
* Private interface between the IOAPIC and APIC.
1374
* See comments about this hack on PDMAPICREG::pfnBusDeliverHC.
1376
* @returns The current TPR.
1377
* @param pDevIns Device instance of the IOAPIC.
1378
* @param u8Dest See APIC implementation.
1379
* @param u8DestMode See APIC implementation.
1380
* @param u8DeliveryMode See APIC implementation.
1381
* @param iVector See APIC implementation.
1382
* @param u8Polarity See APIC implementation.
1383
* @param u8TriggerMode See APIC implementation.
1385
DECLR3CALLBACKMEMBER(void, pfnApicBusDeliver,(PPDMDEVINS pDevIns, uint8_t u8Dest, uint8_t u8DestMode, uint8_t u8DeliveryMode,
1386
uint8_t iVector, uint8_t u8Polarity, uint8_t u8TriggerMode));
1388
#ifdef VBOX_WITH_PDM_LOCK
1390
* Acquires the PDM lock.
1392
* @returns VINF_SUCCESS on success.
1393
* @returns Fatal error on failure.
1394
* @param pDevIns The IOAPIC device instance.
1395
* @param rc Dummy for making the interface identical to the GC and R0 versions.
1397
DECLR3CALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
1400
* Releases the PDM lock.
1402
* @param pDevIns The IOAPIC device instance.
1404
DECLR3CALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
1408
* Gets the address of the GC IOAPIC helpers.
1410
* This should be called at both construction and relocation time
1411
* to obtain the correct address of the GC helpers.
1413
* @returns GC pointer to the IOAPIC helpers.
1414
* @param pDevIns Device instance of the IOAPIC.
1416
DECLR3CALLBACKMEMBER(PCPDMIOAPICHLPGC, pfnGetGCHelpers,(PPDMDEVINS pDevIns));
1419
* Gets the address of the R0 IOAPIC helpers.
1421
* This should be called at both construction and relocation time
1422
* to obtain the correct address of the R0 helpers.
1424
* @returns R0 pointer to the IOAPIC helpers.
1425
* @param pDevIns Device instance of the IOAPIC.
1427
DECLR3CALLBACKMEMBER(PCPDMIOAPICHLPR0, pfnGetR0Helpers,(PPDMDEVINS pDevIns));
1429
/** Just a safety precaution. */
1432
/** Pointer to IOAPIC HC helpers. */
1433
typedef HCPTRTYPE(PDMIOAPICHLPR3 *) PPDMIOAPICHLPR3;
1434
/** Pointer to const IOAPIC helpers. */
1435
typedef HCPTRTYPE(const PDMIOAPICHLPR3 *) PCPDMIOAPICHLPR3;
1437
/** Current PDMIOAPICHLPR3 version number. */
1438
#define PDM_IOAPICHLPR3_VERSION 0xff010000
1445
* DMA Transfer Handler.
1447
* @returns Number of bytes transferred.
1448
* @param pDevIns Device instance of the DMA.
1449
* @param pvUser User pointer.
1450
* @param uChannel Channel number.
1451
* @param off DMA position.
1452
* @param cb Block size.
1454
typedef DECLCALLBACK(uint32_t) FNDMATRANSFERHANDLER(PPDMDEVINS pDevIns, void *pvUser, unsigned uChannel, uint32_t off, uint32_t cb);
1455
/** Pointer to a FNDMATRANSFERHANDLER(). */
1456
typedef FNDMATRANSFERHANDLER *PFNDMATRANSFERHANDLER;
1459
* DMA Controller registration structure.
1461
typedef struct PDMDMAREG
1463
/** Structure version number. PDM_DMACREG_VERSION defines the current version. */
1464
uint32_t u32Version;
1467
* Execute pending transfers.
1469
* @returns A more work indiciator. I.e. 'true' if there is more to be done, and 'false' if all is done.
1470
* @param pDevIns Device instance of the DMAC.
1472
DECLR3CALLBACKMEMBER(bool, pfnRun,(PPDMDEVINS pDevIns));
1475
* Register transfer function for DMA channel.
1477
* @param pDevIns Device instance of the DMAC.
1478
* @param uChannel Channel number.
1479
* @param pfnTransferHandler Device specific transfer function.
1480
* @param pvUSer User pointer to be passed to the callback.
1482
DECLR3CALLBACKMEMBER(void, pfnRegister,(PPDMDEVINS pDevIns, unsigned uChannel, PFNDMATRANSFERHANDLER pfnTransferHandler, void *pvUser));
1487
* @returns Number of bytes read.
1488
* @param pDevIns Device instance of the DMAC.
1489
* @param pvBuffer Pointer to target buffer.
1490
* @param off DMA position.
1491
* @param cbBlock Block size.
1493
DECLR3CALLBACKMEMBER(uint32_t, pfnReadMemory,(PPDMDEVINS pDevIns, unsigned uChannel, void *pvBuffer, uint32_t off, uint32_t cbBlock));
1498
* @returns Number of bytes written.
1499
* @param pDevIns Device instance of the DMAC.
1500
* @param pvBuffer Memory to write.
1501
* @param off DMA position.
1502
* @param cbBlock Block size.
1504
DECLR3CALLBACKMEMBER(uint32_t, pfnWriteMemory,(PPDMDEVINS pDevIns, unsigned uChannel, const void *pvBuffer, uint32_t off, uint32_t cbBlock));
1507
* Set the DREQ line.
1509
* @param pDevIns Device instance of the DMAC.
1510
* @param uChannel Channel number.
1511
* @param uLevel Level of the line.
1513
DECLR3CALLBACKMEMBER(void, pfnSetDREQ,(PPDMDEVINS pDevIns, unsigned uChannel, unsigned uLevel));
1518
* @returns Channel mode.
1519
* @param pDevIns Device instance of the DMAC.
1520
* @param uChannel Channel number.
1522
DECLR3CALLBACKMEMBER(uint8_t, pfnGetChannelMode,(PPDMDEVINS pDevIns, unsigned uChannel));
1525
/** Pointer to a DMAC registration structure. */
1526
typedef PDMDMACREG *PPDMDMACREG;
1528
/** Current PDMDMACREG version number. */
1529
#define PDM_DMACREG_VERSION 0xf5010000
1533
* DMA Controller device helpers.
1535
typedef struct PDMDMACHLP
1537
/** Structure version. PDM_DMACHLP_VERSION defines the current version. */
1538
uint32_t u32Version;
1543
/** Pointer to DMAC helpers. */
1544
typedef PDMDMACHLP *PPDMDMACHLP;
1545
/** Pointer to const DMAC helpers. */
1546
typedef const PDMDMACHLP *PCPDMDMACHLP;
1548
/** Current PDMDMACHLP version number. */
1549
#define PDM_DMACHLP_VERSION 0xf6010000
1551
#endif /* IN_RING3 */
1556
* RTC registration structure.
1558
typedef struct PDMRTCREG
1560
/** Structure version number. PDM_RTCREG_VERSION defines the current version. */
1561
uint32_t u32Version;
1562
uint32_t u32Alignment; /**< structure size alignment. */
1565
* Write to a CMOS register and update the checksum if necessary.
1567
* @returns VBox status code.
1568
* @param pDevIns Device instance of the RTC.
1569
* @param iReg The CMOS register index.
1570
* @param u8Value The CMOS register value.
1572
DECLR3CALLBACKMEMBER(int, pfnWrite,(PPDMDEVINS pDevIns, unsigned iReg, uint8_t u8Value));
1575
* Read a CMOS register.
1577
* @returns VBox status code.
1578
* @param pDevIns Device instance of the RTC.
1579
* @param iReg The CMOS register index.
1580
* @param pu8Value Where to store the CMOS register value.
1582
DECLR3CALLBACKMEMBER(int, pfnRead,(PPDMDEVINS pDevIns, unsigned iReg, uint8_t *pu8Value));
1585
/** Pointer to a RTC registration structure. */
1586
typedef PDMRTCREG *PPDMRTCREG;
1587
/** Pointer to a const RTC registration structure. */
1588
typedef const PDMRTCREG *PCPDMRTCREG;
1590
/** Current PDMRTCREG version number. */
1591
#define PDM_RTCREG_VERSION 0xfa010000
1595
* RTC device helpers.
1597
typedef struct PDMRTCHLP
1599
/** Structure version. PDM_RTCHLP_VERSION defines the current version. */
1600
uint32_t u32Version;
1605
/** Pointer to RTC helpers. */
1606
typedef PDMRTCHLP *PPDMRTCHLP;
1607
/** Pointer to const RTC helpers. */
1608
typedef const PDMRTCHLP *PCPDMRTCHLP;
1610
/** Current PDMRTCHLP version number. */
1611
#define PDM_RTCHLP_VERSION 0xf6010000
1620
typedef struct PDMDEVHLP
1622
/** Structure version. PDM_DEVHLP_VERSION defines the current version. */
1623
uint32_t u32Version;
1626
* Register a number of I/O ports with a device.
1628
* These callbacks are of course for the host context (HC).
1629
* Register HC handlers before guest context (GC) handlers! There must be a
1630
* HC handler for every GC handler!
1632
* @returns VBox status.
1633
* @param pDevIns The device instance to register the ports with.
1634
* @param Port First port number in the range.
1635
* @param cPorts Number of ports to register.
1636
* @param pvUser User argument.
1637
* @param pfnOut Pointer to function which is gonna handle OUT operations.
1638
* @param pfnIn Pointer to function which is gonna handle IN operations.
1639
* @param pfnOutStr Pointer to function which is gonna handle string OUT operations.
1640
* @param pfnInStr Pointer to function which is gonna handle string IN operations.
1641
* @param pszDesc Pointer to description string. This must not be freed.
1643
DECLR3CALLBACKMEMBER(int, pfnIOPortRegister,(PPDMDEVINS pDevIns, RTIOPORT Port, RTUINT cPorts, RTHCPTR pvUser,
1644
PFNIOMIOPORTOUT pfnOut, PFNIOMIOPORTIN pfnIn,
1645
PFNIOMIOPORTOUTSTRING pfnOutStr, PFNIOMIOPORTINSTRING pfnInStr, const char *pszDesc));
1648
* Register a number of I/O ports with a device for GC.
1650
* These callbacks are for the host context (GC).
1651
* Register host context (HC) handlers before guest context handlers! There must be a
1652
* HC handler for every GC handler!
1654
* @returns VBox status.
1655
* @param pDevIns The device instance to register the ports with and which GC module
1656
* to resolve the names against.
1657
* @param Port First port number in the range.
1658
* @param cPorts Number of ports to register.
1659
* @param pvUser User argument.
1660
* @param pszOut Name of the GC function which is gonna handle OUT operations.
1661
* @param pszIn Name of the GC function which is gonna handle IN operations.
1662
* @param pszOutStr Name of the GC function which is gonna handle string OUT operations.
1663
* @param pszInStr Name of the GC function which is gonna handle string IN operations.
1664
* @param pszDesc Pointer to description string. This must not be freed.
1666
DECLR3CALLBACKMEMBER(int, pfnIOPortRegisterGC,(PPDMDEVINS pDevIns, RTIOPORT Port, RTUINT cPorts, RTGCPTR pvUser,
1667
const char *pszOut, const char *pszIn,
1668
const char *pszOutStr, const char *pszInStr, const char *pszDesc));
1671
* Register a number of I/O ports with a device.
1673
* These callbacks are of course for the ring-0 host context (R0).
1674
* Register R3 (HC) handlers before R0 (R0) handlers! There must be a R3 (HC) handler for every R0 handler!
1676
* @returns VBox status.
1677
* @param pDevIns The device instance to register the ports with.
1678
* @param Port First port number in the range.
1679
* @param cPorts Number of ports to register.
1680
* @param pvUser User argument. (if pointer, then it must be in locked memory!)
1681
* @param pszOut Name of the R0 function which is gonna handle OUT operations.
1682
* @param pszIn Name of the R0 function which is gonna handle IN operations.
1683
* @param pszOutStr Name of the R0 function which is gonna handle string OUT operations.
1684
* @param pszInStr Name of the R0 function which is gonna handle string IN operations.
1685
* @param pszDesc Pointer to description string. This must not be freed.
1687
DECLR3CALLBACKMEMBER(int, pfnIOPortRegisterR0,(PPDMDEVINS pDevIns, RTIOPORT Port, RTUINT cPorts, RTR0PTR pvUser,
1688
const char *pszOut, const char *pszIn,
1689
const char *pszOutStr, const char *pszInStr, const char *pszDesc));
1692
* Deregister I/O ports.
1694
* This naturally affects both guest context (GC), ring-0 (R0) and ring-3 (R3/HC) handlers.
1696
* @returns VBox status.
1697
* @param pDevIns The device instance owning the ports.
1698
* @param Port First port number in the range.
1699
* @param cPorts Number of ports to deregister.
1701
DECLR3CALLBACKMEMBER(int, pfnIOPortDeregister,(PPDMDEVINS pDevIns, RTIOPORT Port, RTUINT cPorts));
1705
* Register a Memory Mapped I/O (MMIO) region.
1707
* These callbacks are of course for the host context (HC).
1708
* Register HC handlers before guest context (GC) handlers! There must be a
1709
* HC handler for every GC handler!
1711
* @returns VBox status.
1712
* @param pDevIns The device instance to register the MMIO with.
1713
* @param GCPhysStart First physical address in the range.
1714
* @param cbRange The size of the range (in bytes).
1715
* @param pvUser User argument.
1716
* @param pfnWrite Pointer to function which is gonna handle Write operations.
1717
* @param pfnRead Pointer to function which is gonna handle Read operations.
1718
* @param pfnFill Pointer to function which is gonna handle Fill/memset operations. (optional)
1719
* @param pszDesc Pointer to description string. This must not be freed.
1721
DECLR3CALLBACKMEMBER(int, pfnMMIORegister,(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, RTHCPTR pvUser,
1722
PFNIOMMMIOWRITE pfnWrite, PFNIOMMMIOREAD pfnRead, PFNIOMMMIOFILL pfnFill,
1723
const char *pszDesc));
1726
* Register a Memory Mapped I/O (MMIO) region for GC.
1728
* These callbacks are for the guest context (GC).
1729
* Register host context (HC) handlers before guest context handlers! There must be a
1730
* HC handler for every GC handler!
1732
* @returns VBox status.
1733
* @param pDevIns The device instance to register the MMIO with.
1734
* @param GCPhysStart First physical address in the range.
1735
* @param cbRange The size of the range (in bytes).
1736
* @param pvUser User argument.
1737
* @param pszWrite Name of the GC function which is gonna handle Write operations.
1738
* @param pszRead Name of the GC function which is gonna handle Read operations.
1739
* @param pszFill Name of the GC function which is gonna handle Fill/memset operations. (optional)
1740
* @param pszDesc Pointer to description string. This must not be freed.
1742
DECLR3CALLBACKMEMBER(int, pfnMMIORegisterGC,(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, RTGCPTR pvUser,
1743
const char *pszWrite, const char *pszRead, const char *pszFill,
1744
const char *pszDesc));
1747
* Register a Memory Mapped I/O (MMIO) region for R0.
1749
* These callbacks are for the ring-0 host context (R0).
1750
* Register R3 (HC) handlers before R0 handlers! There must be a R3 handler for every R0 handler!
1752
* @returns VBox status.
1753
* @param pDevIns The device instance to register the MMIO with.
1754
* @param GCPhysStart First physical address in the range.
1755
* @param cbRange The size of the range (in bytes).
1756
* @param pvUser User argument. (if pointer, then it must be in locked memory!)
1757
* @param pszWrite Name of the GC function which is gonna handle Write operations.
1758
* @param pszRead Name of the GC function which is gonna handle Read operations.
1759
* @param pszFill Name of the GC function which is gonna handle Fill/memset operations. (optional)
1760
* @param pszDesc Pointer to description string. This must not be freed.
1762
DECLR3CALLBACKMEMBER(int, pfnMMIORegisterR0,(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, RTR0PTR pvUser,
1763
const char *pszWrite, const char *pszRead, const char *pszFill,
1764
const char *pszDesc));
1767
* Deregister a Memory Mapped I/O (MMIO) region.
1769
* This naturally affects both guest context (GC), ring-0 (R0) and ring-3 (R3/HC) handlers.
1771
* @returns VBox status.
1772
* @param pDevIns The device instance owning the MMIO region(s).
1773
* @param GCPhysStart First physical address in the range.
1774
* @param cbRange The size of the range (in bytes).
1776
DECLR3CALLBACKMEMBER(int, pfnMMIODeregister,(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange));
1779
* Register a ROM (BIOS) region.
1781
* It goes without saying that this is read-only memory. The memory region must be
1782
* in unassigned memory. I.e. from the top of the address space or on the PC in
1783
* the 0xa0000-0xfffff range.
1785
* @returns VBox status.
1786
* @param pDevIns The device instance owning the ROM region.
1787
* @param GCPhysStart First physical address in the range.
1788
* Must be page aligned!
1789
* @param cbRange The size of the range (in bytes).
1790
* Must be page aligned!
1791
* @param pvBinary Pointer to the binary data backing the ROM image.
1792
* This must be cbRange bytes big.
1793
* It will be copied and doesn't have to stick around if fShadow is clear.
1794
* @param fShadow Whether to emulate ROM shadowing. This involves leaving
1795
* the ROM writable for a while during the POST and refreshing
1796
* it at reset. When this flag is set, the memory pointed to by
1797
* pvBinary has to stick around for the lifespan of the VM.
1798
* @param pszDesc Pointer to description string. This must not be freed.
1800
* @remark There is no way to remove the rom, automatically on device cleanup or
1801
* manually from the device yet. At present I doubt we need such features...
1803
DECLR3CALLBACKMEMBER(int, pfnROMRegister,(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, const void *pvBinary, bool fShadow, const char *pszDesc));
1806
* Register a save state data unit.
1808
* @returns VBox status.
1809
* @param pDevIns Device instance.
1810
* @param pszName Data unit name.
1811
* @param u32Instance The instance identifier of the data unit.
1812
* This must together with the name be unique.
1813
* @param u32Version Data layout version number.
1814
* @param cbGuess The approximate amount of data in the unit.
1815
* Only for progress indicators.
1816
* @param pfnSavePrep Prepare save callback, optional.
1817
* @param pfnSaveExec Execute save callback, optional.
1818
* @param pfnSaveDone Done save callback, optional.
1819
* @param pfnLoadPrep Prepare load callback, optional.
1820
* @param pfnLoadExec Execute load callback, optional.
1821
* @param pfnLoadDone Done load callback, optional.
1823
DECLR3CALLBACKMEMBER(int, pfnSSMRegister,(PPDMDEVINS pDevIns, const char *pszName, uint32_t u32Instance, uint32_t u32Version, size_t cbGuess,
1824
PFNSSMDEVSAVEPREP pfnSavePrep, PFNSSMDEVSAVEEXEC pfnSaveExec, PFNSSMDEVSAVEDONE pfnSaveDone,
1825
PFNSSMDEVLOADPREP pfnLoadPrep, PFNSSMDEVLOADEXEC pfnLoadExec, PFNSSMDEVLOADDONE pfnLoadDone));
1830
* @returns VBox status.
1831
* @param pDevIns Device instance.
1832
* @param enmClock The clock to use on this timer.
1833
* @param pfnCallback Callback function.
1834
* @param pszDesc Pointer to description string which must stay around
1835
* until the timer is fully destroyed (i.e. a bit after TMTimerDestroy()).
1836
* @param ppTimer Where to store the timer on success.
1838
DECLR3CALLBACKMEMBER(int, pfnTMTimerCreate,(PPDMDEVINS pDevIns, TMCLOCK enmClock, PFNTMTIMERDEV pfnCallback, const char *pszDesc, PPTMTIMERHC ppTimer));
1841
* Creates an external timer.
1843
* @returns timer pointer
1844
* @param pDevIns Device instance.
1845
* @param enmClock The clock to use on this timer.
1846
* @param pfnCallback Callback function.
1847
* @param pvUser User pointer
1848
* @param pszDesc Pointer to description string which must stay around
1849
* until the timer is fully destroyed (i.e. a bit after TMTimerDestroy()).
1851
DECLR3CALLBACKMEMBER(PTMTIMERHC, pfnTMTimerCreateExternal,(PPDMDEVINS pDevIns, TMCLOCK enmClock, PFNTMTIMEREXT pfnCallback, void *pvUser, const char *pszDesc));
1854
* Registers the device with the default PCI bus.
1856
* @returns VBox status code.
1857
* @param pDevIns Device instance.
1858
* @param pPciDev The PCI device structure.
1859
* Any PCI enabled device must keep this in it's instance data!
1860
* Fill in the PCI data config before registration, please.
1861
* @remark This is the simple interface, a Ex interface will be created if
1862
* more features are needed later.
1864
DECLR3CALLBACKMEMBER(int, pfnPCIRegister,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev));
1867
* Registers a I/O region (memory mapped or I/O ports) for a PCI device.
1869
* @returns VBox status code.
1870
* @param pDevIns Device instance.
1871
* @param iRegion The region number.
1872
* @param cbRegion Size of the region.
1873
* @param enmType PCI_ADDRESS_SPACE_MEM, PCI_ADDRESS_SPACE_IO or PCI_ADDRESS_SPACE_MEM_PREFETCH.
1874
* @param pfnCallback Callback for doing the mapping.
1876
DECLR3CALLBACKMEMBER(int, pfnPCIIORegionRegister,(PPDMDEVINS pDevIns, int iRegion, uint32_t cbRegion, PCIADDRESSSPACE enmType, PFNPCIIOREGIONMAP pfnCallback));
1879
* Register PCI configuration space read/write callbacks.
1881
* @param pDevIns Device instance.
1882
* @param pPciDev The PCI device structure.
1883
* If NULL the default PCI device for this device instance is used.
1884
* @param pfnRead Pointer to the user defined PCI config read function.
1885
* @param ppfnReadOld Pointer to function pointer which will receive the old (default)
1886
* PCI config read function. This way, user can decide when (and if)
1887
* to call default PCI config read function. Can be NULL.
1888
* @param pfnWrite Pointer to the user defined PCI config write function.
1889
* @param pfnWriteOld Pointer to function pointer which will receive the old (default)
1890
* PCI config write function. This way, user can decide when (and if)
1891
* to call default PCI config write function. Can be NULL.
1894
DECLR3CALLBACKMEMBER(void, pfnPCISetConfigCallbacks,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, PFNPCICONFIGREAD pfnRead, PPFNPCICONFIGREAD ppfnReadOld,
1895
PFNPCICONFIGWRITE pfnWrite, PPFNPCICONFIGWRITE ppfnWriteOld));
1898
* Set the IRQ for a PCI device.
1900
* @param pDevIns Device instance.
1901
* @param iIrq IRQ number to set.
1902
* @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
1903
* @thread Any thread, but will involve the emulation thread.
1905
DECLR3CALLBACKMEMBER(void, pfnPCISetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
1908
* Set the IRQ for a PCI device, but don't wait for EMT to process
1909
* the request when not called from EMT.
1911
* @param pDevIns Device instance.
1912
* @param iIrq IRQ number to set.
1913
* @param iLevel IRQ level.
1914
* @thread Any thread, but will involve the emulation thread.
1916
DECLR3CALLBACKMEMBER(void, pfnPCISetIrqNoWait,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
1919
* Set ISA IRQ for a device.
1921
* @param pDevIns Device instance.
1922
* @param iIrq IRQ number to set.
1923
* @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
1924
* @thread Any thread, but will involve the emulation thread.
1926
DECLR3CALLBACKMEMBER(void, pfnISASetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
1929
* Set the ISA IRQ for a device, but don't wait for EMT to process
1930
* the request when not called from EMT.
1932
* @param pDevIns Device instance.
1933
* @param iIrq IRQ number to set.
1934
* @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
1935
* @thread Any thread, but will involve the emulation thread.
1937
DECLR3CALLBACKMEMBER(void, pfnISASetIrqNoWait,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
1940
* Attaches a driver (chain) to the device.
1942
* The first call for a LUN this will serve as a registartion of the LUN. The pBaseInterface and
1943
* the pszDesc string will be registered with that LUN and kept around for PDMR3QueryDeviceLun().
1945
* @returns VBox status code.
1946
* @param pDevIns Device instance.
1947
* @param iLun The logical unit to attach.
1948
* @param pBaseInterface Pointer to the base interface for that LUN. (device side / down)
1949
* @param ppBaseInterface Where to store the pointer to the base interface. (driver side / up)
1950
* @param pszDesc Pointer to a string describing the LUN. This string must remain valid
1951
* for the live of the device instance.
1953
DECLR3CALLBACKMEMBER(int, pfnDriverAttach,(PPDMDEVINS pDevIns, RTUINT iLun, PPDMIBASE pBaseInterface, PPDMIBASE *ppBaseInterface, const char *pszDesc));
1956
* Allocate memory which is associated with current VM instance
1957
* and automatically freed on it's destruction.
1959
* @returns Pointer to allocated memory. The memory is *NOT* zero-ed.
1960
* @param pDevIns Device instance.
1961
* @param cb Number of bytes to allocate.
1963
DECLR3CALLBACKMEMBER(void *, pfnMMHeapAlloc,(PPDMDEVINS pDevIns, size_t cb));
1966
* Allocate memory which is associated with current VM instance
1967
* and automatically freed on it's destruction. The memory is ZEROed.
1969
* @returns Pointer to allocated memory. The memory is *NOT* zero-ed.
1970
* @param pDevIns Device instance.
1971
* @param cb Number of bytes to allocate.
1973
DECLR3CALLBACKMEMBER(void *, pfnMMHeapAllocZ,(PPDMDEVINS pDevIns, size_t cb));
1976
* Free memory allocated with pfnMMHeapAlloc() and pfnMMHeapAllocZ().
1978
* @param pDevIns Device instance.
1979
* @param pv Pointer to the memory to free.
1981
DECLR3CALLBACKMEMBER(void, pfnMMHeapFree,(PPDMDEVINS pDevIns, void *pv));
1984
* Set the VM error message
1987
* @param pDevIns Device instance.
1988
* @param rc VBox status code.
1989
* @param RT_SRC_POS_DECL Use RT_SRC_POS.
1990
* @param pszFormat Error message format string.
1991
* @param ... Error message arguments.
1993
DECLR3CALLBACKMEMBER(int, pfnVMSetError,(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...));
1996
* Set the VM error message
1999
* @param pDevIns Device instance.
2000
* @param rc VBox status code.
2001
* @param RT_SRC_POS_DECL Use RT_SRC_POS.
2002
* @param pszFormat Error message format string.
2003
* @param va Error message arguments.
2005
DECLR3CALLBACKMEMBER(int, pfnVMSetErrorV,(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va));
2008
* Set the VM runtime error message
2010
* @returns VBox status code.
2011
* @param pDevIns Device instance.
2012
* @param fFatal Whether it is a fatal error or not.
2013
* @param pszErrorID Error ID string.
2014
* @param pszFormat Error message format string.
2015
* @param ... Error message arguments.
2017
DECLR3CALLBACKMEMBER(int, pfnVMSetRuntimeError,(PPDMDEVINS pDevIns, bool fFatal, const char *pszErrorID, const char *pszFormat, ...));
2020
* Set the VM runtime error message
2022
* @returns VBox status code.
2023
* @param pDevIns Device instance.
2024
* @param fFatal Whether it is a fatal error or not.
2025
* @param pszErrorID Error ID string.
2026
* @param pszFormat Error message format string.
2027
* @param va Error message arguments.
2029
DECLR3CALLBACKMEMBER(int, pfnVMSetRuntimeErrorV,(PPDMDEVINS pDevIns, bool fFatal, const char *pszErrorID, const char *pszFormat, va_list va));
2032
* Assert that the current thread is the emulation thread.
2034
* @returns True if correct.
2035
* @returns False if wrong.
2036
* @param pDevIns Device instance.
2037
* @param pszFile Filename of the assertion location.
2038
* @param iLine The linenumber of the assertion location.
2039
* @param pszFunction Function of the assertion location.
2041
DECLR3CALLBACKMEMBER(bool, pfnAssertEMT,(PPDMDEVINS pDevIns, const char *pszFile, unsigned iLine, const char *pszFunction));
2044
* Assert that the current thread is NOT the emulation thread.
2046
* @returns True if correct.
2047
* @returns False if wrong.
2048
* @param pDevIns Device instance.
2049
* @param pszFile Filename of the assertion location.
2050
* @param iLine The linenumber of the assertion location.
2051
* @param pszFunction Function of the assertion location.
2053
DECLR3CALLBACKMEMBER(bool, pfnAssertOther,(PPDMDEVINS pDevIns, const char *pszFile, unsigned iLine, const char *pszFunction));
2056
* Stops the VM and enters the debugger to look at the guest state.
2058
* Use the PDMDeviceDBGFStop() inline function with the RT_SRC_POS macro instead of
2059
* invoking this function directly.
2061
* @returns VBox status code which must be passed up to the VMM.
2062
* @param pDevIns Device instance.
2063
* @param pszFile Filename of the assertion location.
2064
* @param iLine The linenumber of the assertion location.
2065
* @param pszFunction Function of the assertion location.
2066
* @param pszFormat Message. (optional)
2067
* @param args Message parameters.
2069
DECLR3CALLBACKMEMBER(int, pfnDBGFStopV,(PPDMDEVINS pDevIns, const char *pszFile, unsigned iLine, const char *pszFunction, const char *pszFormat, va_list args));
2072
* Register a info handler with DBGF,
2074
* @returns VBox status code.
2075
* @param pDevIns Device instance.
2076
* @param pszName The identifier of the info.
2077
* @param pszDesc The description of the info and any arguments the handler may take.
2078
* @param pfnHandler The handler function to be called to display the info.
2080
DECLR3CALLBACKMEMBER(int, pfnDBGFInfoRegister,(PPDMDEVINS pDevIns, const char *pszName, const char *pszDesc, PFNDBGFHANDLERDEV pfnHandler));
2083
* Registers a statistics sample if statistics are enabled.
2085
* @param pDevIns Device instance of the DMA.
2086
* @param pvSample Pointer to the sample.
2087
* @param enmType Sample type. This indicates what pvSample is pointing at.
2088
* @param pszName Sample name. The name is on this form "/<component>/<sample>".
2089
* Further nesting is possible.
2090
* @param enmUnit Sample unit.
2091
* @param pszDesc Sample description.
2093
DECLR3CALLBACKMEMBER(void, pfnSTAMRegister,(PPDMDEVINS pDevIns, void *pvSample, STAMTYPE enmType, const char *pszName, STAMUNIT enmUnit, const char *pszDesc));
2096
* Same as pfnSTAMRegister except that the name is specified in a
2097
* RTStrPrintf like fashion.
2099
* @returns VBox status.
2100
* @param pDevIns Device instance of the DMA.
2101
* @param pvSample Pointer to the sample.
2102
* @param enmType Sample type. This indicates what pvSample is pointing at.
2103
* @param enmVisibility Visibility type specifying whether unused statistics should be visible or not.
2104
* @param enmUnit Sample unit.
2105
* @param pszDesc Sample description.
2106
* @param pszName The sample name format string.
2107
* @param ... Arguments to the format string.
2109
DECLR3CALLBACKMEMBER(void, pfnSTAMRegisterF,(PPDMDEVINS pDevIns, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility,
2110
STAMUNIT enmUnit, const char *pszDesc, const char *pszName, ...));
2113
* Same as pfnSTAMRegister except that the name is specified in a
2114
* RTStrPrintfV like fashion.
2116
* @returns VBox status.
2117
* @param pDevIns Device instance of the DMA.
2118
* @param pvSample Pointer to the sample.
2119
* @param enmType Sample type. This indicates what pvSample is pointing at.
2120
* @param enmVisibility Visibility type specifying whether unused statistics should be visible or not.
2121
* @param enmUnit Sample unit.
2122
* @param pszDesc Sample description.
2123
* @param pszName The sample name format string.
2124
* @param args Arguments to the format string.
2126
DECLR3CALLBACKMEMBER(void, pfnSTAMRegisterV,(PPDMDEVINS pDevIns, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility,
2127
STAMUNIT enmUnit, const char *pszDesc, const char *pszName, va_list args));
2130
* Register the RTC device.
2132
* @returns VBox status code.
2133
* @param pDevIns Device instance.
2134
* @param pRtcReg Pointer to a RTC registration structure.
2135
* @param ppRtcHlp Where to store the pointer to the helper functions.
2137
DECLR3CALLBACKMEMBER(int, pfnRTCRegister,(PPDMDEVINS pDevIns, PCPDMRTCREG pRtcReg, PCPDMRTCHLP *ppRtcHlp));
2142
* @returns VBox status code.
2143
* @param pDevIns The device instance.
2144
* @param cbItem The size of a queue item.
2145
* @param cItems The number of items in the queue.
2146
* @param cMilliesInterval The number of milliseconds between polling the queue.
2147
* If 0 then the emulation thread will be notified whenever an item arrives.
2148
* @param pfnCallback The consumer function.
2149
* @param fGCEnabled Set if the queue should work in GC too.
2150
* @param ppQueue Where to store the queue handle on success.
2151
* @thread The emulation thread.
2153
DECLR3CALLBACKMEMBER(int, pfnPDMQueueCreate,(PPDMDEVINS pDevIns, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval,
2154
PFNPDMQUEUEDEV pfnCallback, bool fGCEnabled, PPDMQUEUE *ppQueue));
2157
* Initializes a PDM critical section.
2159
* The PDM critical sections are derived from the IPRT critical sections, but
2160
* works in GC as well.
2162
* @returns VBox status code.
2163
* @param pDevIns Device instance.
2164
* @param pCritSect Pointer to the critical section.
2165
* @param pszName The name of the critical section (for statistics).
2167
DECLR3CALLBACKMEMBER(int, pfnCritSectInit,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, const char *pszName));
2170
* Get the real world UTC time adjusted for VM lag, user offset and warpdrive.
2173
* @param pDevIns Device instance.
2174
* @param pTime Where to store the time.
2176
DECLR3CALLBACKMEMBER(PRTTIMESPEC, pfnUTCNow,(PPDMDEVINS pDevIns, PRTTIMESPEC pTime));
2179
* Creates a PDM thread.
2181
* This differs from the RTThreadCreate() API in that PDM takes care of suspending,
2182
* resuming, and destroying the thread as the VM state changes.
2184
* @returns VBox status code.
2185
* @param pDevIns The device instance.
2186
* @param ppThread Where to store the thread 'handle'.
2187
* @param pvUser The user argument to the thread function.
2188
* @param pfnThread The thread function.
2189
* @param pfnWakeup The wakup callback. This is called on the EMT thread when
2190
* a state change is pending.
2191
* @param cbStack See RTThreadCreate.
2192
* @param enmType See RTThreadCreate.
2193
* @param pszName See RTThreadCreate.
2195
DECLR3CALLBACKMEMBER(int, pfnPDMThreadCreate,(PPDMDEVINS pDevIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADDEV pfnThread,
2196
PFNPDMTHREADWAKEUPDEV pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName));
2199
/** Space reserved for future members.
2201
DECLR3CALLBACKMEMBER(void, pfnReserved2,(void));
2202
DECLR3CALLBACKMEMBER(void, pfnReserved3,(void));
2203
DECLR3CALLBACKMEMBER(void, pfnReserved4,(void));
2204
DECLR3CALLBACKMEMBER(void, pfnReserved5,(void));
2205
DECLR3CALLBACKMEMBER(void, pfnReserved6,(void));
2206
DECLR3CALLBACKMEMBER(void, pfnReserved7,(void));
2207
DECLR3CALLBACKMEMBER(void, pfnReserved8,(void));
2208
DECLR3CALLBACKMEMBER(void, pfnReserved9,(void));
2209
DECLR3CALLBACKMEMBER(void, pfnReserved10,(void));
2213
/** API available to trusted devices only.
2215
* These APIs are providing unrestricted access to the guest and the VM,
2216
* or they are interacting intimately with PDM.
2221
* Gets the VM handle. Restricted API.
2223
* @returns VM Handle.
2224
* @param pDevIns Device instance.
2226
DECLR3CALLBACKMEMBER(PVM, pfnGetVM,(PPDMDEVINS pDevIns));
2229
* Register the PCI Bus.
2231
* @returns VBox status code.
2232
* @param pDevIns Device instance.
2233
* @param pPciBusReg Pointer to PCI bus registration structure.
2234
* @param ppPciHlpR3 Where to store the pointer to the PCI Bus helpers.
2236
DECLR3CALLBACKMEMBER(int, pfnPCIBusRegister,(PPDMDEVINS pDevIns, PPDMPCIBUSREG pPciBusReg, PCPDMPCIHLPR3 *ppPciHlpR3));
2239
* Register the PIC device.
2241
* @returns VBox status code.
2242
* @param pDevIns Device instance.
2243
* @param pPicReg Pointer to a PIC registration structure.
2244
* @param ppPicHlpR3 Where to store the pointer to the PIC HC helpers.
2246
DECLR3CALLBACKMEMBER(int, pfnPICRegister,(PPDMDEVINS pDevIns, PPDMPICREG pPicReg, PCPDMPICHLPR3 *ppPicHlpR3));
2249
* Register the APIC device.
2251
* @returns VBox status code.
2252
* @param pDevIns Device instance.
2253
* @param pApicReg Pointer to a APIC registration structure.
2254
* @param ppApicHlpR3 Where to store the pointer to the APIC helpers.
2256
DECLR3CALLBACKMEMBER(int, pfnAPICRegister,(PPDMDEVINS pDevIns, PPDMAPICREG pApicReg, PCPDMAPICHLPR3 *ppApicHlpR3));
2259
* Register the I/O APIC device.
2261
* @returns VBox status code.
2262
* @param pDevIns Device instance.
2263
* @param pIoApicReg Pointer to a I/O APIC registration structure.
2264
* @param ppIoApicHlpR3 Where to store the pointer to the IOAPIC helpers.
2266
DECLR3CALLBACKMEMBER(int, pfnIOAPICRegister,(PPDMDEVINS pDevIns, PPDMIOAPICREG pIoApicReg, PCPDMIOAPICHLPR3 *ppIoApicHlpR3));
2269
* Register the DMA device.
2271
* @returns VBox status code.
2272
* @param pDevIns Device instance.
2273
* @param pDmacReg Pointer to a DMAC registration structure.
2274
* @param ppDmacHlp Where to store the pointer to the DMA helpers.
2276
DECLR3CALLBACKMEMBER(int, pfnDMACRegister,(PPDMDEVINS pDevIns, PPDMDMACREG pDmacReg, PCPDMDMACHLP *ppDmacHlp));
2279
* Read physical memory.
2281
* @param pDevIns Device instance.
2282
* @param GCPhys Physical address start reading from.
2283
* @param pvBuf Where to put the read bits.
2284
* @param cbRead How many bytes to read.
2285
* @thread Any thread, but the call may involve the emulation thread.
2287
DECLR3CALLBACKMEMBER(void, pfnPhysRead,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead));
2290
* Write to physical memory.
2292
* @param pDevIns Device instance.
2293
* @param GCPhys Physical address to write to.
2294
* @param pvBuf What to write.
2295
* @param cbWrite How many bytes to write.
2296
* @thread Any thread, but the call may involve the emulation thread.
2298
DECLR3CALLBACKMEMBER(void, pfnPhysWrite,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite));
2301
* Read guest physical memory by virtual address.
2303
* @param pDevIns Device instance.
2304
* @param pvDst Where to put the read bits.
2305
* @param GCVirtSrc Guest virtual address to start reading from.
2306
* @param cb How many bytes to read.
2307
* @thread The emulation thread.
2309
DECLR3CALLBACKMEMBER(int, pfnPhysReadGCVirt,(PPDMDEVINS pDevIns, void *pvDst, RTGCPTR GCVirtSrc, size_t cb));
2312
* Write to guest physical memory by virtual address.
2314
* @param pDevIns Device instance.
2315
* @param GCVirtDst Guest virtual address to write to.
2316
* @param pvSrc What to write.
2317
* @param cb How many bytes to write.
2318
* @thread The emulation thread.
2320
DECLR3CALLBACKMEMBER(int, pfnPhysWriteGCVirt,(PPDMDEVINS pDevIns, RTGCPTR GCVirtDst, const void *pvSrc, size_t cb));
2323
* Reserve physical address space for ROM and MMIO ranges.
2325
* @returns VBox status code.
2326
* @param pDevIns Device instance.
2327
* @param GCPhys Start physical address.
2328
* @param cbRange The size of the range.
2329
* @param pszDesc Description string.
2330
* @thread The emulation thread.
2332
DECLR3CALLBACKMEMBER(int, pfnPhysReserve,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTUINT cbRange, const char *pszDesc));
2335
* Convert a guest physical address to a host virtual address.
2337
* @returns VBox status code.
2338
* @param pDevIns Device instance.
2339
* @param GCPhys Start physical address.
2340
* @param cbRange The size of the range. Use 0 if you don't care about the range.
2341
* @param ppvHC Where to store the HC pointer corresponding to GCPhys.
2342
* @thread Any thread.
2344
DECLR3CALLBACKMEMBER(int, pfnPhys2HCVirt,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTUINT cbRange, PRTHCPTR ppvHC));
2347
* Convert a guest virtual address to a host virtual address.
2349
* @returns VBox status code.
2350
* @param pDevIns Device instance.
2351
* @param GCPtr Guest virtual address.
2352
* @param pHCPtr Where to store the HC pointer corresponding to GCPtr.
2353
* @thread The emulation thread.
2354
* @remark Careful with page boundraries.
2356
DECLR3CALLBACKMEMBER(int, pfnPhysGCPtr2HCPtr,(PPDMDEVINS pDevIns, RTGCPTR GCPtr, PRTHCPTR pHCPtr));
2359
* Checks if the Gate A20 is enabled or not.
2361
* @returns true if A20 is enabled.
2362
* @returns false if A20 is disabled.
2363
* @param pDevIns Device instance.
2364
* @thread The emulation thread.
2366
DECLR3CALLBACKMEMBER(bool, pfnA20IsEnabled,(PPDMDEVINS pDevIns));
2369
* Enables or disables the Gate A20.
2371
* @param pDevIns Device instance.
2372
* @param fEnable Set this flag to enable the Gate A20; clear it to disable.
2373
* @thread The emulation thread.
2375
DECLR3CALLBACKMEMBER(void, pfnA20Set,(PPDMDEVINS pDevIns, bool fEnable));
2380
* @returns The appropriate VBox status code to pass around on reset.
2381
* @param pDevIns Device instance.
2382
* @thread The emulation thread.
2384
DECLR3CALLBACKMEMBER(int, pfnVMReset,(PPDMDEVINS pDevIns));
2389
* @returns The appropriate VBox status code to pass around on suspend.
2390
* @param pDevIns Device instance.
2391
* @thread The emulation thread.
2393
DECLR3CALLBACKMEMBER(int, pfnVMSuspend,(PPDMDEVINS pDevIns));
2398
* @returns The appropriate VBox status code to pass around on power off.
2399
* @param pDevIns Device instance.
2400
* @thread The emulation thread.
2402
DECLR3CALLBACKMEMBER(int, pfnVMPowerOff,(PPDMDEVINS pDevIns));
2405
* Acquire global VM lock
2407
* @returns VBox status code
2408
* @param pDevIns Device instance.
2410
DECLR3CALLBACKMEMBER(int , pfnLockVM,(PPDMDEVINS pDevIns));
2413
* Release global VM lock
2415
* @returns VBox status code
2416
* @param pDevIns Device instance.
2418
DECLR3CALLBACKMEMBER(int, pfnUnlockVM,(PPDMDEVINS pDevIns));
2421
* Check that the current thread owns the global VM lock.
2424
* @param pDevIns Device instance.
2425
* @param pszFile Filename of the assertion location.
2426
* @param iLine Linenumber of the assertion location.
2427
* @param pszFunction Function of the assertion location.
2429
DECLR3CALLBACKMEMBER(bool, pfnAssertVMLock,(PPDMDEVINS pDevIns, const char *pszFile, unsigned iLine, const char *pszFunction));
2432
* Register transfer function for DMA channel.
2434
* @returns VBox status code.
2435
* @param pDevIns Device instance.
2436
* @param uChannel Channel number.
2437
* @param pfnTransferHandler Device specific transfer callback function.
2438
* @param pvUser User pointer to pass to the callback.
2441
DECLR3CALLBACKMEMBER(int, pfnDMARegister,(PPDMDEVINS pDevIns, unsigned uChannel, PFNDMATRANSFERHANDLER pfnTransferHandler, void *pvUser));
2446
* @returns VBox status code.
2447
* @param pDevIns Device instance.
2448
* @param uChannel Channel number.
2449
* @param pvBuffer Pointer to target buffer.
2450
* @param off DMA position.
2451
* @param cbBlock Block size.
2452
* @param pcbRead Where to store the number of bytes which was read. optional.
2455
DECLR3CALLBACKMEMBER(int, pfnDMAReadMemory,(PPDMDEVINS pDevIns, unsigned uChannel, void *pvBuffer, uint32_t off, uint32_t cbBlock, uint32_t *pcbRead));
2460
* @returns VBox status code.
2461
* @param pDevIns Device instance.
2462
* @param uChannel Channel number.
2463
* @param pvBuffer Memory to write.
2464
* @param off DMA position.
2465
* @param cbBlock Block size.
2466
* @param pcbWritten Where to store the number of bytes which was written. optional.
2469
DECLR3CALLBACKMEMBER(int, pfnDMAWriteMemory,(PPDMDEVINS pDevIns, unsigned uChannel, const void *pvBuffer, uint32_t off, uint32_t cbBlock, uint32_t *pcbWritten));
2472
* Set the DREQ line.
2474
* @returns VBox status code.
2475
* @param pDevIns Device instance.
2476
* @param uChannel Channel number.
2477
* @param uLevel Level of the line.
2480
DECLR3CALLBACKMEMBER(int, pfnDMASetDREQ,(PPDMDEVINS pDevIns, unsigned uChannel, unsigned uLevel));
2485
* @returns Channel mode. See specs.
2486
* @param pDevIns Device instance.
2487
* @param uChannel Channel number.
2490
DECLR3CALLBACKMEMBER(uint8_t, pfnDMAGetChannelMode,(PPDMDEVINS pDevIns, unsigned uChannel));
2493
* Schedule DMA execution.
2495
* @param pDevIns Device instance.
2496
* @thread Any thread.
2498
DECLR3CALLBACKMEMBER(void, pfnDMASchedule,(PPDMDEVINS pDevIns));
2501
* Write CMOS value and update the checksum(s).
2503
* @returns VBox status code.
2504
* @param pDevIns Device instance.
2505
* @param iReg The CMOS register index.
2506
* @param u8Value The CMOS register value.
2509
DECLR3CALLBACKMEMBER(int, pfnCMOSWrite,(PPDMDEVINS pDevIns, unsigned iReg, uint8_t u8Value));
2514
* @returns VBox status code.
2515
* @param pDevIns Device instance.
2516
* @param iReg The CMOS register index.
2517
* @param pu8Value Where to store the CMOS register value.
2520
DECLR3CALLBACKMEMBER(int, pfnCMOSRead,(PPDMDEVINS pDevIns, unsigned iReg, uint8_t *pu8Value));
2525
* @param pDevIns Device instance.
2526
* @param iLeaf The CPUID leaf to get.
2527
* @param pEax Where to store the EAX value.
2528
* @param pEbx Where to store the EBX value.
2529
* @param pEcx Where to store the ECX value.
2530
* @param pEdx Where to store the EDX value.
2532
DECLR3CALLBACKMEMBER(void, pfnGetCpuId,(PPDMDEVINS pDevIns, uint32_t iLeaf, uint32_t *pEax, uint32_t *pEbx, uint32_t *pEcx, uint32_t *pEdx));
2535
* Write protects a shadow ROM mapping.
2537
* This is intented for use by the system BIOS or by the device that
2538
* employs a shadow ROM BIOS, so that the shadow ROM mapping can be
2539
* write protected once the POST is over.
2541
* @param pDevIns Device instance.
2542
* @param GCPhysStart Where the shadow ROM mapping starts.
2543
* @param cbRange The size of the shadow ROM mapping.
2545
DECLR3CALLBACKMEMBER(int, pfnROMProtectShadow,(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange));
2549
/** Just a safety precaution. (PDM_DEVHLP_VERSION) */
2552
#endif /* !IN_RING3 */
2553
/** Pointer PDM Device API. */
2554
typedef HCPTRTYPE(struct PDMDEVHLP *) PPDMDEVHLP;
2555
/** Pointer PDM Device API. */
2556
typedef HCPTRTYPE(const struct PDMDEVHLP *) PCPDMDEVHLP;
2558
/** Current PDMDEVHLP version number. */
2559
#define PDM_DEVHLP_VERSION 0xf2050000
2563
* PDM Device API - GC Variant.
2565
typedef struct PDMDEVHLPGC
2567
/** Structure version. PDM_DEVHLPGC_VERSION defines the current version. */
2568
uint32_t u32Version;
2571
* Set the IRQ for a PCI device.
2573
* @param pDevIns Device instance.
2574
* @param iIrq IRQ number to set.
2575
* @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
2576
* @thread Any thread, but will involve the emulation thread.
2578
DECLGCCALLBACKMEMBER(void, pfnPCISetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
2581
* Set ISA IRQ for a device.
2583
* @param pDevIns Device instance.
2584
* @param iIrq IRQ number to set.
2585
* @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
2586
* @thread Any thread, but will involve the emulation thread.
2588
DECLGCCALLBACKMEMBER(void, pfnISASetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
2591
* Read physical memory.
2593
* @param pDevIns Device instance.
2594
* @param GCPhys Physical address start reading from.
2595
* @param pvBuf Where to put the read bits.
2596
* @param cbRead How many bytes to read.
2598
DECLGCCALLBACKMEMBER(void, pfnPhysRead,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead));
2601
* Write to physical memory.
2603
* @param pDevIns Device instance.
2604
* @param GCPhys Physical address to write to.
2605
* @param pvBuf What to write.
2606
* @param cbWrite How many bytes to write.
2608
DECLGCCALLBACKMEMBER(void, pfnPhysWrite,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite));
2611
* Checks if the Gate A20 is enabled or not.
2613
* @returns true if A20 is enabled.
2614
* @returns false if A20 is disabled.
2615
* @param pDevIns Device instance.
2616
* @thread The emulation thread.
2618
DECLGCCALLBACKMEMBER(bool, pfnA20IsEnabled,(PPDMDEVINS pDevIns));
2621
* Set the VM error message
2624
* @param pDrvIns Driver instance.
2625
* @param rc VBox status code.
2626
* @param RT_SRC_POS_DECL Use RT_SRC_POS.
2627
* @param pszFormat Error message format string.
2628
* @param ... Error message arguments.
2630
DECLGCCALLBACKMEMBER(int, pfnVMSetError,(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...));
2633
* Set the VM error message
2636
* @param pDrvIns Driver instance.
2637
* @param rc VBox status code.
2638
* @param RT_SRC_POS_DECL Use RT_SRC_POS.
2639
* @param pszFormat Error message format string.
2640
* @param va Error message arguments.
2642
DECLGCCALLBACKMEMBER(int, pfnVMSetErrorV,(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va));
2645
* Set the VM runtime error message
2647
* @returns VBox status code.
2648
* @param pDevIns Device instance.
2649
* @param fFatal Whether it is a fatal error or not.
2650
* @param pszErrorID Error ID string.
2651
* @param pszFormat Error message format string.
2652
* @param ... Error message arguments.
2654
DECLGCCALLBACKMEMBER(int, pfnVMSetRuntimeError,(PPDMDEVINS pDevIns, bool fFatal, const char *pszErrorID, const char *pszFormat, ...));
2657
* Set the VM runtime error message
2659
* @returns VBox status code.
2660
* @param pDevIns Device instance.
2661
* @param fFatal Whether it is a fatal error or not.
2662
* @param pszErrorID Error ID string.
2663
* @param pszFormat Error message format string.
2664
* @param va Error message arguments.
2666
DECLGCCALLBACKMEMBER(int, pfnVMSetRuntimeErrorV,(PPDMDEVINS pDevIns, bool fFatal, const char *pszErrorID, const char *pszFormat, va_list va));
2669
* Set parameters for pending MMIO patch operation
2671
* @returns VBox status code.
2672
* @param pDevIns Device instance.
2673
* @param GCPhys MMIO physical address
2674
* @param pCachedData GC pointer to cached data
2676
DECLGCCALLBACKMEMBER(int, pfnPATMSetMMIOPatchInfo,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTGCPTR pCachedData));
2678
/** Just a safety precaution. */
2681
/** Pointer PDM Device GC API. */
2682
typedef GCPTRTYPE(struct PDMDEVHLPGC *) PPDMDEVHLPGC;
2683
/** Pointer PDM Device GC API. */
2684
typedef GCPTRTYPE(const struct PDMDEVHLPGC *) PCPDMDEVHLPGC;
2686
/** Current PDMDEVHLP version number. */
2687
#define PDM_DEVHLPGC_VERSION 0xfb010000
2691
* PDM Device API - R0 Variant.
2693
typedef struct PDMDEVHLPR0
2695
/** Structure version. PDM_DEVHLPR0_VERSION defines the current version. */
2696
uint32_t u32Version;
2699
* Set the IRQ for a PCI device.
2701
* @param pDevIns Device instance.
2702
* @param iIrq IRQ number to set.
2703
* @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
2704
* @thread Any thread, but will involve the emulation thread.
2706
DECLR0CALLBACKMEMBER(void, pfnPCISetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
2709
* Set ISA IRQ for a device.
2711
* @param pDevIns Device instance.
2712
* @param iIrq IRQ number to set.
2713
* @param iLevel IRQ level. See the PDM_IRQ_LEVEL_* \#defines.
2714
* @thread Any thread, but will involve the emulation thread.
2716
DECLR0CALLBACKMEMBER(void, pfnISASetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
2719
* Read physical memory.
2721
* @param pDevIns Device instance.
2722
* @param GCPhys Physical address start reading from.
2723
* @param pvBuf Where to put the read bits.
2724
* @param cbRead How many bytes to read.
2726
DECLR0CALLBACKMEMBER(void, pfnPhysRead,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead));
2729
* Write to physical memory.
2731
* @param pDevIns Device instance.
2732
* @param GCPhys Physical address to write to.
2733
* @param pvBuf What to write.
2734
* @param cbWrite How many bytes to write.
2736
DECLR0CALLBACKMEMBER(void, pfnPhysWrite,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite));
2739
* Checks if the Gate A20 is enabled or not.
2741
* @returns true if A20 is enabled.
2742
* @returns false if A20 is disabled.
2743
* @param pDevIns Device instance.
2744
* @thread The emulation thread.
2746
DECLR0CALLBACKMEMBER(bool, pfnA20IsEnabled,(PPDMDEVINS pDevIns));
2749
* Set the VM error message
2752
* @param pDrvIns Driver instance.
2753
* @param rc VBox status code.
2754
* @param RT_SRC_POS_DECL Use RT_SRC_POS.
2755
* @param pszFormat Error message format string.
2756
* @param ... Error message arguments.
2758
DECLR0CALLBACKMEMBER(int, pfnVMSetError,(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...));
2761
* Set the VM error message
2764
* @param pDrvIns Driver instance.
2765
* @param rc VBox status code.
2766
* @param RT_SRC_POS_DECL Use RT_SRC_POS.
2767
* @param pszFormat Error message format string.
2768
* @param va Error message arguments.
2770
DECLR0CALLBACKMEMBER(int, pfnVMSetErrorV,(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va));
2773
* Set the VM runtime error message
2775
* @returns VBox status code.
2776
* @param pDevIns Device instance.
2777
* @param fFatal Whether it is a fatal error or not.
2778
* @param pszErrorID Error ID string.
2779
* @param pszFormat Error message format string.
2780
* @param ... Error message arguments.
2782
DECLR0CALLBACKMEMBER(int, pfnVMSetRuntimeError,(PPDMDEVINS pDevIns, bool fFatal, const char *pszErrorID, const char *pszFormat, ...));
2785
* Set the VM runtime error message
2787
* @returns VBox status code.
2788
* @param pDevIns Device instance.
2789
* @param fFatal Whether it is a fatal error or not.
2790
* @param pszErrorID Error ID string.
2791
* @param pszFormat Error message format string.
2792
* @param va Error message arguments.
2794
DECLR0CALLBACKMEMBER(int, pfnVMSetRuntimeErrorV,(PPDMDEVINS pDevIns, bool fFatal, const char *pszErrorID, const char *pszFormat, va_list va));
2797
* Set parameters for pending MMIO patch operation
2800
* @param pDevIns Device instance.
2801
* @param GCPhys MMIO physical address
2802
* @param pCachedData GC pointer to cached data
2804
DECLR0CALLBACKMEMBER(int, pfnPATMSetMMIOPatchInfo,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTGCPTR pCachedData));
2806
/** Just a safety precaution. */
2809
/** Pointer PDM Device R0 API. */
2810
typedef HCPTRTYPE(struct PDMDEVHLPR0 *) PPDMDEVHLPR0;
2811
/** Pointer PDM Device GC API. */
2812
typedef HCPTRTYPE(const struct PDMDEVHLPR0 *) PCPDMDEVHLPR0;
2814
/** Current PDMDEVHLP version number. */
2815
#define PDM_DEVHLPR0_VERSION 0xfb010000
2820
* PDM Device Instance.
2822
typedef struct PDMDEVINS
2824
/** Structure version. PDM_DEVINS_VERSION defines the current version. */
2825
uint32_t u32Version;
2826
/** Device instance number. */
2828
/** The base interface of the device.
2829
* The device constructor initializes this if it has any
2830
* device level interfaces to export. To obtain this interface
2831
* call PDMR3QueryDevice(). */
2834
/** Internal data. */
2837
#ifdef PDMDEVINSINT_DECLARED
2840
uint8_t padding[HC_ARCH_BITS == 32 ? 48 : 96];
2843
/** Pointer the HC PDM Device API. */
2844
R3PTRTYPE(PCPDMDEVHLP) pDevHlp;
2845
/** Pointer the R0 PDM Device API. */
2846
R0PTRTYPE(PCPDMDEVHLPR0) pDevHlpR0;
2847
/** Pointer to device registration structure. */
2848
R3PTRTYPE(PCPDMDEVREG) pDevReg;
2849
/** Configuration handle. */
2850
R3PTRTYPE(PCFGMNODE) pCfgHandle;
2851
/** Pointer to device instance data. */
2852
R3PTRTYPE(void *) pvInstanceDataR3;
2853
/** Pointer to device instance data. */
2854
R0PTRTYPE(void *) pvInstanceDataR0;
2855
/** Pointer the GC PDM Device API. */
2856
GCPTRTYPE(PCPDMDEVHLPGC) pDevHlpGC;
2857
/** Pointer to device instance data. */
2858
GCPTRTYPE(void *) pvInstanceDataGC;
2859
/* padding to make achInstanceData aligned at 32 byte boundrary. */
2860
uint32_t au32Padding[HC_ARCH_BITS == 32 ? 1 : 6];
2861
/** Device instance data. The size of this area is defined
2862
* in the PDMDEVREG::cbInstanceData field. */
2863
char achInstanceData[8];
2866
/** Current DEVREG version number. */
2867
#define PDM_DEVINS_VERSION 0xf3010000
2869
/** Converts a pointer to the PDMDEVINS::IBase to a pointer to PDMDEVINS. */
2870
#define PDMIBASE_2_PDMDEV(pInterface) ( (PPDMDEVINS)((char *)(pInterface) - RT_OFFSETOF(PDMDEVINS, IBase)) )
2873
/** @def PDMDEV_ASSERT_EMT
2874
* Assert that the current thread is the emulation thread.
2877
# define PDMDEV_ASSERT_EMT(pDevIns) pDevIns->pDevHlp->pfnAssertEMT(pDevIns, __FILE__, __LINE__, __FUNCTION__)
2879
# define PDMDEV_ASSERT_EMT(pDevIns) do { } while (0)
2882
/** @def PDMDEV_ASSERT_OTHER
2883
* Assert that the current thread is NOT the emulation thread.
2886
# define PDMDEV_ASSERT_OTHER(pDevIns) pDevIns->pDevHlp->pfnAssertOther(pDevIns, __FILE__, __LINE__, __FUNCTION__)
2888
# define PDMDEV_ASSERT_OTHER(pDevIns) do { } while (0)
2891
/** @def PDMDEV_ASSERT_VMLOCK_OWNER
2892
* Assert that the current thread is owner of the VM lock.
2895
# define PDMDEV_ASSERT_VMLOCK_OWNER(pDevIns) pDevIns->pDevHlp->pfnAssertVMLock(pDevIns, __FILE__, __LINE__, __FUNCTION__)
2897
# define PDMDEV_ASSERT_VMLOCK_OWNER(pDevIns) do { } while (0)
2900
/** @def PDMDEV_SET_ERROR
2901
* Set the VM error. See PDMDevHlpVMSetError() for printf like message formatting.
2903
#define PDMDEV_SET_ERROR(pDevIns, rc, pszError) \
2904
PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS, "%s", pszError)
2906
/** @def PDMDEV_SET_RUNTIME_ERROR
2907
* Set the VM runtime error. See PDMDevHlpVMSetRuntimeError() for printf like message formatting.
2909
#define PDMDEV_SET_RUNTIME_ERROR(pDevIns, fFatal, pszErrorID, pszError) \
2910
PDMDevHlpVMSetRuntimeError(pDevIns, fFatal, pszErrorID, "%s", pszError)
2912
/** @def PDMDEVINS_2_GCPTR
2913
* Converts a PDM Device instance pointer a GC PDM Device instance pointer.
2915
#define PDMDEVINS_2_GCPTR(pDevIns) ( (GCPTRTYPE(PPDMDEVINS))((RTGCUINTPTR)(pDevIns)->pvInstanceDataGC - RT_OFFSETOF(PDMDEVINS, achInstanceData)) )
2917
/** @def PDMDEVINS_2_R3PTR
2918
* Converts a PDM Device instance pointer a HC PDM Device instance pointer.
2920
#define PDMDEVINS_2_R3PTR(pDevIns) ( (HCPTRTYPE(PPDMDEVINS))((RTHCUINTPTR)(pDevIns)->pvInstanceDataR3 - RT_OFFSETOF(PDMDEVINS, achInstanceData)) )
2922
/** @def PDMDEVINS_2_R0PTR
2923
* Converts a PDM Device instance pointer a R0 PDM Device instance pointer.
2925
#define PDMDEVINS_2_R0PTR(pDevIns) ( (R0PTRTYPE(PPDMDEVINS))((RTR0UINTPTR)(pDevIns)->pvInstanceDataR0 - RT_OFFSETOF(PDMDEVINS, achInstanceData)) )
2929
* VBOX_STRICT wrapper for pDevHlp->pfnDBGFStopV.
2931
* @returns VBox status code which must be passed up to the VMM.
2932
* @param pDevIns Device instance.
2933
* @param RT_SRC_POS_DECL Use RT_SRC_POS.
2934
* @param pszFormat Message. (optional)
2935
* @param ... Message parameters.
2937
DECLINLINE(int) PDMDeviceDBGFStop(PPDMDEVINS pDevIns, RT_SRC_POS_DECL, const char *pszFormat, ...)
2943
va_start(args, pszFormat);
2944
rc = pDevIns->pDevHlp->pfnDBGFStopV(pDevIns, RT_SRC_POS_ARGS, pszFormat, args);
2948
return VINF_EM_DBG_STOP;
2951
return VINF_SUCCESS;
2958
* @copydoc PDMDEVHLP::pfnIOPortRegister
2960
DECLINLINE(int) PDMDevHlpIOPortRegister(PPDMDEVINS pDevIns, RTIOPORT Port, RTUINT cPorts, RTHCPTR pvUser,
2961
PFNIOMIOPORTOUT pfnOut, PFNIOMIOPORTIN pfnIn,
2962
PFNIOMIOPORTOUTSTRING pfnOutStr, PFNIOMIOPORTINSTRING pfnInStr, const char *pszDesc)
2964
return pDevIns->pDevHlp->pfnIOPortRegister(pDevIns, Port, cPorts, pvUser, pfnOut, pfnIn, pfnOutStr, pfnInStr, pszDesc);
2968
* @copydoc PDMDEVHLP::pfnIOPortRegisterGC
2970
DECLINLINE(int) PDMDevHlpIOPortRegisterGC(PPDMDEVINS pDevIns, RTIOPORT Port, RTUINT cPorts, RTGCPTR pvUser,
2971
const char *pszOut, const char *pszIn, const char *pszOutStr,
2972
const char *pszInStr, const char *pszDesc)
2974
return pDevIns->pDevHlp->pfnIOPortRegisterGC(pDevIns, Port, cPorts, pvUser, pszOut, pszIn, pszOutStr, pszInStr, pszDesc);
2978
* @copydoc PDMDEVHLP::pfnIOPortRegisterR0
2980
DECLINLINE(int) PDMDevHlpIOPortRegisterR0(PPDMDEVINS pDevIns, RTIOPORT Port, RTUINT cPorts, RTR0PTR pvUser,
2981
const char *pszOut, const char *pszIn, const char *pszOutStr,
2982
const char *pszInStr, const char *pszDesc)
2984
return pDevIns->pDevHlp->pfnIOPortRegisterR0(pDevIns, Port, cPorts, pvUser, pszOut, pszIn, pszOutStr, pszInStr, pszDesc);
2988
* @copydoc PDMDEVHLP::pfnMMIORegister
2990
DECLINLINE(int) PDMDevHlpMMIORegister(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, RTHCPTR pvUser,
2991
PFNIOMMMIOWRITE pfnWrite, PFNIOMMMIOREAD pfnRead, PFNIOMMMIOFILL pfnFill,
2992
const char *pszDesc)
2994
return pDevIns->pDevHlp->pfnMMIORegister(pDevIns, GCPhysStart, cbRange, pvUser, pfnWrite, pfnRead, pfnFill, pszDesc);
2998
* @copydoc PDMDEVHLP::pfnMMIORegisterGC
3000
DECLINLINE(int) PDMDevHlpMMIORegisterGC(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, RTGCPTR pvUser,
3001
const char *pszWrite, const char *pszRead, const char *pszFill, const char *pszDesc)
3003
return pDevIns->pDevHlp->pfnMMIORegisterGC(pDevIns, GCPhysStart, cbRange, pvUser, pszWrite, pszRead, pszFill, pszDesc);
3007
* @copydoc PDMDEVHLP::pfnMMIORegisterR0
3009
DECLINLINE(int) PDMDevHlpMMIORegisterR0(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, RTR0PTR pvUser,
3010
const char *pszWrite, const char *pszRead, const char *pszFill, const char *pszDesc)
3012
return pDevIns->pDevHlp->pfnMMIORegisterR0(pDevIns, GCPhysStart, cbRange, pvUser, pszWrite, pszRead, pszFill, pszDesc);
3016
* @copydoc PDMDEVHLP::pfnROMRegister
3018
DECLINLINE(int) PDMDevHlpROMRegister(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, const void *pvBinary, bool fShadow, const char *pszDesc)
3020
return pDevIns->pDevHlp->pfnROMRegister(pDevIns, GCPhysStart, cbRange, pvBinary, fShadow, pszDesc);
3024
* @copydoc PDMDEVHLP::pfnROMProtectShadow
3026
DECLINLINE(int) PDMDevHlpROMProtectShadow(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange)
3028
return pDevIns->pDevHlp->pfnROMProtectShadow(pDevIns, GCPhysStart, cbRange);
3032
* @copydoc PDMDEVHLP::pfnSSMRegister
3034
DECLINLINE(int) PDMDevHlpSSMRegister(PPDMDEVINS pDevIns, const char *pszName, uint32_t u32Instance, uint32_t u32Version, size_t cbGuess,
3035
PFNSSMDEVSAVEPREP pfnSavePrep, PFNSSMDEVSAVEEXEC pfnSaveExec, PFNSSMDEVSAVEDONE pfnSaveDone,
3036
PFNSSMDEVLOADPREP pfnLoadPrep, PFNSSMDEVLOADEXEC pfnLoadExec, PFNSSMDEVLOADDONE pfnLoadDone)
3038
return pDevIns->pDevHlp->pfnSSMRegister(pDevIns, pszName, u32Instance, u32Version, cbGuess,
3039
pfnSavePrep, pfnSaveExec, pfnSaveDone,
3040
pfnLoadPrep, pfnLoadExec, pfnLoadDone);
3044
* @copydoc PDMDEVHLP::pfnTMTimerCreate
3046
DECLINLINE(int) PDMDevHlpTMTimerCreate(PPDMDEVINS pDevIns, TMCLOCK enmClock, PFNTMTIMERDEV pfnCallback, const char *pszDesc, PPTMTIMERHC ppTimer)
3048
return pDevIns->pDevHlp->pfnTMTimerCreate(pDevIns, enmClock, pfnCallback, pszDesc, ppTimer);
3052
* @copydoc PDMDEVHLP::pfnPCIRegister
3054
DECLINLINE(int) PDMDevHlpPCIRegister(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev)
3056
return pDevIns->pDevHlp->pfnPCIRegister(pDevIns, pPciDev);
3060
* @copydoc PDMDEVHLP::pfnPCIIORegionRegister
3062
DECLINLINE(int) PDMDevHlpPCIIORegionRegister(PPDMDEVINS pDevIns, int iRegion, uint32_t cbRegion, PCIADDRESSSPACE enmType, PFNPCIIOREGIONMAP pfnCallback)
3064
return pDevIns->pDevHlp->pfnPCIIORegionRegister(pDevIns, iRegion, cbRegion, enmType, pfnCallback);
3068
* @copydoc PDMDEVHLP::pfnPCISetConfigCallbacks
3070
DECLINLINE(void) PDMDevHlpPCISetConfigCallbacks(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, PFNPCICONFIGREAD pfnRead, PPFNPCICONFIGREAD ppfnReadOld,
3071
PFNPCICONFIGWRITE pfnWrite, PPFNPCICONFIGWRITE ppfnWriteOld)
3073
pDevIns->pDevHlp->pfnPCISetConfigCallbacks(pDevIns, pPciDev, pfnRead, ppfnReadOld, pfnWrite, ppfnWriteOld);
3077
* @copydoc PDMDEVHLP::pfnDriverAttach
3079
DECLINLINE(int) PDMDevHlpDriverAttach(PPDMDEVINS pDevIns, RTUINT iLun, PPDMIBASE pBaseInterface, PPDMIBASE *ppBaseInterface, const char *pszDesc)
3081
return pDevIns->pDevHlp->pfnDriverAttach(pDevIns, iLun, pBaseInterface, ppBaseInterface, pszDesc);
3085
* @copydoc PDMDEVHLP::pfnMMHeapAlloc
3087
DECLINLINE(void *) PDMDevHlpMMHeapAlloc(PPDMDEVINS pDevIns, size_t cb)
3089
return pDevIns->pDevHlp->pfnMMHeapAlloc(pDevIns, cb);
3093
* @copydoc PDMDEVHLP::pfnMMHeapAllocZ
3095
DECLINLINE(void *) PDMDevHlpMMHeapAllocZ(PPDMDEVINS pDevIns, size_t cb)
3097
return pDevIns->pDevHlp->pfnMMHeapAllocZ(pDevIns, cb);
3101
* @copydoc PDMDEVHLP::pfnMMHeapFree
3103
DECLINLINE(void) PDMDevHlpMMHeapFree(PPDMDEVINS pDevIns, void *pv)
3105
pDevIns->pDevHlp->pfnMMHeapFree(pDevIns, pv);
3109
* @copydoc PDMDEVHLP::pfnDBGFInfoRegister
3111
DECLINLINE(int) PDMDevHlpDBGFInfoRegister(PPDMDEVINS pDevIns, const char *pszName, const char *pszDesc, PFNDBGFHANDLERDEV pfnHandler)
3113
return pDevIns->pDevHlp->pfnDBGFInfoRegister(pDevIns, pszName, pszDesc, pfnHandler);
3117
* @copydoc PDMDEVHLP::pfnSTAMRegister
3119
DECLINLINE(void) PDMDevHlpSTAMRegister(PPDMDEVINS pDevIns, void *pvSample, STAMTYPE enmType, const char *pszName, STAMUNIT enmUnit, const char *pszDesc)
3121
pDevIns->pDevHlp->pfnSTAMRegister(pDevIns, pvSample, enmType, pszName, enmUnit, pszDesc);
3125
* @copydoc PDMDEVHLP::pfnSTAMRegisterF
3127
DECLINLINE(void) PDMDevHlpSTAMRegisterF(PPDMDEVINS pDevIns, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility, STAMUNIT enmUnit,
3128
const char *pszDesc, const char *pszName, ...)
3131
va_start(va, pszName);
3132
pDevIns->pDevHlp->pfnSTAMRegisterV(pDevIns, pvSample, enmType, enmVisibility, enmUnit, pszDesc, pszName, va);
3137
* @copydoc PDMDEVHLP::pfnPDMQueueCreate
3139
DECLINLINE(int) PDMDevHlpPDMQueueCreate(PPDMDEVINS pDevIns, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval,
3140
PFNPDMQUEUEDEV pfnCallback, bool fGCEnabled, PPDMQUEUE *ppQueue)
3142
return pDevIns->pDevHlp->pfnPDMQueueCreate(pDevIns, cbItem, cItems, cMilliesInterval, pfnCallback, fGCEnabled, ppQueue);
3146
* @copydoc PDMDEVHLP::pfnCritSectInit
3148
DECLINLINE(int) PDMDevHlpCritSectInit(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, const char *pszName)
3150
return pDevIns->pDevHlp->pfnCritSectInit(pDevIns, pCritSect, pszName);
3154
* @copydoc PDMDEVHLP::pfnUTCNow
3156
DECLINLINE(PRTTIMESPEC) PDMDevHlpUTCNow(PPDMDEVINS pDevIns, PRTTIMESPEC pTime)
3158
return pDevIns->pDevHlp->pfnUTCNow(pDevIns, pTime);
3162
* @copydoc PDMDEVHLP::pfnGetVM
3164
DECLINLINE(PVM) PDMDevHlpGetVM(PPDMDEVINS pDevIns)
3166
return pDevIns->pDevHlp->pfnGetVM(pDevIns);
3170
* @copydoc PDMDEVHLP::pfnPhysReadGCVirt
3172
DECLINLINE(int) PDMDevHlpPhysReadGCVirt(PPDMDEVINS pDevIns, void *pvDst, RTGCPTR GCVirtSrc, size_t cb)
3174
return pDevIns->pDevHlp->pfnPhysReadGCVirt(pDevIns, pvDst, GCVirtSrc, cb);
3178
* @copydoc PDMDEVHLP::pfnPhysWriteGCVirt
3180
DECLINLINE(int) PDMDevHlpPhysWriteGCVirt(PPDMDEVINS pDevIns, RTGCPTR GCVirtDst, const void *pvSrc, size_t cb)
3182
return pDevIns->pDevHlp->pfnPhysWriteGCVirt(pDevIns, GCVirtDst, pvSrc, cb);
3186
* @copydoc PDMDEVHLP::pfnPhysReserve
3188
DECLINLINE(int) PDMDevHlpPhysReserve(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTUINT cbRange, const char *pszDesc)
3190
return pDevIns->pDevHlp->pfnPhysReserve(pDevIns, GCPhys, cbRange, pszDesc);
3194
* @copydoc PDMDEVHLP::pfnPhys2HCVirt
3196
DECLINLINE(int) PDMDevHlpPhys2HCVirt(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTUINT cbRange, PRTHCPTR ppvHC)
3198
return pDevIns->pDevHlp->pfnPhys2HCVirt(pDevIns, GCPhys, cbRange, ppvHC);
3202
* @copydoc PDMDEVHLP::pfnPhysGCPtr2HCPtr
3204
DECLINLINE(int) PDMDevHlpPhysGCPtr2HCPtr(PPDMDEVINS pDevIns, RTGCPTR GCPtr, PRTHCPTR pHCPtr)
3206
return pDevIns->pDevHlp->pfnPhysGCPtr2HCPtr(pDevIns, GCPtr, pHCPtr);
3210
* @copydoc PDMDEVHLP::pfnA20Set
3212
DECLINLINE(void) PDMDevHlpA20Set(PPDMDEVINS pDevIns, bool fEnable)
3214
pDevIns->pDevHlp->pfnA20Set(pDevIns, fEnable);
3218
* @copydoc PDMDEVHLP::pfnVMReset
3220
DECLINLINE(int) PDMDevHlpVMReset(PPDMDEVINS pDevIns)
3222
return pDevIns->pDevHlp->pfnVMReset(pDevIns);
3226
* @copydoc PDMDEVHLP::pfnVMSuspend
3228
DECLINLINE(int) PDMDevHlpVMSuspend(PPDMDEVINS pDevIns)
3230
return pDevIns->pDevHlp->pfnVMSuspend(pDevIns);
3234
* @copydoc PDMDEVHLP::pfnVMPowerOff
3236
DECLINLINE(int) PDMDevHlpVMPowerOff(PPDMDEVINS pDevIns)
3238
return pDevIns->pDevHlp->pfnVMPowerOff(pDevIns);
3242
* @copydoc PDMDEVHLP::pfnDMARegister
3244
DECLINLINE(int) PDMDevHlpDMARegister(PPDMDEVINS pDevIns, unsigned uChannel, PFNDMATRANSFERHANDLER pfnTransferHandler, void *pvUser)
3246
return pDevIns->pDevHlp->pfnDMARegister(pDevIns, uChannel, pfnTransferHandler, pvUser);
3250
* @copydoc PDMDEVHLP::pfnDMAReadMemory
3252
DECLINLINE(int) PDMDevHlpDMAReadMemory(PPDMDEVINS pDevIns, unsigned uChannel, void *pvBuffer, uint32_t off, uint32_t cbBlock, uint32_t *pcbRead)
3254
return pDevIns->pDevHlp->pfnDMAReadMemory(pDevIns, uChannel, pvBuffer, off, cbBlock, pcbRead);
3258
* @copydoc PDMDEVHLP::pfnDMAWriteMemory
3260
DECLINLINE(int) PDMDevHlpDMAWriteMemory(PPDMDEVINS pDevIns, unsigned uChannel, const void *pvBuffer, uint32_t off, uint32_t cbBlock, uint32_t *pcbWritten)
3262
return pDevIns->pDevHlp->pfnDMAWriteMemory(pDevIns, uChannel, pvBuffer, off, cbBlock, pcbWritten);
3266
* @copydoc PDMDEVHLP::pfnDMASetDREQ
3268
DECLINLINE(int) PDMDevHlpDMASetDREQ(PPDMDEVINS pDevIns, unsigned uChannel, unsigned uLevel)
3270
return pDevIns->pDevHlp->pfnDMASetDREQ(pDevIns, uChannel, uLevel);
3274
* @copydoc PDMDEVHLP::pfnDMAGetChannelMode
3276
DECLINLINE(uint8_t) PDMDevHlpDMAGetChannelMode(PPDMDEVINS pDevIns, unsigned uChannel)
3278
return pDevIns->pDevHlp->pfnDMAGetChannelMode(pDevIns, uChannel);
3282
* @copydoc PDMDEVHLP::pfnDMASchedule
3284
DECLINLINE(void) PDMDevHlpDMASchedule(PPDMDEVINS pDevIns)
3286
pDevIns->pDevHlp->pfnDMASchedule(pDevIns);
3290
* @copydoc PDMDEVHLP::pfnCMOSWrite
3292
DECLINLINE(int) PDMDevHlpCMOSWrite(PPDMDEVINS pDevIns, unsigned iReg, uint8_t u8Value)
3294
return pDevIns->pDevHlp->pfnCMOSWrite(pDevIns, iReg, u8Value);
3298
* @copydoc PDMDEVHLP::pfnCMOSRead
3300
DECLINLINE(int) PDMDevHlpCMOSRead(PPDMDEVINS pDevIns, unsigned iReg, uint8_t *pu8Value)
3302
return pDevIns->pDevHlp->pfnCMOSRead(pDevIns, iReg, pu8Value);
3306
* @copydoc PDMDEVHLP::pfnGetCpuId
3308
DECLINLINE(void) PDMDevHlpGetCpuId(PPDMDEVINS pDevIns, uint32_t iLeaf, uint32_t *pEax, uint32_t *pEbx, uint32_t *pEcx, uint32_t *pEdx)
3310
pDevIns->pDevHlp->pfnGetCpuId(pDevIns, iLeaf, pEax, pEbx, pEcx, pEdx);
3314
* @copydoc PDMDEVHLP::pfnPDMThreadCreate
3316
DECLINLINE(int) PDMDevHlpPDMThreadCreate(PPDMDEVINS pDevIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADDEV pfnThread,
3317
PFNPDMTHREADWAKEUPDEV pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName)
3319
return pDevIns->pDevHlp->pfnPDMThreadCreate(pDevIns, ppThread, pvUser, pfnThread, pfnWakeup, cbStack, enmType, pszName);
3321
#endif /* IN_RING3 */
3325
* @copydoc PDMDEVHLP::pfnPCISetIrq
3327
DECLINLINE(void) PDMDevHlpPCISetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel)
3330
pDevIns->pDevHlpGC->pfnPCISetIrq(pDevIns, iIrq, iLevel);
3331
#elif defined(IN_RING0)
3332
pDevIns->pDevHlpR0->pfnPCISetIrq(pDevIns, iIrq, iLevel);
3334
pDevIns->pDevHlp->pfnPCISetIrq(pDevIns, iIrq, iLevel);
3339
* @copydoc PDMDEVHLP::pfnPCISetIrqNoWait
3341
DECLINLINE(void) PDMDevHlpPCISetIrqNoWait(PPDMDEVINS pDevIns, int iIrq, int iLevel)
3344
pDevIns->pDevHlpGC->pfnPCISetIrq(pDevIns, iIrq, iLevel);
3345
#elif defined(IN_RING0)
3346
pDevIns->pDevHlpR0->pfnPCISetIrq(pDevIns, iIrq, iLevel);
3348
pDevIns->pDevHlp->pfnPCISetIrqNoWait(pDevIns, iIrq, iLevel);
3353
* @copydoc PDMDEVHLP::pfnISASetIrq
3355
DECLINLINE(void) PDMDevHlpISASetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel)
3358
pDevIns->pDevHlpGC->pfnISASetIrq(pDevIns, iIrq, iLevel);
3359
#elif defined(IN_RING0)
3360
pDevIns->pDevHlpR0->pfnISASetIrq(pDevIns, iIrq, iLevel);
3362
pDevIns->pDevHlp->pfnISASetIrq(pDevIns, iIrq, iLevel);
3367
* @copydoc PDMDEVHLP::pfnISASetIrqNoWait
3369
DECLINLINE(void) PDMDevHlpISASetIrqNoWait(PPDMDEVINS pDevIns, int iIrq, int iLevel)
3372
pDevIns->pDevHlpGC->pfnISASetIrq(pDevIns, iIrq, iLevel);
3373
#elif defined(IN_RING0)
3374
pDevIns->pDevHlpR0->pfnISASetIrq(pDevIns, iIrq, iLevel);
3376
pDevIns->pDevHlp->pfnISASetIrqNoWait(pDevIns, iIrq, iLevel);
3381
* @copydoc PDMDEVHLP::pfnPhysRead
3383
DECLINLINE(void) PDMDevHlpPhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)
3386
pDevIns->pDevHlpGC->pfnPhysRead(pDevIns, GCPhys, pvBuf, cbRead);
3387
#elif defined(IN_RING0)
3388
pDevIns->pDevHlpR0->pfnPhysRead(pDevIns, GCPhys, pvBuf, cbRead);
3390
pDevIns->pDevHlp->pfnPhysRead(pDevIns, GCPhys, pvBuf, cbRead);
3395
* @copydoc PDMDEVHLP::pfnPhysWrite
3397
DECLINLINE(void) PDMDevHlpPhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)
3400
pDevIns->pDevHlpGC->pfnPhysWrite(pDevIns, GCPhys, pvBuf, cbWrite);
3401
#elif defined(IN_RING0)
3402
pDevIns->pDevHlpR0->pfnPhysWrite(pDevIns, GCPhys, pvBuf, cbWrite);
3404
pDevIns->pDevHlp->pfnPhysWrite(pDevIns, GCPhys, pvBuf, cbWrite);
3409
* @copydoc PDMDEVHLP::pfnA20IsEnabled
3411
DECLINLINE(bool) PDMDevHlpA20IsEnabled(PPDMDEVINS pDevIns)
3414
return pDevIns->pDevHlpGC->pfnA20IsEnabled(pDevIns);
3415
#elif defined(IN_RING0)
3416
return pDevIns->pDevHlpR0->pfnA20IsEnabled(pDevIns);
3418
return pDevIns->pDevHlp->pfnA20IsEnabled(pDevIns);
3423
* @copydoc PDMDEVHLP::pfnVMSetError
3425
DECLINLINE(int) PDMDevHlpVMSetError(PPDMDEVINS pDevIns, const int rc, RT_SRC_POS_DECL, const char *pszFormat, ...)
3428
va_start(va, pszFormat);
3430
pDevIns->pDevHlpGC->pfnVMSetErrorV(pDevIns, rc, RT_SRC_POS_ARGS, pszFormat, va);
3431
#elif defined(IN_RING0)
3432
pDevIns->pDevHlpR0->pfnVMSetErrorV(pDevIns, rc, RT_SRC_POS_ARGS, pszFormat, va);
3434
pDevIns->pDevHlp->pfnVMSetErrorV(pDevIns, rc, RT_SRC_POS_ARGS, pszFormat, va);
3441
* @copydoc PDMDEVHLP::pfnVMSetRuntimeError
3443
DECLINLINE(int) PDMDevHlpVMSetRuntimeError(PPDMDEVINS pDevIns, bool fFatal, const char *pszErrorID, const char *pszFormat, ...)
3447
va_start(va, pszFormat);
3449
rc = pDevIns->pDevHlpGC->pfnVMSetRuntimeErrorV(pDevIns, fFatal, pszErrorID, pszFormat, va);
3450
#elif defined(IN_RING0)
3451
rc = pDevIns->pDevHlpR0->pfnVMSetRuntimeErrorV(pDevIns, fFatal, pszErrorID, pszFormat, va);
3453
rc = pDevIns->pDevHlp->pfnVMSetRuntimeErrorV(pDevIns, fFatal, pszErrorID, pszFormat, va);
3461
/** Pointer to callbacks provided to the VBoxDeviceRegister() call. */
3462
typedef struct PDMDEVREGCB *PPDMDEVREGCB;
3465
* Callbacks for VBoxDeviceRegister().
3467
typedef struct PDMDEVREGCB
3469
/** Interface version.
3470
* This is set to PDM_DEVREG_CB_VERSION. */
3471
uint32_t u32Version;
3474
* Registers a device with the current VM instance.
3476
* @returns VBox status code.
3477
* @param pCallbacks Pointer to the callback table.
3478
* @param pDevReg Pointer to the device registration record.
3479
* This data must be permanent and readonly.
3481
DECLR3CALLBACKMEMBER(int, pfnRegister,(PPDMDEVREGCB pCallbacks, PCPDMDEVREG pDevReg));
3484
* Allocate memory which is associated with current VM instance
3485
* and automatically freed on it's destruction.
3487
* @returns Pointer to allocated memory. The memory is *NOT* zero-ed.
3488
* @param pCallbacks Pointer to the callback table.
3489
* @param cb Number of bytes to allocate.
3491
DECLR3CALLBACKMEMBER(void *, pfnMMHeapAlloc,(PPDMDEVREGCB pCallbacks, size_t cb));
3494
/** Current version of the PDMDEVREGCB structure. */
3495
#define PDM_DEVREG_CB_VERSION 0xf4010000
3499
* The VBoxDevicesRegister callback function.
3501
* PDM will invoke this function after loading a device module and letting
3502
* the module decide which devices to register and how to handle conflicts.
3504
* @returns VBox status code.
3505
* @param pCallbacks Pointer to the callback table.
3506
* @param u32Version VBox version number.
3508
typedef DECLCALLBACK(int) FNPDMVBOXDEVICESREGISTER(PPDMDEVREGCB pCallbacks, uint32_t u32Version);