VirtualBox

Changeset 79973 in vbox for trunk/src


Ignore:
Timestamp:
Jul 25, 2019 8:10:25 AM (5 years ago)
Author:
vboxsync
Message:

Just checking in changes. Working out new interface between Virtio_1.0.cpp and its clients. Currently crashing in DrvSCSI construct (that was working when it was all contained in DevVirtioScsi). Next thing to troubleshoot.

Location:
trunk/src/VBox/Devices
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/DevVirtioSCSI.cpp

    r79929 r79973  
    5555typedef struct VIRTIOSCSITARGET
    5656{
    57 
    58 
    59     /** Pointer to the owning virtioScsi device instance. - R3 pointer */
     57    /** Pointer to PCI device that owns this target instance. - R3 /pointer */
    6058    R3PTRTYPE(struct VIRTIOSCSI *)  pVirtioScsiR3;
    61     /** Pointer to the owning virtioScsi device instance. - R0 pointer */
     59    /** Pointer to PCI device that owns this target instance. - R0 pointer */
    6260    R3PTRTYPE(struct VIRTIOSCSI *)  pVirtioScsiR0;
    63     /** Pointer to the owning virtioScsi device instance. - RC pointer */
     61    /** Pointer to PCI device that owns this target instance. - RC pointer */
    6462    R3PTRTYPE(struct VIRTIOSCSI *)  pVirtioScsiRC;
    6563
     
    108106typedef struct VIRTIOSCSI
    109107{
     108    /* virtioState must be first member */
     109    VIRTIOSTATE                     virtioState;
     110
     111    /* SCSI target instances data */
     112    VIRTIOSCSITARGET                aTargetInstances[VIRTIOSCSI_MAX_TARGETS];
    110113
    111114    PPDMDEVINSR3           pDevInsR3;              /**< Device instance - R3. */
    112115    PPDMDEVINSR0           pDevInsR0;              /**< Device instance - R0. */
    113116    PPDMDEVINSRC           pDevInsRC;              /**< Device instance - RC. */
    114 
    115     /* virtioState must be first member */
    116     VIRTIOSTATE                     virtioState;
    117 
    118     /* SCSI target instances data */
    119     VIRTIOSCSITARGET                aTargetInstances[VIRTIOSCSI_MAX_TARGETS];
    120 
    121     /** Base address of the I/O ports. */
    122     RTIOPORT                        IOPortBase;
    123117
    124118    /** Base address of the memory mapping. */
     
    766760    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMEDIAPORT, &pTarget->IMediaPort);
    767761    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMEDIAEXPORT, &pTarget->IMediaExPort);
     762
     763    /* This call back is necessary to get Status / LED support */
     764    return virtioQueryInterface(pInterface, pszIID);
     765
    768766    return NULL;
    769767}
     
    867865    pVirtioPciParams->uInterruptPin  = 0x01;
    868866
    869 
    870     PVIRTIOSTATE pVirtioScsi = &(pThis->virtioState);
    871     rc = virtioConstruct(pDevIns, pVirtioScsi, iInstance, pVirtioPciParams,
     867    PVIRTIOSTATE pVirtio = &(pThis->virtioState);
     868    pDevIns->IBase.pfnQueryInterface = virtioScsiR3DeviceQueryInterface;
     869
     870    rc = virtioConstruct(pDevIns, pVirtio, iInstance, pVirtioPciParams,
    872871                         VIRTIO_SCSI_NAME_FMT, VIRTIO_SCSI_N_QUEUES, VIRTIO_SCSI_REGION_PCI_CAP,
    873                          virtioScsiR3DevCapRead, virtioScsiR3DevCapWrite, sizeof(VIRTIODEVCFG));
     872                         virtioScsiR3DevCapRead, virtioScsiR3DevCapWrite, sizeof(VIRTIODEVCAP));
    874873    if (RT_FAILURE(rc))
    875874        return PDMDEV_SET_ERROR(pDevIns, rc, N_("virtio-scsi: failed to initialize VirtIO"));
    876875
    877     rc = PDMDevHlpPCIIORegionRegister(pDevIns, VIRTIO_SCSI_REGION_PORT_IO, 32,
     876    rc = PDMDevHlpPCIIORegionRegister(pDevIns, VIRTIO_SCSI_REGION_MEM_IO, 32,
    878877                                      PCI_ADDRESS_SPACE_MEM, virtioScsiR3Map);
    879878    if (RT_FAILURE(rc))
     
    904903        PVIRTIOSCSITARGET pTarget = &pThis->aTargetInstances[iLUN];
    905904
    906         if (RTStrAPrintf(&pTarget->pszLunName, "VSCSI%u", iLUN) < 0)
     905        if (RTStrAPrintf(&pTarget->pszLunName, "VIRTIOSCSI%u", iLUN) < 0)
    907906            AssertLogRelFailedReturn(VERR_NO_MEMORY);
    908907
     
    919918        pTarget->IMediaExPort.pfnIoReqQueryBuf           = NULL;
    920919        pTarget->IMediaExPort.pfnIoReqQueryDiscardRanges = NULL;
    921         pDevIns->IBase.pfnQueryInterface                 = virtioScsiR3DeviceQueryInterface;
    922920
    923921        LogFunc(("Attaching LUN: %s\n", pTarget->pszLunName));
     
    986984    "virtio-scsi",
    987985    /* szRCMod */
    988     "",
     986    "VBoxDDRC.rc",
    989987    /* szR0Mod */
    990     "",
     988    "VBoxDDR0.r0",
    991989    /* pszDescription */
    992     "Virtio SCSI.\n",
     990    "Virtio Host SCSI.\n",
    993991    /* fFlags */
    994992#ifdef VIRTIOSCSI_GC_SUPPORT
  • trunk/src/VBox/Devices/VirtIO/Virtio_1_0.cpp

    r79941 r79973  
    2222#define LOG_GROUP LOG_GROUP_DEV_VIRTIO
    2323
     24#include <VBox/log.h>
    2425#include <iprt/param.h>
     26#include <iprt/assert.h>
    2527#include <iprt/uuid.h>
    2628#include <VBox/vmm/pdmdev.h>
     
    717719                    uint16_t cbDevSpecificCap)
    718720{
    719 
    720721    RT_NOREF(nQueues);
    721722
     
    730731    pVirtio->pfnVirtioDevCapRead     = devCapReadCallback;
    731732    pVirtio->pfnVirtioDevCapWrite    = devCapWriteCallback;
    732 
    733     int rc = VINF_SUCCESS;
    734     rc = PDMDevHlpPCIIORegionRegister(pDevIns, uVirtioRegion, 32, PCI_ADDRESS_SPACE_MEM, virtioR3Map);
    735     if (RT_FAILURE(rc))
    736         return PDMDEV_SET_ERROR(pDevIns, rc,
    737             N_("virtio: cannot register PCI Capabilities address space")); /* can we put params in this error? */
    738 
    739733
    740734    /* Set PCI config registers (assume 32-bit mode) */
     
    750744    PCIDevSetInterruptPin      (&pVirtio->dev, pPciParams->uInterruptPin);
    751745
     746    int rc = VINF_SUCCESS;
     747    /* Register PCI device */
     748    rc = PDMDevHlpPCIRegister(pDevIns, &pVirtio->dev);
     749    if (RT_FAILURE(rc))
     750        return PDMDEV_SET_ERROR(pDevIns, rc,
     751            N_("virtio: cannot register PCI Device")); /* can we put params in this error? */
     752
     753    pVirtio->IBase = pDevIns->IBase;
     754
     755    rc = PDMDevHlpPCIIORegionRegister(pDevIns, uVirtioRegion, 32, PCI_ADDRESS_SPACE_MEM, virtioR3Map);
     756    if (RT_FAILURE(rc))
     757        return PDMDEV_SET_ERROR(pDevIns, rc,
     758            N_("virtio: cannot register PCI Capabilities address space")); /* can we put params in this error? */
     759
    752760    /** Build PCI vendor-specific capabilities list for exchanging
    753761     *  VirtIO device capabilities with driver */
     
    758766#endif
    759767    uint8_t uCfgCapOffset = 0x40;
    760     PVIRTIOPCICAP pCommonCfg = (PVIRTIOPCICAP)&pVirtio->dev.abConfig[uCfgCapOffset];
    761     pCommonCfg->uCapVndr = VIRTIO_PCI_CAP_ID_VENDOR;
    762     pCommonCfg->uCapNext = uCfgCapOffset += sizeof(VIRTIOPCICAP);
    763     pCommonCfg->uCfgType = VIRTIO_PCI_CAP_COMMON_CFG;
    764     pCommonCfg->uBar     = uVirtioRegion;
    765     pCommonCfg->uOffset  = 0;
    766     pCommonCfg->uLength  = sizeof(VIRTIOPCICAP);
    767 
    768     PVIRTIOPCICAP pNotifyCfg = (PVIRTIOPCICAP)&pVirtio->dev.abConfig[uCfgCapOffset];
    769     pNotifyCfg->uCapVndr = VIRTIO_PCI_CAP_ID_VENDOR;
    770     pNotifyCfg->uCapNext = uCfgCapOffset += sizeof(VIRTIOPCICAP);
    771     pNotifyCfg->uCfgType = VIRTIO_PCI_CAP_NOTIFY_CFG;
    772     pNotifyCfg->uBar     = uVirtioRegion;
    773     pNotifyCfg->uOffset  = pVirtio->pCommonCfg->uOffset + sizeof(VIRTIOCOMMONCFG);
    774     pNotifyCfg->uLength  = sizeof(VIRTIOPCICAP);
    775 
    776     PVIRTIOPCICAP pISRConfig = (PVIRTIOPCICAP)&pVirtio->dev.abConfig[uCfgCapOffset];
    777     pISRConfig->uCapVndr = VIRTIO_PCI_CAP_ID_VENDOR;
    778     pISRConfig->uCapNext = uCfgCapOffset += sizeof(VIRTIOPCICAP);
    779     pISRConfig->uCfgType = VIRTIO_PCI_CAP_ISR_CFG;
    780     pISRConfig->uBar     = uVirtioRegion;
    781     pISRConfig->uOffset  = pVirtio->pNotifyCfg->uOffset + sizeof(VIRTIONOTIFYCFG);
    782     pISRConfig->uLength  = sizeof(VIRTIOPCICAP);
    783 
    784     PVIRTIOPCICAP pPCIConfig = (PVIRTIOPCICAP)&pVirtio->dev.abConfig[uCfgCapOffset];
    785     pPCIConfig->uCapVndr = VIRTIO_PCI_CAP_ID_VENDOR;
    786     pPCIConfig->uCapNext = (uint8_t)(fMsiSupport || cbDevSpecificCap ? (uCfgCapOffset += sizeof(VIRTIOPCICAP)): 0);
    787     pPCIConfig->uCfgType = VIRTIO_PCI_CAP_PCI_CFG;
    788     pPCIConfig->uBar     = uVirtioRegion;
    789     pPCIConfig->uOffset  = pVirtio->pISRConfig->uOffset + sizeof(VIRTIOISRCFG);
    790     pPCIConfig->uLength  = sizeof(VIRTIOPCICAP);
    791 
    792     pVirtio->pCommonCfg = pCommonCfg;
    793     pVirtio->pNotifyCfg = pNotifyCfg;
    794     pVirtio->pISRConfig = pISRConfig;
    795     pVirtio->pPCIConfig = pPCIConfig;
     768    /* Capability will be mapped via VirtIO 1.0: struct virtio_pci_common_cfg (VIRTIOCOMMONCFG)*/
     769    PVIRTIOPCICAP pCfg = pVirtio->pCommonCfg = (PVIRTIOPCICAP)&pVirtio->dev.abConfig[uCfgCapOffset];
     770    pCfg->uCapVndr = VIRTIO_PCI_CAP_ID_VENDOR;
     771    pCfg->uCapNext = uCfgCapOffset += sizeof(VIRTIOPCICAP);
     772    pCfg->uCfgType = VIRTIO_PCI_CAP_COMMON_CFG;
     773    pCfg->uBar     = uVirtioRegion;
     774    pCfg->uOffset  = 0;
     775    pCfg->uLength  = sizeof(VIRTIOPCICAP);
     776
     777    /* Capability will be mapped via VirtIO 1.0: struct virtio_pci_notify_cap (VIRTIONOTIFYCAP)*/
     778    pCfg = pVirtio->pNotifyCap = (PVIRTIOPCICAP)&pVirtio->dev.abConfig[uCfgCapOffset];
     779    pCfg->uCapVndr = VIRTIO_PCI_CAP_ID_VENDOR;
     780    pCfg->uCapNext = uCfgCapOffset += sizeof(VIRTIOPCICAP);
     781    pCfg->uCfgType = VIRTIO_PCI_CAP_NOTIFY_CFG;
     782    pCfg->uBar     = uVirtioRegion;
     783    pCfg->uOffset  = pVirtio->pCommonCfg->uOffset + sizeof(VIRTIOCOMMONCFG);
     784    pCfg->uLength  = sizeof(VIRTIOPCICAP);
     785
     786    /* Capability will be mapped via VirtIO 1.0: uint8_t (VIRTIOISRCAP)  */
     787    pCfg = pVirtio->pISRCap = (PVIRTIOPCICAP)&pVirtio->dev.abConfig[uCfgCapOffset];
     788    pCfg->uCapVndr = VIRTIO_PCI_CAP_ID_VENDOR;
     789    pCfg->uCapNext = uCfgCapOffset += sizeof(VIRTIOPCICAP);
     790    pCfg->uCfgType = VIRTIO_PCI_CAP_ISR_CFG;
     791    pCfg->uBar     = uVirtioRegion;
     792    pCfg->uOffset  = pVirtio->pNotifyCap->uOffset + sizeof(VIRTIONOTIFYCAP);
     793    pCfg->uLength  = sizeof(VIRTIOPCICAP);
     794
     795    /* Capability will be mapped via VirtIO 1.0: struct virtio_pci_cfg_cap (VIRTIOPCICAP) */
     796    pCfg = pVirtio->pPCICfgCap = (PVIRTIOPCICAP)&pVirtio->dev.abConfig[uCfgCapOffset];
     797    pCfg->uCapVndr = VIRTIO_PCI_CAP_ID_VENDOR;
     798    pCfg->uCapNext = (uint8_t)(fMsiSupport || cbDevSpecificCap ? (uCfgCapOffset += sizeof(VIRTIOPCICAP)): 0);
     799    pCfg->uCfgType = VIRTIO_PCI_CAP_PCI_CFG;
     800    pCfg->uBar     = uVirtioRegion;
     801    pCfg->uOffset  = pVirtio->pISRCap->uOffset + sizeof(VIRTIOISRCAP);
     802    pCfg->uLength  = sizeof(VIRTIOPCICAP);
    796803
    797804    if (cbDevSpecificCap)
    798805    {
    799         PVIRTIOPCICAP pDeviceCfg = (PVIRTIOPCICAP)&pVirtio->dev.abConfig[uCfgCapOffset];
    800         pDeviceCfg->uCapVndr = VIRTIO_PCI_CAP_ID_VENDOR;
    801         pDeviceCfg->uCapNext = (uint8_t)(fMsiSupport ? (uCfgCapOffset += sizeof(VIRTIOPCICAP)) : 0);
    802         pDeviceCfg->uCfgType = VIRTIO_PCI_CAP_DEVICE_CFG;
    803         pDeviceCfg->uBar     = uVirtioRegion;
    804         pDeviceCfg->uOffset  = pVirtio->pPCIConfig->uOffset + sizeof(VIRTIOCAPCFG);
    805         pDeviceCfg->uLength  = sizeof(VIRTIOPCICAP);
    806         pVirtio->pDeviceCfg  = pDeviceCfg;
     806     /* Capability will be mapped via VirtIO 1.0: struct virtio_pci_dev_cap (VIRTIODEVCAP)*/
     807        pCfg = pVirtio->pDeviceCap = (PVIRTIOPCICAP)&pVirtio->dev.abConfig[uCfgCapOffset];
     808        pCfg->uCapVndr = VIRTIO_PCI_CAP_ID_VENDOR;
     809        pCfg->uCapNext = (uint8_t)(fMsiSupport ? (uCfgCapOffset += sizeof(VIRTIOPCICAP)) : 0);
     810        pCfg->uCfgType = VIRTIO_PCI_CAP_DEVICE_CFG;
     811        pCfg->uBar     = uVirtioRegion;
     812        pCfg->uOffset  = pVirtio->pPCICfgCap->uOffset + sizeof(VIRTIOPCICAP);
     813        pCfg->uLength  = sizeof(VIRTIOPCICAP);
    807814    }
    808815
     
    810817    PCIDevSetCapabilityList    (&pVirtio->dev, 0x40);
    811818    PCIDevSetStatus            (&pVirtio->dev, VBOX_PCI_STATUS_CAP_LIST);
    812 
    813     /* Register PCI device */
    814     rc = PDMDevHlpPCIRegister(pDevIns, &pVirtio->dev);
    815     if (RT_FAILURE(rc))
    816         return rc;
    817819
    818820    if (fMsiSupport)
     
    834836
    835837    /* Status driver */
    836     PPDMIBASE pBase;
    837     rc = PDMDevHlpDriverAttach(pDevIns, PDM_STATUS_LUN, &pVirtio->IBase, &pBase, "Status Port");
     838    PPDMIBASE pUpstreamBase;
     839
     840    rc = PDMDevHlpDriverAttach(pDevIns, PDM_STATUS_LUN, &pVirtio->IBase, &pUpstreamBase, "Status Port");
    838841    if (RT_FAILURE(rc))
    839842        return PDMDEV_SET_ERROR(pDevIns, rc, N_("Failed to attach the status LUN"));
    840     pVirtio->pLedsConnector = PDMIBASE_QUERY_INTERFACE(pBase, PDMILEDCONNECTORS);
     843    pVirtio->pLedsConnector = PDMIBASE_QUERY_INTERFACE(&pVirtio->IBase, PDMILEDCONNECTORS);
    841844
    842845    return rc;
  • trunk/src/VBox/Devices/VirtIO/Virtio_1_0.h

    r79928 r79973  
    11/* $Id$ */
    22/** @file
    3  * Virtio_1_0.h - Virtio Declarations
     3 * Virtio_1_0p .h - Virtio Declarations
    44 */
    55
     
    175175        struct virtio_pci_cap cap;
    176176        uint32_t uNotifyOffMultiplier; /* notify_off_multiplier                        */
    177 } VIRTIONOTIFYCFG, *PVIRTIONOTIFYCFG;
    178 
    179 typedef uint32_t VIRTIOISRCFG, *PVIRTIOISRCFG;
     177} VIRTIONOTIFYCAP, *PVIRTIONOTIFYCAP;
     178
     179typedef uint8_t VIRTIOISRCAP, *PVIRTIOISRCAP;
    180180
    181181/* Device-specific configuration (if any) ... T.B.D. (if and when neeed), provide an
     
    185185typedef struct virtio_pci_dev_cfg
    186186{
    187 } VIRTIODEVCFG, *PVIRTIODEVCFG;
     187} VIRTIODEVCAP, *PVIRTIODEVCAP;
    188188
    189189typedef struct virtio_pci_cfg_cap {
    190190        struct virtio_pci_cap cap;
    191191        uint8_t pci_cfg_data[4]; /* Data for BAR access. */
    192 } VIRTIOCAPCFG, *PVIRTIOCAPCFG;
     192} VIRTIOPCICFGCAP, *PVIRTIOPCICFGCAP;
    193193
    194194typedef struct virtq_desc  /* VirtIO 1.0 specification formal name of this struct     */
     
    319319
    320320    VIRTIOCOMMONCFG        pGcPhysVirtioCommonCfg;
    321     VIRTIONOTIFYCFG        pGcPhysVirtioNotifyCfg;
    322     VIRTIOISRCFG           pGcPhysVirtioIsrCfg;
    323     VIRTIOCAPCFG           pGcPhysVirtioCapCfg;
    324     VIRTIODEVCFG           pGcPhysVirtioDevCfg;
     321    VIRTIONOTIFYCAP        pGcPhysVirtioNotifyCap;
     322    VIRTIOISRCAP           pGcPhysVirtioIsrCap;
     323    VIRTIODEVCAP           pGcPhysVirtioDevCap;
     324    VIRTIOPCICFGCAP        pGcPhysVirtioPciCap;
    325325
    326326    /** Callbacks when guest driver reads or writes VirtIO device-specific capabilities(s) */
     
    353353
    354354    PVIRTIOPCICAP pCommonCfg;
    355     PVIRTIOPCICAP pNotifyCfg;
    356     PVIRTIOPCICAP pISRConfig;
    357     PVIRTIOPCICAP pPCIConfig;
    358     PVIRTIOPCICAP pDeviceCfg;
     355    PVIRTIOPCICAP pNotifyCap;
     356    PVIRTIOPCICAP pISRCap;
     357    PVIRTIOPCICAP pPCICfgCap;
     358    PVIRTIOPCICAP pDeviceCap;
    359359} VIRTIOSTATE, *PVIRTIOSTATE;
    360360
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