Changeset 80589 in vbox for trunk/src/VBox/Devices/Storage/VSCSI
- Timestamp:
- Sep 4, 2019 6:20:28 PM (5 years ago)
- Location:
- trunk/src/VBox/Devices/Storage/VSCSI
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/VSCSI/VSCSIDevice.cpp
r80541 r80589 67 67 SCSIINQUIRYDATA ScsiInquiryReply; 68 68 69 vscsiReqSetXferDir(pVScsiReq, VSCSIXFERDIR_T2I); 69 70 vscsiReqSetXferSize(pVScsiReq, RT_MIN(sizeof(SCSIINQUIRYDATA), scsiBE2H_U16(&pVScsiReq->pbCDB[3]))); 70 71 memset(&ScsiInquiryReply, 0, sizeof(ScsiInquiryReply)); … … 86 87 * to return an error. 87 88 */ 89 vscsiReqSetXferDir(pVScsiReq, VSCSIXFERDIR_T2I); 88 90 vscsiReqSetXferSize(pVScsiReq, scsiBE2H_U32(&pVScsiReq->pbCDB[6])); 89 91 if (pVScsiReq->cbXfer < 16) … … 106 108 case SCSI_TEST_UNIT_READY: 107 109 { 110 vscsiReqSetXferDir(pVScsiReq, VSCSIXFERDIR_NONE); 108 111 if ( vscsiDeviceLunIsPresent(pVScsiDevice, pVScsiReq->iLun) 109 112 && pVScsiDevice->papVScsiLun[pVScsiReq->iLun]->fReady) … … 115 118 case SCSI_REQUEST_SENSE: 116 119 { 120 vscsiReqSetXferDir(pVScsiReq, VSCSIXFERDIR_T2I); 117 121 vscsiReqSetXferSize(pVScsiReq, pVScsiReq->pbCDB[4]); 118 122 … … 183 187 pVScsiDevice->pfnVScsiReqCompleted(pVScsiDevice, pVScsiDevice->pvVScsiDeviceUser, 184 188 pVScsiReq->pvVScsiReqUser, rcScsiCode, fRedoPossible, 185 rcReq, pVScsiReq->cbXfer );189 rcReq, pVScsiReq->cbXfer, pVScsiReq->enmXferDir, pVScsiReq->cbSenseWritten); 186 190 187 191 if (pVScsiReq->pvLun) … … 411 415 pVScsiReq->cbXfer = 0; 412 416 pVScsiReq->pvLun = NULL; 417 pVScsiReq->enmXferDir = VSCSIXFERDIR_UNKNOWN; 418 pVScsiReq->cbSenseWritten = 0; 413 419 RTSgBufInit(&pVScsiReq->SgBuf, paSGList, cSGListEntries); 414 420 -
trunk/src/VBox/Devices/Storage/VSCSI/VSCSIInternal.h
r76565 r80589 126 126 /** Transfer size determined from the CDB. */ 127 127 size_t cbXfer; 128 /** Number of bytes of sense data written. */ 129 size_t cbSenseWritten; 130 /** Transfer direction as indicated by the CDB. */ 131 VSCSIXFERDIR enmXferDir; 128 132 /** Pointer to the opaque data which may be allocated by the LUN 129 133 * the request is for. */ … … 491 495 492 496 /** 497 * Sets the transfer direction for the given request. 498 * 499 * @returns nothing. 500 * @param pVScsiReq The SCSI request. 501 * @param cbXfer The transfer size for the request. 502 */ 503 DECLINLINE(void) vscsiReqSetXferDir(PVSCSIREQINT pVScsiReq, VSCSIXFERDIR enmXferDir) 504 { 505 pVScsiReq->enmXferDir = enmXferDir; 506 } 507 508 /** 493 509 * Wrapper for the set I/O request allocation size I/O callback. 494 510 * -
trunk/src/VBox/Devices/Storage/VSCSI/VSCSILunMmc.cpp
r80541 r80589 1086 1086 case SCSI_TEST_UNIT_READY: 1087 1087 Assert(!pVScsiLunMmc->Core.fReady); /* Only should get here if LUN isn't ready. */ 1088 vscsiReqSetXferDir(pVScsiReq, VSCSIXFERDIR_NONE); 1088 1089 rcReq = vscsiLunReqSenseErrorSet(pVScsiLun, pVScsiReq, SCSI_SENSE_NOT_READY, SCSI_ASC_MEDIUM_NOT_PRESENT, 0x00); 1089 1090 break; … … 1093 1094 SCSIINQUIRYDATA ScsiInquiryReply; 1094 1095 1096 vscsiReqSetXferDir(pVScsiReq, VSCSIXFERDIR_T2I); 1095 1097 vscsiReqSetXferSize(pVScsiReq, RT_MIN(sizeof(SCSIINQUIRYDATA), scsiBE2H_U16(&pVScsiReq->pbCDB[3]))); 1096 1098 memset(&ScsiInquiryReply, 0, sizeof(ScsiInquiryReply)); … … 1122 1124 uint8_t aReply[8]; 1123 1125 memset(aReply, 0, sizeof(aReply)); 1126 vscsiReqSetXferDir(pVScsiReq, VSCSIXFERDIR_T2I); 1124 1127 vscsiReqSetXferSize(pVScsiReq, sizeof(aReply)); 1125 1128 … … 1144 1147 bool fValid = false; 1145 1148 1149 vscsiReqSetXferDir(pVScsiReq, VSCSIXFERDIR_T2I); 1146 1150 vscsiReqSetXferSize(pVScsiReq, pVScsiReq->pbCDB[4]); 1147 1151 memset(aReply, 0, sizeof(aReply)); … … 1176 1180 { 1177 1181 size_t cbMax = scsiBE2H_U16(&pVScsiReq->pbCDB[7]); 1182 vscsiReqSetXferDir(pVScsiReq, VSCSIXFERDIR_T2I); 1178 1183 vscsiReqSetXferSize(pVScsiReq, cbMax); 1179 1184 rcReq = vscsiLunMmcModeSense10(pVScsiLunMmc, pVScsiReq, cbMax); … … 1183 1188 { 1184 1189 uint32_t uLba = scsiBE2H_U32(&pVScsiReq->pbCDB[2]); 1190 1191 vscsiReqSetXferDir(pVScsiReq, VSCSIXFERDIR_NONE); 1185 1192 if (uLba > pVScsiLunMmc->cSectors) 1186 1193 rcReq = vscsiLunReqSenseErrorSet(pVScsiLun, pVScsiReq, SCSI_SENSE_ILLEGAL_REQUEST, … … 1193 1200 { 1194 1201 /** @todo implement!! */ 1202 vscsiReqSetXferDir(pVScsiReq, VSCSIXFERDIR_I2T); 1195 1203 vscsiReqSetXferSize(pVScsiReq, pVScsiReq->pbCDB[4]); 1196 1204 rcReq = vscsiLunReqSenseOkSet(pVScsiLun, pVScsiReq); … … 1394 1402 uint8_t uDataMode = pVScsiReq->pbCDB[1] & 0x1f; 1395 1403 1404 vscsiReqSetXferDir(pVScsiReq, VSCSIXFERDIR_T2I); 1396 1405 vscsiReqSetXferSize(pVScsiReq, scsiBE2H_U16(&pVScsiReq->pbCDB[6])); 1397 1406 … … 1425 1434 { 1426 1435 int rc2 = VINF_SUCCESS; 1436 1437 vscsiReqSetXferDir(pVScsiReq, VSCSIXFERDIR_NONE); 1427 1438 switch (pVScsiReq->pbCDB[4] & 3) 1428 1439 { … … 1448 1459 uint8_t uSubPageCode = pVScsiReq->pbCDB[3]; 1449 1460 1461 vscsiReqSetXferDir(pVScsiReq, VSCSIXFERDIR_T2I); 1450 1462 vscsiReqSetXferSize(pVScsiReq, scsiBE2H_U16(&pVScsiReq->pbCDB[7])); 1451 1463 … … 1487 1499 /* Leave the rest 0 */ 1488 1500 1501 vscsiReqSetXferDir(pVScsiReq, VSCSIXFERDIR_T2I); 1489 1502 vscsiReqSetXferSize(pVScsiReq, sizeof(aReply)); 1490 1503 RTSgBufCopyFromBuf(&pVScsiReq->SgBuf, aReply, sizeof(aReply)); … … 1515 1528 fMSF = (pVScsiReq->pbCDB[1] >> 1) & 1; 1516 1529 1530 vscsiReqSetXferDir(pVScsiReq, VSCSIXFERDIR_T2I); 1517 1531 vscsiReqSetXferSize(pVScsiReq, cbMax); 1518 1532 switch (format) … … 1537 1551 size_t cbMax = scsiBE2H_U16(&pVScsiReq->pbCDB[7]); 1538 1552 1553 vscsiReqSetXferDir(pVScsiReq, VSCSIXFERDIR_T2I); 1539 1554 vscsiReqSetXferSize(pVScsiReq, cbMax); 1540 1555 if (pVScsiReq->pbCDB[1] & 0x1) … … 1549 1564 uint8_t aReply[8]; 1550 1565 1566 vscsiReqSetXferDir(pVScsiReq, VSCSIXFERDIR_T2I); 1551 1567 vscsiReqSetXferSize(pVScsiReq, cbMax); 1552 1568 scsiH2BE_U16(&aReply[0], 0); … … 1566 1582 size_t cbMax = scsiBE2H_U16(&pVScsiReq->pbCDB[7]); 1567 1583 1584 vscsiReqSetXferDir(pVScsiReq, VSCSIXFERDIR_T2I); 1568 1585 vscsiReqSetXferSize(pVScsiReq, cbMax); 1569 1586 memset(aReply, '\0', sizeof(aReply)); … … 1588 1605 { 1589 1606 size_t cbMax = scsiBE2H_U16(&pVScsiReq->pbCDB[7]); 1607 1608 vscsiReqSetXferDir(pVScsiReq, VSCSIXFERDIR_T2I); 1590 1609 vscsiReqSetXferSize(pVScsiReq, cbMax); 1591 1610 rcReq = vscsiLunMmcReadTrackInformation(pVScsiLunMmc, pVScsiReq, cbMax); … … 1595 1614 { 1596 1615 size_t cbMax = scsiBE2H_U16(&pVScsiReq->pbCDB[7]); 1616 1617 vscsiReqSetXferDir(pVScsiReq, VSCSIXFERDIR_T2I); 1597 1618 vscsiReqSetXferSize(pVScsiReq, cbMax); 1598 1619 rcReq = vscsiLunMmcGetConfiguration(pVScsiLunMmc, pVScsiReq, cbMax); … … 1602 1623 { 1603 1624 size_t cbMax = scsiBE2H_U16(&pVScsiReq->pbCDB[8]); 1625 1626 vscsiReqSetXferDir(pVScsiReq, VSCSIXFERDIR_T2I); 1604 1627 vscsiReqSetXferSize(pVScsiReq, cbMax); 1605 1628 rcReq = vscsiLunMmcReadDvdStructure(pVScsiLunMmc, pVScsiReq, cbMax); … … 1617 1640 __FUNCTION__, uLbaStart, cSectorTransfer)); 1618 1641 1642 vscsiReqSetXferDir(pVScsiReq, enmTxDir == VSCSIIOREQTXDIR_WRITE ? VSCSIXFERDIR_I2T : VSCSIXFERDIR_T2I); 1619 1643 vscsiReqSetXferSize(pVScsiReq, cSectorTransfer * cbSector); 1620 1644 if (RT_UNLIKELY(uLbaStart + cSectorTransfer > pVScsiLunMmc->cSectors)) -
trunk/src/VBox/Devices/Storage/VSCSI/VSCSILunSbc.cpp
r80541 r80589 201 201 case SCSI_INQUIRY: 202 202 { 203 vscsiReqSetXferDir(pVScsiReq, VSCSIXFERDIR_T2I); 203 204 vscsiReqSetXferSize(pVScsiReq, RT_MIN(sizeof(SCSIINQUIRYDATA), scsiBE2H_U16(&pVScsiReq->pbCDB[3]))); 204 205 … … 252 253 memset(aReply, 0, sizeof(aReply)); 253 254 255 vscsiReqSetXferDir(pVScsiReq, VSCSIXFERDIR_T2I); 254 256 vscsiReqSetXferSize(pVScsiReq, sizeof(aReply)); 255 257 … … 274 276 bool fValid = false; 275 277 278 vscsiReqSetXferDir(pVScsiReq, VSCSIXFERDIR_T2I); 276 279 vscsiReqSetXferSize(pVScsiReq, pVScsiReq->pbCDB[4]); 277 280 memset(aReply, 0, sizeof(aReply)); … … 312 315 size_t cbList = pVScsiReq->pbCDB[4]; 313 316 317 vscsiReqSetXferDir(pVScsiReq, VSCSIXFERDIR_I2T); 314 318 vscsiReqSetXferSize(pVScsiReq, pVScsiReq->pbCDB[4]); 315 319 … … 405 409 uint8_t uDataMode = pVScsiReq->pbCDB[1] & 0x1f; 406 410 411 vscsiReqSetXferDir(pVScsiReq, VSCSIXFERDIR_T2I); 407 412 vscsiReqSetXferSize(pVScsiReq, scsiBE2H_U16(&pVScsiReq->pbCDB[6])); 408 413 … … 437 442 case SCSI_START_STOP_UNIT: 438 443 { 444 vscsiReqSetXferDir(pVScsiReq, VSCSIXFERDIR_NONE); 439 445 vscsiReqSetXferSize(pVScsiReq, 0); 440 446 rcReq = vscsiLunReqSenseOkSet(pVScsiLun, pVScsiReq); … … 446 452 uint8_t uSubPageCode = pVScsiReq->pbCDB[3]; 447 453 454 vscsiReqSetXferDir(pVScsiReq, VSCSIXFERDIR_T2I); 448 455 vscsiReqSetXferSize(pVScsiReq, scsiBE2H_U16(&pVScsiReq->pbCDB[7])); 449 456 … … 486 493 /* Leave the rest 0 */ 487 494 495 vscsiReqSetXferDir(pVScsiReq, VSCSIXFERDIR_T2I); 488 496 vscsiReqSetXferSize(pVScsiReq, sizeof(aReply)); 489 497 RTSgBufCopyFromBuf(&pVScsiReq->SgBuf, aReply, sizeof(aReply)); … … 505 513 506 514 /* Copy the header. */ 515 vscsiReqSetXferDir(pVScsiReq, VSCSIXFERDIR_I2T); 507 516 vscsiReqSetXferSize(pVScsiReq, cbList); 508 517 cbCopied = RTSgBufCopyToBuf(&pVScsiReq->SgBuf, &abHdr[0], sizeof(abHdr)); … … 570 579 if (RT_UNLIKELY(uLbaStart + cSectorTransfer > pVScsiLunSbc->cSectors)) 571 580 { 581 vscsiReqSetXferDir(pVScsiReq, VSCSIXFERDIR_NONE); 572 582 rcReq = vscsiLunReqSenseErrorSet(pVScsiLun, pVScsiReq, SCSI_SENSE_ILLEGAL_REQUEST, SCSI_ASC_LOGICAL_BLOCK_OOR, 0x00); 573 583 vscsiDeviceReqComplete(pVScsiLun->pVScsiDevice, pVScsiReq, rcReq, false, VINF_SUCCESS); … … 576 586 { 577 587 /* A 0 transfer length is not an error. */ 588 vscsiReqSetXferDir(pVScsiReq, VSCSIXFERDIR_NONE); 578 589 rcReq = vscsiLunReqSenseOkSet(pVScsiLun, pVScsiReq); 579 590 vscsiDeviceReqComplete(pVScsiLun->pVScsiDevice, pVScsiReq, rcReq, false, VINF_SUCCESS); … … 587 598 rcReq = vscsiLunReqSenseErrorSet(pVScsiLun, pVScsiReq, SCSI_SENSE_DATA_PROTECT, SCSI_ASC_WRITE_PROTECTED, 0x00); 588 599 else 600 { 601 vscsiReqSetXferDir(pVScsiReq, enmTxDir == VSCSIIOREQTXDIR_WRITE ? VSCSIXFERDIR_I2T : VSCSIXFERDIR_T2I); 589 602 rc = vscsiIoReqTransferEnqueue(pVScsiLun, pVScsiReq, enmTxDir, 590 603 uLbaStart * 512, cSectorTransfer * 512); 604 } 591 605 } 592 606 } … … 594 608 { 595 609 /* Enqueue flush */ 610 vscsiReqSetXferDir(pVScsiReq, VSCSIXFERDIR_NONE); 596 611 vscsiReqSetXferSize(pVScsiReq, 0); 597 612 rc = vscsiIoReqFlushEnqueue(pVScsiLun, pVScsiReq); -
trunk/src/VBox/Devices/Storage/VSCSI/VSCSISense.cpp
r76553 r80589 44 44 45 45 if (pVScsiReq->pbSense && pVScsiReq->cbSense) 46 memcpy(pVScsiReq->pbSense, pVScsiSense->abSenseBuf, RT_MIN(sizeof(pVScsiSense->abSenseBuf), pVScsiReq->cbSense)); 46 { 47 pVScsiReq->cbSenseWritten = RT_MIN(sizeof(pVScsiSense->abSenseBuf), pVScsiReq->cbSense); 48 memcpy(pVScsiReq->pbSense, pVScsiSense->abSenseBuf, pVScsiReq->cbSenseWritten); 49 } 47 50 48 51 return SCSI_STATUS_OK; … … 59 62 60 63 if (pVScsiReq->pbSense && pVScsiReq->cbSense) 61 memcpy(pVScsiReq->pbSense, pVScsiSense->abSenseBuf, RT_MIN(sizeof(pVScsiSense->abSenseBuf), pVScsiReq->cbSense)); 64 { 65 pVScsiReq->cbSenseWritten = RT_MIN(sizeof(pVScsiSense->abSenseBuf), pVScsiReq->cbSense); 66 memcpy(pVScsiReq->pbSense, pVScsiSense->abSenseBuf, pVScsiReq->cbSenseWritten); 67 } 62 68 63 69 return SCSI_STATUS_CHECK_CONDITION; … … 75 81 76 82 if (pVScsiReq->pbSense && pVScsiReq->cbSense) 77 memcpy(pVScsiReq->pbSense, pVScsiSense->abSenseBuf, RT_MIN(sizeof(pVScsiSense->abSenseBuf), pVScsiReq->cbSense)); 83 { 84 pVScsiReq->cbSenseWritten = RT_MIN(sizeof(pVScsiSense->abSenseBuf), pVScsiReq->cbSense); 85 memcpy(pVScsiReq->pbSense, pVScsiSense->abSenseBuf, pVScsiReq->cbSenseWritten); 86 } 78 87 79 88 return SCSI_STATUS_CHECK_CONDITION;
Note:
See TracChangeset
for help on using the changeset viewer.