- Timestamp:
- Oct 8, 2012 5:47:04 PM (13 years ago)
- svn:sync-xref-src-repo-rev:
- 81216
- Location:
- trunk/src/VBox/Devices/Storage
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/ATAPIPassthrough.cpp
r43567 r43572 33 33 /** The track is the lead out track of the medium. */ 34 34 #define TRACK_FLAGS_LEAD_OUT RT_BIT_32(2) 35 36 /** Don't clear already detected tracks on the medium. */ 37 #define ATAPI_TRACK_LIST_REALLOCATE_FLAGS_DONT_CLEAR RT_BIT_32(0) 35 38 36 39 /** … … 136 139 * @param pTrackList The track list to reallocate. 137 140 * @param cTracks Number of tracks the list must be able to hold. 138 */ 139 static int atapiTrackListReallocate(PTRACKLIST pTrackList, unsigned cTracks) 141 * @param fFlags Flags for the reallocation. 142 */ 143 static int atapiTrackListReallocate(PTRACKLIST pTrackList, unsigned cTracks, uint32_t fFlags) 140 144 { 141 145 int rc = VINF_SUCCESS; 142 146 143 ATAPIPassthroughTrackListClear(pTrackList); 147 if (!(fFlags & ATAPI_TRACK_LIST_REALLOCATE_FLAGS_DONT_CLEAR)) 148 ATAPIPassthroughTrackListClear(pTrackList); 144 149 145 150 if (pTrackList->cTracksMax < cTracks) … … 172 177 * @param pbCueSheetEntry CUE sheet entry to use. 173 178 */ 174 static void atapiTrackListEntryCreateFromCueSheetEntry(PTRACK pTrack, uint8_t *pbCueSheetEntry)179 static void atapiTrackListEntryCreateFromCueSheetEntry(PTRACK pTrack, const uint8_t *pbCueSheetEntry) 175 180 { 176 181 TRACKDATAFORM enmTrackDataForm = TRACKDATAFORM_INVALID; … … 264 269 * @param pvBuf The CUE sheet. 265 270 */ 266 static int atapiTrackListUpdateFromSendCueSheet(PTRACKLIST pTrackList, uint8_t *pbCDB,void *pvBuf)271 static int atapiTrackListUpdateFromSendCueSheet(PTRACKLIST pTrackList, const uint8_t *pbCDB, const void *pvBuf) 267 272 { 268 273 int rc = VINF_SUCCESS; … … 272 277 AssertReturn(cbCueSheet % 8 == 0 && cTracks, VERR_INVALID_PARAMETER); 273 278 274 rc = atapiTrackListReallocate(pTrackList, cTracks );279 rc = atapiTrackListReallocate(pTrackList, cTracks, 0); 275 280 if (RT_SUCCESS(rc)) 276 281 { 277 uint8_t *pbCueSheet = (uint8_t *)pvBuf;282 const uint8_t *pbCueSheet = (uint8_t *)pvBuf; 278 283 PTRACK pTrack = pTrackList->paTracks; 279 284 … … 291 296 } 292 297 293 static int atapiTrackListUpdateFromSendDvdStructure(PTRACKLIST pTrackList, uint8_t *pbCDB,void *pvBuf)298 static int atapiTrackListUpdateFromSendDvdStructure(PTRACKLIST pTrackList, const uint8_t *pbCDB, const void *pvBuf) 294 299 { 295 300 return VERR_NOT_IMPLEMENTED; 296 301 } 297 302 298 static int atapiTrackListUpdateFromReadTocPmaAtip(PTRACKLIST pTrackList, uint8_t *pbCDB, void *pvBuf) 303 /** 304 * Update track list from formatted TOC data. 305 * 306 * @returns VBox status code. 307 * @param pTrackList The track list to update. 308 * @param fMSF Flag whether block addresses are in MSF or LBA format. 309 * @param pbBuf Buffer holding the formatted TOC. 310 * @param cbBuffer Size of the buffer. 311 */ 312 static int atapiTrackListUpdateFromFormattedToc(PTRACKLIST pTrackList, uint8_t iTrack, 313 bool fMSF, const uint8_t *pbBuf, size_t cbBuffer) 314 { 315 int rc = VINF_SUCCESS; 316 size_t cbToc = atapiBE2H_U16(pbBuf); 317 uint8_t iTrackFirst = pbBuf[2]; 318 unsigned cTracks; 319 320 cbToc -= 2; 321 pbBuf += 4; 322 AssertReturn(cbToc % 8 == 0, VERR_INVALID_PARAMETER); 323 324 cTracks = cbToc / 8 + iTrackFirst; 325 326 rc = atapiTrackListReallocate(pTrackList, cTracks, ATAPI_TRACK_LIST_REALLOCATE_FLAGS_DONT_CLEAR); 327 if (RT_SUCCESS(rc)) 328 { 329 PTRACK pTrack = &pTrackList->paTracks[iTrackFirst]; 330 331 for (unsigned i = iTrackFirst; i < cTracks; i++) 332 { 333 if (pbBuf[1] & 0x4) 334 pTrack->enmMainDataForm = TRACKDATAFORM_MODE1_2048; 335 else 336 pTrack->enmMainDataForm = TRACKDATAFORM_CDDA; 337 338 pTrack->enmSubChnDataForm = SUBCHNDATAFORM_0; 339 if (fMSF) 340 pTrack->iLbaStart = atapiMSF2LBA(&pbBuf[4]); 341 else 342 pTrack->iLbaStart = atapiBE2H_U32(&pbBuf[4]); 343 344 if (pbBuf[2] != 0xaa) 345 { 346 /* Calculate number of sectors from the next entry. */ 347 int64_t iLbaNext; 348 349 if (fMSF) 350 iLbaNext = atapiMSF2LBA(&pbBuf[4+8]); 351 else 352 iLbaNext = atapiBE2H_U32(&pbBuf[4+8]); 353 354 pTrack->cSectors = iLbaNext - pTrack->iLbaStart; 355 } 356 else 357 pTrack->cSectors = 0; 358 359 pTrack->fFlags &= ~TRACK_FLAGS_UNDETECTED; 360 pbBuf += 8; 361 } 362 } 363 364 return rc; 365 } 366 367 static int atapiTrackListUpdateFromReadTocPmaAtip(PTRACKLIST pTrackList, const uint8_t *pbCDB, const void *pvBuf) 368 { 369 int rc = VINF_SUCCESS; 370 size_t cbBuffer = atapiBE2H_U16(&pbCDB[7]); 371 bool fMSF = (pbCDB[1] & 0x2) != 0; 372 uint8_t uFmt = pbCDB[2] & 0xf; 373 uint8_t iTrack = pbCDB[6]; 374 375 switch (uFmt) 376 { 377 case 0x00: 378 rc = atapiTrackListUpdateFromFormattedToc(pTrackList, iTrack, fMSF, (uint8_t *)pvBuf, cbBuffer); 379 break; 380 case 0x01: 381 case 0x02: 382 case 0x03: 383 case 0x04: 384 case 0x05: 385 default: 386 rc = VERR_INVALID_PARAMETER; 387 } 388 389 return rc; 390 } 391 392 static int atapiTrackListUpdateFromReadTrackInformation(PTRACKLIST pTrackList, const uint8_t *pbCDB, const void *pvBuf) 299 393 { 300 394 return VERR_NOT_IMPLEMENTED; 301 395 } 302 396 303 static int atapiTrackListUpdateFromRead TrackInformation(PTRACKLIST pTrackList, uint8_t *pbCDB,void *pvBuf)397 static int atapiTrackListUpdateFromReadDvdStructure(PTRACKLIST pTrackList, const uint8_t *pbCDB, const void *pvBuf) 304 398 { 305 399 return VERR_NOT_IMPLEMENTED; 306 400 } 307 401 308 static int atapiTrackListUpdateFromReadDvdStructure(PTRACKLIST pTrackList, uint8_t *pbCDB, void *pvBuf) 309 { 310 return VERR_NOT_IMPLEMENTED; 311 } 312 313 static int atapiTrackListUpdateFromReadDiscInformation(PTRACKLIST pTrackList, uint8_t *pbCDB, void *pvBuf) 402 static int atapiTrackListUpdateFromReadDiscInformation(PTRACKLIST pTrackList, const uint8_t *pbCDB, const void *pvBuf) 314 403 { 315 404 return VERR_NOT_IMPLEMENTED; … … 426 515 } 427 516 428 DECLHIDDEN(int) ATAPIPassthroughTrackListUpdate(PTRACKLIST pTrackList, uint8_t *pbCDB,void *pvBuf)517 DECLHIDDEN(int) ATAPIPassthroughTrackListUpdate(PTRACKLIST pTrackList, const uint8_t *pbCDB, const void *pvBuf) 429 518 { 430 519 int rc = VINF_SUCCESS; … … 455 544 } 456 545 546 #ifdef LOG_ENABLED 457 547 atapiTrackListDump(pTrackList); 548 #endif 458 549 459 550 return rc; -
trunk/src/VBox/Devices/Storage/DevATA.cpp
r43571 r43572 102 102 /* Media track type */ 103 103 #define ATA_MEDIA_TYPE_UNKNOWN 0 /**< unknown CD type */ 104 #define ATA_MEDIA_TYPE_DATA 1 /**< Data CD */105 #define ATA_MEDIA_TYPE_CDDA 2 /**< CD-DA (audio) CD type */106 104 #define ATA_MEDIA_NO_DISC 0x70 /**< Door closed, no medium */ 107 105 … … 2128 2126 { 2129 2127 case SCSI_SEND_CUE_SHEET: 2128 case SCSI_READ_TOC_PMA_ATIP: 2130 2129 { 2131 2130 if (!s->pTrackList) … … 2137 2136 if ( RT_FAILURE(rc) 2138 2137 && s->cErrors++ < MAX_LOG_REL_ERRORS) 2139 LogRel(("ATA: Error (%Rrc) while updating the tracklist during SEND CUE SHEET, burning the disc might fail\n",2140 rc ));2138 LogRel(("ATA: Error (%Rrc) while updating the tracklist during %s, burning the disc might fail\n", 2139 rc, s->aATAPICmd[0] == SCSI_SEND_CUE_SHEET ? "SEND CUE SHEET" : "READ TOC/PMA/ATIP")); 2141 2140 break; 2142 2141 } … … 2169 2168 ataSCSIPadStr(s->CTX_SUFF(pbIOBuffer) + 32, "1.0", 4); 2170 2169 } 2171 else if ( s->aATAPICmd[0] == SCSI_READ_TOC_PMA_ATIP 2172 && (s->aATAPICmd[2] & 0xf) != 0x05 2173 && s->aATAPICmd[6] != 0xaa) 2174 { 2175 /* Set the media type if we can detect it. */ 2176 uint8_t *pbBuf = s->CTX_SUFF(pbIOBuffer); 2177 2178 /** @todo: Implemented only for formatted TOC now. */ 2179 if ( (s->aATAPICmd[2] & 0xf) == 0 2180 && cbTransfer >= 6) 2181 { 2182 uint32_t NewMediaType; 2183 uint32_t OldMediaType; 2184 2185 if (pbBuf[5] & 0x4) 2186 NewMediaType = ATA_MEDIA_TYPE_DATA; 2187 else 2188 NewMediaType = ATA_MEDIA_TYPE_CDDA; 2189 2190 OldMediaType = ataMediumTypeSet(s, NewMediaType); 2191 2192 if (OldMediaType != NewMediaType) 2193 LogRel(("PIIX3 ATA: LUN#%d: CD-ROM passthrough, detected %s CD\n", 2194 s->iLUN, 2195 NewMediaType == ATA_MEDIA_TYPE_DATA 2196 ? "data" 2197 : "audio")); 2198 } 2199 else /* Play safe and set to unknown. */ 2200 ataMediumTypeSet(s, ATA_MEDIA_TYPE_UNKNOWN); 2201 } 2170 2202 2171 if (cbTransfer) 2203 2172 Log3(("ATAPI PT data read (%d): %.*Rhxs\n", cbTransfer, cbTransfer, s->CTX_SUFF(pbIOBuffer))); … … 3524 3493 { 3525 3494 case 0x0: /* All types. */ 3526 if (ASMAtomicReadU32(&s->MediaTrackType) == ATA_MEDIA_TYPE_CDDA) 3527 s->cbATAPISector = 2352; 3495 { 3496 uint32_t iLbaStart; 3497 3498 if (pbPacket[0] == SCSI_READ_CD) 3499 iLbaStart = ataBE2H_U32(&pbPacket[2]); 3500 else 3501 iLbaStart = ataMSF2LBA(&pbPacket[3]); 3502 3503 if (s->pTrackList) 3504 s->cbATAPISector = ATAPIPassthroughTrackListGetSectorSizeFromLba(s->pTrackList, iLbaStart); 3528 3505 else 3529 3506 s->cbATAPISector = 2048; /* Might be incorrect if we couldn't determine the type. */ 3530 3507 break; 3508 } 3531 3509 case 0x1: /* CD-DA */ 3532 3510 s->cbATAPISector = 2352;
Note:
See TracChangeset
for help on using the changeset viewer.