VirtualBox

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


Ignore:
Timestamp:
Sep 10, 2019 9:58:21 AM (5 years ago)
Author:
vboxsync
Message:

DevHDA: Use device helpers for critical sections. bugref:9218

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

Legend:

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

    r80682 r80691  
    110110 * Acquires the HDA lock.
    111111 */
    112 #define DEVHDA_LOCK(a_pThis) \
     112#define DEVHDA_LOCK(a_pDevIns, a_pThis) \
    113113    do { \
    114         int rcLock = PDMCritSectEnter(&(a_pThis)->CritSect, VERR_IGNORED); \
     114        int rcLock = PDMDevHlpCritSectEnter((a_pDevIns), &(a_pThis)->CritSect, VERR_IGNORED); \
    115115        AssertRC(rcLock); \
    116116    } while (0)
     
    119119 * Acquires the HDA lock or returns.
    120120 */
    121 # define DEVHDA_LOCK_RETURN(a_pThis, a_rcBusy) \
     121#define DEVHDA_LOCK_RETURN(a_pDevIns, a_pThis, a_rcBusy) \
    122122    do { \
    123         int rcLock = PDMCritSectEnter(&(a_pThis)->CritSect, a_rcBusy); \
    124         if (rcLock != VINF_SUCCESS) \
     123        int rcLock = PDMDevHlpCritSectEnter((a_pDevIns), &(a_pThis)->CritSect, a_rcBusy); \
     124        if (rcLock == VINF_SUCCESS) \
     125        { /* likely */ } \
     126        else \
    125127        { \
    126128            AssertRC(rcLock); \
     
    132134 * Acquires the HDA lock or returns.
    133135 */
    134 # define DEVHDA_LOCK_RETURN_VOID(a_pThis) \
     136# define DEVHDA_LOCK_RETURN_VOID(a_pDevIns, a_pThis) \
    135137    do { \
    136         int rcLock = PDMCritSectEnter(&(a_pThis)->CritSect, VERR_IGNORED); \
    137         if (rcLock != VINF_SUCCESS) \
     138        int rcLock = PDMDevHlpCritSectEnter((a_pDevIns), &(a_pThis)->CritSect, VERR_IGNORED); \
     139        if (rcLock == VINF_SUCCESS) \
     140        { /* likely */ } \
     141        else \
    138142        { \
    139143            AssertRC(rcLock); \
     
    145149 * Releases the HDA lock.
    146150 */
    147 #define DEVHDA_UNLOCK(a_pThis) \
    148     do { PDMCritSectLeave(&(a_pThis)->CritSect); } while (0)
     151#define DEVHDA_UNLOCK(a_pDevIns, a_pThis) \
     152    do { PDMDevHlpCritSectLeave((a_pDevIns), &(a_pThis)->CritSect); } while (0)
    149153
    150154/**
    151155 * Acquires the TM lock and HDA lock, returns on failure.
    152156 */
    153 #define DEVHDA_LOCK_BOTH_RETURN_VOID(a_pThis, a_SD) \
     157#define DEVHDA_LOCK_BOTH_RETURN_VOID(a_pDevIns, a_pThis, a_SD) \
    154158    do { \
    155159        int rcLock = TMTimerLock((a_pThis)->pTimer[a_SD], VERR_IGNORED); \
    156         if (rcLock != VINF_SUCCESS) \
     160        if (rcLock == VINF_SUCCESS) \
     161        { /* likely */ } \
     162        else \
    157163        { \
    158164            AssertRC(rcLock); \
    159165            return; \
    160166        } \
    161         rcLock = PDMCritSectEnter(&(a_pThis)->CritSect, VERR_IGNORED); \
    162         if (rcLock != VINF_SUCCESS) \
     167        rcLock = PDMDevHlpCritSectEnter((a_pDevIns), &(a_pThis)->CritSect, VERR_IGNORED); \
     168        if (rcLock == VINF_SUCCESS) \
     169        { /* likely */ } \
     170        else \
    163171        { \
    164172            AssertRC(rcLock); \
     
    171179 * Acquires the TM lock and HDA lock, returns on failure.
    172180 */
    173 #define DEVHDA_LOCK_BOTH_RETURN(a_pThis, a_SD, a_rcBusy) \
     181#define DEVHDA_LOCK_BOTH_RETURN(a_pDevIns, a_pThis, a_SD, a_rcBusy) \
    174182    do { \
    175183        int rcLock = TMTimerLock((a_pThis)->pTimer[a_SD], (a_rcBusy)); \
    176         if (rcLock != VINF_SUCCESS) \
     184        if (rcLock == VINF_SUCCESS) \
     185        { /* likely */ } \
     186        else \
     187        { \
     188            AssertRC(rcLock); \
    177189            return rcLock; \
    178         rcLock = PDMCritSectEnter(&(a_pThis)->CritSect, (a_rcBusy)); \
    179         if (rcLock != VINF_SUCCESS) \
     190        } \
     191        rcLock = PDMDevHlpCritSectEnter((a_pDevIns), &(a_pThis)->CritSect, (a_rcBusy)); \
     192        if (rcLock == VINF_SUCCESS) \
     193        { /* likely */ } \
     194        else \
    180195        { \
    181196            AssertRC(rcLock); \
     
    188203 * Releases the HDA lock and TM lock.
    189204 */
    190 #define DEVHDA_UNLOCK_BOTH(a_pThis, a_SD) \
     205#define DEVHDA_UNLOCK_BOTH(a_pDevIns, a_pThis, a_SD) \
    191206    do { \
    192         PDMCritSectLeave(&(a_pThis)->CritSect); \
     207        PDMDevHlpCritSectLeave((a_pDevIns), &(a_pThis)->CritSect); \
    193208        TMTimerUnlock((a_pThis)->pTimer[a_SD]); \
    194209    } while (0)
     
    290305 * @{
    291306 */
    292 static int hdaRegReadUnimpl(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value);
    293 static int hdaRegWriteUnimpl(PHDASTATE pThis, uint32_t iReg, uint32_t pu32Value);
     307static int hdaRegReadUnimpl(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value);
     308static int hdaRegWriteUnimpl(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
    294309/** @} */
    295310
     
    297312 * @{
    298313 */
    299 static int hdaRegWriteGCTL(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
    300 static int hdaRegReadLPIB(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value);
    301 static int hdaRegReadWALCLK(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value);
    302 static int hdaRegWriteCORBWP(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
    303 static int hdaRegWriteCORBRP(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
    304 static int hdaRegWriteCORBCTL(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
    305 static int hdaRegWriteCORBSIZE(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
    306 static int hdaRegWriteCORBSTS(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
    307 static int hdaRegWriteRINTCNT(PHDASTATE pThis, uint32_t iReg, uint32_t pu32Value);
    308 static int hdaRegWriteRIRBWP(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
    309 static int hdaRegWriteRIRBSTS(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
    310 static int hdaRegWriteSTATESTS(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
    311 static int hdaRegWriteIRS(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
    312 static int hdaRegReadIRS(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value);
    313 static int hdaRegWriteBase(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
     314static int hdaRegWriteGCTL(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
     315static int hdaRegReadLPIB(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value);
     316static int hdaRegReadWALCLK(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value);
     317static int hdaRegWriteCORBWP(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
     318static int hdaRegWriteCORBRP(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
     319static int hdaRegWriteCORBCTL(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
     320static int hdaRegWriteCORBSIZE(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
     321static int hdaRegWriteCORBSTS(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
     322static int hdaRegWriteRINTCNT(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
     323static int hdaRegWriteRIRBWP(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
     324static int hdaRegWriteRIRBSTS(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
     325static int hdaRegWriteSTATESTS(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
     326static int hdaRegWriteIRS(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
     327static int hdaRegReadIRS(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value);
     328static int hdaRegWriteBase(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
    314329/** @} */
    315330
     
    317332 * @{
    318333 */
    319 static int hdaRegWriteSDCBL(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
    320 static int hdaRegWriteSDCTL(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
    321 static int hdaRegWriteSDSTS(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
    322 static int hdaRegWriteSDLVI(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
    323 static int hdaRegWriteSDFIFOW(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
    324 static int hdaRegWriteSDFIFOS(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
    325 static int hdaRegWriteSDFMT(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
    326 static int hdaRegWriteSDBDPL(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
    327 static int hdaRegWriteSDBDPU(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
     334static int hdaRegWriteSDCBL(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
     335static int hdaRegWriteSDCTL(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
     336static int hdaRegWriteSDSTS(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
     337static int hdaRegWriteSDLVI(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
     338static int hdaRegWriteSDFIFOW(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
     339static int hdaRegWriteSDFIFOS(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
     340static int hdaRegWriteSDFMT(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
     341static int hdaRegWriteSDBDPL(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
     342static int hdaRegWriteSDBDPU(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
    328343/** @} */
    329344
     
    331346 * @{
    332347 */
    333 static int hdaRegReadU32(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value);
    334 static int hdaRegWriteU32(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
    335 static int hdaRegReadU24(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value);
     348static int hdaRegReadU32(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value);
     349static int hdaRegWriteU32(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
     350static int hdaRegReadU24(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value);
    336351#ifdef IN_RING3
    337 static int hdaRegWriteU24(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
     352static int hdaRegWriteU24(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
    338353#endif
    339 static int hdaRegReadU16(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value);
    340 static int hdaRegWriteU16(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
    341 static int hdaRegReadU8(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value);
    342 static int hdaRegWriteU8(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
     354static int hdaRegReadU16(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value);
     355static int hdaRegWriteU16(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
     356static int hdaRegReadU8(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value);
     357static int hdaRegWriteU8(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
    343358/** @} */
    344359
     
    903918/* Register access handlers. */
    904919
    905 static int hdaRegReadUnimpl(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value)
    906 {
    907     RT_NOREF_PV(pThis); RT_NOREF_PV(iReg);
     920static int hdaRegReadUnimpl(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value)
     921{
     922    RT_NOREF(pDevIns, pThis, iReg);
    908923    *pu32Value = 0;
    909924    return VINF_SUCCESS;
    910925}
    911926
    912 static int hdaRegWriteUnimpl(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
    913 {
    914     RT_NOREF_PV(pThis); RT_NOREF_PV(iReg); RT_NOREF_PV(u32Value);
     927static int hdaRegWriteUnimpl(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
     928{
     929    RT_NOREF(pDevIns, pThis, iReg, u32Value);
    915930    return VINF_SUCCESS;
    916931}
    917932
    918933/* U8 */
    919 static int hdaRegReadU8(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value)
     934static int hdaRegReadU8(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value)
    920935{
    921936    Assert(((pThis->au32Regs[g_aHdaRegMap[iReg].mem_idx] & g_aHdaRegMap[iReg].readable) & 0xffffff00) == 0);
    922     return hdaRegReadU32(pThis, iReg, pu32Value);
    923 }
    924 
    925 static int hdaRegWriteU8(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
     937    return hdaRegReadU32(pDevIns, pThis, iReg, pu32Value);
     938}
     939
     940static int hdaRegWriteU8(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
    926941{
    927942    Assert((u32Value & 0xffffff00) == 0);
    928     return hdaRegWriteU32(pThis, iReg, u32Value);
     943    return hdaRegWriteU32(pDevIns, pThis, iReg, u32Value);
    929944}
    930945
    931946/* U16 */
    932 static int hdaRegReadU16(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value)
     947static int hdaRegReadU16(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value)
    933948{
    934949    Assert(((pThis->au32Regs[g_aHdaRegMap[iReg].mem_idx] & g_aHdaRegMap[iReg].readable) & 0xffff0000) == 0);
    935     return hdaRegReadU32(pThis, iReg, pu32Value);
    936 }
    937 
    938 static int hdaRegWriteU16(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
     950    return hdaRegReadU32(pDevIns, pThis, iReg, pu32Value);
     951}
     952
     953static int hdaRegWriteU16(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
    939954{
    940955    Assert((u32Value & 0xffff0000) == 0);
    941     return hdaRegWriteU32(pThis, iReg, u32Value);
     956    return hdaRegWriteU32(pDevIns, pThis, iReg, u32Value);
    942957}
    943958
    944959/* U24 */
    945 static int hdaRegReadU24(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value)
     960static int hdaRegReadU24(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value)
    946961{
    947962    Assert(((pThis->au32Regs[g_aHdaRegMap[iReg].mem_idx] & g_aHdaRegMap[iReg].readable) & 0xff000000) == 0);
    948     return hdaRegReadU32(pThis, iReg, pu32Value);
     963    return hdaRegReadU32(pDevIns, pThis, iReg, pu32Value);
    949964}
    950965
    951966#ifdef IN_RING3
    952 static int hdaRegWriteU24(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
     967static int hdaRegWriteU24(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
    953968{
    954969    Assert((u32Value & 0xff000000) == 0);
    955     return hdaRegWriteU32(pThis, iReg, u32Value);
     970    return hdaRegWriteU32(pDevIns, pThis, iReg, u32Value);
    956971}
    957972#endif
    958973
    959974/* U32 */
    960 static int hdaRegReadU32(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value)
     975static int hdaRegReadU32(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value)
    961976{
    962977    uint32_t iRegMem = g_aHdaRegMap[iReg].mem_idx;
    963978
    964     DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_READ);
     979    DEVHDA_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_MMIO_READ);
    965980
    966981    *pu32Value = pThis->au32Regs[iRegMem] & g_aHdaRegMap[iReg].readable;
    967982
    968     DEVHDA_UNLOCK(pThis);
     983    DEVHDA_UNLOCK(pDevIns, pThis);
    969984    return VINF_SUCCESS;
    970985}
    971986
    972 static int hdaRegWriteU32(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
     987static int hdaRegWriteU32(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
    973988{
    974989    uint32_t iRegMem = g_aHdaRegMap[iReg].mem_idx;
    975990
    976     DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE);
     991    DEVHDA_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_MMIO_WRITE);
    977992
    978993    pThis->au32Regs[iRegMem]  = (u32Value & g_aHdaRegMap[iReg].writable)
    979994                              | (pThis->au32Regs[iRegMem] & ~g_aHdaRegMap[iReg].writable);
    980     DEVHDA_UNLOCK(pThis);
     995    DEVHDA_UNLOCK(pDevIns, pThis);
    981996    return VINF_SUCCESS;
    982997}
    983998
    984 static int hdaRegWriteGCTL(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
     999static int hdaRegWriteGCTL(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
    9851000{
    9861001    RT_NOREF_PV(iReg);
    9871002#ifdef IN_RING3
    988     DEVHDA_LOCK(pThis);
     1003    DEVHDA_LOCK(pDevIns, pThis);
    9891004#else
    9901005    if (!(u32Value & HDA_GCTL_CRST))
    9911006        return VINF_IOM_R3_MMIO_WRITE;
    992     DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE);
     1007    DEVHDA_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_MMIO_WRITE);
    9931008#endif
    9941009
     
    10121027        hdaR3GCTLReset(pThis);
    10131028#else
    1014         AssertFailedReturnStmt(DEVHDA_UNLOCK(pThis), VINF_IOM_R3_MMIO_WRITE);
     1029        AssertFailedReturnStmt(DEVHDA_UNLOCK(pDevIns, pThis), VINF_IOM_R3_MMIO_WRITE);
    10151030#endif
    10161031    }
     
    10231038    }
    10241039
    1025     DEVHDA_UNLOCK(pThis);
     1040    DEVHDA_UNLOCK(pDevIns, pThis);
    10261041    return VINF_SUCCESS;
    10271042}
    10281043
    1029 static int hdaRegWriteSTATESTS(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
    1030 {
    1031     DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE);
     1044static int hdaRegWriteSTATESTS(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
     1045{
     1046    DEVHDA_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_MMIO_WRITE);
    10321047
    10331048    uint32_t v  = HDA_REG_IND(pThis, iReg);
     
    10361051    HDA_REG(pThis, STATESTS) &= ~(v & nv); /* Write of 1 clears corresponding bit. */
    10371052
    1038     DEVHDA_UNLOCK(pThis);
     1053    DEVHDA_UNLOCK(pDevIns, pThis);
    10391054    return VINF_SUCCESS;
    10401055}
    10411056
    1042 static int hdaRegReadLPIB(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value)
    1043 {
    1044     DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_READ);
     1057static int hdaRegReadLPIB(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value)
     1058{
     1059    DEVHDA_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_MMIO_READ);
    10451060
    10461061    const uint8_t  uSD     = HDA_SD_NUM_FROM_REG(pThis, LPIB, iReg);
     
    10531068    *pu32Value = u32LPIB;
    10541069
    1055     DEVHDA_UNLOCK(pThis);
     1070    DEVHDA_UNLOCK(pDevIns, pThis);
    10561071    return VINF_SUCCESS;
    10571072}
     
    10981113#endif /* IN_RING3 */
    10991114
    1100 static int hdaRegReadWALCLK(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value)
     1115static int hdaRegReadWALCLK(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value)
    11011116{
    11021117#ifdef IN_RING3
    11031118    RT_NOREF(iReg);
    11041119
    1105     DEVHDA_LOCK(pThis);
     1120    DEVHDA_LOCK(pDevIns, pThis);
    11061121
    11071122    *pu32Value = RT_LO_U32(ASMAtomicReadU64(&pThis->u64WalClk));
     
    11091124    Log3Func(("%RU32 (max @ %RU64)\n",*pu32Value, hdaR3WalClkGetMax(pThis)));
    11101125
    1111     DEVHDA_UNLOCK(pThis);
     1126    DEVHDA_UNLOCK(pDevIns, pThis);
    11121127    return VINF_SUCCESS;
    11131128#else
    1114     RT_NOREF(pThis, iReg, pu32Value);
     1129    RT_NOREF(pDevIns, pThis, iReg, pu32Value);
    11151130    return VINF_IOM_R3_MMIO_READ;
    11161131#endif
    11171132}
    11181133
    1119 static int hdaRegWriteCORBRP(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
     1134static int hdaRegWriteCORBRP(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
    11201135{
    11211136    RT_NOREF(iReg);
    1122     DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE);
     1137    DEVHDA_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_MMIO_WRITE);
    11231138
    11241139    if (u32Value & HDA_CORBRP_RST)
     
    11311146            RT_BZERO((void *)pThis->pu32CorbBuf, pThis->cbCorbBuf);
    11321147#else
    1133             DEVHDA_UNLOCK(pThis);
     1148            DEVHDA_UNLOCK(pDevIns, pThis);
    11341149            return VINF_IOM_R3_MMIO_WRITE;
    11351150#endif
     
    11431158        HDA_REG(pThis, CORBRP) &= ~HDA_CORBRP_RST;  /* Only CORBRP_RST bit is writable. */
    11441159
    1145     DEVHDA_UNLOCK(pThis);
     1160    DEVHDA_UNLOCK(pDevIns, pThis);
    11461161    return VINF_SUCCESS;
    11471162}
    11481163
    1149 static int hdaRegWriteCORBCTL(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
     1164static int hdaRegWriteCORBCTL(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
    11501165{
    11511166#ifdef IN_RING3
    1152     DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE);
    1153 
    1154     int rc = hdaRegWriteU8(pThis, iReg, u32Value);
     1167    DEVHDA_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_MMIO_WRITE);
     1168
     1169    int rc = hdaRegWriteU8(pDevIns, pThis, iReg, u32Value);
    11551170    AssertRC(rc);
    11561171
     
    11621177        LogFunc(("CORB DMA not running, skipping\n"));
    11631178
    1164     DEVHDA_UNLOCK(pThis);
     1179    DEVHDA_UNLOCK(pDevIns, pThis);
    11651180    return rc;
    11661181#else
    1167     RT_NOREF(pThis, iReg, u32Value);
     1182    RT_NOREF(pDevIns, pThis, iReg, u32Value);
    11681183    return VINF_IOM_R3_MMIO_WRITE;
    11691184#endif
    11701185}
    11711186
    1172 static int hdaRegWriteCORBSIZE(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
     1187static int hdaRegWriteCORBSIZE(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
    11731188{
    11741189#ifdef IN_RING3
    11751190    RT_NOREF(iReg);
    1176     DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE);
     1191    DEVHDA_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_MMIO_WRITE);
    11771192
    11781193    if (HDA_REG(pThis, CORBCTL) & HDA_CORBCTL_DMA) /* Ignore request if CORB DMA engine is (still) running. */
     
    11801195        LogFunc(("CORB DMA is (still) running, skipping\n"));
    11811196
    1182         DEVHDA_UNLOCK(pThis);
     1197        DEVHDA_UNLOCK(pDevIns, pThis);
    11831198        return VINF_SUCCESS;
    11841199    }
     
    12221237    HDA_REG(pThis, CORBSIZE) = u32Value;
    12231238
    1224     DEVHDA_UNLOCK(pThis);
     1239    DEVHDA_UNLOCK(pDevIns, pThis);
    12251240    return VINF_SUCCESS;
    12261241#else
    1227     RT_NOREF(pThis, iReg, u32Value);
     1242    RT_NOREF(pDevIns, pThis, iReg, u32Value);
    12281243    return VINF_IOM_R3_MMIO_WRITE;
    12291244#endif
    12301245}
    12311246
    1232 static int hdaRegWriteCORBSTS(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
     1247static int hdaRegWriteCORBSTS(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
    12331248{
    12341249    RT_NOREF_PV(iReg);
    1235     DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE);
     1250    DEVHDA_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_MMIO_WRITE);
    12361251
    12371252    uint32_t v = HDA_REG(pThis, CORBSTS);
    12381253    HDA_REG(pThis, CORBSTS) &= ~(v & u32Value);
    12391254
    1240     DEVHDA_UNLOCK(pThis);
     1255    DEVHDA_UNLOCK(pDevIns, pThis);
    12411256    return VINF_SUCCESS;
    12421257}
    12431258
    1244 static int hdaRegWriteCORBWP(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
     1259static int hdaRegWriteCORBWP(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
    12451260{
    12461261#ifdef IN_RING3
    1247     DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE);
    1248 
    1249     int rc = hdaRegWriteU16(pThis, iReg, u32Value);
     1262    DEVHDA_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_MMIO_WRITE);
     1263
     1264    int rc = hdaRegWriteU16(pDevIns, pThis, iReg, u32Value);
    12501265    AssertRCSuccess(rc);
    12511266
    12521267    rc = hdaR3CORBCmdProcess(pThis);
    12531268
    1254     DEVHDA_UNLOCK(pThis);
     1269    DEVHDA_UNLOCK(pDevIns, pThis);
    12551270    return rc;
    12561271#else
    1257     RT_NOREF(pThis, iReg, u32Value);
     1272    RT_NOREF(pDevIns, pThis, iReg, u32Value);
    12581273    return VINF_IOM_R3_MMIO_WRITE;
    12591274#endif
    12601275}
    12611276
    1262 static int hdaRegWriteSDCBL(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
    1263 {
    1264     DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE);
    1265 
    1266     int rc = hdaRegWriteU32(pThis, iReg, u32Value);
     1277static int hdaRegWriteSDCBL(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
     1278{
     1279    DEVHDA_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_MMIO_WRITE);
     1280
     1281    int rc = hdaRegWriteU32(pDevIns, pThis, iReg, u32Value);
    12671282    AssertRCSuccess(rc);
    12681283
    1269     DEVHDA_UNLOCK(pThis);
     1284    DEVHDA_UNLOCK(pDevIns, pThis);
    12701285    return rc;
    12711286}
    12721287
    1273 static int hdaRegWriteSDCTL(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
     1288static int hdaRegWriteSDCTL(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
    12741289{
    12751290#ifdef IN_RING3
     
    12771292    const uint8_t uSD = HDA_SD_NUM_FROM_REG(pThis, CTL, iReg);
    12781293
    1279     DEVHDA_LOCK_BOTH_RETURN(pThis, uSD, VINF_IOM_R3_MMIO_WRITE);
     1294    DEVHDA_LOCK_BOTH_RETURN(pDevIns, pThis, uSD, VINF_IOM_R3_MMIO_WRITE);
    12801295
    12811296    /*
     
    13061321        LogFunc(("[SD%RU8] Warning: Invalid stream tag %RU8 specified!\n", uSD, uTag));
    13071322
    1308         int rc = hdaRegWriteU24(pThis, iReg, u32Value);
    1309         DEVHDA_UNLOCK_BOTH(pThis, uSD);
     1323        int rc = hdaRegWriteU24(pDevIns, pThis, iReg, u32Value);
     1324        DEVHDA_UNLOCK_BOTH(pDevIns, pThis, uSD);
    13101325        return rc;
    13111326    }
     
    14551470    }
    14561471
    1457     int rc2 = hdaRegWriteU24(pThis, iReg, u32Value);
     1472    int rc2 = hdaRegWriteU24(pDevIns, pThis, iReg, u32Value);
    14581473    AssertRC(rc2);
    14591474
    1460     DEVHDA_UNLOCK_BOTH(pThis, uSD);
     1475    DEVHDA_UNLOCK_BOTH(pDevIns, pThis, uSD);
    14611476    return VINF_SUCCESS; /* Always return success to the MMIO handler. */
    14621477#else  /* !IN_RING3 */
    1463     RT_NOREF_PV(pThis); RT_NOREF_PV(iReg); RT_NOREF_PV(u32Value);
     1478    RT_NOREF(pDevIns, pThis, iReg, u32Value);
    14641479    return VINF_IOM_R3_MMIO_WRITE;
    1465 #endif /* IN_RING3 */
    1466 }
    1467 
    1468 static int hdaRegWriteSDSTS(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
     1480#endif /* !IN_RING3 */
     1481}
     1482
     1483static int hdaRegWriteSDSTS(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
    14691484{
    14701485#ifdef IN_RING3
    14711486    const uint8_t uSD = HDA_SD_NUM_FROM_REG(pThis, STS, iReg);
    14721487
    1473     DEVHDA_LOCK_BOTH_RETURN(pThis, uSD, VINF_IOM_R3_MMIO_WRITE);
     1488    DEVHDA_LOCK_BOTH_RETURN(pDevIns, pThis, uSD, VINF_IOM_R3_MMIO_WRITE);
    14741489
    14751490    PHDASTREAM pStream = hdaGetStreamFromSD(pThis, uSD);
     
    14791494                         HDA_SD_NUM_FROM_REG(pThis, STS, iReg), u32Value));
    14801495
    1481         int rc = hdaRegWriteU16(pThis, iReg, u32Value);
    1482         DEVHDA_UNLOCK_BOTH(pThis, uSD);
     1496        int rc = hdaRegWriteU16(pDevIns, pThis, iReg, u32Value);
     1497        DEVHDA_UNLOCK_BOTH(pDevIns, pThis, uSD);
    14831498        return rc;
    14841499    }
     
    15821597    hdaR3StreamUnlock(pStream);
    15831598
    1584     DEVHDA_UNLOCK_BOTH(pThis, uSD);
     1599    DEVHDA_UNLOCK_BOTH(pDevIns, pThis, uSD);
    15851600    return VINF_SUCCESS;
    1586 #else /* IN_RING3 */
    1587     RT_NOREF(pThis, iReg, u32Value);
     1601#else  /* !IN_RING3 */
     1602    RT_NOREF(pDevIns, pThis, iReg, u32Value);
    15881603    return VINF_IOM_R3_MMIO_WRITE;
    15891604#endif /* !IN_RING3 */
    15901605}
    15911606
    1592 static int hdaRegWriteSDLVI(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
    1593 {
    1594     DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE);
     1607static int hdaRegWriteSDLVI(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
     1608{
     1609    DEVHDA_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_MMIO_WRITE);
    15951610
    15961611#ifdef HDA_USE_DMA_ACCESS_HANDLER
     
    16111626#endif
    16121627
    1613     int rc2 = hdaRegWriteU16(pThis, iReg, u32Value);
     1628    int rc2 = hdaRegWriteU16(pDevIns, pThis, iReg, u32Value);
    16141629    AssertRC(rc2);
    16151630
    1616     DEVHDA_UNLOCK(pThis);
     1631    DEVHDA_UNLOCK(pDevIns, pThis);
    16171632    return VINF_SUCCESS; /* Always return success to the MMIO handler. */
    16181633}
    16191634
    1620 static int hdaRegWriteSDFIFOW(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
    1621 {
    1622     DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE);
     1635static int hdaRegWriteSDFIFOW(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
     1636{
     1637    DEVHDA_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_MMIO_WRITE);
    16231638
    16241639    uint8_t uSD = HDA_SD_NUM_FROM_REG(pThis, FIFOW, iReg);
     
    16281643#ifndef IN_RING0
    16291644        LogRel(("HDA: Warning: Guest tried to write read-only FIFOW to output stream #%RU8, ignoring\n", uSD));
    1630         DEVHDA_UNLOCK(pThis);
     1645        DEVHDA_UNLOCK(pDevIns, pThis);
    16311646        return VINF_SUCCESS;
    16321647#else
    1633         DEVHDA_UNLOCK(pThis);
     1648        DEVHDA_UNLOCK(pDevIns, pThis);
    16341649        return VINF_IOM_R3_MMIO_WRITE;
    16351650#endif
     
    16411656        AssertMsgFailed(("[SD%RU8] Warning: Changing FIFOW on non-attached stream (0x%x)\n", uSD, u32Value));
    16421657
    1643         int rc = hdaRegWriteU16(pThis, iReg, u32Value);
    1644         DEVHDA_UNLOCK(pThis);
     1658        int rc = hdaRegWriteU16(pDevIns, pThis, iReg, u32Value);
     1659        DEVHDA_UNLOCK(pDevIns, pThis);
    16451660        return rc;
    16461661    }
     
    16671682        LogFunc(("[SD%RU8] Updating FIFOW to %RU32 bytes\n", uSD, pStream->u16FIFOW));
    16681683
    1669         int rc2 = hdaRegWriteU16(pThis, iReg, u32FIFOW);
     1684        int rc2 = hdaRegWriteU16(pDevIns, pThis, iReg, u32FIFOW);
    16701685        AssertRC(rc2);
    16711686    }
    16721687
    1673     DEVHDA_UNLOCK(pThis);
     1688    DEVHDA_UNLOCK(pDevIns, pThis);
    16741689    return VINF_SUCCESS; /* Always return success to the MMIO handler. */
    16751690}
     
    16781693 * @note This method could be called for changing value on Output Streams only (ICH6 datasheet 18.2.39).
    16791694 */
    1680 static int hdaRegWriteSDFIFOS(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
    1681 {
    1682     DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE);
     1695static int hdaRegWriteSDFIFOS(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
     1696{
     1697    DEVHDA_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_MMIO_WRITE);
    16831698
    16841699    uint8_t uSD = HDA_SD_NUM_FROM_REG(pThis, FIFOS, iReg);
     
    16881703        LogRel(("HDA: Warning: Guest tried to write read-only FIFOS to input stream #%RU8, ignoring\n", uSD));
    16891704
    1690         DEVHDA_UNLOCK(pThis);
     1705        DEVHDA_UNLOCK(pDevIns, pThis);
    16911706        return VINF_SUCCESS;
    16921707    }
     
    17121727    }
    17131728
    1714     int rc2 = hdaRegWriteU16(pThis, iReg, u32FIFOS);
     1729    int rc2 = hdaRegWriteU16(pDevIns, pThis, iReg, u32FIFOS);
    17151730    AssertRC(rc2);
    17161731
    1717     DEVHDA_UNLOCK(pThis);
     1732    DEVHDA_UNLOCK(pDevIns, pThis);
    17181733    return VINF_SUCCESS; /* Always return success to the MMIO handler. */
    17191734}
     
    19992014#endif /* IN_RING3 */
    20002015
    2001 static int hdaRegWriteSDFMT(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
    2002 {
    2003     DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE);
     2016static int hdaRegWriteSDFMT(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
     2017{
     2018    DEVHDA_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_MMIO_WRITE);
    20042019
    20052020    /* Write the wanted stream format into the register in any case.
     
    20102025     * When ignoring those (invalid) formats, this leads to MacOS thinking that the device is malfunctioning
    20112026     * and therefore disabling the device completely. */
    2012     int rc = hdaRegWriteU16(pThis, iReg, u32Value);
     2027    int rc = hdaRegWriteU16(pDevIns, pThis, iReg, u32Value);
    20132028    AssertRC(rc);
    20142029
    2015     DEVHDA_UNLOCK(pThis);
     2030    DEVHDA_UNLOCK(pDevIns, pThis);
    20162031    return VINF_SUCCESS; /* Always return success to the MMIO handler. */
    20172032}
    20182033
    20192034/* Note: Will be called for both, BDPL and BDPU, registers. */
    2020 DECLINLINE(int) hdaRegWriteSDBDPX(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value, uint8_t uSD)
     2035DECLINLINE(int) hdaRegWriteSDBDPX(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value, uint8_t uSD)
    20212036{
    20222037#ifdef IN_RING3
    2023     DEVHDA_LOCK(pThis);
     2038    DEVHDA_LOCK(pDevIns, pThis);
    20242039
    20252040# ifdef HDA_USE_DMA_ACCESS_HANDLER
     
    20402055# endif
    20412056
    2042     int rc2 = hdaRegWriteU32(pThis, iReg, u32Value);
     2057    int rc2 = hdaRegWriteU32(pDevIns, pThis, iReg, u32Value);
    20432058    AssertRC(rc2);
    20442059
    2045     DEVHDA_UNLOCK(pThis);
     2060    DEVHDA_UNLOCK(pDevIns, pThis);
    20462061    return VINF_SUCCESS; /* Always return success to the MMIO handler. */
    20472062#else  /* !IN_RING3 */
    2048     RT_NOREF_PV(pThis); RT_NOREF_PV(iReg); RT_NOREF_PV(u32Value); RT_NOREF_PV(uSD);
     2063    RT_NOREF(pDevIns, pThis, iReg, u32Value, uSD);
    20492064    return VINF_IOM_R3_MMIO_WRITE;
    2050 #endif /* IN_RING3 */
    2051 }
    2052 
    2053 static int hdaRegWriteSDBDPL(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
    2054 {
    2055     return hdaRegWriteSDBDPX(pThis, iReg, u32Value, HDA_SD_NUM_FROM_REG(pThis, BDPL, iReg));
    2056 }
    2057 
    2058 static int hdaRegWriteSDBDPU(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
    2059 {
    2060     return hdaRegWriteSDBDPX(pThis, iReg, u32Value, HDA_SD_NUM_FROM_REG(pThis, BDPU, iReg));
    2061 }
    2062 
    2063 static int hdaRegReadIRS(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value)
    2064 {
    2065     DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_READ);
     2065#endif /* !IN_RING3 */
     2066}
     2067
     2068static int hdaRegWriteSDBDPL(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
     2069{
     2070    return hdaRegWriteSDBDPX(pDevIns, pThis, iReg, u32Value, HDA_SD_NUM_FROM_REG(pThis, BDPL, iReg));
     2071}
     2072
     2073static int hdaRegWriteSDBDPU(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
     2074{
     2075    return hdaRegWriteSDBDPX(pDevIns, pThis, iReg, u32Value, HDA_SD_NUM_FROM_REG(pThis, BDPU, iReg));
     2076}
     2077
     2078static int hdaRegReadIRS(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value)
     2079{
     2080    DEVHDA_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_MMIO_READ);
    20662081
    20672082    /* regarding 3.4.3 we should mark IRS as busy in case CORB is active */
     
    20722087    }
    20732088
    2074     int rc = hdaRegReadU32(pThis, iReg, pu32Value);
    2075     DEVHDA_UNLOCK(pThis);
     2089    int rc = hdaRegReadU32(pDevIns, pThis, iReg, pu32Value);
     2090    DEVHDA_UNLOCK(pDevIns, pThis);
    20762091
    20772092    return rc;
    20782093}
    20792094
    2080 static int hdaRegWriteIRS(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
     2095static int hdaRegWriteIRS(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
    20812096{
    20822097    RT_NOREF_PV(iReg);
    2083     DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE);
     2098    DEVHDA_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_MMIO_WRITE);
    20842099
    20852100    /*
     
    20952110        if (HDA_REG(pThis, CORBWP) != HDA_REG(pThis, CORBRP))
    20962111        {
    2097             DEVHDA_UNLOCK(pThis);
     2112            DEVHDA_UNLOCK(pDevIns, pThis);
    20982113
    20992114            /*
     
    21172132        HDA_REG(pThis, IRS) &= ~HDA_IRS_ICB;    /* busy is clear */
    21182133
    2119         DEVHDA_UNLOCK(pThis);
     2134        DEVHDA_UNLOCK(pDevIns, pThis);
    21202135        return VINF_SUCCESS;
    21212136#else  /* !IN_RING3 */
    2122         DEVHDA_UNLOCK(pThis);
     2137        DEVHDA_UNLOCK(pDevIns, pThis);
    21232138        return VINF_IOM_R3_MMIO_WRITE;
    21242139#endif /* !IN_RING3 */
     
    21302145    HDA_REG(pThis, IRS) &= ~(u32Value & HDA_IRS_IRV);
    21312146
    2132     DEVHDA_UNLOCK(pThis);
     2147    DEVHDA_UNLOCK(pDevIns, pThis);
    21332148    return VINF_SUCCESS;
    21342149}
    21352150
    2136 static int hdaRegWriteRIRBWP(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
     2151static int hdaRegWriteRIRBWP(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
    21372152{
    21382153    RT_NOREF(iReg);
    2139     DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE);
     2154    DEVHDA_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_MMIO_WRITE);
    21402155
    21412156    if (HDA_REG(pThis, CORBCTL) & HDA_CORBCTL_DMA) /* Ignore request if CORB DMA engine is (still) running. */
     
    21432158        LogFunc(("CORB DMA (still) running, skipping\n"));
    21442159
    2145         DEVHDA_UNLOCK(pThis);
     2160        DEVHDA_UNLOCK(pDevIns, pThis);
    21462161        return VINF_SUCCESS;
    21472162    }
     
    21632178    /* The remaining bits are O, see 6.2.22. */
    21642179
    2165     DEVHDA_UNLOCK(pThis);
     2180    DEVHDA_UNLOCK(pDevIns, pThis);
    21662181    return VINF_SUCCESS;
    21672182}
    21682183
    2169 static int hdaRegWriteRINTCNT(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
    2170 {
    2171     DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE);
     2184static int hdaRegWriteRINTCNT(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
     2185{
     2186    DEVHDA_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_MMIO_WRITE);
    21722187
    21732188    if (HDA_REG(pThis, CORBCTL) & HDA_CORBCTL_DMA) /* Ignore request if CORB DMA engine is (still) running. */
     
    21752190        LogFunc(("CORB DMA is (still) running, skipping\n"));
    21762191
    2177         DEVHDA_UNLOCK(pThis);
     2192        DEVHDA_UNLOCK(pDevIns, pThis);
    21782193        return VINF_SUCCESS;
    21792194    }
    21802195
    2181     int rc = hdaRegWriteU16(pThis, iReg, u32Value);
     2196    int rc = hdaRegWriteU16(pDevIns, pThis, iReg, u32Value);
    21822197    AssertRC(rc);
    21832198
    21842199    LogFunc(("Response interrupt count is now %RU8\n", HDA_REG(pThis, RINTCNT) & 0xFF));
    21852200
    2186     DEVHDA_UNLOCK(pThis);
     2201    DEVHDA_UNLOCK(pDevIns, pThis);
    21872202    return rc;
    21882203}
    21892204
    2190 static int hdaRegWriteBase(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
     2205static int hdaRegWriteBase(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
    21912206{
    21922207    uint32_t iRegMem = g_aHdaRegMap[iReg].mem_idx;
    2193     DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE);
    2194 
    2195     int rc = hdaRegWriteU32(pThis, iReg, u32Value);
     2208    DEVHDA_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_MMIO_WRITE);
     2209
     2210    int rc = hdaRegWriteU32(pDevIns, pThis, iReg, u32Value);
    21962211    AssertRCSuccess(rc);
    21972212
     
    22352250             pThis->u64CORBBase, pThis->u64RIRBBase, pThis->u64DPBase));
    22362251
    2237     DEVHDA_UNLOCK(pThis);
     2252    DEVHDA_UNLOCK(pDevIns, pThis);
    22382253    return rc;
    22392254}
    22402255
    2241 static int hdaRegWriteRIRBSTS(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
     2256static int hdaRegWriteRIRBSTS(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
    22422257{
    22432258    RT_NOREF_PV(iReg);
    2244     DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE);
     2259    DEVHDA_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_MMIO_WRITE);
    22452260
    22462261    uint8_t v = HDA_REG(pThis, RIRBSTS);
     
    22532268#endif
    22542269
    2255     DEVHDA_UNLOCK(pThis);
     2270    DEVHDA_UNLOCK(pDevIns, pThis);
    22562271    return rc;
    22572272}
     
    28592874static DECLCALLBACK(void) hdaR3Timer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)
    28602875{
    2861     RT_NOREF(pDevIns, pTimer);
     2876    RT_NOREF(pTimer);
    28622877
    28632878    PHDASTREAM pStream = (PHDASTREAM)pvUser;
     
    28662881    PHDASTATE  pThis   = pStream->pHDAState;
    28672882
    2868     DEVHDA_LOCK_BOTH_RETURN_VOID(pStream->pHDAState, pStream->u8SD);
     2883    DEVHDA_LOCK_BOTH_RETURN_VOID(pDevIns, pStream->pHDAState, pStream->u8SD);
    28692884
    28702885    hdaR3StreamUpdate(pStream, true /* fInTimer */);
     
    28882903        Log3Func(("fSinksActive=%RTbool\n", fSinkActive));
    28892904
    2890     DEVHDA_UNLOCK_BOTH(pThis, pStream->u8SD);
     2905    DEVHDA_UNLOCK_BOTH(pDevIns, pThis, pStream->u8SD);
    28912906}
    28922907
     
    31633178    Assert(cb == 4); Assert((offReg & 3) == 0);
    31643179
    3165     DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_READ);
     3180    DEVHDA_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_MMIO_READ);
    31663181
    31673182    if (!(HDA_REG(pThis, GCTL) & HDA_GCTL_CRST) && idxRegDsc != HDA_REG_GCTL)
     
    31743189    {
    31753190        /* Leave lock before calling read function. */
    3176         DEVHDA_UNLOCK(pThis);
     3191        DEVHDA_UNLOCK(pDevIns, pThis);
    31773192
    31783193        /* ASSUMES gapless DWORD at end of map. */
     
    31823197             * Straight forward DWORD access.
    31833198             */
    3184             rc = g_aHdaRegMap[idxRegDsc].pfnRead(pThis, idxRegDsc, (uint32_t *)pv);
     3199            rc = g_aHdaRegMap[idxRegDsc].pfnRead(pDevIns, pThis, idxRegDsc, (uint32_t *)pv);
    31853200            Log3Func(("\tRead %s => %x (%Rrc)\n", g_aHdaRegMap[idxRegDsc].abbrev, *(uint32_t *)pv, rc));
    31863201        }
     
    31993214                uint32_t        u32Tmp       = 0;
    32003215
    3201                 rc = g_aHdaRegMap[idxRegDsc].pfnRead(pThis, idxRegDsc, &u32Tmp);
     3216                rc = g_aHdaRegMap[idxRegDsc].pfnRead(pDevIns, pThis, idxRegDsc, &u32Tmp);
    32023217                Log3Func(("\tRead %s[%db] => %x (%Rrc)*\n", g_aHdaRegMap[idxRegDsc].abbrev, cbReg, u32Tmp, rc));
    32033218                if (rc != VINF_SUCCESS)
     
    32223237    else
    32233238    {
    3224         DEVHDA_UNLOCK(pThis);
     3239        DEVHDA_UNLOCK(pDevIns, pThis);
    32253240
    32263241        rc = VINF_IOM_MMIO_UNUSED_FF;
     
    32433258
    32443259
    3245 DECLINLINE(int) hdaWriteReg(PHDASTATE pThis, int idxRegDsc, uint32_t u32Value, char const *pszLog)
    3246 {
    3247     DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE);
     3260DECLINLINE(int) hdaWriteReg(PPDMDEVINS pDevIns, PHDASTATE pThis, int idxRegDsc, uint32_t u32Value, char const *pszLog)
     3261{
     3262    DEVHDA_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_MMIO_WRITE);
    32483263
    32493264    if (!(HDA_REG(pThis, GCTL) & HDA_GCTL_CRST) && idxRegDsc != HDA_REG_GCTL)
     
    32533268                 g_aHdaRegMap[idxRegDsc].abbrev));
    32543269
    3255         DEVHDA_UNLOCK(pThis);
     3270        DEVHDA_UNLOCK(pDevIns, pThis);
    32563271        return VINF_SUCCESS;
    32573272    }
     
    32803295                     g_aHdaRegMap[idxRegDsc].abbrev));
    32813296
    3282             DEVHDA_UNLOCK(pThis);
     3297            DEVHDA_UNLOCK(pDevIns, pThis);
    32833298            return VINF_SUCCESS;
    32843299        }
     
    32953310     * do the two-three things a write handle needs to do than enter
    32963311     * and exit the lock all the time. */
    3297     DEVHDA_UNLOCK(pThis);
     3312    DEVHDA_UNLOCK(pDevIns, pThis);
    32983313
    32993314#ifdef LOG_ENABLED
     
    33013316    uint32_t const u32OldValue = pThis->au32Regs[idxRegMem];
    33023317#endif
    3303     int rc = g_aHdaRegMap[idxRegDsc].pfnWrite(pThis, idxRegDsc, u32Value);
     3318    int rc = g_aHdaRegMap[idxRegDsc].pfnWrite(pDevIns, pThis, idxRegDsc, u32Value);
    33043319    Log3Func(("Written value %#x to %s[%d byte]; %x => %x%s, rc=%d\n", u32Value, g_aHdaRegMap[idxRegDsc].abbrev,
    33053320              g_aHdaRegMap[idxRegDsc].size, u32OldValue, pThis->au32Regs[idxRegMem], pszLog, rc));
     
    33673382    if (idxRegDsc != -1 && g_aHdaRegMap[idxRegDsc].size == cb)
    33683383    {
    3369         rc = hdaWriteReg(pThis, idxRegDsc, u64Value, "");
     3384        rc = hdaWriteReg(pDevIns, pThis, idxRegDsc, u64Value, "");
    33703385        Log3Func(("\t%#x -> %#x\n", u32LogOldValue, idxRegMem != UINT32_MAX ? pThis->au32Regs[idxRegMem] : UINT32_MAX));
    33713386    }
     
    34113426                uint32_t uLogOldVal = pThis->au32Regs[idxRegMem];
    34123427# endif
    3413                 rc = hdaWriteReg(pThis, idxRegDsc, u64Value, "*");
     3428                rc = hdaWriteReg(pDevIns, pThis, idxRegDsc, u64Value, "*");
    34143429                Log3Func(("\t%#x -> %#x\n", uLogOldVal, pThis->au32Regs[idxRegMem]));
    34153430            }
     
    45724587    PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE);
    45734588
    4574     DEVHDA_LOCK_RETURN(pThis, VERR_IGNORED);
     4589    DEVHDA_LOCK_RETURN(pDevIns, pThis, VERR_IGNORED);
    45754590
    45764591    LogFunc(("uLUN=%u, fFlags=0x%x\n", uLUN, fFlags));
     
    45844599        LogFunc(("Failed with %Rrc\n", rc2));
    45854600
    4586     DEVHDA_UNLOCK(pThis);
     4601    DEVHDA_UNLOCK(pDevIns, pThis);
    45874602
    45884603    return VINF_SUCCESS;
     
    45964611    PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE);
    45974612
    4598     DEVHDA_LOCK(pThis);
     4613    DEVHDA_LOCK(pDevIns, pThis);
    45994614
    46004615    LogFunc(("uLUN=%u, fFlags=0x%x\n", uLUN, fFlags));
     
    46164631    }
    46174632
    4618     DEVHDA_UNLOCK(pThis);
     4633    DEVHDA_UNLOCK(pDevIns, pThis);
    46194634}
    46204635
     
    46284643    PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE);
    46294644
    4630     DEVHDA_LOCK_RETURN_VOID(pThis);
     4645    DEVHDA_LOCK_RETURN_VOID(pDevIns, pThis);
    46314646
    46324647    LogRel2(("HDA: Powering off ...\n"));
     
    46464661    }
    46474662
    4648     DEVHDA_UNLOCK(pThis);
     4663    DEVHDA_UNLOCK(pDevIns, pThis);
    46494664}
    46504665
     
    47284743    LogFlowFuncEnter();
    47294744
    4730     DEVHDA_LOCK_RETURN_VOID(pThis);
     4745    DEVHDA_LOCK_RETURN_VOID(pDevIns, pThis);
    47314746
    47324747     /*
     
    47434758    HDA_REG(pThis, GCTL)    = HDA_GCTL_CRST;
    47444759
    4745     DEVHDA_UNLOCK(pThis);
     4760    DEVHDA_UNLOCK(pDevIns, pThis);
    47464761}
    47474762
     
    47654780    PDMDEV_CHECK_VERSIONS_RETURN_QUIET(pDevIns); /* this shall come first */
    47664781    PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE);
    4767     DEVHDA_LOCK(pThis); /** @todo r=bird: this will fail on early constructor failure. */
     4782    DEVHDA_LOCK(pDevIns, pThis); /** @todo r=bird: this will fail on early constructor failure. */
    47684783
    47694784    PHDADRIVER pDrv;
     
    47934808        hdaR3StreamDestroy(&pThis->aStreams[i]);
    47944809
    4795     DEVHDA_UNLOCK(pThis);
     4810    DEVHDA_UNLOCK(pDevIns, pThis);
    47964811    return VINF_SUCCESS;
    47974812}
  • trunk/src/VBox/Devices/Audio/DevHDACommon.h

    r76565 r80691  
    4141    uint32_t    fFlags;
    4242    /** Read callback. */
    43     int       (*pfnRead)(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value);
     43    int       (*pfnRead)(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value);
    4444    /** Write callback. */
    45     int       (*pfnWrite)(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
     45    int       (*pfnWrite)(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
    4646    /** Index into the register storage array. */
    4747    uint32_t    mem_idx;
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