Changeset 59248 in vbox for trunk/src/VBox/Devices/Storage/DrvSCSI.cpp
- Timestamp:
- Jan 4, 2016 2:13:22 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/DrvSCSI.cpp
r59152 r59248 44 44 * 45 45 * @implements PDMISCSICONNECTOR 46 * @implements PDMI BLOCKASYNCPORT46 * @implements PDMIMEDIAASYNCPORT 47 47 * @implements PDMIMOUNTNOTIFY 48 48 */ … … 55 55 PPDMIBASE pDrvBase; 56 56 /** Pointer to the attached driver's block interface. */ 57 PPDMI BLOCK pDrvBlock;57 PPDMIMEDIA pDrvMedia; 58 58 /** Pointer to the attached driver's async block interface. */ 59 PPDMIBLOCKASYNC pDrvBlockAsync; 60 /** Pointer to the attached driver's block bios interface. */ 61 PPDMIBLOCKBIOS pDrvBlockBios; 59 PPDMIMEDIAASYNC pDrvMediaAsync; 62 60 /** Pointer to the attached driver's mount interface. */ 63 61 PPDMIMOUNT pDrvMount; … … 68 66 /** The scsi connector interface .*/ 69 67 PDMISCSICONNECTOR ISCSIConnector; 70 /** The blockport interface. */71 PDMI BLOCKPORT IPort;72 /** The optional blockasync port interface. */73 PDMI BLOCKASYNCPORT IPortAsync;68 /** The media port interface. */ 69 PDMIMEDIAPORT IPort; 70 /** The optional media async port interface. */ 71 PDMIMEDIAASYNCPORT IPortAsync; 74 72 /** The mount notify interface. */ 75 73 PDMIMOUNTNOTIFY IMountNotify; … … 113 111 #define PDMISCSICONNECTOR_2_DRVSCSI(pInterface) ( (PDRVSCSI)((uintptr_t)pInterface - RT_OFFSETOF(DRVSCSI, ISCSIConnector)) ) 114 112 /** Converts a pointer to DRVSCSI::IPortAsync to a PDRVSCSI. */ 115 #define PDMI BLOCKASYNCPORT_2_DRVSCSI(pInterface) ( (PDRVSCSI)((uintptr_t)pInterface - RT_OFFSETOF(DRVSCSI, IPortAsync)) )113 #define PDMIMEDIAASYNCPORT_2_DRVSCSI(pInterface) ( (PDRVSCSI)((uintptr_t)pInterface - RT_OFFSETOF(DRVSCSI, IPortAsync)) ) 116 114 /** Converts a pointer to DRVSCSI::IMountNotify to PDRVSCSI. */ 117 115 #define PDMIMOUNTNOTIFY_2_DRVSCSI(pInterface) ( (PDRVSCSI)((uintptr_t)pInterface - RT_OFFSETOF(DRVSCSI, IMountNotify)) ) 118 116 /** Converts a pointer to DRVSCSI::IPort to a PDRVSCSI. */ 119 #define PDMI BLOCKPORT_2_DRVSCSI(pInterface) ( (PDRVSCSI)((uintptr_t)pInterface - RT_OFFSETOF(DRVSCSI, IPort)) )117 #define PDMIMEDIAPORT_2_DRVSCSI(pInterface) ( (PDRVSCSI)((uintptr_t)pInterface - RT_OFFSETOF(DRVSCSI, IPort)) ) 120 118 121 119 static bool drvscsiIsRedoPossible(int rc) … … 142 140 case VSCSIIOREQTXDIR_FLUSH: 143 141 { 144 rc = pThis->pDrv Block->pfnFlush(pThis->pDrvBlock);142 rc = pThis->pDrvMedia->pfnFlush(pThis->pDrvMedia); 145 143 if ( RT_FAILURE(rc) 146 144 && pThis->cErrors++ < MAX_LOG_REL_ERRORS) … … 171 169 { 172 170 pThis->pLed->Asserted.s.fReading = pThis->pLed->Actual.s.fReading = 1; 173 rc = pThis->pDrv Block->pfnRead(pThis->pDrvBlock, uOffset,171 rc = pThis->pDrvMedia->pfnRead(pThis->pDrvMedia, uOffset, 174 172 paSeg->pvSeg, cbProcess); 175 173 pThis->pLed->Actual.s.fReading = 0; … … 181 179 { 182 180 pThis->pLed->Asserted.s.fWriting = pThis->pLed->Actual.s.fWriting = 1; 183 rc = pThis->pDrv Block->pfnWrite(pThis->pDrvBlock, uOffset,181 rc = pThis->pDrvMedia->pfnWrite(pThis->pDrvMedia, uOffset, 184 182 paSeg->pvSeg, cbProcess); 185 183 pThis->pLed->Actual.s.fWriting = 0; … … 217 215 218 216 pThis->pLed->Asserted.s.fWriting = pThis->pLed->Actual.s.fWriting = 1; 219 rc = pThis->pDrv Block->pfnDiscard(pThis->pDrvBlock, paRanges, cRanges);217 rc = pThis->pDrvMedia->pfnDiscard(pThis->pDrvMedia, paRanges, cRanges); 220 218 pThis->pLed->Actual.s.fWriting = 0; 221 219 … … 243 241 PDRVSCSI pThis = (PDRVSCSI)pvScsiLunUser; 244 242 245 *pcbSize = pThis->pDrv Block->pfnGetSize(pThis->pDrvBlock);243 *pcbSize = pThis->pDrvMedia->pfnGetSize(pThis->pDrvMedia); 246 244 247 245 return VINF_SUCCESS; … … 253 251 PDRVSCSI pThis = (PDRVSCSI)pvScsiLunUser; 254 252 255 *pcbSectorSize = pThis->pDrv Block->pfnGetSectorSize(pThis->pDrvBlock);253 *pcbSectorSize = pThis->pDrvMedia->pfnGetSectorSize(pThis->pDrvMedia); 256 254 257 255 return VINF_SUCCESS; … … 269 267 } 270 268 271 static DECLCALLBACK(int) drvscsiTransferCompleteNotify(PPDMI BLOCKASYNCPORT pInterface, void *pvUser, int rc)272 { 273 PDRVSCSI pThis = PDMI BLOCKASYNCPORT_2_DRVSCSI(pInterface);269 static DECLCALLBACK(int) drvscsiTransferCompleteNotify(PPDMIMEDIAASYNCPORT pInterface, void *pvUser, int rc) 270 { 271 PDRVSCSI pThis = PDMIMEDIAASYNCPORT_2_DRVSCSI(pInterface); 274 272 VSCSIIOREQ hVScsiIoReq = (VSCSIIOREQ)pvUser; 275 273 VSCSIIOREQTXDIR enmTxDir = VSCSIIoReqTxDirGet(hVScsiIoReq); … … 332 330 PDRVSCSI pThis = (PDRVSCSI)pvScsiLunUser; 333 331 334 if (pThis->pDrv BlockAsync)332 if (pThis->pDrvMediaAsync) 335 333 { 336 334 /* async I/O path. */ … … 345 343 case VSCSIIOREQTXDIR_FLUSH: 346 344 { 347 rc = pThis->pDrv BlockAsync->pfnStartFlush(pThis->pDrvBlockAsync, hVScsiIoReq);345 rc = pThis->pDrvMediaAsync->pfnStartFlush(pThis->pDrvMediaAsync, hVScsiIoReq); 348 346 if ( RT_FAILURE(rc) 349 347 && rc != VERR_VD_ASYNC_IO_IN_PROGRESS … … 362 360 363 361 pThis->pLed->Asserted.s.fWriting = pThis->pLed->Actual.s.fWriting = 1; 364 rc = pThis->pDrv BlockAsync->pfnStartDiscard(pThis->pDrvBlockAsync, paRanges, cRanges, hVScsiIoReq);362 rc = pThis->pDrvMediaAsync->pfnStartDiscard(pThis->pDrvMediaAsync, paRanges, cRanges, hVScsiIoReq); 365 363 if ( RT_FAILURE(rc) 366 364 && rc != VERR_VD_ASYNC_IO_IN_PROGRESS … … 386 384 { 387 385 pThis->pLed->Asserted.s.fReading = pThis->pLed->Actual.s.fReading = 1; 388 rc = pThis->pDrv BlockAsync->pfnStartRead(pThis->pDrvBlockAsync, uOffset,386 rc = pThis->pDrvMediaAsync->pfnStartRead(pThis->pDrvMediaAsync, uOffset, 389 387 paSeg, cSeg, cbTransfer, 390 388 hVScsiIoReq); … … 394 392 { 395 393 pThis->pLed->Asserted.s.fWriting = pThis->pLed->Actual.s.fWriting = 1; 396 rc = pThis->pDrv BlockAsync->pfnStartWrite(pThis->pDrvBlockAsync, uOffset,394 rc = pThis->pDrvMediaAsync->pfnStartWrite(pThis->pDrvMediaAsync, uOffset, 397 395 paSeg, cSeg, cbTransfer, 398 396 hVScsiIoReq); … … 464 462 *pfFeatures = 0; 465 463 466 if ( pThis->pDrv Block->pfnDiscard467 || ( pThis->pDrv BlockAsync468 && pThis->pDrv BlockAsync->pfnStartDiscard))464 if ( pThis->pDrvMedia->pfnDiscard 465 || ( pThis->pDrvMediaAsync 466 && pThis->pDrvMediaAsync->pfnStartDiscard)) 469 467 *pfFeatures |= VSCSI_LUN_FEATURE_UNMAP; 470 468 … … 682 680 683 681 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMOUNT, pThis->pDrvMount); 684 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBLOCKBIOS, pThis->pDrvBlockBios);685 682 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pDrvIns->IBase); 686 683 PDMIBASE_RETURN_INTERFACE(pszIID, PDMISCSICONNECTOR, &pThis->ISCSIConnector); 687 PDMIBASE_RETURN_INTERFACE(pszIID, PDMI BLOCKPORT, &pThis->IPort);684 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMEDIAPORT, &pThis->IPort); 688 685 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMOUNTNOTIFY, &pThis->IMountNotify); 689 PDMIBASE_RETURN_INTERFACE(pszIID, PDMI BLOCKASYNCPORT, &pThis->IPortAsync);686 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMEDIAASYNCPORT, &pThis->IPortAsync); 690 687 return NULL; 691 688 } 692 689 693 static DECLCALLBACK(int) drvscsiQueryDeviceLocation(PPDMI BLOCKPORT pInterface, const char **ppcszController,690 static DECLCALLBACK(int) drvscsiQueryDeviceLocation(PPDMIMEDIAPORT pInterface, const char **ppcszController, 694 691 uint32_t *piInstance, uint32_t *piLUN) 695 692 { 696 PDRVSCSI pThis = PDMI BLOCKPORT_2_DRVSCSI(pInterface);693 PDRVSCSI pThis = PDMIMEDIAPORT_2_DRVSCSI(pInterface); 697 694 698 695 return pThis->pDevScsiPort->pfnQueryDeviceLocation(pThis->pDevScsiPort, ppcszController, … … 711 708 712 709 /* Ignore the call if we're called while being attached. */ 713 if (!pThis->pDrv Block)710 if (!pThis->pDrvMedia) 714 711 return; 715 712 … … 742 739 PDRVSCSI pThis = PDMINS_2_DATA(pDrvIns, PDRVSCSI); 743 740 744 if (!pThis->pDrv BlockAsync)741 if (!pThis->pDrvMediaAsync) 745 742 { 746 743 if (pThis->hQueueRequests != NIL_RTREQQUEUE) … … 790 787 PDRVSCSI pThis = PDMINS_2_DATA(pDrvIns, PDRVSCSI); 791 788 792 if (pThis->pDrv BlockAsync)789 if (pThis->pDrvMediaAsync) 793 790 { 794 791 if (pThis->StatIoDepth > 0) … … 833 830 PDRVSCSI pThis = PDMINS_2_DATA(pDrvIns, PDRVSCSI); 834 831 835 if (pThis->pDrv BlockAsync)832 if (pThis->pDrvMediaAsync) 836 833 { 837 834 if (pThis->StatIoDepth > 0) … … 967 964 * Query the block and blockbios interfaces. 968 965 */ 969 pThis->pDrv Block = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIBLOCK);970 if (!pThis->pDrv Block)966 pThis->pDrvMedia = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIMEDIA); 967 if (!pThis->pDrvMedia) 971 968 { 972 969 AssertMsgFailed(("Configuration error: No block interface!\n")); 973 970 return VERR_PDM_MISSING_INTERFACE; 974 971 } 975 pThis->pDrvBlockBios = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIBLOCKBIOS);976 if (!pThis->pDrvBlockBios)977 {978 AssertMsgFailed(("Configuration error: No block BIOS interface!\n"));979 return VERR_PDM_MISSING_INTERFACE;980 }981 972 982 973 pThis->pDrvMount = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIMOUNT); 983 974 984 975 /* Try to get the optional async block interface. */ 985 pThis->pDrv BlockAsync = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIBLOCKASYNC);986 987 PDM BLOCKTYPE enmType = pThis->pDrvBlock->pfnGetType(pThis->pDrvBlock);976 pThis->pDrvMediaAsync = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIMEDIAASYNC); 977 978 PDMMEDIATYPE enmType = pThis->pDrvMedia->pfnGetType(pThis->pDrvMedia); 988 979 VSCSILUNTYPE enmLunType; 989 980 switch (enmType) 990 981 { 991 case PDM BLOCKTYPE_HARD_DISK:982 case PDMMEDIATYPE_HARD_DISK: 992 983 enmLunType = VSCSILUNTYPE_SBC; 993 984 break; 994 case PDM BLOCKTYPE_CDROM:995 case PDM BLOCKTYPE_DVD:985 case PDMMEDIATYPE_CDROM: 986 case PDMMEDIATYPE_DVD: 996 987 enmLunType = VSCSILUNTYPE_MMC; 997 988 break; … … 1001 992 enmType); 1002 993 } 1003 if ( ( enmType == PDM BLOCKTYPE_DVD1004 || enmType == PDM BLOCKTYPE_CDROM)994 if ( ( enmType == PDMMEDIATYPE_DVD 995 || enmType == PDMMEDIATYPE_CDROM) 1005 996 && !pThis->pDrvMount) 1006 997 { … … 1028 1019 if (pThis->pDrvMount) 1029 1020 { 1030 if (pThis->pDrv Block->pfnGetSize(pThis->pDrvBlock))1021 if (pThis->pDrvMedia->pfnGetSize(pThis->pDrvMedia)) 1031 1022 { 1032 1023 rc = VINF_SUCCESS; VSCSILunMountNotify(pThis->hVScsiLun); … … 1061 1052 pThis->StatIoDepth = 0; 1062 1053 1063 if (!pThis->pDrv BlockAsync)1054 if (!pThis->pDrvMediaAsync) 1064 1055 { 1065 1056 /* Create request queue. */ … … 1076 1067 LogRel(("SCSI#%d: using async I/O\n", pDrvIns->iInstance)); 1077 1068 1078 if ( pThis->pDrv Block->pfnDiscard1079 || ( pThis->pDrv BlockAsync1080 && pThis->pDrv BlockAsync->pfnStartDiscard))1069 if ( pThis->pDrvMedia->pfnDiscard 1070 || ( pThis->pDrvMediaAsync 1071 && pThis->pDrvMediaAsync->pfnStartDiscard)) 1081 1072 LogRel(("SCSI#%d: Enabled UNMAP support\n", pDrvIns->iInstance)); 1082 1073
Note:
See TracChangeset
for help on using the changeset viewer.