VirtualBox

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

Last change on this file since 80722 was 80722, checked in by vboxsync, 5 years ago

PDM,PCI: More PDMPCIDEV related refactoring work, mainly concerned with eliminating unnecessary pointers. bugref:9218

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.2 KB
Line 
1/* $Id: pdmpcidevint.h 80722 2019-09-11 09:21:47Z vboxsync $ */
2/** @file
3 * DevPCI - PDM PCI Internal header - Only for hiding bits of PDMPCIDEV.
4 */
5
6/*
7 * Copyright (C) 2006-2019 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, 0xffffffff means not mapped. */
52 uint64_t addr;
53 uint64_t size;
54 uint8_t type; /* PCIADDRESSSPACE */
55 uint8_t padding[HC_ARCH_BITS == 32 ? 3 : 7];
56 /** Callback called when the region is mapped. */
57 R3PTRTYPE(PFNPCIIOREGIONMAP) map_func;
58} PCIIOREGION, PCIIORegion;
59/** Pointer to PCI I/O region. */
60typedef PCIIOREGION *PPCIIOREGION;
61
62/**
63 * Callback function for reading from the PCI configuration space.
64 *
65 * @returns The register value.
66 * @param pDevIns Pointer to the device instance of the PCI bus.
67 * @param iBus The bus number this device is on.
68 * @param iDevice The number of the device on the bus.
69 * @param u32Address The configuration space register address. [0..255]
70 * @param cb The register size. [1,2,4]
71 */
72typedef DECLCALLBACK(uint32_t) FNPCIBRIDGECONFIGREAD(PPDMDEVINSR3 pDevIns, uint8_t iBus, uint8_t iDevice, uint32_t u32Address, unsigned cb);
73/** Pointer to a FNPCICONFIGREAD() function. */
74typedef FNPCIBRIDGECONFIGREAD *PFNPCIBRIDGECONFIGREAD;
75/** Pointer to a PFNPCICONFIGREAD. */
76typedef PFNPCIBRIDGECONFIGREAD *PPFNPCIBRIDGECONFIGREAD;
77
78/**
79 * Callback function for writing to the PCI configuration space.
80 *
81 * @param pDevIns Pointer to the device instance of the PCI bus.
82 * @param iBus The bus number this device is on.
83 * @param iDevice The number of the device on the bus.
84 * @param u32Address The configuration space register address. [0..255]
85 * @param u32Value The value that's being written. The number of bits actually used from
86 * this value is determined by the cb parameter.
87 * @param cb The register size. [1,2,4]
88 */
89typedef DECLCALLBACK(void) FNPCIBRIDGECONFIGWRITE(PPDMDEVINSR3 pDevIns, uint8_t iBus, uint8_t iDevice, uint32_t u32Address, uint32_t u32Value, unsigned cb);
90/** Pointer to a FNPCICONFIGWRITE() function. */
91typedef FNPCIBRIDGECONFIGWRITE *PFNPCIBRIDGECONFIGWRITE;
92/** Pointer to a PFNPCICONFIGWRITE. */
93typedef PFNPCIBRIDGECONFIGWRITE *PPFNPCIBRIDGECONFIGWRITE;
94
95/* Forward declaration */
96struct DEVPCIBUS;
97
98enum {
99 /** Flag whether the device is a pci-to-pci bridge.
100 * This is set prior to device registration. */
101 PCIDEV_FLAG_PCI_TO_PCI_BRIDGE = RT_BIT_32(1),
102 /** Flag whether the device is a PCI Express device.
103 * This is set prior to device registration. */
104 PCIDEV_FLAG_PCI_EXPRESS_DEVICE = RT_BIT_32(2),
105 /** Flag whether the device is capable of MSI.
106 * This one is set by MsiInit(). */
107 PCIDEV_FLAG_MSI_CAPABLE = RT_BIT_32(3),
108 /** Flag whether the device is capable of MSI-X.
109 * This one is set by MsixInit(). */
110 PCIDEV_FLAG_MSIX_CAPABLE = RT_BIT_32(4),
111 /** Flag if device represents real physical device in passthrough mode. */
112 PCIDEV_FLAG_PASSTHROUGH = RT_BIT_32(5),
113 /** Flag whether the device is capable of MSI using 64-bit address. */
114 PCIDEV_FLAG_MSI64_CAPABLE = RT_BIT_32(6)
115
116};
117
118
119/**
120 * PDM PCI Device - Internal data.
121 *
122 * @sa PDMPCIDEV
123 */
124typedef struct PDMPCIDEVINT
125{
126 /** @name Owned by PDM.
127 * @remarks The bus may use the device instance pointers.
128 * @{
129 */
130 /** Pointer to the PDM device the PCI device belongs to. (R3 ptr) */
131 PPDMDEVINSR3 pDevInsR3;
132 /** Pointer to the next PDM device associate with the PDM device. (R3 ptr) */
133 R3PTRTYPE(PPDMPCIDEV) pNextR3;
134 /** Pointer to the next PDM device associate with the PDM device. (R0 ptr) */
135 R0PTRTYPE(PPDMPCIDEV) pNextR0;
136
137 /** The CFGM device configuration index (default, PciDev1..255).
138 * This also works as the internal sub-device ordinal with MMIOEx. */
139 uint8_t idxDevCfg;
140 /** Set if the it can be reassigned to a different PCI device number. */
141 bool fReassignableDevNo;
142 /** Set if the it can be reassigned to a different PCI function number. */
143 bool fReassignableFunNo;
144 /** Alignment padding - used by ICH9 for region swapping (DevVGA hack). */
145 uint8_t bPadding0;
146 /** Index into the PDM internal bus array (PDM::aPciBuses). */
147 uint8_t idxPdmBus;
148 /** Index into PDMDEVINSR3::apPciDevs. */
149 uint8_t idxPciDevs;
150
151 /** Alignment padding. */
152 uint8_t abPadding1[2+4+4];
153 RTR0PTR apR0PaddingPdm2[2];
154 RTR3PTR pR3PaddingPdm3;
155 /** @} */
156
157 /** @name Owned by the PCI Bus
158 * @remarks PDM will not touch anything here (includes not relocating anything).
159 * @{
160 */
161 /** Pointer to the PCI bus of the device. (R3 ptr) */
162 R3PTRTYPE(struct DEVPCIBUS *) pBusR3;
163 /** Page used for MSI-X state. (R3 ptr) */
164 R3PTRTYPE(void *) pMsixPageR3;
165 /** Read config callback. */
166 R3PTRTYPE(PFNPCICONFIGREAD) pfnConfigRead;
167 /** Write config callback. */
168 R3PTRTYPE(PFNPCICONFIGWRITE) pfnConfigWrite;
169 /** Read config callback for PCI bridges to pass requests
170 * to devices on another bus. */
171 R3PTRTYPE(PFNPCIBRIDGECONFIGREAD) pfnBridgeConfigRead;
172 /** Write config callback for PCI bridges to pass requests
173 * to devices on another bus. */
174 R3PTRTYPE(PFNPCIBRIDGECONFIGWRITE) pfnBridgeConfigWrite;
175
176 /** Pointer to the PCI bus of the device. (R0 ptr)
177 * @note Only used by ich9pcibridgeSetIrq to find the host (root) bus. */
178 R0PTRTYPE(struct DEVPCIBUS *) pBusR0;
179 /** Page used for MSI-X state. (R0 ptr) */
180 R0PTRTYPE(void *) pMsixPageR0;
181
182 /** Pointer to the PCI bus of the device. (RC ptr)
183 * @note Only used by ich9pcibridgeSetIrq to find the host (root) bus. */
184 RCPTRTYPE(struct DEVPCIBUS *) pBusRC;
185 /** Page used for MSI-X state. (RC ptr) */
186 RCPTRTYPE(void *) pMsixPageRC;
187
188 /** Flags of this PCI device, see PCIDEV_FLAG_XXX constants. */
189 uint32_t fFlags;
190 /** Current state of the IRQ pin of the device. */
191 int32_t uIrqPinState;
192
193 /** Offset of MSI PCI capability in config space, or 0.
194 * @todo fix non-standard naming. */
195 uint8_t u8MsiCapOffset;
196 /** Size of MSI PCI capability in config space, or 0.
197 * @todo fix non-standard naming. */
198 uint8_t u8MsiCapSize;
199 /** Offset of MSI-X PCI capability in config space, or 0.
200 * @todo fix non-standard naming. */
201 uint8_t u8MsixCapOffset;
202 /** Size of MSI-X PCI capability in config space, or 0.
203 * @todo fix non-standard naming. */
204 uint8_t u8MsixCapSize;
205 /** Size of the MSI-X region. */
206 uint16_t cbMsixRegion;
207 /** Offset to the PBA for MSI-X. */
208 uint16_t offMsixPba;
209#if HC_ARCH_BITS == 32
210 /** Add padding to align aIORegions to an 8 byte boundary. */
211 uint8_t abPadding2[12];
212#endif
213
214 /** Pointer to bus specific data. (R3 ptr) */
215 R3PTRTYPE(const void *) pPciBusPtrR3;
216
217 /** I/O regions. */
218 PCIIOREGION aIORegions[VBOX_PCI_NUM_REGIONS];
219 /** @} */
220} PDMPCIDEVINT;
221AssertCompileMemberAlignment(PDMPCIDEVINT, aIORegions, 8);
222AssertCompileSize(PDMPCIDEVINT, HC_ARCH_BITS == 32 ? 280 : 384);
223
224/** Indicate that PDMPCIDEV::Int.s can be declared. */
225#define PDMPCIDEVINT_DECLARED
226
227/** @} */
228
229#endif /* !VBOX_INCLUDED_vmm_pdmpcidevint_h */
230
Note: See TracBrowser for help on using the repository browser.

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