VirtualBox

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


Ignore:
Timestamp:
Sep 22, 2019 9:56:37 AM (5 years ago)
Author:
vboxsync
Message:

Storage/DevVirtioSCSI.cpp: Fixed errors that prevented it from building on Windows and tested. See bugref:9440, Comment #93

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/VirtIO/Virtio_1_0.cpp

    r80928 r80931  
    3535#define INSTANCE(pVirtio) pVirtio->szInstance
    3636#define QUEUENAME(qIdx) (pVirtio->virtqState[qIdx].szVirtqName)
     37
    3738
    3839/**
     
    246247    Log3Func(("Copying client data to %s, desc chain (head desc_idx %d)\n",
    247248               QUEUENAME(qIdx), uUsedIdx));
     249    (void)uUsedIdx;
    248250
    249251    /*
     
    252254     * (pulled from avail ring of queue), essentially giving result back to the guest driver.
    253255     */
    254     uint32_t cbRemain = RTSgBufCalcTotalLength(pSgVirtReturn);
    255     uint32_t cbCopy = 0;
     256    size_t cbCopy = 0;
     257    size_t cbRemain = RTSgBufCalcTotalLength(pSgVirtReturn);
    256258    while (cbRemain)
    257259    {
     
    260262        uint64_t dstSgLen   = (uint64_t)paSeg->cbSeg;
    261263        uint64_t dstSgCur   = (uint64_t)pSgPhysReturn->pvSegCur;
    262         cbCopy = RT_MIN(pSgVirtReturn->cbSegLeft, dstSgLen - (dstSgCur - dstSgStart));
     264        cbCopy = RT_MIN((uint64_t)pSgVirtReturn->cbSegLeft, dstSgLen - (dstSgCur - dstSgStart));
    263265        PDMDevHlpPhysWrite(pVirtio->CTX_SUFF(pDevIns),
    264266                          (RTGCPHYS)pSgPhysReturn->pvSegCur, pSgVirtReturn->pvSegCur, cbCopy);
     
    276278            pVirtq->fEventThresholdReached = true;
    277279
     280    Assert(!(cbCopy & 0xffffffff00000000));
    278281    /**
    279282     * Place used buffer's descriptor in used ring but don't update used ring's slot index.
    280283     * That will be done with a subsequent client call to virtioQueueSync() */
    281     virtioWriteUsedElem(pVirtio, qIdx, pVirtq->uUsedIdx++, pDescChain->uHeadIdx, cbCopy);
    282 
    283     Log2Func((".... Copied %u bytes to %u byte buffer, residual=%d\n",
     284    virtioWriteUsedElem(pVirtio, qIdx, pVirtq->uUsedIdx++, pDescChain->uHeadIdx,
     285            (uint32_t)(cbCopy & 0xffffffff));
     286
     287    Log2Func((".... Copied %ul bytes to %ul byte buffer, residual=%ul\n",
    284288         cbCopy, pDescChain->cbPhysDst, pDescChain->cbPhysDst - cbCopy));
    285289
     
    310314    Log6Func(("Updating %s used_idx from %u to %u\n",
    311315              QUEUENAME(qIdx), uIdx, pVirtq->uUsedIdx));
     316    (void)uIdx;
    312317
    313318    virtioWriteUsedRingIdx(pVirtio, qIdx, pVirtq->uUsedIdx);
     
    323328{
    324329    Assert(uNotifyIdx == qIdx);
     330    (void)uNotifyIdx;
    325331
    326332    PVIRTQSTATE pVirtq = &pVirtio->virtqState[qIdx];
    327333    Log6Func(("%s\n", pVirtq->szVirtqName));
     334    (void)pVirtq;
    328335
    329336    /** Inform client */
     
    488495{
    489496    PVIRTIOSTATE pVirtio = (PVIRTIOSTATE)hVirtio;
    490     return pVirtio->uQueueEnable[qIdx];
     497    return pVirtio->uQueueEnable[qIdx] != 0;
    491498}
    492499
     
    528535
    529536    /** Let the client know */
    530     pVirtio->virtioCallbacks.pfnVirtioStatusChanged((VIRTIOHANDLE)pVirtio, pVirtio->pClientContext, false);
     537    pVirtio->virtioCallbacks.pfnVirtioStatusChanged((VIRTIOHANDLE)pVirtio, pVirtio->pClientContext, 0);
    531538    virtioResetDevice(pVirtio);
    532539}
     
    645652             * Notify client only if status actually changed from last time.
    646653             */
    647             bool fOkayNow = pVirtio->uDeviceStatus & VIRTIO_STATUS_DRIVER_OK;
    648             bool fWasOkay = pVirtio->uPrevDeviceStatus & VIRTIO_STATUS_DRIVER_OK;
     654            uint32_t fOkayNow = pVirtio->uDeviceStatus & VIRTIO_STATUS_DRIVER_OK;
     655            uint32_t fWasOkay = pVirtio->uPrevDeviceStatus & VIRTIO_STATUS_DRIVER_OK;
     656            uint32_t fDrvOk = pVirtio->uDeviceStatus & VIRTIO_STATUS_DRIVER_OK;
    649657            if ((fOkayNow && !fWasOkay) || (!fOkayNow && fWasOkay))
    650                 pVirtio->virtioCallbacks.pfnVirtioStatusChanged((VIRTIOHANDLE)pVirtio, pVirtio->pClientContext,
    651                        pVirtio->uDeviceStatus & VIRTIO_STATUS_DRIVER_OK);
     658                pVirtio->virtioCallbacks.pfnVirtioStatusChanged((VIRTIOHANDLE)pVirtio, pVirtio->pClientContext, fDrvOk);
    652659            pVirtio->uPrevDeviceStatus = pVirtio->uDeviceStatus;
    653660        }
     
    758765    {
    759766        uint32_t uOffset = GCPhysAddr - pVirtio->pGcPhysCommonCfg;
    760         virtioCommonCfgAccessed(pVirtio, 0 /* fWrite */, uOffset, cb, pv);
     767        virtioCommonCfgAccessed(pVirtio, 0 /* fWrite */, uOffset, cb, (void const *)pv);
    761768    }
    762769    else
     
    10721079    pVirtio->virtioCallbacks.pfnSSMDevLoadExec      = ssmLoadExecCallback;
    10731080    pVirtio->virtioCallbacks.pfnSSMDevLoadDone      = ssmLoadDoneCallback;
    1074 
    10751081
    10761082    /* Set PCI config registers (assume 32-bit mode) */
     
    13081314
    13091315    int rc = VINF_SUCCESS;
    1310     virtioDumpState(pVirtio, "virtioSaveExec");
    1311 
     1316
     1317#ifdef DEBUG
     1318    virtioDumpState(pVirtio, (const char *)"virtioSaveExec");
     1319#endif
    13121320    rc = SSMR3PutBool(pSSM,   pVirtio->fGenUpdatePending);
    13131321    rc = SSMR3PutU8(pSSM,     pVirtio->uDeviceStatus);
     
    13651373
    13661374    int rc = VINF_SUCCESS;
     1375
     1376#ifdef DEBUG
    13671377    virtioDumpState(pVirtio, "virtioLoadExec");
     1378#endif
    13681379
    13691380    if (uPass == SSM_PASS_FINAL)
     
    14241435
    14251436    int rc = VINF_SUCCESS;
     1437#ifdef DEBUG
    14261438    virtioDumpState(pVirtio, "virtioLoadDone");
    1427 
     1439#endif
    14281440    rc = pVirtio->virtioCallbacks.pfnSSMDevLoadDone(pDevIns, pSSM);
    14291441
     
    14371449
    14381450    int rc = VINF_SUCCESS;
     1451
     1452#ifdef DEBUG
    14391453    virtioDumpState(pVirtio, "virtioLiveExec");
    1440 
     1454#endif
    14411455    rc = pVirtio->virtioCallbacks.pfnSSMDevLiveExec(pDevIns, pSSM, uPass);
    14421456
     
    14731487    }
    14741488    Log(("\n"));
     1489    RT_NOREF2(uBase, pv);
    14751490 }
    14761491
     
    14891504 */
    14901505void virtioLogMappedIoValue(const char *pszFunc, const char *pszMember, uint32_t uMemberSize,
    1491                         const void *pv, uint32_t cb, uint32_t uOffset, bool fWrite,
    1492                         bool fHasIndex, uint32_t idx)
     1506                        const void *pv, uint32_t cb, uint32_t uOffset, int fWrite,
     1507                        int fHasIndex, uint32_t idx)
    14931508{
    14941509
     
    15291544              pszIdx, uOffset, uOffset + cb, cb, pv));
    15301545    }
     1546    RT_NOREF2(fWrite, pszFunc);
    15311547}
    15321548
  • trunk/src/VBox/Devices/VirtIO/Virtio_1_0.h

    r80928 r80931  
    6565{
    6666    uint32_t  uHeadIdx;                                    /**< Head idx of associated desc chain        */
    67     uint32_t    cbVirtSrc;                                   /**< Size of virt source buffer               */
     67    uint32_t  cbVirtSrc;                                   /**< Size of virt source buffer               */
    6868    void     *pVirtSrc;                                    /**< Virt mem buf holding out data from guest */
    69     uint32_t    cbPhysDst;                                   /**< Total size of dst buffer                 */
     69    uint32_t  cbPhysDst;                                   /**< Total size of dst buffer                 */
    7070    PRTSGBUF  pSgPhysDst;                                  /**< Phys S/G buf to store result for guest   */
    7171} VIRTIO_DESC_CHAIN_T, *PVIRTIO_DESC_CHAIN_T, **PPVIRTIO_DESC_CHAIN_T;
     
    9696 * @param pClient       Pointer to opaque client data (state)
    9797 */
    98 typedef DECLCALLBACK(void)   FNVIRTIOSTATUSCHANGED(VIRTIOHANDLE hVirtio, void *pClient, bool fDriverOk);
     98typedef DECLCALLBACK(void)   FNVIRTIOSTATUSCHANGED(VIRTIOHANDLE hVirtio, void *pClient, uint32_t fDriverOk);
    9999typedef FNVIRTIOSTATUSCHANGED *PFNVIRTIOSTATUSCHANGED;
    100100
     
    140140{
    141141     DECLCALLBACKMEMBER(void, pfnVirtioStatusChanged)
    142                                   (VIRTIOHANDLE hVirtio, void *pClient, bool fDriverOk);
     142                                  (VIRTIOHANDLE hVirtio, void *pClient, uint32_t fDriverOk);
    143143     DECLCALLBACKMEMBER(void, pfnVirtioQueueNotified)
    144144                                  (VIRTIOHANDLE hVirtio, void *pClient, uint16_t qIdx);
     
    320320 */
    321321uint64_t virtioGetNegotiatedFeatures(VIRTIOHANDLE hVirtio);
    322 
    323322
    324323/** CLIENT MUST CALL ON RELOCATE CALLBACK! */
     
    383382void virtioLogMappedIoValue(const char *pszFunc, const char *pszMember, uint32_t uMemberSize,
    384383                            const void *pv, uint32_t cb, uint32_t uOffset,
    385                             bool fWrite, bool fHasIndex, uint32_t idx);
    386 
     384                            int fWrite, int fHasIndex, uint32_t idx);
    387385/**
    388386 * Does a formatted hex dump using Log(()), recommend using VIRTIO_HEX_DUMP() macro to
  • trunk/src/VBox/Devices/VirtIO/Virtio_1_0_impl.h

    r80928 r80931  
    240240/**
    241241* This macro returns true if the implied parameter GCPhysAddr address and access length are
    242 * within mapped capability struct specified with the explicit parameters.
     242* within the range of the mapped capability struct specified with the explicit parameters.
    243243*
    244244* Actual Parameters:
     
    283283#define LOG_COMMON_CFG_ACCESS_INDEXED(member, idx) \
    284284        virtioLogMappedIoValue(__FUNCTION__, #member, RT_SIZEOFMEMB(VIRTIO_PCI_COMMON_CFG_T, member), \
    285                                pv, cb, uIntraOff, fWrite, true, idx);
     285                                pv, cb, uIntraOff, fWrite, true, idx);
    286286
    287287#define COMMON_CFG_ACCESSOR(member) \
     
    521521}
    522522
     523static int  virtioCommonCfgAccessed (PVIRTIOSTATE pVirtio, int fWrite, off_t uOffset, unsigned cb, void const *pv);
    523524static void virtioResetQueue        (PVIRTIOSTATE pVirtio, uint16_t qIdx);
    524525static void virtioNotifyGuestDriver (PVIRTIOSTATE pVirtio, uint16_t qIdx, bool fForce);
     
    526527static void virtioLowerInterrupt    (PVIRTIOSTATE pVirtio);
    527528static void virtioQueueNotified     (PVIRTIOSTATE pVirtio, uint16_t qidx, uint16_t uDescIdx);
    528 static int  virtioCommonCfgAccessed (PVIRTIOSTATE pVirtio, int fWrite, off_t uOffset, unsigned cb, void const *pv);
    529529static void virtioGuestResetted     (PVIRTIOSTATE pVirtio);
    530530
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