VirtualBox

Changeset 64423 in vbox for trunk


Ignore:
Timestamp:
Oct 25, 2016 4:10:37 PM (8 years ago)
Author:
vboxsync
Message:

DevPci: Share location code, fixing missing pPciHlpRC relocation for bridges.

Location:
trunk/src/VBox/Devices/Bus
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Bus/DevPCI.cpp

    r64420 r64423  
    33 * DevPCI - PCI BUS Device.
    44 *
    5  * @remarks New code is currently added to DevPciMerge1.cpp.h, the goal is
    6  *          to end up with a large common code base for the two PCI bus
    7  *          implementations.  The merge file will soon be compiled separately
    8  *          and not included, so it shall not be used as a template with
    9  *          \#ifdefs for different PCI bus configs, but rather use config
    10  *          flags in the structures to select paths & feature sets.
    11  *
    12  *          When moving code, always prefer the ICH9 version, not this!
     5 * @remarks New code shall be added to DevPciIch9.cpp as that will become
     6 *          the common PCI bus code soon.  Don't fix code in both DevPCI.cpp
     7 *          and DevPciIch9.cpp when it's possible to just make the latter
     8 *          version common.   Common code uses the 'devpci' prefix, is
     9 *          prototyped in DevPciInternal.h, and is defined in DevPciIch9.cpp.
    1310 */
    1411
     
    18211818/* -=-=-=-=-=- PDMDEVREG  -=-=-=-=-=- */
    18221819
    1823 /**
    1824  * @interface_method_impl{PDMDEVREG,pfnRelocate}
    1825  */
    1826 static DECLCALLBACK(void) pciR3Relocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta)
    1827 {
    1828     PDEVPCIROOT pGlobals = PDMINS_2_DATA(pDevIns, PDEVPCIROOT);
    1829     PDEVPCIBUS     pBus     = &pGlobals->PciBus;
    1830     pGlobals->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);
    1831 
    1832     pBus->pPciHlpRC = pBus->pPciHlpR3->pfnGetRCHelpers(pDevIns);
    1833     pBus->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);
    1834 
    1835     /* Relocate RC pointers for the attached pci devices. */
    1836     for (uint32_t i = 0; i < RT_ELEMENTS(pBus->apDevices); i++)
    1837     {
    1838         if (pBus->apDevices[i])
    1839             pBus->apDevices[i]->Int.s.pBusRC += offDelta;
    1840     }
    1841 }
    1842 
    18431820
    18441821/**
     
    20412018    NULL,
    20422019    /* pfnRelocate */
    2043     pciR3Relocate,
     2020    devpciR3RootRelocate,
    20442021    /* pfnMemSetup */
    20452022    NULL,
     
    22122189
    22132190/**
    2214  * @interface_method_impl{PDMDEVREG,pfnRelocate}
    2215  */
    2216 static DECLCALLBACK(void) pcibridgeR3Relocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta)
    2217 {
    2218     PDEVPCIBUS pBus = PDMINS_2_DATA(pDevIns, PDEVPCIBUS);
    2219     pBus->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);
    2220 
    2221     /* Relocate RC pointers for the attached pci devices. */
    2222     for (uint32_t i = 0; i < RT_ELEMENTS(pBus->apDevices); i++)
    2223     {
    2224         if (pBus->apDevices[i])
    2225             pBus->apDevices[i]->Int.s.pBusRC += offDelta;
    2226     }
    2227 }
    2228 
    2229 
    2230 /**
    22312191 * @interface_method_impl{PDMDEVREG,pfnConstruct}
    22322192 */
     
    23762336    NULL,
    23772337    /* pfnRelocate */
    2378     pcibridgeR3Relocate,
     2338    devpciR3BusRelocate,
    23792339    /* pfnMemSetup */
    23802340    NULL,
  • trunk/src/VBox/Devices/Bus/DevPciIch9.cpp

    r64421 r64423  
    33 * DevPCI - ICH9 southbridge PCI bus emulation device.
    44 *
    5  * @remarks New code is currently added to DevPciMerge1.cpp.h, the goal is
    6  *          to end up with a large common code base for the two PCI bus
    7  *          implementations.  The merge file will soon be compiled separately
    8  *          and not included, so it shall not be used as a template with
    9  *          \#ifdefs for different PCI bus configs, but rather use config
    10  *          flags in the structures to select paths & feature sets.
     5 * @remarks We'll be slowly promoting the code in this file to common PCI bus
     6 *          code.   Function without 'static' and using 'devpci' as prefix is
     7 *          also used by DevPCI.cpp and have a prototype in DevPciInternal.h.
    118 *
    12  *          When moving code, always prefer the ICH9 version (this file)!
     9 *          For the time being the DevPciMerge1.cpp.h file will remain separate,
     10 *          due to 5.1.  We can merge it into this one later in the dev cycle.
    1311 */
    1412
     
    25542552}
    25552553
    2556 static void ich9pciRelocateDevice(PPDMPCIDEV pDev, RTGCINTPTR offDelta)
    2557 {
    2558     if (pDev)
    2559     {
    2560         pDev->Int.s.pBusRC += offDelta;
    2561         if (pDev->Int.s.pMsixPageRC)
    2562             pDev->Int.s.pMsixPageRC += offDelta;
    2563     }
    2564 }
    25652554
    25662555/**
    2567  * @copydoc FNPDMDEVRELOCATE
    2568  */
    2569 static DECLCALLBACK(void) ich9pciRelocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta)
    2570 {
    2571     PDEVPCIROOT pGlobals = PDMINS_2_DATA(pDevIns, PDEVPCIROOT);
    2572     PDEVPCIBUS     pBus     = &pGlobals->PciBus;
    2573     pGlobals->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);
    2574 
     2556 * @interface_method_impl{PDMDEVREG,pfnRelocate}
     2557 */
     2558DECLCALLBACK(void) devpciR3BusRelocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta)
     2559{
     2560    PDEVPCIBUS pBus = PDMINS_2_DATA(pDevIns, PDEVPCIBUS);
     2561
     2562    pBus->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);
    25752563    pBus->pPciHlpRC = pBus->pPciHlpR3->pfnGetRCHelpers(pDevIns);
    2576     pBus->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);
    25772564
    25782565    /* Relocate RC pointers for the attached pci devices. */
    25792566    for (uint32_t i = 0; i < RT_ELEMENTS(pBus->apDevices); i++)
    2580         ich9pciRelocateDevice(pBus->apDevices[i], offDelta);
    2581 
    2582 }
     2567    {
     2568        PPDMPCIDEV pDev = pBus->apDevices[i];
     2569        if (pDev)
     2570        {
     2571            pDev->Int.s.pBusRC += offDelta;
     2572            if (pDev->Int.s.pMsixPageRC)
     2573                pDev->Int.s.pMsixPageRC += offDelta;
     2574        }
     2575    }
     2576}
     2577
     2578
     2579/**
     2580 * @interface_method_impl{PDMDEVREG,pfnRelocate}
     2581 */
     2582DECLCALLBACK(void) devpciR3RootRelocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta)
     2583{
     2584    PDEVPCIROOT pGlobals = PDMINS_2_DATA(pDevIns, PDEVPCIROOT);
     2585    pGlobals->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);
     2586
     2587    AssertCompileMemberOffset(DEVPCIROOT, PciBus, 0);
     2588    devpciR3BusRelocate(pDevIns, offDelta);
     2589}
     2590
    25832591
    25842592/**
     
    27292737
    27302738
    2731 /**
    2732  * @copydoc FNPDMDEVRELOCATE
    2733  */
    2734 static DECLCALLBACK(void) ich9pcibridgeRelocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta)
    2735 {
    2736     PDEVPCIBUS pBus = PDMINS_2_DATA(pDevIns, PDEVPCIBUS);
    2737     pBus->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);
    2738 
    2739     /* Relocate RC pointers for the attached pci devices. */
    2740     for (uint32_t i = 0; i < RT_ELEMENTS(pBus->apDevices); i++)
    2741         ich9pciRelocateDevice(pBus->apDevices[i], offDelta);
    2742 }
    27432739
    27442740/**
     
    27702766    NULL,
    27712767    /* pfnRelocate */
    2772     ich9pciRelocate,
     2768    devpciR3RootRelocate,
    27732769    /* pfnMemSetup */
    27742770    NULL,
     
    28262822    NULL,
    28272823    /* pfnRelocate */
    2828     ich9pcibridgeRelocate,
     2824    devpciR3BusRelocate,
    28292825    /* pfnMemSetup */
    28302826    NULL,
  • trunk/src/VBox/Devices/Bus/DevPciInternal.h

    r64420 r64423  
    181181
    182182
     183DECLCALLBACK(void) devpciR3RootRelocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta);
     184DECLCALLBACK(void) devpciR3BusRelocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta);
     185
    183186#endif
    184187
  • trunk/src/VBox/Devices/Bus/DevPciMerge1.cpp.h

    r64420 r64423  
    11/* $Id$ */
    22/** @file
    3  * DevPci - Common code that is included by both DevPci and DevPciIch9.
    4  *
    5  * @note All the code in this file is written by us!
    6  * @note No #ifdefs, use instant data booleans/flags/whatever.  Goal is to
    7  *       completely merge these files!
     3 * DevPci - Early attempt at common code for DevPci and DevPciIch9.
     4 *
     5 * @note    Don't add more, add code to DevPciIch9.cpp instead.
     6 * @note    We'll keep this file like this for a little while longer
     7 *          because of 5.1.
    88 */
    99
Note: See TracChangeset for help on using the changeset viewer.

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