VirtualBox

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

Last change on this file since 73768 was 69107, checked in by vboxsync, 7 years ago

include/VBox/: (C) year

  • 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 69107 2017-10-17 10:53:48Z vboxsync $ */
2/** @file
3 * DevPCI - PDM PCI Internal header - Only for hiding bits of PDMPCIDEV.
4 */
5
6/*
7 * Copyright (C) 2006-2017 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_vmm_pdmpcidevint_h
28#define ___VBox_vmm_pdmpcidevint_h
29
30#include <VBox/vmm/pdmdev.h>
31
32/** @defgroup grp_pdm_pcidev_int The PDM PCI Device Internals
33 * @ingroup grp_pdm_pcidev
34 *
35 * @remarks The PDM PCI device internals are visible to both PDM and the PCI Bus
36 * implementation, thus it lives among the the public headers despite
37 * being rather private and internal.
38 *
39 * @{
40 */
41
42
43/**
44 * PCI I/O region.
45 */
46typedef struct PCIIOREGION
47{
48 /** Current PCI mapping address, 0xffffffff means not mapped. */
49 uint64_t addr;
50 uint64_t size;
51 uint8_t type; /* PCIADDRESSSPACE */
52 uint8_t padding[HC_ARCH_BITS == 32 ? 3 : 7];
53 /** Callback called when the region is mapped. */
54 R3PTRTYPE(PFNPCIIOREGIONMAP) map_func;
55} PCIIOREGION, PCIIORegion;
56/** Pointer to PCI I/O region. */
57typedef PCIIOREGION *PPCIIOREGION;
58
59/**
60 * Callback function for reading from the PCI configuration space.
61 *
62 * @returns The register value.
63 * @param pDevIns Pointer to the device instance of the PCI bus.
64 * @param iBus The bus number this device is on.
65 * @param iDevice The number of the device on the bus.
66 * @param u32Address The configuration space register address. [0..255]
67 * @param cb The register size. [1,2,4]
68 */
69typedef DECLCALLBACK(uint32_t) FNPCIBRIDGECONFIGREAD(PPDMDEVINSR3 pDevIns, uint8_t iBus, uint8_t iDevice, uint32_t u32Address, unsigned cb);
70/** Pointer to a FNPCICONFIGREAD() function. */
71typedef FNPCIBRIDGECONFIGREAD *PFNPCIBRIDGECONFIGREAD;
72/** Pointer to a PFNPCICONFIGREAD. */
73typedef PFNPCIBRIDGECONFIGREAD *PPFNPCIBRIDGECONFIGREAD;
74
75/**
76 * Callback function for writing to the PCI configuration space.
77 *
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 u32Value The value that's being written. The number of bits actually used from
83 * this value is determined by the cb parameter.
84 * @param cb The register size. [1,2,4]
85 */
86typedef DECLCALLBACK(void) FNPCIBRIDGECONFIGWRITE(PPDMDEVINSR3 pDevIns, uint8_t iBus, uint8_t iDevice, uint32_t u32Address, uint32_t u32Value, unsigned cb);
87/** Pointer to a FNPCICONFIGWRITE() function. */
88typedef FNPCIBRIDGECONFIGWRITE *PFNPCIBRIDGECONFIGWRITE;
89/** Pointer to a PFNPCICONFIGWRITE. */
90typedef PFNPCIBRIDGECONFIGWRITE *PPFNPCIBRIDGECONFIGWRITE;
91
92/* Forward declaration */
93struct DEVPCIBUS;
94
95enum {
96 /** Flag whether the device is a pci-to-pci bridge.
97 * This is set prior to device registration. */
98 PCIDEV_FLAG_PCI_TO_PCI_BRIDGE = RT_BIT_32(1),
99 /** Flag whether the device is a PCI Express device.
100 * This is set prior to device registration. */
101 PCIDEV_FLAG_PCI_EXPRESS_DEVICE = RT_BIT_32(2),
102 /** Flag whether the device is capable of MSI.
103 * This one is set by MsiInit(). */
104 PCIDEV_FLAG_MSI_CAPABLE = RT_BIT_32(3),
105 /** Flag whether the device is capable of MSI-X.
106 * This one is set by MsixInit(). */
107 PCIDEV_FLAG_MSIX_CAPABLE = RT_BIT_32(4),
108 /** Flag if device represents real physical device in passthrough mode. */
109 PCIDEV_FLAG_PASSTHROUGH = RT_BIT_32(5),
110 /** Flag whether the device is capable of MSI using 64-bit address. */
111 PCIDEV_FLAG_MSI64_CAPABLE = RT_BIT_32(6)
112
113};
114
115
116/**
117 * PDM PCI Device - Internal data.
118 *
119 * @sa PDMPCIDEV
120 */
121typedef struct PDMPCIDEVINT
122{
123 /** @name Owned by PDM.
124 * @remarks The bus may use the device instance pointers.
125 * @{
126 */
127 /** Pointer to the PDM device the PCI device belongs to. (R3 ptr) */
128 PPDMDEVINSR3 pDevInsR3;
129 /** Pointer to the next PDM device associate with the PDM device. (R3 ptr) */
130 R3PTRTYPE(PPDMPCIDEV) pNextR3;
131 /** Pointer to the internal PDM PCI bus for the device. (R3 ptr) */
132 R3PTRTYPE(struct PDMPCIBUS *) pPdmBusR3;
133
134 /** Pointer to the PDM device the PCI device belongs to. (R0 ptr) */
135 PPDMDEVINSR0 pDevInsR0;
136 /** Pointer to the next PDM device associate with the PDM device. (R0 ptr) */
137 R0PTRTYPE(PPDMPCIDEV) pNextR0;
138 /** Pointer to the internal PDM PCI bus for the device. (R0 ptr) */
139 R0PTRTYPE(struct PDMPCIBUS *) pPdmBusR0;
140
141 /** Pointer to the PDM device the PCI device belongs to. (RC ptr) */
142 PPDMDEVINSRC pDevInsRC;
143 /** Pointer to the next PDM device associate with the PDM device. (RC ptr) */
144 RCPTRTYPE(PPDMPCIDEV) pNextRC;
145 /** Pointer to the internal PDM PCI bus for the device. (RC ptr) */
146 RCPTRTYPE(struct PDMPCIBUS *) pPdmBusRC;
147
148 /** The CFGM device configuration index (default, PciDev1..255).
149 * This also works as the internal sub-device ordinal with MMIOEx. */
150 uint8_t idxDevCfg;
151 /** Set if the it can be reassigned to a different PCI device number. */
152 bool fReassignableDevNo;
153 /** Set if the it can be reassigned to a different PCI function number. */
154 bool fReassignableFunNo;
155 /** Alignment padding. */
156 uint8_t bPadding0;
157 /** @} */
158
159 /** @name Owned by the PCI Bus
160 * @remarks PDM will not touch anything here (includes not relocating anything).
161 * @{
162 */
163 /** Pointer to the PCI bus of the device. (R3 ptr) */
164 R3PTRTYPE(struct DEVPCIBUS *) pBusR3;
165 /** Page used for MSI-X state. (R3 ptr) */
166 R3PTRTYPE(void *) pMsixPageR3;
167 /** Read config callback. */
168 R3PTRTYPE(PFNPCICONFIGREAD) pfnConfigRead;
169 /** Write config callback. */
170 R3PTRTYPE(PFNPCICONFIGWRITE) pfnConfigWrite;
171 /** Read config callback for PCI bridges to pass requests
172 * to devices on another bus. */
173 R3PTRTYPE(PFNPCIBRIDGECONFIGREAD) pfnBridgeConfigRead;
174 /** Write config callback for PCI bridges to pass requests
175 * to devices on another bus. */
176 R3PTRTYPE(PFNPCIBRIDGECONFIGWRITE) pfnBridgeConfigWrite;
177
178 /** Pointer to the PCI bus of the device. (R0 ptr) */
179 R0PTRTYPE(struct DEVPCIBUS *) pBusR0;
180 /** Page used for MSI-X state. (R0 ptr) */
181 R0PTRTYPE(void *) pMsixPageR0;
182
183 /** Pointer to the PCI bus of the device. (RC ptr) */
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 abPadding1[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
230
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use