Changeset 65111 in vbox
- Timestamp:
- Jan 4, 2017 2:07:58 PM (8 years ago)
- Location:
- trunk/src/VBox/Devices/Storage/VSCSI
- Files:
-
- 1 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/VSCSI/VSCSIDevice.cpp
r64654 r65111 67 67 SCSIINQUIRYDATA ScsiInquiryReply; 68 68 69 vscsiReqSetXferSize(pVScsiReq, vscsiBE2HU16(&pVScsiReq->pbCDB[3]));69 vscsiReqSetXferSize(pVScsiReq, scsiBE2H_U16(&pVScsiReq->pbCDB[3])); 70 70 memset(&ScsiInquiryReply, 0, sizeof(ScsiInquiryReply)); 71 71 ScsiInquiryReply.cbAdditional = 31; … … 86 86 * to return an error. 87 87 */ 88 vscsiReqSetXferSize(pVScsiReq, vscsiBE2HU32(&pVScsiReq->pbCDB[6]));88 vscsiReqSetXferSize(pVScsiReq, scsiBE2H_U32(&pVScsiReq->pbCDB[6])); 89 89 if (pVScsiReq->cbXfer < 16) 90 90 *prcReq = vscsiReqSenseErrorSet(&pVScsiDevice->VScsiSense, pVScsiReq, SCSI_SENSE_ILLEGAL_REQUEST, SCSI_ASC_INV_FIELD_IN_CMD_PACKET, 0x00); … … 95 95 96 96 memset(aReply, 0, sizeof(aReply)); 97 vscsiH2BEU32(&aReply[0], 8); /* List length starts at position 0. */97 scsiH2BE_U32(&aReply[0], 8); /* List length starts at position 0. */ 98 98 cbData = RTSgBufCopyFromBuf(&pVScsiReq->SgBuf, aReply, sizeof(aReply)); 99 99 if (cbData < 16) … … 141 141 uint8_t u8ReportMode = pVScsiReq->pbCDB[2] & 0x7; 142 142 uint8_t u8Opc = pVScsiReq->pbCDB[3]; 143 uint16_t u16SvcAction = vscsiBE2HU16(&pVScsiReq->pbCDB[4]);144 uint16_t cbData = vscsiBE2HU16(&pVScsiReq->pbCDB[6]);143 uint16_t u16SvcAction = scsiBE2H_U16(&pVScsiReq->pbCDB[4]); 144 uint16_t cbData = scsiBE2H_U16(&pVScsiReq->pbCDB[6]); 145 145 146 146 switch (u8ReportMode) -
trunk/src/VBox/Devices/Storage/VSCSI/VSCSIInternal.h
r64654 r65111 20 20 #include <VBox/vscsi.h> 21 21 #include <VBox/scsi.h> 22 #include <VBox/scsiinline.h> 22 23 #include <iprt/memcache.h> 23 24 #include <iprt/sg.h> 24 25 #include <iprt/list.h> 25 26 26 #include "VSCSIInline.h"27 27 #include "VSCSIVpdPages.h" 28 28 -
trunk/src/VBox/Devices/Storage/VSCSI/VSCSILunMmc.cpp
r64654 r65111 80 80 81 81 82 DECLINLINE(void) mmcLBA2MSF(uint8_t *pbBuf, uint32_t iLBA)83 {84 iLBA += 150;85 pbBuf[0] = (iLBA / 75) / 60;86 pbBuf[1] = (iLBA / 75) % 60;87 pbBuf[2] = iLBA % 75;88 }89 90 #if 0 /* unused */91 DECLINLINE(uint32_t) mmcMSF2LBA(const uint8_t *pbBuf)92 {93 return (pbBuf[0] * 60 + pbBuf[1]) * 75 + pbBuf[2];94 }95 #endif96 97 98 82 /* Fabricate normal TOC information. */ 99 83 static int mmcReadTOCNormal(PVSCSILUNINT pVScsiLun, PVSCSIREQINT pVScsiReq, uint16_t cbMaxTransfer, bool fMSF) … … 123 107 { 124 108 *q++ = 0; /* reserved */ 125 mmcLBA2MSF(q, 0);109 scsiLBA2MSF(q, 0); 126 110 q += 3; 127 111 } … … 129 113 { 130 114 /* sector 0 */ 131 vscsiH2BEU32(q, 0);115 scsiH2BE_U32(q, 0); 132 116 q += 4; 133 117 } … … 141 125 { 142 126 *q++ = 0; /* reserved */ 143 mmcLBA2MSF(q, pVScsiLunMmc->cSectors);127 scsiLBA2MSF(q, pVScsiLunMmc->cSectors); 144 128 q += 3; 145 129 } 146 130 else 147 131 { 148 vscsiH2BEU32(q, pVScsiLunMmc->cSectors);132 scsiH2BE_U32(q, pVScsiLunMmc->cSectors); 149 133 q += 4; 150 134 } 151 135 cbSize = q - pbBuf; 152 136 Assert(cbSize <= sizeof(aReply)); 153 vscsiH2BEU16(pbBuf, cbSize - 2);137 scsiH2BE_U16(pbBuf, cbSize - 2); 154 138 if (cbSize < cbMaxTransfer) 155 139 cbMaxTransfer = cbSize; … … 178 162 { 179 163 pbBuf[8] = 0; /* reserved */ 180 mmcLBA2MSF(pbBuf + 8, 0);164 scsiLBA2MSF(pbBuf + 8, 0); 181 165 } 182 166 else 183 167 { 184 168 /* sector 0 */ 185 vscsiH2BEU32(pbBuf + 8, 0);169 scsiH2BE_U32(pbBuf + 8, 0); 186 170 } 187 171 … … 244 228 { 245 229 *pbBuf++ = 0; /* reserved */ 246 mmcLBA2MSF(pbBuf, pVScsiLunMmc->cSectors);230 scsiLBA2MSF(pbBuf, pVScsiLunMmc->cSectors); 247 231 pbBuf += 3; 248 232 } 249 233 else 250 234 { 251 vscsiH2BEU32(pbBuf, pVScsiLunMmc->cSectors);235 scsiH2BE_U32(pbBuf, pVScsiLunMmc->cSectors); 252 236 pbBuf += 4; 253 237 } … … 263 247 { 264 248 *pbBuf++ = 0; /* reserved */ 265 mmcLBA2MSF(pbBuf, 0);249 scsiLBA2MSF(pbBuf, 0); 266 250 pbBuf += 3; 267 251 } … … 269 253 { 270 254 /* sector 0 */ 271 vscsiH2BEU32(pbBuf, 0);255 scsiH2BE_U32(pbBuf, 0); 272 256 pbBuf += 4; 273 257 } 274 258 275 259 cbSize = pbBuf - aReply; 276 vscsiH2BEU16(&aReply[0], cbSize - 2);260 scsiH2BE_U16(&aReply[0], cbSize - 2); 277 261 278 262 RTSgBufCopyFromBuf(&pVScsiReq->SgBuf, aReply, RT_MIN(cbMaxTransfer, cbSize)); … … 285 269 return 0; 286 270 287 vscsiH2BEU16(pbBuf, 0x0); /* feature 0: list of profiles supported */271 scsiH2BE_U16(pbBuf, 0x0); /* feature 0: list of profiles supported */ 288 272 pbBuf[2] = (0 << 2) | (1 << 1) | (1 << 0); /* version 0, persistent, current */ 289 273 pbBuf[3] = 8; /* additional bytes for profiles */ 290 274 /* The MMC-3 spec says that DVD-ROM read capability should be reported 291 275 * before CD-ROM read capability. */ 292 vscsiH2BEU16(pbBuf + 4, 0x10); /* profile: read-only DVD */276 scsiH2BE_U16(pbBuf + 4, 0x10); /* profile: read-only DVD */ 293 277 pbBuf[6] = (0 << 0); /* NOT current profile */ 294 vscsiH2BEU16(pbBuf + 8, 0x08); /* profile: read only CD */278 scsiH2BE_U16(pbBuf + 8, 0x08); /* profile: read only CD */ 295 279 pbBuf[10] = (1 << 0); /* current profile */ 296 280 … … 303 287 return 0; 304 288 305 vscsiH2BEU16(pbBuf, 0x1); /* feature 0001h: Core Feature */289 scsiH2BE_U16(pbBuf, 0x1); /* feature 0001h: Core Feature */ 306 290 pbBuf[2] = (0x2 << 2) | RT_BIT(1) | RT_BIT(0); /* Version | Persistent | Current */ 307 291 pbBuf[3] = 8; /* Additional length */ 308 vscsiH2BEU16(pbBuf + 4, 0x00000002); /* Physical interface ATAPI. */292 scsiH2BE_U16(pbBuf + 4, 0x00000002); /* Physical interface ATAPI. */ 309 293 pbBuf[8] = RT_BIT(0); /* DBE */ 310 294 /* Rest is reserved. */ … … 318 302 return 0; 319 303 320 vscsiH2BEU16(pbBuf, 0x2); /* feature 0002h: Morphing Feature */304 scsiH2BE_U16(pbBuf, 0x2); /* feature 0002h: Morphing Feature */ 321 305 pbBuf[2] = (0x1 << 2) | RT_BIT(1) | RT_BIT(0); /* Version | Persistent | Current */ 322 306 pbBuf[3] = 4; /* Additional length */ … … 332 316 return 0; 333 317 334 vscsiH2BEU16(pbBuf, 0x3); /* feature 0003h: Removable Medium Feature */318 scsiH2BE_U16(pbBuf, 0x3); /* feature 0003h: Removable Medium Feature */ 335 319 pbBuf[2] = (0x2 << 2) | RT_BIT(1) | RT_BIT(0); /* Version | Persistent | Current */ 336 320 pbBuf[3] = 4; /* Additional length */ … … 347 331 return 0; 348 332 349 vscsiH2BEU16(pbBuf, 0x10); /* feature 0010h: Random Readable Feature */333 scsiH2BE_U16(pbBuf, 0x10); /* feature 0010h: Random Readable Feature */ 350 334 pbBuf[2] = (0x0 << 2) | RT_BIT(1) | RT_BIT(0); /* Version | Persistent | Current */ 351 335 pbBuf[3] = 8; /* Additional length */ 352 vscsiH2BEU32(pbBuf + 4, 2048); /* Logical block size. */353 vscsiH2BEU16(pbBuf + 8, 0x10); /* Blocking (0x10 for DVD, CD is not defined). */336 scsiH2BE_U32(pbBuf + 4, 2048); /* Logical block size. */ 337 scsiH2BE_U16(pbBuf + 8, 0x10); /* Blocking (0x10 for DVD, CD is not defined). */ 354 338 pbBuf[10] = 0; /* PP not present */ 355 339 /* Rest is reserved. */ … … 363 347 return 0; 364 348 365 vscsiH2BEU16(pbBuf, 0x1e); /* feature 001Eh: CD Read Feature */349 scsiH2BE_U16(pbBuf, 0x1e); /* feature 001Eh: CD Read Feature */ 366 350 pbBuf[2] = (0x2 << 2) | RT_BIT(1) | RT_BIT(0); /* Version | Persistent | Current */ 367 351 pbBuf[3] = 0; /* Additional length */ … … 377 361 return 0; 378 362 379 vscsiH2BEU16(pbBuf, 0x100); /* feature 0100h: Power Management Feature */363 scsiH2BE_U16(pbBuf, 0x100); /* feature 0100h: Power Management Feature */ 380 364 pbBuf[2] = (0x0 << 2) | RT_BIT(1) | RT_BIT(0); /* Version | Persistent | Current */ 381 365 pbBuf[3] = 0; /* Additional length */ … … 389 373 return 0; 390 374 391 vscsiH2BEU16(pbBuf, 0x105); /* feature 0105h: Timeout Feature */375 scsiH2BE_U16(pbBuf, 0x105); /* feature 0105h: Timeout Feature */ 392 376 pbBuf[2] = (0x0 << 2) | RT_BIT(1) | RT_BIT(0); /* Version | Persistent | Current */ 393 377 pbBuf[3] = 4; /* Additional length */ … … 413 397 414 398 /* Accept valid request types only, and only starting feature 0. */ 415 if ((pVScsiReq->pbCDB[1] & 0x03) == 3 || vscsiBE2HU16(&pVScsiReq->pbCDB[2]) != 0)399 if ((pVScsiReq->pbCDB[1] & 0x03) == 3 || scsiBE2H_U16(&pVScsiReq->pbCDB[2]) != 0) 416 400 return vscsiLunReqSenseErrorSet(&pVScsiLunMmc->Core, pVScsiReq, SCSI_SENSE_ILLEGAL_REQUEST, 417 401 SCSI_ASC_INV_FIELD_IN_CMD_PACKET, 0x00); … … 420 404 * way to differentiate them right now is based on the image size). */ 421 405 if (pVScsiLunMmc->cSectors) 422 vscsiH2BEU16(pbBuf + 6, 0x08); /* current profile: read-only CD */406 scsiH2BE_U16(pbBuf + 6, 0x08); /* current profile: read-only CD */ 423 407 else 424 vscsiH2BEU16(pbBuf + 6, 0x00); /* current profile: none -> no media */408 scsiH2BE_U16(pbBuf + 6, 0x00); /* current profile: none -> no media */ 425 409 cbBuf -= 8; 426 410 pbBuf += 8; … … 459 443 460 444 /* Set data length now. */ 461 vscsiH2BEU32(&aReply[0], (uint32_t)(sizeof(aReply) - cbBuf));445 scsiH2BE_U32(&aReply[0], (uint32_t)(sizeof(aReply) - cbBuf)); 462 446 463 447 RTSgBufCopyFromBuf(&pVScsiReq->SgBuf, aReply, RT_MIN(cbMaxTransfer, sizeof(aReply) - cbBuf)); … … 534 518 535 519 /* FIXME: 0x30000 per spec? */ 536 vscsiH2BEU32(&aReply[8], 0); /* start sector */537 vscsiH2BEU32(&aReply[12], cTotalSectors - 1); /* end sector */538 vscsiH2BEU32(&aReply[16], cTotalSectors - 1); /* l0 end sector */520 scsiH2BE_U32(&aReply[8], 0); /* start sector */ 521 scsiH2BE_U32(&aReply[12], cTotalSectors - 1); /* end sector */ 522 scsiH2BE_U32(&aReply[16], cTotalSectors - 1); /* l0 end sector */ 539 523 540 524 /* Size of buffer, not including 2 byte size field */ 541 vscsiH2BEU32(&aReply[0], 2048 + 2);525 scsiH2BE_U32(&aReply[0], 2048 + 2); 542 526 543 527 /* 2k data + 4 byte header */ … … 550 534 551 535 /* Size of buffer, not including 2 byte size field */ 552 vscsiH2BEU16(&aReply[0], 4 + 2);536 scsiH2BE_U16(&aReply[0], 4 + 2); 553 537 554 538 /* 4 byte header + 4 byte data */ … … 562 546 case 0x04: /* DVD disc manufacturing information */ 563 547 /* Size of buffer, not including 2 byte size field */ 564 vscsiH2BEU16(&aReply[0], 2048 + 2);548 scsiH2BE_U16(&aReply[0], 2048 + 2); 565 549 566 550 /* 2k data + 4 byte header */ … … 575 559 aReply[4] = 0x00; /* Physical format */ 576 560 aReply[5] = 0x40; /* Not writable, is readable */ 577 vscsiH2BEU16(&aReply[6], 2048 + 4);561 scsiH2BE_U16(&aReply[6], 2048 + 4); 578 562 579 563 aReply[8] = 0x01; /* Copyright info */ 580 564 aReply[9] = 0x40; /* Not writable, is readable */ 581 vscsiH2BEU16(&aReply[10], 4 + 4);565 scsiH2BE_U16(&aReply[10], 4 + 4); 582 566 583 567 aReply[12] = 0x03; /* BCA info */ 584 568 aReply[13] = 0x40; /* Not writable, is readable */ 585 vscsiH2BEU16(&aReply[14], 188 + 4);569 scsiH2BE_U16(&aReply[14], 188 + 4); 586 570 587 571 aReply[16] = 0x04; /* Manufacturing info */ 588 572 aReply[17] = 0x40; /* Not writable, is readable */ 589 vscsiH2BEU16(&aReply[18], 2048 + 4);573 scsiH2BE_U16(&aReply[18], 2048 + 4); 590 574 591 575 /* Size of buffer, not including 2 byte size field */ 592 vscsiH2BEU16(&aReply[0], 16 + 2);576 scsiH2BE_U16(&aReply[0], 16 + 2); 593 577 594 578 /* data written + 4 byte header */ … … 645 629 uint8_t aReply[16]; 646 630 647 vscsiH2BEU16(&aReply[0], 16 + 6);631 scsiH2BE_U16(&aReply[0], 16 + 6); 648 632 aReply[2] = (uint8_t)pVScsiLunMmc->u32MediaTrackType; 649 633 aReply[3] = 0; … … 669 653 uint8_t aReply[40]; 670 654 671 vscsiH2BEU16(&aReply[0], 38);655 scsiH2BE_U16(&aReply[0], 38); 672 656 aReply[2] = (uint8_t)pVScsiLunMmc->u32MediaTrackType; 673 657 aReply[3] = 0; … … 690 674 aReply[14] |= 1 << 1; /* report lock state */ 691 675 aReply[15] = 0; /* no subchannel reads supported, no separate audio volume control, no changer etc. */ 692 vscsiH2BEU16(&aReply[16], 5632); /* (obsolete) claim 32x speed support */693 vscsiH2BEU16(&aReply[18], 2); /* number of audio volume levels */694 vscsiH2BEU16(&aReply[20], 128); /* buffer size supported in Kbyte - We don't have a buffer because we write directly into guest memory.676 scsiH2BE_U16(&aReply[16], 5632); /* (obsolete) claim 32x speed support */ 677 scsiH2BE_U16(&aReply[18], 2); /* number of audio volume levels */ 678 scsiH2BE_U16(&aReply[20], 128); /* buffer size supported in Kbyte - We don't have a buffer because we write directly into guest memory. 695 679 Just write some dummy value. */ 696 vscsiH2BEU16(&aReply[22], 5632); /* (obsolete) current read speed 32x */680 scsiH2BE_U16(&aReply[22], 5632); /* (obsolete) current read speed 32x */ 697 681 aReply[24] = 0; /* reserved */ 698 682 aReply[25] = 0; /* reserved for digital audio (see idx 15) */ 699 vscsiH2BEU16(&aReply[26], 0); /* (obsolete) maximum write speed */700 vscsiH2BEU16(&aReply[28], 0); /* (obsolete) current write speed */701 vscsiH2BEU16(&aReply[30], 0); /* copy management revision supported 0=no CSS */683 scsiH2BE_U16(&aReply[26], 0); /* (obsolete) maximum write speed */ 684 scsiH2BE_U16(&aReply[28], 0); /* (obsolete) current write speed */ 685 scsiH2BE_U16(&aReply[30], 0); /* copy management revision supported 0=no CSS */ 702 686 aReply[32] = 0; /* reserved */ 703 687 aReply[33] = 0; /* reserved */ 704 688 aReply[34] = 0; /* reserved */ 705 689 aReply[35] = 1; /* rotation control CAV */ 706 vscsiH2BEU16(&aReply[36], 0); /* current write speed */707 vscsiH2BEU16(&aReply[38], 0); /* number of write speed performance descriptors */690 scsiH2BE_U16(&aReply[36], 0); /* current write speed */ 691 scsiH2BE_U16(&aReply[38], 0); /* number of write speed performance descriptors */ 708 692 RTSgBufCopyFromBuf(&pVScsiReq->SgBuf, aReply, RT_MIN(cbMaxTransfer, sizeof(aReply))); 709 693 rcReq = vscsiLunReqSenseOkSet(&pVScsiLunMmc->Core, pVScsiReq); … … 759 743 case MMCEVENTSTATUSTYPE_MEDIA_NEW: 760 744 /* mount */ 761 vscsiH2BEU16(&aReply[0], 6);745 scsiH2BE_U16(&aReply[0], 6); 762 746 aReply[2] = 0x04; /* media */ 763 747 aReply[3] = 0x5e; /* supported = busy|media|external|power|operational */ … … 772 756 case MMCEVENTSTATUSTYPE_MEDIA_REMOVED: 773 757 /* umount */ 774 vscsiH2BEU16(&aReply[0], 6);758 scsiH2BE_U16(&aReply[0], 6); 775 759 aReply[2] = 0x04; /* media */ 776 760 aReply[3] = 0x5e; /* supported = busy|media|external|power|operational */ … … 784 768 785 769 case MMCEVENTSTATUSTYPE_MEDIA_EJECT_REQUESTED: /* currently unused */ 786 vscsiH2BEU16(&aReply[0], 6);770 scsiH2BE_U16(&aReply[0], 6); 787 771 aReply[2] = 0x04; /* media */ 788 772 aReply[3] = 0x5e; /* supported = busy|media|external|power|operational */ … … 795 779 case MMCEVENTSTATUSTYPE_UNCHANGED: 796 780 default: 797 vscsiH2BEU16(&aReply[0], 6);781 scsiH2BE_U16(&aReply[0], 6); 798 782 aReply[2] = 0x01; /* operational change request / notification */ 799 783 aReply[3] = 0x5e; /* supported = busy|media|external|power|operational */ … … 887 871 SCSIINQUIRYDATA ScsiInquiryReply; 888 872 889 vscsiReqSetXferSize(pVScsiReq, vscsiBE2HU16(&pVScsiReq->pbCDB[3]));873 vscsiReqSetXferSize(pVScsiReq, scsiBE2H_U16(&pVScsiReq->pbCDB[3])); 890 874 memset(&ScsiInquiryReply, 0, sizeof(ScsiInquiryReply)); 891 875 … … 897 881 ScsiInquiryReply.fCmdQue = 1; /* Command queuing supported. */ 898 882 ScsiInquiryReply.fWBus16 = 1; 899 vscsiPadStr(ScsiInquiryReply.achVendorId, "VBOX", 8);900 vscsiPadStr(ScsiInquiryReply.achProductId, "CD-ROM", 16);901 vscsiPadStr(ScsiInquiryReply.achProductLevel, "1.0", 4);883 scsiPadStrS(ScsiInquiryReply.achVendorId, "VBOX", 8); 884 scsiPadStrS(ScsiInquiryReply.achProductId, "CD-ROM", 16); 885 scsiPadStrS(ScsiInquiryReply.achProductLevel, "1.0", 4); 902 886 903 887 RTSgBufCopyFromBuf(&pVScsiReq->SgBuf, (uint8_t *)&ScsiInquiryReply, sizeof(SCSIINQUIRYDATA)); … … 916 900 */ 917 901 if (pVScsiLunMmc->cSectors > UINT32_C(0xffffffff)) 918 vscsiH2BEU32(aReply, UINT32_C(0xffffffff));902 scsiH2BE_U32(aReply, UINT32_C(0xffffffff)); 919 903 else 920 vscsiH2BEU32(aReply, pVScsiLunMmc->cSectors - 1);921 vscsiH2BEU32(&aReply[4], pVScsiLunMmc->cbSector);904 scsiH2BE_U32(aReply, pVScsiLunMmc->cSectors - 1); 905 scsiH2BE_U32(&aReply[4], pVScsiLunMmc->cbSector); 922 906 RTSgBufCopyFromBuf(&pVScsiReq->SgBuf, aReply, sizeof(aReply)); 923 907 rcReq = vscsiLunReqSenseOkSet(pVScsiLun, pVScsiReq); … … 962 946 case SCSI_MODE_SENSE_10: 963 947 { 964 size_t cbMax = vscsiBE2HU16(&pVScsiReq->pbCDB[7]);948 size_t cbMax = scsiBE2H_U16(&pVScsiReq->pbCDB[7]); 965 949 vscsiReqSetXferSize(pVScsiReq, cbMax); 966 950 rcReq = vscsiLunMmcModeSense10(pVScsiLunMmc, pVScsiReq, cbMax); … … 969 953 case SCSI_SEEK_10: 970 954 { 971 uint32_t uLba = vscsiBE2HU32(&pVScsiReq->pbCDB[2]);955 uint32_t uLba = scsiBE2H_U32(&pVScsiReq->pbCDB[2]); 972 956 if (uLba > pVScsiLunMmc->cSectors) 973 957 rcReq = vscsiLunReqSenseErrorSet(pVScsiLun, pVScsiReq, SCSI_SENSE_ILLEGAL_REQUEST, … … 996 980 { 997 981 enmTxDir = VSCSIIOREQTXDIR_READ; 998 uLbaStart = vscsiBE2HU32(&pVScsiReq->pbCDB[2]);999 cSectorTransfer = vscsiBE2HU16(&pVScsiReq->pbCDB[7]);982 uLbaStart = scsiBE2H_U32(&pVScsiReq->pbCDB[2]); 983 cSectorTransfer = scsiBE2H_U16(&pVScsiReq->pbCDB[7]); 1000 984 break; 1001 985 } … … 1003 987 { 1004 988 enmTxDir = VSCSIIOREQTXDIR_READ; 1005 uLbaStart = vscsiBE2HU32(&pVScsiReq->pbCDB[2]);1006 cSectorTransfer = vscsiBE2HU32(&pVScsiReq->pbCDB[6]);989 uLbaStart = scsiBE2H_U32(&pVScsiReq->pbCDB[2]); 990 cSectorTransfer = scsiBE2H_U32(&pVScsiReq->pbCDB[6]); 1007 991 break; 1008 992 } … … 1010 994 { 1011 995 enmTxDir = VSCSIIOREQTXDIR_READ; 1012 uLbaStart = vscsiBE2HU64(&pVScsiReq->pbCDB[2]);1013 cSectorTransfer = vscsiBE2HU32(&pVScsiReq->pbCDB[10]);996 uLbaStart = scsiBE2H_U64(&pVScsiReq->pbCDB[2]); 997 cSectorTransfer = scsiBE2H_U32(&pVScsiReq->pbCDB[10]); 1014 998 break; 1015 999 } … … 1018 1002 uint8_t uDataMode = pVScsiReq->pbCDB[1] & 0x1f; 1019 1003 1020 vscsiReqSetXferSize(pVScsiReq, vscsiBE2HU16(&pVScsiReq->pbCDB[6]));1004 vscsiReqSetXferSize(pVScsiReq, scsiBE2H_U16(&pVScsiReq->pbCDB[6])); 1021 1005 1022 1006 switch (uDataMode) … … 1072 1056 uint8_t uSubPageCode = pVScsiReq->pbCDB[3]; 1073 1057 1074 vscsiReqSetXferSize(pVScsiReq, vscsiBE2HU16(&pVScsiReq->pbCDB[7]));1058 vscsiReqSetXferSize(pVScsiReq, scsiBE2H_U16(&pVScsiReq->pbCDB[7])); 1075 1059 1076 1060 switch (uPageCode) … … 1106 1090 1107 1091 memset(aReply, 0, sizeof(aReply)); 1108 vscsiH2BEU64(aReply, pVScsiLunMmc->cSectors - 1);1109 vscsiH2BEU32(&aReply[8], pVScsiLunMmc->cbSector);1092 scsiH2BE_U64(aReply, pVScsiLunMmc->cSectors - 1); 1093 scsiH2BE_U32(&aReply[8], pVScsiLunMmc->cbSector); 1110 1094 /* Leave the rest 0 */ 1111 1095 … … 1135 1119 1136 1120 format = pVScsiReq->pbCDB[2] & 0x0f; 1137 cbMax = vscsiBE2HU16(&pVScsiReq->pbCDB[7]);1121 cbMax = scsiBE2H_U16(&pVScsiReq->pbCDB[7]); 1138 1122 fMSF = (pVScsiReq->pbCDB[1] >> 1) & 1; 1139 1123 … … 1158 1142 { 1159 1143 /* Only supporting polled mode at the moment. */ 1160 size_t cbMax = vscsiBE2HU16(&pVScsiReq->pbCDB[7]);1144 size_t cbMax = scsiBE2H_U16(&pVScsiReq->pbCDB[7]); 1161 1145 1162 1146 vscsiReqSetXferSize(pVScsiReq, cbMax); … … 1169 1153 case SCSI_MECHANISM_STATUS: 1170 1154 { 1171 size_t cbMax = vscsiBE2HU16(&pVScsiReq->pbCDB[8]);1155 size_t cbMax = scsiBE2H_U16(&pVScsiReq->pbCDB[8]); 1172 1156 uint8_t aReply[8]; 1173 1157 1174 1158 vscsiReqSetXferSize(pVScsiReq, cbMax); 1175 vscsiH2BEU16(&aReply[0], 0);1159 scsiH2BE_U16(&aReply[0], 0); 1176 1160 /* no current LBA */ 1177 1161 aReply[2] = 0; … … 1179 1163 aReply[4] = 0; 1180 1164 aReply[5] = 1; 1181 vscsiH2BEU16(&aReply[6], 0);1165 scsiH2BE_U16(&aReply[6], 0); 1182 1166 RTSgBufCopyFromBuf(&pVScsiReq->SgBuf, aReply, RT_MIN(sizeof(aReply), cbMax)); 1183 1167 rcReq = vscsiLunReqSenseOkSet(pVScsiLun, pVScsiReq); … … 1187 1171 { 1188 1172 uint8_t aReply[34]; 1189 size_t cbMax = vscsiBE2HU16(&pVScsiReq->pbCDB[7]);1173 size_t cbMax = scsiBE2H_U16(&pVScsiReq->pbCDB[7]); 1190 1174 1191 1175 vscsiReqSetXferSize(pVScsiReq, cbMax); 1192 1176 memset(aReply, '\0', sizeof(aReply)); 1193 vscsiH2BEU16(&aReply[0], 32);1177 scsiH2BE_U16(&aReply[0], 32); 1194 1178 aReply[2] = (0 << 4) | (3 << 2) | (2 << 0); /* not erasable, complete session, complete disc */ 1195 1179 aReply[3] = 1; /* number of first track */ … … 1202 1186 aReply[10] = 0; /* number of sessions (MSB) */ 1203 1187 aReply[11] = 0; /* number of sessions (MSB) */ 1204 vscsiH2BEU32(&aReply[16], 0x00ffffff); /* last session lead-in start time is not available */1205 vscsiH2BEU32(&aReply[20], 0x00ffffff); /* last possible start time for lead-out is not available */1188 scsiH2BE_U32(&aReply[16], 0x00ffffff); /* last session lead-in start time is not available */ 1189 scsiH2BE_U32(&aReply[20], 0x00ffffff); /* last possible start time for lead-out is not available */ 1206 1190 RTSgBufCopyFromBuf(&pVScsiReq->SgBuf, aReply, RT_MIN(sizeof(aReply), cbMax)); 1207 1191 rcReq = vscsiLunReqSenseOkSet(pVScsiLun, pVScsiReq); … … 1210 1194 case SCSI_READ_TRACK_INFORMATION: 1211 1195 { 1212 size_t cbMax = vscsiBE2HU16(&pVScsiReq->pbCDB[7]);1196 size_t cbMax = scsiBE2H_U16(&pVScsiReq->pbCDB[7]); 1213 1197 1214 1198 vscsiReqSetXferSize(pVScsiReq, cbMax); 1215 1199 /* Accept address/number type of 1 only, and only track 1 exists. */ 1216 if ((pVScsiReq->pbCDB[1] & 0x03) != 1 || vscsiBE2HU32(&pVScsiReq->pbCDB[2]) != 1)1200 if ((pVScsiReq->pbCDB[1] & 0x03) != 1 || scsiBE2H_U32(&pVScsiReq->pbCDB[2]) != 1) 1217 1201 rcReq = vscsiLunReqSenseErrorSet(pVScsiLun, pVScsiReq, SCSI_SENSE_ILLEGAL_REQUEST, 1218 1202 SCSI_ASC_INV_FIELD_IN_CMD_PACKET, 0x00); … … 1222 1206 RT_ZERO(aReply); 1223 1207 1224 vscsiH2BEU16(&aReply[0], 34);1208 scsiH2BE_U16(&aReply[0], 34); 1225 1209 aReply[2] = 1; /* track number (LSB) */ 1226 1210 aReply[3] = 1; /* session number (LSB) */ … … 1228 1212 aReply[6] = (0 << 7) | (0 << 6) | (0 << 5) | (0 << 6) | (1 << 0); /* not reserved track, not blank, not packet writing, not fixed packet, data mode 1 */ 1229 1213 aReply[7] = (0 << 1) | (0 << 0); /* last recorded address not valid, next recordable address not valid */ 1230 vscsiH2BEU32(&aReply[8], 0); /* track start address is 0 */1231 vscsiH2BEU32(&aReply[24], pVScsiLunMmc->cSectors); /* track size */1214 scsiH2BE_U32(&aReply[8], 0); /* track start address is 0 */ 1215 scsiH2BE_U32(&aReply[24], pVScsiLunMmc->cSectors); /* track size */ 1232 1216 aReply[32] = 0; /* track number (MSB) */ 1233 1217 aReply[33] = 0; /* session number (MSB) */ … … 1240 1224 case SCSI_GET_CONFIGURATION: 1241 1225 { 1242 size_t cbMax = vscsiBE2HU16(&pVScsiReq->pbCDB[7]);1226 size_t cbMax = scsiBE2H_U16(&pVScsiReq->pbCDB[7]); 1243 1227 vscsiReqSetXferSize(pVScsiReq, cbMax); 1244 1228 rcReq = vscsiLunMmcGetConfiguration(pVScsiLunMmc, pVScsiReq, cbMax); … … 1247 1231 case SCSI_READ_DVD_STRUCTURE: 1248 1232 { 1249 size_t cbMax = vscsiBE2HU16(&pVScsiReq->pbCDB[8]);1233 size_t cbMax = scsiBE2H_U16(&pVScsiReq->pbCDB[8]); 1250 1234 vscsiReqSetXferSize(pVScsiReq, cbMax); 1251 1235 rcReq = vscsiLunMmcReadDvdStructure(pVScsiLunMmc, pVScsiReq, cbMax); -
trunk/src/VBox/Devices/Storage/VSCSI/VSCSILunSbc.cpp
r64654 r65111 203 203 case SCSI_INQUIRY: 204 204 { 205 vscsiReqSetXferSize(pVScsiReq, vscsiBE2HU16(&pVScsiReq->pbCDB[3]));205 vscsiReqSetXferSize(pVScsiReq, scsiBE2H_U16(&pVScsiReq->pbCDB[3])); 206 206 207 207 /* Check for EVPD bit. */ … … 233 233 ScsiInquiryReply.fCmdQue = 1; /* Command queuing supported. */ 234 234 ScsiInquiryReply.fWBus16 = 1; 235 vscsiPadStr(ScsiInquiryReply.achVendorId, "VBOX", 8);236 vscsiPadStr(ScsiInquiryReply.achProductId, "HARDDISK", 16);237 vscsiPadStr(ScsiInquiryReply.achProductLevel, "1.0", 4);235 scsiPadStrS(ScsiInquiryReply.achVendorId, "VBOX", 8); 236 scsiPadStrS(ScsiInquiryReply.achProductId, "HARDDISK", 16); 237 scsiPadStrS(ScsiInquiryReply.achProductLevel, "1.0", 4); 238 238 239 239 RTSgBufCopyFromBuf(&pVScsiReq->SgBuf, (uint8_t *)&ScsiInquiryReply, sizeof(SCSIINQUIRYDATA)); … … 254 254 */ 255 255 if (pVScsiLunSbc->cSectors > UINT32_C(0xffffffff)) 256 vscsiH2BEU32(aReply, UINT32_C(0xffffffff));256 scsiH2BE_U32(aReply, UINT32_C(0xffffffff)); 257 257 else 258 vscsiH2BEU32(aReply, pVScsiLunSbc->cSectors - 1);259 vscsiH2BEU32(&aReply[4], pVScsiLunSbc->cbSector);258 scsiH2BE_U32(aReply, pVScsiLunSbc->cSectors - 1); 259 scsiH2BE_U32(&aReply[4], pVScsiLunSbc->cbSector); 260 260 RTSgBufCopyFromBuf(&pVScsiReq->SgBuf, aReply, sizeof(aReply)); 261 261 rcReq = vscsiLunReqSenseOkSet(pVScsiLun, pVScsiReq); … … 320 320 uint32_t cbBlock; 321 321 322 cbBlock = vscsiBE2HU24(&abParms[4 + 5]);322 cbBlock = scsiBE2H_U24(&abParms[4 + 5]); 323 323 Log2(("SBC: set LOGICAL BLOCK LENGTH to %u\n", cbBlock)); 324 324 if (cbBlock == 512) /* Fixed block size. */ … … 344 344 { 345 345 enmTxDir = VSCSIIOREQTXDIR_READ; 346 uLbaStart = vscsiBE2HU32(&pVScsiReq->pbCDB[2]);347 cSectorTransfer = vscsiBE2HU16(&pVScsiReq->pbCDB[7]);346 uLbaStart = scsiBE2H_U32(&pVScsiReq->pbCDB[2]); 347 cSectorTransfer = scsiBE2H_U16(&pVScsiReq->pbCDB[7]); 348 348 break; 349 349 } … … 351 351 { 352 352 enmTxDir = VSCSIIOREQTXDIR_READ; 353 uLbaStart = vscsiBE2HU32(&pVScsiReq->pbCDB[2]);354 cSectorTransfer = vscsiBE2HU32(&pVScsiReq->pbCDB[6]);353 uLbaStart = scsiBE2H_U32(&pVScsiReq->pbCDB[2]); 354 cSectorTransfer = scsiBE2H_U32(&pVScsiReq->pbCDB[6]); 355 355 break; 356 356 } … … 358 358 { 359 359 enmTxDir = VSCSIIOREQTXDIR_READ; 360 uLbaStart = vscsiBE2HU64(&pVScsiReq->pbCDB[2]);361 cSectorTransfer = vscsiBE2HU32(&pVScsiReq->pbCDB[10]);360 uLbaStart = scsiBE2H_U64(&pVScsiReq->pbCDB[2]); 361 cSectorTransfer = scsiBE2H_U32(&pVScsiReq->pbCDB[10]); 362 362 break; 363 363 } … … 374 374 { 375 375 enmTxDir = VSCSIIOREQTXDIR_WRITE; 376 uLbaStart = vscsiBE2HU32(&pVScsiReq->pbCDB[2]);377 cSectorTransfer = vscsiBE2HU16(&pVScsiReq->pbCDB[7]);376 uLbaStart = scsiBE2H_U32(&pVScsiReq->pbCDB[2]); 377 cSectorTransfer = scsiBE2H_U16(&pVScsiReq->pbCDB[7]); 378 378 break; 379 379 } … … 381 381 { 382 382 enmTxDir = VSCSIIOREQTXDIR_WRITE; 383 uLbaStart = vscsiBE2HU32(&pVScsiReq->pbCDB[2]);384 cSectorTransfer = vscsiBE2HU32(&pVScsiReq->pbCDB[6]);383 uLbaStart = scsiBE2H_U32(&pVScsiReq->pbCDB[2]); 384 cSectorTransfer = scsiBE2H_U32(&pVScsiReq->pbCDB[6]); 385 385 break; 386 386 } … … 388 388 { 389 389 enmTxDir = VSCSIIOREQTXDIR_WRITE; 390 uLbaStart = vscsiBE2HU64(&pVScsiReq->pbCDB[2]);391 cSectorTransfer = vscsiBE2HU32(&pVScsiReq->pbCDB[10]);390 uLbaStart = scsiBE2H_U64(&pVScsiReq->pbCDB[2]); 391 cSectorTransfer = scsiBE2H_U32(&pVScsiReq->pbCDB[10]); 392 392 break; 393 393 } … … 400 400 uint8_t uDataMode = pVScsiReq->pbCDB[1] & 0x1f; 401 401 402 vscsiReqSetXferSize(pVScsiReq, vscsiBE2HU16(&pVScsiReq->pbCDB[6]));402 vscsiReqSetXferSize(pVScsiReq, scsiBE2H_U16(&pVScsiReq->pbCDB[6])); 403 403 404 404 switch (uDataMode) … … 441 441 uint8_t uSubPageCode = pVScsiReq->pbCDB[3]; 442 442 443 vscsiReqSetXferSize(pVScsiReq, vscsiBE2HU16(&pVScsiReq->pbCDB[7]));443 vscsiReqSetXferSize(pVScsiReq, scsiBE2H_U16(&pVScsiReq->pbCDB[7])); 444 444 445 445 switch (uPageCode) … … 474 474 475 475 memset(aReply, 0, sizeof(aReply)); 476 vscsiH2BEU64(aReply, pVScsiLunSbc->cSectors - 1);477 vscsiH2BEU32(&aReply[8], 512);476 scsiH2BE_U64(aReply, pVScsiLunSbc->cSectors - 1); 477 scsiH2BE_U32(&aReply[8], 512); 478 478 if (pVScsiLun->fFeatures & VSCSI_LUN_FEATURE_UNMAP) 479 479 aReply[14] = 0x80; /* LPME enabled */ … … 496 496 uint8_t abHdr[8]; 497 497 size_t cbCopied; 498 size_t cbList = vscsiBE2HU16(&pVScsiReq->pbCDB[7]);498 size_t cbList = scsiBE2H_U16(&pVScsiReq->pbCDB[7]); 499 499 500 500 /* Copy the header. */ … … 507 507 && cbList >= 8) 508 508 { 509 uint32_t cBlkDesc = vscsiBE2HU16(&abHdr[2]) / 16;509 uint32_t cBlkDesc = scsiBE2H_U16(&abHdr[2]) / 16; 510 510 511 511 if (cBlkDesc) … … 525 525 } 526 526 527 paRanges[i].offStart = vscsiBE2HU64(&abBlkDesc[0]) * 512;528 paRanges[i].cbRange = vscsiBE2HU32(&abBlkDesc[8]) * 512;527 paRanges[i].offStart = scsiBE2H_U64(&abBlkDesc[0]) * 512; 528 paRanges[i].cbRange = scsiBE2H_U32(&abBlkDesc[8]) * 512; 529 529 } 530 530 -
trunk/src/VBox/Devices/Storage/VSCSI/VSCSISense.cpp
r62506 r65111 69 69 pVScsiSense->abSenseBuf[0] = RT_BIT(7) | SCSI_SENSE_RESPONSE_CODE_CURR_FIXED; /* Fixed format */ 70 70 pVScsiSense->abSenseBuf[2] = uSCSISenseKey; 71 vscsiH2BEU32(&pVScsiSense->abSenseBuf[3], uInfo);71 scsiH2BE_U32(&pVScsiSense->abSenseBuf[3], uInfo); 72 72 pVScsiSense->abSenseBuf[7] = 10; 73 73 pVScsiSense->abSenseBuf[12] = uSCSIASC;
Note:
See TracChangeset
for help on using the changeset viewer.