VirtualBox

Changeset 32300 in vbox


Ignore:
Timestamp:
Sep 7, 2010 10:34:57 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
65635
Message:

AHCI/ATAPI: port fixes for audio CD over and implement support for saved states

Location:
trunk/src/VBox/Devices
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/DevAHCI.cpp

    r32082 r32300  
    6464
    6565/** 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
    6769/** The saved state version use in VirtualBox 3.0 and earlier.
    6870 * This was before the config was added and ahciIOTasks was dropped. */
     
    106108#define ATA_EVENT_STATUS_MEDIA_CHANGED          3    /**< medium was removed + new medium was inserted */
    107109#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 */
    108115
    109116/** ATAPI sense info size. */
     
    457464    /** The same for GET_EVENT_STATUS for mechanism */
    458465    volatile uint32_t               MediaEventStatus;
     466    /** Media type if known. */
     467    volatile uint32_t               MediaTrackType;
    459468
    460469    /** The LUN. */
     
    467476    /** Bitmask for finished queued tasks. */
    468477    volatile uint32_t               u32QueuedTasksFinished;
    469 
    470     uint32_t                        u32Alignment6;
    471478
    472479    /**
     
    19031910
    19041911    ASMAtomicWriteU32(&pAhciPort->MediaEventStatus, ATA_EVENT_STATUS_UNCHANGED);
     1912    ASMAtomicWriteU32(&pAhciPort->MediaTrackType, ATA_MEDIA_TYPE_UNKNOWN);
    19051913
    19061914    if (pAhciPort->pDrvBase)
     
    34663474}
    34673475
     3476/**
     3477 * Sets the given media track type.
     3478 */
     3479static uint32_t ataMediumTypeSet(PAHCIPort pAhciPort, uint32_t MediaTrackType)
     3480{
     3481    return ASMAtomicXchgU32(&pAhciPort->MediaTrackType, MediaTrackType);
     3482}
     3483
    34683484static int atapiPassthroughSS(PAHCIPORTTASKSTATE pAhciPortTaskState, PAHCIPort pAhciPort, int *pcbData)
    34693485{
     
    36243640                ataSCSIPadStr((uint8_t *)pAhciPortTaskState->pSGListHead[0].pvSeg + 16, "CD-ROM", 16);
    36253641                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);
    36263671            }
    36273672            if (cbTransfer)
     
    41964241            goto sendcmd;
    41974242        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
    41994273            cbTransfer = ataBE2H_U24(pbPacket + 6) * pAhciPortTaskState->cbATAPISector;
    42004274            enmTxDir = AHCITXDIR_READ;
    42014275            goto sendcmd;
     4276        }
    42024277        case SCSI_READ_CD_MSF:
    42034278            cSectors = ataMSF2LBA(pbPacket + 6) - ataMSF2LBA(pbPacket + 3);
     
    67146789        SSMR3PutU32(pSSM, pThis->ahciPort[i].u32TasksFinished);
    67156790        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);
    67166797    }
    67176798
     
    67436824
    67446825    if (    uVersion != AHCI_SAVED_STATE_VERSION
     6826        &&  uVersion != AHCI_SAVED_STATE_VERSION_PRE_ATAPI
    67456827        &&  uVersion != AHCI_SAVED_STATE_VERSION_VBOX_30)
    67466828        return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
     
    68686950            SSMR3GetU32(pSSM, (uint32_t *)&pThis->ahciPort[i].u32TasksFinished);
    68696951            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"));
    68706962        }
    68716963
     
    70347126            pAhciPort->cNotifiedMediaChange = 2;
    70357127        ahciMediumInserted(pAhciPort);
     7128        ataMediumTypeSet(pAhciPort, ATA_MEDIA_TYPE_UNKNOWN);
    70367129    }
    70377130    else
     
    70717164        pAhciPort->cNotifiedMediaChange = 4;
    70727165        ahciMediumRemoved(pAhciPort);
     7166        ataMediumTypeSet(pAhciPort, ATA_MEDIA_TYPE_UNKNOWN);
    70737167    }
    70747168    else
  • trunk/src/VBox/Devices/testcase/tstDeviceStructSizeRC.cpp

    r32088 r32300  
    11941194    GEN_CHECK_OFF(AHCIPort, abATAPISense);
    11951195    GEN_CHECK_OFF(AHCIPort, cNotifiedMediaChange);
     1196    GEN_CHECK_OFF(AHCIPort, MediaEventStatus);
     1197    GEN_CHECK_OFF(AHCIPort, MediaTrackType);
    11961198    GEN_CHECK_OFF(AHCIPort, iLUN);
    11971199    GEN_CHECK_OFF(AHCIPort, fResetDevice);
Note: See TracChangeset for help on using the changeset viewer.

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