VirtualBox

source: vbox/trunk/include/VBox/vmm/pdmpcidevint.h@ 93963

Last change on this file since 93963 was 93115, checked in by vboxsync, 3 years ago

scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.3 KB
Line 
1/* $Id: pdmpcidevint.h 93115 2022-01-01 11:31:46Z vboxsync $ */
2/** @file
3 * DevPCI - PDM PCI Internal header - Only for hiding bits of PDMPCIDEV.
4 */
5
6/*
7 * Copyright (C) 2006-2022 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27#ifndef VBOX_INCLUDED_vmm_pdmpcidevint_h
28#define VBOX_INCLUDED_vmm_pdmpcidevint_h
29#ifndef RT_WITHOUT_PRAGMA_ONCE
30# pragma once
31#endif
32
33#include <VBox/vmm/pdmdev.h>
34
35/** @defgroup grp_pdm_pcidev_int The PDM PCI Device Internals
36 * @ingroup grp_pdm_pcidev
37 *
38 * @remarks The PDM PCI device internals are visible to both PDM and the PCI Bus
39 * implementation, thus it lives among the the public headers despite
40 * being rather private and internal.
41 *
42 * @{
43 */
44
45
46/**
47 * PCI I/O region.
48 */
49typedef struct PCIIOREGION
50{
51 /** Current PCI mapping address, INVALID_PCI_ADDRESS (0xffffffff) means not mapped. */
52 uint64_t addr;
53 /** The region size. Power of 2. */
54 uint64_t size;
55 /** Handle or UINT64_MAX (see PDMPCIDEV_IORGN_F_HANDLE_MASK in fFlags). */
56 uint64_t hHandle;
57 /** PDMPCIDEV_IORGN_F_XXXX. */
58 uint32_t fFlags;
59 /** PCIADDRESSSPACE */
60 uint8_t type;
61 uint8_t abPadding0[3];
62 /** Callback called when the region is mapped or unmapped (new style devs). */
63 R3PTRTYPE(PFNPCIIOREGIONMAP) pfnMap;
64#if R3_ARCH_BITS == 32
65 uint32_t u32Padding2;
66#endif
67} PCIIOREGION;
68AssertCompileSize(PCIIOREGION, 5*8);
69/** Pointer to a PCI I/O region. */
70typedef PCIIOREGION *PPCIIOREGION;
71/** Pointer to a const PCI I/O region. */
72typedef PCIIOREGION const *PCPCIIOREGION;
73
74/**
75 * Callback function for reading from the PCI configuration space.
76 *
77 * @returns Strict VBox status code.
78 * @param pDevIns Pointer to the device instance of the PCI bus.
79 * @param iBus The bus number this device is on.
80 * @param iDevice The number of the device on the bus.
81 * @param u32Address The configuration space register address. [0..255]
82 * @param cb The register size. [1,2,4]
83 * @param pu32Value Where to return the register value.
84 */
85typedef DECLCALLBACKTYPE(VBOXSTRICTRC, FNPCIBRIDGECONFIGREAD,(PPDMDEVINSR3 pDevIns, uint8_t iBus, uint8_t iDevice,
86 uint32_t u32Address, unsigned cb, uint32_t *pu32Value));
87/** Pointer to a FNPCICONFIGREAD() function. */
88typedef FNPCIBRIDGECONFIGREAD *PFNPCIBRIDGECONFIGREAD;
89#if !RT_CLANG_PREREQ(11, 0) /* Clang 11 (at least) has trouble with nothrow and pointers to function pointers. */
90/** Pointer to a PFNPCICONFIGREAD. */
91typedef PFNPCIBRIDGECONFIGREAD *PPFNPCIBRIDGECONFIGREAD;
92#endif
93
94/**
95 * Callback function for writing to the PCI configuration space.
96 *
97 * @returns Strict VBox status code.
98 * @param pDevIns Pointer to the device instance of the PCI bus.
99 * @param iBus The bus number this device is on.
100 * @param iDevice The number of the device on the bus.
101 * @param u32Address The configuration space register address. [0..255]
102 * @param cb The register size. [1,2,4]
103 * @param u32Value The value that's being written. The number of bits actually used from
104 * this value is determined by the cb parameter.
105 */
106typedef DECLCALLBACKTYPE(VBOXSTRICTRC, FNPCIBRIDGECONFIGWRITE,(PPDMDEVINSR3 pDevIns, uint8_t iBus, uint8_t iDevice,
107 uint32_t u32Address, unsigned cb, uint32_t u32Value));
108/** Pointer to a FNPCICONFIGWRITE() function. */
109typedef FNPCIBRIDGECONFIGWRITE *PFNPCIBRIDGECONFIGWRITE;
110#if !RT_CLANG_PREREQ(11, 0) /* Clang 11 (at least) has trouble with nothrow and pointers to function pointers. */
111/** Pointer to a PFNPCICONFIGWRITE. */
112typedef PFNPCIBRIDGECONFIGWRITE *PPFNPCIBRIDGECONFIGWRITE;
113#endif
114
115/* Forward declaration */
116struct DEVPCIBUS;
117
118enum {
119 /** Flag whether the device is a pci-to-pci bridge.
120 * This is set prior to device registration. */
121 PCIDEV_FLAG_PCI_TO_PCI_BRIDGE = RT_BIT_32(1),
122 /** Flag whether the device is a PCI Express device.
123 * This is set prior to device registration. */
124 PCIDEV_FLAG_PCI_EXPRESS_DEVICE = RT_BIT_32(2),
125 /** Flag whether the device is capable of MSI.
126 * This one is set by MsiInit(). */
127 PCIDEV_FLAG_MSI_CAPABLE = RT_BIT_32(3),
128 /** Flag whether the device is capable of MSI-X.
129 * This one is set by MsixInit(). */
130 PCIDEV_FLAG_MSIX_CAPABLE = RT_BIT_32(4),
131 /** Flag if device represents real physical device in passthrough mode. */
132 PCIDEV_FLAG_PASSTHROUGH = RT_BIT_32(5),
133 /** Flag whether the device is capable of MSI using 64-bit address. */
134 PCIDEV_FLAG_MSI64_CAPABLE = RT_BIT_32(6)
135
136};
137
138
139/**
140 * PDM PCI Device - Internal data.
141 *
142 * @sa PDMPCIDEV
143 */
144typedef struct PDMPCIDEVINT
145{
146 /** @name Owned by PDM.
147 * @remarks The bus may use the device instance pointers.
148 * @{
149 */
150 /** Pointer to the PDM device the PCI device belongs to. (R3 ptr) */
151 PPDMDEVINSR3 pDevInsR3;
152 /** The CFGM device configuration index (default, PciDev1..255).
153 * This also works as the internal sub-device ordinal with MMIOEx.
154 * @note Same value as idxSubDev, can therefore be removed later. */
155 uint8_t idxDevCfg;
156 /** Set if the it can be reassigned to a different PCI device number. */
157 bool fReassignableDevNo;
158 /** Set if the it can be reassigned to a different PCI function number. */
159 bool fReassignableFunNo;
160 /** Alignment padding - used by ICH9 for region swapping (DevVGA hack). */
161 uint8_t bPadding0;
162 /** Index into the PDM internal bus array (PDM::aPciBuses). */
163 uint8_t idxPdmBus;
164 /** Set if this device has been registered. */
165 bool fRegistered;
166 /** Index into PDMDEVINSR3::apPciDevs (same as PDMPCIDEV::idxSubDev). */
167 uint16_t idxSubDev;
168 /** @} */
169
170 /** @name Owned by the PCI Bus
171 * @remarks PDM will not touch anything here (includes not relocating anything).
172 * @{
173 */
174 /** Pointer to the PCI bus of the device. (R3 ptr) */
175 R3PTRTYPE(struct DEVPCIBUS *) pBusR3;
176 /** Read config callback. */
177 R3PTRTYPE(PFNPCICONFIGREAD) pfnConfigRead;
178 /** Write config callback. */
179 R3PTRTYPE(PFNPCICONFIGWRITE) pfnConfigWrite;
180 /** Read config callback for PCI bridges to pass requests
181 * to devices on another bus. */
182 R3PTRTYPE(PFNPCIBRIDGECONFIGREAD) pfnBridgeConfigRead;
183 /** Write config callback for PCI bridges to pass requests
184 * to devices on another bus. */
185 R3PTRTYPE(PFNPCIBRIDGECONFIGWRITE) pfnBridgeConfigWrite;
186
187 /** Flags of this PCI device, see PCIDEV_FLAG_XXX constants. */
188 uint32_t fFlags;
189 /** Current state of the IRQ pin of the device. */
190 int32_t uIrqPinState;
191
192 /** Offset of MSI PCI capability in config space, or 0.
193 * @todo fix non-standard naming. */
194 uint8_t u8MsiCapOffset;
195 /** Size of MSI PCI capability in config space, or 0.
196 * @todo fix non-standard naming. */
197 uint8_t u8MsiCapSize;
198 /** Offset of MSI-X PCI capability in config space, or 0.
199 * @todo fix non-standard naming. */
200 uint8_t u8MsixCapOffset;
201 /** Size of MSI-X PCI capability in config space, or 0.
202 * @todo fix non-standard naming. */
203 uint8_t u8MsixCapSize;
204 /** Size of the MSI-X region. */
205 uint16_t cbMsixRegion;
206 /** Offset to the PBA for MSI-X. */
207 uint16_t offMsixPba;
208 /** Add padding to align aIORegions to an 16 byte boundary. */
209 uint8_t abPadding2[HC_ARCH_BITS == 32 ? 12 : 8];
210 /** The MMIO handle for the MSI-X MMIO bar. */
211 IOMMMIOHANDLE hMmioMsix;
212
213 /** Pointer to bus specific data. (R3 ptr) */
214 R3PTRTYPE(const void *) pvPciBusPtrR3;
215 /** I/O regions. */
216 PCIIOREGION aIORegions[VBOX_PCI_NUM_REGIONS];
217 /** @} */
218} PDMPCIDEVINT;
219AssertCompileMemberAlignment(PDMPCIDEVINT, aIORegions, 8);
220AssertCompileSize(PDMPCIDEVINT, HC_ARCH_BITS == 32 ? 0x98 : 0x178);
221
222/** Indicate that PDMPCIDEV::Int.s can be declared. */
223#define PDMPCIDEVINT_DECLARED
224
225/** @} */
226
227#endif /* !VBOX_INCLUDED_vmm_pdmpcidevint_h */
228
Note: See TracBrowser for help on using the repository browser.

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