VirtualBox

Changeset 59322 in vbox


Ignore:
Timestamp:
Jan 13, 2016 2:32:34 PM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
104991
Message:

Audio/HDA: Fixes for stream DMA counters; also take them into account upon save/restore, more (debug) checks.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Audio/DevIchHda.cpp

    r59283 r59322  
    572572typedef struct HDASTREAMSTATE
    573573{
    574     /** Number of BDLEs (Buffer Descriptor List Entry).
    575      *  Should be SDnLVI + 1 usually. */
    576     uint16_t            cBDLE;
    577574    /** Current BDLE to use. Wraps around to 0 if
    578575     *  maximum (cBDLE) is reached. */
     
    590587    /** Event signalling that the stream's state has been changed. */
    591588    RTSEMEVENT          hStateChangedEvent;
    592     /** Array of BDLEs. */
    593     R3PTRTYPE(PHDABDLE) paBDLE;
     589    /** Current BDLE (Buffer Descriptor List Entry). */
     590    HDABDLE             BDLE;
    594591} HDASTREAMSTATE, *PHDASTREAMSTATE;
    595592
     
    806803 * {IOB}SDn read/write functions.
    807804 */
    808 static int hdaRegWriteSDCBL(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
    809 static int hdaRegWriteSDCTL(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
    810 static int hdaRegWriteSDSTS(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
    811 static int hdaRegWriteSDLVI(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
    812 static int hdaRegWriteSDFIFOW(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
    813 static int hdaRegWriteSDFIFOS(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
    814 static int hdaRegWriteSDFMT(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
    815 static int hdaRegWriteSDBDPL(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
    816 static int hdaRegWriteSDBDPU(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
     805static int  hdaRegWriteSDCBL(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
     806static int  hdaRegWriteSDCTL(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
     807static int  hdaRegWriteSDSTS(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
     808static int  hdaRegWriteSDLVI(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
     809static int  hdaRegWriteSDFIFOW(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
     810static int  hdaRegWriteSDFIFOS(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
     811static int  hdaRegWriteSDFMT(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
     812static int  hdaRegWriteSDBDPL(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
     813static int  hdaRegWriteSDBDPU(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
     814inline bool hdaRegWriteSDIsAllowed(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
    817815
    818816/*
     
    829827
    830828#ifdef IN_RING3
    831 static int hdaStreamInit(PHDASTATE pThis, PHDASTREAM pStrmSt, uint8_t u8Strm);
    832829static void hdaStreamDestroy(PHDASTREAM pStrmSt);
    833830static int hdaStreamStart(PHDASTREAM pStrmSt);
     
    841838static void hdaStreamUpdateLPIB(PHDASTATE pThis, PHDASTREAM pStrmSt, uint32_t u32LPIB);
    842839# ifdef LOG_ENABLED
    843 static void hdaBDLEDumpAll(PHDASTATE pThis, uint64_t u64BaseDMA, uint16_t u16LVI);
     840static void hdaBDLEDumpAll(PHDASTATE pThis, uint64_t u64BaseDMA, uint16_t cBDLE);
    844841# endif
    845 static void hdaBDLEReset(PHDABDLE pBDLE);
    846842#endif
    847843
     
    988984
    989985#ifdef IN_RING3
    990 /** HDABDLESTATE field descriptors for the v5+ saved state. */
    991 static SSMFIELD const g_aSSMBDLEStateFields5[] =
     986/** HDABDLE field descriptors for the v6+ saved state. */
     987static SSMFIELD const g_aSSMBDLEFields6[] =
     988{
     989    SSMFIELD_ENTRY(HDABDLE, u64BufAdr),
     990    SSMFIELD_ENTRY(HDABDLE, u32BufSize),
     991    SSMFIELD_ENTRY(HDABDLE, fIntOnCompletion),
     992    SSMFIELD_ENTRY_TERM()
     993};
     994
     995/** HDABDLESTATE field descriptors for the v6+ saved state. */
     996static SSMFIELD const g_aSSMBDLEStateFields6[] =
    992997{
    993998    SSMFIELD_ENTRY(HDABDLESTATE, u32BDLIndex),
     
    9981003};
    9991004
    1000 /** HDASTREAMSTATE field descriptors for the v5+ saved state. */
    1001 static SSMFIELD const g_aSSMStreamStateFields5[] =
    1002 {
    1003     SSMFIELD_ENTRY       (HDASTREAMSTATE, cBDLE),
    1004     SSMFIELD_ENTRY       (HDASTREAMSTATE, uCurBDLE),
    1005     SSMFIELD_ENTRY_IGNORE(HDASTREAMSTATE, paBDLE),
     1005/** HDASTREAMSTATE field descriptors for the v6+ saved state. */
     1006static SSMFIELD const g_aSSMStreamStateFields6[] =
     1007{
     1008    SSMFIELD_ENTRY_OLD(cBDLE, 2),
     1009    SSMFIELD_ENTRY(HDASTREAMSTATE, uCurBDLE),
     1010    SSMFIELD_ENTRY(HDASTREAMSTATE, fDoStop),
     1011    SSMFIELD_ENTRY(HDASTREAMSTATE, fActive),
     1012    SSMFIELD_ENTRY(HDASTREAMSTATE, fInReset),
    10061013    SSMFIELD_ENTRY_TERM()
    10071014};
     
    10341041    {
    10351042        int rc2 = PDMDevHlpPCIPhysWrite(pThis->CTX_SUFF(pDevIns),
    1036                                         (pThis->u64DPBase & DPBASE_ADDR_MASK) + (pStrmSt->u8Strm * 8),
     1043                                        (pThis->u64DPBase & DPBASE_ADDR_MASK) + (pStrmSt->u8Strm * 2 * sizeof(uint32_t)),
    10371044                                        (void *)&u32LPIB, sizeof(uint32_t));
    10381045        AssertRC(rc2);
     1046#ifdef DEBUG
     1047        hdaBDLEDumpAll(pThis, pStrmSt->u64BaseDMA, pStrmSt->State.uCurBDLE);
     1048#endif
    10391049    }
    10401050}
     
    10961106#ifdef IN_RING3
    10971107/**
    1098  * Returns the current BDLE to use for a stream.
     1108 * Fetches the next BDLE to use for a stream.
    10991109 *
    1100  * @return BDLE to use, NULL if none found.
    1101  */
    1102 DECLINLINE(PHDABDLE) hdaStreamGetCurrentBDLE(PHDASTATE pThis, PHDASTREAM pStrmSt)
    1103 {
    1104     AssertPtrReturn(pThis,   NULL);
    1105     AssertPtrReturn(pStrmSt, NULL);
    1106 
    1107     Assert(pStrmSt->State.paBDLE);
    1108     Assert(pStrmSt->State.uCurBDLE < pStrmSt->State.cBDLE);
    1109 
    1110     PHDABDLE pBDLE = &pStrmSt->State.paBDLE[pStrmSt->State.uCurBDLE];
    1111     return pBDLE;
    1112 }
    1113 
    1114 /**
    1115  * Returns the next BDLE to use for a stream.
    1116  *
    1117  * @return BDLE to use next, NULL if none found.
    1118  */
    1119 DECLINLINE(PHDABDLE) hdaStreamGetNextBDLE(PHDASTATE pThis, PHDASTREAM pStrmSt)
    1120 {
    1121     AssertPtrReturn(pThis,   NULL);
    1122     AssertPtrReturn(pStrmSt, NULL);
     1110 * @return  IPRT status code.
     1111 */
     1112DECLINLINE(int) hdaStreamGetNextBDLE(PHDASTATE pThis, PHDASTREAM pStrmSt)
     1113{
     1114    AssertPtrReturn(pThis,   VERR_INVALID_POINTER);
     1115    AssertPtrReturn(pStrmSt, VERR_INVALID_POINTER);
    11231116
    11241117    NOREF(pThis);
    11251118
    1126     Assert(pStrmSt->State.paBDLE);
    1127     Assert(pStrmSt->State.uCurBDLE < pStrmSt->State.cBDLE);
     1119    Assert(pStrmSt->State.uCurBDLE < pStrmSt->u16LVI + 1);
    11281120
    11291121#ifdef DEBUG
     
    11361128     */
    11371129    pStrmSt->State.uCurBDLE++;
    1138     if (pStrmSt->State.uCurBDLE == pStrmSt->State.cBDLE)
     1130    if (pStrmSt->State.uCurBDLE == pStrmSt->u16LVI + 1)
    11391131    {
    11401132        pStrmSt->State.uCurBDLE = 0;
     
    11431135    }
    11441136
    1145     Assert(pStrmSt->State.uCurBDLE < pStrmSt->State.cBDLE);
    1146 
    1147     PHDABDLE pBDLE = &pStrmSt->State.paBDLE[pStrmSt->State.uCurBDLE];
    1148     AssertPtr(pBDLE);
    1149 
    1150     hdaBDLEReset(pBDLE);
     1137    Assert(pStrmSt->State.uCurBDLE < pStrmSt->u16LVI + 1);
     1138
     1139    int rc = hdaBDLEFetch(pThis, &pStrmSt->State.BDLE, pStrmSt->u64BaseDMA, pStrmSt->State.uCurBDLE);
    11511140
    11521141#ifdef DEBUG
    1153     LogFlowFunc(("[SD%RU8]: uOldBDLE=%RU16, uCurBDLE=%RU16, cBDLE=%RU32, %R[bdle]\n",
    1154                  pStrmSt->u8Strm, uOldBDLE, pStrmSt->State.uCurBDLE, pStrmSt->State.cBDLE, pBDLE));
    1155 #endif
    1156     return pBDLE;
     1142    LogFlowFunc(("[SD%RU8]: uOldBDLE=%RU16, uCurBDLE=%RU16, LVI=%RU32, %R[bdle]\n",
     1143                 pStrmSt->u8Strm, uOldBDLE, pStrmSt->State.uCurBDLE, pStrmSt->u16LVI, &pStrmSt->State.BDLE));
     1144#endif
     1145    return rc;
    11571146}
    11581147#endif
     
    14541443    AssertRC(rc);
    14551444
     1445    pStrmSt->u8Strm         = UINT8_MAX;
     1446
    14561447    pStrmSt->State.fActive  = false;
    14571448    pStrmSt->State.fInReset = false;
     
    14621453}
    14631454
     1455static void hdaStreamDestroy(PHDASTREAM pStrmSt)
     1456{
     1457    AssertPtrReturnVoid(pStrmSt);
     1458
     1459    LogFlowFunc(("[SD%RU8]: Destroy\n", pStrmSt->u8Strm));
     1460
     1461    int rc2 = hdaStreamStop(pStrmSt);
     1462    AssertRC(rc2);
     1463
     1464    if (pStrmSt->State.hStateChangedEvent != NIL_RTSEMEVENT)
     1465    {
     1466        rc2 = RTSemEventDestroy(pStrmSt->State.hStateChangedEvent);
     1467        AssertRC(rc2);
     1468    }
     1469
     1470    LogFlowFuncLeave();
     1471}
     1472
    14641473static int hdaStreamInit(PHDASTATE pThis, PHDASTREAM pStrmSt, uint8_t u8Strm)
    14651474{
     
    14681477
    14691478    pStrmSt->u8Strm     = u8Strm;
    1470     pStrmSt->u64BaseDMA = RT_MAKE_U64(HDA_STREAM_REG(pThis, BDPL, u8Strm),
     1479    pStrmSt->u64BaseDMA = RT_MAKE_U64(HDA_STREAM_REG(pThis, BDPL, pStrmSt->u8Strm),
     1480                                      HDA_STREAM_REG(pThis, BDPU, pStrmSt->u8Strm));
     1481    pStrmSt->u16LVI     = HDA_STREAM_REG(pThis, LVI, pStrmSt->u8Strm);
     1482    pStrmSt->u32CBL     = HDA_STREAM_REG(pThis, CBL, pStrmSt->u8Strm);
     1483    pStrmSt->u16FIFOS   = hdaSDFIFOSToBytes(HDA_STREAM_REG(pThis, FIFOS, pStrmSt->u8Strm));
     1484
     1485    RT_ZERO(pStrmSt->State.BDLE);
     1486    pStrmSt->State.uCurBDLE = 0;
     1487
     1488    LogFlowFunc(("[SD%RU8]: DMA @ 0x%x (%RU32 bytes), LVI=%RU16, FIFOS=%RU16\n",
     1489                 pStrmSt->u8Strm, pStrmSt->u64BaseDMA, pStrmSt->u32CBL, pStrmSt->u16LVI, pStrmSt->u16FIFOS));
     1490
     1491#ifdef DEBUG
     1492    uint64_t u64BaseDMA = RT_MAKE_U64(HDA_STREAM_REG(pThis, BDPL, u8Strm),
    14711493                                      HDA_STREAM_REG(pThis, BDPU, u8Strm));
    1472     pStrmSt->u16LVI     = HDA_STREAM_REG(pThis, LVI, u8Strm);
    1473     pStrmSt->u32CBL     = HDA_STREAM_REG(pThis, CBL, u8Strm);
    1474     pStrmSt->u16FIFOS   = hdaSDFIFOSToBytes(HDA_STREAM_REG(pThis, FIFOS, u8Strm));
    1475 
    1476     int rc = VINF_SUCCESS;
    1477 
    1478     if (pStrmSt->State.paBDLE)
    1479     {
    1480         Assert(pStrmSt->State.cBDLE);
    1481         RTMemFree(pStrmSt->State.paBDLE);
    1482         pStrmSt->State.paBDLE = NULL;
    1483     }
    1484 
    1485     pStrmSt->State.cBDLE = 0;
    1486 
    1487     if (/* Is there a base DMA address set? */
    1488            pStrmSt->u64BaseDMA
    1489         /* Any BDLEs to fetch? */
    1490         && pStrmSt->u16LVI)
    1491     {
    1492         uint32_t cbBDLE = 0;
    1493 
    1494         pStrmSt->State.cBDLE  = pStrmSt->u16LVI + 1; /* See 18.2.37: If LVI is n, then there are n + 1 entries. */
    1495         pStrmSt->State.paBDLE = (PHDABDLE)RTMemAllocZ(sizeof(HDABDLE) * pStrmSt->State.cBDLE);
    1496         if (pStrmSt->State.paBDLE)
    1497         {
    1498             for (uint16_t i = 0; i < pStrmSt->State.cBDLE; i++)
    1499             {
    1500                 rc = hdaBDLEFetch(pThis, &pStrmSt->State.paBDLE[i], pStrmSt->u64BaseDMA, i);
    1501                 if (RT_FAILURE(rc))
    1502                     break;
    1503 
    1504                 cbBDLE += pStrmSt->State.paBDLE[i].u32BufSize;
    1505             }
    1506 
    1507 #ifdef DEBUG
    1508             hdaBDLEDumpAll(pThis, pStrmSt->u64BaseDMA, pStrmSt->State.cBDLE);
    1509 #endif
    1510             if (RT_SUCCESS(rc))
    1511             {
    1512                 if (pStrmSt->u32CBL != cbBDLE)
    1513                 {
    1514                     AssertMsgFailed(("CBL (%RU32) does not match BDL entries (%RU32)\n", pStrmSt->u32CBL, cbBDLE));
    1515                     LogRel(("HDA: Warning: CBL (%RU32) does not match BDL entries (%RU32); expect sound hickups\n",
    1516                             pStrmSt->u32CBL, cbBDLE));
    1517                 }
    1518 
    1519                 HDA_STREAM_REG(pThis, STS, pStrmSt->u8Strm) |= HDA_REG_FIELD_FLAG_MASK(SDSTS, BCIS);
    1520             }
    1521         }
    1522         else
    1523             rc = VERR_NO_MEMORY;
    1524     }
    1525 
    1526     LogFunc(("[SD%RU8]: DMA=0x%x, LVI=%RU16, CBL=%RU32, FIFOS=%RU16\n",
    1527              u8Strm, pStrmSt->u64BaseDMA, pStrmSt->u16LVI, pStrmSt->u32CBL, pStrmSt->u16FIFOS));
    1528 
    1529     return rc;
    1530 }
    1531 
    1532 static void hdaStreamDestroy(PHDASTREAM pStrmSt)
    1533 {
    1534     AssertPtrReturnVoid(pStrmSt);
    1535 
    1536     LogFlowFuncEnter();
    1537 
    1538     int rc2 = hdaStreamStop(pStrmSt);
    1539     AssertRC(rc2);
    1540 
    1541     if (pStrmSt->State.hStateChangedEvent != NIL_RTSEMEVENT)
    1542     {
    1543         rc2 = RTSemEventDestroy(pStrmSt->State.hStateChangedEvent);
    1544         AssertRC(rc2);
    1545     }
    1546 
    1547     /*
    1548      * Destroy.
    1549      */
    1550     if (pStrmSt->State.paBDLE)
    1551     {
    1552         Assert(pStrmSt->State.cBDLE);
    1553         RTMemFree(pStrmSt->State.paBDLE);
    1554         pStrmSt->State.paBDLE = NULL;
    1555     }
    1556 
    1557     pStrmSt->State.cBDLE = 0;
    1558 
    1559     LogFlowFuncLeave();
     1494    uint16_t u16LVI     = HDA_STREAM_REG(pThis, LVI, u8Strm);
     1495    uint32_t u32CBL     = HDA_STREAM_REG(pThis, CBL, u8Strm);
     1496
     1497    LogFlowFunc(("\t-> DMA @ 0x%x, LVI=%RU16, CBL=%RU32\n", u64BaseDMA, u16LVI, u32CBL));
     1498
     1499    hdaBDLEDumpAll(pThis, u64BaseDMA, u16LVI + 1);
     1500#endif
     1501
     1502    return VINF_SUCCESS;
    15601503}
    15611504
     
    15801523     * First, reset the internal stream state.
    15811524     */
    1582     pStrmSt->u8Strm     = u8Strm;
    1583     pStrmSt->u64BaseDMA = 0;
    1584     pStrmSt->u32CBL     = 0;
    1585     pStrmSt->u16FMT     = 0;
    1586     pStrmSt->u16FIFOS   = 0;
    1587     pStrmSt->u16LVI     = 0;
     1525    RT_BZERO(pStrmSt, sizeof(HDASTREAM));
    15881526
    15891527    /*
     
    16051543    HDA_STREAM_REG(pThis, BDPL,  u8Strm) = 0;
    16061544
     1545    /*
     1546     * Third, set the internal state according to the just set registers.
     1547     */
     1548    pStrmSt->u8Strm   = u8Strm;
     1549    pStrmSt->u16FIFOS = HDA_STREAM_REG(pThis, FIFOS, u8Strm);
     1550
     1551
    16071552    /* Report that we're done resetting this stream. */
    16081553    HDA_STREAM_REG(pThis, CTL,   u8Strm) = 0;
     
    19801925        if (fInRun != fRun)
    19811926        {
    1982             if (fRun)
    1983             {
    1984                 int rc2 = hdaStreamInit(pThis, pStrmSt, u8Strm);
    1985                 AssertRC(rc2);
    1986             }
    1987 
    19881927            Assert(!fReset && !fInReset);
    19891928            LogFunc(("[SD%RU8]: fRun=%RTbool\n", u8Strm, fRun));
     
    20201959            }
    20211960        }
     1961
     1962        if (!fInRun && !fRun)
     1963            hdaStreamInit(pThis, pStrmSt, u8Strm);
     1964
    20221965#else /* !IN_RING3 */
    20231966        return VINF_IOM_R3_MMIO_WRITE;
     
    20391982static int hdaRegWriteSDLVI(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
    20401983{
    2041     /* Only can be modified if RUN bit is 0. */
    2042     bool fIsRunning = RT_BOOL(HDA_REG_IND(pThis, iReg) & HDA_REG_FIELD_FLAG_MASK(SDCTL, RUN));
    2043     if (fIsRunning)
    2044     {
    2045         AssertMsgFailed(("Cannot write to register when RUN bit is set\n"));
     1984    if (!hdaRegWriteSDIsAllowed(pThis, iReg, u32Value))
    20461985        return VINF_SUCCESS;
    2047     }
    20481986
    20491987    int rc = hdaRegWriteU32(pThis, iReg, u32Value);
     
    22592197static int hdaRegWriteSDBDPL(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
    22602198{
     2199    if (!hdaRegWriteSDIsAllowed(pThis, iReg, u32Value))
     2200        return VINF_SUCCESS;
     2201
     2202    LogFlowFunc(("[SD%RU8]: DMA BDPL -> 0x%x\n", HDA_SD_NUM_FROM_REG(pThis, CTL, iReg), u32Value));
     2203
    22612204    int rc = hdaRegWriteU32(pThis, iReg, u32Value);
    22622205    if (RT_FAILURE(rc))
     
    22672210static int hdaRegWriteSDBDPU(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
    22682211{
     2212    if (!hdaRegWriteSDIsAllowed(pThis, iReg, u32Value))
     2213        return VINF_SUCCESS;
     2214
     2215    LogFlowFunc(("[SD%RU8]: DMA BDPU -> 0x%x\n", HDA_SD_NUM_FROM_REG(pThis, CTL, iReg), u32Value));
     2216
    22692217    int rc = hdaRegWriteU32(pThis, iReg, u32Value);
    22702218    if (RT_FAILURE(rc))
    22712219        AssertRCReturn(rc, VINF_SUCCESS);
    22722220    return rc;
     2221}
     2222
     2223/**
     2224 * Checks whether a write to a specific SDnXXX register is allowed or not.
     2225 *
     2226 * @return  bool                Returns @true if write is allowed, @false if not.
     2227 * @param   pThis               Pointer to HDA state.
     2228 * @param   iReg                Register to write.
     2229 * @param   u32Value            Value to write.
     2230 */
     2231inline bool hdaRegWriteSDIsAllowed(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
     2232{
     2233    /* Check if the SD's RUN bit is set. */
     2234    bool fIsRunning = RT_BOOL(HDA_REG_IND(pThis, iReg) & HDA_REG_FIELD_FLAG_MASK(SDCTL, RUN));
     2235    if (fIsRunning)
     2236    {
     2237#ifdef VBOX_STRICT
     2238        AssertMsgFailed(("[SD%RU8]: Cannot write to register 0x%x (0x%x) when RUN bit is set\n",
     2239                         HDA_SD_NUM_FROM_REG(pThis, CTL, iReg), iReg, u32Value));
     2240#endif
     2241        return false;
     2242    }
     2243
     2244    return true;
    22732245}
    22742246
     
    23802352
    23812353            /* Also make sure to handle the DMA position enable bit. */
    2382             bool fEnabled = pThis->au32Regs[iRegMem] & RT_BIT_32(0);
    2383             if (pThis->fDMAPosition != fEnabled)
    2384             {
    2385                 LogRel(("HDA: %s DMA position buffer\n", fEnabled ? "Enabled" : "Disabled"));
    2386                 pThis->fDMAPosition = fEnabled;
    2387             }
     2354            pThis->fDMAPosition = pThis->au32Regs[iRegMem] & RT_BIT_32(0);
     2355            LogRel(("HDA: %s DMA position buffer\n", pThis->fDMAPosition ? "Enabled" : "Disabled"));
    23882356            break;
    23892357        }
     
    24142382static void hdaBDLEDumpAll(PHDASTATE pThis, uint64_t u64BaseDMA, uint16_t cBDLE)
    24152383{
     2384    LogFlowFunc(("BDLEs @ 0x%x (%RU16):\n", u64BaseDMA, cBDLE));
     2385    if (!u64BaseDMA)
     2386        return;
     2387
    24162388    uint32_t cbBDLE = 0;
    2417 
    24182389    for (uint16_t i = 0; i < cBDLE; i++)
    24192390    {
     
    24252396        uint32_t ioc  = *(uint32_t *)&bdle[12];
    24262397
    2427         LogFlowFunc(("#%03d BDLE(adr:0x%llx, size:%RU32, ioc:%RTbool)\n",
     2398        LogFlowFunc(("\t#%03d BDLE(adr:0x%llx, size:%RU32, ioc:%RTbool)\n",
    24282399                     i, addr, len, RT_BOOL(ioc & 0x1)));
    24292400
     
    24362407        return;
    24372408
     2409    LogFlowFunc(("DMA counters:\n", cbBDLE));
     2410
    24382411    for (int i = 0; i < 8; i++) /** @todo Use a define for MAX_STREAMS! */
    24392412    {
    24402413        uint32_t uDMACnt;
    2441         PDMDevHlpPhysRead(pThis->CTX_SUFF(pDevIns), (pThis->u64DPBase & DPBASE_ADDR_MASK) + i * 8, /** @todo Use a define. */
     2414        PDMDevHlpPhysRead(pThis->CTX_SUFF(pDevIns), (pThis->u64DPBase & DPBASE_ADDR_MASK) + (i * 2 * sizeof(uint32_t)),
    24422415                          &uDMACnt, sizeof(&uDMACnt));
    24432416
    2444         LogFlowFunc(("%s #%02d STREAM(0x%x)\n",
    2445                      i == HDA_SDCTL_NUM(pThis, 4) || i == HDA_SDCTL_NUM(pThis, 0) ? "*" : " ", i , uDMACnt));
     2417        LogFlowFunc(("\t#%03d DMA @ 0x%x\n", i , uDMACnt));
    24462418    }
    24472419}
     
    24692441        return rc;
    24702442
     2443    RT_BZERO(pBDLE, sizeof(HDABDLE));
     2444
    24712445    pBDLE->State.u32BDLIndex = u16Entry;
    24722446    pBDLE->u64BufAdr         = *(uint64_t *) uBundleEntry;
     
    24802454}
    24812455
    2482 static void hdaBDLEReset(PHDABDLE pBDLE)
    2483 {
    2484     AssertPtrReturnVoid(pBDLE);
    2485 
    2486     pBDLE->State.u32BufOff    = 0;
    2487     pBDLE->State.cbBelowFIFOW = 0;
    2488 }
    2489 
    24902456/**
    24912457 * Returns the number of outstanding stream data bytes which need to be processed
     
    25022468        return 0;
    25032469
    2504     PHDABDLE pBDLE = hdaStreamGetCurrentBDLE(pThis, pStrmSt);
     2470    PHDABDLE pBDLE = &pStrmSt->State.BDLE;
    25052471
    25062472    uint32_t cbFree = pStrmSt->u32CBL - HDA_STREAM_REG(pThis, LPIB, pStrmSt->u8Strm);
     
    25732539    AssertPtrReturn(pStrmSt, false);
    25742540
    2575     PHDABDLE pBDLE   = hdaStreamGetCurrentBDLE(pThis, pStrmSt);
     2541    PHDABDLE pBDLE   = &pStrmSt->State.BDLE;
    25762542    uint32_t u32LPIB = HDA_STREAM_REG(pThis, LPIB, pStrmSt->u8Strm);
    25772543
     
    25822548     * the CBL limit or our internal DMA buffer is full. */
    25832549    bool fNeedsNextBDLE   = (   fCBLLimitReached
    2584                              || (   pBDLE->State.u32BufOff
    2585                                  && pBDLE->State.u32BufOff >= pBDLE->u32BufSize)
    2586                             );
     2550                             || (pBDLE->State.u32BufOff >= pBDLE->u32BufSize));
    25872551
    25882552    Assert(u32LPIB                <= pStrmSt->u32CBL);
     
    25992563    }
    26002564
    2601     if (fNeedsNextBDLE)
    2602     {
    2603         /* Reset current BDLE. */
    2604         hdaBDLEReset(pBDLE);
    2605     }
    2606 
    26072565    return fNeedsNextBDLE;
    26082566}
     
    26172575    Assert(cbInc <= pStrmSt->u16FIFOS);
    26182576
    2619     PHDABDLE pBDLE = hdaStreamGetCurrentBDLE(pThis, pStrmSt);
     2577    PHDABDLE pBDLE = &pStrmSt->State.BDLE;
    26202578
    26212579    /*
     
    26452603    bool fIsComplete = false;
    26462604
    2647     PHDABDLE       pBDLE   = hdaStreamGetCurrentBDLE(pThis, pStrmSt);
     2605    PHDABDLE       pBDLE   = &pStrmSt->State.BDLE;
    26482606    const uint32_t u32LPIB = HDA_STREAM_REG(pThis, LPIB, pStrmSt->u8Strm);
    26492607
     
    27012659    /* pcbRead is optional. */
    27022660
    2703     PHDABDLE pBDLE = hdaStreamGetCurrentBDLE(pThis, pStrmSt);
     2661    PHDABDLE pBDLE = &pStrmSt->State.BDLE;
    27042662
    27052663    int rc;
     
    27682726    /* pcbWritten is optional. */
    27692727
    2770     PHDABDLE pBDLE = hdaStreamGetCurrentBDLE(pThis, pStrmSt);
    2771     int rc;
     2728    PHDABDLE pBDLE = &pStrmSt->State.BDLE;
    27722729
    27732730    uint32_t cbWritten = 0;
     
    27802737     * previous unreported transfer we write at offset 'pBDLE->State.cbUnderFifoW').
    27812738     */
     2739    int rc;
    27822740    if (!cbData)
    27832741    {
     
    31513109    /* pcbProcessed is optional. */
    31523110
    3153     LogFlowFunc(("enmSrc=%RU32, cbToProcess=%RU32\n", enmSrc, cbToProcess));
    3154 
    31553111    if (ASMAtomicReadBool(&pThis->fInReset)) /* HDA controller in reset mode? Bail out. */
    31563112    {
     
    32063162    /* Is the stream not in a running state currently? */
    32073163    else if (!(HDA_STREAM_REG(pThis, CTL, pStrmSt->u8Strm) & HDA_REG_FIELD_FLAG_MASK(SDCTL, RUN)))
    3208         fProceed = false;
    3209     /* There must be BDLEs defined in order to have a working stream. */
    3210     else if (pStrmSt->State.cBDLE == 0)
    32113164        fProceed = false;
    32123165    /* Nothing to process? */
     
    32213174    }
    32223175
     3176    LogFlowFunc(("enmSrc=%RU32, cbToProcess=%RU32\n", enmSrc, cbToProcess));
     3177
    32233178    /* Sanity checks. */
    32243179    Assert(pStrmSt->u8Strm <= 7); /** @todo Use a define for MAX_STREAMS! */
     
    32273182
    32283183    /* State sanity checks. */
    3229     AssertPtr(pStrmSt->State.paBDLE);
    32303184    Assert(ASMAtomicReadBool(&pStrmSt->State.fInReset) == false);
    32313185
     
    33953349{
    33963350    if (pThis->fInReset && idxRegDsc != HDA_REG_GCTL)
    3397         LogFunc(("access to registers except GCTL is blocked while reset\n"));  /** @todo where is this enforced? */
     3351    {
     3352        LogRel2(("HDA: Access to register 0x%x is blocked while reset\n", idxRegDsc));
     3353        return VINF_SUCCESS;
     3354    }
    33983355
    33993356    uint32_t idxRegMem = g_aHdaRegMap[idxRegDsc].mem_idx;
     
    34133370PDMBOTHCBDECL(int) hdaMMIOWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void const *pv, unsigned cb)
    34143371{
    3415     PHDASTATE               pThis  = PDMINS_2_DATA(pDevIns, PHDASTATE);
    3416     int                     rc;
     3372    PHDASTATE pThis  = PDMINS_2_DATA(pDevIns, PHDASTATE);
     3373    int       rc;
    34173374
    34183375    /*
     
    35943551static int hdaSaveStream(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, PHDASTREAM pStrm)
    35953552{
     3553    PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE);
     3554
     3555    LogFlowFunc(("[SD%RU8]\n", pStrm->u8Strm));
     3556
    35963557    /* Save stream ID. */
    35973558    int rc = SSMR3PutU8(pSSM, pStrm->u8Strm);
     
    35993560    Assert(pStrm->u8Strm <= 7); /** @todo Use a define. */
    36003561
    3601     rc = SSMR3PutStructEx(pSSM, &pStrm->State, sizeof(HDASTREAMSTATE), 0 /*fFlags*/, g_aSSMStreamStateFields5, NULL);
     3562    rc = SSMR3PutStructEx(pSSM, &pStrm->State, sizeof(HDASTREAMSTATE), 0 /*fFlags*/, g_aSSMStreamStateFields6, NULL);
    36023563    AssertRCReturn(rc, rc);
    36033564
    3604     for (uint32_t i = 0; i < pStrm->State.cBDLE; i++)
    3605     {
    3606         rc = SSMR3PutStructEx(pSSM, &pStrm->State.paBDLE[i].State, sizeof(HDABDLESTATE),
    3607                               0 /*fFlags*/, g_aSSMBDLEStateFields5, NULL);
    3608         AssertRCReturn(rc, rc);
    3609     }
    3610 
     3565#ifdef DEBUG /* Sanity checks. */
     3566    uint64_t u64BaseDMA = RT_MAKE_U64(HDA_STREAM_REG(pThis, BDPL, pStrm->u8Strm),
     3567                                      HDA_STREAM_REG(pThis, BDPU, pStrm->u8Strm));
     3568    uint16_t u16LVI     = HDA_STREAM_REG(pThis, LVI, pStrm->u8Strm);
     3569    uint32_t u32CBL     = HDA_STREAM_REG(pThis, CBL, pStrm->u8Strm);
     3570
     3571    hdaBDLEDumpAll(pThis, u64BaseDMA, u16LVI + 1);
     3572
     3573    Assert(u64BaseDMA == pStrm->u64BaseDMA);
     3574    Assert(u16LVI     == pStrm->u16LVI);
     3575    Assert(u32CBL     == pStrm->u32CBL);
     3576#endif
     3577
     3578    rc = SSMR3PutStructEx(pSSM, &pStrm->State.BDLE, sizeof(HDABDLE),
     3579                          0 /*fFlags*/, g_aSSMBDLEFields6, NULL);
     3580    AssertRCReturn(rc, rc);
     3581
     3582    rc = SSMR3PutStructEx(pSSM, &pStrm->State.BDLE.State, sizeof(HDABDLESTATE),
     3583                          0 /*fFlags*/, g_aSSMBDLEStateFields6, NULL);
     3584    AssertRCReturn(rc, rc);
     3585
     3586#ifdef DEBUG /* Sanity checks. */
     3587    PHDABDLE pBDLE = &pStrm->State.BDLE;
     3588    if (u64BaseDMA)
     3589    {
     3590        Assert(pStrm->State.uCurBDLE <= u16LVI + 1);
     3591
     3592        HDABDLE curBDLE;
     3593        rc = hdaBDLEFetch(pThis, &curBDLE, u64BaseDMA, pStrm->State.uCurBDLE);
     3594        AssertRC(rc);
     3595
     3596        Assert(curBDLE.u32BufSize       == pBDLE->u32BufSize);
     3597        Assert(curBDLE.u64BufAdr        == pBDLE->u64BufAdr);
     3598        Assert(curBDLE.fIntOnCompletion == pBDLE->fIntOnCompletion);
     3599    }
     3600    else
     3601    {
     3602        Assert(pBDLE->u64BufAdr  == 0);
     3603        Assert(pBDLE->u32BufSize == 0);
     3604    }
     3605#endif
    36113606    return rc;
    36123607}
     
    37283723     *       according to the spec).
    37293724     */
    3730 #define HDA_SSM_LOAD_BDLE_STATE_PRE_V5(v, x)                        \
    3731     rc = SSMR3Skip(pSSM, sizeof(uint32_t));    /* Begin marker */   \
    3732     AssertRCReturn(rc, rc);                                         \
    3733     rc = SSMR3Skip(pSSM, sizeof(uint64_t));    /* u64BdleCviAddr */ \
    3734     AssertRCReturn(rc, rc);                                         \
    3735     rc = SSMR3Skip(pSSM, sizeof(uint32_t));    /* u32BdleMaxCvi */  \
    3736     AssertRCReturn(rc, rc);                                         \
    3737     rc = SSMR3GetU32(pSSM, &x->u32BDLIndex);   /* u32BdleCvi */     \
    3738     AssertRCReturn(rc, rc);                                         \
    3739     rc = SSMR3Skip(pSSM, sizeof(uint32_t));    /* u32BdleCviLen */  \
    3740     AssertRCReturn(rc, rc);                                         \
    3741     rc = SSMR3GetU32(pSSM, &x->u32BufOff);     /* u32BdleCviPos */  \
    3742     AssertRCReturn(rc, rc);                                         \
    3743     rc = SSMR3Skip(pSSM, sizeof(uint8_t));     /* fBdleCviIoc */    \
    3744     AssertRCReturn(rc, rc);                                         \
    3745     rc = SSMR3GetU32(pSSM, &x->cbBelowFIFOW); /* cbUnderFifoW */   \
    3746     AssertRCReturn(rc, rc);                                         \
    3747     rc = SSMR3GetMem(pSSM, &x->au8FIFO, sizeof(x->au8FIFO));        \
    3748     AssertRCReturn(rc, rc);                                         \
    3749     rc = SSMR3Skip(pSSM, sizeof(uint32_t));    /* End marker */     \
    3750     AssertRCReturn(rc, rc);                                         \
     3725#define HDA_SSM_LOAD_BDLE_STATE_PRE_V5(v, x)                            \
     3726    rc = SSMR3Skip(pSSM, sizeof(uint32_t));        /* Begin marker */   \
     3727    AssertRCReturn(rc, rc);                                             \
     3728    rc = SSMR3GetU64(pSSM, &x.u64BufAdr);          /* u64BdleCviAddr */ \
     3729    AssertRCReturn(rc, rc);                                             \
     3730    rc = SSMR3Skip(pSSM, sizeof(uint32_t));        /* u32BdleMaxCvi */  \
     3731    AssertRCReturn(rc, rc);                                             \
     3732    rc = SSMR3GetU32(pSSM, &x.State.u32BDLIndex);  /* u32BdleCvi */     \
     3733    AssertRCReturn(rc, rc);                                             \
     3734    rc = SSMR3GetU32(pSSM, &x.u32BufSize);         /* u32BdleCviLen */  \
     3735    AssertRCReturn(rc, rc);                                             \
     3736    rc = SSMR3GetU32(pSSM, &x.State.u32BufOff);    /* u32BdleCviPos */  \
     3737    AssertRCReturn(rc, rc);                                             \
     3738    rc = SSMR3GetBool(pSSM, &x.fIntOnCompletion);  /* fBdleCviIoc */    \
     3739    AssertRCReturn(rc, rc);                                             \
     3740    rc = SSMR3GetU32(pSSM, &x.State.cbBelowFIFOW); /* cbUnderFifoW */   \
     3741    AssertRCReturn(rc, rc);                                             \
     3742    rc = SSMR3GetMem(pSSM, &x.State.au8FIFO, sizeof(x.State.au8FIFO));  \
     3743    AssertRCReturn(rc, rc);                                             \
     3744    rc = SSMR3Skip(pSSM, sizeof(uint32_t));        /* End marker */     \
     3745    AssertRCReturn(rc, rc);                                             \
    37513746
    37523747    /*
    37533748     * Load BDLEs (Buffer Descriptor List Entries) and DMA counters.
    37543749     */
    3755     HDABDLESTATE StateBDLEDummy;
    3756 
    37573750    switch (uVersion)
    37583751    {
     
    37653758             * The rest will be initialized from the saved registers later. */
    37663759
    3767             /* Note: Only the *current* BDLE for a stream was saved! */
     3760            /* Note 1: Only the *current* BDLE for a stream was saved! */
     3761            /* Note 2: The stream's saving order is/was fixed, so don't touch! */
    37683762
    37693763            /* Output */
     
    37713765            if (RT_FAILURE(rc))
    37723766                break;
    3773             HDA_SSM_LOAD_BDLE_STATE_PRE_V5(uVersion, (   pThis->StrmStOut.State.cBDLE
    3774                                                       ? &pThis->StrmStOut.State.paBDLE[0].State : &StateBDLEDummy));
     3767            HDA_SSM_LOAD_BDLE_STATE_PRE_V5(uVersion, pThis->StrmStOut.State.BDLE);
     3768            pThis->StrmStOut.State.uCurBDLE = pThis->StrmStOut.State.BDLE.State.u32BDLIndex;
     3769
    37753770            /* Microphone-In */
    37763771            rc = hdaStreamInit(pThis, &pThis->StrmStMicIn,  2 /* Stream number, hardcoded */);
    37773772            if (RT_FAILURE(rc))
    37783773                break;
    3779             HDA_SSM_LOAD_BDLE_STATE_PRE_V5(uVersion, (   pThis->StrmStMicIn.State.cBDLE
    3780                                                       ? &pThis->StrmStMicIn.State.paBDLE[0].State : &StateBDLEDummy));
     3774            HDA_SSM_LOAD_BDLE_STATE_PRE_V5(uVersion, pThis->StrmStMicIn.State.BDLE);
     3775            pThis->StrmStMicIn.State.uCurBDLE = pThis->StrmStMicIn.State.BDLE.State.u32BDLIndex;
     3776
    37813777            /* Line-In */
    37823778            rc = hdaStreamInit(pThis, &pThis->StrmStLineIn, 0 /* Stream number, hardcoded */);
    37833779            if (RT_FAILURE(rc))
    37843780                break;
    3785             HDA_SSM_LOAD_BDLE_STATE_PRE_V5(uVersion, (  pThis->StrmStLineIn.State.cBDLE
    3786                                                       ? &pThis->StrmStLineIn.State.paBDLE[0].State : &StateBDLEDummy));
     3781            HDA_SSM_LOAD_BDLE_STATE_PRE_V5(uVersion, pThis->StrmStLineIn.State.BDLE);
     3782            pThis->StrmStLineIn.State.uCurBDLE = pThis->StrmStLineIn.State.BDLE.State.u32BDLIndex;
    37873783            break;
    37883784        }
     
    38263822                    default:
    38273823                        pStrm = &StreamDummy;
     3824
     3825                        LogRel2(("HDA: Warning: Stream ID=%RU32 not supported, skipping to load ...\n", uStreamID));
    38283826                        break;
    38293827                }
    38303828
    38313829                RT_BZERO(pStrm, sizeof(HDASTREAM));
    3832                 rc = SSMR3GetStructEx(pSSM, &pStrm->State, sizeof(HDASTREAMSTATE), 0 /* fFlags */, g_aSSMStreamStateFields5, NULL);
    3833                 if (RT_FAILURE(rc))
    3834                     break;
    3835 #ifdef DEBUG
    3836                 uint32_t cBDLE = pStrm->State.cBDLE;
    3837                 LogFlowFunc(("Stream #%RU32: ID=%RU8, cBDLE=%RU32\n", i, uStreamID, cBDLE));
    3838 #endif
     3830
    38393831                rc = hdaStreamInit(pThis, pStrm, uStreamID);
    38403832                if (RT_FAILURE(rc))
    38413833                {
    3842                     LogRel(("HDA: Stream #%RU32: Inititialization of stream (ID=%RU8, cBDLE=%RU32) failed, rc=%Rrc\n", i, uStreamID, pStrm->State.cBDLE, rc));
     3834                    LogRel(("HDA: Stream #%RU32: Initialization of stream %RU8 failed, rc=%Rrc\n", i, uStreamID, rc));
    38433835                    break;
    38443836                }
    3845 #ifdef DEBUG
    3846                 AssertMsg(cBDLE == pStrm->State.cBDLE, ("Loaded BDLE states (%RU32) vs. emulated ones (%RU32) don't match\n",
    3847                                                         cBDLE, pStrm->State.cBDLE));
    3848 #endif
    3849                 /* Load BDLE states. */
    3850                 for (uint32_t a = 0; a < pStrm->State.cBDLE; a++)
     3837
     3838                if (uVersion == HDA_SSM_VERSION_5)
    38513839                {
    3852                     if (uVersion == HDA_SSM_VERSION_5)
     3840                    /* Get the current BDLE entry and skip the rest. */
     3841                    uint16_t cBDLE;
     3842
     3843                    rc = SSMR3Skip(pSSM, sizeof(uint32_t)); /* Begin marker */
     3844                    AssertRC(rc);
     3845                    rc = SSMR3GetU16(pSSM, &cBDLE);                 /* cBDLE */
     3846                    AssertRC(rc);
     3847                    rc = SSMR3GetU16(pSSM, &pStrm->State.uCurBDLE); /* uCurBDLE */
     3848                    AssertRC(rc);
     3849                    rc = SSMR3Skip(pSSM, sizeof(uint32_t));         /* End marker */
     3850                    AssertRC(rc);
     3851
     3852                    uint32_t u32BDLEIndex;
     3853                    for (uint16_t i = 0; i < cBDLE; i++)
    38533854                    {
    3854                         /* v5 saved the entire HDABDLE struct instead of only HDABDLESTATE,
    3855                          * so skip. */
    3856                         rc = SSMR3Skip(pSSM, 0x120 /* sizeof(HDABLDE) in v5 */);
     3855                        rc = SSMR3Skip(pSSM, sizeof(uint32_t)); /* Begin marker */
     3856                        AssertRC(rc);
     3857                        rc = SSMR3GetU32(pSSM, &u32BDLEIndex);  /* u32BDLIndex */
     3858                        AssertRC(rc);
     3859
     3860                        /* Does the current BDLE index match the current BDLE to process? */
     3861                        if (u32BDLEIndex == pStrm->State.uCurBDLE)
     3862                        {
     3863                            rc = SSMR3GetU32(pSSM, &pStrm->State.BDLE.State.cbBelowFIFOW); /* cbBelowFIFOW */
     3864                            AssertRC(rc);
     3865                            rc = SSMR3GetMem(pSSM,
     3866                                             &pStrm->State.BDLE.State.au8FIFO,
     3867                                             sizeof(uint8_t) * 256);                       /* au8FIFO */
     3868                            AssertRC(rc);
     3869                            rc = SSMR3GetU32(pSSM, &pStrm->State.BDLE.State.u32BufOff);    /* u32BufOff */
     3870                            AssertRC(rc);
     3871                            rc = SSMR3Skip(pSSM, sizeof(uint32_t));                        /* End marker */
     3872                            AssertRC(rc);
     3873                        }
     3874                        else /* Skip not current BDLEs. */
     3875                        {
     3876                            rc = SSMR3Skip(pSSM,   sizeof(uint32_t)      /* cbBelowFIFOW */
     3877                                                 + sizeof(uint8_t) * 256 /* au8FIFO */
     3878                                                 + sizeof(uint32_t)      /* u32BufOff */
     3879                                                 + sizeof(uint32_t));    /* End marker */
     3880                            AssertRC(rc);
     3881                        }
    38573882                    }
    3858                     else
    3859                     {
    3860                         rc = SSMR3GetStructEx(pSSM, &pStrm->State.paBDLE[a].State, sizeof(HDABDLESTATE),
    3861                                               0 /* fFlags */, g_aSSMBDLEStateFields5, NULL);
    3862                     }
     3883                }
     3884                else
     3885                {
     3886                    rc = SSMR3GetStructEx(pSSM, &pStrm->State, sizeof(HDASTREAMSTATE),
     3887                                          0 /* fFlags */, g_aSSMStreamStateFields6, NULL);
     3888                    if (RT_FAILURE(rc))
     3889                        break;
     3890
     3891                    rc = SSMR3GetStructEx(pSSM, &pStrm->State.BDLE, sizeof(HDABDLE),
     3892                                          0 /* fFlags */, g_aSSMBDLEFields6, NULL);
     3893                    if (RT_FAILURE(rc))
     3894                        break;
     3895
     3896                    rc = SSMR3GetStructEx(pSSM, &pStrm->State.BDLE.State, sizeof(HDABDLESTATE),
     3897                                          0 /* fFlags */, g_aSSMBDLEStateFields6, NULL);
    38633898                    if (RT_FAILURE(rc))
    38643899                        break;
    38653900                }
    3866 
    3867                 /* Destroy dummy again. */
    3868                 if (pStrm == &StreamDummy)
    3869                     hdaStreamDestroy(pStrm);
    38703901            }
    38713902            break;
     
    39093940    if (RT_SUCCESS(rc))
    39103941    {
    3911         pThis->u64CORBBase = RT_MAKE_U64(HDA_REG(pThis, CORBLBASE), HDA_REG(pThis, CORBUBASE));
    3912         pThis->u64RIRBBase = RT_MAKE_U64(HDA_REG(pThis, RIRBLBASE), HDA_REG(pThis, RIRBUBASE));
    3913         pThis->u64DPBase   = RT_MAKE_U64(HDA_REG(pThis, DPLBASE),   HDA_REG(pThis, DPUBASE));
     3942        pThis->u64CORBBase  = RT_MAKE_U64(HDA_REG(pThis, CORBLBASE), HDA_REG(pThis, CORBUBASE));
     3943        pThis->u64RIRBBase  = RT_MAKE_U64(HDA_REG(pThis, RIRBLBASE), HDA_REG(pThis, RIRBUBASE));
     3944        pThis->u64DPBase    = RT_MAKE_U64(HDA_REG(pThis, DPLBASE),   HDA_REG(pThis, DPUBASE));
     3945
     3946        /* Also make sure to update the DMA position bit if this was enabled when saving the state. */
     3947        pThis->fDMAPosition = RT_BOOL(HDA_REG(pThis, DPLBASE) & RT_BIT_32(0));
    39143948    }
    39153949    else
     
    41474181    LogFunc(("Resetting ...\n"));
    41484182
    4149     /*
    4150      * Stop any audio currently playing and/or recording.
    4151      */
    4152     PHDADRIVER pDrv;
    4153     RTListForEach(&pThis->lstDrv, pDrv, HDADRIVER, Node)
    4154     {
    4155         pDrv->pConnector->pfnEnableIn(pDrv->pConnector, pDrv->LineIn.pStrmIn, false /* Disable */);
    4156 #ifdef VBOX_WITH_HDA_MIC_IN
    4157         /* Ignore rc. */
    4158         pDrv->pConnector->pfnEnableIn(pDrv->pConnector, pDrv->MicIn.pStrmIn, false /* Disable */);
    4159 #endif
    4160         /* Ditto. */
    4161         pDrv->pConnector->pfnEnableOut(pDrv->pConnector, pDrv->Out.pStrmOut, false /* Disable */);
    4162         /* Ditto. */
    4163     }
    4164 
    4165     pThis->cbCorbBuf = 256 * sizeof(uint32_t); /** @todo Use a define here. */
    4166 
    4167     if (pThis->pu32CorbBuf)
    4168         RT_BZERO(pThis->pu32CorbBuf, pThis->cbCorbBuf);
    4169     else
    4170         pThis->pu32CorbBuf = (uint32_t *)RTMemAllocZ(pThis->cbCorbBuf);
    4171 
    4172     pThis->cbRirbBuf = 256 * sizeof(uint64_t); /** @todo Use a define here. */
    4173     if (pThis->pu64RirbBuf)
    4174         RT_BZERO(pThis->pu64RirbBuf, pThis->cbRirbBuf);
    4175     else
    4176         pThis->pu64RirbBuf = (uint64_t *)RTMemAllocZ(pThis->cbRirbBuf);
    4177 
    4178     pThis->u64BaseTS = PDMDevHlpTMTimeVirtGetNano(pDevIns);
    4179 
    41804183# ifndef VBOX_WITH_AUDIO_CALLBACKS
    41814184    /*
     
    41894192    }
    41904193# endif
     4194
     4195    /*
     4196     * Stop any audio currently playing and/or recording.
     4197     */
     4198    PHDADRIVER pDrv;
     4199    RTListForEach(&pThis->lstDrv, pDrv, HDADRIVER, Node)
     4200    {
     4201        pDrv->pConnector->pfnEnableIn(pDrv->pConnector, pDrv->LineIn.pStrmIn, false /* Disable */);
     4202# ifdef VBOX_WITH_HDA_MIC_IN
     4203        /* Ignore rc. */
     4204        pDrv->pConnector->pfnEnableIn(pDrv->pConnector, pDrv->MicIn.pStrmIn, false /* Disable */);
     4205# endif
     4206        /* Ditto. */
     4207        pDrv->pConnector->pfnEnableOut(pDrv->pConnector, pDrv->Out.pStrmOut, false /* Disable */);
     4208        /* Ditto. */
     4209    }
     4210
     4211    pThis->cbCorbBuf = 256 * sizeof(uint32_t); /** @todo Use a define here. */
     4212
     4213    if (pThis->pu32CorbBuf)
     4214        RT_BZERO(pThis->pu32CorbBuf, pThis->cbCorbBuf);
     4215    else
     4216        pThis->pu32CorbBuf = (uint32_t *)RTMemAllocZ(pThis->cbCorbBuf);
     4217
     4218    pThis->cbRirbBuf = 256 * sizeof(uint64_t); /** @todo Use a define here. */
     4219    if (pThis->pu64RirbBuf)
     4220        RT_BZERO(pThis->pu64RirbBuf, pThis->cbRirbBuf);
     4221    else
     4222        pThis->pu64RirbBuf = (uint64_t *)RTMemAllocZ(pThis->cbRirbBuf);
     4223
     4224    pThis->u64BaseTS = PDMDevHlpTMTimeVirtGetNano(pDevIns);
    41914225
    41924226    for (uint8_t u8Strm = 0; u8Strm < 8; u8Strm++) /** @todo Use a define here. */
     
    42204254    if (pThis->pTimer)
    42214255    {
     4256        LogFunc(("Restarting timer\n"));
    42224257        rc2 = TMTimerSet(pThis->pTimer, TMTimerGet(pThis->pTimer) + pThis->cTimerTicks);
    42234258        AssertRC(rc2);
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