- Timestamp:
- Aug 30, 2010 12:26:18 PM (14 years ago)
- Location:
- trunk/src/VBox/Devices
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/DevATA.cpp
r32082 r32088 98 98 #define ATA_EVENT_STATUS_MEDIA_CHANGED 3 /**< medium was removed + new medium was inserted */ 99 99 #define ATA_EVENT_STATUS_MEDIA_EJECT_REQUESTED 4 /**< medium eject requested (eject button pressed) */ 100 101 /* Media track type */ 102 #define ATA_MEDIA_TYPE_UNKNOWN 0 /**< unknown CD type */ 103 #define ATA_MEDIA_TYPE_DATA 1 /**< Data CD */ 104 #define ATA_MEDIA_TYPE_CDDA 2 /**< CD-DA (audio) CD type */ 100 105 101 106 /** … … 207 212 volatile uint32_t MediaEventStatus; 208 213 209 uint32_t Alignment0; 214 /** Media type if known. */ 215 volatile uint32_t MediaTrackType; 210 216 211 217 /** The status LED state for this drive. */ … … 1878 1884 } 1879 1885 1886 /** 1887 * Sets the given media track type. 1888 */ 1889 static uint32_t ataMediumTypeSet(ATADevState *s, uint32_t MediaTrackType) 1890 { 1891 return ASMAtomicXchgU32(&s->MediaTrackType, MediaTrackType); 1892 } 1880 1893 1881 1894 static bool atapiPassthroughSS(ATADevState *s) … … 2034 2047 ataSCSIPadStr(s->CTX_SUFF(pbIOBuffer) + 16, "CD-ROM", 16); 2035 2048 ataSCSIPadStr(s->CTX_SUFF(pbIOBuffer) + 32, "1.0", 4); 2049 } 2050 else if (s->aATAPICmd[0] == SCSI_READ_TOC_PMA_ATIP) 2051 { 2052 /* Set the media type if we can detect it. */ 2053 uint8_t *pbBuf = s->CTX_SUFF(pbIOBuffer); 2054 2055 /** @todo: Implemented only for formatted TOC now. */ 2056 if ( (s->aATAPICmd[1] & 0xf) == 0 2057 && cbTransfer >= 6) 2058 { 2059 uint32_t NewMediaType; 2060 uint32_t OldMediaType; 2061 2062 if (pbBuf[5] & 0x4) 2063 NewMediaType = ATA_MEDIA_TYPE_DATA; 2064 else 2065 NewMediaType = ATA_MEDIA_TYPE_CDDA; 2066 2067 OldMediaType = ataMediumTypeSet(s, NewMediaType); 2068 2069 if (OldMediaType != NewMediaType) 2070 LogRel(("PIIX3 ATA: LUN#%d: CD-ROM passthrough, detected %s CD\n", 2071 s->iLUN, 2072 NewMediaType == ATA_MEDIA_TYPE_DATA 2073 ? "data" 2074 : "audio")); 2075 } 2076 else /* Play safe and set to unknown. */ 2077 ataMediumTypeSet(s, ATA_MEDIA_TYPE_UNKNOWN); 2036 2078 } 2037 2079 if (cbTransfer) … … 3189 3231 goto sendcmd; 3190 3232 case SCSI_READ_CD: 3191 s->cbATAPISector = 2048; /**< @todo this size is not always correct */ 3233 { 3234 /* Get sector size based on the expected sector type field. */ 3235 switch ((pbPacket[1] >> 2) & 0x7) 3236 { 3237 case 0x0: /* All types. */ 3238 if (ASMAtomicReadU32(&s->MediaTrackType) == ATA_MEDIA_TYPE_CDDA) 3239 s->cbATAPISector = 2352; 3240 else 3241 s->cbATAPISector = 2048; /* Might be incorrect if we couldn't determine the type. */ 3242 break; 3243 case 0x1: /* CD-DA */ 3244 s->cbATAPISector = 2352; 3245 break; 3246 case 0x2: /* Mode 1 */ 3247 s->cbATAPISector = 2048; 3248 break; 3249 case 0x3: /* Mode 2 formless */ 3250 s->cbATAPISector = 2336; 3251 break; 3252 case 0x4: /* Mode 2 form 1 */ 3253 s->cbATAPISector = 2048; 3254 break; 3255 case 0x5: /* Mode 2 form 2 */ 3256 s->cbATAPISector = 2324; 3257 break; 3258 default: /* Reserved */ 3259 AssertMsgFailed(("Unknown sector type\n")); 3260 s->cbATAPISector = 0; /** @todo we should probably fail the command here already. */ 3261 } 3262 3192 3263 cbTransfer = ataBE2H_U24(pbPacket + 6) * s->cbATAPISector; 3193 3264 uTxDir = PDMBLOCKTXDIR_FROM_DEVICE; 3194 3265 goto sendcmd; 3266 } 3195 3267 case SCSI_READ_CD_MSF: 3196 3268 cSectors = ataMSF2LBA(pbPacket + 6) - ataMSF2LBA(pbPacket + 3); … … 3435 3507 } 3436 3508 3437 3438 3509 /** 3439 3510 * Called when a media is mounted. … … 3461 3532 pIf->cNotifiedMediaChange = 2; 3462 3533 ataMediumInserted(pIf); 3534 ataMediumTypeSet(pIf, ATA_MEDIA_TYPE_UNKNOWN); 3463 3535 } 3464 3536 … … 3481 3553 pIf->cNotifiedMediaChange = 4; 3482 3554 ataMediumRemoved(pIf); 3555 ataMediumTypeSet(pIf, ATA_MEDIA_TYPE_UNKNOWN); 3483 3556 } 3484 3557 … … 3497 3570 s->cNotifiedMediaChange = 0; 3498 3571 ASMAtomicWriteU32(&s->MediaEventStatus, ATA_EVENT_STATUS_UNCHANGED); 3572 ASMAtomicWriteU32(&s->MediaTrackType, ATA_MEDIA_TYPE_UNKNOWN); 3499 3573 ataUnsetIRQ(s); 3500 3574 -
trunk/src/VBox/Devices/testcase/tstDeviceStructSizeRC.cpp
r32069 r32088 713 713 GEN_CHECK_OFF(ATADevState, cNotifiedMediaChange); 714 714 GEN_CHECK_OFF(ATADevState, MediaEventStatus); 715 GEN_CHECK_OFF(ATADevState, MediaTrackType); 715 716 GEN_CHECK_OFF(ATADevState, Led); 716 717 GEN_CHECK_OFF(ATADevState, cbIOBuffer);
Note:
See TracChangeset
for help on using the changeset viewer.