- Timestamp:
- Jun 24, 2021 7:13:49 PM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 145358
- Location:
- trunk/src/VBox/Devices/Audio
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevHda.cpp
r89894 r89900 53 53 #include "AudioMixer.h" 54 54 55 #define VBOX_HDA_CAN_ACCESS_REG_MAP /* g_aHdaRegMap is accessible */ 55 56 #include "DevHda.h" 56 57 … … 223 224 224 225 226 /** Read callback. */ 227 typedef VBOXSTRICTRC FNHDAREGREAD(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value); 228 /** Write callback. */ 229 typedef VBOXSTRICTRC FNHDAREGWRITE(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); 230 231 /** 232 * HDA register descriptor. 233 */ 234 typedef 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 225 262 /********************************************************************************************************************************* 226 263 * Internal Functions * … … 292 329 */ 293 330 #ifdef IN_RING3 294 static int 295 static int 331 static int hdaR3AddStream(PHDASTATER3 pThisCC, PPDMAUDIOSTREAMCFG pCfg); 332 static int hdaR3RemoveStream(PHDASTATER3 pThisCC, PPDMAUDIOSTREAMCFG pCfg); 296 333 #endif /* IN_RING3 */ 297 334 /** @} */ … … 358 395 359 396 /** See 302349 p 6.2. */ 360 const HDAREGDESC g_aHdaRegMap[HDA_NUM_REGS] =397 static const HDAREGDESC g_aHdaRegMap[HDA_NUM_REGS] = 361 398 { 362 399 /* offset size read mask write mask flags read callback write callback index + abbrev */ … … 515 552 }; 516 553 554 555 #ifdef VBOX_STRICT 556 557 /** 558 * Strict register accessor verifing defines and mapping table. 559 * @see HDA_REG 560 */ 561 DECLINLINE(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 */ 572 DECLINLINE(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 */ 517 582 518 583 -
trunk/src/VBox/Devices/Audio/DevHda.h
r89899 r89900 97 97 98 98 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 99 112 /** Number of general registers. */ 100 113 #define HDA_NUM_GENERAL_REGS 34 … … 105 118 106 119 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 HDAREGDESC116 {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 to126 * 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_STRICT142 extern const HDAREGDESC g_aHdaRegMap[HDA_NUM_REGS];143 #endif144 145 146 /**147 * ICH6 datasheet defines limits for FIFOS registers (18.2.39).148 * Formula: size - 1149 * Other values not listed are not supported.150 */151 152 120 /** Offset of the SD0 register map. */ 153 121 #define HDA_REG_DESC_SD0_BASE 0x80 154 155 /*156 * NB: Register values stored in memory (au32Regs[]) are indexed through157 * the HDA_RMX_xxx macros (also HDA_MEM_IND_NAME()). On the other hand, the158 * register descriptors in g_aHdaRegMap[] are indexed through the159 * HDA_REG_xxx macros (also HDA_REG_IND_NAME()).160 *161 * The au32Regs[] layout is kept unchanged for saved state compatibility.162 */163 122 164 123 /* Registers */ … … 170 129 171 130 /** Accesses register @a ShortRegNm. */ 172 #if def VBOX_STRICT131 #if defined(VBOX_STRICT) && defined(VBOX_HDA_CAN_ACCESS_REG_MAP) 173 132 # define HDA_REG(a_pThis, a_ShortRegNm) (*hdaStrictRegAccessor(a_pThis, HDA_REG_IND_NAME(a_ShortRegNm), HDA_MEM_IND_NAME(a_ShortRegNm))) 174 133 #else … … 343 302 #define HDA_STREAM_RMX_DEF(name, num) (HDA_RMX_SD##num##name) 344 303 /** @note sdnum here _MUST_ be stream reg number [0,7]. */ 345 #if def VBOX_STRICT304 #if defined(VBOX_STRICT) && defined(VBOX_HDA_CAN_ACCESS_REG_MAP) 346 305 # define HDA_STREAM_REG(pThis, name, sdnum) (*hdaStrictStreamRegAccessor((pThis), HDA_REG_SD0##name, HDA_RMX_SD0##name, (sdnum))) 347 306 #else … … 454 413 #define HDA_RMX_SD7FIFOS (HDA_STREAM_RMX_DEF(FIFOS, 0) + 70) 455 414 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 456 419 #define HDA_SDIFIFO_120B 0x77 /* 8-, 16-, 20-, 24-, 32-bit Input Streams */ 457 420 #define HDA_SDIFIFO_160B 0x9F /* 20-, 24-bit Input Streams Streams */ … … 550 513 | (((_aBits) & HDA_SDFMT_BITS_MASK) << HDA_SDFMT_BITS_SHIFT) \ 551 514 | ( (_aChan) & HDA_SDFMT_CHANNELS_MASK)) 515 516 /** @} */ /* grp_hda_regs */ 552 517 553 518 … … 836 801 uint8_t hdaSDFIFOWToBytes(uint16_t u16RegFIFOW); 837 802 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: */ 805 DECLINLINE(uint32_t *) hdaStrictRegAccessor(PHDASTATE pThis, uint32_t idxMap, uint32_t idxReg); 806 DECLINLINE(uint32_t *) hdaStrictStreamRegAccessor(PHDASTATE pThis, uint32_t idxMap0, uint32_t idxReg0, size_t idxStream); 807 #endif /* VBOX_STRICT && VBOX_HDA_CAN_ACCESS_REG_MAP */ 866 808 867 809
Note:
See TracChangeset
for help on using the changeset viewer.