VirtualBox

Changeset 79375 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jun 27, 2019 6:41:20 AM (6 years ago)
Author:
vboxsync
Message:

Fixed crash, still not seeing on pci bus with lspci, will check with virtualbox debugger

File:
1 edited

Legend:

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

    r79336 r79375  
    3636*   Structures and Typedefs                                                                                                      *
    3737*********************************************************************************************************************************/
    38 #define VIRTIOSCSI_MAX_DEVICES  16
     38#define VIRTIOSCSI_MAX_DEVICES  1
    3939
    4040/**
     
    5454    /** LUN of the device. */
    5555    RTUINT                        iLUN;
    56 
    57     PDMIMEDIAPORT                 IMediaPort;
    58     /** Extended media port interface. */
    59 
    60     PDMIMEDIAEXPORT               IMediaExPort;
    61     /** Led interface. */
    62 
    63     R3PTRTYPE(PPDMIMEDIA)         pDrvMedia;
    64     /** Pointer to the attached driver's extended media interface. */
    65 
    66     R3PTRTYPE(PPDMIMEDIAEX)       pDrvMediaEx;
    67     /** The status LED state for this device. */
    68 
    6956
    7057    /** Flag whether device is present. */
     
    9582    PPDMDEVINSRC                    pDevInsRC;
    9683
     84    /** Queue to send tasks to R3. - HC ptr */
     85    R3PTRTYPE(PPDMQUEUE)            pNotifierQueueR3;
     86    /** Queue to send tasks to R3. - HC ptr */
     87    R0PTRTYPE(PPDMQUEUE)            pNotifierQueueR0;
     88    /** Queue to send tasks to R3. - RC ptr */
     89    RCPTRTYPE(PPDMQUEUE)            pNotifierQueueRC;
     90
    9791    /** The base interface.
    9892     * @todo use PDMDEVINS::IBase  */
     
    112106    RTGCPHYS                        MMIOBase;
    113107
     108    /** Partner of ILeds. */
     109    R3PTRTYPE(PPDMILEDCONNECTORS)   pLedsConnector;
     110
    114111} VIRTIOSCSI, *PVIRTIOSCSI;
    115112
     
    120117typedef struct VIRTIOSCSIREQ
    121118{
    122     /** PDM extended media interface I/O request hande. */
    123     PDMMEDIAEXIOREQ                hIoReq;
    124119    /** Device this task is assigned to. */
    125     PVIRTIOSCSIDEV               pTargetDevice;
     120    PVIRTIOSCSIDEV                 pTargetDevice;
    126121    /** The command control block from the guest. */
    127122//    CCBU                           CCBGuest;
     
    140135
    141136#define VIRTIOSCSI_SAVED_STATE_MINOR_VERSION        0x01
    142 
    143 
     137/*********************************************************************************************************************************/
    144138#if 0
     139
    145140/** @callback_method_impl{FNSSMDEVLIVEEXEC}  */
    146141static DECLCALLBACK(int) virtioScsiR3LiveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uPass)
     
    149144    NOREF(pSSM);
    150145    PVIRTIOSCSI pThis = PDMINS_2_DATA(pDevIns, PVIRTIOSCSI);
     146    LogFunc(("callback"));
    151147    NOREF(pThis);
    152148    return VINF_SSM_DONT_CALL_AGAIN;
     
    160156    NOREF(uVersion);
    161157    PVIRTIOSCSI pThis = PDMINS_2_DATA(pDevIns, PVIRTIOSCSI);
     158    LogFunc(("callback"));
    162159    NOREF(pThis);
    163160    return VINF_SSM_DONT_CALL_AGAIN;
     
    169166    RT_NOREF(pSSM);
    170167    PVIRTIOSCSI pThis = PDMINS_2_DATA(pDevIns, PVIRTIOSCSI);
     168    LogFunc(("callback"));
    171169    NOREF(pThis);
    172170    return VINF_SUCCESS;
     
    178176    RT_NOREF(pSSM);
    179177    PVIRTIOSCSI pThis = PDMINS_2_DATA(pDevIns, PVIRTIOSCSI);
     178    LogFunc(("callback"));
    180179    NOREF(pThis);
    181180    return VINF_SUCCESS;
     
    282281    return rc;
    283282}
     283
     284/**
     285 * BusLogic debugger info callback.
     286 *
     287 * @param   pDevIns     The device instance.
     288 * @param   pHlp        The output helpers.
     289 * @param   pszArgs     The arguments.
     290 */
     291static DECLCALLBACK(void) virtioScsiR3Info(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs)
     292{
     293    PVIRTIOSCSI   pThis = PDMINS_2_DATA(pDevIns, PVIRTIOSCSI);
     294    bool        fVerbose = false;
     295
     296    /* Parse arguments. */
     297    if (pszArgs)
     298        fVerbose = strstr(pszArgs, "verbose") != NULL;
     299
     300    /* Show basic information. */
     301    pHlp->pfnPrintf(pHlp, "%s#%d: virtio-scsci ",
     302                    pDevIns->pReg->szName,
     303                    pDevIns->iInstance);
     304    pHlp->pfnPrintf(pHlp, "GC=%RTbool R0=%RTbool\n",
     305                    !!pThis->fGCEnabled, !!pThis->fR0Enabled);
     306}
     307
    284308/**
    285309 * @callback_method_impl{FNPCIIOREGIONMAP}
     
    355379
    356380
    357 
    358 
    359 
    360381/**
    361382 * @copydoc FNPDMDEVRESET
     
    372393//    {
    373394//        ASMAtomicWriteBool(&pThis->fSignalIdle, false);
    374 //        virtioScsiR3HwReset(pThis, true);
    375395//   }
    376396}
     
    378398static DECLCALLBACK(void) virtioScsiR3Relocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta)
    379399{
     400LogFunc(("Relocating virtio-scsci"));
    380401    RT_NOREF(offDelta);
    381402    PVIRTIOSCSI pThis = PDMINS_2_DATA(pDevIns, PVIRTIOSCSI);
    382     NOREF(pThis);
    383 
    384 //    pThis->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);
     403
     404    pThis->pDevInsR3 = pDevIns;
    385405//    pThis->pNotifierQueueRC = PDMQueueRCPtr(pThis->pNotifierQueueR3);
    386 //
    387 //    for (uint32_t i = 0; i < VIRTIOSCSI_MAX_DEVICES; i++)
    388 //   {
    389 //        PVIRTIOSCSIDEVICE pDevice = &pThis->aDevInstances[i];
    390 //
    391 //        pDevice->pvirtio-scsiRC = PDMINS_2_DATA_RCPTR(pDevIns);
    392 //
    393 //    }
     406
     407    for (uint32_t i = 0; i < VIRTIOSCSI_MAX_DEVICES; i++)
     408    {
     409        PVIRTIOSCSIDEV pDevice = &pThis->aDevInstances[i];
     410        pDevice->pVirtioScsiR3 = pThis;;
     411
     412  }
    394413
    395414}
     
    472491        return PDMDEV_SET_ERROR(pDevIns, rc, N_("virtio-scsi cannot register with PCI bus"));
    473492
    474 //    rc = PDMDevHlpPCIIORegionRegister(pDevIns, 0, 32, PCI_ADDRESS_SPACE_IO, devVirtioScsiR3MmioMap);
    475 //    if (RT_FAILURE(rc))
    476 //        return PDMDEV_SET_ERROR(pDevIns, rc, N_("virtio-scsi cannot register PCI I/O address space"));
    477 
    478 //    rc = PDMDevHlpPCIIORegionRegister(pDevIns, 1, 32, PCI_ADDRESS_SPACE_MEM, devVirtioScsiR3MmioMap);
    479 //    if (RT_FAILURE(rc))
    480 //        return PDMDEV_SET_ERROR(pDevIns, rc, N_("virtio-scsi cannot register PCI mmio address space"));
    481     NOREF(devVirtioScsiR3MmioMap);
     493    rc = PDMDevHlpPCIIORegionRegister(pDevIns, 0, 32, PCI_ADDRESS_SPACE_IO, devVirtioScsiR3MmioMap);
     494    if (RT_FAILURE(rc))
     495        return PDMDEV_SET_ERROR(pDevIns, rc, N_("virtio-scsi cannot register PCI I/O address space"));
     496
     497    rc = PDMDevHlpPCIIORegionRegister(pDevIns, 1, 32, PCI_ADDRESS_SPACE_MEM, devVirtioScsiR3MmioMap);
     498    if (RT_FAILURE(rc))
     499        return PDMDEV_SET_ERROR(pDevIns, rc, N_("virtio-scsi cannot register PCI mmio address space"));
     500
    482501#if 0
    483502    if (fBootable)
     
    491510            return PDMDEV_SET_ERROR(pDevIns, rc, N_("virtio-scsi cannot register BIOS I/O handlers"));
    492511    }
     512#endif
     513
     514
     515#if 0
     516    /* Initialize task queue. */
     517    rc = PDMDevHlpQueueCreate(pDevIns, sizeof(PDMQUEUEITEMCORE), 5, 0,
     518                              buslogicR3NotifyQueueConsumer, true, "BusLogicTask", &pThis->pNotifierQueueR3);
     519    if (RT_FAILURE(rc))
     520        return rc;
    493521
    494522    pThis->pNotifierQueueR0 = PDMQueueR0Ptr(pThis->pNotifierQueueR3);
    495523    pThis->pNotifierQueueRC = PDMQueueRCPtr(pThis->pNotifierQueueR3);
    496 
    497     rc = PDMDevHlpCritSectInit(pDevIns, &pThis->CritSectIntr, RT_SRC_POS, "virtio-scsi-Intr#%u", pDevIns->iInstance);
    498     if (RT_FAILURE(rc))
    499         return PDMDEV_SET_ERROR(pDevIns, rc, N_("virtio-scsi: cannot create critical section"));
    500 
    501     /*
    502      * Create event semaphore and worker thread.
    503      */
    504     rc = SUPSemEventCreate(pThis->pSupDrvSession, &pThis->hEvtProcess);
    505     if (RT_FAILURE(rc))
    506         return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS,
    507                                    N_("virtio-scsi: Failed to create SUP event semaphore"));
    508 
    509     char szDevTag[20];
    510     RTStrPrintf(szDevTag, sizeof(szDevTag), "VIRTIOSCSI-%u", iInstance);
    511 
    512     rc = PDMDevHlpThreadCreate(pDevIns, &pThis->pThreadWrk, pThis, virtioScsiR3Worker,
    513                                virtioScsiR3WorkerWakeUp, 0, RTTHREADTYPE_IO, szDevTag);
    514     if (RT_FAILURE(rc))
    515         return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS,
    516                                    N_("virtio-scsi: Failed to create worker thread %s"), szDevTag);
    517524#endif
    518525
     
    529536        pDevice->iLUN = i;
    530537        pDevice->pVirtioScsiR3 = pThis;
    531 LogFunc(("Attaching: Lun=%d, pszName=%s\n",  pDevice->iLUN, pszName));
     538
     539        LogFunc(("Attaching: Lun=%d, pszName=%s\n",  pDevice->iLUN, pszName));
    532540        /* Attach SCSI driver. */
    533541        rc = PDMDevHlpDriverAttach(pDevIns, pDevice->iLUN, &pDevice->IBase, &pDevice->pDrvBase, pszName);
    534542        if (RT_SUCCESS(rc))
    535         {
    536 #if 0
    537             /* Query the media interface. */
    538             pDevice->pDrvMedia = PDMIBASE_QUERY_INTERFACE(pDevice->pDrvBase, PDMIMEDIA);
    539             AssertMsgReturn(VALID_PTR(pDevice->pDrvMedia),
    540                             ("virtio-scsi configuration error: LUN#%d misses the basic media interface!\n", pDevice->iLUN),
    541                             VERR_PDM_MISSING_INTERFACE);
    542 
    543             /* Get the extended media interface. */
    544             pDevice->pDrvMediaEx = PDMIBASE_QUERY_INTERFACE(pDevice->pDrvBase, PDMIMEDIAEX);
    545             AssertMsgReturn(VALID_PTR(pDevice->pDrvMediaEx),
    546                             ("virtio-scsi configuration error: LUN#%d misses the extended media interface!\n", pDevice->iLUN),
    547                             VERR_PDM_MISSING_INTERFACE);
    548 
    549 #endif
    550             rc = pDevice->pDrvMediaEx->pfnIoReqAllocSizeSet(pDevice->pDrvMediaEx, sizeof(VIRTIOSCSIREQ));
    551             if (RT_FAILURE(rc))
    552                 return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS,
    553                                            N_("virtio-scsi configuration error: LUN#%u: Failed to set I/O request size!"),
    554                                            pDevice->iLUN);
    555 
    556543            pDevice->fPresent = true;
    557         }
    558544        else if (rc == VERR_PDM_NO_ATTACHED_DRIVER)
    559545        {
    560546            pDevice->fPresent    = false;
    561547            pDevice->pDrvBase    = NULL;
    562 //            pDevice->pDrvMedia   = NULL;
    563 //            pDevice->pDrvMediaEx = NULL;
    564548            rc = VINF_SUCCESS;
    565549            Log(("virtio-scsi: no driver attached to device %s\n", pszName));
     
    571555        }
    572556    }
    573 #if 0
    574557    /*
    575558     * Attach status driver (optional).
    576559     */
     560#if 0
    577561    PPDMIBASE pBase;
    578562    rc = PDMDevHlpDriverAttach(pDevIns, PDM_STATUS_LUN, &pThis->IBase, &pBase, "Status Port");
    579563    if (RT_SUCCESS(rc))
    580     {
    581 //        pThis->pLedsConnector = PDMIBASE_QUERY_INTERFACE(pBase, PDMILEDCONNECTORS);
    582 //        pThis->pMediaNotify = PDMIBASE_QUERY_INTERFACE(pBase, PDMIMEDIANOTIFY);
    583     }
     564        pThis->pLedsConnector = PDMIBASE_QUERY_INTERFACE(pBase, PDMILEDCONNECTORS);
    584565    else if (rc != VERR_PDM_NO_ATTACHED_DRIVER)
    585566    {
     
    594575    if (RT_FAILURE(rc))
    595576        return PDMDEV_SET_ERROR(pDevIns, rc, N_("virtio-scsi cannot register save state handlers"));
    596 
    597 //#if 0
     577#endif
    598578    /*
    599579     * Register the debugger info callback.
     
    603583    PDMDevHlpDBGFInfoRegister(pDevIns, szTmp, "virtio-scsi HBA info", virtioScsiR3Info);
    604584
    605 
    606     rc = virtioScsiR3HwReset(pThis, true);
    607     AssertMsgRC(rc, ("hardware reset of virtio-scsi host adapter failed rc=%Rrc\n", rc));
    608 #endif
    609 
    610585    return rc;
     586}
     587
     588
     589/**
     590 * Detach notification.
     591 *
     592 * One harddisk at one port has been unplugged.
     593 * The VM is suspended at this point.
     594 *
     595 * @param   pDevIns     The device instance.
     596 * @param   iLUN        The logical unit which is being detached.
     597 * @param   fFlags      Flags, combination of the PDMDEVATT_FLAGS_* \#defines.
     598 */
     599static DECLCALLBACK(void) devVirtioScsiR3Detach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags)
     600{
     601    RT_NOREF(fFlags);
     602    PVIRTIOSCSI       pThis = PDMINS_2_DATA(pDevIns, PVIRTIOSCSI);
     603    PVIRTIOSCSIDEV pDevice = &pThis->aDevInstances[iLUN];
     604
     605    Log(("%s:\n", __FUNCTION__));
     606
     607    AssertMsg(fFlags & PDM_TACH_FLAGS_NOT_HOT_PLUG,
     608              ("virtio-scsi: Device does not support hotplugging\n"));
     609
     610    /*
     611     * Zero some important members.
     612     */
     613    pDevice->fPresent    = false;
     614    pDevice->pDrvBase    = NULL;
    611615}
    612616
     
    636640    /* the usual paranoia */
    637641    AssertRelease(!pDevice->pDrvBase);
    638     AssertRelease(!pDevice->pDrvMedia);
    639     AssertRelease(!pDevice->pDrvMediaEx);
    640642    Assert(pDevice->iLUN == iLUN);
    641643
     
    646648    rc = PDMDevHlpDriverAttach(pDevIns, pDevice->iLUN, &pDevice->IBase, &pDevice->pDrvBase, NULL);
    647649    if (RT_SUCCESS(rc))
    648     {
    649         /* Query the media interface. */
    650         pDevice->pDrvMedia = PDMIBASE_QUERY_INTERFACE(pDevice->pDrvBase, PDMIMEDIA);
    651         AssertMsgReturn(VALID_PTR(pDevice->pDrvMedia),
    652                         ("virtio-scsi configuration error: LUN#%d misses the basic media interface!\n", pDevice->iLUN),
    653                         VERR_PDM_MISSING_INTERFACE);
    654 
    655         /* Get the extended media interface. */
    656         pDevice->pDrvMediaEx = PDMIBASE_QUERY_INTERFACE(pDevice->pDrvBase, PDMIMEDIAEX);
    657         AssertMsgReturn(VALID_PTR(pDevice->pDrvMediaEx),
    658                         ("virtio-scsi configuration error: LUN#%d misses the extended media interface!\n", pDevice->iLUN),
    659                         VERR_PDM_MISSING_INTERFACE);
    660 
    661         rc = pDevice->pDrvMediaEx->pfnIoReqAllocSizeSet(pDevice->pDrvMediaEx, sizeof(VIRTIOSCSIREQ));
    662         AssertMsgRCReturn(rc, ("virtio-scsi configuration error: LUN#%u: Failed to set I/O request size!", pDevice->iLUN),
    663                           rc);
    664650        pDevice->fPresent = true;
    665     }
    666651    else
    667652        AssertMsgFailed(("Failed to attach LUN#%d. rc=%Rrc\n", pDevice->iLUN, rc));
     
    671656        pDevice->fPresent    = false;
    672657        pDevice->pDrvBase    = NULL;
    673         pDevice->pDrvMedia   = NULL;
    674         pDevice->pDrvMediaEx = NULL;
    675658    }
    676659    return rc;
    677 }
    678 
    679 
    680 /**
    681  * Detach notification.
    682  *
    683  * One harddisk at one port has been unplugged.
    684  * The VM is suspended at this point.
    685  *
    686  * @param   pDevIns     The device instance.
    687  * @param   iLUN        The logical unit which is being detached.
    688  * @param   fFlags      Flags, combination of the PDMDEVATT_FLAGS_* \#defines.
    689  */
    690 static DECLCALLBACK(void) devVirtioScsiR3Detach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags)
    691 {
    692     RT_NOREF(fFlags);
    693     PVIRTIOSCSI       pThis = PDMINS_2_DATA(pDevIns, PVIRTIOSCSI);
    694     PVIRTIOSCSIDEV pDevice = &pThis->aDevInstances[iLUN];
    695 
    696     Log(("%s:\n", __FUNCTION__));
    697 
    698     AssertMsg(fFlags & PDM_TACH_FLAGS_NOT_HOT_PLUG,
    699               ("virtio-scsi: Device does not support hotplugging\n"));
    700 
    701     /*
    702      * Zero some important members.
    703      */
    704     pDevice->fPresent    = false;
    705     pDevice->pDrvBase    = NULL;
    706 //    pDevice->pDrvMedia   = NULL;
    707 //    pDevice->pDrvMediaEx = NULL;
    708 
    709660}
    710661
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