VirtualBox

Changeset 35676 in vbox for trunk


Ignore:
Timestamp:
Jan 24, 2011 2:24:34 PM (14 years ago)
Author:
vboxsync
Message:

Main, VMM: PCI passthrough work

Location:
trunk
Files:
19 edited

Legend:

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

    r35358 r35676  
    984984    return (pDev->Int.s.uFlags & PCIDEV_FLAG_MSIX_CAPABLE) != 0;
    985985}
     986
     987DECLINLINE(void) PCISetPassthrough(PPCIDEVICE pDev)
     988{
     989    pDev->Int.s.uFlags |= PCIDEV_FLAG_PASSTHROUGH;
     990}
     991
     992DECLINLINE(void) PCIClearPassthrough(PPCIDEVICE pDev)
     993{
     994    pDev->Int.s.uFlags &= ~PCIDEV_FLAG_PASSTHROUGH;
     995}
     996
     997DECLINLINE(bool) PCIIsPassthrough(PPCIDEVICE pDev)
     998{
     999    return (pDev->Int.s.uFlags & PCIDEV_FLAG_PASSTHROUGH) != 0;
     1000}
    9861001#endif
    9871002
     
    10711086    }
    10721087
    1073     void fromLong(int32_t value)
     1088    PciBusAddress& fromLong(int32_t value)
    10741089    {
    10751090        iBus = (value >> 8) & 0xff;
    10761091        iDevice = (value & 0xff) >> 3;
    10771092        iFn = (value & 7);
     1093        return *this;
    10781094    }
    10791095};
  • trunk/include/VBox/vmm/pdmdev.h

    r35361 r35676  
    18221822#define PDM_HPETHLPR3_VERSION                   PDM_VERSION_MAKE(0xffec, 2, 0)
    18231823
    1824 
     1824typedef struct PDMPCIRAWREG
     1825{
     1826    /** Struct version+magic number (PDM_PCIRAWREG_VERSION). */
     1827     uint32_t            u32Version;
     1828} PDMPCIRAWREG;
     1829
     1830/** Pointer to a raw PCI registration structure. */
     1831typedef PDMPCIRAWREG *PPDMPCIRAWREG;
     1832/** Current PDMPCIRAWREG version number. */
     1833#define PDM_PCIRAWREG_VERSION                     PDM_VERSION_MAKE(0xffe3, 1, 0)
     1834struct PDMPCIRAWHLPRC
     1835{
     1836    uint32_t u32Version;
     1837    /** Just a safety precaution. */
     1838    uint32_t u32TheEnd;
     1839};
     1840typedef RCPTRTYPE(PDMPCIRAWHLPRC *) PPDMPCIRAWHLPRC;
     1841typedef RCPTRTYPE(const PDMPCIRAWHLPRC *) PCPDMPCIRAWHLPRC;
     1842
     1843struct PDMPCIRAWHLPR0
     1844{
     1845uint32_t u32Version;
     1846/** Just a safety precaution. */
     1847uint32_t u32TheEnd;
     1848};
     1849typedef R0PTRTYPE(PDMPCIRAWHLPR0 *) PPDMPCIRAWHLPR0;
     1850typedef R0PTRTYPE(const PDMPCIRAWHLPR0 *) PCPDMPCIRAWHLPR0;
     1851
     1852
     1853typedef struct PDMPCIRAWHLPR3
     1854{
     1855uint32_t u32Version;
     1856/**
     1857* Gets the address of the RC PCI raw helpers.
     1858*
     1859* This should be called at both construction and relocation time
     1860* to obtain the correct address of the RC helpers.
     1861*
     1862* @returns RC pointer to the PCI raw helpers.
     1863* @param   pDevIns         Device instance of the raw PCI device.
     1864*/
     1865DECLR3CALLBACKMEMBER(PCPDMPCIRAWHLPRC, pfnGetRCHelpers,(PPDMDEVINS pDevIns));
     1866
     1867/**
     1868* Gets the address of the R0 PCI raw helpers.
     1869*
     1870* This should be called at both construction and relocation time
     1871* to obtain the correct address of the R0 helpers.
     1872*
     1873* @returns R0 pointer to the PCI raw helpers.
     1874* @param   pDevIns         Device instance of the raw PCI device.
     1875*/
     1876DECLR3CALLBACKMEMBER(PCPDMPCIRAWHLPR0, pfnGetR0Helpers,(PPDMDEVINS pDevIns));
     1877
     1878/** Just a safety precaution. */
     1879uint32_t                u32TheEnd;
     1880} PDMPCIRAWHLPR3;
     1881/** Pointer to raw PCI R3 helpers. */
     1882typedef R3PTRTYPE(PDMPCIRAWHLPR3 *) PPDMPCIRAWHLPR3;
     1883/** Pointer to const raw PCI R3 helpers. */
     1884typedef R3PTRTYPE(const PDMPCIRAWHLPR3 *) PCPDMPCIRAWHLPR3;
     1885
     1886/** Current PDMPCIRAWHLPRC version number. */
     1887#define PDM_PCIRAWHLPRC_VERSION                   PDM_VERSION_MAKE(0xfff0, 1, 0)
     1888/** Current PDMPCIRAWHLPR0 version number. */
     1889#define PDM_PCIRAWHLPR0_VERSION                   PDM_VERSION_MAKE(0xfff1, 1, 0)
     1890/** Current PDMPCIRAWHLPR3 version number. */
     1891#define PDM_PCIRAWHLPR3_VERSION                   PDM_VERSION_MAKE(0xfff2, 1, 0)
    18251892
    18261893#ifdef IN_RING3
     
    29212988     */
    29222989    DECLR3CALLBACKMEMBER(int, pfnHPETRegister,(PPDMDEVINS pDevIns, PPDMHPETREG pHpetReg, PCPDMHPETHLPR3 *ppHpetHlpR3));
     2990
     2991    /**
     2992     * Register the raw PCI device.
     2993     *
     2994     * @returns VBox status code.
     2995     * @param   pDevIns             The device instance.
     2996     * @param   pHpetReg            Pointer to a raw PCI registration structure.
     2997     * @param   ppHpetHlpR3         Where to store the pointer to the raw PCI
     2998     *                              helpers.
     2999     */
     3000    DECLR3CALLBACKMEMBER(int, pfnPciRawRegister,(PPDMDEVINS pDevIns, PPDMPCIRAWREG pPciRawReg, PCPDMPCIRAWHLPR3 *ppPciRawHlpR3));
    29233001
    29243002    /**
     
    44554533}
    44564534
     4535/**
     4536 * @copydoc PDMDEVHLPR3::pfnPciRawRegister
     4537 */
     4538DECLINLINE(int) PDMDevHlpPciRawRegister(PPDMDEVINS pDevIns, PPDMPCIRAWREG pPciRawReg, PCPDMPCIRAWHLPR3 *ppPciRawHlpR3)
     4539{
     4540    return pDevIns->pHlpR3->pfnPciRawRegister(pDevIns, pPciRawReg, ppPciRawHlpR3);
     4541}
     4542
    44574543/**
    44584544 * @copydoc PDMDEVHLPR3::pfnDMACRegister
  • trunk/include/VBox/vmm/pdmdrv.h

    r35361 r35676  
    338338/** SCSI driver. */
    339339#define PDM_DRVREG_CLASS_SCSI           RT_BIT(15)
     340/** Generic raw PCI device driver. */
     341#define PDM_DRVREG_CLASS_PCIRAW         RT_BIT(16)
    340342/** @} */
    341343
  • trunk/src/VBox/Devices/Bus/DevPciIch9.cpp

    r35397 r35676  
    949949static DECLCALLBACK(int) ich9pciGenericSaveExec(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, PSSMHANDLE pSSM)
    950950{
     951    Assert(!PCIIsPassthrough(pPciDev));
    951952    return SSMR3PutMem(pSSM, &pPciDev->config[0], sizeof(pPciDev->config));
    952953}
     
    12011202     */
    12021203    uint8_t const fBridge = fIsBridge ? 2 : 1;
     1204    Assert(!PCIIsPassthrough(pDev));
    12031205    uint8_t *pbDstConfig = &pDev->config[0];
     1206
    12041207    for (uint32_t i = 0; i < RT_ELEMENTS(s_aFields); i++)
    12051208        if (s_aFields[i].fBridge & fBridge)
     
    13951398
    13961399        /* commit the loaded device config. */
     1400        Assert(!PCIIsPassthrough(pDev));
    13971401        pciR3CommonRestoreConfig(pDev, &DevTmp.config[0], false ); /** @todo fix bridge fun! */
    13981402
     
    14261430static DECLCALLBACK(int) ich9pciGenericLoadExec(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, PSSMHANDLE pSSM)
    14271431{
     1432    Assert(!PCIIsPassthrough(pPciDev));
    14281433    return SSMR3GetMem(pSSM, &pPciDev->config[0], sizeof(pPciDev->config));
    14291434}
     
    17511756    }
    17521757
     1758    AssertMsgReturn(u32Address + len <= 256, ("Read after end of PCI config space\n"),
     1759                    0);
    17531760    if (   PCIIsMsiCapable(aDev)
    17541761        && (u32Address >= aDev->Int.s.u8MsiCapOffset)
     
    21462153        if (pPciDev != NULL)
    21472154        {
     2155            if (PCIIsPassthrough(pPciDev))
     2156            {
     2157                printIndent(pHlp, iIndent);
     2158                /**
     2159                 * For passthrough devices MSI/MSI-X mostly reflects the way interrupts delivered to the guest,
     2160                 * as host driver handles real devices interrupts.
     2161                 */
     2162                pHlp->pfnPrintf(pHlp, "%02x:%02x:%02x %s: %s%s - PASSTHROUGH\n",
     2163                                pBus->iBus, (iDev >> 3) & 0xff, iDev & 0x7,
     2164                                pPciDev->name,
     2165                                PCIIsMsiCapable(pPciDev)  ? " MSI" : "",
     2166                                PCIIsMsixCapable(pPciDev) ? " MSI-X" : ""
     2167                                );
     2168                continue;
     2169            }
    21482170            printIndent(pHlp, iIndent);
    21492171            pHlp->pfnPrintf(pHlp, "%02x:%02x:%02x %s: %04x-%04x%s%s",
  • trunk/src/VBox/Devices/Bus/DevPciRaw.cpp

    r35358 r35676  
    2020*******************************************************************************/
    2121#define LOG_GROUP LOG_GROUP_DEV_PCI
     22#include <VBox/log.h>
     23#define PCI_INCLUDE_PRIVATE
     24#include <VBox/pci.h>
    2225#include <VBox/vmm/pdmdev.h>
    2326#include <VBox/log.h>
    2427#include <VBox/vmm/stam.h>
     28#include <VBox/vmm/pdmpci.h>
    2529#include <iprt/assert.h>
    2630#include <iprt/string.h>
     31#include <iprt/uuid.h>
    2732
    2833#include "VBoxDD.h"
     
    3843 *******************************************************************************/
    3944
    40 /* Temporary PDM stubs */
    41 typedef struct PDMPCIRAWREG
    42 {
    43     /** Struct version+magic number (PDM_PCIRAWREG_VERSION). */
    44     uint32_t            u32Version;
    45 
    46 } PDMPCIRAWREG;
    47 /** Pointer to a raw PCI registration structure. */
    48 typedef PDMPCIRAWREG *PPDMPCIRAWREG;
    49 
    50 /** Current PDMPCIRAWREG version number. */
    51 #define PDM_PCIRAWREG_VERSION                     PDM_VERSION_MAKE(0xffe3, 1, 0)
    52 
    53 struct PDMPCIRAWHLPRC
    54 {
    55     uint32_t u32Version;
    56 };
    57 typedef RCPTRTYPE(PDMPCIRAWHLPRC *) PPDMPCIRAWHLPRC;
    58 typedef RCPTRTYPE(const PDMPCIRAWHLPRC *) PCPDMPCIRAWHLPRC;
    59 
    60 struct PDMPCIRAWHLPR0
    61 {
    62     uint32_t u32Version;
    63 };
    64 typedef R0PTRTYPE(PDMPCIRAWHLPR0 *) PPDMPCIRAWHLPR0;
    65 typedef R0PTRTYPE(const PDMPCIRAWHLPR0 *) PCPDMPCIRAWHLPR0;
    66 
    67 struct PDMPCIRAWHLPR3
    68 {
    69     uint32_t u32Version;
    70     /**
    71      * Gets the address of the RC PCI raw helpers.
    72      *
    73      * This should be called at both construction and relocation time
    74      * to obtain the correct address of the RC helpers.
    75      *
    76      * @returns RC pointer to the PCI raw helpers.
    77      * @param   pDevIns         Device instance of the raw PCI device.
    78      */
    79     DECLR3CALLBACKMEMBER(PCPDMPCIRAWHLPRC, pfnGetRCHelpers,(PPDMDEVINS pDevIns));
    80 
    81     /**
    82      * Gets the address of the R0 PCI raw helpers.
    83      *
    84      * This should be called at both construction and relocation time
    85      * to obtain the correct address of the R0 helpers.
    86      *
    87      * @returns R0 pointer to the PCI raw helpers.
    88      * @param   pDevIns         Device instance of the raw PCI device.
    89      */
    90     DECLR3CALLBACKMEMBER(PCPDMPCIRAWHLPR0, pfnGetR0Helpers,(PPDMDEVINS pDevIns));
    91 
    92     /** Just a safety precaution. */
    93     uint32_t                u32TheEnd;
    94 };
    95 /** Pointer to raw PCI R3 helpers. */
    96 typedef R3PTRTYPE(PDMPCIRAWHLPR3 *) PPDMPCIRAWHLPR3;
    97 /** Pointer to const raw PCI R3 helpers. */
    98 typedef R3PTRTYPE(const PDMPCIRAWHLPR3 *) PCPDMPCIRAWHLPR3;
    99 
    100 /**
    101  * @copydoc PDMDEVHLPR3::pfnPciRawRegister
    102  */
    103 DECLINLINE(int) PDMDevHlpPciRawRegister(PPDMDEVINS pDevIns, PPDMPCIRAWREG pPciRawReg, PCPDMPCIRAWHLPR3 *ppPciRawHlpR3)
    104 {
    105     //return pDevIns->pHlpR3->pfnPciRawRegister(pDevIns, pPciRawReg, ppPciRawHlpR3);
    106     return VINF_SUCCESS;
    107 }
    108 
    109 /* End of PDM stubs */
    110 
    11145typedef struct PciRawState
    11246{
     
    12963    PCIDEVICE            aPciDevice;
    13064
     65    /* Device name, as provided by Main */
     66    char                 szDeviceName[64];
     67
    13168    /* Address of device on the host */
    132     PciBusAddress        aHostDeviceAddress;
     69    int32_t              i32HostDeviceAddress;
    13370    /* Address of device in the guest */
    134     PciBusAddress        aGuestDeviceAddress;
     71    int32_t              i32GuestDeviceAddress;
    13572
    13673    /* Global device lock */
    13774    PDMCRITSECT          csLock;
     75    /**
     76     * Device port - LUN#0.
     77     *
     78     * @implements  PDMIBASE
     79     * @implements  PDMIPCIRAW
     80     */
     81    struct
     82    {
     83        /** The base interface for the PCI device port. */
     84        PDMIBASE                            IBase;
     85        /** The device port base interface. */
     86        PDMIPCIRAW                          IDevice;
     87
     88        /** The base interface of the attached raw PCI driver. */
     89        R3PTRTYPE(PPDMIBASE)                pDrvBase;
     90        /** The device interface of the attached raw PCI driver. */
     91        R3PTRTYPE(PPDMIPCIRAWCONNECTOR)     pDrv;
     92    } Lun0;
    13893} PciRawState;
    13994
     95
     96/** Pointer to the raw PCI instance data. */
     97typedef PciRawState *PPciRawState;
    14098
    14199#ifndef VBOX_DEVICE_STRUCT_TESTCASE
     
    150108RT_C_DECLS_END
    151109
    152 /*
    153  * Temporary control to disable locking if problems found
    154  */
    155110DECLINLINE(int) pcirawLock(PciRawState* pThis, int rcBusy)
    156111{
     
    331286}
    332287
     288static DECLCALLBACK(int) pcirawAttach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags)
     289{
     290    PciRawState *pThis = PDMINS_2_DATA(pDevIns, PciRawState *);
     291
     292    LogFlow(("pcirawAttach: LUN%d\n", iLUN));
     293    /* Not yet used */
     294    return 0;
     295}
     296
     297static DECLCALLBACK(void) pcirawDetach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags)
     298{
     299    PciRawState *pThis = PDMINS_2_DATA(pDevIns, PciRawState *);
     300
     301    LogFlow(("pcirawDetach: LUN%d\n", iLUN));
     302    /* Not yet used */
     303}
     304
    333305/**
    334306 * Initialization routine.
     
    337309 * @param   pDevIns     The device instance data.
    338310 */
    339 static int pcirawInit(PPDMDEVINS pDevIns, PciBusAddress hostAddress)
     311static int pcirawInit(PPDMDEVINS pDevIns, PciBusAddress hostAddress, PciBusAddress guestAddress)
    340312{
    341313    unsigned   i;
     
    349321    pThis->pDevInsRC  = PDMDEVINS_2_RCPTR(pDevIns);
    350322
    351     pThis->aHostDeviceAddress.init(hostAddress);
     323    pThis->i32HostDeviceAddress = hostAddress.asLong();
     324    pThis->i32GuestDeviceAddress = guestAddress.asLong();
    352325
    353326    pcirawReset(pDevIns);
    354327
    355328    return VINF_SUCCESS;
     329}
     330static uint32_t pcirawConfigRead(PPCIDEVICE pPciDev, uint32_t Address, unsigned cb)
     331{
     332    PPDMDEVINS pDevIns = pPciDev->pDevIns;
     333    PciRawState*  pThis = PDMINS_2_DATA(pDevIns, PciRawState *);
     334
     335    Log2(("rawpci: PCI config read: 0x%x (%d)\n", Address, cb));
     336
     337    return 0;
     338}
     339
     340static void pcirawConfigWrite(PPCIDEVICE pPciDev, uint32_t Address, uint32_t u32Value, unsigned cb)
     341{
     342    PPDMDEVINS  pDevIns = pPciDev->pDevIns;
     343    PciRawState  *pThis = PDMINS_2_DATA(pDevIns, PciRawState *);
     344
     345    Log2(("rawpci: PCI config write: 0x%x -> 0x%x (%d)\n", u32Value, Address, cb));
     346}
     347
     348
     349/**
     350 * @interface_method_impl{PDMIBASE,pfnQueryInterface}
     351 */
     352static DECLCALLBACK(void *) pcirawQueryInterface(PPDMIBASE pInterface, const char *pszIID)
     353{
     354    PciRawState* pThis = RT_FROM_CPP_MEMBER(pInterface, PciRawState, Lun0.IBase);
     355    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE,   &pThis->Lun0.IBase);
     356    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIPCIRAW, &pThis->Lun0.IDevice);
     357    return NULL;
     358}
     359
     360static DECLCALLBACK(int) pcirawFoo(PPDMIPCIRAW pInterface)
     361{
     362    return 0;
     363
    356364}
    357365
     
    373381                              "GCEnabled\0"
    374382                              "R0Enabled\0"
     383                              "DeviceName\0"
     384                              "GuestPCIBusNo\0"
     385                              "GuestPCIDeviceNo\0"
     386                              "GuestPCIFunctionNo\0"
    375387                              "HostPCIBusNo\0"
    376388                              "HostPCIDeviceNo\0"
     
    390402                                N_("Configuration error: failed to read R0Enabled as boolean"));
    391403
    392     /* Obtain host device address */
    393     uint32_t u32Bus, u32Device, u32Fn;
    394     rc = CFGMR3QueryU32(pCfg, "HostPCIBusNo", &u32Bus);
     404
     405    rc = CFGMR3QueryString(pCfg, "DeviceName", pThis->szDeviceName, sizeof(pThis->szDeviceName));
    395406    if (RT_FAILURE(rc))
    396407        return PDMDEV_SET_ERROR(pDevIns, rc,
    397                                 N_("Configuration error: Querying \"HostPCIBusNo\" as a int failed"));
    398     rc = CFGMR3QueryU32(pCfg, "HostPCIDeviceNo", &u32Device);
    399     if (RT_FAILURE(rc))
    400         return PDMDEV_SET_ERROR(pDevIns, rc,
    401                                 N_("Configuration error: Querying \"HostPCIDeviceNo\" as a int failed"));
    402     rc = CFGMR3QueryU32(pCfg, "HostPCIFunctionNo", &u32Fn);
    403     if (RT_FAILURE(rc))
    404         return PDMDEV_SET_ERROR(pDevIns, rc,
    405                                 N_("Configuration error: Querying \"HostPCIFunctionNo\" as a int failed"));
    406 
    407 
    408     /* Initialize the device state */
    409     rc = pcirawInit(pDevIns, PciBusAddress(u32Bus, u32Device, u32Fn));
    410     if (RT_FAILURE(rc))
    411         return rc;
    412 
    413     pThis->pDevInsR3 = pDevIns;
    414     pThis->pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns);
    415     pThis->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);
    416 
    417     /*
    418      * Register the raw device and get helpers.
    419      */
    420     PciRawReg.u32Version  = PDM_PCIRAWREG_VERSION;
    421     rc = PDMDevHlpPciRawRegister(pDevIns, &PciRawReg, &pThis->pPciRawHlpR3);
    422     if (RT_FAILURE(rc))
    423     {
    424         AssertMsgRC(rc, ("Cannot PciRawRegister: %Rrc\n", rc));
    425         return rc;
    426     }
    427 
    428     /*
    429      * Initialize critical section.
    430      */
    431     rc = PDMDevHlpCritSectInit(pDevIns, &pThis->csLock, RT_SRC_POS, "PCIRAW");
    432     if (RT_FAILURE(rc))
    433         return PDMDEV_SET_ERROR(pDevIns, rc, N_("Raw PCI device cannot initialize critical section"));
    434 
    435 #if 0
    436     /*
    437      * Register IO/MMIO ranges for guest, basing on real device ranges.
    438      */
    439     for (int iRegion = 0; iRegion < VBOX_PCI_NUM_REGIONS; iRegion++)
    440     {
    441 
    442     }
    443 #endif
    444 
    445     if (fRCEnabled)
    446     {
    447         pThis->pPciRawHlpRC = pThis->pPciRawHlpR3->pfnGetRCHelpers(pDevIns);
    448         if (!pThis->pPciRawHlpRC)
    449         {
    450             AssertReleaseMsgFailed(("cannot get RC helper\n"));
    451             return VERR_INTERNAL_ERROR;
    452         }
    453     }
    454     if (fR0Enabled)
    455     {
    456         pThis->pPciRawHlpR0 = pThis->pPciRawHlpR3->pfnGetR0Helpers(pDevIns);
    457         if (!pThis->pPciRawHlpR0)
    458         {
    459             AssertReleaseMsgFailed(("cannot get R0 helper\n"));
    460             return VERR_INTERNAL_ERROR;
    461         }
    462     }
    463 
    464     /* Register SSM callbacks */
    465     rc = PDMDevHlpSSMRegister3(pDevIns, PCIRAW_SAVED_STATE_VERSION, sizeof(*pThis), pcirawLiveExec, pcirawSaveExec, pcirawLoadExec);
    466     if (RT_FAILURE(rc))
    467         return rc;
    468 
    469     return VINF_SUCCESS;
     408                                N_("Configuration error: failed to read DeviceName as string"));
     409
     410    PciBusAddress hostAddress, guestAddress;
     411
     412    /* Obtain device address info */
     413    uint32_t u32Bus, u32Device, u32Fn;
     414
     415    do {
     416        rc = CFGMR3QueryU32(pCfg, "HostPCIBusNo", &u32Bus);
     417        if (RT_FAILURE(rc))
     418        {
     419            PDMDEV_SET_ERROR(pDevIns, rc,
     420                             N_("Configuration error: Querying \"HostPCIBusNo\" as a int failed"));
     421            break;
     422        }
     423        rc = CFGMR3QueryU32(pCfg, "HostPCIDeviceNo", &u32Device);
     424        if (RT_FAILURE(rc))
     425        {
     426            PDMDEV_SET_ERROR(pDevIns, rc,
     427                             N_("Configuration error: Querying \"HostPCIDeviceNo\" as a int failed"));
     428            break;
     429        }
     430        rc = CFGMR3QueryU32(pCfg, "HostPCIFunctionNo", &u32Fn);
     431        if (RT_FAILURE(rc))
     432        {
     433            PDMDEV_SET_ERROR(pDevIns, rc,
     434                             N_("Configuration error: Querying \"HostPCIFunctionNo\" as a int failed"));
     435            break;
     436        }
     437        hostAddress = PciBusAddress(u32Bus, u32Device, u32Fn);
     438
     439        rc = CFGMR3QueryU32(pCfg, "GuestPCIBusNo", &u32Bus);
     440        if (RT_FAILURE(rc))
     441        {
     442            PDMDEV_SET_ERROR(pDevIns, rc,
     443                             N_("Configuration error: Querying \"GuestPCIBusNo\" as a int failed"));
     444            break;
     445        }
     446        rc = CFGMR3QueryU32(pCfg, "GuestPCIDeviceNo", &u32Device);
     447        if (RT_FAILURE(rc))
     448        {
     449            PDMDEV_SET_ERROR(pDevIns, rc,
     450                             N_("Configuration error: Querying \"GuestPCIDeviceNo\" as a int failed"));
     451            break;
     452        }
     453        rc = CFGMR3QueryU32(pCfg, "GuestPCIFunctionNo", &u32Fn);
     454        if (RT_FAILURE(rc))
     455        {
     456            PDMDEV_SET_ERROR(pDevIns, rc,
     457                         N_("Configuration error: Querying \"GuestPCIFunctionNo\" as a int failed"));
     458            break;
     459        }
     460        guestAddress = PciBusAddress(u32Bus, u32Device, u32Fn);
     461
     462        /* Initialize the device state */
     463        rc = pcirawInit(pDevIns, hostAddress, guestAddress);
     464        if (RT_FAILURE(rc))
     465            break;
     466
     467        pThis->pDevInsR3 = pDevIns;
     468        pThis->pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns);
     469        pThis->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);
     470
     471        /*
     472         * Register the raw device and get helpers.
     473         */
     474        PciRawReg.u32Version  = PDM_PCIRAWREG_VERSION;
     475        rc = PDMDevHlpPciRawRegister(pDevIns, &PciRawReg, &pThis->pPciRawHlpR3);
     476        if (RT_FAILURE(rc))
     477        {
     478            AssertMsgRC(rc, ("Cannot PciRawRegister: %Rrc\n", rc));
     479            break;
     480        }
     481
     482        /*
     483         * Initialize critical section.
     484         */
     485        rc = PDMDevHlpCritSectInit(pDevIns, &pThis->csLock, RT_SRC_POS, "PCIRAW");
     486        if (RT_FAILURE(rc))
     487        {
     488            PDMDEV_SET_ERROR(pDevIns, rc, N_("Raw PCI device cannot initialize critical section"));
     489            break;
     490        }
     491
     492        /* Mark device as passthrough */
     493        PCISetPassthrough(&pThis->aPciDevice);
     494
     495        /* IBase */
     496        pThis->Lun0.IBase.pfnQueryInterface = pcirawQueryInterface;
     497        pThis->Lun0.IDevice.pfnFoo          = pcirawFoo;
     498
     499        /*
     500         * Attach to the Main driver.
     501         */
     502        rc = pDevIns->pHlpR3->pfnDriverAttach(pDevIns, 0/*iLun*/, &pThis->Lun0.IBase, &pThis->Lun0.pDrvBase, "Device Port");
     503        if (RT_FAILURE(rc))
     504        {
     505            rc = PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS, N_("Raw PCI failed to attach Main driver"));
     506            break;
     507        }
     508
     509        pThis->Lun0.pDrv = PDMIBASE_QUERY_INTERFACE(pThis->Lun0.pDrvBase, PDMIPCIRAWCONNECTOR);
     510        if (!pThis->Lun0.pDrv)
     511        {
     512            rc = PDMDevHlpVMSetError(pDevIns, VERR_PDM_MISSING_INTERFACE, RT_SRC_POS, N_("Raw PCI failed to query interface"));
     513            break;
     514        }
     515
     516        /* Just a safety measure, this data shall never be reached */
     517        PCIDevSetVendorId(&pThis->aPciDevice, 0xdead);
     518        PCIDevSetDeviceId(&pThis->aPciDevice, 0xbeef);
     519
     520        rc = PDMDevHlpPCIRegister(pDevIns, &pThis->aPciDevice);
     521        if (RT_FAILURE(rc))
     522            break;
     523
     524        PDMDevHlpPCISetConfigCallbacks(pDevIns, &pThis->aPciDevice,
     525                                       pcirawConfigRead,  NULL /* we don't care about old ones */,
     526                                       pcirawConfigWrite, NULL /* we don't care about old ones */);
     527
     528        /*
     529         * Register IO/MMIO ranges for the guest, basing on real device ranges.
     530         */
     531        for (int iRegion = 0; iRegion < VBOX_PCI_NUM_REGIONS; iRegion++)
     532        {
     533            RTHCPHYS RegStart;
     534            uint64_t iRegSize;
     535            bool     fMmio;
     536
     537            if (pThis->Lun0.pDrv->pfnGetRegionInfo(pThis->Lun0.pDrv, hostAddress.asLong(), iRegion,
     538                                                   &RegStart, &iRegSize, &fMmio))
     539            {
     540                /* If region is present, register callbacks in guest.
     541                   @todo: replace it with direct region access with remap */
     542                // @todo: check if host's PA make sense for the guest
     543                if (fMmio)
     544                {
     545                    rc = PDMDevHlpMMIORegister(pDevIns, RegStart, iRegSize, NULL,
     546                                               pcirawMMIOWrite, pcirawMMIORead, NULL,
     547                                               "Raw PCI MMIO regions");
     548                    if (RT_FAILURE(rc))
     549                    {
     550                        AssertMsgRC(rc, ("Cannot register MMIO: %Rrc\n", rc));
     551                        break;
     552                    }
     553                }
     554                else
     555                {
     556                    rc = PDMDevHlpIOPortRegister(pDevIns, (RTIOPORT)RegStart, iRegSize, NULL,
     557                                                 pcirawIOPortWrite, pcirawIOPortRead, NULL, NULL,
     558                                                 "Raw PCI IO regions");
     559                    if (RT_FAILURE(rc))
     560                    {
     561                        AssertMsgRC(rc, ("Cannot register IO: %Rrc\n", rc));
     562                        break;
     563                    }
     564                }
     565            }
     566        }
     567
     568        if (RT_FAILURE(rc))
     569            break;
     570
     571        if (fRCEnabled)
     572        {
     573            pThis->pPciRawHlpRC = pThis->pPciRawHlpR3->pfnGetRCHelpers(pDevIns);
     574            if (!pThis->pPciRawHlpRC)
     575            {
     576                AssertReleaseMsgFailed(("cannot get RC helper\n"));
     577                rc = VERR_INTERNAL_ERROR;
     578                break;
     579            }
     580        }
     581
     582        if (fR0Enabled)
     583        {
     584            pThis->pPciRawHlpR0 = pThis->pPciRawHlpR3->pfnGetR0Helpers(pDevIns);
     585            if (!pThis->pPciRawHlpR0)
     586            {
     587                AssertReleaseMsgFailed(("cannot get R0 helper\n"));
     588                rc = VERR_INTERNAL_ERROR;
     589                break;
     590            }
     591        }
     592
     593        /* Register SSM callbacks */
     594        rc = PDMDevHlpSSMRegister3(pDevIns, PCIRAW_SAVED_STATE_VERSION, sizeof(*pThis), pcirawLiveExec, pcirawSaveExec, pcirawLoadExec);
     595        if (RT_FAILURE(rc))
     596            break;
     597    } while (0);
     598
     599    /* Notify Main about result of PCI device attach attempt */
     600    if (pThis->Lun0.pDrv != NULL)
     601        pThis->Lun0.pDrv->pfnPciDeviceConstructComplete(pThis->Lun0.pDrv, hostAddress.asLong(), guestAddress.asLong(),
     602                                                        rc, pThis->szDeviceName);
     603
     604    return rc;
    470605}
    471606
  • trunk/src/VBox/Devices/Bus/PCIInternal.h

    r35358 r35676  
    8787    /** Flag whether the device is capable of MSI-X.
    8888     * This one is set by MsixInit().  */
    89     PCIDEV_FLAG_MSIX_CAPABLE       = 1<<4
     89    PCIDEV_FLAG_MSIX_CAPABLE       = 1<<4,
     90    /** Flag if device represents real physical device in passthrough mode. */
     91    PCIDEV_FLAG_PASSTHROUGH        = 1<<5
    9092};
    9193
  • trunk/src/VBox/Devices/Makefile.kmk

    r35572 r35676  
    517517 Bus/DevPCI.cpp_INCS      = Bus
    518518 Bus/DevPciIch9.cpp_INCS  = Bus
    519  Bus/MsiCommon.cpp_INCS  = Bus
     519 Bus/MsiCommon.cpp_INCS   = Bus
    520520 Bus/MsixCommon.cpp_INCS  = Bus
     521 Bus/DevPciRaw.cpp_INCS   = Bus
    521522
    522523 # For finding and generating vbetables.h (see Graphics/BIOS/Makefile.kmk).
  • trunk/src/VBox/Main/Makefile.kmk

    r35498 r35676  
    637637        src-client/AudioSnifferInterface.cpp \
    638638        src-client/BusAssignmentManager.cpp \
     639        src-client/PciRawDevImpl.cpp \
    639640        src-client/ConsoleImpl.cpp \
    640641        src-client/ConsoleImpl2.cpp \
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r35602 r35676  
    34223422
    34233423  <interface
    3424     name="IEventContext" extends="$unknown"
    3425     uuid="7563F4E7-1583-40F7-B4C4-C9BA02CB0AE3"
    3426     wsmap="managed"
    3427     >
    3428     <desc>
    3429       Placeholder class for event contexts.
    3430     </desc>
    3431   </interface>
    3432 
    3433 
    3434   <interface
    34353424    name="IPciAddress" extends="$unknown"
    34363425    uuid="D88B324F-DB19-4D3B-A1A9-BF5B127199A8"
     
    47434732        <desc>Desired position of this device on guest PCI bus.</desc>
    47444733      </param>
    4745       <param name="eventContext" type="IEventContext" dir="in">
    4746         <desc>Context passed into IHostPciDevicePlugEvent event.</desc>
    4747       </param>
    47484734      <param name="tryToUnbind" type="boolean" dir="in">
    47494735        <desc>If VMM shall try to unbind existing drivers from the
     
    47564742        Detach host PCI device from the virtual machine.
    47574743        Also HostPciDevicePlugEvent on IVirtualBox event source
    4758         will be delivered.
     4744        will be delivered. As currently we don't support hot device
     4745        unplug, IHostPciDevicePlugEvent event is delivered immediately.
    47594746
    47604747        <note>
     
    1664416631    name="IHostPciDevicePlugEvent" extends="IMachineEvent"
    1664516632    waitable="yes"
    16646     uuid="EDD4782B-DB74-43A0-B724-2BAA36F039CC"
     16633    uuid="9cebfc27-c579-4965-8eb7-d31794cd7dcf"
    1664716634    wsmap="managed" autogen="VBoxEvent" id="OnHostPciDevicePlug"
    1664816635    >
    1664916636    <desc>
    16650       Notification when host PCI device is plugged/unplugged.
     16637      Notification when host PCI device is plugged/unplugged. Plugging
     16638      usually takes place on VM startup, unplug - when
     16639      IMachine::DetachHostPciDevice is called.
     16640
     16641      <see>IMachine::DetachHostPciDevice</see>
     16642
    1665116643    </desc>
    1665216644
    1665316645    <attribute name="plugged" type="boolean" readonly="yes">
    1665416646      <desc>
    16655         If device successfully plugged or unplugged.
     16647      If device successfully plugged or unplugged.
    1665616648      </desc>
    1665716649    </attribute>
     
    1666716659      <desc>
    1666816660        Attachment info for this device.
    16669       </desc>
    16670     </attribute>
    16671 
    16672     <attribute name="eventContext" type="IEventContext" readonly="yes">
    16673       <desc>
    16674         Context object, passed into attachHostPciDevice() and
    16675         attachHostPciDevice().
    1667616661      </desc>
    1667716662    </attribute>
  • trunk/src/VBox/Main/include/MachineImpl.h

    r35638 r35676  
    291291        BOOL                 mIoCacheEnabled;
    292292        ULONG                mIoCacheSize;
     293
     294        typedef std::list< ComObjPtr<PciDeviceAttachment> > PciDeviceAssignmentList;
     295        PciDeviceAssignmentList mPciDeviceAssignments;
    293296    };
    294297
    295298    /**
    296      *  Hard disk and other media data.
     299   *  Hard disk and other media data.
    297300     *
    298301     *  The usage policy is the same as for HWData, but a separate structure
     
    521524    STDMETHOD(QueryLogFilename(ULONG aIdx, BSTR *aName));
    522525    STDMETHOD(ReadLog(ULONG aIdx, LONG64 aOffset, LONG64 aSize, ComSafeArrayOut(BYTE, aData)));
    523     STDMETHOD(AttachHostPciDevice(LONG hostAddress, LONG desiredGuestAddress, IEventContext *eventContext, BOOL tryToUnbind));
     526    STDMETHOD(AttachHostPciDevice(LONG hostAddress, LONG desiredGuestAddress, BOOL tryToUnbind));
    524527    STDMETHOD(DetachHostPciDevice(LONG hostAddress));
    525528    STDMETHOD(COMGETTER(PciDeviceAssignments))(ComSafeArrayOut(IPciDeviceAttachment *, aAssignments));
     
    868871    typedef std::list< ComObjPtr<StorageController> > StorageControllerList;
    869872    Backupable<StorageControllerList> mStorageControllers;
    870 
    871     typedef std::list< ComObjPtr<PciDeviceAttachment> > PciDeviceAssignmentList;
    872     PciDeviceAssignmentList mPciDeviceAssignments;
    873873
    874874    friend class SessionMachine;
  • trunk/src/VBox/Main/src-client/ConsoleImpl.cpp

    r35638 r35676  
    314314            }
    315315            break;
     316
     317            case VBoxEventType_OnHostPciDevicePlug:
     318            {
     319                // handle if needed
     320                break;
     321            }
     322
    316323            default:
    317                 AssertFailed();
     324              AssertFailed();
    318325        }
    319326        return S_OK;
     
    387394
    388395    uninit();
    389    
     396
    390397    BaseFinalRelease();
    391398}
     
    491498        com::SafeArray<VBoxEventType_T> eventTypes;
    492499        eventTypes.push_back(VBoxEventType_OnNATRedirect);
     500        eventTypes.push_back(VBoxEventType_OnHostPciDevicePlug);
    493501        rc = pES->RegisterListener(mVmListener, ComSafeArrayAsInParam(eventTypes), true);
    494502        AssertComRC(rc);
  • trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp

    r35667 r35676  
    3434#include "VMMDev.h"
    3535#include "Global.h"
     36#include "PciRawDevImpl.h"
    3637
    3738// generated header
     
    454455}
    455456
     457static HRESULT attachRawPciDevices(BusAssignmentManager* BusMgr,
     458                                   PCFGMNODE             pDevices,
     459                                   Console*              pConsole)
     460{
     461    HRESULT hrc = S_OK;
     462    PCFGMNODE pDev, pInst, pCfg, pLunL0;
     463
     464    SafeIfaceArray<IPciDeviceAttachment> assignments;
     465    ComPtr<IMachine> aMachine =  pConsole->machine();
     466
     467    hrc = aMachine->COMGETTER(PciDeviceAssignments)(ComSafeArrayAsOutParam(assignments));
     468    if (hrc != S_OK)
     469        return hrc;
     470
     471    for (size_t iDev = 0; iDev < assignments.size(); iDev++)
     472    {
     473        PciBusAddress HostPciAddress, GuestPciAddress;
     474        ComPtr<IPciDeviceAttachment> assignment = assignments[iDev];
     475        LONG host, guest;
     476        Bstr aDevName;
     477
     478        assignment->COMGETTER(HostAddress)(&host);
     479        assignment->COMGETTER(GuestAddress)(&guest);
     480        assignment->COMGETTER(Name)(aDevName.asOutParam());
     481
     482        InsertConfigNode(pDevices,     "pciraw",  &pDev);
     483        InsertConfigNode(pDev,          Utf8StrFmt("%d", iDev).c_str(), &pInst);
     484        InsertConfigInteger(pInst,     "Trusted", 1);
     485
     486        HostPciAddress.fromLong(host);
     487        Assert(HostPciAddress.valid());
     488        InsertConfigNode(pInst,        "Config",  &pCfg);
     489        InsertConfigString(pCfg,       "DeviceName",  aDevName);
     490
     491        InsertConfigInteger(pCfg,      "HostPCIBusNo",      HostPciAddress.iBus);
     492        InsertConfigInteger(pCfg,      "HostPCIDeviceNo",   HostPciAddress.iDevice);
     493        InsertConfigInteger(pCfg,      "HostPCIFunctionNo", HostPciAddress.iFn);
     494
     495        GuestPciAddress.fromLong(guest);
     496        Assert(GuestPciAddress.valid());
     497        hrc = BusMgr->assignPciDevice("pciraw", pInst, GuestPciAddress, true);
     498        if (hrc != S_OK)
     499            return hrc;
     500        InsertConfigInteger(pCfg,      "GuestPCIBusNo",      GuestPciAddress.iBus);
     501        InsertConfigInteger(pCfg,      "GuestPCIDeviceNo",   GuestPciAddress.iDevice);
     502        InsertConfigInteger(pCfg,      "GuestPCIFunctionNo", GuestPciAddress.iFn);
     503
     504        /* the Main driver */
     505        PciRawDev* pMainDev = new PciRawDev(pConsole);
     506        InsertConfigNode(pInst,        "LUN#0",   &pLunL0);
     507        InsertConfigString(pLunL0,     "Driver",  "PciRawMain");
     508        InsertConfigNode(pLunL0,       "Config" , &pCfg);
     509        InsertConfigInteger(pCfg,      "Object", (uintptr_t)pMainDev);
     510    }
     511
     512    return hrc;
     513}
    456514
    457515/**
     
    921979            InsertConfigInteger(pInst, "Trusted",              1); /* boolean */
    922980            hrc = BusMgr->assignPciDevice("ich9pcibridge", pInst);                               H();
     981
     982            /* Add PCI passthrough devices */
     983            hrc = attachRawPciDevices(BusMgr, pDevices, pConsole);                               H();
    923984        }
    924 
    925         /*
    926          * Enable 3 following devices: HPET, SMC, LPC on MacOS X guests
     985        /*
     986         * Enable 3 following devices: HPET, SMC, LPC on MacOS X guests or on ICH9 chipset
    927987         */
    928988        /*
  • trunk/src/VBox/Main/src-client/GuestCtrlImpl.cpp

    r35540 r35676  
    206206        {
    207207            rc = TaskGuest::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->progress,
    208                                                  Guest::tr("Source file \"%s\" does not exist"),
     208                                                 Guest::tr("Source file \"%s\" does not exist, or is not a file"),
    209209                                                 aTask->strSource.c_str());
    210210        }
     
    25312531#endif /* VBOX_WITH_GUEST_CONTROL */
    25322532}
    2533 
  • trunk/src/VBox/Main/src-client/VBoxDriversRegister.cpp

    r35368 r35676  
    2626#include "AudioSnifferInterface.h"
    2727#include "ConsoleImpl.h"
     28#include "PciRawDevImpl.h"
    2829
    2930#include "Logging.h"
     
    6768    if (RT_FAILURE(rc))
    6869        return rc;
     70
     71    rc = pCallbacks->pfnRegister(pCallbacks, &PciRawDev::DrvReg);
     72    if (RT_FAILURE(rc))
     73        return rc;
     74
    6975    return VINF_SUCCESS;
    7076}
  • trunk/src/VBox/Main/src-server/MachineImpl.cpp

    r35638 r35676  
    5050#include "DisplayUtils.h"
    5151#include "BandwidthControlImpl.h"
     52
     53// generated header
     54#include "VBoxEvents.h"
    5255
    5356#ifdef VBOX_WITH_USB
     
    58125815
    58135816
    5814 STDMETHODIMP Machine::AttachHostPciDevice(LONG hostAddress, LONG desiredGuestAddress, IEventContext * /*eventContext*/, BOOL /*tryToUnbind*/)
    5815 {
    5816     AutoCaller autoCaller(this);
    5817     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    5818     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    5819 
    5820     ComObjPtr<PciDeviceAttachment> pda;
    5821     char name[32];
    5822 
    5823     pda.createObject();
    5824     RTStrPrintf(name, sizeof(name), "host%02x:%02x.%x", (hostAddress>>8) & 0xff, (hostAddress & 0xf8) >> 3, hostAddress & 7);
    5825     Bstr bname(name);
    5826     pda.createObject();
    5827     pda->init(this, bname,  hostAddress, desiredGuestAddress, TRUE);
    5828 
    5829     mPciDeviceAssignments.push_back(pda);
    5830     return S_OK;
    5831 }
    5832 
    5833 STDMETHODIMP Machine::DetachHostPciDevice(LONG /*hostAddress*/)
    5834 {
    5835     AutoCaller autoCaller(this);
    5836     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    5837     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    5838 
    5839     return E_NOTIMPL;
     5817/**
     5818 * Currently this method doesn't attach device to the running VM,
     5819 * just makes sure it's plugged on next VM start.
     5820 */
     5821STDMETHODIMP Machine::AttachHostPciDevice(LONG hostAddress, LONG desiredGuestAddress, BOOL /*tryToUnbind*/)
     5822{
     5823    AutoCaller autoCaller(this);
     5824    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     5825
     5826    // lock scope
     5827    {
     5828        AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     5829
     5830        //HRESULT rc = checkStateDependency(MutableStateDep);
     5831        //if (FAILED(rc)) return rc;
     5832
     5833        ComObjPtr<PciDeviceAttachment> pda;
     5834        char name[32];
     5835
     5836        RTStrPrintf(name, sizeof(name), "host%02x:%02x.%x", (hostAddress>>8) & 0xff, (hostAddress & 0xf8) >> 3, hostAddress & 7);
     5837        Bstr bname(name);
     5838        pda.createObject();
     5839        pda->init(this, bname,  hostAddress, desiredGuestAddress, TRUE);
     5840        setModified(IsModified_MachineData);
     5841        mHWData.backup();
     5842        mHWData->mPciDeviceAssignments.push_back(pda);
     5843    }
     5844
     5845    // do we need it?
     5846    //saveSettings(NULL);
     5847    mHWData.commit();
     5848
     5849    return S_OK;
     5850}
     5851
     5852/**
     5853 * Currently this method doesn't detach device from the running VM,
     5854 * just makes sure it's not plugged on next VM start.
     5855 */
     5856STDMETHODIMP Machine::DetachHostPciDevice(LONG hostAddress)
     5857{
     5858    AutoCaller autoCaller(this);
     5859    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     5860
     5861    ComObjPtr<PciDeviceAttachment> pAttach;
     5862    bool fRemoved = false;
     5863    HRESULT rc;
     5864
     5865    // lock scope
     5866    {
     5867        AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     5868
     5869        rc = checkStateDependency(MutableStateDep);
     5870        if (FAILED(rc)) return rc;
     5871
     5872        for (HWData::PciDeviceAssignmentList::iterator it =  mHWData->mPciDeviceAssignments.begin();
     5873             it !=  mHWData->mPciDeviceAssignments.end();
     5874             ++it)
     5875        {
     5876            LONG iHostAddress = -1;
     5877            pAttach = *it;
     5878            pAttach->COMGETTER(HostAddress)(&iHostAddress);
     5879            if (iHostAddress  != -1  && iHostAddress == hostAddress)
     5880            {
     5881                setModified(IsModified_MachineData);
     5882                mHWData.backup();
     5883                mHWData->mPciDeviceAssignments.remove(pAttach);
     5884                fRemoved = true;
     5885                break;
     5886            }
     5887        }
     5888        // Indeed under lock?
     5889        mHWData.commit();
     5890
     5891        // do we need it?
     5892        // saveSettings(NULL);
     5893    }
     5894
     5895
     5896    /* Fire event outside of the lock */
     5897    if (fRemoved)
     5898    {
     5899        Assert(!pAttach.isNull());
     5900        ComPtr<IEventSource> es;
     5901        rc = mParent->COMGETTER(EventSource)(es.asOutParam());
     5902        Assert(SUCCEEDED(rc));
     5903        Bstr mid;
     5904        rc = this->COMGETTER(Id)(mid.asOutParam());
     5905        Assert(SUCCEEDED(rc));
     5906        fireHostPciDevicePlugEvent(es, mid.raw(), false /* unplugged */, true /* success */, pAttach, NULL);
     5907    }
     5908
     5909    return S_OK;
    58405910}
    58415911
     
    58495919    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    58505920
    5851     SafeIfaceArray<IPciDeviceAttachment> assignments(mPciDeviceAssignments);
     5921    SafeIfaceArray<IPciDeviceAttachment> assignments(mHWData->mPciDeviceAssignments);
    58525922    assignments.detachTo(ComSafeArrayOutArg(aAssignments));
    58535923
     
    61286198        Utf8Str idStr = mData->mUuid.toString();
    61296199        const char * args[] = {szPath, "--comment", mUserData->s.strName.c_str(), "--startvm", idStr.c_str(), 0 };
     6200        fprintf(stderr, "SDL=%s\n",  szPath);
    61306201        vrc = RTProcCreate(szPath, args, env, 0, &pid);
    61316202    }
  • trunk/src/VBox/VMM/VMMR0/PDMR0Device.cpp

    r35358 r35676  
    4848extern DECLEXPORT(const PDMPCIHLPR0)    g_pdmR0PciHlp;
    4949extern DECLEXPORT(const PDMHPETHLPR0)   g_pdmR0HpetHlp;
     50extern DECLEXPORT(const PDMPCIRAWHLPR0) g_pdmR0PciRawHlp;
    5051extern DECLEXPORT(const PDMDRVHLPR0)    g_pdmR0DrvHlp;
    5152RT_C_DECLS_END
     
    680681/** @} */
    681682
    682 
    683 
     683/** @name Raw PCI Ring-0 Helpers
     684 * @{
     685 */
     686/**
     687 * The Ring-0 PCI raw Helper Callbacks.
     688 */
     689extern DECLEXPORT(const PDMPCIRAWHLPR0) g_pdmR0PciRawHlp =
     690{
     691    PDM_PCIRAWHLPR0_VERSION,
     692    PDM_PCIRAWHLPR0_VERSION, /* the end */
     693};
     694
     695/** @} */
    684696
    685697/** @name Ring-0 Context Driver Helpers
     
    900912    }
    901913}
    902 
  • trunk/src/VBox/VMM/VMMR3/PDMDevHlp.cpp

    r35358 r35676  
    28122812}
    28132813
     2814/** @interface_method_impl{PDMDEVHLPR3,pfnPciRawRegister} */
     2815static DECLCALLBACK(int) pdmR3DevHlp_PciRawRegister(PPDMDEVINS pDevIns, PPDMPCIRAWREG pPciRawReg, PCPDMPCIRAWHLPR3 *ppPciRawHlpR3)
     2816{
     2817    PDMDEV_ASSERT_DEVINS(pDevIns);
     2818    VM_ASSERT_EMT(pDevIns->Internal.s.pVMR3);
     2819    LogFlow(("pdmR3DevHlp_PciRawRegister: caller='%s'/%d:\n"));
     2820
     2821    /*
     2822     * Validate input.
     2823     */
     2824    if (pPciRawReg->u32Version != PDM_PCIRAWREG_VERSION)
     2825    {
     2826        AssertMsgFailed(("u32Version=%#x expected %#x\n", pPciRawReg->u32Version, PDM_PCIRAWREG_VERSION));
     2827        LogFlow(("pdmR3DevHlp_PciRawRegister: caller='%s'/%d: returns %Rrc (version)\n", pDevIns->pReg->szName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
     2828        return VERR_INVALID_PARAMETER;
     2829    }
     2830
     2831    if (!ppPciRawHlpR3)
     2832    {
     2833        Assert(ppPciRawHlpR3);
     2834        LogFlow(("pdmR3DevHlp_PciRawRegister: caller='%s'/%d: returns %Rrc (ppApicHlpR3)\n", pDevIns->pReg->szName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
     2835        return VERR_INVALID_PARAMETER;
     2836    }
     2837
     2838    /* set the helper pointer and return. */
     2839    *ppPciRawHlpR3 = &g_pdmR3DevPciRawHlp;
     2840    LogFlow(("pdmR3DevHlp_PciRawRegister: caller='%s'/%d: returns %Rrc\n", pDevIns->pReg->szName, pDevIns->iInstance, VINF_SUCCESS));
     2841    return VINF_SUCCESS;
     2842}
    28142843
    28152844/** @interface_method_impl{PDMDEVHLPR3,pfnDMACRegister} */
     
    31823211    pdmR3DevHlp_IOAPICRegister,
    31833212    pdmR3DevHlp_HPETRegister,
     3213    pdmR3DevHlp_PciRawRegister,
    31843214    pdmR3DevHlp_DMACRegister,
    31853215    pdmR3DevHlp_DMARegister,
     
    33923422    pdmR3DevHlp_IOAPICRegister,
    33933423    pdmR3DevHlp_HPETRegister,
     3424    pdmR3DevHlp_PciRawRegister,
    33943425    pdmR3DevHlp_DMACRegister,
    33953426    pdmR3DevHlp_DMARegister,
     
    34693500
    34703501/** @} */
    3471 
  • trunk/src/VBox/VMM/VMMR3/PDMDevMiscHlp.cpp

    r35358 r35676  
    651651/** @} */
    652652
    653 
     653/** @interface_method_impl{PDMPCIRAWHLPR3,pfnGetRCHelpers} */
     654static DECLCALLBACK(PCPDMPCIRAWHLPRC) pdmR3PciRawHlp_GetRCHelpers(PPDMDEVINS pDevIns)
     655{
     656    PDMDEV_ASSERT_DEVINS(pDevIns);
     657    VM_ASSERT_EMT(pDevIns->Internal.s.pVMR3);
     658    RTRCPTR pRCHelpers = 0;
     659    int rc = PDMR3LdrGetSymbolRC(pDevIns->Internal.s.pVMR3, NULL, "g_pdmRCPciRawHlp", &pRCHelpers);
     660    AssertReleaseRC(rc);
     661    AssertRelease(pRCHelpers);
     662    LogFlow(("pdmR3PciRawHlp_GetGCHelpers: caller='%s'/%d: returns %RRv\n",
     663             pDevIns->pReg->szName, pDevIns->iInstance, pRCHelpers));
     664    return pRCHelpers;
     665}
     666
     667
     668/** @interface_method_impl{PDMPCIRAWHLPR3,pfnGetR0Helpers} */
     669static DECLCALLBACK(PCPDMPCIRAWHLPR0) pdmR3PciRawHlp_GetR0Helpers(PPDMDEVINS pDevIns)
     670{
     671    PDMDEV_ASSERT_DEVINS(pDevIns);
     672    VM_ASSERT_EMT(pDevIns->Internal.s.pVMR3);
     673    PCPDMHPETHLPR0 pR0Helpers = 0;
     674    int rc = PDMR3LdrGetSymbolR0(pDevIns->Internal.s.pVMR3, NULL, "g_pdmR0PciRawHlp", &pR0Helpers);
     675    AssertReleaseRC(rc);
     676    AssertRelease(pR0Helpers);
     677    LogFlow(("pdmR3PciRawHlp_GetR0Helpers: caller='%s'/%d: returns %RHv\n",
     678             pDevIns->pReg->szName, pDevIns->iInstance, pR0Helpers));
     679    return pR0Helpers;
     680}
     681
     682/**
     683 * Raw PCI Device Helpers.
     684 */
     685const PDMPCIRAWHLPR3 g_pdmR3DevPciRawHlp =
     686{
     687    PDM_PCIRAWHLPR3_VERSION,
     688    pdmR3PciRawHlp_GetRCHelpers,
     689    pdmR3PciRawHlp_GetR0Helpers,
     690    PDM_PCIRAWHLPR3_VERSION, /* the end */
     691};
    654692
    655693/* none yet */
  • trunk/src/VBox/VMM/include/PDMInternal.h

    r35358 r35676  
    10851085extern const PDMRTCHLP      g_pdmR3DevRtcHlp;
    10861086extern const PDMHPETHLPR3   g_pdmR3DevHpetHlp;
     1087extern const PDMPCIRAWHLPR3 g_pdmR3DevPciRawHlp;
    10871088#endif
    10881089
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