VirtualBox

Changeset 79973 in vbox for trunk/src/VBox/Devices/VirtIO


Ignore:
Timestamp:
Jul 25, 2019 8:10:25 AM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
132404
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/VirtIO
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • 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.

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