Changeset 80691 in vbox for trunk/src/VBox/Devices/Audio
- Timestamp:
- Sep 10, 2019 9:58:21 AM (5 years ago)
- Location:
- trunk/src/VBox/Devices/Audio
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevHDA.cpp
r80682 r80691 110 110 * Acquires the HDA lock. 111 111 */ 112 #define DEVHDA_LOCK(a_p This) \112 #define DEVHDA_LOCK(a_pDevIns, a_pThis) \ 113 113 do { \ 114 int rcLock = PDM CritSectEnter(&(a_pThis)->CritSect, VERR_IGNORED); \114 int rcLock = PDMDevHlpCritSectEnter((a_pDevIns), &(a_pThis)->CritSect, VERR_IGNORED); \ 115 115 AssertRC(rcLock); \ 116 116 } while (0) … … 119 119 * Acquires the HDA lock or returns. 120 120 */ 121 # define DEVHDA_LOCK_RETURN(a_pThis, a_rcBusy) \121 #define DEVHDA_LOCK_RETURN(a_pDevIns, a_pThis, a_rcBusy) \ 122 122 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 \ 125 127 { \ 126 128 AssertRC(rcLock); \ … … 132 134 * Acquires the HDA lock or returns. 133 135 */ 134 # define DEVHDA_LOCK_RETURN_VOID(a_p This) \136 # define DEVHDA_LOCK_RETURN_VOID(a_pDevIns, a_pThis) \ 135 137 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 \ 138 142 { \ 139 143 AssertRC(rcLock); \ … … 145 149 * Releases the HDA lock. 146 150 */ 147 #define DEVHDA_UNLOCK(a_p This) \148 do { PDM CritSectLeave(&(a_pThis)->CritSect); } while (0)151 #define DEVHDA_UNLOCK(a_pDevIns, a_pThis) \ 152 do { PDMDevHlpCritSectLeave((a_pDevIns), &(a_pThis)->CritSect); } while (0) 149 153 150 154 /** 151 155 * Acquires the TM lock and HDA lock, returns on failure. 152 156 */ 153 #define DEVHDA_LOCK_BOTH_RETURN_VOID(a_p This, a_SD) \157 #define DEVHDA_LOCK_BOTH_RETURN_VOID(a_pDevIns, a_pThis, a_SD) \ 154 158 do { \ 155 159 int rcLock = TMTimerLock((a_pThis)->pTimer[a_SD], VERR_IGNORED); \ 156 if (rcLock != VINF_SUCCESS) \ 160 if (rcLock == VINF_SUCCESS) \ 161 { /* likely */ } \ 162 else \ 157 163 { \ 158 164 AssertRC(rcLock); \ 159 165 return; \ 160 166 } \ 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 \ 163 171 { \ 164 172 AssertRC(rcLock); \ … … 171 179 * Acquires the TM lock and HDA lock, returns on failure. 172 180 */ 173 #define DEVHDA_LOCK_BOTH_RETURN(a_p This, a_SD, a_rcBusy) \181 #define DEVHDA_LOCK_BOTH_RETURN(a_pDevIns, a_pThis, a_SD, a_rcBusy) \ 174 182 do { \ 175 183 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); \ 177 189 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 \ 180 195 { \ 181 196 AssertRC(rcLock); \ … … 188 203 * Releases the HDA lock and TM lock. 189 204 */ 190 #define DEVHDA_UNLOCK_BOTH(a_p This, a_SD) \205 #define DEVHDA_UNLOCK_BOTH(a_pDevIns, a_pThis, a_SD) \ 191 206 do { \ 192 PDM CritSectLeave(&(a_pThis)->CritSect); \207 PDMDevHlpCritSectLeave((a_pDevIns), &(a_pThis)->CritSect); \ 193 208 TMTimerUnlock((a_pThis)->pTimer[a_SD]); \ 194 209 } while (0) … … 290 305 * @{ 291 306 */ 292 static int hdaRegReadUnimpl(P HDASTATE pThis, uint32_t iReg, uint32_t *pu32Value);293 static int hdaRegWriteUnimpl(P HDASTATE pThis, uint32_t iReg, uint32_t pu32Value);307 static int hdaRegReadUnimpl(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value); 308 static int hdaRegWriteUnimpl(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); 294 309 /** @} */ 295 310 … … 297 312 * @{ 298 313 */ 299 static int hdaRegWriteGCTL(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value);300 static int hdaRegReadLPIB(P HDASTATE pThis, uint32_t iReg, uint32_t *pu32Value);301 static int hdaRegReadWALCLK(P HDASTATE pThis, uint32_t iReg, uint32_t *pu32Value);302 static int hdaRegWriteCORBWP(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value);303 static int hdaRegWriteCORBRP(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value);304 static int hdaRegWriteCORBCTL(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value);305 static int hdaRegWriteCORBSIZE(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value);306 static int hdaRegWriteCORBSTS(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value);307 static int hdaRegWriteRINTCNT(P HDASTATE pThis, uint32_t iReg, uint32_t pu32Value);308 static int hdaRegWriteRIRBWP(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value);309 static int hdaRegWriteRIRBSTS(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value);310 static int hdaRegWriteSTATESTS(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value);311 static int hdaRegWriteIRS(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value);312 static int hdaRegReadIRS(P HDASTATE pThis, uint32_t iReg, uint32_t *pu32Value);313 static int hdaRegWriteBase(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value);314 static int hdaRegWriteGCTL(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); 315 static int hdaRegReadLPIB(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value); 316 static int hdaRegReadWALCLK(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value); 317 static int hdaRegWriteCORBWP(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); 318 static int hdaRegWriteCORBRP(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); 319 static int hdaRegWriteCORBCTL(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); 320 static int hdaRegWriteCORBSIZE(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); 321 static int hdaRegWriteCORBSTS(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); 322 static int hdaRegWriteRINTCNT(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); 323 static int hdaRegWriteRIRBWP(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); 324 static int hdaRegWriteRIRBSTS(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); 325 static int hdaRegWriteSTATESTS(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); 326 static int hdaRegWriteIRS(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); 327 static int hdaRegReadIRS(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value); 328 static int hdaRegWriteBase(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); 314 329 /** @} */ 315 330 … … 317 332 * @{ 318 333 */ 319 static int hdaRegWriteSDCBL(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value);320 static int hdaRegWriteSDCTL(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value);321 static int hdaRegWriteSDSTS(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value);322 static int hdaRegWriteSDLVI(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value);323 static int hdaRegWriteSDFIFOW(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value);324 static int hdaRegWriteSDFIFOS(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value);325 static int hdaRegWriteSDFMT(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value);326 static int hdaRegWriteSDBDPL(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value);327 static int hdaRegWriteSDBDPU(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value);334 static int hdaRegWriteSDCBL(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); 335 static int hdaRegWriteSDCTL(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); 336 static int hdaRegWriteSDSTS(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); 337 static int hdaRegWriteSDLVI(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); 338 static int hdaRegWriteSDFIFOW(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); 339 static int hdaRegWriteSDFIFOS(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); 340 static int hdaRegWriteSDFMT(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); 341 static int hdaRegWriteSDBDPL(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); 342 static int hdaRegWriteSDBDPU(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); 328 343 /** @} */ 329 344 … … 331 346 * @{ 332 347 */ 333 static int hdaRegReadU32(P HDASTATE pThis, uint32_t iReg, uint32_t *pu32Value);334 static int hdaRegWriteU32(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value);335 static int hdaRegReadU24(P HDASTATE pThis, uint32_t iReg, uint32_t *pu32Value);348 static int hdaRegReadU32(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value); 349 static int hdaRegWriteU32(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); 350 static int hdaRegReadU24(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value); 336 351 #ifdef IN_RING3 337 static int hdaRegWriteU24(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value);352 static int hdaRegWriteU24(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); 338 353 #endif 339 static int hdaRegReadU16(P HDASTATE pThis, uint32_t iReg, uint32_t *pu32Value);340 static int hdaRegWriteU16(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value);341 static int hdaRegReadU8(P HDASTATE pThis, uint32_t iReg, uint32_t *pu32Value);342 static int hdaRegWriteU8(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value);354 static int hdaRegReadU16(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value); 355 static int hdaRegWriteU16(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); 356 static int hdaRegReadU8(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value); 357 static int hdaRegWriteU8(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); 343 358 /** @} */ 344 359 … … 903 918 /* Register access handlers. */ 904 919 905 static int hdaRegReadUnimpl(P HDASTATE pThis, uint32_t iReg, uint32_t *pu32Value)906 { 907 RT_NOREF _PV(pThis); RT_NOREF_PV(iReg);920 static int hdaRegReadUnimpl(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value) 921 { 922 RT_NOREF(pDevIns, pThis, iReg); 908 923 *pu32Value = 0; 909 924 return VINF_SUCCESS; 910 925 } 911 926 912 static int hdaRegWriteUnimpl(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value)913 { 914 RT_NOREF _PV(pThis); RT_NOREF_PV(iReg); RT_NOREF_PV(u32Value);927 static int hdaRegWriteUnimpl(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) 928 { 929 RT_NOREF(pDevIns, pThis, iReg, u32Value); 915 930 return VINF_SUCCESS; 916 931 } 917 932 918 933 /* U8 */ 919 static int hdaRegReadU8(P HDASTATE pThis, uint32_t iReg, uint32_t *pu32Value)934 static int hdaRegReadU8(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value) 920 935 { 921 936 Assert(((pThis->au32Regs[g_aHdaRegMap[iReg].mem_idx] & g_aHdaRegMap[iReg].readable) & 0xffffff00) == 0); 922 return hdaRegReadU32(p This, iReg, pu32Value);923 } 924 925 static int hdaRegWriteU8(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value)937 return hdaRegReadU32(pDevIns, pThis, iReg, pu32Value); 938 } 939 940 static int hdaRegWriteU8(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) 926 941 { 927 942 Assert((u32Value & 0xffffff00) == 0); 928 return hdaRegWriteU32(p This, iReg, u32Value);943 return hdaRegWriteU32(pDevIns, pThis, iReg, u32Value); 929 944 } 930 945 931 946 /* U16 */ 932 static int hdaRegReadU16(P HDASTATE pThis, uint32_t iReg, uint32_t *pu32Value)947 static int hdaRegReadU16(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value) 933 948 { 934 949 Assert(((pThis->au32Regs[g_aHdaRegMap[iReg].mem_idx] & g_aHdaRegMap[iReg].readable) & 0xffff0000) == 0); 935 return hdaRegReadU32(p This, iReg, pu32Value);936 } 937 938 static int hdaRegWriteU16(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value)950 return hdaRegReadU32(pDevIns, pThis, iReg, pu32Value); 951 } 952 953 static int hdaRegWriteU16(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) 939 954 { 940 955 Assert((u32Value & 0xffff0000) == 0); 941 return hdaRegWriteU32(p This, iReg, u32Value);956 return hdaRegWriteU32(pDevIns, pThis, iReg, u32Value); 942 957 } 943 958 944 959 /* U24 */ 945 static int hdaRegReadU24(P HDASTATE pThis, uint32_t iReg, uint32_t *pu32Value)960 static int hdaRegReadU24(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value) 946 961 { 947 962 Assert(((pThis->au32Regs[g_aHdaRegMap[iReg].mem_idx] & g_aHdaRegMap[iReg].readable) & 0xff000000) == 0); 948 return hdaRegReadU32(p This, iReg, pu32Value);963 return hdaRegReadU32(pDevIns, pThis, iReg, pu32Value); 949 964 } 950 965 951 966 #ifdef IN_RING3 952 static int hdaRegWriteU24(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value)967 static int hdaRegWriteU24(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) 953 968 { 954 969 Assert((u32Value & 0xff000000) == 0); 955 return hdaRegWriteU32(p This, iReg, u32Value);970 return hdaRegWriteU32(pDevIns, pThis, iReg, u32Value); 956 971 } 957 972 #endif 958 973 959 974 /* U32 */ 960 static int hdaRegReadU32(P HDASTATE pThis, uint32_t iReg, uint32_t *pu32Value)975 static int hdaRegReadU32(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value) 961 976 { 962 977 uint32_t iRegMem = g_aHdaRegMap[iReg].mem_idx; 963 978 964 DEVHDA_LOCK_RETURN(p This, VINF_IOM_R3_MMIO_READ);979 DEVHDA_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_MMIO_READ); 965 980 966 981 *pu32Value = pThis->au32Regs[iRegMem] & g_aHdaRegMap[iReg].readable; 967 982 968 DEVHDA_UNLOCK(p This);983 DEVHDA_UNLOCK(pDevIns, pThis); 969 984 return VINF_SUCCESS; 970 985 } 971 986 972 static int hdaRegWriteU32(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value)987 static int hdaRegWriteU32(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) 973 988 { 974 989 uint32_t iRegMem = g_aHdaRegMap[iReg].mem_idx; 975 990 976 DEVHDA_LOCK_RETURN(p This, VINF_IOM_R3_MMIO_WRITE);991 DEVHDA_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_MMIO_WRITE); 977 992 978 993 pThis->au32Regs[iRegMem] = (u32Value & g_aHdaRegMap[iReg].writable) 979 994 | (pThis->au32Regs[iRegMem] & ~g_aHdaRegMap[iReg].writable); 980 DEVHDA_UNLOCK(p This);995 DEVHDA_UNLOCK(pDevIns, pThis); 981 996 return VINF_SUCCESS; 982 997 } 983 998 984 static int hdaRegWriteGCTL(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value)999 static int hdaRegWriteGCTL(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) 985 1000 { 986 1001 RT_NOREF_PV(iReg); 987 1002 #ifdef IN_RING3 988 DEVHDA_LOCK(p This);1003 DEVHDA_LOCK(pDevIns, pThis); 989 1004 #else 990 1005 if (!(u32Value & HDA_GCTL_CRST)) 991 1006 return VINF_IOM_R3_MMIO_WRITE; 992 DEVHDA_LOCK_RETURN(p This, VINF_IOM_R3_MMIO_WRITE);1007 DEVHDA_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_MMIO_WRITE); 993 1008 #endif 994 1009 … … 1012 1027 hdaR3GCTLReset(pThis); 1013 1028 #else 1014 AssertFailedReturnStmt(DEVHDA_UNLOCK(p This), VINF_IOM_R3_MMIO_WRITE);1029 AssertFailedReturnStmt(DEVHDA_UNLOCK(pDevIns, pThis), VINF_IOM_R3_MMIO_WRITE); 1015 1030 #endif 1016 1031 } … … 1023 1038 } 1024 1039 1025 DEVHDA_UNLOCK(p This);1040 DEVHDA_UNLOCK(pDevIns, pThis); 1026 1041 return VINF_SUCCESS; 1027 1042 } 1028 1043 1029 static int hdaRegWriteSTATESTS(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value)1030 { 1031 DEVHDA_LOCK_RETURN(p This, VINF_IOM_R3_MMIO_WRITE);1044 static int hdaRegWriteSTATESTS(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) 1045 { 1046 DEVHDA_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_MMIO_WRITE); 1032 1047 1033 1048 uint32_t v = HDA_REG_IND(pThis, iReg); … … 1036 1051 HDA_REG(pThis, STATESTS) &= ~(v & nv); /* Write of 1 clears corresponding bit. */ 1037 1052 1038 DEVHDA_UNLOCK(p This);1053 DEVHDA_UNLOCK(pDevIns, pThis); 1039 1054 return VINF_SUCCESS; 1040 1055 } 1041 1056 1042 static int hdaRegReadLPIB(P HDASTATE pThis, uint32_t iReg, uint32_t *pu32Value)1043 { 1044 DEVHDA_LOCK_RETURN(p This, VINF_IOM_R3_MMIO_READ);1057 static int hdaRegReadLPIB(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value) 1058 { 1059 DEVHDA_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_MMIO_READ); 1045 1060 1046 1061 const uint8_t uSD = HDA_SD_NUM_FROM_REG(pThis, LPIB, iReg); … … 1053 1068 *pu32Value = u32LPIB; 1054 1069 1055 DEVHDA_UNLOCK(p This);1070 DEVHDA_UNLOCK(pDevIns, pThis); 1056 1071 return VINF_SUCCESS; 1057 1072 } … … 1098 1113 #endif /* IN_RING3 */ 1099 1114 1100 static int hdaRegReadWALCLK(P HDASTATE pThis, uint32_t iReg, uint32_t *pu32Value)1115 static int hdaRegReadWALCLK(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value) 1101 1116 { 1102 1117 #ifdef IN_RING3 1103 1118 RT_NOREF(iReg); 1104 1119 1105 DEVHDA_LOCK(p This);1120 DEVHDA_LOCK(pDevIns, pThis); 1106 1121 1107 1122 *pu32Value = RT_LO_U32(ASMAtomicReadU64(&pThis->u64WalClk)); … … 1109 1124 Log3Func(("%RU32 (max @ %RU64)\n",*pu32Value, hdaR3WalClkGetMax(pThis))); 1110 1125 1111 DEVHDA_UNLOCK(p This);1126 DEVHDA_UNLOCK(pDevIns, pThis); 1112 1127 return VINF_SUCCESS; 1113 1128 #else 1114 RT_NOREF(p This, iReg, pu32Value);1129 RT_NOREF(pDevIns, pThis, iReg, pu32Value); 1115 1130 return VINF_IOM_R3_MMIO_READ; 1116 1131 #endif 1117 1132 } 1118 1133 1119 static int hdaRegWriteCORBRP(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value)1134 static int hdaRegWriteCORBRP(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) 1120 1135 { 1121 1136 RT_NOREF(iReg); 1122 DEVHDA_LOCK_RETURN(p This, VINF_IOM_R3_MMIO_WRITE);1137 DEVHDA_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_MMIO_WRITE); 1123 1138 1124 1139 if (u32Value & HDA_CORBRP_RST) … … 1131 1146 RT_BZERO((void *)pThis->pu32CorbBuf, pThis->cbCorbBuf); 1132 1147 #else 1133 DEVHDA_UNLOCK(p This);1148 DEVHDA_UNLOCK(pDevIns, pThis); 1134 1149 return VINF_IOM_R3_MMIO_WRITE; 1135 1150 #endif … … 1143 1158 HDA_REG(pThis, CORBRP) &= ~HDA_CORBRP_RST; /* Only CORBRP_RST bit is writable. */ 1144 1159 1145 DEVHDA_UNLOCK(p This);1160 DEVHDA_UNLOCK(pDevIns, pThis); 1146 1161 return VINF_SUCCESS; 1147 1162 } 1148 1163 1149 static int hdaRegWriteCORBCTL(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value)1164 static int hdaRegWriteCORBCTL(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) 1150 1165 { 1151 1166 #ifdef IN_RING3 1152 DEVHDA_LOCK_RETURN(p This, VINF_IOM_R3_MMIO_WRITE);1153 1154 int rc = hdaRegWriteU8(p This, iReg, u32Value);1167 DEVHDA_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_MMIO_WRITE); 1168 1169 int rc = hdaRegWriteU8(pDevIns, pThis, iReg, u32Value); 1155 1170 AssertRC(rc); 1156 1171 … … 1162 1177 LogFunc(("CORB DMA not running, skipping\n")); 1163 1178 1164 DEVHDA_UNLOCK(p This);1179 DEVHDA_UNLOCK(pDevIns, pThis); 1165 1180 return rc; 1166 1181 #else 1167 RT_NOREF(p This, iReg, u32Value);1182 RT_NOREF(pDevIns, pThis, iReg, u32Value); 1168 1183 return VINF_IOM_R3_MMIO_WRITE; 1169 1184 #endif 1170 1185 } 1171 1186 1172 static int hdaRegWriteCORBSIZE(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value)1187 static int hdaRegWriteCORBSIZE(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) 1173 1188 { 1174 1189 #ifdef IN_RING3 1175 1190 RT_NOREF(iReg); 1176 DEVHDA_LOCK_RETURN(p This, VINF_IOM_R3_MMIO_WRITE);1191 DEVHDA_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_MMIO_WRITE); 1177 1192 1178 1193 if (HDA_REG(pThis, CORBCTL) & HDA_CORBCTL_DMA) /* Ignore request if CORB DMA engine is (still) running. */ … … 1180 1195 LogFunc(("CORB DMA is (still) running, skipping\n")); 1181 1196 1182 DEVHDA_UNLOCK(p This);1197 DEVHDA_UNLOCK(pDevIns, pThis); 1183 1198 return VINF_SUCCESS; 1184 1199 } … … 1222 1237 HDA_REG(pThis, CORBSIZE) = u32Value; 1223 1238 1224 DEVHDA_UNLOCK(p This);1239 DEVHDA_UNLOCK(pDevIns, pThis); 1225 1240 return VINF_SUCCESS; 1226 1241 #else 1227 RT_NOREF(p This, iReg, u32Value);1242 RT_NOREF(pDevIns, pThis, iReg, u32Value); 1228 1243 return VINF_IOM_R3_MMIO_WRITE; 1229 1244 #endif 1230 1245 } 1231 1246 1232 static int hdaRegWriteCORBSTS(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value)1247 static int hdaRegWriteCORBSTS(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) 1233 1248 { 1234 1249 RT_NOREF_PV(iReg); 1235 DEVHDA_LOCK_RETURN(p This, VINF_IOM_R3_MMIO_WRITE);1250 DEVHDA_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_MMIO_WRITE); 1236 1251 1237 1252 uint32_t v = HDA_REG(pThis, CORBSTS); 1238 1253 HDA_REG(pThis, CORBSTS) &= ~(v & u32Value); 1239 1254 1240 DEVHDA_UNLOCK(p This);1255 DEVHDA_UNLOCK(pDevIns, pThis); 1241 1256 return VINF_SUCCESS; 1242 1257 } 1243 1258 1244 static int hdaRegWriteCORBWP(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value)1259 static int hdaRegWriteCORBWP(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) 1245 1260 { 1246 1261 #ifdef IN_RING3 1247 DEVHDA_LOCK_RETURN(p This, VINF_IOM_R3_MMIO_WRITE);1248 1249 int rc = hdaRegWriteU16(p This, iReg, u32Value);1262 DEVHDA_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_MMIO_WRITE); 1263 1264 int rc = hdaRegWriteU16(pDevIns, pThis, iReg, u32Value); 1250 1265 AssertRCSuccess(rc); 1251 1266 1252 1267 rc = hdaR3CORBCmdProcess(pThis); 1253 1268 1254 DEVHDA_UNLOCK(p This);1269 DEVHDA_UNLOCK(pDevIns, pThis); 1255 1270 return rc; 1256 1271 #else 1257 RT_NOREF(p This, iReg, u32Value);1272 RT_NOREF(pDevIns, pThis, iReg, u32Value); 1258 1273 return VINF_IOM_R3_MMIO_WRITE; 1259 1274 #endif 1260 1275 } 1261 1276 1262 static int hdaRegWriteSDCBL(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value)1263 { 1264 DEVHDA_LOCK_RETURN(p This, VINF_IOM_R3_MMIO_WRITE);1265 1266 int rc = hdaRegWriteU32(p This, iReg, u32Value);1277 static 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); 1267 1282 AssertRCSuccess(rc); 1268 1283 1269 DEVHDA_UNLOCK(p This);1284 DEVHDA_UNLOCK(pDevIns, pThis); 1270 1285 return rc; 1271 1286 } 1272 1287 1273 static int hdaRegWriteSDCTL(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value)1288 static int hdaRegWriteSDCTL(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) 1274 1289 { 1275 1290 #ifdef IN_RING3 … … 1277 1292 const uint8_t uSD = HDA_SD_NUM_FROM_REG(pThis, CTL, iReg); 1278 1293 1279 DEVHDA_LOCK_BOTH_RETURN(p This, uSD, VINF_IOM_R3_MMIO_WRITE);1294 DEVHDA_LOCK_BOTH_RETURN(pDevIns, pThis, uSD, VINF_IOM_R3_MMIO_WRITE); 1280 1295 1281 1296 /* … … 1306 1321 LogFunc(("[SD%RU8] Warning: Invalid stream tag %RU8 specified!\n", uSD, uTag)); 1307 1322 1308 int rc = hdaRegWriteU24(p This, iReg, u32Value);1309 DEVHDA_UNLOCK_BOTH(p This, uSD);1323 int rc = hdaRegWriteU24(pDevIns, pThis, iReg, u32Value); 1324 DEVHDA_UNLOCK_BOTH(pDevIns, pThis, uSD); 1310 1325 return rc; 1311 1326 } … … 1455 1470 } 1456 1471 1457 int rc2 = hdaRegWriteU24(p This, iReg, u32Value);1472 int rc2 = hdaRegWriteU24(pDevIns, pThis, iReg, u32Value); 1458 1473 AssertRC(rc2); 1459 1474 1460 DEVHDA_UNLOCK_BOTH(p This, uSD);1475 DEVHDA_UNLOCK_BOTH(pDevIns, pThis, uSD); 1461 1476 return VINF_SUCCESS; /* Always return success to the MMIO handler. */ 1462 1477 #else /* !IN_RING3 */ 1463 RT_NOREF _PV(pThis); RT_NOREF_PV(iReg); RT_NOREF_PV(u32Value);1478 RT_NOREF(pDevIns, pThis, iReg, u32Value); 1464 1479 return VINF_IOM_R3_MMIO_WRITE; 1465 #endif /* IN_RING3 */1466 } 1467 1468 static int hdaRegWriteSDSTS(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value)1480 #endif /* !IN_RING3 */ 1481 } 1482 1483 static int hdaRegWriteSDSTS(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) 1469 1484 { 1470 1485 #ifdef IN_RING3 1471 1486 const uint8_t uSD = HDA_SD_NUM_FROM_REG(pThis, STS, iReg); 1472 1487 1473 DEVHDA_LOCK_BOTH_RETURN(p This, uSD, VINF_IOM_R3_MMIO_WRITE);1488 DEVHDA_LOCK_BOTH_RETURN(pDevIns, pThis, uSD, VINF_IOM_R3_MMIO_WRITE); 1474 1489 1475 1490 PHDASTREAM pStream = hdaGetStreamFromSD(pThis, uSD); … … 1479 1494 HDA_SD_NUM_FROM_REG(pThis, STS, iReg), u32Value)); 1480 1495 1481 int rc = hdaRegWriteU16(p This, iReg, u32Value);1482 DEVHDA_UNLOCK_BOTH(p This, uSD);1496 int rc = hdaRegWriteU16(pDevIns, pThis, iReg, u32Value); 1497 DEVHDA_UNLOCK_BOTH(pDevIns, pThis, uSD); 1483 1498 return rc; 1484 1499 } … … 1582 1597 hdaR3StreamUnlock(pStream); 1583 1598 1584 DEVHDA_UNLOCK_BOTH(p This, uSD);1599 DEVHDA_UNLOCK_BOTH(pDevIns, pThis, uSD); 1585 1600 return VINF_SUCCESS; 1586 #else /*IN_RING3 */1587 RT_NOREF(p This, iReg, u32Value);1601 #else /* !IN_RING3 */ 1602 RT_NOREF(pDevIns, pThis, iReg, u32Value); 1588 1603 return VINF_IOM_R3_MMIO_WRITE; 1589 1604 #endif /* !IN_RING3 */ 1590 1605 } 1591 1606 1592 static int hdaRegWriteSDLVI(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value)1593 { 1594 DEVHDA_LOCK_RETURN(p This, VINF_IOM_R3_MMIO_WRITE);1607 static int hdaRegWriteSDLVI(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) 1608 { 1609 DEVHDA_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_MMIO_WRITE); 1595 1610 1596 1611 #ifdef HDA_USE_DMA_ACCESS_HANDLER … … 1611 1626 #endif 1612 1627 1613 int rc2 = hdaRegWriteU16(p This, iReg, u32Value);1628 int rc2 = hdaRegWriteU16(pDevIns, pThis, iReg, u32Value); 1614 1629 AssertRC(rc2); 1615 1630 1616 DEVHDA_UNLOCK(p This);1631 DEVHDA_UNLOCK(pDevIns, pThis); 1617 1632 return VINF_SUCCESS; /* Always return success to the MMIO handler. */ 1618 1633 } 1619 1634 1620 static int hdaRegWriteSDFIFOW(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value)1621 { 1622 DEVHDA_LOCK_RETURN(p This, VINF_IOM_R3_MMIO_WRITE);1635 static int hdaRegWriteSDFIFOW(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) 1636 { 1637 DEVHDA_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_MMIO_WRITE); 1623 1638 1624 1639 uint8_t uSD = HDA_SD_NUM_FROM_REG(pThis, FIFOW, iReg); … … 1628 1643 #ifndef IN_RING0 1629 1644 LogRel(("HDA: Warning: Guest tried to write read-only FIFOW to output stream #%RU8, ignoring\n", uSD)); 1630 DEVHDA_UNLOCK(p This);1645 DEVHDA_UNLOCK(pDevIns, pThis); 1631 1646 return VINF_SUCCESS; 1632 1647 #else 1633 DEVHDA_UNLOCK(p This);1648 DEVHDA_UNLOCK(pDevIns, pThis); 1634 1649 return VINF_IOM_R3_MMIO_WRITE; 1635 1650 #endif … … 1641 1656 AssertMsgFailed(("[SD%RU8] Warning: Changing FIFOW on non-attached stream (0x%x)\n", uSD, u32Value)); 1642 1657 1643 int rc = hdaRegWriteU16(p This, iReg, u32Value);1644 DEVHDA_UNLOCK(p This);1658 int rc = hdaRegWriteU16(pDevIns, pThis, iReg, u32Value); 1659 DEVHDA_UNLOCK(pDevIns, pThis); 1645 1660 return rc; 1646 1661 } … … 1667 1682 LogFunc(("[SD%RU8] Updating FIFOW to %RU32 bytes\n", uSD, pStream->u16FIFOW)); 1668 1683 1669 int rc2 = hdaRegWriteU16(p This, iReg, u32FIFOW);1684 int rc2 = hdaRegWriteU16(pDevIns, pThis, iReg, u32FIFOW); 1670 1685 AssertRC(rc2); 1671 1686 } 1672 1687 1673 DEVHDA_UNLOCK(p This);1688 DEVHDA_UNLOCK(pDevIns, pThis); 1674 1689 return VINF_SUCCESS; /* Always return success to the MMIO handler. */ 1675 1690 } … … 1678 1693 * @note This method could be called for changing value on Output Streams only (ICH6 datasheet 18.2.39). 1679 1694 */ 1680 static int hdaRegWriteSDFIFOS(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value)1681 { 1682 DEVHDA_LOCK_RETURN(p This, VINF_IOM_R3_MMIO_WRITE);1695 static int hdaRegWriteSDFIFOS(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) 1696 { 1697 DEVHDA_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_MMIO_WRITE); 1683 1698 1684 1699 uint8_t uSD = HDA_SD_NUM_FROM_REG(pThis, FIFOS, iReg); … … 1688 1703 LogRel(("HDA: Warning: Guest tried to write read-only FIFOS to input stream #%RU8, ignoring\n", uSD)); 1689 1704 1690 DEVHDA_UNLOCK(p This);1705 DEVHDA_UNLOCK(pDevIns, pThis); 1691 1706 return VINF_SUCCESS; 1692 1707 } … … 1712 1727 } 1713 1728 1714 int rc2 = hdaRegWriteU16(p This, iReg, u32FIFOS);1729 int rc2 = hdaRegWriteU16(pDevIns, pThis, iReg, u32FIFOS); 1715 1730 AssertRC(rc2); 1716 1731 1717 DEVHDA_UNLOCK(p This);1732 DEVHDA_UNLOCK(pDevIns, pThis); 1718 1733 return VINF_SUCCESS; /* Always return success to the MMIO handler. */ 1719 1734 } … … 1999 2014 #endif /* IN_RING3 */ 2000 2015 2001 static int hdaRegWriteSDFMT(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value)2002 { 2003 DEVHDA_LOCK_RETURN(p This, VINF_IOM_R3_MMIO_WRITE);2016 static int hdaRegWriteSDFMT(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) 2017 { 2018 DEVHDA_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_MMIO_WRITE); 2004 2019 2005 2020 /* Write the wanted stream format into the register in any case. … … 2010 2025 * When ignoring those (invalid) formats, this leads to MacOS thinking that the device is malfunctioning 2011 2026 * and therefore disabling the device completely. */ 2012 int rc = hdaRegWriteU16(p This, iReg, u32Value);2027 int rc = hdaRegWriteU16(pDevIns, pThis, iReg, u32Value); 2013 2028 AssertRC(rc); 2014 2029 2015 DEVHDA_UNLOCK(p This);2030 DEVHDA_UNLOCK(pDevIns, pThis); 2016 2031 return VINF_SUCCESS; /* Always return success to the MMIO handler. */ 2017 2032 } 2018 2033 2019 2034 /* Note: Will be called for both, BDPL and BDPU, registers. */ 2020 DECLINLINE(int) hdaRegWriteSDBDPX(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value, uint8_t uSD)2035 DECLINLINE(int) hdaRegWriteSDBDPX(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value, uint8_t uSD) 2021 2036 { 2022 2037 #ifdef IN_RING3 2023 DEVHDA_LOCK(p This);2038 DEVHDA_LOCK(pDevIns, pThis); 2024 2039 2025 2040 # ifdef HDA_USE_DMA_ACCESS_HANDLER … … 2040 2055 # endif 2041 2056 2042 int rc2 = hdaRegWriteU32(p This, iReg, u32Value);2057 int rc2 = hdaRegWriteU32(pDevIns, pThis, iReg, u32Value); 2043 2058 AssertRC(rc2); 2044 2059 2045 DEVHDA_UNLOCK(p This);2060 DEVHDA_UNLOCK(pDevIns, pThis); 2046 2061 return VINF_SUCCESS; /* Always return success to the MMIO handler. */ 2047 2062 #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); 2049 2064 return VINF_IOM_R3_MMIO_WRITE; 2050 #endif /* IN_RING3 */2051 } 2052 2053 static int hdaRegWriteSDBDPL(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value)2054 { 2055 return hdaRegWriteSDBDPX(p This, iReg, u32Value, HDA_SD_NUM_FROM_REG(pThis, BDPL, iReg));2056 } 2057 2058 static int hdaRegWriteSDBDPU(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value)2059 { 2060 return hdaRegWriteSDBDPX(p This, iReg, u32Value, HDA_SD_NUM_FROM_REG(pThis, BDPU, iReg));2061 } 2062 2063 static int hdaRegReadIRS(P HDASTATE pThis, uint32_t iReg, uint32_t *pu32Value)2064 { 2065 DEVHDA_LOCK_RETURN(p This, VINF_IOM_R3_MMIO_READ);2065 #endif /* !IN_RING3 */ 2066 } 2067 2068 static 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 2073 static 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 2078 static int hdaRegReadIRS(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value) 2079 { 2080 DEVHDA_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_MMIO_READ); 2066 2081 2067 2082 /* regarding 3.4.3 we should mark IRS as busy in case CORB is active */ … … 2072 2087 } 2073 2088 2074 int rc = hdaRegReadU32(p This, iReg, pu32Value);2075 DEVHDA_UNLOCK(p This);2089 int rc = hdaRegReadU32(pDevIns, pThis, iReg, pu32Value); 2090 DEVHDA_UNLOCK(pDevIns, pThis); 2076 2091 2077 2092 return rc; 2078 2093 } 2079 2094 2080 static int hdaRegWriteIRS(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value)2095 static int hdaRegWriteIRS(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) 2081 2096 { 2082 2097 RT_NOREF_PV(iReg); 2083 DEVHDA_LOCK_RETURN(p This, VINF_IOM_R3_MMIO_WRITE);2098 DEVHDA_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_MMIO_WRITE); 2084 2099 2085 2100 /* … … 2095 2110 if (HDA_REG(pThis, CORBWP) != HDA_REG(pThis, CORBRP)) 2096 2111 { 2097 DEVHDA_UNLOCK(p This);2112 DEVHDA_UNLOCK(pDevIns, pThis); 2098 2113 2099 2114 /* … … 2117 2132 HDA_REG(pThis, IRS) &= ~HDA_IRS_ICB; /* busy is clear */ 2118 2133 2119 DEVHDA_UNLOCK(p This);2134 DEVHDA_UNLOCK(pDevIns, pThis); 2120 2135 return VINF_SUCCESS; 2121 2136 #else /* !IN_RING3 */ 2122 DEVHDA_UNLOCK(p This);2137 DEVHDA_UNLOCK(pDevIns, pThis); 2123 2138 return VINF_IOM_R3_MMIO_WRITE; 2124 2139 #endif /* !IN_RING3 */ … … 2130 2145 HDA_REG(pThis, IRS) &= ~(u32Value & HDA_IRS_IRV); 2131 2146 2132 DEVHDA_UNLOCK(p This);2147 DEVHDA_UNLOCK(pDevIns, pThis); 2133 2148 return VINF_SUCCESS; 2134 2149 } 2135 2150 2136 static int hdaRegWriteRIRBWP(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value)2151 static int hdaRegWriteRIRBWP(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) 2137 2152 { 2138 2153 RT_NOREF(iReg); 2139 DEVHDA_LOCK_RETURN(p This, VINF_IOM_R3_MMIO_WRITE);2154 DEVHDA_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_MMIO_WRITE); 2140 2155 2141 2156 if (HDA_REG(pThis, CORBCTL) & HDA_CORBCTL_DMA) /* Ignore request if CORB DMA engine is (still) running. */ … … 2143 2158 LogFunc(("CORB DMA (still) running, skipping\n")); 2144 2159 2145 DEVHDA_UNLOCK(p This);2160 DEVHDA_UNLOCK(pDevIns, pThis); 2146 2161 return VINF_SUCCESS; 2147 2162 } … … 2163 2178 /* The remaining bits are O, see 6.2.22. */ 2164 2179 2165 DEVHDA_UNLOCK(p This);2180 DEVHDA_UNLOCK(pDevIns, pThis); 2166 2181 return VINF_SUCCESS; 2167 2182 } 2168 2183 2169 static int hdaRegWriteRINTCNT(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value)2170 { 2171 DEVHDA_LOCK_RETURN(p This, VINF_IOM_R3_MMIO_WRITE);2184 static int hdaRegWriteRINTCNT(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) 2185 { 2186 DEVHDA_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_MMIO_WRITE); 2172 2187 2173 2188 if (HDA_REG(pThis, CORBCTL) & HDA_CORBCTL_DMA) /* Ignore request if CORB DMA engine is (still) running. */ … … 2175 2190 LogFunc(("CORB DMA is (still) running, skipping\n")); 2176 2191 2177 DEVHDA_UNLOCK(p This);2192 DEVHDA_UNLOCK(pDevIns, pThis); 2178 2193 return VINF_SUCCESS; 2179 2194 } 2180 2195 2181 int rc = hdaRegWriteU16(p This, iReg, u32Value);2196 int rc = hdaRegWriteU16(pDevIns, pThis, iReg, u32Value); 2182 2197 AssertRC(rc); 2183 2198 2184 2199 LogFunc(("Response interrupt count is now %RU8\n", HDA_REG(pThis, RINTCNT) & 0xFF)); 2185 2200 2186 DEVHDA_UNLOCK(p This);2201 DEVHDA_UNLOCK(pDevIns, pThis); 2187 2202 return rc; 2188 2203 } 2189 2204 2190 static int hdaRegWriteBase(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value)2205 static int hdaRegWriteBase(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) 2191 2206 { 2192 2207 uint32_t iRegMem = g_aHdaRegMap[iReg].mem_idx; 2193 DEVHDA_LOCK_RETURN(p This, VINF_IOM_R3_MMIO_WRITE);2194 2195 int rc = hdaRegWriteU32(p This, iReg, u32Value);2208 DEVHDA_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_MMIO_WRITE); 2209 2210 int rc = hdaRegWriteU32(pDevIns, pThis, iReg, u32Value); 2196 2211 AssertRCSuccess(rc); 2197 2212 … … 2235 2250 pThis->u64CORBBase, pThis->u64RIRBBase, pThis->u64DPBase)); 2236 2251 2237 DEVHDA_UNLOCK(p This);2252 DEVHDA_UNLOCK(pDevIns, pThis); 2238 2253 return rc; 2239 2254 } 2240 2255 2241 static int hdaRegWriteRIRBSTS(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value)2256 static int hdaRegWriteRIRBSTS(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) 2242 2257 { 2243 2258 RT_NOREF_PV(iReg); 2244 DEVHDA_LOCK_RETURN(p This, VINF_IOM_R3_MMIO_WRITE);2259 DEVHDA_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_MMIO_WRITE); 2245 2260 2246 2261 uint8_t v = HDA_REG(pThis, RIRBSTS); … … 2253 2268 #endif 2254 2269 2255 DEVHDA_UNLOCK(p This);2270 DEVHDA_UNLOCK(pDevIns, pThis); 2256 2271 return rc; 2257 2272 } … … 2859 2874 static DECLCALLBACK(void) hdaR3Timer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 2860 2875 { 2861 RT_NOREF(p DevIns, pTimer);2876 RT_NOREF(pTimer); 2862 2877 2863 2878 PHDASTREAM pStream = (PHDASTREAM)pvUser; … … 2866 2881 PHDASTATE pThis = pStream->pHDAState; 2867 2882 2868 DEVHDA_LOCK_BOTH_RETURN_VOID(p Stream->pHDAState, pStream->u8SD);2883 DEVHDA_LOCK_BOTH_RETURN_VOID(pDevIns, pStream->pHDAState, pStream->u8SD); 2869 2884 2870 2885 hdaR3StreamUpdate(pStream, true /* fInTimer */); … … 2888 2903 Log3Func(("fSinksActive=%RTbool\n", fSinkActive)); 2889 2904 2890 DEVHDA_UNLOCK_BOTH(p This, pStream->u8SD);2905 DEVHDA_UNLOCK_BOTH(pDevIns, pThis, pStream->u8SD); 2891 2906 } 2892 2907 … … 3163 3178 Assert(cb == 4); Assert((offReg & 3) == 0); 3164 3179 3165 DEVHDA_LOCK_RETURN(p This, VINF_IOM_R3_MMIO_READ);3180 DEVHDA_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_MMIO_READ); 3166 3181 3167 3182 if (!(HDA_REG(pThis, GCTL) & HDA_GCTL_CRST) && idxRegDsc != HDA_REG_GCTL) … … 3174 3189 { 3175 3190 /* Leave lock before calling read function. */ 3176 DEVHDA_UNLOCK(p This);3191 DEVHDA_UNLOCK(pDevIns, pThis); 3177 3192 3178 3193 /* ASSUMES gapless DWORD at end of map. */ … … 3182 3197 * Straight forward DWORD access. 3183 3198 */ 3184 rc = g_aHdaRegMap[idxRegDsc].pfnRead(p This, idxRegDsc, (uint32_t *)pv);3199 rc = g_aHdaRegMap[idxRegDsc].pfnRead(pDevIns, pThis, idxRegDsc, (uint32_t *)pv); 3185 3200 Log3Func(("\tRead %s => %x (%Rrc)\n", g_aHdaRegMap[idxRegDsc].abbrev, *(uint32_t *)pv, rc)); 3186 3201 } … … 3199 3214 uint32_t u32Tmp = 0; 3200 3215 3201 rc = g_aHdaRegMap[idxRegDsc].pfnRead(p This, idxRegDsc, &u32Tmp);3216 rc = g_aHdaRegMap[idxRegDsc].pfnRead(pDevIns, pThis, idxRegDsc, &u32Tmp); 3202 3217 Log3Func(("\tRead %s[%db] => %x (%Rrc)*\n", g_aHdaRegMap[idxRegDsc].abbrev, cbReg, u32Tmp, rc)); 3203 3218 if (rc != VINF_SUCCESS) … … 3222 3237 else 3223 3238 { 3224 DEVHDA_UNLOCK(p This);3239 DEVHDA_UNLOCK(pDevIns, pThis); 3225 3240 3226 3241 rc = VINF_IOM_MMIO_UNUSED_FF; … … 3243 3258 3244 3259 3245 DECLINLINE(int) hdaWriteReg(P HDASTATE pThis, int idxRegDsc, uint32_t u32Value, char const *pszLog)3246 { 3247 DEVHDA_LOCK_RETURN(p This, VINF_IOM_R3_MMIO_WRITE);3260 DECLINLINE(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); 3248 3263 3249 3264 if (!(HDA_REG(pThis, GCTL) & HDA_GCTL_CRST) && idxRegDsc != HDA_REG_GCTL) … … 3253 3268 g_aHdaRegMap[idxRegDsc].abbrev)); 3254 3269 3255 DEVHDA_UNLOCK(p This);3270 DEVHDA_UNLOCK(pDevIns, pThis); 3256 3271 return VINF_SUCCESS; 3257 3272 } … … 3280 3295 g_aHdaRegMap[idxRegDsc].abbrev)); 3281 3296 3282 DEVHDA_UNLOCK(p This);3297 DEVHDA_UNLOCK(pDevIns, pThis); 3283 3298 return VINF_SUCCESS; 3284 3299 } … … 3295 3310 * do the two-three things a write handle needs to do than enter 3296 3311 * and exit the lock all the time. */ 3297 DEVHDA_UNLOCK(p This);3312 DEVHDA_UNLOCK(pDevIns, pThis); 3298 3313 3299 3314 #ifdef LOG_ENABLED … … 3301 3316 uint32_t const u32OldValue = pThis->au32Regs[idxRegMem]; 3302 3317 #endif 3303 int rc = g_aHdaRegMap[idxRegDsc].pfnWrite(p This, idxRegDsc, u32Value);3318 int rc = g_aHdaRegMap[idxRegDsc].pfnWrite(pDevIns, pThis, idxRegDsc, u32Value); 3304 3319 Log3Func(("Written value %#x to %s[%d byte]; %x => %x%s, rc=%d\n", u32Value, g_aHdaRegMap[idxRegDsc].abbrev, 3305 3320 g_aHdaRegMap[idxRegDsc].size, u32OldValue, pThis->au32Regs[idxRegMem], pszLog, rc)); … … 3367 3382 if (idxRegDsc != -1 && g_aHdaRegMap[idxRegDsc].size == cb) 3368 3383 { 3369 rc = hdaWriteReg(p This, idxRegDsc, u64Value, "");3384 rc = hdaWriteReg(pDevIns, pThis, idxRegDsc, u64Value, ""); 3370 3385 Log3Func(("\t%#x -> %#x\n", u32LogOldValue, idxRegMem != UINT32_MAX ? pThis->au32Regs[idxRegMem] : UINT32_MAX)); 3371 3386 } … … 3411 3426 uint32_t uLogOldVal = pThis->au32Regs[idxRegMem]; 3412 3427 # endif 3413 rc = hdaWriteReg(p This, idxRegDsc, u64Value, "*");3428 rc = hdaWriteReg(pDevIns, pThis, idxRegDsc, u64Value, "*"); 3414 3429 Log3Func(("\t%#x -> %#x\n", uLogOldVal, pThis->au32Regs[idxRegMem])); 3415 3430 } … … 4572 4587 PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE); 4573 4588 4574 DEVHDA_LOCK_RETURN(p This, VERR_IGNORED);4589 DEVHDA_LOCK_RETURN(pDevIns, pThis, VERR_IGNORED); 4575 4590 4576 4591 LogFunc(("uLUN=%u, fFlags=0x%x\n", uLUN, fFlags)); … … 4584 4599 LogFunc(("Failed with %Rrc\n", rc2)); 4585 4600 4586 DEVHDA_UNLOCK(p This);4601 DEVHDA_UNLOCK(pDevIns, pThis); 4587 4602 4588 4603 return VINF_SUCCESS; … … 4596 4611 PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE); 4597 4612 4598 DEVHDA_LOCK(p This);4613 DEVHDA_LOCK(pDevIns, pThis); 4599 4614 4600 4615 LogFunc(("uLUN=%u, fFlags=0x%x\n", uLUN, fFlags)); … … 4616 4631 } 4617 4632 4618 DEVHDA_UNLOCK(p This);4633 DEVHDA_UNLOCK(pDevIns, pThis); 4619 4634 } 4620 4635 … … 4628 4643 PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE); 4629 4644 4630 DEVHDA_LOCK_RETURN_VOID(p This);4645 DEVHDA_LOCK_RETURN_VOID(pDevIns, pThis); 4631 4646 4632 4647 LogRel2(("HDA: Powering off ...\n")); … … 4646 4661 } 4647 4662 4648 DEVHDA_UNLOCK(p This);4663 DEVHDA_UNLOCK(pDevIns, pThis); 4649 4664 } 4650 4665 … … 4728 4743 LogFlowFuncEnter(); 4729 4744 4730 DEVHDA_LOCK_RETURN_VOID(p This);4745 DEVHDA_LOCK_RETURN_VOID(pDevIns, pThis); 4731 4746 4732 4747 /* … … 4743 4758 HDA_REG(pThis, GCTL) = HDA_GCTL_CRST; 4744 4759 4745 DEVHDA_UNLOCK(p This);4760 DEVHDA_UNLOCK(pDevIns, pThis); 4746 4761 } 4747 4762 … … 4765 4780 PDMDEV_CHECK_VERSIONS_RETURN_QUIET(pDevIns); /* this shall come first */ 4766 4781 PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE); 4767 DEVHDA_LOCK(p This); /** @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. */ 4768 4783 4769 4784 PHDADRIVER pDrv; … … 4793 4808 hdaR3StreamDestroy(&pThis->aStreams[i]); 4794 4809 4795 DEVHDA_UNLOCK(p This);4810 DEVHDA_UNLOCK(pDevIns, pThis); 4796 4811 return VINF_SUCCESS; 4797 4812 } -
trunk/src/VBox/Devices/Audio/DevHDACommon.h
r76565 r80691 41 41 uint32_t fFlags; 42 42 /** Read callback. */ 43 int (*pfnRead)(P HDASTATE pThis, uint32_t iReg, uint32_t *pu32Value);43 int (*pfnRead)(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value); 44 44 /** Write callback. */ 45 int (*pfnWrite)(P HDASTATE pThis, uint32_t iReg, uint32_t u32Value);45 int (*pfnWrite)(PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); 46 46 /** Index into the register storage array. */ 47 47 uint32_t mem_idx;
Note:
See TracChangeset
for help on using the changeset viewer.