- Timestamp:
- Jan 4, 2017 2:07:27 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/DrvHostDVD.cpp
r65083 r65109 31 31 #include <iprt/critsect.h> 32 32 #include <VBox/scsi.h> 33 #include <VBox/scsiinline.h> 33 34 34 35 #include "VBoxDD.h" … … 60 61 *********************************************************************************************************************************/ 61 62 62 DECLINLINE(void) drvHostDvdH2BE_U16(uint8_t *pbBuf, uint16_t val)63 {64 pbBuf[0] = val >> 8;65 pbBuf[1] = val;66 }67 68 69 DECLINLINE(void) drvHostDvdH2BE_U24(uint8_t *pbBuf, uint32_t val)70 {71 pbBuf[0] = val >> 16;72 pbBuf[1] = val >> 8;73 pbBuf[2] = val;74 }75 76 77 DECLINLINE(void) drvHostDvdH2BE_U32(uint8_t *pbBuf, uint32_t val)78 {79 pbBuf[0] = val >> 24;80 pbBuf[1] = val >> 16;81 pbBuf[2] = val >> 8;82 pbBuf[3] = val;83 }84 85 86 DECLINLINE(uint16_t) drvHostDvdBE2H_U16(const uint8_t *pbBuf)87 {88 return (pbBuf[0] << 8) | pbBuf[1];89 }90 91 92 DECLINLINE(uint32_t) drvHostDvdBE2H_U24(const uint8_t *pbBuf)93 {94 return (pbBuf[0] << 16) | (pbBuf[1] << 8) | pbBuf[2];95 }96 97 98 DECLINLINE(uint32_t) drvHostDvdBE2H_U32(const uint8_t *pbBuf)99 {100 return (pbBuf[0] << 24) | (pbBuf[1] << 16) | (pbBuf[2] << 8) | pbBuf[3];101 }102 103 104 DECLINLINE(void) drvHostDvdLBA2MSF(uint8_t *pbBuf, uint32_t iATAPILBA)105 {106 iATAPILBA += 150;107 pbBuf[0] = (iATAPILBA / 75) / 60;108 pbBuf[1] = (iATAPILBA / 75) % 60;109 pbBuf[2] = iATAPILBA % 75;110 }111 112 113 DECLINLINE(uint32_t) drvHostDvdMSF2LBA(const uint8_t *pbBuf)114 {115 return (pbBuf[0] * 60 + pbBuf[1]) * 75 + pbBuf[2];116 }117 63 118 64 static uint8_t drvHostDvdCmdOK(PDRVHOSTDVD pThis) … … 197 143 break; 198 144 case SCSI_ERASE_10: 199 uLba = drvHostDvdBE2H_U32(pbCdb + 2);200 cbXfer = drvHostDvdBE2H_U16(pbCdb + 7);145 uLba = scsiBE2H_U32(pbCdb + 2); 146 cbXfer = scsiBE2H_U16(pbCdb + 7); 201 147 enmTxDir = PDMMEDIATXDIR_TO_DEVICE; 202 148 fPassthrough = true; … … 208 154 break; 209 155 case SCSI_GET_CONFIGURATION: 210 cbXfer = drvHostDvdBE2H_U16(pbCdb + 7);156 cbXfer = scsiBE2H_U16(pbCdb + 7); 211 157 enmTxDir = PDMMEDIATXDIR_FROM_DEVICE; 212 158 fPassthrough = true; 213 159 break; 214 160 case SCSI_GET_EVENT_STATUS_NOTIFICATION: 215 cbXfer = drvHostDvdBE2H_U16(pbCdb + 7);161 cbXfer = scsiBE2H_U16(pbCdb + 7); 216 162 enmTxDir = PDMMEDIATXDIR_FROM_DEVICE; 217 163 fPassthrough = true; … … 223 169 break; 224 170 case SCSI_INQUIRY: 225 cbXfer = drvHostDvdBE2H_U16(pbCdb + 3);171 cbXfer = scsiBE2H_U16(pbCdb + 3); 226 172 enmTxDir = PDMMEDIATXDIR_FROM_DEVICE; 227 173 fPassthrough = true; 228 174 break; 229 175 case SCSI_MECHANISM_STATUS: 230 cbXfer = drvHostDvdBE2H_U16(pbCdb + 8);176 cbXfer = scsiBE2H_U16(pbCdb + 8); 231 177 enmTxDir = PDMMEDIATXDIR_FROM_DEVICE; 232 178 fPassthrough = true; 233 179 break; 234 180 case SCSI_MODE_SELECT_10: 235 cbXfer = drvHostDvdBE2H_U16(pbCdb + 7);181 cbXfer = scsiBE2H_U16(pbCdb + 7); 236 182 enmTxDir = PDMMEDIATXDIR_TO_DEVICE; 237 183 fPassthrough = true; 238 184 break; 239 185 case SCSI_MODE_SENSE_10: 240 cbXfer = drvHostDvdBE2H_U16(pbCdb + 7);186 cbXfer = scsiBE2H_U16(pbCdb + 7); 241 187 enmTxDir = PDMMEDIATXDIR_FROM_DEVICE; 242 188 fPassthrough = true; 243 189 break; 244 190 case SCSI_READ_10: 245 uLba = drvHostDvdBE2H_U32(pbCdb + 2);246 cSectors = drvHostDvdBE2H_U16(pbCdb + 7);191 uLba = scsiBE2H_U32(pbCdb + 2); 192 cSectors = scsiBE2H_U16(pbCdb + 7); 247 193 cbSector = 2048; 248 194 cbXfer = cSectors * cbSector; … … 251 197 break; 252 198 case SCSI_READ_12: 253 uLba = drvHostDvdBE2H_U32(pbCdb + 2);254 cSectors = drvHostDvdBE2H_U32(pbCdb + 6);199 uLba = scsiBE2H_U32(pbCdb + 2); 200 cSectors = scsiBE2H_U32(pbCdb + 6); 255 201 cbSector = 2048; 256 202 cbXfer = cSectors * cbSector; … … 259 205 break; 260 206 case SCSI_READ_BUFFER: 261 cbXfer = drvHostDvdBE2H_U24(pbCdb + 6);207 cbXfer = scsiBE2H_U24(pbCdb + 6); 262 208 enmTxDir = PDMMEDIATXDIR_FROM_DEVICE; 263 209 fPassthrough = true; 264 210 break; 265 211 case SCSI_READ_BUFFER_CAPACITY: 266 cbXfer = drvHostDvdBE2H_U16(pbCdb + 7);212 cbXfer = scsiBE2H_U16(pbCdb + 7); 267 213 enmTxDir = PDMMEDIATXDIR_FROM_DEVICE; 268 214 fPassthrough = true; … … 284 230 285 231 if (pbCdb[0] == SCSI_READ_CD) 286 iLbaStart = drvHostDvdBE2H_U32(&pbCdb[2]);232 iLbaStart = scsiBE2H_U32(&pbCdb[2]); 287 233 else 288 iLbaStart = drvHostDvdMSF2LBA(&pbCdb[3]);234 iLbaStart = scsiMSF2LBA(&pbCdb[3]); 289 235 290 236 if (pThis->pTrackList) … … 315 261 316 262 if (pbCdb[0] == SCSI_READ_CD) 317 cbXfer = drvHostDvdBE2H_U24(pbCdb + 6) * cbSector;263 cbXfer = scsiBE2H_U24(pbCdb + 6) * cbSector; 318 264 else /* SCSI_READ_MSF */ 319 265 { 320 cSectors = drvHostDvdMSF2LBA(pbCdb + 6) - drvHostDvdMSF2LBA(pbCdb + 3);266 cSectors = scsiMSF2LBA(pbCdb + 6) - scsiMSF2LBA(pbCdb + 3); 321 267 if (cSectors > 32) 322 268 cSectors = 32; /* Limit transfer size to 64~74K. Safety first. In any case this can only harm software doing CDDA extraction. */ … … 328 274 } 329 275 case SCSI_READ_DISC_INFORMATION: 330 cbXfer = drvHostDvdBE2H_U16(pbCdb + 7);276 cbXfer = scsiBE2H_U16(pbCdb + 7); 331 277 enmTxDir = PDMMEDIATXDIR_FROM_DEVICE; 332 278 fPassthrough = true; 333 279 break; 334 280 case SCSI_READ_DVD_STRUCTURE: 335 cbXfer = drvHostDvdBE2H_U16(pbCdb + 8);281 cbXfer = scsiBE2H_U16(pbCdb + 8); 336 282 enmTxDir = PDMMEDIATXDIR_FROM_DEVICE; 337 283 fPassthrough = true; 338 284 break; 339 285 case SCSI_READ_FORMAT_CAPACITIES: 340 cbXfer = drvHostDvdBE2H_U16(pbCdb + 7);286 cbXfer = scsiBE2H_U16(pbCdb + 7); 341 287 enmTxDir = PDMMEDIATXDIR_FROM_DEVICE; 342 288 fPassthrough = true; 343 289 break; 344 290 case SCSI_READ_SUBCHANNEL: 345 cbXfer = drvHostDvdBE2H_U16(pbCdb + 7);291 cbXfer = scsiBE2H_U16(pbCdb + 7); 346 292 enmTxDir = PDMMEDIATXDIR_FROM_DEVICE; 347 293 fPassthrough = true; 348 294 break; 349 295 case SCSI_READ_TOC_PMA_ATIP: 350 cbXfer = drvHostDvdBE2H_U16(pbCdb + 7);296 cbXfer = scsiBE2H_U16(pbCdb + 7); 351 297 enmTxDir = PDMMEDIATXDIR_FROM_DEVICE; 352 298 fPassthrough = true; 353 299 break; 354 300 case SCSI_READ_TRACK_INFORMATION: 355 cbXfer = drvHostDvdBE2H_U16(pbCdb + 7);301 cbXfer = scsiBE2H_U16(pbCdb + 7); 356 302 enmTxDir = PDMMEDIATXDIR_FROM_DEVICE; 357 303 fPassthrough = true; 358 304 break; 359 305 case SCSI_REPORT_KEY: 360 cbXfer = drvHostDvdBE2H_U16(pbCdb + 8);306 cbXfer = scsiBE2H_U16(pbCdb + 8); 361 307 enmTxDir = PDMMEDIATXDIR_FROM_DEVICE; 362 308 fPassthrough = true; … … 383 329 break; 384 330 case SCSI_SEND_CUE_SHEET: 385 cbXfer = drvHostDvdBE2H_U24(pbCdb + 6);331 cbXfer = scsiBE2H_U24(pbCdb + 6); 386 332 enmTxDir = PDMMEDIATXDIR_TO_DEVICE; 387 333 fPassthrough = true; 388 334 break; 389 335 case SCSI_SEND_DVD_STRUCTURE: 390 cbXfer = drvHostDvdBE2H_U16(pbCdb + 8);336 cbXfer = scsiBE2H_U16(pbCdb + 8); 391 337 enmTxDir = PDMMEDIATXDIR_TO_DEVICE; 392 338 fPassthrough = true; 393 339 break; 394 340 case SCSI_SEND_EVENT: 395 cbXfer = drvHostDvdBE2H_U16(pbCdb + 8);341 cbXfer = scsiBE2H_U16(pbCdb + 8); 396 342 enmTxDir = PDMMEDIATXDIR_TO_DEVICE; 397 343 fPassthrough = true; 398 344 break; 399 345 case SCSI_SEND_KEY: 400 cbXfer = drvHostDvdBE2H_U16(pbCdb + 8);346 cbXfer = scsiBE2H_U16(pbCdb + 8); 401 347 enmTxDir = PDMMEDIATXDIR_TO_DEVICE; 402 348 fPassthrough = true; 403 349 break; 404 350 case SCSI_SEND_OPC_INFORMATION: 405 cbXfer = drvHostDvdBE2H_U16(pbCdb + 7);351 cbXfer = scsiBE2H_U16(pbCdb + 7); 406 352 enmTxDir = PDMMEDIATXDIR_TO_DEVICE; 407 353 fPassthrough = true; 408 354 break; 409 355 case SCSI_SET_STREAMING: 410 cbXfer = drvHostDvdBE2H_U16(pbCdb + 9);356 cbXfer = scsiBE2H_U16(pbCdb + 9); 411 357 enmTxDir = PDMMEDIATXDIR_TO_DEVICE; 412 358 fPassthrough = true; … … 414 360 case SCSI_WRITE_10: 415 361 case SCSI_WRITE_AND_VERIFY_10: 416 uLba = drvHostDvdBE2H_U32(pbCdb + 2);417 cSectors = drvHostDvdBE2H_U16(pbCdb + 7);362 uLba = scsiBE2H_U32(pbCdb + 2); 363 cSectors = scsiBE2H_U16(pbCdb + 7); 418 364 if (pThis->pTrackList) 419 365 cbSector = ATAPIPassthroughTrackListGetSectorSizeFromLba(pThis->pTrackList, uLba); … … 425 371 break; 426 372 case SCSI_WRITE_12: 427 uLba = drvHostDvdBE2H_U32(pbCdb + 2);428 cSectors = drvHostDvdBE2H_U32(pbCdb + 6);373 uLba = scsiBE2H_U32(pbCdb + 2); 374 cSectors = scsiBE2H_U32(pbCdb + 6); 429 375 if (pThis->pTrackList) 430 376 cbSector = ATAPIPassthroughTrackListGetSectorSizeFromLba(pThis->pTrackList, uLba); … … 448 394 break; 449 395 default: 450 cbXfer = drvHostDvdBE2H_U16(pbCdb + 6);396 cbXfer = scsiBE2H_U16(pbCdb + 6); 451 397 enmTxDir = PDMMEDIATXDIR_TO_DEVICE; 452 398 fPassthrough = true; … … 455 401 break; 456 402 case SCSI_REPORT_LUNS: /* Not part of MMC-3, but used by Windows. */ 457 cbXfer = drvHostDvdBE2H_U32(pbCdb + 6);403 cbXfer = scsiBE2H_U32(pbCdb + 6); 458 404 enmTxDir = PDMMEDIATXDIR_FROM_DEVICE; 459 405 fPassthrough = true; … … 583 529 case SCSI_WRITE_10: 584 530 case SCSI_WRITE_AND_VERIFY_10: 585 iATAPILBA = drvHostDvdBE2H_U32(pbCdb + 2);586 cSectors = drvHostDvdBE2H_U16(pbCdb + 7);531 iATAPILBA = scsiBE2H_U32(pbCdb + 2); 532 cSectors = scsiBE2H_U16(pbCdb + 7); 587 533 break; 588 534 case SCSI_READ_12: 589 535 case SCSI_WRITE_12: 590 iATAPILBA = drvHostDvdBE2H_U32(pbCdb + 2);591 cSectors = drvHostDvdBE2H_U32(pbCdb + 6);536 iATAPILBA = scsiBE2H_U32(pbCdb + 2); 537 cSectors = scsiBE2H_U32(pbCdb + 6); 592 538 break; 593 539 case SCSI_READ_CD: 594 iATAPILBA = drvHostDvdBE2H_U32(pbCdb + 2);595 cSectors = drvHostDvdBE2H_U24(pbCdb + 6);540 iATAPILBA = scsiBE2H_U32(pbCdb + 2); 541 cSectors = scsiBE2H_U24(pbCdb + 6); 596 542 break; 597 543 case SCSI_READ_CD_MSF: 598 iATAPILBA = drvHostDvdMSF2LBA(pbCdb + 3);599 cSectors = drvHostDvdMSF2LBA(pbCdb + 6) - iATAPILBA;544 iATAPILBA = scsiMSF2LBA(pbCdb + 3); 545 cSectors = scsiMSF2LBA(pbCdb + 6) - iATAPILBA; 600 546 break; 601 547 default: … … 621 567 case SCSI_WRITE_10: 622 568 case SCSI_WRITE_AND_VERIFY_10: 623 drvHostDvdH2BE_U32(aATAPICmd + 2, iATAPILBA);624 drvHostDvdH2BE_U16(aATAPICmd + 7, cReqSectors);569 scsiH2BE_U32(aATAPICmd + 2, iATAPILBA); 570 scsiH2BE_U16(aATAPICmd + 7, cReqSectors); 625 571 break; 626 572 case SCSI_READ_12: 627 573 case SCSI_WRITE_12: 628 drvHostDvdH2BE_U32(aATAPICmd + 2, iATAPILBA);629 drvHostDvdH2BE_U32(aATAPICmd + 6, cReqSectors);574 scsiH2BE_U32(aATAPICmd + 2, iATAPILBA); 575 scsiH2BE_U32(aATAPICmd + 6, cReqSectors); 630 576 break; 631 577 case SCSI_READ_CD: 632 drvHostDvdH2BE_U32(aATAPICmd + 2, iATAPILBA);633 drvHostDvdH2BE_U24(aATAPICmd + 6, cReqSectors);578 scsiH2BE_U32(aATAPICmd + 2, iATAPILBA); 579 scsiH2BE_U24(aATAPICmd + 6, cReqSectors); 634 580 break; 635 581 case SCSI_READ_CD_MSF: 636 drvHostDvdLBA2MSF(aATAPICmd + 3, iATAPILBA);637 drvHostDvdLBA2MSF(aATAPICmd + 6, iATAPILBA + cReqSectors);582 scsiLBA2MSF(aATAPICmd + 3, iATAPILBA); 583 scsiLBA2MSF(aATAPICmd + 6, iATAPILBA + cReqSectors); 638 584 break; 639 585 }
Note:
See TracChangeset
for help on using the changeset viewer.