VirtualBox

Changeset 32820 in vbox for trunk/src/VBox/Devices/Bus


Ignore:
Timestamp:
Sep 29, 2010 4:25:16 PM (14 years ago)
Author:
vboxsync
Message:

PCI, PDM: initial drop of MSI support

Location:
trunk/src/VBox/Devices/Bus
Files:
2 added
3 edited

Legend:

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

    r32776 r32820  
    24122412    PciBusReg.u32Version              = PDM_PCIBUSREG_VERSION;
    24132413    PciBusReg.pfnRegisterR3           = pcibridgeRegister;
     2414    PciBusReg.pfnRegisterMsiR3        = NULL;
    24142415    PciBusReg.pfnIORegionRegisterR3   = pciIORegionRegister;
    24152416    PciBusReg.pfnSetConfigCallbacksR3 = pciSetConfigCallbacks;
  • trunk/src/VBox/Devices/Bus/DevPciIch9.cpp

    r32776 r32820  
    2323#define PCI_INCLUDE_PRIVATE
    2424#include <VBox/pci.h>
     25#include <VBox/msi.h>
    2526#include <VBox/pdmdev.h>
    2627#include <iprt/asm.h>
     
    2930
    3031#include "../Builtins.h"
     32
     33#include "MsiCommon.h"
    3134
    3235/**
     
    176179#ifdef IN_RING3
    177180static int ich9pciRegisterInternal(PPCIBUS pBus, int iDev, PPCIDEVICE pPciDev, const char *pszName);
    178 static void ich9pciUpdateMappings(PCIDevice *d);
     181static void ich9pciUpdateMappings(PCIDevice *pDev);
    179182static DECLCALLBACK(uint32_t) ich9pciConfigRead(PCIDevice *aDev, uint32_t u32Address, unsigned len);
    180183DECLINLINE(PPCIDEVICE) ich9pciFindBridge(PPCIBUS pBus, uint8_t iBus);
     
    183186
    184187// See 7.2.2. PCI Express Enhanced Configuration Mechanism for details of address
    185 // mapping, we take n=8 approach
     188// mapping, we take n=6 approach
    186189DECLINLINE(void) ich9pciPhysToPciAddr(PPCIGLOBALS pGlobals, RTGCPHYS GCPhysAddr, PciAddress* pPciAddr)
    187190{
     
    523526static void ich9pciSetIrqInternal(PPCIGLOBALS pGlobals, uint8_t uDevFn, PPCIDEVICE pPciDev, int iIrq, int iLevel)
    524527{
     528    if (MSIIsEnabled(pPciDev))
     529    {
     530        Log2(("Raise a MSI interrupt: %d\n", iIrq));
     531        MSINotify(pGlobals->aPciBus.CTX_SUFF(pDevIns), pPciDev, iIrq);
     532        return;
     533    }
     534
    525535    PPCIBUS     pBus =     &pGlobals->aPciBus;
    526536    const bool  fIsAcpiDevice = PCIDevGetDeviceId(pPciDev) == 0x7113;
     
    769779}
    770780
     781
     782static DECLCALLBACK(int) ich9pciRegisterMsi(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, PPDMMSIREG pMsiReg)
     783{
     784    return MSIInit(pPciDev, pMsiReg);
     785}
     786
     787
    771788static DECLCALLBACK(int) ich9pcibridgeRegister(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, const char *pszName, int iDev)
    772789{
    773790
    774791    PPCIBUS pBus = PDMINS_2_DATA(pDevIns, PPCIBUS);
    775    
     792
    776793    /*
    777794     * Check input.
     
    15741591    }
    15751592
     1593    if (   PCIIsMsiCapable(aDev)
     1594        && (u32Address >= aDev->Int.s.u8MsiCapOffset)
     1595        && (u32Address <  aDev->Int.s.u8MsiCapOffset + aDev->Int.s.u8MsiCapSize)
     1596       )
     1597    {
     1598        return MSIPciConfigRead(aDev, u32Address, len);
     1599    }
     1600
    15761601    AssertMsgReturn(u32Address + len <= 256, ("Read after end of PCI config space\n"),
    15771602                    0);
     
    15791604    {
    15801605        case 1:
    1581             return aDev->config[u32Address];
     1606            return PCIDevGetByte(aDev,  u32Address);
    15821607        case 2:
    1583             return RT_LE2H_U16(*(uint16_t *)(aDev->config + u32Address));
     1608            return PCIDevGetWord(aDev,  u32Address);
    15841609        default:
    15851610        case 4:
    1586             return RT_LE2H_U32(*(uint32_t *)(aDev->config + u32Address));
     1611            return PCIDevGetDWord(aDev, u32Address);
    15871612    }
    15881613}
     
    16021627
    16031628    AssertMsgReturnVoid(u32Address + len <= 256, ("Write after end of PCI config space\n"));
     1629
     1630    if (   PCIIsMsiCapable(aDev)
     1631        && (u32Address >= aDev->Int.s.u8MsiCapOffset)
     1632        && (u32Address <  aDev->Int.s.u8MsiCapOffset + aDev->Int.s.u8MsiCapSize)
     1633       )
     1634    {
     1635        MSIPciConfigWrite(aDev, u32Address, val, len);
     1636        return;
     1637    }
     1638
    16041639
    16051640    /* Fast case - update one of BARs or ROM address, 'while' only for 'break' */
     
    16281663            val |= pRegion->type;
    16291664        }
    1630         *(uint32_t *)(aDev->config + u32Address) = RT_H2LE_U32(val);
     1665        PCIDevSetDWord(aDev, u32Address, val);
    16311666        ich9pciUpdateMappings(aDev);
    16321667        return;
     
    16441679                switch (addr)
    16451680                {
    1646                     /* Read-only registers, see  */
     1681                    /* Read-only registers  */
    16471682                    case VBOX_PCI_VENDOR_ID: case VBOX_PCI_VENDOR_ID+1:
    16481683                    case VBOX_PCI_DEVICE_ID: case VBOX_PCI_DEVICE_ID+1:
     
    19922027    PciBusReg.u32Version              = PDM_PCIBUSREG_VERSION;
    19932028    PciBusReg.pfnRegisterR3           = ich9pciRegister;
     2029    PciBusReg.pfnRegisterMsiR3        = ich9pciRegisterMsi;
    19942030    PciBusReg.pfnIORegionRegisterR3   = ich9pciIORegionRegister;
    19952031    PciBusReg.pfnSetConfigCallbacksR3 = ich9pciSetConfigCallbacks;
     
    21812217    PciBusReg.u32Version              = PDM_PCIBUSREG_VERSION;
    21822218    PciBusReg.pfnRegisterR3           = ich9pcibridgeRegister;
     2219    PciBusReg.pfnRegisterMsiR3        = ich9pciRegisterMsi;
    21832220    PciBusReg.pfnIORegionRegisterR3   = ich9pciIORegionRegister;
    21842221    PciBusReg.pfnSetConfigCallbacksR3 = ich9pciSetConfigCallbacks;
  • trunk/src/VBox/Devices/Bus/PCIInternal.h

    r32779 r32820  
    7575    /** Set if the specific device fun was requested by PDM.
    7676     * If clear the device and it's functions can be relocated to satisfy the slot request of another device. */
    77     PCIDEV_FLAG_REQUESTED_DEVFUNC = 1<<0,
     77    PCIDEV_FLAG_REQUESTED_DEVFUNC  = 1<<0,
    7878    /** Flag whether the device is a pci-to-pci bridge.
    7979     * This is set prior to device registration.  */
    80     PCIDEV_FLAG_PCI_TO_PCI_BRIDGE = 1<<1,
     80    PCIDEV_FLAG_PCI_TO_PCI_BRIDGE  = 1<<1,
    8181    /** Flag whether the device is a PCI Express device.
    8282     * This is set prior to device registration.  */
    8383    PCIDEV_FLAG_PCI_EXPRESS_DEVICE = 1<<2,
    8484    /** Flag whether the device is capable of MSI.
    85      * This is set prior to device registration.  */
    86     PCIDEV_FLAG_PCI_MSI            = 1<<3,
    87      /** Flag whether the device is capable of MSI-X.
    88      * This is set prior to device registration.  */
    89     PCIDEV_FLAG_PCI_MSIX           = 1<<4
    90    
     85     * This one is set by analyzing device capabilities, or explicitly.  */
     86    PCIDEV_FLAG_MSI_CAPABLE        = 1<<3,
     87    /** Flag whether the device is capable of MSI-X.
     88     * This one is set by analyzing device capabilities.  */
     89    PCIDEV_FLAG_MSIX_CAPABLE       = 1<<4
    9190};
    9291
     
    118117    int32_t                         uIrqPinState;
    119118
     119    /* Offset of MSI PCI capability in config space, or 0 */
     120    uint8_t                         u8MsiCapOffset;
     121    /* Size of MSI PCI capability in config space, or 0 */
     122    uint8_t                         u8MsiCapSize;
     123    /* Offset of MSI-X PCI capability in config space, or 0 */
     124    uint8_t                         u8MsixCapOffset;
     125    /* Size of MSI-X PCI capability in config space, or 0 */
     126    uint8_t                         u8MsixCapSize;
     127
     128    uint32_t                        Alignment1;
     129
    120130    /** Read config callback for PCI bridges to pass requests
    121131     *  to devices on another bus.
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