VirtualBox

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

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

DevPci: Allow access to config space above 256 bytes with ICH9. bugref:9218

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.5 KB
Line 
1/* $Id: pdmpcidevint.h 81035 2019-09-26 20:22:35Z 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 Strict VBox status code.
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 * @param pu32Value Where to return the register value.
72 */
73typedef DECLCALLBACK(VBOXSTRICTRC) FNPCIBRIDGECONFIGREAD(PPDMDEVINSR3 pDevIns, uint8_t iBus, uint8_t iDevice,
74 uint32_t u32Address, unsigned cb, uint32_t *pu32Value);
75/** Pointer to a FNPCICONFIGREAD() function. */
76typedef FNPCIBRIDGECONFIGREAD *PFNPCIBRIDGECONFIGREAD;
77/** Pointer to a PFNPCICONFIGREAD. */
78typedef PFNPCIBRIDGECONFIGREAD *PPFNPCIBRIDGECONFIGREAD;
79
80/**
81 * Callback function for writing to the PCI configuration space.
82 *
83 * @returns Strict VBox status code.
84 * @param pDevIns Pointer to the device instance of the PCI bus.
85 * @param iBus The bus number this device is on.
86 * @param iDevice The number of the device on the bus.
87 * @param u32Address The configuration space register address. [0..255]
88 * @param cb The register size. [1,2,4]
89 * @param u32Value The value that's being written. The number of bits actually used from
90 * this value is determined by the cb parameter.
91 */
92typedef DECLCALLBACK(VBOXSTRICTRC) FNPCIBRIDGECONFIGWRITE(PPDMDEVINSR3 pDevIns, uint8_t iBus, uint8_t iDevice,
93 uint32_t u32Address, unsigned cb, uint32_t u32Value);
94/** Pointer to a FNPCICONFIGWRITE() function. */
95typedef FNPCIBRIDGECONFIGWRITE *PFNPCIBRIDGECONFIGWRITE;
96/** Pointer to a PFNPCICONFIGWRITE. */
97typedef PFNPCIBRIDGECONFIGWRITE *PPFNPCIBRIDGECONFIGWRITE;
98
99/* Forward declaration */
100struct DEVPCIBUS;
101
102enum {
103 /** Flag whether the device is a pci-to-pci bridge.
104 * This is set prior to device registration. */
105 PCIDEV_FLAG_PCI_TO_PCI_BRIDGE = RT_BIT_32(1),
106 /** Flag whether the device is a PCI Express device.
107 * This is set prior to device registration. */
108 PCIDEV_FLAG_PCI_EXPRESS_DEVICE = RT_BIT_32(2),
109 /** Flag whether the device is capable of MSI.
110 * This one is set by MsiInit(). */
111 PCIDEV_FLAG_MSI_CAPABLE = RT_BIT_32(3),
112 /** Flag whether the device is capable of MSI-X.
113 * This one is set by MsixInit(). */
114 PCIDEV_FLAG_MSIX_CAPABLE = RT_BIT_32(4),
115 /** Flag if device represents real physical device in passthrough mode. */
116 PCIDEV_FLAG_PASSTHROUGH = RT_BIT_32(5),
117 /** Flag whether the device is capable of MSI using 64-bit address. */
118 PCIDEV_FLAG_MSI64_CAPABLE = RT_BIT_32(6)
119
120};
121
122
123/**
124 * PDM PCI Device - Internal data.
125 *
126 * @sa PDMPCIDEV
127 */
128typedef struct PDMPCIDEVINT
129{
130 /** @name Owned by PDM.
131 * @remarks The bus may use the device instance pointers.
132 * @{
133 */
134 /** Pointer to the PDM device the PCI device belongs to. (R3 ptr) */
135 PPDMDEVINSR3 pDevInsR3;
136 /** The CFGM device configuration index (default, PciDev1..255).
137 * This also works as the internal sub-device ordinal with MMIOEx.
138 * @note Same value as idxSubDev, can therefore be removed later. */
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 /** Set if this device has been registered. */
149 bool fRegistered;
150 /** Index into PDMDEVINSR3::apPciDevs (same as PDMPCIDEV::idxSubDev). */
151 uint16_t idxSubDev;
152 /** @} */
153
154 /** @name Owned by the PCI Bus
155 * @remarks PDM will not touch anything here (includes not relocating anything).
156 * @{
157 */
158 /** Pointer to the PCI bus of the device. (R3 ptr) */
159 R3PTRTYPE(struct DEVPCIBUS *) pBusR3;
160 /** Read config callback. */
161 R3PTRTYPE(PFNPCICONFIGREAD) pfnConfigRead;
162 /** Write config callback. */
163 R3PTRTYPE(PFNPCICONFIGWRITE) pfnConfigWrite;
164 /** Read config callback for PCI bridges to pass requests
165 * to devices on another bus. */
166 R3PTRTYPE(PFNPCIBRIDGECONFIGREAD) pfnBridgeConfigRead;
167 /** Write config callback for PCI bridges to pass requests
168 * to devices on another bus. */
169 R3PTRTYPE(PFNPCIBRIDGECONFIGWRITE) pfnBridgeConfigWrite;
170
171 /** Flags of this PCI device, see PCIDEV_FLAG_XXX constants. */
172 uint32_t fFlags;
173 /** Current state of the IRQ pin of the device. */
174 int32_t uIrqPinState;
175
176 /** Offset of MSI PCI capability in config space, or 0.
177 * @todo fix non-standard naming. */
178 uint8_t u8MsiCapOffset;
179 /** Size of MSI PCI capability in config space, or 0.
180 * @todo fix non-standard naming. */
181 uint8_t u8MsiCapSize;
182 /** Offset of MSI-X PCI capability in config space, or 0.
183 * @todo fix non-standard naming. */
184 uint8_t u8MsixCapOffset;
185 /** Size of MSI-X PCI capability in config space, or 0.
186 * @todo fix non-standard naming. */
187 uint8_t u8MsixCapSize;
188 /** Size of the MSI-X region. */
189 uint16_t cbMsixRegion;
190 /** Offset to the PBA for MSI-X. */
191 uint16_t offMsixPba;
192 /** Add padding to align aIORegions to an 16 byte boundary. */
193 uint8_t abPadding2[HC_ARCH_BITS == 32 ? 0x14 : 0x10];
194
195 /** Pointer to bus specific data. (R3 ptr) */
196 R3PTRTYPE(const void *) pvPciBusPtrR3;
197 /** I/O regions. */
198 PCIIOREGION aIORegions[VBOX_PCI_NUM_REGIONS];
199 /** @} */
200} PDMPCIDEVINT;
201AssertCompileMemberAlignment(PDMPCIDEVINT, aIORegions, 8);
202AssertCompileSize(PDMPCIDEVINT, HC_ARCH_BITS == 32 ? 0x60 : 0x140);
203
204/** Indicate that PDMPCIDEV::Int.s can be declared. */
205#define PDMPCIDEVINT_DECLARED
206
207/** @} */
208
209#endif /* !VBOX_INCLUDED_vmm_pdmpcidevint_h */
210
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