VirtualBox

Ignore:
Timestamp:
Jun 24, 2021 6:57:00 PM (3 years ago)
Author:
vboxsync
Message:

DevHda: Added another assertion wrapper for register access for strict builds. bugref:9890

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Audio/DevHda.h

    r89897 r89899  
    168168/** Direct register access by HDASTATE::au32Reg index. */
    169169#define HDA_REG_BY_IDX(a_pThis, a_idxReg)   ((a_pThis)->au32Regs[(a_idxReg)])
     170
    170171/** Accesses register @a ShortRegNm. */
    171 #define HDA_REG(a_pThis, a_ShortRegNm)      HDA_REG_BY_IDX(a_pThis, HDA_MEM_IND_NAME(a_ShortRegNm))
     172#ifdef VBOX_STRICT
     173# define HDA_REG(a_pThis, a_ShortRegNm)     (*hdaStrictRegAccessor(a_pThis, HDA_REG_IND_NAME(a_ShortRegNm), HDA_MEM_IND_NAME(a_ShortRegNm)))
     174#else
     175# define HDA_REG(a_pThis, a_ShortRegNm)     HDA_REG_BY_IDX(a_pThis, HDA_MEM_IND_NAME(a_ShortRegNm))
     176#endif
     177
    172178/** Indirect register access via g_aHdaRegMap[].mem_idx. */
    173179#define HDA_REG_IND(a_pThis, a_idxMap)      HDA_REG_BY_IDX(a_pThis, g_aHdaRegMap[(a_idxMap)].mem_idx)
     
    827833}
    828834
     835/* Used by hdaR3StreamSetUp: */
     836uint8_t hdaSDFIFOWToBytes(uint16_t u16RegFIFOW);
     837
     838
    829839#ifdef VBOX_STRICT
     840/**
     841 * Strict register accessor verifing defines and mapping table.
     842 * @see HDA_REG
     843 */
     844DECLINLINE(uint32_t *) hdaStrictRegAccessor(PHDASTATE pThis, uint32_t idxMap, uint32_t idxReg)
     845{
     846    Assert(idxMap < RT_ELEMENTS(g_aHdaRegMap));
     847    AssertMsg(idxReg == g_aHdaRegMap[idxMap].mem_idx, ("idxReg=%d\n", idxReg));
     848    return &pThis->au32Regs[idxReg];
     849}
     850
     851/**
     852 * Strict stream register accessor verifing defines and mapping table.
     853 * @see HDA_STREAM_REG
     854 */
    830855DECLINLINE(uint32_t *) hdaStrictStreamRegAccessor(PHDASTATE pThis, uint32_t idxMap0, uint32_t idxReg0, size_t idxStream)
    831856{
     857    Assert(idxMap0 < RT_ELEMENTS(g_aHdaRegMap));
    832858    AssertMsg(idxStream < RT_ELEMENTS(pThis->aStreams), ("%#zx\n", idxStream));
    833859    AssertMsg(idxReg0 + idxStream * 10 == g_aHdaRegMap[idxMap0 + idxStream * 10].mem_idx,
     
    835861    return &pThis->au32Regs[idxReg0 + idxStream * 10];
    836862}
    837 #endif
    838 
    839 /* Used by hdaR3StreamSetUp: */
    840 uint8_t hdaSDFIFOWToBytes(uint16_t u16RegFIFOW);
     863
     864#endif /* VBOX_STRICT */
    841865
    842866
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