Changeset 32300 in vbox
- Timestamp:
- Sep 7, 2010 10:34:57 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 65635
- Location:
- trunk/src/VBox/Devices
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/DevAHCI.cpp
r32082 r32300 64 64 65 65 /** The current saved state version. */ 66 #define AHCI_SAVED_STATE_VERSION 3 66 #define AHCI_SAVED_STATE_VERSION 4 67 /** Saved state version before ATAPI support was added. */ 68 #define AHCI_SAVED_STATE_VERSION_PRE_ATAPI 3 67 69 /** The saved state version use in VirtualBox 3.0 and earlier. 68 70 * This was before the config was added and ahciIOTasks was dropped. */ … … 106 108 #define ATA_EVENT_STATUS_MEDIA_CHANGED 3 /**< medium was removed + new medium was inserted */ 107 109 #define ATA_EVENT_STATUS_MEDIA_EJECT_REQUESTED 4 /**< medium eject requested (eject button pressed) */ 110 111 /* Media track type */ 112 #define ATA_MEDIA_TYPE_UNKNOWN 0 /**< unknown CD type */ 113 #define ATA_MEDIA_TYPE_DATA 1 /**< Data CD */ 114 #define ATA_MEDIA_TYPE_CDDA 2 /**< CD-DA (audio) CD type */ 108 115 109 116 /** ATAPI sense info size. */ … … 457 464 /** The same for GET_EVENT_STATUS for mechanism */ 458 465 volatile uint32_t MediaEventStatus; 466 /** Media type if known. */ 467 volatile uint32_t MediaTrackType; 459 468 460 469 /** The LUN. */ … … 467 476 /** Bitmask for finished queued tasks. */ 468 477 volatile uint32_t u32QueuedTasksFinished; 469 470 uint32_t u32Alignment6;471 478 472 479 /** … … 1903 1910 1904 1911 ASMAtomicWriteU32(&pAhciPort->MediaEventStatus, ATA_EVENT_STATUS_UNCHANGED); 1912 ASMAtomicWriteU32(&pAhciPort->MediaTrackType, ATA_MEDIA_TYPE_UNKNOWN); 1905 1913 1906 1914 if (pAhciPort->pDrvBase) … … 3466 3474 } 3467 3475 3476 /** 3477 * Sets the given media track type. 3478 */ 3479 static uint32_t ataMediumTypeSet(PAHCIPort pAhciPort, uint32_t MediaTrackType) 3480 { 3481 return ASMAtomicXchgU32(&pAhciPort->MediaTrackType, MediaTrackType); 3482 } 3483 3468 3484 static int atapiPassthroughSS(PAHCIPORTTASKSTATE pAhciPortTaskState, PAHCIPort pAhciPort, int *pcbData) 3469 3485 { … … 3624 3640 ataSCSIPadStr((uint8_t *)pAhciPortTaskState->pSGListHead[0].pvSeg + 16, "CD-ROM", 16); 3625 3641 ataSCSIPadStr((uint8_t *)pAhciPortTaskState->pSGListHead[0].pvSeg + 32, "1.0", 4); 3642 } 3643 else if (pAhciPortTaskState->aATAPICmd[0] == SCSI_READ_TOC_PMA_ATIP) 3644 { 3645 /* Set the media type if we can detect it. */ 3646 uint8_t *pbBuf = (uint8_t *)pAhciPortTaskState->pSGListHead[0].pvSeg; 3647 3648 /** @todo: Implemented only for formatted TOC now. */ 3649 if ( (pAhciPortTaskState->aATAPICmd[1] & 0xf) == 0 3650 && cbTransfer >= 6) 3651 { 3652 uint32_t NewMediaType; 3653 uint32_t OldMediaType; 3654 3655 if (pbBuf[5] & 0x4) 3656 NewMediaType = ATA_MEDIA_TYPE_DATA; 3657 else 3658 NewMediaType = ATA_MEDIA_TYPE_CDDA; 3659 3660 OldMediaType = ataMediumTypeSet(pAhciPort, NewMediaType); 3661 3662 if (OldMediaType != NewMediaType) 3663 LogRel(("AHCI: LUN#%d: CD-ROM passthrough, detected %s CD\n", 3664 pAhciPort->iLUN, 3665 NewMediaType == ATA_MEDIA_TYPE_DATA 3666 ? "data" 3667 : "audio")); 3668 } 3669 else /* Play safe and set to unknown. */ 3670 ataMediumTypeSet(pAhciPort, ATA_MEDIA_TYPE_UNKNOWN); 3626 3671 } 3627 3672 if (cbTransfer) … … 4196 4241 goto sendcmd; 4197 4242 case SCSI_READ_CD: 4198 pAhciPortTaskState->cbATAPISector = 2048; /**< @todo this size is not always correct */ 4243 { 4244 /* Get sector size based on the expected sector type field. */ 4245 switch ((pbPacket[1] >> 2) & 0x7) 4246 { 4247 case 0x0: /* All types. */ 4248 if (ASMAtomicReadU32(&pAhciPort->MediaTrackType) == ATA_MEDIA_TYPE_CDDA) 4249 pAhciPortTaskState->cbATAPISector = 2352; 4250 else 4251 pAhciPortTaskState->cbATAPISector = 2048; /* Might be incorrect if we couldn't determine the type. */ 4252 break; 4253 case 0x1: /* CD-DA */ 4254 pAhciPortTaskState->cbATAPISector = 2352; 4255 break; 4256 case 0x2: /* Mode 1 */ 4257 pAhciPortTaskState->cbATAPISector = 2048; 4258 break; 4259 case 0x3: /* Mode 2 formless */ 4260 pAhciPortTaskState->cbATAPISector = 2336; 4261 break; 4262 case 0x4: /* Mode 2 form 1 */ 4263 pAhciPortTaskState->cbATAPISector = 2048; 4264 break; 4265 case 0x5: /* Mode 2 form 2 */ 4266 pAhciPortTaskState->cbATAPISector = 2324; 4267 break; 4268 default: /* Reserved */ 4269 AssertMsgFailed(("Unknown sector type\n")); 4270 pAhciPortTaskState->cbATAPISector = 0; /** @todo we should probably fail the command here already. */ 4271 } 4272 4199 4273 cbTransfer = ataBE2H_U24(pbPacket + 6) * pAhciPortTaskState->cbATAPISector; 4200 4274 enmTxDir = AHCITXDIR_READ; 4201 4275 goto sendcmd; 4276 } 4202 4277 case SCSI_READ_CD_MSF: 4203 4278 cSectors = ataMSF2LBA(pbPacket + 6) - ataMSF2LBA(pbPacket + 3); … … 6714 6789 SSMR3PutU32(pSSM, pThis->ahciPort[i].u32TasksFinished); 6715 6790 SSMR3PutU32(pSSM, pThis->ahciPort[i].u32QueuedTasksFinished); 6791 6792 /* ATAPI saved state. */ 6793 SSMR3PutBool(pSSM, pThis->ahciPort[i].fATAPI); 6794 SSMR3PutMem(pSSM, &pThis->ahciPort[i].abATAPISense[0], sizeof(pThis->ahciPort[i].abATAPISense)); 6795 SSMR3PutU8(pSSM, pThis->ahciPort[i].cNotifiedMediaChange); 6796 SSMR3PutU32(pSSM, pThis->ahciPort[i].MediaEventStatus); 6716 6797 } 6717 6798 … … 6743 6824 6744 6825 if ( uVersion != AHCI_SAVED_STATE_VERSION 6826 && uVersion != AHCI_SAVED_STATE_VERSION_PRE_ATAPI 6745 6827 && uVersion != AHCI_SAVED_STATE_VERSION_VBOX_30) 6746 6828 return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION; … … 6868 6950 SSMR3GetU32(pSSM, (uint32_t *)&pThis->ahciPort[i].u32TasksFinished); 6869 6951 SSMR3GetU32(pSSM, (uint32_t *)&pThis->ahciPort[i].u32QueuedTasksFinished); 6952 6953 if (uVersion > AHCI_SAVED_STATE_VERSION_PRE_ATAPI) 6954 { 6955 SSMR3GetBool(pSSM, &pThis->ahciPort[i].fATAPI); 6956 SSMR3GetMem(pSSM, pThis->ahciPort[i].abATAPISense, sizeof(pThis->ahciPort[i].abATAPISense)); 6957 SSMR3GetU8(pSSM, &pThis->ahciPort[i].cNotifiedMediaChange); 6958 SSMR3GetU32(pSSM, (uint32_t*)&pThis->ahciPort[i].MediaEventStatus); 6959 } 6960 else if (pThis->ahciPort[i].fATAPI) 6961 return SSMR3SetCfgError(pSSM, RT_SRC_POS, N_("Config mismatch: atapi - saved=%false config=true")); 6870 6962 } 6871 6963 … … 7034 7126 pAhciPort->cNotifiedMediaChange = 2; 7035 7127 ahciMediumInserted(pAhciPort); 7128 ataMediumTypeSet(pAhciPort, ATA_MEDIA_TYPE_UNKNOWN); 7036 7129 } 7037 7130 else … … 7071 7164 pAhciPort->cNotifiedMediaChange = 4; 7072 7165 ahciMediumRemoved(pAhciPort); 7166 ataMediumTypeSet(pAhciPort, ATA_MEDIA_TYPE_UNKNOWN); 7073 7167 } 7074 7168 else -
trunk/src/VBox/Devices/testcase/tstDeviceStructSizeRC.cpp
r32088 r32300 1194 1194 GEN_CHECK_OFF(AHCIPort, abATAPISense); 1195 1195 GEN_CHECK_OFF(AHCIPort, cNotifiedMediaChange); 1196 GEN_CHECK_OFF(AHCIPort, MediaEventStatus); 1197 GEN_CHECK_OFF(AHCIPort, MediaTrackType); 1196 1198 GEN_CHECK_OFF(AHCIPort, iLUN); 1197 1199 GEN_CHECK_OFF(AHCIPort, fResetDevice);
Note:
See TracChangeset
for help on using the changeset viewer.