VirtualBox

Changeset 89900 in vbox for trunk


Ignore:
Timestamp:
Jun 24, 2021 7:13:49 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
145358
Message:

DevHda: Made the register map local to DevHda.cpp only, DevHdaStream.cpp does not need it. bugref:9890

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

Legend:

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

    r89894 r89900  
    5353#include "AudioMixer.h"
    5454
     55#define VBOX_HDA_CAN_ACCESS_REG_MAP /* g_aHdaRegMap is accessible */
    5556#include "DevHda.h"
    5657
     
    223224
    224225
     226/** Read callback. */
     227typedef VBOXSTRICTRC FNHDAREGREAD(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value);
     228/** Write callback. */
     229typedef VBOXSTRICTRC FNHDAREGWRITE(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
     230
     231/**
     232 * HDA register descriptor.
     233 */
     234typedef struct HDAREGDESC
     235{
     236    /** Register offset in the register space. */
     237    uint32_t        offset;
     238    /** Size in bytes. Registers of size > 4 are in fact tables. */
     239    uint32_t        size;
     240    /** Readable bits. */
     241    uint32_t        readable;
     242    /** Writable bits. */
     243    uint32_t        writable;
     244    /** Register descriptor (RD) flags of type HDA_RD_F_XXX. These are used to
     245     *  specify the read/write handling policy of the register. */
     246    uint32_t        fFlags;
     247    /** Read callback. */
     248    FNHDAREGREAD   *pfnRead;
     249    /** Write callback. */
     250    FNHDAREGWRITE  *pfnWrite;
     251    /** Index into the register storage array.
     252     * @todo r=bird: Bad structure layout. Move up before pfnRead. */
     253    uint32_t        mem_idx;
     254    /** Abbreviated name. */
     255    const char     *abbrev;
     256    /** Descripton. */
     257    const char     *desc;
     258} HDAREGDESC;
     259
     260
     261
    225262/*********************************************************************************************************************************
    226263*   Internal Functions                                                                                                           *
     
    292329 */
    293330#ifdef IN_RING3
    294 static int                        hdaR3AddStream(PHDASTATER3 pThisCC, PPDMAUDIOSTREAMCFG pCfg);
    295 static int                        hdaR3RemoveStream(PHDASTATER3 pThisCC, PPDMAUDIOSTREAMCFG pCfg);
     331static int hdaR3AddStream(PHDASTATER3 pThisCC, PPDMAUDIOSTREAMCFG pCfg);
     332static int hdaR3RemoveStream(PHDASTATER3 pThisCC, PPDMAUDIOSTREAMCFG pCfg);
    296333#endif /* IN_RING3 */
    297334/** @} */
     
    358395
    359396/** See 302349 p 6.2. */
    360 const HDAREGDESC g_aHdaRegMap[HDA_NUM_REGS] =
     397static const HDAREGDESC g_aHdaRegMap[HDA_NUM_REGS] =
    361398{
    362399    /* offset  size     read mask   write mask  flags          read callback     write callback       index + abbrev               */
     
    515552};
    516553
     554
     555#ifdef VBOX_STRICT
     556
     557/**
     558 * Strict register accessor verifing defines and mapping table.
     559 * @see HDA_REG
     560 */
     561DECLINLINE(uint32_t *) hdaStrictRegAccessor(PHDASTATE pThis, uint32_t idxMap, uint32_t idxReg)
     562{
     563    Assert(idxMap < RT_ELEMENTS(g_aHdaRegMap));
     564    AssertMsg(idxReg == g_aHdaRegMap[idxMap].mem_idx, ("idxReg=%d\n", idxReg));
     565    return &pThis->au32Regs[idxReg];
     566}
     567
     568/**
     569 * Strict stream register accessor verifing defines and mapping table.
     570 * @see HDA_STREAM_REG
     571 */
     572DECLINLINE(uint32_t *) hdaStrictStreamRegAccessor(PHDASTATE pThis, uint32_t idxMap0, uint32_t idxReg0, size_t idxStream)
     573{
     574    Assert(idxMap0 < RT_ELEMENTS(g_aHdaRegMap));
     575    AssertMsg(idxStream < RT_ELEMENTS(pThis->aStreams), ("%#zx\n", idxStream));
     576    AssertMsg(idxReg0 + idxStream * 10 == g_aHdaRegMap[idxMap0 + idxStream * 10].mem_idx,
     577              ("idxReg0=%d idxStream=%zx\n", idxReg0, idxStream));
     578    return &pThis->au32Regs[idxReg0 + idxStream * 10];
     579}
     580
     581#endif /* VBOX_STRICT */
    517582
    518583
  • trunk/src/VBox/Devices/Audio/DevHda.h

    r89899 r89900  
    9797
    9898
     99/** @defgroup grp_hda_regs  HDA Register Definitions
     100 *
     101 * There are two variants for most register defines:
     102 *      - HDA_REG_XXX: Index into g_aHdaRegMap
     103 *      - HDA_RMX_XXX: Index into HDASTATE::au32Regs
     104 *
     105 * Use the HDA_REG and HDA_STREAM_REG macros to access registers where possible.
     106 *
     107 * @note The au32Regs[] layout is kept unchanged for saved state compatibility,
     108 *       thus the HDA_RMX_XXX assignments are for all purposes set in stone.
     109 *
     110 * @{ */
     111
    99112/** Number of general registers. */
    100113#define HDA_NUM_GENERAL_REGS        34
     
    105118
    106119
    107 /** Read callback. */
    108 typedef VBOXSTRICTRC FNHDAREGREAD(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value);
    109 /** Write callback. */
    110 typedef VBOXSTRICTRC FNHDAREGWRITE(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
    111 
    112 /**
    113  * HDA register descriptor.
    114  */
    115 typedef struct HDAREGDESC
    116 {
    117     /** Register offset in the register space. */
    118     uint32_t        offset;
    119     /** Size in bytes. Registers of size > 4 are in fact tables. */
    120     uint32_t        size;
    121     /** Readable bits. */
    122     uint32_t        readable;
    123     /** Writable bits. */
    124     uint32_t        writable;
    125     /** Register descriptor (RD) flags of type HDA_RD_F_XXX. These are used to
    126      *  specify the read/write handling policy of the register. */
    127     uint32_t        fFlags;
    128     /** Read callback. */
    129     FNHDAREGREAD   *pfnRead;
    130     /** Write callback. */
    131     FNHDAREGWRITE  *pfnWrite;
    132     /** Index into the register storage array.
    133      * @todo r=bird: Bad structure layout. Move up before pfnRead. */
    134     uint32_t        mem_idx;
    135     /** Abbreviated name. */
    136     const char     *abbrev;
    137     /** Descripton. */
    138     const char     *desc;
    139 } HDAREGDESC;
    140 
    141 #ifdef VBOX_STRICT
    142 extern const HDAREGDESC g_aHdaRegMap[HDA_NUM_REGS];
    143 #endif
    144 
    145 
    146 /**
    147  * ICH6 datasheet defines limits for FIFOS registers (18.2.39).
    148  * Formula: size - 1
    149  * Other values not listed are not supported.
    150  */
    151 
    152120/** Offset of the SD0 register map. */
    153121#define HDA_REG_DESC_SD0_BASE       0x80
    154 
    155 /*
    156  * NB: Register values stored in memory (au32Regs[]) are indexed through
    157  * the HDA_RMX_xxx macros (also HDA_MEM_IND_NAME()). On the other hand, the
    158  * register descriptors in g_aHdaRegMap[] are indexed through the
    159  * HDA_REG_xxx macros (also HDA_REG_IND_NAME()).
    160  *
    161  * The au32Regs[] layout is kept unchanged for saved state compatibility.
    162  */
    163122
    164123/* Registers */
     
    170129
    171130/** Accesses register @a ShortRegNm. */
    172 #ifdef VBOX_STRICT
     131#if defined(VBOX_STRICT) && defined(VBOX_HDA_CAN_ACCESS_REG_MAP)
    173132# define HDA_REG(a_pThis, a_ShortRegNm)     (*hdaStrictRegAccessor(a_pThis, HDA_REG_IND_NAME(a_ShortRegNm), HDA_MEM_IND_NAME(a_ShortRegNm)))
    174133#else
     
    343302#define HDA_STREAM_RMX_DEF(name, num)           (HDA_RMX_SD##num##name)
    344303/** @note sdnum here _MUST_ be stream reg number [0,7]. */
    345 #ifdef VBOX_STRICT
     304#if defined(VBOX_STRICT) && defined(VBOX_HDA_CAN_ACCESS_REG_MAP)
    346305# define HDA_STREAM_REG(pThis, name, sdnum)      (*hdaStrictStreamRegAccessor((pThis), HDA_REG_SD0##name, HDA_RMX_SD0##name, (sdnum)))
    347306#else
     
    454413#define HDA_RMX_SD7FIFOS            (HDA_STREAM_RMX_DEF(FIFOS, 0) + 70)
    455414
     415/* The ICH6 datasheet defines limits for FIFOS registers (18.2.39).
     416   Formula: size - 1
     417   Other values not listed are not supported. */
     418
    456419#define HDA_SDIFIFO_120B            0x77        /* 8-, 16-, 20-, 24-, 32-bit Input Streams */
    457420#define HDA_SDIFIFO_160B            0x9F        /* 20-, 24-bit Input Streams Streams */
     
    550513     | (((_aBits)     & HDA_SDFMT_BITS_MASK)      << HDA_SDFMT_BITS_SHIFT)      \
    551514     | ( (_aChan)     & HDA_SDFMT_CHANNELS_MASK))
     515
     516/** @} */ /* grp_hda_regs */
    552517
    553518
     
    836801uint8_t hdaSDFIFOWToBytes(uint16_t u16RegFIFOW);
    837802
    838 
    839 #ifdef VBOX_STRICT
    840 /**
    841  * Strict register accessor verifing defines and mapping table.
    842  * @see HDA_REG
    843  */
    844 DECLINLINE(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  */
    855 DECLINLINE(uint32_t *) hdaStrictStreamRegAccessor(PHDASTATE pThis, uint32_t idxMap0, uint32_t idxReg0, size_t idxStream)
    856 {
    857     Assert(idxMap0 < RT_ELEMENTS(g_aHdaRegMap));
    858     AssertMsg(idxStream < RT_ELEMENTS(pThis->aStreams), ("%#zx\n", idxStream));
    859     AssertMsg(idxReg0 + idxStream * 10 == g_aHdaRegMap[idxMap0 + idxStream * 10].mem_idx,
    860               ("idxReg0=%d idxStream=%zx\n", idxReg0, idxStream));
    861     return &pThis->au32Regs[idxReg0 + idxStream * 10];
    862 }
    863 
    864 #endif /* VBOX_STRICT */
    865 
     803#if defined(VBOX_STRICT) && defined(VBOX_HDA_CAN_ACCESS_REG_MAP)
     804/* Only in DevHda.cpp: */
     805DECLINLINE(uint32_t *) hdaStrictRegAccessor(PHDASTATE pThis, uint32_t idxMap, uint32_t idxReg);
     806DECLINLINE(uint32_t *) hdaStrictStreamRegAccessor(PHDASTATE pThis, uint32_t idxMap0, uint32_t idxReg0, size_t idxStream);
     807#endif /* VBOX_STRICT && VBOX_HDA_CAN_ACCESS_REG_MAP */
    866808
    867809
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