VirtualBox

source: vbox/trunk/src/VBox/Devices/Bus/DevPciGenericEcam.cpp

Last change on this file was 109212, checked in by vboxsync, 11 days ago

GIC: bugref:10877 Add MSI registeration callbacks in PCI ECAM configured when the ITS is enabled. Added invoking of the GIC backend's MSI handler from PDM.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 38.4 KB
Line 
1/* $Id: DevPciGenericEcam.cpp 109212 2025-05-09 06:25:38Z vboxsync $ */
2/** @file
3 * DevPciGeneric - Generic host to PCIe bridge emulation.
4 */
5
6/*
7 * Copyright (C) 2023-2024 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.215389.xyz.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28
29/*********************************************************************************************************************************
30* Header Files *
31*********************************************************************************************************************************/
32#define LOG_GROUP LOG_GROUP_DEV_PCI
33#define PDMPCIDEV_INCLUDE_PRIVATE /* Hack to get pdmpcidevint.h included at the right point. */
34#include <VBox/vmm/pdmpcidev.h>
35
36#include <VBox/AssertGuest.h>
37#include <VBox/msi.h>
38#include <VBox/vmm/pdmdev.h>
39#include <VBox/vmm/mm.h>
40#include <iprt/asm.h>
41#include <iprt/assert.h>
42#include <iprt/string.h>
43#ifdef IN_RING3
44# include <iprt/mem.h>
45# include <iprt/uuid.h>
46#endif
47
48#include "PciInline.h"
49#include "VBoxDD.h"
50#include "MsiCommon.h"
51#include "DevPciInternal.h"
52
53
54/*********************************************************************************************************************************
55* Structures and Typedefs *
56*********************************************************************************************************************************/
57
58
59/*********************************************************************************************************************************
60* Defined Constants And Macros *
61*********************************************************************************************************************************/
62/** @todo As this shares a lot of code with the ICH9 PCI device we have to also keep the saved state version in sync. */
63/** Saved state version of the generic ECAM PCI bus device. */
64#define VBOX_PCIGENECAM_SAVED_STATE_VERSION VBOX_ICH9PCI_SAVED_STATE_VERSION_4KB_CFG_SPACE
65/** 4KB config space */
66#define VBOX_ICH9PCI_SAVED_STATE_VERSION_4KB_CFG_SPACE 4
67
68
69/*********************************************************************************************************************************
70* Internal Functions *
71*********************************************************************************************************************************/
72
73/**
74 * Returns the interrupt pin for a given device slot on the root port
75 * due to swizzeling.
76 *
77 * @returns Interrupt pin on the root port.
78 * @param uDevFn The device.
79 * @param uPin The interrupt pin on the device.
80 */
81DECLINLINE(uint8_t) pciGenEcamGetPirq(uint8_t uDevFn, uint8_t uPin)
82{
83 uint8_t uSlot = (uDevFn >> 3) - 1;
84 return (uPin + uSlot) & 3;
85}
86
87
88/**
89 * Returns whether the interrupt line is asserted on the PCI root for the given pin.
90 *
91 * @returns Flag whther the interrupt line is asserted (true) or not (false).
92 * @param pPciRoot The PCI root bus.
93 * @param u8IrqPin The IRQ pin being checked.
94 */
95DECLINLINE(bool) pciGenEcamGetIrqLvl(PDEVPCIROOT pPciRoot, uint8_t u8IrqPin)
96{
97 return (pPciRoot->u.GenericEcam.auPciIrqLevels[u8IrqPin] != 0);
98}
99
100
101/**
102 * Internal IRQ update worker for the root bus and bridges.
103 *
104 * @param pDevIns The PDM device instance updating the interrupt.
105 * @param pPciRoot The PCI root bus.
106 * @param pBusCC Current context PCI bus data.
107 * @param uDevFn Device and function number of the device/bridge updating the interrupt on the root bus.
108 * @param pPciDev The PCI device data of the device updating the interrupt.
109 * @param iIrq The interrupt number or MSI message.
110 * @param iLevel The level of the interrupt.
111 * @param uTagSrc The source tag of the interrupt.
112 */
113static void pciGenEcamSetIrqInternal(PPDMDEVINS pDevIns, PDEVPCIROOT pPciRoot, PDEVPCIBUSCC pBusCC,
114 uint8_t uDevFn, PPDMPCIDEV pPciDev, int iIrq, int iLevel, uint32_t uTagSrc)
115{
116 PDEVPCIBUS pBus = &pPciRoot->PciBus;
117 uint16_t const uBusDevFn = PCIBDF_MAKE(pBus->iBus, uDevFn);
118
119 /* If MSI or MSI-X is enabled, PCI INTx# signals are disabled regardless of the PCI command
120 * register interrupt bit state.
121 * PCI 3.0 (section 6.8) forbids MSI and MSI-X to be enabled at the same time and makes
122 * that undefined behavior. We check for MSI first, then MSI-X.
123 */
124 if (MsiIsEnabled(pPciDev))
125 {
126 Assert(!MsixIsEnabled(pPciDev)); /* Not allowed -- see note above. */
127 LogFlowFunc(("PCI Dev %p : MSI\n", pPciDev));
128 MsiNotify(pDevIns, pBusCC->CTX_SUFF(pPciHlp), pPciDev, iIrq, iLevel, uTagSrc);
129 return;
130 }
131
132 if (MsixIsEnabled(pPciDev))
133 {
134 LogFlowFunc(("PCI Dev %p : MSI-X\n", pPciDev));
135 MsixNotify(pDevIns, pBusCC->CTX_SUFF(pPciHlp), pPciDev, iIrq, iLevel, uTagSrc);
136 return;
137 }
138
139 LogFlowFunc(("PCI Dev %p : IRQ\n", pPciDev));
140
141 /* Check if the state changed. */
142 if (pPciDev->Int.s.uIrqPinState != iLevel)
143 {
144 pPciDev->Int.s.uIrqPinState = (iLevel & PDM_IRQ_LEVEL_HIGH);
145
146 /* Get the pin. */
147 uint8_t uIrqPin = devpciR3GetByte(pPciDev, VBOX_PCI_INTERRUPT_PIN);
148 uint8_t uIrq = pciGenEcamGetPirq(pPciDev->uDevFn, uIrqPin);
149
150 if ((iLevel & PDM_IRQ_LEVEL_HIGH) == PDM_IRQ_LEVEL_HIGH)
151 ASMAtomicIncU32(&pPciRoot->u.GenericEcam.auPciIrqLevels[uIrq]);
152 else if ((iLevel & PDM_IRQ_LEVEL_HIGH) == PDM_IRQ_LEVEL_LOW)
153 ASMAtomicDecU32(&pPciRoot->u.GenericEcam.auPciIrqLevels[uIrq]);
154
155 bool fIrqLvl = pciGenEcamGetIrqLvl(pPciRoot, uIrq);
156 uint32_t u32IrqNr = pPciRoot->u.GenericEcam.auPciIrqNr[uIrq];
157
158 Log3Func(("%s: uIrqPin=%u uIrqRoot=%u fIrqLvl=%RTbool uIrqNr=%u\n",
159 R3STRING(pPciDev->pszNameR3), uIrqPin, uIrq, fIrqLvl, u32IrqNr));
160 pBusCC->CTX_SUFF(pPciHlp)->pfnIoApicSetIrq(pDevIns, uBusDevFn, u32IrqNr, fIrqLvl, uTagSrc);
161
162 if ((iLevel & PDM_IRQ_LEVEL_FLIP_FLOP) == PDM_IRQ_LEVEL_FLIP_FLOP) {
163 ASMAtomicDecU32(&pPciRoot->u.GenericEcam.auPciIrqLevels[uIrq]);
164 pPciDev->Int.s.uIrqPinState = PDM_IRQ_LEVEL_LOW;
165 fIrqLvl = pciGenEcamGetIrqLvl(pPciRoot, uIrq);
166 Log3Func(("%s: uIrqPin=%u uIrqRoot=%u fIrqLvl=%RTbool uIrqNr=%u\n",
167 R3STRING(pPciDev->pszNameR3), uIrqPin, uIrq, fIrqLvl, u32IrqNr));
168 pBusCC->CTX_SUFF(pPciHlp)->pfnIoApicSetIrq(pDevIns, uBusDevFn, u32IrqNr, fIrqLvl, uTagSrc);
169 }
170 }
171}
172
173
174/**
175 * @interface_method_impl{PDMPCIBUSREGCC,pfnSetIrqR3}
176 */
177static DECLCALLBACK(void) pciGenEcamSetIrq(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iIrq, int iLevel, uint32_t uTagSrc)
178{
179 LogFlowFunc(("invoked by %p/%d: iIrq=%d iLevel=%d uTagSrc=%#x\n", pDevIns, pDevIns->iInstance, iIrq, iLevel, uTagSrc));
180 pciGenEcamSetIrqInternal(pDevIns, PDMINS_2_DATA(pDevIns, PDEVPCIROOT), PDMINS_2_DATA_CC(pDevIns, PDEVPCIBUSCC),
181 pPciDev->uDevFn, pPciDev, iIrq, iLevel, uTagSrc);
182}
183
184
185static DECLCALLBACK(void) pciGenEcamBridgeSetIrq(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iIrq, int iLevel, uint32_t uTagSrc)
186{
187 /*
188 * The PCI-to-PCI bridge specification defines how the interrupt pins
189 * are routed from the secondary to the primary bus (see chapter 9).
190 * iIrq gives the interrupt pin the pci device asserted.
191 * We change iIrq here according to the spec and call the SetIrq function
192 * of our parent passing the device which asserted the interrupt instead of the device of the bridge.
193 *
194 * See ich9pciBiosInitAllDevicesOnBus for corresponding configuration code.
195 */
196 PDEVPCIBUS pBus;
197 uint8_t uDevFnBridge;
198 int iIrqPinBridge;
199 PPDMDEVINS pDevInsBus = devpcibridgeCommonSetIrqRootWalk(pDevIns, pPciDev, iIrq, &pBus, &uDevFnBridge, &iIrqPinBridge);
200 AssertReturnVoid(pDevInsBus);
201 AssertMsg(pBus->iBus == 0, ("This is not the host pci bus iBus=%d\n", pBus->iBus));
202 Assert(pDevInsBus->pReg == &g_DevicePciGenericEcam); /* ASSUMPTION: Same style root bus. Need callback interface to mix types. */
203
204 /*
205 * For MSI/MSI-X enabled devices the iIrq doesn't denote the pin but rather a vector which is completely
206 * orthogonal to the pin based approach. The vector is not subject to the pin based routing with PCI bridges.
207 */
208 int iIrqPinVector = iIrqPinBridge;
209 if ( MsiIsEnabled(pPciDev)
210 || MsixIsEnabled(pPciDev))
211 iIrqPinVector = iIrq;
212 pciGenEcamSetIrqInternal(pDevIns, DEVPCIBUS_2_DEVPCIROOT(pBus), PDMINS_2_DATA_CC(pDevInsBus, PDEVPCIBUSCC),
213 uDevFnBridge, pPciDev, iIrqPinVector, iLevel, uTagSrc);
214}
215
216
217/**
218 * @callback_method_impl{FNIOMMMIONEWWRITE,
219 * Emulates writes to PIO space.}
220 */
221static DECLCALLBACK(VBOXSTRICTRC) pciHostR3MmioPioWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void const *pv, unsigned cb)
222{
223 Log2Func(("%RGp LB %d\n", off, cb));
224 RT_NOREF(pvUser);
225
226 AssertReturn(off < _64K, VERR_INVALID_PARAMETER);
227 AssertReturn(cb <= 4, VERR_INVALID_PARAMETER);
228
229 /* Get the value. */
230 uint32_t u32;
231 switch (cb)
232 {
233 case 1:
234 u32 = *(uint8_t const *)pv;
235 break;
236 case 2:
237 u32 = *(uint16_t const *)pv;
238 break;
239 case 4:
240 u32 = *(uint32_t const *)pv;
241 break;
242 default:
243 ASSERT_GUEST_MSG_FAILED(("cb=%u off=%RGp\n", cb, off)); /** @todo how the heck should this work? Split it, right? */
244 u32 = 0;
245 break;
246 }
247
248 return PDMDevHlpIoPortWrite(pDevIns, (RTIOPORT)off, u32, cb);
249}
250
251
252/**
253 * @callback_method_impl{FNIOMMMIONEWWRITE,
254 * Emulates reads from PIO space.}
255 */
256static DECLCALLBACK(VBOXSTRICTRC) pciHostR3MmioPioRead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void *pv, unsigned cb)
257{
258 LogFlowFunc(("%RGp LB %u\n", off, cb));
259 RT_NOREF(pvUser);
260
261 AssertReturn(off < _64K, VERR_INVALID_PARAMETER);
262 AssertReturn(cb <= 4, VERR_INVALID_PARAMETER);
263
264 /* Perform PIO space read */
265 uint32_t u32Value = 0;
266 VBOXSTRICTRC rcStrict = PDMDevHlpIoPortRead(pDevIns, (RTIOPORT)off, &u32Value, cb);
267
268 if (RT_SUCCESS(rcStrict))
269 {
270 switch (cb)
271 {
272 case 1:
273 *(uint8_t *)pv = (uint8_t)u32Value;
274 break;
275 case 2:
276 *(uint16_t *)pv = (uint16_t)u32Value;
277 break;
278 case 4:
279 *(uint32_t *)pv = u32Value;
280 break;
281 default:
282 ASSERT_GUEST_MSG_FAILED(("cb=%u off=%RGp\n", cb, off)); /** @todo how the heck should this work? Split it, right? */
283 break;
284 }
285 }
286
287 return rcStrict;
288}
289
290
291#ifdef IN_RING3
292
293/* -=-=-=-=-=- PCI Config Space -=-=-=-=-=- */
294
295
296/**
297 * @interface_method_impl{PDMDEVREG,pfnConstruct}
298 */
299static DECLCALLBACK(int) pciGenEcamR3Construct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg)
300{
301 RT_NOREF1(iInstance);
302 Assert(iInstance == 0);
303 PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);
304
305 PDEVPCIBUSCC pBusCC = PDMINS_2_DATA_CC(pDevIns, PDEVPCIBUSCC);
306 PDEVPCIROOT pPciRoot = PDMINS_2_DATA(pDevIns, PDEVPCIROOT);
307 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3;
308 PDEVPCIBUS pBus = &pPciRoot->PciBus;
309
310 /*
311 * Validate and read configuration.
312 */
313 PDMDEV_VALIDATE_CONFIG_RETURN(pDevIns, "MmioEcamBase"
314 "|MmioEcamLength"
315 "|MmioPioBase"
316 "|MmioPioSize"
317 "|IntPinA"
318 "|IntPinB"
319 "|IntPinC"
320 "|IntPinD"
321 "|Msi", "");
322
323 int rc = pHlp->pfnCFGMQueryU64Def(pCfg, "MmioEcamBase", &pPciRoot->u64PciConfigMMioAddress, 0);
324 AssertRCReturn(rc, PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Failed to read \"McfgBase\"")));
325
326 rc = pHlp->pfnCFGMQueryU64Def(pCfg, "MmioEcamLength", &pPciRoot->u64PciConfigMMioLength, 0);
327 AssertRCReturn(rc, PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Failed to read \"McfgLength\"")));
328
329 rc = pHlp->pfnCFGMQueryU64Def(pCfg, "MmioPioBase", &pPciRoot->GCPhysMmioPioEmuBase, 0);
330 AssertRCReturn(rc, PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Failed to read \"MmioPioBase\"")));
331
332 rc = pHlp->pfnCFGMQueryU64Def(pCfg, "MmioPioSize", &pPciRoot->GCPhysMmioPioEmuSize, 0);
333 AssertRCReturn(rc, PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Failed to read \"MmioPioSize\"")));
334
335 rc = pHlp->pfnCFGMQueryU32(pCfg, "IntPinA", &pPciRoot->u.GenericEcam.auPciIrqNr[0]);
336 AssertRCReturn(rc, PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Failed to read \"IntPinA\"")));
337
338 rc = pHlp->pfnCFGMQueryU32(pCfg, "IntPinB", &pPciRoot->u.GenericEcam.auPciIrqNr[1]);
339 AssertRCReturn(rc, PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Failed to read \"IntPinB\"")));
340
341 rc = pHlp->pfnCFGMQueryU32(pCfg, "IntPinC", &pPciRoot->u.GenericEcam.auPciIrqNr[2]);
342 AssertRCReturn(rc, PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Failed to read \"IntPinC\"")));
343
344 rc = pHlp->pfnCFGMQueryU32(pCfg, "IntPinD", &pPciRoot->u.GenericEcam.auPciIrqNr[3]);
345 AssertRCReturn(rc, PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Failed to read \"IntPinD\"")));
346
347 bool fMsi;
348 rc = pHlp->pfnCFGMQueryBoolDef(pCfg, "Msi", &fMsi, false);
349 AssertRCReturn(rc, PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Failed to read \"Msi\"")));
350
351 Log(("PCI: fUseIoApic=%RTbool McfgBase=%#RX64 McfgLength=%#RX64 fR0Enabled=%RTbool fRCEnabled=%RTbool\n", pPciRoot->fUseIoApic,
352 pPciRoot->u64PciConfigMMioAddress, pPciRoot->u64PciConfigMMioLength, pDevIns->fR0Enabled, pDevIns->fRCEnabled));
353 Log(("PCI: IntPinA=%u IntPinB=%u IntPinC=%u IntPinD=%u fMsi=%RTbool\n", pPciRoot->u.GenericEcam.auPciIrqNr[0],
354 pPciRoot->u.GenericEcam.auPciIrqNr[1], pPciRoot->u.GenericEcam.auPciIrqNr[2], pPciRoot->u.GenericEcam.auPciIrqNr[3], fMsi));
355
356 /*
357 * Init data.
358 */
359 /* And fill values */
360 pBusCC->pDevInsR3 = pDevIns;
361 pPciRoot->hIoPortAddress = NIL_IOMIOPORTHANDLE;
362 pPciRoot->hIoPortData = NIL_IOMIOPORTHANDLE;
363 pPciRoot->hIoPortMagic = NIL_IOMIOPORTHANDLE;
364 pPciRoot->hMmioMcfg = NIL_IOMMMIOHANDLE;
365 pPciRoot->hMmioPioEmu = NIL_IOMMMIOHANDLE;
366 pPciRoot->PciBus.enmType = DEVPCIBUSTYPE_GENERIC_ECAM;
367 pPciRoot->PciBus.fPureBridge = false;
368 pPciRoot->PciBus.papBridgesR3 = (PPDMPCIDEV *)PDMDevHlpMMHeapAllocZ(pDevIns, sizeof(PPDMPCIDEV) * RT_ELEMENTS(pPciRoot->PciBus.apDevices));
369 AssertLogRelReturn(pPciRoot->PciBus.papBridgesR3, VERR_NO_MEMORY);
370
371 /*
372 * Disable default device locking.
373 */
374 rc = PDMDevHlpSetDeviceCritSect(pDevIns, PDMDevHlpCritSectGetNop(pDevIns));
375 AssertRCReturn(rc, rc);
376
377 /*
378 * Register bus
379 */
380 PDMPCIBUSREGCC PciBusReg;
381 PciBusReg.u32Version = PDM_PCIBUSREGCC_VERSION;
382 PciBusReg.pfnRegisterR3 = devpciR3CommonRegisterDevice;
383 PciBusReg.pfnRegisterMsiR3 = fMsi ? devpciR3CommonRegisterMsi : NULL;
384 PciBusReg.pfnIORegionRegisterR3 = devpciR3CommonIORegionRegister;
385 PciBusReg.pfnInterceptConfigAccesses = devpciR3CommonInterceptConfigAccesses;
386 PciBusReg.pfnConfigRead = devpciR3CommonConfigRead;
387 PciBusReg.pfnConfigWrite = devpciR3CommonConfigWrite;
388 PciBusReg.pfnSetIrqR3 = pciGenEcamSetIrq;
389 PciBusReg.u32EndVersion = PDM_PCIBUSREGCC_VERSION;
390 rc = PDMDevHlpPCIBusRegister(pDevIns, &PciBusReg, &pBusCC->pPciHlpR3, &pBus->iBus);
391 if (RT_FAILURE(rc))
392 return PDMDEV_SET_ERROR(pDevIns, rc, N_("Failed to register ourselves as a PCI Bus"));
393 Assert(pBus->iBus == 0);
394 if (pBusCC->pPciHlpR3->u32Version != PDM_PCIHLPR3_VERSION)
395 return PDMDevHlpVMSetError(pDevIns, VERR_VERSION_MISMATCH, RT_SRC_POS,
396 N_("PCI helper version mismatch; got %#x expected %#x"),
397 pBusCC->pPciHlpR3->u32Version, PDM_PCIHLPR3_VERSION);
398
399 /*
400 * Fill in PCI configs and add them to the bus.
401 */
402#if 0
403 /* Host bridge device */
404 PPDMPCIDEV pPciDev = pDevIns->apPciDevs[0];
405 AssertPtr(pPciDev);
406 PDMPciDevSetVendorId( pPciDev, 0x8086); /** @todo Intel */
407 PDMPciDevSetDeviceId( pPciDev, 0x29e0); /** @todo Desktop */
408 PDMPciDevSetRevisionId(pPciDev, 0x01); /* rev. 01 */
409 PDMPciDevSetClassBase( pPciDev, 0x06); /* bridge */
410 PDMPciDevSetClassSub( pPciDev, 0x00); /* Host/PCI bridge */
411 PDMPciDevSetClassProg( pPciDev, 0x00); /* Host/PCI bridge */
412 PDMPciDevSetHeaderType(pPciDev, 0x00); /* bridge */
413 PDMPciDevSetWord(pPciDev, VBOX_PCI_SEC_STATUS, 0x0280); /* secondary status */
414
415 rc = PDMDevHlpPCIRegisterEx(pDevIns, pPciDev, 0 /*fFlags*/, 0 /*uPciDevNo*/, 0 /*uPciFunNo*/, "Host");
416 AssertLogRelRCReturn(rc, rc);
417#endif
418
419 /*
420 * MMIO handlers.
421 */
422 if (pPciRoot->u64PciConfigMMioAddress != 0)
423 {
424 rc = PDMDevHlpMmioCreateAndMap(pDevIns, pPciRoot->u64PciConfigMMioAddress, pPciRoot->u64PciConfigMMioLength,
425 devpciCommonMcfgMmioWrite, devpciCommonMcfgMmioRead,
426 IOMMMIO_FLAGS_READ_PASSTHRU | IOMMMIO_FLAGS_WRITE_PASSTHRU,
427 "ECAM window", &pPciRoot->hMmioMcfg);
428 AssertMsgRCReturn(rc, ("rc=%Rrc %#RX64/%#RX64\n", rc, pPciRoot->u64PciConfigMMioAddress, pPciRoot->u64PciConfigMMioLength), rc);
429 }
430
431 if (pPciRoot->GCPhysMmioPioEmuBase != 0)
432 {
433 rc = PDMDevHlpMmioCreateAndMap(pDevIns, pPciRoot->GCPhysMmioPioEmuBase, pPciRoot->GCPhysMmioPioEmuSize,
434 pciHostR3MmioPioWrite, pciHostR3MmioPioRead,
435 IOMMMIO_FLAGS_READ_PASSTHRU | IOMMMIO_FLAGS_WRITE_PASSTHRU,
436 "PIO range", &pPciRoot->hMmioPioEmu);
437 AssertMsgRCReturn(rc, ("rc=%Rrc %#RGp/%#RGp\n", rc, pPciRoot->GCPhysMmioPioEmuBase, pPciRoot->GCPhysMmioPioEmuSize), rc);
438 }
439
440 /*
441 * Saved state and info handlers.
442 */
443 rc = PDMDevHlpSSMRegisterEx(pDevIns, VBOX_PCIGENECAM_SAVED_STATE_VERSION,
444 sizeof(*pBus) + 16*128, "pgm",
445 NULL, NULL, NULL,
446 NULL, devpciR3CommonSaveExec, NULL,
447 NULL, devpciR3CommonLoadExec, NULL);
448 AssertRCReturn(rc, rc);
449
450 PDMDevHlpDBGFInfoRegister(pDevIns, "pci",
451 "Display PCI bus status. Recognizes 'basic' or 'verbose' as arguments, defaults to 'basic'.",
452 devpciR3InfoPci);
453 PDMDevHlpDBGFInfoRegister(pDevIns, "pciirq", "Display PCI IRQ state. (no arguments)", devpciR3InfoPciIrq);
454
455 return VINF_SUCCESS;
456}
457
458
459/**
460 * @interface_method_impl{PDMDEVREG,pfnDestruct}
461 */
462static DECLCALLBACK(int) pciGenEcamR3Destruct(PPDMDEVINS pDevIns)
463{
464 PDEVPCIROOT pPciRoot = PDMINS_2_DATA(pDevIns, PDEVPCIROOT);
465 if (pPciRoot->PciBus.papBridgesR3)
466 {
467 PDMDevHlpMMHeapFree(pDevIns, pPciRoot->PciBus.papBridgesR3);
468 pPciRoot->PciBus.papBridgesR3 = NULL;
469 }
470 return VINF_SUCCESS;
471}
472
473
474/**
475 * @interface_method_impl{PDMDEVREG,pfnReset}
476 */
477static DECLCALLBACK(void) pciGenEcamR3Reset(PPDMDEVINS pDevIns)
478{
479 /* Reset everything under the root bridge. */
480 devpciR3CommonResetBridge(pDevIns);
481}
482
483
484/**
485 * @interface_method_impl{PDMIBASE,pfnQueryInterface}
486 */
487static DECLCALLBACK(void *) pciGenEcamBridgeQueryInterface(PPDMIBASE pInterface, const char *pszIID)
488{
489 PPDMDEVINS pDevIns = RT_FROM_MEMBER(pInterface, PDMDEVINS, IBase);
490 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pDevIns->IBase);
491
492 /* HACK ALERT! Special access to the PDMPCIDEV structure of an ich9pcibridge
493 instance (see PDMIICH9BRIDGEPDMPCIDEV_IID for details). */
494 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIICH9BRIDGEPDMPCIDEV, pDevIns->apPciDevs[0]);
495 return NULL;
496}
497
498
499/**
500 * @interface_method_impl{PDMDEVREG,pfnDestruct}
501 */
502static DECLCALLBACK(int) pciGenEcamBridgeR3Destruct(PPDMDEVINS pDevIns)
503{
504 PDEVPCIBUS pBus = PDMINS_2_DATA(pDevIns, PDEVPCIBUS);
505 if (pBus->papBridgesR3)
506 {
507 PDMDevHlpMMHeapFree(pDevIns, pBus->papBridgesR3);
508 pBus->papBridgesR3 = NULL;
509 }
510 return VINF_SUCCESS;
511}
512
513
514/**
515 * @interface_method_impl{PDMDEVREG,pfnConstruct}
516 */
517static DECLCALLBACK(int) pciGenEcamBridgeR3Construct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg)
518{
519 PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);
520 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3;
521
522 /*
523 * Validate and read configuration.
524 */
525 PDMDEV_VALIDATE_CONFIG_RETURN(pDevIns, "ExpressEnabled|ExpressPortType|Msi", "");
526
527 /* check if we're supposed to implement a PCIe bridge. */
528 bool fExpress;
529 int rc = pHlp->pfnCFGMQueryBoolDef(pCfg, "ExpressEnabled", &fExpress, false);
530 AssertRCReturn(rc, PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Failed to query boolean value \"ExpressEnabled\"")));
531
532 char szExpressPortType[80];
533 rc = pHlp->pfnCFGMQueryStringDef(pCfg, "ExpressPortType", szExpressPortType, sizeof(szExpressPortType), "RootCmplxIntEp");
534 AssertRCReturn(rc, PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: failed to read \"ExpressPortType\" as string")));
535
536 uint8_t const uExpressPortType = devpciR3BridgeCommonGetExpressPortTypeFromString(szExpressPortType);
537 Log(("PCI/bridge#%u: fR0Enabled=%RTbool fRCEnabled=%RTbool fExpress=%RTbool uExpressPortType=%u (%s)\n",
538 iInstance, pDevIns->fR0Enabled, pDevIns->fRCEnabled, fExpress, uExpressPortType, szExpressPortType));
539
540 bool fMsi;
541 rc = pHlp->pfnCFGMQueryBoolDef(pCfg, "Msi", &fMsi, false);
542 AssertRCReturn(rc, PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Failed to query boolean value \"Msi\"")));
543
544 /*
545 * Init data and register the PCI bus.
546 */
547 pDevIns->IBase.pfnQueryInterface = pciGenEcamBridgeQueryInterface;
548
549 PDEVPCIBUSCC pBusCC = PDMINS_2_DATA_CC(pDevIns, PDEVPCIBUSCC);
550 PDEVPCIBUS pBus = PDMINS_2_DATA(pDevIns, PDEVPCIBUS);
551
552 pBus->enmType = DEVPCIBUSTYPE_ICH9;
553 pBus->fPureBridge = true;
554 pBusCC->pDevInsR3 = pDevIns;
555 pBus->papBridgesR3 = (PPDMPCIDEV *)PDMDevHlpMMHeapAllocZ(pDevIns, sizeof(PPDMPCIDEV) * RT_ELEMENTS(pBus->apDevices));
556 AssertLogRelReturn(pBus->papBridgesR3, VERR_NO_MEMORY);
557
558 PDMPCIBUSREGCC PciBusReg;
559 PciBusReg.u32Version = PDM_PCIBUSREGCC_VERSION;
560 PciBusReg.pfnRegisterR3 = devpcibridgeR3CommonRegisterDevice;
561 PciBusReg.pfnRegisterMsiR3 = fMsi ? devpciR3CommonRegisterMsi : NULL;
562 PciBusReg.pfnIORegionRegisterR3 = devpciR3CommonIORegionRegister;
563 PciBusReg.pfnInterceptConfigAccesses = devpciR3CommonInterceptConfigAccesses;
564 PciBusReg.pfnConfigWrite = devpciR3CommonConfigWrite;
565 PciBusReg.pfnConfigRead = devpciR3CommonConfigRead;
566 PciBusReg.pfnSetIrqR3 = pciGenEcamBridgeSetIrq;
567 PciBusReg.u32EndVersion = PDM_PCIBUSREGCC_VERSION;
568 rc = PDMDevHlpPCIBusRegister(pDevIns, &PciBusReg, &pBusCC->pPciHlpR3, &pBus->iBus);
569 if (RT_FAILURE(rc))
570 return PDMDEV_SET_ERROR(pDevIns, rc, N_("Failed to register ourselves as a PCI Bus"));
571 Assert(pBus->iBus == (uint32_t)iInstance + 1); /* Can be removed when adding support for multiple bridge implementations. */
572 if (pBusCC->pPciHlpR3->u32Version != PDM_PCIHLPR3_VERSION)
573 return PDMDevHlpVMSetError(pDevIns, VERR_VERSION_MISMATCH, RT_SRC_POS,
574 N_("PCI helper version mismatch; got %#x expected %#x"),
575 pBusCC->pPciHlpR3->u32Version, PDM_PCIHLPR3_VERSION);
576
577 LogRel(("PCI: Registered bridge instance #%u as PDM bus no %u.\n", iInstance, pBus->iBus));
578
579
580 /* Disable default device locking. */
581 rc = PDMDevHlpSetDeviceCritSect(pDevIns, PDMDevHlpCritSectGetNop(pDevIns));
582 AssertRCReturn(rc, rc);
583
584 /** @todo r=aeichner This is the same as the ICH9 bridge. */
585 /*
586 * Fill in PCI configs and add them to the bus.
587 */
588 PPDMPCIDEV pPciDev = pDevIns->apPciDevs[0];
589 PDMPCIDEV_ASSERT_VALID(pDevIns, pPciDev);
590
591 PDMPciDevSetVendorId( pPciDev, 0x8086); /* Intel */
592 if (fExpress)
593 {
594 PDMPciDevSetDeviceId(pPciDev, 0x29e1); /* 82X38/X48 Express Host-Primary PCI Express Bridge. */
595 PDMPciDevSetRevisionId(pPciDev, 0x01);
596 }
597 else
598 {
599 PDMPciDevSetDeviceId(pPciDev, 0x2448); /* 82801 Mobile PCI bridge. */
600 PDMPciDevSetRevisionId(pPciDev, 0xf2);
601 }
602 PDMPciDevSetClassSub( pPciDev, 0x04); /* pci2pci */
603 PDMPciDevSetClassBase( pPciDev, 0x06); /* PCI_bridge */
604 if (fExpress)
605 PDMPciDevSetClassProg(pPciDev, 0x00); /* Normal decoding. */
606 else
607 PDMPciDevSetClassProg(pPciDev, 0x01); /* Supports subtractive decoding. */
608 PDMPciDevSetHeaderType(pPciDev, 0x01); /* Single function device which adheres to the PCI-to-PCI bridge spec. */
609 if (fExpress)
610 {
611 PDMPciDevSetCommand(pPciDev, VBOX_PCI_COMMAND_SERR);
612 PDMPciDevSetStatus(pPciDev, VBOX_PCI_STATUS_CAP_LIST); /* Has capabilities. */
613 PDMPciDevSetByte(pPciDev, VBOX_PCI_CACHE_LINE_SIZE, 8); /* 32 bytes */
614 /* PCI Express */
615 PDMPciDevSetByte(pPciDev, 0xa0 + 0, VBOX_PCI_CAP_ID_EXP); /* PCI_Express */
616 PDMPciDevSetByte(pPciDev, 0xa0 + 1, 0); /* next */
617 PDMPciDevSetWord(pPciDev, 0xa0 + 2,
618 /* version */ 0x2
619 | (uExpressPortType << 4));
620 PDMPciDevSetDWord(pPciDev, 0xa0 + 4, VBOX_PCI_EXP_DEVCAP_RBE); /* Device capabilities. */
621 PDMPciDevSetWord(pPciDev, 0xa0 + 8, 0x0000); /* Device control. */
622 PDMPciDevSetWord(pPciDev, 0xa0 + 10, 0x0000); /* Device status. */
623 PDMPciDevSetDWord(pPciDev, 0xa0 + 12,
624 /* Max Link Speed */ 2
625 | /* Maximum Link Width */ (16 << 4)
626 | /* Active State Power Management (ASPM) Sopport */ (0 << 10)
627 | VBOX_PCI_EXP_LNKCAP_LBNC
628 | /* Port Number */ ((2 + iInstance) << 24)); /* Link capabilities. */
629 PDMPciDevSetWord(pPciDev, 0xa0 + 16, VBOX_PCI_EXP_LNKCTL_CLOCK); /* Link control. */
630 PDMPciDevSetWord(pPciDev, 0xa0 + 18,
631 /* Current Link Speed */ 2
632 | /* Negotiated Link Width */ (16 << 4)
633 | VBOX_PCI_EXP_LNKSTA_SL_CLK); /* Link status. */
634 PDMPciDevSetDWord(pPciDev, 0xa0 + 20,
635 /* Slot Power Limit Value */ (75 << 7)
636 | /* Physical Slot Number */ (0 << 19)); /* Slot capabilities. */
637 PDMPciDevSetWord(pPciDev, 0xa0 + 24, 0x0000); /* Slot control. */
638 PDMPciDevSetWord(pPciDev, 0xa0 + 26, 0x0000); /* Slot status. */
639 PDMPciDevSetWord(pPciDev, 0xa0 + 28, 0x0000); /* Root control. */
640 PDMPciDevSetWord(pPciDev, 0xa0 + 30, 0x0000); /* Root capabilities. */
641 PDMPciDevSetDWord(pPciDev, 0xa0 + 32, 0x00000000); /* Root status. */
642 PDMPciDevSetDWord(pPciDev, 0xa0 + 36, 0x00000000); /* Device capabilities 2. */
643 PDMPciDevSetWord(pPciDev, 0xa0 + 40, 0x0000); /* Device control 2. */
644 PDMPciDevSetWord(pPciDev, 0xa0 + 42, 0x0000); /* Device status 2. */
645 PDMPciDevSetDWord(pPciDev, 0xa0 + 44,
646 /* Supported Link Speeds Vector */ (2 << 1)); /* Link capabilities 2. */
647 PDMPciDevSetWord(pPciDev, 0xa0 + 48,
648 /* Target Link Speed */ 2); /* Link control 2. */
649 PDMPciDevSetWord(pPciDev, 0xa0 + 50, 0x0000); /* Link status 2. */
650 PDMPciDevSetDWord(pPciDev, 0xa0 + 52, 0x00000000); /* Slot capabilities 2. */
651 PDMPciDevSetWord(pPciDev, 0xa0 + 56, 0x0000); /* Slot control 2. */
652 PDMPciDevSetWord(pPciDev, 0xa0 + 58, 0x0000); /* Slot status 2. */
653 PDMPciDevSetCapabilityList(pPciDev, 0xa0);
654 }
655 else
656 {
657 PDMPciDevSetCommand(pPciDev, 0x00);
658 PDMPciDevSetStatus(pPciDev, 0x20); /* 66MHz Capable. */
659 }
660 PDMPciDevSetInterruptLine(pPciDev, 0x00); /* This device does not assert interrupts. */
661
662 /*
663 * This device does not generate interrupts. Interrupt delivery from
664 * devices attached to the bus is unaffected.
665 */
666 PDMPciDevSetInterruptPin (pPciDev, 0x00);
667
668 if (fExpress)
669 {
670 /** @todo r=klaus set up the PCIe config space beyond the old 256 byte
671 * limit, containing additional capability descriptors. */
672 }
673
674 /*
675 * Register this PCI bridge. The called function will take care on which bus we will get registered.
676 */
677 rc = PDMDevHlpPCIRegisterEx(pDevIns, pPciDev, PDMPCIDEVREG_F_PCI_BRIDGE, PDMPCIDEVREG_DEV_NO_FIRST_UNUSED,
678 PDMPCIDEVREG_FUN_NO_FIRST_UNUSED, "pci-generic-ecam-bridge");
679 AssertLogRelRCReturn(rc, rc);
680
681 pPciDev->Int.s.pfnBridgeConfigRead = devpciR3BridgeCommonConfigRead;
682 pPciDev->Int.s.pfnBridgeConfigWrite = devpciR3BridgeCommonConfigWrite;
683
684 /*
685 * Register SSM handlers. We use the same saved state version as for the host bridge
686 * to make changes easier.
687 */
688 rc = PDMDevHlpSSMRegisterEx(pDevIns, VBOX_PCIGENECAM_SAVED_STATE_VERSION,
689 sizeof(*pBus) + 16*128,
690 "pgm" /* before */,
691 NULL, NULL, NULL,
692 NULL, devpciR3BridgeCommonSaveExec, NULL,
693 NULL, devpciR3BridgeCommonLoadExec, NULL);
694 AssertLogRelRCReturn(rc, rc);
695
696 return VINF_SUCCESS;
697}
698
699#else /* !IN_RING3 */
700
701/**
702 * @interface_method_impl{PDMDEVREGR0,pfnConstruct}
703 */
704DECLCALLBACK(int) pciGenEcamRZConstruct(PPDMDEVINS pDevIns)
705{
706 PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);
707 PDEVPCIROOT pPciRoot = PDMINS_2_DATA(pDevIns, PDEVPCIROOT);
708 PDEVPCIBUSCC pBusCC = PDMINS_2_DATA_CC(pDevIns, PDEVPCIBUSCC);
709
710 /* Mirror the ring-3 device lock disabling: */
711 int rc = PDMDevHlpSetDeviceCritSect(pDevIns, PDMDevHlpCritSectGetNop(pDevIns));
712 AssertRCReturn(rc, rc);
713
714 /* Set up the RZ PCI bus callbacks: */
715 PDMPCIBUSREGCC PciBusReg;
716 PciBusReg.u32Version = PDM_PCIBUSREGCC_VERSION;
717 PciBusReg.iBus = pPciRoot->PciBus.iBus;
718 PciBusReg.pfnSetIrq = pciGenEcamSetIrq;
719 PciBusReg.u32EndVersion = PDM_PCIBUSREGCC_VERSION;
720 rc = PDMDevHlpPCIBusSetUpContext(pDevIns, &PciBusReg, &pBusCC->CTX_SUFF(pPciHlp));
721 AssertRCReturn(rc, rc);
722
723 /* Set up MMIO callbacks: */
724 if (pPciRoot->hMmioMcfg != NIL_IOMMMIOHANDLE)
725 {
726 rc = PDMDevHlpMmioSetUpContext(pDevIns, pPciRoot->hMmioMcfg, devpciCommonMcfgMmioWrite, devpciCommonMcfgMmioRead, NULL /*pvUser*/);
727 AssertLogRelRCReturn(rc, rc);
728 }
729
730 return rc;
731}
732
733
734/**
735 * @interface_method_impl{PDMDEVREGR0,pfnConstruct}
736 */
737static DECLCALLBACK(int) pciGenEcamBridgeRZConstruct(PPDMDEVINS pDevIns)
738{
739 PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);
740 PDEVPCIBUS pBus = PDMINS_2_DATA(pDevIns, PDEVPCIBUS);
741 PDEVPCIBUSCC pBusCC = PDMINS_2_DATA_CC(pDevIns, PDEVPCIBUSCC);
742
743 /* Mirror the ring-3 device lock disabling: */
744 int rc = PDMDevHlpSetDeviceCritSect(pDevIns, PDMDevHlpCritSectGetNop(pDevIns));
745 AssertRCReturn(rc, rc);
746
747 /* Set up the RZ PCI bus callbacks: */
748 PDMPCIBUSREGCC PciBusReg;
749 PciBusReg.u32Version = PDM_PCIBUSREGCC_VERSION;
750 PciBusReg.iBus = pBus->iBus;
751 PciBusReg.pfnSetIrq = pciGenEcamBridgeSetIrq;
752 PciBusReg.u32EndVersion = PDM_PCIBUSREGCC_VERSION;
753 rc = PDMDevHlpPCIBusSetUpContext(pDevIns, &PciBusReg, &pBusCC->CTX_SUFF(pPciHlp));
754 AssertRCReturn(rc, rc);
755
756 return rc;
757}
758
759#endif /* !IN_RING3 */
760
761/**
762 * The PCI bus device registration structure.
763 */
764const PDMDEVREG g_DevicePciGenericEcam =
765{
766 /* .u32Version = */ PDM_DEVREG_VERSION,
767 /* .uReserved0 = */ 0,
768 /* .szName = */ "pci-generic-ecam",
769 /* .fFlags = */ PDM_DEVREG_FLAGS_DEFAULT_BITS | PDM_DEVREG_FLAGS_RZ | PDM_DEVREG_FLAGS_NEW_STYLE,
770 /* .fClass = */ PDM_DEVREG_CLASS_BUS_PCI,
771 /* .cMaxInstances = */ 1,
772 /* .uSharedVersion = */ 42,
773 /* .cbInstanceShared = */ sizeof(DEVPCIROOT),
774 /* .cbInstanceCC = */ sizeof(CTX_SUFF(DEVPCIBUS)),
775 /* .cbInstanceRC = */ sizeof(DEVPCIBUSRC),
776 /* .cMaxPciDevices = */ 1,
777 /* .cMaxMsixVectors = */ 0,
778 /* .pszDescription = */ "Generic PCI host bridge (working with pci-host-ecam-generic driver)",
779#if defined(IN_RING3)
780 /* .pszRCMod = */ "VBoxDDRC.rc",
781 /* .pszR0Mod = */ "VBoxDDR0.r0",
782 /* .pfnConstruct = */ pciGenEcamR3Construct,
783 /* .pfnDestruct = */ pciGenEcamR3Destruct,
784 /* .pfnRelocate = */ NULL,
785 /* .pfnMemSetup = */ NULL,
786 /* .pfnPowerOn = */ NULL,
787 /* .pfnReset = */ pciGenEcamR3Reset,
788 /* .pfnSuspend = */ NULL,
789 /* .pfnResume = */ NULL,
790 /* .pfnAttach = */ NULL,
791 /* .pfnDetach = */ NULL,
792 /* .pfnQueryInterface = */ NULL,
793 /* .pfnInitComplete = */ NULL,
794 /* .pfnPowerOff = */ NULL,
795 /* .pfnSoftReset = */ NULL,
796 /* .pfnReserved0 = */ NULL,
797 /* .pfnReserved1 = */ NULL,
798 /* .pfnReserved2 = */ NULL,
799 /* .pfnReserved3 = */ NULL,
800 /* .pfnReserved4 = */ NULL,
801 /* .pfnReserved5 = */ NULL,
802 /* .pfnReserved6 = */ NULL,
803 /* .pfnReserved7 = */ NULL,
804#elif defined(IN_RING0)
805 /* .pfnEarlyConstruct = */ NULL,
806 /* .pfnConstruct = */ pciGenEcamRZConstruct,
807 /* .pfnDestruct = */ NULL,
808 /* .pfnFinalDestruct = */ NULL,
809 /* .pfnRequest = */ NULL,
810 /* .pfnReserved0 = */ NULL,
811 /* .pfnReserved1 = */ NULL,
812 /* .pfnReserved2 = */ NULL,
813 /* .pfnReserved3 = */ NULL,
814 /* .pfnReserved4 = */ NULL,
815 /* .pfnReserved5 = */ NULL,
816 /* .pfnReserved6 = */ NULL,
817 /* .pfnReserved7 = */ NULL,
818#elif defined(IN_RC)
819 /* .pfnConstruct = */ pciGenEcamRZConstruct,
820 /* .pfnReserved0 = */ NULL,
821 /* .pfnReserved1 = */ NULL,
822 /* .pfnReserved2 = */ NULL,
823 /* .pfnReserved3 = */ NULL,
824 /* .pfnReserved4 = */ NULL,
825 /* .pfnReserved5 = */ NULL,
826 /* .pfnReserved6 = */ NULL,
827 /* .pfnReserved7 = */ NULL,
828#else
829# error "Not in IN_RING3, IN_RING0 or IN_RC!"
830#endif
831 /* .u32VersionEnd = */ PDM_DEVREG_VERSION
832};
833
834/**
835 * The device registration structure
836 * for the PCI-to-PCI bridge.
837 */
838const PDMDEVREG g_DevicePciGenericEcamBridge =
839{
840 /* .u32Version = */ PDM_DEVREG_VERSION,
841 /* .uReserved0 = */ 0,
842 /* .szName = */ "pci-generic-ecam-bridge",
843 /* .fFlags = */ PDM_DEVREG_FLAGS_DEFAULT_BITS | PDM_DEVREG_FLAGS_RZ | PDM_DEVREG_FLAGS_NEW_STYLE,
844 /* .fClass = */ PDM_DEVREG_CLASS_BUS_PCI,
845 /* .cMaxInstances = */ ~0U,
846 /* .uSharedVersion = */ 42,
847 /* .cbInstanceShared = */ sizeof(DEVPCIBUS),
848 /* .cbInstanceCC = */ sizeof(CTX_SUFF(DEVPCIBUS)),
849 /* .cbInstanceRC = */ 0,
850 /* .cMaxPciDevices = */ 1,
851 /* .cMaxMsixVectors = */ 0,
852 /* .pszDescription = */ "Generic ECAM PCI to PCI bridge",
853#if defined(IN_RING3)
854 /* .pszRCMod = */ "VBoxDDRC.rc",
855 /* .pszR0Mod = */ "VBoxDDR0.r0",
856 /* .pfnConstruct = */ pciGenEcamBridgeR3Construct,
857 /* .pfnDestruct = */ pciGenEcamBridgeR3Destruct,
858 /* .pfnRelocate = */ NULL,
859 /* .pfnMemSetup = */ NULL,
860 /* .pfnPowerOn = */ NULL,
861 /* .pfnReset = */ NULL, /* Must be NULL, to make sure only bus driver handles reset */
862 /* .pfnSuspend = */ NULL,
863 /* .pfnResume = */ NULL,
864 /* .pfnAttach = */ NULL,
865 /* .pfnDetach = */ NULL,
866 /* .pfnQueryInterface = */ NULL,
867 /* .pfnInitComplete = */ NULL,
868 /* .pfnPowerOff = */ NULL,
869 /* .pfnSoftReset = */ NULL,
870 /* .pfnReserved0 = */ NULL,
871 /* .pfnReserved1 = */ NULL,
872 /* .pfnReserved2 = */ NULL,
873 /* .pfnReserved3 = */ NULL,
874 /* .pfnReserved4 = */ NULL,
875 /* .pfnReserved5 = */ NULL,
876 /* .pfnReserved6 = */ NULL,
877 /* .pfnReserved7 = */ NULL,
878#elif defined(IN_RING0)
879 /* .pfnEarlyConstruct = */ NULL,
880 /* .pfnConstruct = */ pciGenEcamBridgeRZConstruct,
881 /* .pfnDestruct = */ NULL,
882 /* .pfnFinalDestruct = */ NULL,
883 /* .pfnRequest = */ NULL,
884 /* .pfnReserved0 = */ NULL,
885 /* .pfnReserved1 = */ NULL,
886 /* .pfnReserved2 = */ NULL,
887 /* .pfnReserved3 = */ NULL,
888 /* .pfnReserved4 = */ NULL,
889 /* .pfnReserved5 = */ NULL,
890 /* .pfnReserved6 = */ NULL,
891 /* .pfnReserved7 = */ NULL,
892#elif defined(IN_RC)
893 /* .pfnConstruct = */ pciGenEcamBridgeRZConstruct,
894 /* .pfnReserved0 = */ NULL,
895 /* .pfnReserved1 = */ NULL,
896 /* .pfnReserved2 = */ NULL,
897 /* .pfnReserved3 = */ NULL,
898 /* .pfnReserved4 = */ NULL,
899 /* .pfnReserved5 = */ NULL,
900 /* .pfnReserved6 = */ NULL,
901 /* .pfnReserved7 = */ NULL,
902#else
903# error "Not in IN_RING3, IN_RING0 or IN_RC!"
904#endif
905 /* .u32VersionEnd = */ PDM_DEVREG_VERSION
906};
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