VirtualBox

Changeset 71768 in vbox


Ignore:
Timestamp:
Apr 9, 2018 2:10:52 PM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
121871
Message:

Msi: Some R3 prefixes and some clenaup.

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

Legend:

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

    r71155 r71768  
    791791    int rc;
    792792
    793     rc = MsiInit(pPciDev, pMsiReg);
     793    rc = MsiR3Init(pPciDev, pMsiReg);
    794794    if (RT_FAILURE(rc))
    795795        return rc;
    796796
    797     rc = MsixInit(pPciDev->Int.s.CTX_SUFF(pBus)->CTX_SUFF(pPciHlp), pPciDev, pMsiReg);
     797    rc = MsixR3Init(pPciDev->Int.s.CTX_SUFF(pBus)->CTX_SUFF(pPciHlp), pPciDev, pMsiReg);
    798798    if (RT_FAILURE(rc))
    799799        return rc;
     
    25442544        if (   pciDevIsMsiCapable(pPciDev)
    25452545            && uAddress - (uint32_t)pPciDev->Int.s.u8MsiCapOffset < (uint32_t)pPciDev->Int.s.u8MsiCapSize)
    2546             MsiPciConfigWrite(pPciDev->Int.s.CTX_SUFF(pBus)->CTX_SUFF(pDevIns),
    2547                               pPciDev->Int.s.CTX_SUFF(pBus)->CTX_SUFF(pPciHlp),
    2548                               pPciDev, uAddress, u32Value, cb);
     2546            MsiR3PciConfigWrite(pPciDev->Int.s.CTX_SUFF(pBus)->CTX_SUFF(pDevIns),
     2547                                pPciDev->Int.s.CTX_SUFF(pBus)->CTX_SUFF(pPciHlp),
     2548                                pPciDev, uAddress, u32Value, cb);
    25492549        else if (   pciDevIsMsixCapable(pPciDev)
    25502550                 && uAddress - (uint32_t)pPciDev->Int.s.u8MsixCapOffset < (uint32_t)pPciDev->Int.s.u8MsixCapSize)
    2551             MsixPciConfigWrite(pPciDev->Int.s.CTX_SUFF(pBus)->CTX_SUFF(pDevIns),
    2552                                pPciDev->Int.s.CTX_SUFF(pBus)->CTX_SUFF(pPciHlp),
    2553                                pPciDev, uAddress, u32Value, cb);
     2551            MsixR3PciConfigWrite(pPciDev->Int.s.CTX_SUFF(pBus)->CTX_SUFF(pDevIns),
     2552                                 pPciDev->Int.s.CTX_SUFF(pBus)->CTX_SUFF(pPciHlp),
     2553                                 pPciDev, uAddress, u32Value, cb);
    25542554        else
    25552555        {
  • trunk/src/VBox/Devices/Bus/MsiCommon.cpp

    r68118 r71768  
    1717 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
    1818 */
     19
    1920#define LOG_GROUP LOG_GROUP_DEV_PCI
    2021#define PDMPCIDEV_INCLUDE_PRIVATE  /* Hack to get pdmpcidevint.h included at the right point. */
     
    2728#include "PciInline.h"
    2829
     30
    2931DECLINLINE(uint16_t) msiGetMessageControl(PPDMPCIDEV pDev)
    3032{
    3133    uint32_t idxMessageControl = pDev->Int.s.u8MsiCapOffset + VBOX_MSI_CAP_MESSAGE_CONTROL;
    3234#ifdef IN_RING3
    33     if (pciDevIsPassthrough(pDev)) {
     35    if (pciDevIsPassthrough(pDev))
    3436        return pDev->Int.s.pfnConfigRead(pDev->Int.s.CTX_SUFF(pDevIns), pDev, idxMessageControl, 2);
    35     }
    3637#endif
    3738    return PCIDevGetWord(pDev, idxMessageControl);
     
    4647 * up to date, which is a wrong assumption for the "emulate passthrough" case
    4748 * where only the callbacks give the correct data. */
    48 DECLINLINE(uint32_t*) msiGetMaskBits(PPDMPCIDEV pDev)
     49DECLINLINE(uint32_t *) msiGetMaskBits(PPDMPCIDEV pDev)
    4950{
    5051    uint8_t iOff = msiIs64Bit(pDev) ? VBOX_MSI_CAP_MASK_BITS_64 : VBOX_MSI_CAP_MASK_BITS_32;
     
    8788        return RT_MAKE_U64(lo, hi);
    8889    }
    89     else
    90     {
    91         return PCIDevGetDWord(pDev, pDev->Int.s.u8MsiCapOffset + VBOX_MSI_CAP_MESSAGE_ADDRESS_32);
    92     }
     90    return PCIDevGetDWord(pDev, pDev->Int.s.u8MsiCapOffset + VBOX_MSI_CAP_MESSAGE_ADDRESS_32);
    9391}
    9492
     
    109107#ifdef IN_RING3
    110108
    111 DECLINLINE(bool) msiBitJustCleared(uint32_t uOldValue,
    112                                    uint32_t uNewValue,
    113                                    uint32_t uMask)
    114 {
    115     return (!!(uOldValue & uMask) && !(uNewValue & uMask));
    116 }
    117 
    118 DECLINLINE(bool) msiBitJustSet(uint32_t uOldValue,
    119                                uint32_t uNewValue,
    120                                uint32_t uMask)
    121 {
    122     return (!(uOldValue & uMask) && !!(uNewValue & uMask));
    123 }
    124 
    125 void     MsiPciConfigWrite(PPDMDEVINS pDevIns, PCPDMPCIHLP pPciHlp, PPDMPCIDEV pDev,
    126                            uint32_t u32Address, uint32_t val, unsigned len)
     109DECLINLINE(bool) msiR3BitJustCleared(uint32_t uOldValue, uint32_t uNewValue, uint32_t uMask)
     110{
     111    return !!(uOldValue & uMask) && !(uNewValue & uMask);
     112}
     113
     114DECLINLINE(bool) msiR3BitJustSet(uint32_t uOldValue, uint32_t uNewValue, uint32_t uMask)
     115{
     116    return !(uOldValue & uMask) && !!(uNewValue & uMask);
     117}
     118
     119void MsiR3PciConfigWrite(PPDMDEVINS pDevIns, PCPDMPCIHLP pPciHlp, PPDMPCIDEV pDev,
     120                         uint32_t u32Address, uint32_t val, unsigned len)
    127121{
    128122    int32_t iOff = u32Address - pDev->Int.s.u8MsiCapOffset;
    129123    Assert(iOff >= 0 && (pciDevIsMsiCapable(pDev) && iOff < pDev->Int.s.u8MsiCapSize));
    130124
    131     Log2(("MsiPciConfigWrite: %d <- %x (%d)\n", iOff, val, len));
     125    Log2(("MsiR3PciConfigWrite: %d <- %x (%d)\n", iOff, val, len));
    132126
    133127    uint32_t uAddr = u32Address;
     
    181175                            uint32_t uVector = maskUpdated*8 + iBitNum;
    182176
    183                             if (msiBitJustCleared(pDev->abConfig[uAddr], u8Val, iBit))
     177                            if (msiR3BitJustCleared(pDev->abConfig[uAddr], u8Val, iBit))
    184178                            {
    185179                                Log(("msi: mask updated bit %d@%x (%d)\n", iBitNum, uAddr, maskUpdated));
     
    193187                                }
    194188                            }
    195                             if (msiBitJustSet(pDev->abConfig[uAddr], u8Val, iBit))
     189                            if (msiR3BitJustSet(pDev->abConfig[uAddr], u8Val, iBit))
    196190                            {
    197191                                Log(("msi: mask vector: %d\n", uVector));
     
    208202}
    209203
    210 int MsiInit(PPDMPCIDEV pDev, PPDMMSIREG pMsiReg)
     204int MsiR3Init(PPDMPCIDEV pDev, PPDMMSIREG pMsiReg)
    211205{
    212206    if (pMsiReg->cMsiVectors == 0)
     
    272266
    273267
    274 bool     MsiIsEnabled(PPDMPCIDEV pDev)
     268bool MsiIsEnabled(PPDMPCIDEV pDev)
    275269{
    276270    return pciDevIsMsiCapable(pDev) && msiIsEnabled(pDev);
     
    326320    pPciHlp->pfnIoApicSendMsi(pDevIns, GCAddr, u32Value, uTagSrc);
    327321}
     322
  • trunk/src/VBox/Devices/Bus/MsiCommon.h

    r69124 r71768  
    33 * Header for MSI/MSI-X support routines.
    44 */
     5
    56/*
    67 * Copyright (C) 2010-2017 Oracle Corporation
     
    3031#ifdef IN_RING3
    3132/* Init MSI support in the device. */
    32 int      MsiInit(PPDMPCIDEV pDev, PPDMMSIREG pMsiReg);
     33int      MsiR3Init(PPDMPCIDEV pDev, PPDMMSIREG pMsiReg);
    3334#endif
    3435
     
    4142#ifdef IN_RING3
    4243/* PCI config space accessors for MSI registers */
    43 void     MsiPciConfigWrite(PPDMDEVINS pDevIns, PCPDMPCIHLP pPciHlp, PPDMPCIDEV pDev, uint32_t u32Address, uint32_t val, unsigned len);
     44void     MsiR3PciConfigWrite(PPDMDEVINS pDevIns, PCPDMPCIHLP pPciHlp, PPDMPCIDEV pDev, uint32_t u32Address, uint32_t val, unsigned len);
    4445#endif
    4546
    4647#ifdef IN_RING3
    4748/* Init MSI-X support in the device. */
    48 int      MsixInit(PCPDMPCIHLP pPciHlp, PPDMPCIDEV pDev, PPDMMSIREG pMsiReg);
     49int      MsixR3Init(PCPDMPCIHLP pPciHlp, PPDMPCIDEV pDev, PPDMMSIREG pMsiReg);
    4950#endif
    5051
     
    5758#ifdef IN_RING3
    5859/* PCI config space accessors for MSI-X */
    59 void     MsixPciConfigWrite(PPDMDEVINS pDevIns, PCPDMPCIHLP pPciHlp, PPDMPCIDEV pDev, uint32_t u32Address, uint32_t val, unsigned len);
     60void     MsixR3PciConfigWrite(PPDMDEVINS pDevIns, PCPDMPCIHLP pPciHlp, PPDMPCIDEV pDev, uint32_t u32Address, uint32_t val, unsigned len);
    6061#endif
  • trunk/src/VBox/Devices/Bus/MsixCommon.cpp

    r68423 r71768  
    1515 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
    1616 */
     17
     18
    1719#define LOG_GROUP LOG_GROUP_DEV_PCI
    1820#define PDMPCIDEV_INCLUDE_PRIVATE  /* Hack to get pdmpcidevint.h included at the right point. */
     
    2830#include "PciInline.h"
    2931
    30 #pragma pack(1)
    3132typedef struct
    3233{
     
    3738} MsixTableRecord;
    3839AssertCompileSize(MsixTableRecord, VBOX_MSIX_ENTRY_SIZE);
    39 #pragma pack()
     40
    4041
    4142/** @todo use accessors so that raw PCI devices work correctly with MSI-X. */
     
    114115#ifdef IN_RING3
    115116
    116 PDMBOTHCBDECL(int) msixMMIORead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb)
     117PDMBOTHCBDECL(int) msixR3MMIORead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb)
    117118{
    118119    LogFlowFunc(("\n"));
     
    130131                    VINF_IOM_MMIO_UNUSED_FF);
    131132
    132     *(uint32_t*)pv = *(uint32_t*)msixGetPageOffset(pPciDev, off);
     133    *(uint32_t *)pv = *(uint32_t *)msixGetPageOffset(pPciDev, off);
    133134    return VINF_SUCCESS;
    134135}
    135136
    136 PDMBOTHCBDECL(int) msixMMIOWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void const *pv, unsigned cb)
     137PDMBOTHCBDECL(int) msixR3MMIOWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void const *pv, unsigned cb)
    137138{
    138139    LogFlowFunc(("\n"));
     
    149150                    VINF_IOM_MMIO_UNUSED_FF);
    150151
    151     *(uint32_t*)msixGetPageOffset(pPciDev, off) = *(uint32_t*)pv;
     152    *(uint32_t *)msixGetPageOffset(pPciDev, off) = *(uint32_t *)pv;
    152153
    153154    msixCheckPendingVector(pDevIns, (PCPDMPCIHLP)pPciDev->Int.s.pPciBusPtrR3, pPciDev, off / VBOX_MSIX_ENTRY_SIZE);
     
    158159 * @callback_method_impl{FNPCIIOREGIONMAP}
    159160 */
    160 static DECLCALLBACK(int) msixMap(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion,
    161                                  RTGCPHYS GCPhysAddress, RTGCPHYS cb, PCIADDRESSSPACE enmType)
     161static DECLCALLBACK(int) msixR3Map(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion,
     162                                   RTGCPHYS GCPhysAddress, RTGCPHYS cb, PCIADDRESSSPACE enmType)
    162163{
    163164    Assert(enmType == PCI_ADDRESS_SPACE_MEM);
     
    166167    int rc = PDMDevHlpMMIORegister(pDevIns, GCPhysAddress, cb, pPciDev,
    167168                                   IOMMMIO_FLAGS_READ_PASSTHRU | IOMMMIO_FLAGS_WRITE_PASSTHRU,
    168                                    msixMMIOWrite, msixMMIORead, "MSI-X tables");
     169                                   msixR3MMIOWrite, msixR3MMIORead, "MSI-X tables");
    169170
    170171    if (RT_FAILURE(rc))
     
    174175}
    175176
    176 int MsixInit(PCPDMPCIHLP pPciHlp, PPDMPCIDEV pDev, PPDMMSIREG pMsiReg)
     177int MsixR3Init(PCPDMPCIHLP pPciHlp, PPDMPCIDEV pDev, PPDMMSIREG pMsiReg)
    177178{
    178179    if (pMsiReg->cMsixVectors == 0)
    179          return VINF_SUCCESS;
     180        return VINF_SUCCESS;
    180181
    181182     /* We cannot init MSI-X on raw devices yet. */
     
    205206    if (!pciDevIsPassthrough(pDev))
    206207    {
    207         rc = PDMDevHlpPCIIORegionRegister(pDev->Int.s.CTX_SUFF(pDevIns), iBar, cbMsixRegion, PCI_ADDRESS_SPACE_MEM, msixMap);
     208        rc = PDMDevHlpPCIIORegionRegister(pDev->Int.s.CTX_SUFF(pDevIns), iBar, cbMsixRegion, PCI_ADDRESS_SPACE_MEM, msixR3Map);
    208209        if (RT_FAILURE (rc))
    209210            return rc;
     
    244245#endif
    245246
    246 bool     MsixIsEnabled(PPDMPCIDEV pDev)
     247bool MsixIsEnabled(PPDMPCIDEV pDev)
    247248{
    248249    return pciDevIsMsixCapable(pDev) && msixIsEnabled(pDev);
     
    292293
    293294
    294 void MsixPciConfigWrite(PPDMDEVINS pDevIns, PCPDMPCIHLP pPciHlp, PPDMPCIDEV pDev, uint32_t u32Address, uint32_t val, unsigned len)
     295void MsixR3PciConfigWrite(PPDMDEVINS pDevIns, PCPDMPCIHLP pPciHlp, PPDMPCIDEV pDev, uint32_t u32Address, uint32_t val, unsigned len)
    295296{
    296297    int32_t iOff = u32Address - pDev->Int.s.u8MsixCapOffset;
    297298    Assert(iOff >= 0 && (pciDevIsMsixCapable(pDev) && iOff < pDev->Int.s.u8MsixCapSize));
    298299
    299     Log2(("MsixPciConfigWrite: %d <- %x (%d)\n", iOff, val, len));
     300    Log2(("MsixR3PciConfigWrite: %d <- %x (%d)\n", iOff, val, len));
    300301
    301302    uint32_t uAddr = u32Address;
Note: See TracChangeset for help on using the changeset viewer.

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