VirtualBox

Changeset 89687 in vbox for trunk/src/VBox/Devices/Audio


Ignore:
Timestamp:
Jun 14, 2021 4:11:37 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
145135
Message:

DevIchAc97: ichac97R3DbgPrintBdl misunderstood LVI. Some todos and nits. bugref:9890

File:
1 edited

Legend:

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

    r89681 r89687  
    18851885     *       up to and we cannot really make much of a plan out of it.
    18861886     */
     1887    /** @todo This is wrong! The valid range is CVI thru LVI. However, CVI is
     1888     *        typically reset to zero, I guess... */
    18871889    AC97BDLE aBdl[AC97_MAX_BDLE];
    18881890    RT_ZERO(aBdl);
     
    28692871                         *                Last Valid Index Register +
    28702872                         *                Status Register */
    2871                         *pu32 = pRegs->civ | (pRegs->lvi << 8) | (pRegs->sr << 16); /** @todo r=andy Use RT_MAKE_U32_FROM_U8. */
     2873                        *pu32 = pRegs->civ | ((uint32_t)pRegs->lvi << 8) | ((uint32_t)pRegs->sr << 16);
    28722874                        Log3Func(("CIV LVI SR[%d] -> %#x, %#x, %#x\n",
    28732875                                  AC97_PORT2IDX(offPort), pRegs->civ, pRegs->lvi, pRegs->sr));
     
    28772879                         *                Prefetched Index Value Register +
    28782880                         *                Control Register */
    2879                         *pu32 = pRegs->picb | (pRegs->piv << 16) | (pRegs->cr << 24); /** @todo r=andy Use RT_MAKE_U32_FROM_U8. */
     2881                        *pu32 = pRegs->picb | ((uint32_t)pRegs->piv << 16) | ((uint32_t)pRegs->cr << 24);
    28802882                        Log3Func(("PICB PIV CR[%d] -> %#x %#x %#x %#x\n",
    28812883                                  AC97_PORT2IDX(offPort), *pu32, pRegs->picb, pRegs->piv, pRegs->cr));
     
    29902992                            && (pRegs->sr & AC97_SR_DCH))
    29912993                        {
    2992 #ifdef IN_RING3
     2994#ifdef IN_RING3 /** @todo r=bird: What kind of unexplained non-sense is this ifdef?!? */
    29932995                            pRegs->sr &= ~(AC97_SR_DCH | AC97_SR_CELV);
    29942996                            pRegs->civ = pRegs->piv;
     
    30883090                    case AC97_NABM_OFF_BDBAR:
    30893091                        /* Buffer Descriptor list Base Address Register */
    3090                         pRegs->bdbar = u32 & ~3;
     3092                        pRegs->bdbar = u32 & ~(uint32_t)3;
    30913093                        Log3Func(("[SD%RU8] BDBAR <- %#x (bdbar %#x)\n", AC97_PORT2IDX(offPort), u32, pRegs->bdbar));
    30923094                        break;
     
    36373639                                 PCDBGFINFOHLP pHlp, const char *pszPrefix)
    36383640{
    3639     unsigned const cEntries = pStream->Regs.lvi + 1;
    3640     pHlp->pfnPrintf(pHlp, "%sBDL for stream #%u: @ %#RX32 L %#x:\n", pszPrefix, pStream->u8SD, pStream->Regs.bdbar, cEntries);
     3641    uint8_t const bLvi = pStream->Regs.lvi;
     3642    uint8_t const bCiv = pStream->Regs.civ;
     3643    pHlp->pfnPrintf(pHlp, "%sBDL for stream #%u: @ %#RX32 LB 0x100; CIV=%#04x LVI=%#04x:\n",
     3644                    pszPrefix, pStream->u8SD, pStream->Regs.bdbar, bCiv, bLvi);
    36413645    if (pStream->Regs.bdbar != 0)
    36423646    {
    36433647        /* Read all in one go. */
    3644         AssertCompile(sizeof(pStream->Regs.lvi) == sizeof(uint8_t));
    3645         AC97BDLE aBdl[256];
     3648        AC97BDLE aBdl[AC97_MAX_BDLE];
    36463649        RT_ZERO(aBdl);
    3647         PDMDevHlpPCIPhysRead(pDevIns, pStream->Regs.bdbar, aBdl, sizeof(aBdl[0]) * cEntries);
     3650        PDMDevHlpPCIPhysRead(pDevIns, pStream->Regs.bdbar, aBdl, sizeof(aBdl));
    36483651
    36493652        /* Get the audio props for the stream so we can translate the sizes correctly. */
     
    36533656        /* Dump them. */
    36543657        uint64_t cbTotal = 0;
    3655         for (unsigned i = 0; i < cEntries; i++)
     3658        uint64_t cbValid = 0;
     3659        for (unsigned i = 0; i < RT_ELEMENTS(aBdl); i++)
    36563660        {
    36573661            aBdl[i].addr    = RT_LE2H_U32(aBdl[i].addr);
    36583662            aBdl[i].ctl_len = RT_LE2H_U32(aBdl[i].ctl_len);
    36593663
     3664            bool const fValid = bCiv <= bLvi
     3665                              ? i >= bCiv && i <= bLvi
     3666                              : (i >= bCiv && i < RT_ELEMENTS(aBdl)) || i <= bLvi;
     3667
    36603668            uint32_t const cb = (aBdl[i].ctl_len & AC97_BD_LEN_MASK) * PDMAudioPropsSampleSize(&Props); /** @todo or frame size? OSDev says frame... */
    36613669            cbTotal += cb;
     3670            if (fValid)
     3671                cbValid += cb;
    36623672
    36633673            char szFlags[64];
     
    36663676                RTStrPrintf(szFlags, sizeof(szFlags), " !!fFlags=%#x!!\n", aBdl[i].ctl_len & ~AC97_BD_LEN_MASK);
    36673677
    3668             pHlp->pfnPrintf(pHlp, "%s  BDLE%02u: %#010RX32 L %#06x / LB %#RX32 / %RU64ms%s%s%s%s\n", pszPrefix, i, aBdl[i].addr,
     3678            pHlp->pfnPrintf(pHlp, "%s %cBDLE%02u: %#010RX32 L %#06x / LB %#RX32 / %RU64ms%s%s%s%s\n",
     3679                            pszPrefix, fValid ? ' ' : '?', i, aBdl[i].addr,
    36693680                            aBdl[i].ctl_len & AC97_BD_LEN_MASK, cb, PDMAudioPropsBytesToMilli(&Props, cb),
    36703681                            aBdl[i].ctl_len & AC97_BD_IOC ?  " ioc" : "",
     
    36733684        }
    36743685
    3675         pHlp->pfnPrintf(pHlp, "%sTotal: %#RX64 bytes (%RU64), %RU64 ms\n", pszPrefix, cbTotal, cbTotal,
    3676                         PDMAudioPropsBytesToMilli(&Props, cbTotal));
     3686        pHlp->pfnPrintf(pHlp, "%sTotal: %#RX64 bytes (%RU64), %RU64 ms;  Valid: %#RX64 bytes (%RU64), %RU64 ms\n", pszPrefix,
     3687                        cbTotal, cbTotal, PDMAudioPropsBytesToMilli(&Props, cbTotal),
     3688                        cbValid, cbValid, PDMAudioPropsBytesToMilli(&Props, cbValid) );
    36773689    }
    36783690}
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