- Timestamp:
- Oct 12, 2016 1:11:22 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/DrvSCSI.cpp
r64221 r64226 82 82 * SCSI driver instance data. 83 83 * 84 * @implements PDMISCSICONNECTOR85 84 * @implements PDMIMEDIAEXPORT 86 85 * @implements PDMIMEDIAEX … … 100 99 /** Pointer to the attached driver's mount interface. */ 101 100 PPDMIMOUNT pDrvMount; 102 /** Pointer to the SCSI port interface of the device above. */103 PPDMISCSIPORT pDevScsiPort;104 101 /** Pointer to the extended media port interface of the device above. */ 105 102 PPDMIMEDIAEXPORT pDevMediaExPort; … … 108 105 /** pointer to the Led port interface of the dveice above. */ 109 106 PPDMILEDPORTS pLedPort; 110 /** The scsi connector interface .*/111 PDMISCSICONNECTOR ISCSIConnector;112 107 /** The media interface for the device above. */ 113 108 PDMIMEDIA IMedia; … … 624 619 } 625 620 626 static DECLCALLBACK(void) drvscsiVScsiReqCompleted(VSCSIDEVICE hVScsiDevice, void *pVScsiDeviceUser,627 void *pVScsiReqUser, int rcScsiCode, bool fRedoPossible, int rcReq)628 {629 RT_NOREF(hVScsiDevice);630 PDRVSCSI pThis = (PDRVSCSI)pVScsiDeviceUser;631 632 ASMAtomicDecU32(&pThis->StatIoDepth);633 634 pThis->pDevScsiPort->pfnSCSIRequestCompleted(pThis->pDevScsiPort, (PPDMSCSIREQUEST)pVScsiReqUser,635 rcScsiCode, fRedoPossible, rcReq);636 637 if (RT_UNLIKELY(pThis->fDummySignal) && !pThis->StatIoDepth)638 PDMDrvHlpAsyncNotificationCompleted(pThis->pDrvIns);639 }640 641 /* -=-=-=-=- ISCSIConnector -=-=-=-=- */642 643 #ifdef DEBUG644 /**645 * Dumps a SCSI request structure for debugging purposes.646 *647 * @returns nothing.648 * @param pRequest Pointer to the request to dump.649 */650 static void drvscsiDumpScsiRequest(PPDMSCSIREQUEST pRequest)651 {652 Log(("Dump for pRequest=%#p Command: %s\n", pRequest, SCSICmdText(pRequest->pbCDB[0])));653 Log(("cbCDB=%u\n", pRequest->cbCDB));654 for (uint32_t i = 0; i < pRequest->cbCDB; i++)655 Log(("pbCDB[%u]=%#x\n", i, pRequest->pbCDB[i]));656 Log(("cbScatterGather=%u\n", pRequest->cbScatterGather));657 Log(("cScatterGatherEntries=%u\n", pRequest->cScatterGatherEntries));658 /* Print all scatter gather entries. */659 for (uint32_t i = 0; i < pRequest->cScatterGatherEntries; i++)660 {661 Log(("ScatterGatherEntry[%u].cbSeg=%u\n", i, pRequest->paScatterGatherHead[i].cbSeg));662 Log(("ScatterGatherEntry[%u].pvSeg=%#p\n", i, pRequest->paScatterGatherHead[i].pvSeg));663 }664 Log(("pvUser=%#p\n", pRequest->pvUser));665 }666 #endif667 668 /** @interface_method_impl{PDMISCSICONNECTOR,pfnSCSIRequestSend} */669 static DECLCALLBACK(int) drvscsiRequestSend(PPDMISCSICONNECTOR pInterface, PPDMSCSIREQUEST pSCSIRequest)670 {671 int rc;672 PDRVSCSI pThis = RT_FROM_MEMBER(pInterface, DRVSCSI, ISCSIConnector);673 VSCSIREQ hVScsiReq;674 675 #ifdef DEBUG676 drvscsiDumpScsiRequest(pSCSIRequest);677 #endif678 679 rc = VSCSIDeviceReqCreate(pThis->hVScsiDevice, &hVScsiReq,680 pSCSIRequest->uLogicalUnit,681 pSCSIRequest->pbCDB,682 pSCSIRequest->cbCDB,683 pSCSIRequest->cbScatterGather,684 pSCSIRequest->cScatterGatherEntries,685 pSCSIRequest->paScatterGatherHead,686 pSCSIRequest->pbSenseBuffer,687 pSCSIRequest->cbSenseBuffer,688 pSCSIRequest);689 if (RT_FAILURE(rc))690 return rc;691 692 ASMAtomicIncU32(&pThis->StatIoDepth);693 rc = VSCSIDeviceReqEnqueue(pThis->hVScsiDevice, hVScsiReq);694 695 return rc;696 }697 698 /** @interface_method_impl{PDMISCSICONNECTOR,pfnQueryLUNType} */699 static DECLCALLBACK(int) drvscsiQueryLUNType(PPDMISCSICONNECTOR pInterface, uint32_t iLun, PPDMSCSILUNTYPE pLunType)700 {701 PDRVSCSI pThis = RT_FROM_MEMBER(pInterface, DRVSCSI, ISCSIConnector);702 VSCSILUNTYPE enmLunType;703 704 int rc = VSCSIDeviceLunQueryType(pThis->hVScsiDevice, iLun, &enmLunType);705 if (RT_FAILURE(rc))706 return rc;707 708 switch (enmLunType)709 {710 case VSCSILUNTYPE_SBC: *pLunType = PDMSCSILUNTYPE_SBC; break;711 case VSCSILUNTYPE_MMC: *pLunType = PDMSCSILUNTYPE_MMC; break;712 case VSCSILUNTYPE_SSC: *pLunType = PDMSCSILUNTYPE_SSC; break;713 default: *pLunType = PDMSCSILUNTYPE_INVALID;714 }715 716 return rc;717 }718 621 719 622 /* -=-=-=-=- IMedia -=-=-=-=- */ … … 1089 992 Assert(RT_SUCCESS(rc) || rc == VERR_PDM_MEDIA_LOCKED || rc == VERR_PDM_MEDIA_NOT_MOUNTED); 1090 993 if (RT_SUCCESS(rc)) 1091 { 1092 if (pThis->pDevMediaExPort) 1093 pThis->pDevMediaExPort->pfnMediumEjected(pThis->pDevMediaExPort); 1094 } 994 pThis->pDevMediaExPort->pfnMediumEjected(pThis->pDevMediaExPort); 1095 995 1096 996 pEjectState->rcReq = rc; … … 1111 1011 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMOUNT, pThis->pDrvMount); 1112 1012 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pDrvIns->IBase); 1113 PDMIBASE_RETURN_INTERFACE(pszIID, PDMISCSICONNECTOR, &pThis->ISCSIConnector);1114 1013 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMEDIAEX, pThis->pDevMediaExPort ? &pThis->IMediaEx : NULL); 1115 1014 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMEDIA, pThis->pDrvMedia ? &pThis->IMedia : NULL); … … 1125 1024 PDRVSCSI pThis = RT_FROM_MEMBER(pInterface, DRVSCSI, IPort); 1126 1025 1127 if (pThis->pDevScsiPort) 1128 return pThis->pDevScsiPort->pfnQueryDeviceLocation(pThis->pDevScsiPort, ppcszController, 1129 piInstance, piLUN); 1130 if (pThis->pDevMediaPort) 1131 return pThis->pDevMediaPort->pfnQueryDeviceLocation(pThis->pDevMediaPort, ppcszController, 1132 piInstance, piLUN); 1133 1134 return VERR_NOT_SUPPORTED; 1026 return pThis->pDevMediaPort->pfnQueryDeviceLocation(pThis->pDevMediaPort, ppcszController, 1027 piInstance, piLUN); 1135 1028 } 1136 1029 … … 1365 1258 */ 1366 1259 pThis->pDrvIns = pDrvIns; 1367 pThis->ISCSIConnector.pfnSCSIRequestSend = drvscsiRequestSend;1368 pThis->ISCSIConnector.pfnQueryLUNType = drvscsiQueryLUNType;1369 1260 1370 1261 pDrvIns->IBase.pfnQueryInterface = drvscsiQueryInterface; … … 1420 1311 pThis->IPortEx.pfnIoReqStateChanged = drvscsiIoReqStateChanged; 1421 1312 1422 /* Query the optional SCSI port interface above. */1423 pThis->pDevScsiPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMISCSIPORT);1424 1425 1313 /* Query the optional media port interface above. */ 1426 1314 pThis->pDevMediaPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMIMEDIAPORT); … … 1429 1317 pThis->pDevMediaExPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMIMEDIAEXPORT); 1430 1318 1431 AssertMsgReturn(pThis->pDev ScsiPort || pThis->pDevMediaExPort,1432 ("Missing SCSI orextended media port interface above\n"), VERR_PDM_MISSING_INTERFACE);1319 AssertMsgReturn(pThis->pDevMediaExPort, 1320 ("Missing extended media port interface above\n"), VERR_PDM_MISSING_INTERFACE); 1433 1321 1434 1322 /* Query the optional LED interface above. */ … … 1506 1394 pThis->VScsiIoCallbacks.pfnVScsiLunMediumSetLock = drvscsiSetLock; 1507 1395 1508 rc = VSCSIDeviceCreate(&pThis->hVScsiDevice, 1509 pThis->pDevMediaExPort 1510 ? drvscsiIoReqVScsiReqCompleted 1511 : drvscsiVScsiReqCompleted, 1512 pThis); 1396 rc = VSCSIDeviceCreate(&pThis->hVScsiDevice, drvscsiIoReqVScsiReqCompleted, pThis); 1513 1397 AssertMsgReturn(RT_SUCCESS(rc), ("Failed to create VSCSI device rc=%Rrc\n", rc), rc); 1514 1398 rc = VSCSILunCreate(&pThis->hVScsiLun, enmLunType, &pThis->VScsiIoCallbacks, … … 1538 1422 uint32_t iCtrlLun = 0; 1539 1423 1540 if (pThis->pDevScsiPort) 1541 rc = pThis->pDevScsiPort->pfnQueryDeviceLocation(pThis->pDevScsiPort, &pszCtrl, &iCtrlInstance, &iCtrlLun); 1542 if (pThis->pDevMediaPort) 1543 rc = pThis->pDevMediaPort->pfnQueryDeviceLocation(pThis->pDevMediaPort, &pszCtrl, &iCtrlInstance, &iCtrlLun); 1424 rc = pThis->pDevMediaPort->pfnQueryDeviceLocation(pThis->pDevMediaPort, &pszCtrl, &iCtrlInstance, &iCtrlLun); 1544 1425 if (RT_SUCCESS(rc)) 1545 1426 {
Note:
See TracChangeset
for help on using the changeset viewer.