VirtualBox

Changeset 2597 in vbox


Ignore:
Timestamp:
May 11, 2007 6:19:23 PM (18 years ago)
Author:
vboxsync
Message:

New device helper PCISetConfigCallbacks. (patch from R. Zeljko)

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/pdm.h

    r2576 r2597  
    32803280
    32813281    /**
     3282     * Register PCI configuration space read/write callbacks.
     3283     *
     3284     * @param   pDevIns         Device instance of the PCI Bus.
     3285     * @param   pPciDev         The PCI device structure.
     3286     * @param   pfnRead         Pointer to the user defined PCI config read function.
     3287     * @param   ppfnReadOld     Pointer to function pointer which will receive the old (default)
     3288     *                          PCI config read function. This way, user can decide when (and if)
     3289     *                          to call default PCI config read function. Can be NULL.
     3290     * @param   pfnWrite        Pointer to the user defined PCI config write function.
     3291     * @param   pfnWriteOld     Pointer to function pointer which will receive the old (default)
     3292     *                          PCI config write function. This way, user can decide when (and if)
     3293     *                          to call default PCI config write function. Can be NULL.
     3294     * @thread  EMT
     3295     */
     3296    DECLR3CALLBACKMEMBER(void, pfnSetConfigCallbacksHC,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, PFNPCICONFIGREAD pfnRead, PPFNPCICONFIGREAD ppfnReadOld,
     3297                                                        PFNPCICONFIGWRITE pfnWrite, PPFNPCICONFIGWRITE ppfnWriteOld));
     3298
     3299    /**
    32823300     * Set the IRQ for a PCI device.
    32833301     *
     
    33303348
    33313349/** Current PDMPCIBUSREG version number. */
    3332 #define PDM_PCIBUSREG_VERSION   0xd0010000
     3350#define PDM_PCIBUSREG_VERSION   0xd0020000
    33333351
    33343352/**
     
    47134731
    47144732    /**
     4733     * Register PCI configuration space read/write callbacks.
     4734     *
     4735     * @param   pDevIns         Device instance.
     4736     * @param   pPciDev         The PCI device structure.
     4737     *                          If NULL the default PCI device for this device instance is used.
     4738     * @param   pfnRead         Pointer to the user defined PCI config read function.
     4739     * @param   ppfnReadOld     Pointer to function pointer which will receive the old (default)
     4740     *                          PCI config read function. This way, user can decide when (and if)
     4741     *                          to call default PCI config read function. Can be NULL.
     4742     * @param   pfnWrite        Pointer to the user defined PCI config write function.
     4743     * @param   pfnWriteOld     Pointer to function pointer which will receive the old (default)
     4744     *                          PCI config write function. This way, user can decide when (and if)
     4745     *                          to call default PCI config write function. Can be NULL.
     4746     * @thread  EMT
     4747     */
     4748    DECLR3CALLBACKMEMBER(void, pfnPCISetConfigCallbacks,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, PFNPCICONFIGREAD pfnRead, PPFNPCICONFIGREAD ppfnReadOld,
     4749                                                         PFNPCICONFIGWRITE pfnWrite, PPFNPCICONFIGWRITE ppfnWriteOld));
     4750
     4751    /**
    47154752     * Set the IRQ for a PCI device.
    47164753     *
     
    53105347
    53115348/** Current PDMDEVHLP version number. */
    5312 #define PDM_DEVHLP_VERSION  0xf2020000
     5349#define PDM_DEVHLP_VERSION  0xf2030000
    53135350
    53145351
     
    57785815
    57795816/**
     5817 * @copydoc PDMDEVHLP::pfnPCISetConfigCallbacks
     5818 */
     5819DECLINLINE(void) PDMDevHlpPCISetConfigCallbacks(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, PFNPCICONFIGREAD pfnRead, PPFNPCICONFIGREAD ppfnReadOld,
     5820                                                PFNPCICONFIGWRITE pfnWrite, PPFNPCICONFIGWRITE ppfnWriteOld)
     5821{
     5822    pDevIns->pDevHlp->pfnPCISetConfigCallbacks(pDevIns, pPciDev, pfnRead, ppfnReadOld, pfnWrite, ppfnWriteOld);
     5823}
     5824
     5825/**
    57805826 * @copydoc PDMDEVHLP::pfnDriverAttach
    57815827 */
  • trunk/src/VBox/Devices/Bus/DevPCI.cpp

    r2596 r2597  
    13211321
    13221322
     1323/**
     1324 * @copydoc PDMPCIBUSREG::pfnSetConfigCallbacksHC
     1325 */
     1326static DECLCALLBACK(void) pciSetConfigCallbacks(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, PFNPCICONFIGREAD pfnRead, PPFNPCICONFIGREAD ppfnReadOld,
     1327                                                PFNPCICONFIGWRITE pfnWrite, PPFNPCICONFIGWRITE ppfnWriteOld)
     1328{
     1329    if (ppfnReadOld)
     1330        *ppfnReadOld = pPciDev->Int.s.pfnConfigRead;
     1331    pPciDev->Int.s.pfnConfigRead  = pfnRead;
     1332
     1333    if (ppfnWriteOld)
     1334        *ppfnWriteOld = pPciDev->Int.s.pfnConfigWrite;
     1335    pPciDev->Int.s.pfnConfigWrite = pfnWrite;
     1336}
     1337
     1338
    13231339/**
    13241340 * Called to perform the job of the bios.
     
    14611477    pBus->pDevInsGC = PDMDEVINS_2_GCPTR(pDevIns);
    14621478
    1463     PciBusReg.u32Version            = PDM_PCIBUSREG_VERSION;
    1464     PciBusReg.pfnRegisterHC         = pciRegister;
    1465     PciBusReg.pfnIORegionRegisterHC = pciIORegionRegister;
    1466     PciBusReg.pfnSetIrqHC           = pciSetIrq;
    1467     PciBusReg.pfnSaveExecHC         = pciGenericSaveExec;
    1468     PciBusReg.pfnLoadExecHC         = pciGenericLoadExec;
    1469     PciBusReg.pfnFakePCIBIOSHC      = pciFakePCIBIOS;
    1470     PciBusReg.pszSetIrqGC           = fGCEnabled ? "pciSetIrq" : NULL;
    1471     PciBusReg.pszSetIrqR0           = fR0Enabled ? "pciSetIrq" : NULL;
     1479    PciBusReg.u32Version              = PDM_PCIBUSREG_VERSION;
     1480    PciBusReg.pfnRegisterHC           = pciRegister;
     1481    PciBusReg.pfnIORegionRegisterHC   = pciIORegionRegister;
     1482    PciBusReg.pfnSetConfigCallbacksHC = pciSetConfigCallbacks;
     1483    PciBusReg.pfnSetIrqHC             = pciSetIrq;
     1484    PciBusReg.pfnSaveExecHC           = pciGenericSaveExec;
     1485    PciBusReg.pfnLoadExecHC           = pciGenericLoadExec;
     1486    PciBusReg.pfnFakePCIBIOSHC        = pciFakePCIBIOS;
     1487    PciBusReg.pszSetIrqGC             = fGCEnabled ? "pciSetIrq" : NULL;
     1488    PciBusReg.pszSetIrqR0             = fR0Enabled ? "pciSetIrq" : NULL;
    14721489    rc = pDevIns->pDevHlp->pfnPCIBusRegister(pDevIns, &PciBusReg, &pBus->pPciHlpR3);
    14731490    if (VBOX_FAILURE(rc))
  • trunk/src/VBox/VMM/PDMDevice.cpp

    r2464 r2597  
    108108static DECLCALLBACK(int) pdmR3DevHlp_PCIRegister(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev);
    109109static DECLCALLBACK(int) pdmR3DevHlp_PCIIORegionRegister(PPDMDEVINS pDevIns, int iRegion, uint32_t cbRegion, PCIADDRESSSPACE enmType, PFNPCIIOREGIONMAP pfnCallback);
     110static DECLCALLBACK(void) pdmR3DevHlp_PCISetConfigCallbacks(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, PFNPCICONFIGREAD pfnRead, PPFNPCICONFIGREAD ppfnReadOld,
     111                                                            PFNPCICONFIGWRITE pfnWrite, PPFNPCICONFIGWRITE ppfnWriteOld);
    110112static DECLCALLBACK(void) pdmR3DevHlp_PCISetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel);
    111113static DECLCALLBACK(void) pdmR3DevHlp_PCISetIrqNoWait(PPDMDEVINS pDevIns, int iIrq, int iLevel);
     
    288290    pdmR3DevHlp_PCIRegister,
    289291    pdmR3DevHlp_PCIIORegionRegister,
     292    pdmR3DevHlp_PCISetConfigCallbacks,
    290293    pdmR3DevHlp_PCISetIrq,
    291294    pdmR3DevHlp_PCISetIrqNoWait,
     
    372375    pdmR3DevHlp_PCIRegister,
    373376    pdmR3DevHlp_PCIIORegionRegister,
     377    pdmR3DevHlp_PCISetConfigCallbacks,
    374378    pdmR3DevHlp_PCISetIrq,
    375379    pdmR3DevHlp_PCISetIrqNoWait,
     
    16191623{
    16201624    PDMDEV_ASSERT_DEVINS(pDevIns);
    1621     VM_ASSERT_EMT(pDevIns->Internal.s.pVMHC);
     1625    PVM pVM = pDevIns->Internal.s.pVMHC;
     1626    VM_ASSERT_EMT(pVM);
    16221627    LogFlow(("pdmR3DevHlp_PCIIORegionRegister: caller='%s'/%d: iRegion=%d cbRegion=%#x enmType=%d pfnCallback=%p\n",
    16231628             pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, iRegion, cbRegion, enmType, pfnCallback));
     
    16491654        return VERR_INVALID_PARAMETER;
    16501655    }
     1656    AssertRelease(VMR3GetState(pVM) != VMSTATE_RUNNING);
    16511657
    16521658    /*
     
    16701676        PPDMPCIBUS pBus = pDevIns->Internal.s.pPciBusHC;
    16711677        Assert(pBus);
    1672         pdmLock(pDevIns->Internal.s.pVMHC);
     1678        pdmLock(pVM);
    16731679        rc = pBus->pfnIORegionRegisterR3(pBus->pDevInsR3, pPciDev, iRegion, cbRegion, enmType, pfnCallback);
    1674         pdmUnlock(pDevIns->Internal.s.pVMHC);
     1680        pdmUnlock(pVM);
    16751681    }
    16761682    else
     
    16821688    LogFlow(("pdmR3DevHlp_PCIIORegionRegister: caller='%s'/%d: returns %Vrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
    16831689    return rc;
     1690}
     1691
     1692
     1693/** @copydoc PDMDEVHLP::pfnPCISetConfigCallbacks */
     1694static DECLCALLBACK(void) pdmR3DevHlp_PCISetConfigCallbacks(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, PFNPCICONFIGREAD pfnRead, PPFNPCICONFIGREAD ppfnReadOld,
     1695                                                            PFNPCICONFIGWRITE pfnWrite, PPFNPCICONFIGWRITE ppfnWriteOld)
     1696{
     1697    PDMDEV_ASSERT_DEVINS(pDevIns);
     1698    PVM pVM = pDevIns->Internal.s.pVMHC;
     1699    VM_ASSERT_EMT(pVM);
     1700    LogFlow(("pdmR3DevHlp_PCISetConfigCallbacks: caller='%s'/%d: pPciDev=%p pfnRead=%p ppfnReadOld=%p pfnWrite=%p ppfnWriteOld=%p\n",
     1701             pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pPciDev, pfnRead, ppfnReadOld, pfnWrite, ppfnWriteOld));
     1702
     1703    /*
     1704     * Validate input and resolve defaults.
     1705     */
     1706    AssertPtr(pfnRead);
     1707    AssertPtr(pfnWrite);
     1708    AssertPtrNull(ppfnReadOld);
     1709    AssertPtrNull(ppfnWriteOld);
     1710    AssertPtrNull(pPciDev);
     1711
     1712    if (!pPciDev)
     1713        pPciDev = pDevIns->Internal.s.pPciDeviceHC;
     1714    AssertReleaseMsg(pPciDev, ("You must register your device first!\n"));
     1715    PPDMPCIBUS pBus = pDevIns->Internal.s.pPciBusHC;
     1716    AssertRelease(pBus);
     1717    AssertRelease(VMR3GetState(pVM) != VMSTATE_RUNNING);
     1718
     1719    /*
     1720     * Do the job.
     1721     */
     1722    pdmLock(pVM);
     1723    pBus->pfnSetConfigCallbacksR3(pBus->pDevInsR3, pPciDev, pfnRead, ppfnReadOld, pfnWrite, ppfnWriteOld);
     1724    pdmUnlock(pVM);
     1725
     1726    LogFlow(("pdmR3DevHlp_PCISetConfigCallbacks: caller='%s'/%d: returns void\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
    16841727}
    16851728
     
    24342477     * Init the HC bits.
    24352478     */
    2436     pPciBus->iBus                   = iBus;
    2437     pPciBus->pDevInsR3              = pDevIns;
    2438     pPciBus->pfnRegisterR3          = pPciBusReg->pfnRegisterHC;
    2439     pPciBus->pfnIORegionRegisterR3  = pPciBusReg->pfnIORegionRegisterHC;
    2440     pPciBus->pfnSetIrqR3            = pPciBusReg->pfnSetIrqHC;
    2441     pPciBus->pfnSaveExecR3          = pPciBusReg->pfnSaveExecHC;
    2442     pPciBus->pfnLoadExecR3          = pPciBusReg->pfnLoadExecHC;
    2443     pPciBus->pfnFakePCIBIOSR3       = pPciBusReg->pfnFakePCIBIOSHC;
     2479    pPciBus->iBus                    = iBus;
     2480    pPciBus->pDevInsR3               = pDevIns;
     2481    pPciBus->pfnRegisterR3           = pPciBusReg->pfnRegisterHC;
     2482    pPciBus->pfnIORegionRegisterR3   = pPciBusReg->pfnIORegionRegisterHC;
     2483    pPciBus->pfnSetConfigCallbacksR3 = pPciBusReg->pfnSetConfigCallbacksHC;
     2484    pPciBus->pfnSetIrqR3             = pPciBusReg->pfnSetIrqHC;
     2485    pPciBus->pfnSaveExecR3           = pPciBusReg->pfnSaveExecHC;
     2486    pPciBus->pfnLoadExecR3           = pPciBusReg->pfnLoadExecHC;
     2487    pPciBus->pfnFakePCIBIOSR3        = pPciBusReg->pfnFakePCIBIOSHC;
    24442488
    24452489    Log(("PDM: Registered PCI bus device '%s'/%d pDevIns=%p\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pDevIns));
  • trunk/src/VBox/VMM/PDMInternal.h

    r2565 r2597  
    362362    DECLR3CALLBACKMEMBER(int,       pfnIORegionRegisterR3,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, int iRegion, uint32_t cbRegion,
    363363                                                           PCIADDRESSSPACE enmType, PFNPCIIOREGIONMAP pfnCallback));
     364    /** @copydoc PDMPCIBUSREG::pfnSetConfigCallbacksHC */
     365    DECLR3CALLBACKMEMBER(void,      pfnSetConfigCallbacksR3,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, PFNPCICONFIGREAD pfnRead,
     366                                                             PPFNPCICONFIGREAD ppfnReadOld, PFNPCICONFIGWRITE pfnWrite, PPFNPCICONFIGWRITE ppfnWriteOld));
    364367    /** @copydoc PDMPCIBUSREG::pfnSaveExecHC */
    365368    DECLR3CALLBACKMEMBER(int,       pfnSaveExecR3,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, PSSMHANDLE pSSMHandle));
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