VirtualBox

source: vbox/trunk/src/VBox/Devices/Storage/ATAPIPassthrough.cpp@ 63547

Last change on this file since 63547 was 63369, checked in by vboxsync, 8 years ago

warnings (gcc)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 19.7 KB
Line 
1/* $Id: ATAPIPassthrough.cpp 63369 2016-08-12 16:45:31Z vboxsync $ */
2/** @file
3 * VBox storage devices: ATAPI emulation (common code for DevATA and DevAHCI).
4 */
5
6/*
7 * Copyright (C) 2012-2016 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17#define LOG_GROUP LOG_GROUP_DEV_IDE
18#include <iprt/log.h>
19#include <iprt/assert.h>
20#include <iprt/mem.h>
21
22#include <VBox/log.h>
23#include <VBox/err.h>
24#include <VBox/cdefs.h>
25#include <VBox/scsi.h>
26
27#include "ATAPIPassthrough.h"
28
29/** The track was not detected yet. */
30#define TRACK_FLAGS_UNDETECTED RT_BIT_32(0)
31/** The track is the lead in track of the medium. */
32#define TRACK_FLAGS_LEAD_IN RT_BIT_32(1)
33/** The track is the lead out track of the medium. */
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)
38
39/**
40 * Track main data form.
41 */
42typedef enum TRACKDATAFORM
43{
44 /** Invalid data form. */
45 TRACKDATAFORM_INVALID = 0,
46 /** 2352 bytes of data. */
47 TRACKDATAFORM_CDDA,
48 /** CDDA data is pause. */
49 TRACKDATAFORM_CDDA_PAUSE,
50 /** Mode 1 with 2048 bytes sector size. */
51 TRACKDATAFORM_MODE1_2048,
52 /** Mode 1 with 2352 bytes sector size. */
53 TRACKDATAFORM_MODE1_2352,
54 /** Mode 1 with 0 bytes sector size (generated by the drive). */
55 TRACKDATAFORM_MODE1_0,
56 /** XA Mode with 2336 bytes sector size. */
57 TRACKDATAFORM_XA_2336,
58 /** XA Mode with 2352 bytes sector size. */
59 TRACKDATAFORM_XA_2352,
60 /** XA Mode with 0 bytes sector size (generated by the drive). */
61 TRACKDATAFORM_XA_0,
62 /** Mode 2 with 2336 bytes sector size. */
63 TRACKDATAFORM_MODE2_2336,
64 /** Mode 2 with 2352 bytes sector size. */
65 TRACKDATAFORM_MODE2_2352,
66 /** Mode 2 with 0 bytes sector size (generated by the drive). */
67 TRACKDATAFORM_MODE2_0
68} TRACKDATAFORM;
69
70/**
71 * Subchannel data form.
72 */
73typedef enum SUBCHNDATAFORM
74{
75 /** Invalid subchannel data form. */
76 SUBCHNDATAFORM_INVALID = 0,
77 /** 0 bytes for the subchannel (generated by the drive). */
78 SUBCHNDATAFORM_0,
79 /** 96 bytes of data for the subchannel. */
80 SUBCHNDATAFORM_96
81} SUBCHNDATAFORM;
82
83/**
84 * Track entry.
85 */
86typedef struct TRACK
87{
88 /** Start LBA of the track. */
89 int64_t iLbaStart;
90 /** Number of sectors in the track. */
91 uint32_t cSectors;
92 /** Data form of main data. */
93 TRACKDATAFORM enmMainDataForm;
94 /** Data form of sub channel. */
95 SUBCHNDATAFORM enmSubChnDataForm;
96 /** Flags for the track. */
97 uint32_t fFlags;
98} TRACK, *PTRACK;
99
100/**
101 * Media track list.
102 */
103typedef struct TRACKLIST
104{
105 /** Number of detected tracks of the current medium. */
106 unsigned cTracksCurrent;
107 /** Maximum number of tracks the list can contain. */
108 unsigned cTracksMax;
109 /** Variable list of tracks. */
110 PTRACK paTracks;
111} TRACKLIST, *PTRACKLIST;
112
113DECLINLINE(uint16_t) atapiBE2H_U16(const uint8_t *pbBuf)
114{
115 return (pbBuf[0] << 8) | pbBuf[1];
116}
117
118
119DECLINLINE(uint32_t) atapiBE2H_U24(const uint8_t *pbBuf)
120{
121 return (pbBuf[0] << 16) | (pbBuf[1] << 8) | pbBuf[2];
122}
123
124
125DECLINLINE(uint32_t) atapiBE2H_U32(const uint8_t *pbBuf)
126{
127 return (pbBuf[0] << 24) | (pbBuf[1] << 16) | (pbBuf[2] << 8) | pbBuf[3];
128}
129
130DECLINLINE(int64_t) atapiMSF2LBA(const uint8_t *pbBuf)
131{
132 return ((int64_t)(pbBuf[0] * 60 + pbBuf[1]) * 75 + pbBuf[2]) - 150; /* 2 second pregap */
133}
134
135/**
136 * Reallocate the given track list to be able to hold the given number of tracks.
137 *
138 * @returns VBox status code.
139 * @param pTrackList The track list to reallocate.
140 * @param cTracks Number of tracks the list must be able to hold.
141 * @param fFlags Flags for the reallocation.
142 */
143static int atapiTrackListReallocate(PTRACKLIST pTrackList, unsigned cTracks, uint32_t fFlags)
144{
145 int rc = VINF_SUCCESS;
146
147 if (!(fFlags & ATAPI_TRACK_LIST_REALLOCATE_FLAGS_DONT_CLEAR))
148 ATAPIPassthroughTrackListClear(pTrackList);
149
150 if (pTrackList->cTracksMax < cTracks)
151 {
152 PTRACK paTracksNew = (PTRACK)RTMemRealloc(pTrackList->paTracks, cTracks * sizeof(TRACK));
153 if (paTracksNew)
154 {
155 pTrackList->paTracks = paTracksNew;
156
157 /* Mark new tracks as undetected. */
158 for (unsigned i = pTrackList->cTracksMax; i < cTracks; i++)
159 pTrackList->paTracks[i].fFlags |= TRACK_FLAGS_UNDETECTED;
160
161 pTrackList->cTracksMax = cTracks;
162 }
163 else
164 rc = VERR_NO_MEMORY;
165 }
166
167 pTrackList->cTracksCurrent = cTracks;
168
169 return rc;
170}
171
172/**
173 * Initilizes the given track from the given CUE sheet entry.
174 *
175 * @returns nothing.
176 * @param pTrack The track to initialize.
177 * @param pbCueSheetEntry CUE sheet entry to use.
178 */
179static void atapiTrackListEntryCreateFromCueSheetEntry(PTRACK pTrack, const uint8_t *pbCueSheetEntry)
180{
181 TRACKDATAFORM enmTrackDataForm = TRACKDATAFORM_INVALID;
182 SUBCHNDATAFORM enmSubChnDataForm = SUBCHNDATAFORM_INVALID;
183
184 /* Determine size of main data based on the data form field. */
185 switch (pbCueSheetEntry[3] & 0x3f)
186 {
187 case 0x00: /* CD-DA with data. */
188 enmTrackDataForm = TRACKDATAFORM_CDDA;
189 break;
190 case 0x01: /* CD-DA without data (used for pauses between tracks). */
191 enmTrackDataForm = TRACKDATAFORM_CDDA_PAUSE;
192 break;
193 case 0x10: /* CD-ROM mode 1 */
194 case 0x12:
195 enmTrackDataForm = TRACKDATAFORM_MODE1_2048;
196 break;
197 case 0x11:
198 case 0x13:
199 enmTrackDataForm = TRACKDATAFORM_MODE1_2352;
200 break;
201 case 0x14:
202 enmTrackDataForm = TRACKDATAFORM_MODE1_0;
203 break;
204 case 0x20: /* CD-ROM XA, CD-I */
205 case 0x22:
206 enmTrackDataForm = TRACKDATAFORM_XA_2336;
207 break;
208 case 0x21:
209 case 0x23:
210 enmTrackDataForm = TRACKDATAFORM_XA_2352;
211 break;
212 case 0x24:
213 enmTrackDataForm = TRACKDATAFORM_XA_0;
214 break;
215 case 0x31: /* CD-ROM Mode 2 */
216 case 0x33:
217 enmTrackDataForm = TRACKDATAFORM_MODE2_2352;
218 break;
219 case 0x30:
220 case 0x32:
221 enmTrackDataForm = TRACKDATAFORM_MODE2_2336;
222 break;
223 case 0x34:
224 enmTrackDataForm = TRACKDATAFORM_MODE2_0;
225 break;
226 default: /* Reserved, invalid mode. Log and leave default sector size. */
227 LogRel(("ATA: Invalid data form mode %d for current CUE sheet\n",
228 pbCueSheetEntry[3] & 0x3f));
229 }
230
231 /* Determine size of sub channel data based on data form field. */
232 switch ((pbCueSheetEntry[3] & 0xc0) >> 6)
233 {
234 case 0x00: /* Sub channel all zeroes, autogenerated by the drive. */
235 enmSubChnDataForm = SUBCHNDATAFORM_0;
236 break;
237 case 0x01:
238 case 0x03:
239 enmSubChnDataForm = SUBCHNDATAFORM_96;
240 break;
241 default:
242 LogRel(("ATA: Invalid sub-channel data form mode %u for current CUE sheet\n",
243 pbCueSheetEntry[3] & 0xc0));
244 }
245
246 pTrack->enmMainDataForm = enmTrackDataForm;
247 pTrack->enmSubChnDataForm = enmSubChnDataForm;
248 pTrack->iLbaStart = atapiMSF2LBA(&pbCueSheetEntry[5]);
249 if (pbCueSheetEntry[1] != 0xaa)
250 {
251 /* Calculate number of sectors from the next entry. */
252 int64_t iLbaNext = atapiMSF2LBA(&pbCueSheetEntry[5+8]);
253 pTrack->cSectors = iLbaNext - pTrack->iLbaStart;
254 }
255 else
256 {
257 pTrack->fFlags |= TRACK_FLAGS_LEAD_OUT;
258 pTrack->cSectors = 0;
259 }
260 pTrack->fFlags &= ~TRACK_FLAGS_UNDETECTED;
261}
262
263/**
264 * Update the track list from a SEND CUE SHEET request.
265 *
266 * @returns VBox status code.
267 * @param pTrackList Track list to update.
268 * @param pbCDB CDB of the SEND CUE SHEET request.
269 * @param pvBuf The CUE sheet.
270 */
271static int atapiTrackListUpdateFromSendCueSheet(PTRACKLIST pTrackList, const uint8_t *pbCDB, const void *pvBuf)
272{
273 int rc = VINF_SUCCESS;
274 unsigned cbCueSheet = atapiBE2H_U24(pbCDB + 6);
275 unsigned cTracks = cbCueSheet / 8;
276
277 AssertReturn(cbCueSheet % 8 == 0 && cTracks, VERR_INVALID_PARAMETER);
278
279 rc = atapiTrackListReallocate(pTrackList, cTracks, 0);
280 if (RT_SUCCESS(rc))
281 {
282 const uint8_t *pbCueSheet = (uint8_t *)pvBuf;
283 PTRACK pTrack = pTrackList->paTracks;
284
285 for (unsigned i = 0; i < cTracks; i++)
286 {
287 atapiTrackListEntryCreateFromCueSheetEntry(pTrack, pbCueSheet);
288 if (i == 0)
289 pTrack->fFlags |= TRACK_FLAGS_LEAD_IN;
290 pTrack++;
291 pbCueSheet += 8;
292 }
293 }
294
295 return rc;
296}
297
298static int atapiTrackListUpdateFromSendDvdStructure(PTRACKLIST pTrackList, const uint8_t *pbCDB, const void *pvBuf)
299{
300 RT_NOREF(pTrackList, pbCDB, pvBuf);
301 return VERR_NOT_IMPLEMENTED;
302}
303
304/**
305 * Update track list from formatted TOC data.
306 *
307 * @returns VBox status code.
308 * @param pTrackList The track list to update.
309 * @param fMSF Flag whether block addresses are in MSF or LBA format.
310 * @param pbBuf Buffer holding the formatted TOC.
311 * @param cbBuffer Size of the buffer.
312 */
313static int atapiTrackListUpdateFromFormattedToc(PTRACKLIST pTrackList, uint8_t iTrack,
314 bool fMSF, const uint8_t *pbBuf, uint32_t cbBuffer)
315{
316 RT_NOREF(iTrack, cbBuffer); /** @todo unused parameters */
317 int rc = VINF_SUCCESS;
318 unsigned cbToc = atapiBE2H_U16(pbBuf);
319 uint8_t iTrackFirst = pbBuf[2];
320 unsigned cTracks;
321
322 cbToc -= 2;
323 pbBuf += 4;
324 AssertReturn(cbToc % 8 == 0, VERR_INVALID_PARAMETER);
325
326 cTracks = cbToc / 8 + iTrackFirst;
327
328 rc = atapiTrackListReallocate(pTrackList, cTracks, ATAPI_TRACK_LIST_REALLOCATE_FLAGS_DONT_CLEAR);
329 if (RT_SUCCESS(rc))
330 {
331 PTRACK pTrack = &pTrackList->paTracks[iTrackFirst];
332
333 for (unsigned i = iTrackFirst; i < cTracks; i++)
334 {
335 if (pbBuf[1] & 0x4)
336 pTrack->enmMainDataForm = TRACKDATAFORM_MODE1_2048;
337 else
338 pTrack->enmMainDataForm = TRACKDATAFORM_CDDA;
339
340 pTrack->enmSubChnDataForm = SUBCHNDATAFORM_0;
341 if (fMSF)
342 pTrack->iLbaStart = atapiMSF2LBA(&pbBuf[4]);
343 else
344 pTrack->iLbaStart = atapiBE2H_U32(&pbBuf[4]);
345
346 if (pbBuf[2] != 0xaa)
347 {
348 /* Calculate number of sectors from the next entry. */
349 int64_t iLbaNext;
350
351 if (fMSF)
352 iLbaNext = atapiMSF2LBA(&pbBuf[4+8]);
353 else
354 iLbaNext = atapiBE2H_U32(&pbBuf[4+8]);
355
356 pTrack->cSectors = iLbaNext - pTrack->iLbaStart;
357 }
358 else
359 pTrack->cSectors = 0;
360
361 pTrack->fFlags &= ~TRACK_FLAGS_UNDETECTED;
362 pbBuf += 8;
363 pTrack++;
364 }
365 }
366
367 return rc;
368}
369
370static int atapiTrackListUpdateFromReadTocPmaAtip(PTRACKLIST pTrackList, const uint8_t *pbCDB, const void *pvBuf)
371{
372 int rc = VINF_SUCCESS;
373 uint16_t cbBuffer = atapiBE2H_U16(&pbCDB[7]);
374 bool fMSF = (pbCDB[1] & 0x2) != 0;
375 uint8_t uFmt = pbCDB[2] & 0xf;
376 uint8_t iTrack = pbCDB[6];
377
378 switch (uFmt)
379 {
380 case 0x00:
381 rc = atapiTrackListUpdateFromFormattedToc(pTrackList, iTrack, fMSF, (uint8_t *)pvBuf, cbBuffer);
382 break;
383 case 0x01:
384 case 0x02:
385 case 0x03:
386 case 0x04:
387 rc = VERR_NOT_IMPLEMENTED;
388 break;
389 case 0x05:
390 rc = VINF_SUCCESS; /* Does not give information about the tracklist. */
391 break;
392 default:
393 rc = VERR_INVALID_PARAMETER;
394 }
395
396 return rc;
397}
398
399static int atapiTrackListUpdateFromReadTrackInformation(PTRACKLIST pTrackList, const uint8_t *pbCDB, const void *pvBuf)
400{
401 RT_NOREF(pTrackList, pbCDB, pvBuf);
402 return VERR_NOT_IMPLEMENTED;
403}
404
405static int atapiTrackListUpdateFromReadDvdStructure(PTRACKLIST pTrackList, const uint8_t *pbCDB, const void *pvBuf)
406{
407 RT_NOREF(pTrackList, pbCDB, pvBuf);
408 return VERR_NOT_IMPLEMENTED;
409}
410
411static int atapiTrackListUpdateFromReadDiscInformation(PTRACKLIST pTrackList, const uint8_t *pbCDB, const void *pvBuf)
412{
413 RT_NOREF(pTrackList, pbCDB, pvBuf);
414 return VERR_NOT_IMPLEMENTED;
415}
416
417#ifdef LOG_ENABLED
418
419/**
420 * Converts the given track data form to a string.
421 *
422 * @returns Track data form as a string.
423 * @param enmTrackDataForm The track main data form.
424 */
425static const char *atapiTrackListMainDataFormToString(TRACKDATAFORM enmTrackDataForm)
426{
427 switch (enmTrackDataForm)
428 {
429 case TRACKDATAFORM_CDDA:
430 return "CD-DA";
431 case TRACKDATAFORM_CDDA_PAUSE:
432 return "CD-DA Pause";
433 case TRACKDATAFORM_MODE1_2048:
434 return "Mode 1 (2048 bytes)";
435 case TRACKDATAFORM_MODE1_2352:
436 return "Mode 1 (2352 bytes)";
437 case TRACKDATAFORM_MODE1_0:
438 return "Mode 1 (0 bytes)";
439 case TRACKDATAFORM_XA_2336:
440 return "XA (2336 bytes)";
441 case TRACKDATAFORM_XA_2352:
442 return "XA (2352 bytes)";
443 case TRACKDATAFORM_XA_0:
444 return "XA (0 bytes)";
445 case TRACKDATAFORM_MODE2_2336:
446 return "Mode 2 (2336 bytes)";
447 case TRACKDATAFORM_MODE2_2352:
448 return "Mode 2 (2352 bytes)";
449 case TRACKDATAFORM_MODE2_0:
450 return "Mode 2 (0 bytes)";
451 case TRACKDATAFORM_INVALID:
452 default:
453 return "Invalid";
454 }
455}
456
457/**
458 * Converts the given subchannel data form to a string.
459 *
460 * @returns Subchannel data form as a string.
461 * @param enmSubChnDataForm The subchannel main data form.
462 */
463static const char *atapiTrackListSubChnDataFormToString(SUBCHNDATAFORM enmSubChnDataForm)
464{
465 switch (enmSubChnDataForm)
466 {
467 case SUBCHNDATAFORM_0:
468 return "0";
469 case SUBCHNDATAFORM_96:
470 return "96";
471 case SUBCHNDATAFORM_INVALID:
472 default:
473 return "Invalid";
474 }
475}
476
477/**
478 * Dump the complete track list to the release log.
479 *
480 * @returns nothing.
481 * @param pTrackList The track list to dump.
482 */
483static void atapiTrackListDump(PTRACKLIST pTrackList)
484{
485 LogRel(("Track List: cTracks=%u\n", pTrackList->cTracksCurrent));
486 for (unsigned i = 0; i < pTrackList->cTracksCurrent; i++)
487 {
488 PTRACK pTrack = &pTrackList->paTracks[i];
489
490 LogRel((" Track %u: LBAStart=%lld cSectors=%u enmMainDataForm=%s enmSubChnDataForm=%s fFlags=[%s%s%s]\n",
491 i, pTrack->iLbaStart, pTrack->cSectors, atapiTrackListMainDataFormToString(pTrack->enmMainDataForm),
492 atapiTrackListSubChnDataFormToString(pTrack->enmSubChnDataForm),
493 pTrack->fFlags & TRACK_FLAGS_UNDETECTED ? "UNDETECTED " : "",
494 pTrack->fFlags & TRACK_FLAGS_LEAD_IN ? "Lead-In " : "",
495 pTrack->fFlags & TRACK_FLAGS_LEAD_OUT ? "Lead-Out" : ""));
496 }
497}
498
499#endif /* LOG_ENABLED */
500
501DECLHIDDEN(int) ATAPIPassthroughTrackListCreateEmpty(PTRACKLIST *ppTrackList)
502{
503 int rc = VERR_NO_MEMORY;
504 PTRACKLIST pTrackList = (PTRACKLIST)RTMemAllocZ(sizeof(TRACKLIST));
505
506 if (pTrackList)
507 {
508 rc = VINF_SUCCESS;
509 *ppTrackList = pTrackList;
510 }
511
512 return rc;
513}
514
515DECLHIDDEN(void) ATAPIPassthroughTrackListDestroy(PTRACKLIST pTrackList)
516{
517 if (pTrackList->paTracks)
518 RTMemFree(pTrackList->paTracks);
519 RTMemFree(pTrackList);
520}
521
522DECLHIDDEN(void) ATAPIPassthroughTrackListClear(PTRACKLIST pTrackList)
523{
524 AssertPtrReturnVoid(pTrackList);
525
526 pTrackList->cTracksCurrent = 0;
527
528 /* Mark all tracks as undetected. */
529 for (unsigned i = 0; i < pTrackList->cTracksMax; i++)
530 pTrackList->paTracks[i].fFlags |= TRACK_FLAGS_UNDETECTED;
531}
532
533DECLHIDDEN(int) ATAPIPassthroughTrackListUpdate(PTRACKLIST pTrackList, const uint8_t *pbCDB, const void *pvBuf)
534{
535 int rc = VINF_SUCCESS;
536
537 switch (pbCDB[0])
538 {
539 case SCSI_SEND_CUE_SHEET:
540 rc = atapiTrackListUpdateFromSendCueSheet(pTrackList, pbCDB, pvBuf);
541 break;
542 case SCSI_SEND_DVD_STRUCTURE:
543 rc = atapiTrackListUpdateFromSendDvdStructure(pTrackList, pbCDB, pvBuf);
544 break;
545 case SCSI_READ_TOC_PMA_ATIP:
546 rc = atapiTrackListUpdateFromReadTocPmaAtip(pTrackList, pbCDB, pvBuf);
547 break;
548 case SCSI_READ_TRACK_INFORMATION:
549 rc = atapiTrackListUpdateFromReadTrackInformation(pTrackList, pbCDB, pvBuf);
550 break;
551 case SCSI_READ_DVD_STRUCTURE:
552 rc = atapiTrackListUpdateFromReadDvdStructure(pTrackList, pbCDB, pvBuf);
553 break;
554 case SCSI_READ_DISC_INFORMATION:
555 rc = atapiTrackListUpdateFromReadDiscInformation(pTrackList, pbCDB, pvBuf);
556 break;
557 default:
558 LogRel(("ATAPI: Invalid opcode %#x while determining media layout\n", pbCDB[0]));
559 rc = VERR_INVALID_PARAMETER;
560 }
561
562#ifdef LOG_ENABLED
563 atapiTrackListDump(pTrackList);
564#endif
565
566 return rc;
567}
568
569DECLHIDDEN(uint32_t) ATAPIPassthroughTrackListGetSectorSizeFromLba(PTRACKLIST pTrackList, uint32_t iAtapiLba)
570{
571 PTRACK pTrack = NULL;
572 uint32_t cbAtapiSector = 2048;
573
574 if (pTrackList->cTracksCurrent)
575 {
576 if ( iAtapiLba > UINT32_C(0xffff4fa1)
577 && (int32_t)iAtapiLba < -150)
578 {
579 /* Lead-In area, this is always the first entry in the cue sheet. */
580 pTrack = pTrackList->paTracks;
581 Assert(pTrack->fFlags & TRACK_FLAGS_LEAD_IN);
582 LogFlowFunc(("Selected Lead-In area\n"));
583 }
584 else
585 {
586 int64_t iAtapiLba64 = (int32_t)iAtapiLba;
587 pTrack = &pTrackList->paTracks[1];
588
589 /* Go through the track list and find the correct entry. */
590 for (unsigned i = 1; i < pTrackList->cTracksCurrent - 1; i++)
591 {
592 if (pTrack->fFlags & TRACK_FLAGS_UNDETECTED)
593 continue;
594
595 if ( pTrack->iLbaStart <= iAtapiLba64
596 && iAtapiLba64 < pTrack->iLbaStart + pTrack->cSectors)
597 break;
598
599 pTrack++;
600 }
601 }
602
603 if (pTrack)
604 {
605 switch (pTrack->enmMainDataForm)
606 {
607 case TRACKDATAFORM_CDDA:
608 case TRACKDATAFORM_MODE1_2352:
609 case TRACKDATAFORM_XA_2352:
610 case TRACKDATAFORM_MODE2_2352:
611 cbAtapiSector = 2352;
612 break;
613 case TRACKDATAFORM_MODE1_2048:
614 cbAtapiSector = 2048;
615 break;
616 case TRACKDATAFORM_CDDA_PAUSE:
617 case TRACKDATAFORM_MODE1_0:
618 case TRACKDATAFORM_XA_0:
619 case TRACKDATAFORM_MODE2_0:
620 cbAtapiSector = 0;
621 break;
622 case TRACKDATAFORM_XA_2336:
623 case TRACKDATAFORM_MODE2_2336:
624 cbAtapiSector = 2336;
625 break;
626 case TRACKDATAFORM_INVALID:
627 default:
628 AssertMsgFailed(("Invalid track data form %d\n", pTrack->enmMainDataForm));
629 }
630
631 switch (pTrack->enmSubChnDataForm)
632 {
633 case SUBCHNDATAFORM_0:
634 break;
635 case SUBCHNDATAFORM_96:
636 cbAtapiSector += 96;
637 break;
638 case SUBCHNDATAFORM_INVALID:
639 default:
640 AssertMsgFailed(("Invalid subchannel data form %d\n", pTrack->enmSubChnDataForm));
641 }
642 }
643 }
644
645 return cbAtapiSector;
646}
647
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette