VirtualBox

Changeset 43596 in vbox


Ignore:
Timestamp:
Oct 10, 2012 2:11:05 PM (12 years ago)
Author:
vboxsync
Message:

AHCI: Use new code for ATAPI passthrough

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

Legend:

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

    r43472 r43596  
    5656#include "PIIX3ATABmDma.h"
    5757#include "ide.h"
     58#include "ATAPIPassthrough.h"
    5859#include "VBoxDD.h"
    5960
     
    125126/* Media track type */
    126127#define ATA_MEDIA_TYPE_UNKNOWN                  0    /**< unknown CD type */
    127 #define ATA_MEDIA_TYPE_DATA                     1    /**< Data CD */
    128 #define ATA_MEDIA_TYPE_CDDA                     2    /**< CD-DA  (audio) CD type */
    129128
    130129/** ATAPI sense info size. */
     
    516515    /** First task throwing an error. */
    517516    R3PTRTYPE(volatile PAHCIREQ)    pTaskErr;
    518 
    519 #if HC_ARCH_BITS == 32
    520     uint32_t                        u32Alignment4;
    521 #endif
     517    /** The current tracklist of the loaded medium if passthrough is used. */
     518    R3PTRTYPE(PTRACKLIST)           pTrackList;
    522519
    523520    /** Release statistics: number of DMA commands. */
     
    30153012    p[102] = RT_H2LE_U16(pAhciPort->cTotalSectors >> 32);
    30163013    p[103] = RT_H2LE_U16(pAhciPort->cTotalSectors >> 48);
     3014
    30173015    if (pAhciPort->fNonRotational)
    30183016        p[217] = RT_H2LE_U16(1); /* Non-rotational medium */
     
    39703968    if (RT_SUCCESS(rc))
    39713969    {
    3972        Assert(cbTransfer <= pAhciReq->cbTransfer);
     3970        /* Do post processing for certain commands. */
     3971        switch (pAhciReq->aATAPICmd[0])
     3972        {
     3973            case SCSI_SEND_CUE_SHEET:
     3974            case SCSI_READ_TOC_PMA_ATIP:
     3975            {
     3976                if (!pAhciPort->pTrackList)
     3977                    rc = ATAPIPassthroughTrackListCreateEmpty(&pAhciPort->pTrackList);
     3978
     3979                if (RT_SUCCESS(rc))
     3980                    rc = ATAPIPassthroughTrackListUpdate(pAhciPort->pTrackList, pAhciReq->aATAPICmd, pvBuf);
     3981
     3982                if (   RT_FAILURE(rc)
     3983                    && pAhciPort->cErrors++ < MAX_LOG_REL_ERRORS)
     3984                    LogRel(("AHCI: Error (%Rrc) while updating the tracklist during %s, burning the disc might fail\n",
     3985                            rc, pAhciReq->aATAPICmd[0] == SCSI_SEND_CUE_SHEET ? "SEND CUE SHEET" : "READ TOC/PMA/ATIP"));
     3986                break;
     3987            }
     3988            case SCSI_SYNCHRONIZE_CACHE:
     3989            {
     3990                ATAPIPassthroughTrackListClear(pAhciPort->pTrackList);
     3991                break;
     3992            }
     3993        }
    39733994
    39743995        if (pAhciReq->enmTxDir == AHCITXDIR_READ)
    39753996        {
     3997           Assert(cbTransfer <= pAhciReq->cbTransfer);
     3998
    39763999            if (pAhciReq->aATAPICmd[0] == SCSI_INQUIRY)
    39774000            {
     
    39854008                if (cbTransfer >= 32 + 4)
    39864009                    ataSCSIPadStr((uint8_t *)pvBuf + 32, "1.0", 4);
    3987             }
    3988             else if (   pAhciReq->aATAPICmd[0] == SCSI_READ_TOC_PMA_ATIP
    3989                      && (pAhciReq->aATAPICmd[2] & 0xf) != 0x05
    3990                      && pAhciReq->aATAPICmd[6] != 0xaa)
    3991             {
    3992                 /* Set the media type if we can detect it. */
    3993                 uint8_t *pbBuf = (uint8_t *)pvBuf;
    3994 
    3995                 /** @todo: Implemented only for formatted TOC now. */
    3996                 if (   (pAhciReq->aATAPICmd[1] & 0xf) == 0
    3997                     && cbTransfer >= 6)
    3998                 {
    3999                     uint32_t NewMediaType;
    4000                     uint32_t OldMediaType;
    4001 
    4002                     if (pbBuf[5] & 0x4)
    4003                         NewMediaType = ATA_MEDIA_TYPE_DATA;
    4004                     else
    4005                         NewMediaType = ATA_MEDIA_TYPE_CDDA;
    4006 
    4007                     OldMediaType = ataMediumTypeSet(pAhciPort, NewMediaType);
    4008 
    4009                     if (OldMediaType != NewMediaType)
    4010                         LogRel(("AHCI: LUN#%d: CD-ROM passthrough, detected %s CD\n",
    4011                                 pAhciPort->iLUN,
    4012                                 NewMediaType == ATA_MEDIA_TYPE_DATA
    4013                                 ? "data"
    4014                                 : "audio"));
    4015                 }
    4016                 else /* Play safe and set to unknown. */
    4017                     ataMediumTypeSet(pAhciPort, ATA_MEDIA_TYPE_UNKNOWN);
    40184010            }
    40194011
     
    46064598            goto sendcmd;
    46074599        case SCSI_READ_CD:
     4600        case SCSI_READ_CD_MSF:
    46084601        {
    46094602            /* Get sector size based on the expected sector type field. */
     
    46114604            {
    46124605                case 0x0: /* All types. */
    4613                     if (ASMAtomicReadU32(&pAhciPort->MediaTrackType) == ATA_MEDIA_TYPE_CDDA)
    4614                         pAhciReq->cbATAPISector = 2352;
     4606                {
     4607                    uint32_t iLbaStart;
     4608
     4609                    if (pbPacket[0] == SCSI_READ_CD)
     4610                        iLbaStart = ataBE2H_U32(&pbPacket[2]);
     4611                    else
     4612                        iLbaStart = ataMSF2LBA(&pbPacket[3]);
     4613
     4614                    if (pAhciPort->pTrackList)
     4615                        pAhciReq->cbATAPISector = ATAPIPassthroughTrackListGetSectorSizeFromLba(pAhciPort->pTrackList, iLbaStart);
    46154616                    else
    46164617                        pAhciReq->cbATAPISector = 2048; /* Might be incorrect if we couldn't determine the type. */
    46174618                    break;
     4619                }
    46184620                case 0x1: /* CD-DA */
    46194621                    pAhciReq->cbATAPISector = 2352;
     
    46364638            }
    46374639
    4638             cbTransfer = ataBE2H_U24(pbPacket + 6) * pAhciReq->cbATAPISector;
     4640            if (pbPacket[0] == SCSI_READ_CD)
     4641                cbTransfer = ataBE2H_U24(pbPacket + 6) * pAhciReq->cbATAPISector;
     4642            else /* SCSI_READ_MSF */
     4643            {
     4644                cSectors = ataMSF2LBA(pbPacket + 6) - ataMSF2LBA(pbPacket + 3);
     4645                if (cSectors > 32)
     4646                    cSectors = 32; /* Limit transfer size to 64~74K. Safety first. In any case this can only harm software doing CDDA extraction. */
     4647                cbTransfer = cSectors * pAhciReq->cbATAPISector;
     4648            }
    46394649            enmTxDir = AHCITXDIR_READ;
    46404650            goto sendcmd;
    46414651        }
    4642         case SCSI_READ_CD_MSF:
    4643             cSectors = ataMSF2LBA(pbPacket + 6) - ataMSF2LBA(pbPacket + 3);
    4644             if (cSectors > 32)
    4645                 cSectors = 32; /* Limit transfer size to 64~74K. Safety first. In any case this can only harm software doing CDDA extraction. */
    4646             pAhciReq->cbATAPISector = 2048; /**< @todo this size is not always correct */
    4647             cbTransfer = cSectors * pAhciReq->cbATAPISector;
    4648             enmTxDir = AHCITXDIR_READ;
    4649             goto sendcmd;
    46504652        case SCSI_READ_DISC_INFORMATION:
    46514653            cbTransfer = ataBE2H_U16(pbPacket + 7);
     
    47344736            goto sendcmd;
    47354737        case SCSI_WRITE_10:
     4738        case SCSI_WRITE_AND_VERIFY_10:
    47364739            iATAPILBA = ataBE2H_U32(pbPacket + 2);
    47374740            cSectors = ataBE2H_U16(pbPacket + 7);
    47384741            Log2(("ATAPI PT: lba %d sectors %d\n", iATAPILBA, cSectors));
    4739             pAhciReq->cbATAPISector = 2048; /**< @todo this size is not always correct */
     4742            if (pAhciPort->pTrackList)
     4743                pAhciReq->cbATAPISector = ATAPIPassthroughTrackListGetSectorSizeFromLba(pAhciPort->pTrackList, iATAPILBA);
     4744            else
     4745                pAhciReq->cbATAPISector = 2048;
    47404746            cbTransfer = cSectors * pAhciReq->cbATAPISector;
    47414747            enmTxDir = AHCITXDIR_WRITE;
     
    47454751            cSectors = ataBE2H_U32(pbPacket + 6);
    47464752            Log2(("ATAPI PT: lba %d sectors %d\n", iATAPILBA, cSectors));
    4747             pAhciReq->cbATAPISector = 2048; /**< @todo this size is not always correct */
     4753            if (pAhciPort->pTrackList)
     4754                pAhciReq->cbATAPISector = ATAPIPassthroughTrackListGetSectorSizeFromLba(pAhciPort->pTrackList, iATAPILBA);
     4755            else
     4756                pAhciReq->cbATAPISector = 2048;
    47484757            cbTransfer = cSectors * pAhciReq->cbATAPISector;
    4749             enmTxDir = AHCITXDIR_WRITE;
    4750             goto sendcmd;
    4751         case SCSI_WRITE_AND_VERIFY_10:
    4752             iATAPILBA = ataBE2H_U32(pbPacket + 2);
    4753             cSectors = ataBE2H_U16(pbPacket + 7);
    4754             Log2(("ATAPI PT: lba %d sectors %d\n", iATAPILBA, cSectors));
    4755             /* The sector size is determined by the async I/O thread. */
    4756             pAhciReq->cbATAPISector = 0;
    4757             /* Preliminary, will be corrected once the sector size is known. */
    4758             cbTransfer = cSectors;
    47594758            enmTxDir = AHCITXDIR_WRITE;
    47604759            goto sendcmd;
  • trunk/src/VBox/Devices/testcase/tstDeviceStructSizeRC.cpp

    r43568 r43596  
    11781178    GEN_CHECK_OFF(AHCIPort, aCachedTasks);
    11791179    GEN_CHECK_OFF(AHCIPort, pTaskErr);
     1180    GEN_CHECK_OFF(AHCIPort, pTrackList);
    11801181    GEN_CHECK_OFF(AHCIPort, StatDMA);
    11811182    GEN_CHECK_OFF(AHCIPort, StatBytesWritten);
Note: See TracChangeset for help on using the changeset viewer.

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