Changeset 87950 in vbox
- Timestamp:
- Mar 4, 2021 2:13:48 PM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 143046
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevHDA.cpp
r87945 r87950 4047 4047 *********************************************************************************************************************************/ 4048 4048 4049 /** Worker for hdaR3DbgInfo. */ 4049 4050 static int hdaR3DbgLookupRegByName(const char *pszArgs) 4050 4051 { 4051 i nt iReg = 0;4052 for (; iReg < HDA_NUM_REGS; ++iReg)4053 if (!RTStrICmp(g_aHdaRegMap[iReg].abbrev, pszArgs))4054 return iReg;4052 if (pszArgs && *pszArgs != '\0') 4053 for (int iReg = 0; iReg < HDA_NUM_REGS; ++iReg) 4054 if (!RTStrICmp(g_aHdaRegMap[iReg].abbrev, pszArgs)) 4055 return iReg; 4055 4056 return -1; 4056 4057 } 4057 4058 4058 4059 /** Worker for hdaR3DbgInfo. */ 4059 4060 static void hdaR3DbgPrintRegister(PHDASTATE pThis, PCDBGFINFOHLP pHlp, int iHdaIndex) 4060 4061 { 4061 Assert( pThis 4062 && iHdaIndex >= 0 4063 && iHdaIndex < HDA_NUM_REGS); 4064 pHlp->pfnPrintf(pHlp, "%s: 0x%x\n", g_aHdaRegMap[iHdaIndex].abbrev, pThis->au32Regs[g_aHdaRegMap[iHdaIndex].mem_idx]); 4062 /** @todo HDA_REG_IDX_NOMEM & GCAP both uses mem_idx zero, no flag or anything to tell them appart. */ 4063 if (g_aHdaRegMap[iHdaIndex].mem_idx != 0 || g_aHdaRegMap[iHdaIndex].pfnRead != hdaRegReadWALCLK) 4064 pHlp->pfnPrintf(pHlp, "%s: 0x%x\n", g_aHdaRegMap[iHdaIndex].abbrev, pThis->au32Regs[g_aHdaRegMap[iHdaIndex].mem_idx]); 4065 else 4066 pHlp->pfnPrintf(pHlp, "%s: 0x%RX64\n", g_aHdaRegMap[iHdaIndex].abbrev, pThis->u64WalClk); 4065 4067 } 4066 4068 … … 4071 4073 { 4072 4074 PHDASTATE pThis = PDMDEVINS_2_DATA(pDevIns, PHDASTATE); 4073 int i HdaRegisterIndex= hdaR3DbgLookupRegByName(pszArgs);4074 if (i HdaRegisterIndex!= -1)4075 hdaR3DbgPrintRegister(pThis, pHlp, i HdaRegisterIndex);4075 int idxReg = hdaR3DbgLookupRegByName(pszArgs); 4076 if (idxReg != -1) 4077 hdaR3DbgPrintRegister(pThis, pHlp, idxReg); 4076 4078 else 4077 { 4078 for(iHdaRegisterIndex = 0; (unsigned int)iHdaRegisterIndex < HDA_NUM_REGS; ++iHdaRegisterIndex) 4079 hdaR3DbgPrintRegister(pThis, pHlp, iHdaRegisterIndex); 4080 } 4081 } 4082 4083 static void hdaR3DbgPrintStream(PHDASTATE pThis, PCDBGFINFOHLP pHlp, int iIdx) 4084 { 4085 Assert( pThis 4086 && iIdx >= 0 4087 && iIdx < HDA_MAX_STREAMS); 4088 4089 const PHDASTREAM pStream = &pThis->aStreams[iIdx]; 4090 4091 pHlp->pfnPrintf(pHlp, "Stream #%d:\n", iIdx); 4092 pHlp->pfnPrintf(pHlp, "\tSD%dCTL : %R[sdctl]\n", iIdx, HDA_STREAM_REG(pThis, CTL, iIdx)); 4093 pHlp->pfnPrintf(pHlp, "\tSD%dCTS : %R[sdsts]\n", iIdx, HDA_STREAM_REG(pThis, STS, iIdx)); 4094 pHlp->pfnPrintf(pHlp, "\tSD%dFIFOS: %R[sdfifos]\n", iIdx, HDA_STREAM_REG(pThis, FIFOS, iIdx)); 4095 pHlp->pfnPrintf(pHlp, "\tSD%dFIFOW: %R[sdfifow]\n", iIdx, HDA_STREAM_REG(pThis, FIFOW, iIdx)); 4096 pHlp->pfnPrintf(pHlp, "\tBDLE : %R[bdle]\n", &pStream->State.BDLE); 4097 } 4098 4099 static void hdaR3DbgPrintBDLE(PPDMDEVINS pDevIns, PHDASTATE pThis, PCDBGFINFOHLP pHlp, int iIdx) 4100 { 4101 Assert( pThis 4102 && iIdx >= 0 4103 && iIdx < HDA_MAX_STREAMS); 4104 4105 const PHDASTREAM pStream = &pThis->aStreams[iIdx]; 4106 const PHDABDLE pBDLE = &pStream->State.BDLE; 4107 4108 pHlp->pfnPrintf(pHlp, "Stream #%d BDLE:\n", iIdx); 4109 4110 uint64_t u64BaseDMA = RT_MAKE_U64(HDA_STREAM_REG(pThis, BDPL, iIdx), 4111 HDA_STREAM_REG(pThis, BDPU, iIdx)); 4112 uint16_t u16LVI = HDA_STREAM_REG(pThis, LVI, iIdx); 4113 uint32_t u32CBL = HDA_STREAM_REG(pThis, CBL, iIdx); 4114 4079 for (idxReg = 0; idxReg < HDA_NUM_REGS; ++idxReg) 4080 hdaR3DbgPrintRegister(pThis, pHlp, idxReg); 4081 } 4082 4083 /** Worker for hdaR3DbgInfoStream. */ 4084 static void hdaR3DbgPrintStream(PHDASTATE pThis, PCDBGFINFOHLP pHlp, int idxStream) 4085 { 4086 const PHDASTREAM pStream = &pThis->aStreams[idxStream]; 4087 4088 pHlp->pfnPrintf(pHlp, "Stream #%d:\n", idxStream); 4089 pHlp->pfnPrintf(pHlp, " SD%dCTL : %R[sdctl]\n", idxStream, HDA_STREAM_REG(pThis, CTL, idxStream)); 4090 pHlp->pfnPrintf(pHlp, " SD%dCTS : %R[sdsts]\n", idxStream, HDA_STREAM_REG(pThis, STS, idxStream)); 4091 pHlp->pfnPrintf(pHlp, " SD%dFIFOS: %R[sdfifos]\n", idxStream, HDA_STREAM_REG(pThis, FIFOS, idxStream)); 4092 pHlp->pfnPrintf(pHlp, " SD%dFIFOW: %R[sdfifow]\n", idxStream, HDA_STREAM_REG(pThis, FIFOW, idxStream)); 4093 pHlp->pfnPrintf(pHlp, " BDLE : %R[bdle]\n", &pStream->State.BDLE); 4094 } 4095 4096 /** Worker for hdaR3DbgInfoBDLE. */ 4097 static void hdaR3DbgPrintBDLE(PPDMDEVINS pDevIns, PHDASTATE pThis, PCDBGFINFOHLP pHlp, int idxStream) 4098 { 4099 const PHDASTREAM pStream = &pThis->aStreams[idxStream]; 4100 4101 pHlp->pfnPrintf(pHlp, "Stream #%d BDLE:\n", idxStream); 4102 4103 uint64_t const u64BaseDMA = RT_MAKE_U64(HDA_STREAM_REG(pThis, BDPL, idxStream), 4104 HDA_STREAM_REG(pThis, BDPU, idxStream)); 4105 uint16_t const u16LVI = HDA_STREAM_REG(pThis, LVI, idxStream); 4106 uint32_t const u32CBL = HDA_STREAM_REG(pThis, CBL, idxStream); 4107 4108 pHlp->pfnPrintf(pHlp, " Current: %R[bdle]\n", &pStream->State.BDLE); 4109 pHlp->pfnPrintf(pHlp, " Memory - %#RX64 LB %#x (LVI=%u):\n", u64BaseDMA, u16LVI * sizeof(HDABDLEDESC), u16LVI); 4115 4110 if (!u64BaseDMA) 4116 4111 return; 4117 4112 4118 pHlp->pfnPrintf(pHlp, "\tCurrent: %R[bdle]\n\n", pBDLE); 4119 4120 pHlp->pfnPrintf(pHlp, "\tMemory:\n"); 4121 4122 uint32_t cbBDLE = 0; 4113 uint32_t cbTotal = 0; 4123 4114 for (uint16_t i = 0; i < u16LVI + 1; i++) 4124 4115 { 4125 HDABDLEDESC bd; 4116 /** @todo shouldn't this be a PCI read? */ 4117 HDABDLEDESC bd = {0, 0, 0}; 4126 4118 PDMDevHlpPhysRead(pDevIns, u64BaseDMA + i * sizeof(HDABDLEDESC), &bd, sizeof(bd)); 4127 4119 4128 pHlp->pfnPrintf(pHlp, "\t\t%s #%03d BDLE(adr:0x%llx, size:%RU32, ioc:%RTbool)\n", 4129 pBDLE->State.u32BDLIndex == i ? "*" : " ", i, bd.u64BufAddr, bd.u32BufSize, bd.fFlags & HDA_BDLE_F_IOC); 4130 4131 cbBDLE += bd.u32BufSize; 4132 } 4133 4134 pHlp->pfnPrintf(pHlp, "Total: %RU32 bytes\n", cbBDLE); 4135 4136 if (cbBDLE != u32CBL) 4137 pHlp->pfnPrintf(pHlp, "Warning: %RU32 bytes does not match CBL (%RU32)!\n", cbBDLE, u32CBL); 4138 4139 pHlp->pfnPrintf(pHlp, "DMA counters (base @ 0x%llx):\n", u64BaseDMA); 4140 if (!u64BaseDMA) /* No DMA base given? Bail out. */ 4141 { 4142 pHlp->pfnPrintf(pHlp, "\tNo counters found\n"); 4143 return; 4144 } 4145 4146 for (int i = 0; i < u16LVI + 1; i++) 4147 { 4148 uint32_t uDMACnt; 4149 PDMDevHlpPhysRead(pDevIns, (pThis->u64DPBase & DPBASE_ADDR_MASK) + (i * 2 * sizeof(uint32_t)), 4150 &uDMACnt, sizeof(uDMACnt)); 4151 4152 pHlp->pfnPrintf(pHlp, "\t#%03d DMA @ 0x%x\n", i , uDMACnt); 4153 } 4154 } 4155 4156 static int hdaR3DbgLookupStrmIdx(PHDASTATE pThis, const char *pszArgs) 4157 { 4158 RT_NOREF(pThis, pszArgs); 4159 /** @todo Add args parsing. */ 4120 char szFlags[64]; 4121 szFlags[0] = '\0'; 4122 if (bd.fFlags & ~HDA_BDLE_F_IOC) 4123 RTStrPrintf(szFlags, sizeof(szFlags), " !!fFlags=%#x!!\n", bd.fFlags); 4124 pHlp->pfnPrintf(pHlp, " %sBDLE%03u: %#RX64 LB %#x %s%s\n", 4125 pStream->State.BDLE.State.u32BDLIndex == i ? "=>" : " ", i, bd.u64BufAddr, bd.u32BufSize, 4126 bd.fFlags & HDA_BDLE_F_IOC ? " IOC=1" : "", szFlags); 4127 4128 cbTotal += bd.u32BufSize; 4129 } 4130 pHlp->pfnPrintf(pHlp, " Total: %RU32 bytes\n", cbTotal); 4131 if (cbTotal != u32CBL) 4132 pHlp->pfnPrintf(pHlp, " Warning: %RU32 bytes does not match CBL (%RU32)!\n", cbTotal, u32CBL); 4133 4134 uint64_t const uDPBase = pThis->u64DPBase & DPBASE_ADDR_MASK; 4135 pHlp->pfnPrintf(pHlp, " DMA counters %#RX64 LB %#x, %s:\n", uDPBase, u16LVI * 2 * sizeof(uint32_t), 4136 pThis->fDMAPosition ? "enabled" : "disabled"); 4137 if (uDPBase) 4138 for (uint16_t i = 0; i < u16LVI + 1; i++) 4139 { 4140 /** @todo shouldn't this be a PCI read? */ 4141 struct 4142 { 4143 uint32_t uPos; 4144 uint32_t uReserved; 4145 } Buf = { 0 , 0 }; 4146 PDMDevHlpPhysRead(pDevIns, uDPBase + i * sizeof(Buf), &Buf, sizeof(Buf)); 4147 4148 char szReserved[64]; 4149 szReserved[0] = '\0'; 4150 if (Buf.uReserved != 0) 4151 RTStrPrintf(szReserved, sizeof(szReserved), " reserved=%#x", Buf.uReserved); 4152 pHlp->pfnPrintf(pHlp, " #%03d DMA @ %#x%s\n", i, Buf.uPos, szReserved); 4153 } 4154 else 4155 pHlp->pfnPrintf(pHlp, " No counters.\n"); 4156 } 4157 4158 /** Used by hdaR3DbgInfoStream and hdaR3DbgInfoBDLE. */ 4159 static int hdaR3DbgLookupStrmIdx(PCDBGFINFOHLP pHlp, const char *pszArgs) 4160 { 4161 if (pszArgs && *pszArgs) 4162 { 4163 int32_t idxStream; 4164 int rc = RTStrToInt32Full(pszArgs, 0, &idxStream); 4165 if (RT_SUCCESS(rc) && idxStream >= -1 && idxStream < HDA_MAX_STREAMS) 4166 return idxStream; 4167 pHlp->pfnPrintf(pHlp, "Argument '%s' is not a valid stream number!\n", pszArgs); 4168 } 4160 4169 return -1; 4161 4170 } … … 4166 4175 static DECLCALLBACK(void) hdaR3DbgInfoStream(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs) 4167 4176 { 4168 PHDASTATE pThis 4169 int i HdaStreamdex = hdaR3DbgLookupStrmIdx(pThis, pszArgs);4170 if (i HdaStreamdex!= -1)4171 hdaR3DbgPrintStream(pThis, pHlp, i HdaStreamdex);4177 PHDASTATE pThis = PDMDEVINS_2_DATA(pDevIns, PHDASTATE); 4178 int idxStream = hdaR3DbgLookupStrmIdx(pHlp, pszArgs); 4179 if (idxStream != -1) 4180 hdaR3DbgPrintStream(pThis, pHlp, idxStream); 4172 4181 else 4173 for (iHdaStreamdex = 0; iHdaStreamdex < HDA_MAX_STREAMS; ++iHdaStreamdex)4174 hdaR3DbgPrintStream(pThis, pHlp, i HdaStreamdex);4182 for (idxStream = 0; idxStream < HDA_MAX_STREAMS; ++idxStream) 4183 hdaR3DbgPrintStream(pThis, pHlp, idxStream); 4175 4184 } 4176 4185 … … 4180 4189 static DECLCALLBACK(void) hdaR3DbgInfoBDLE(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs) 4181 4190 { 4182 PHDASTATE pThis 4183 int i HdaStreamdex = hdaR3DbgLookupStrmIdx(pThis, pszArgs);4184 if (i HdaStreamdex!= -1)4185 hdaR3DbgPrintBDLE(pDevIns, pThis, pHlp, i HdaStreamdex);4191 PHDASTATE pThis = PDMDEVINS_2_DATA(pDevIns, PHDASTATE); 4192 int idxStream = hdaR3DbgLookupStrmIdx(pHlp, pszArgs); 4193 if (idxStream != -1) 4194 hdaR3DbgPrintBDLE(pDevIns, pThis, pHlp, idxStream); 4186 4195 else 4187 for (i HdaStreamdex = 0; iHdaStreamdex < HDA_MAX_STREAMS; ++iHdaStreamdex)4188 hdaR3DbgPrintBDLE(pDevIns, pThis, pHlp, i HdaStreamdex);4196 for (idxStream = 0; idxStream < HDA_MAX_STREAMS; ++idxStream) 4197 hdaR3DbgPrintBDLE(pDevIns, pThis, pHlp, idxStream); 4189 4198 } 4190 4199 … … 5014 5023 * accept screwing formatting. 5015 5024 */ 5016 PDMDevHlpDBGFInfoRegister(pDevIns, "hda", "HDA info. (hda [register case-insensitive])", hdaR3DbgInfo); 5017 PDMDevHlpDBGFInfoRegister(pDevIns, "hdabdle", "HDA stream BDLE info. (hdabdle [stream number])", hdaR3DbgInfoBDLE); 5025 PDMDevHlpDBGFInfoRegister(pDevIns, "hda", "HDA registers. (hda [register case-insensitive])", hdaR3DbgInfo); 5026 PDMDevHlpDBGFInfoRegister(pDevIns, "hdabdle", 5027 "HDA buffer descriptor list (BDLE) and DMA stream positions. (hdabdle [stream number])", 5028 hdaR3DbgInfoBDLE); 5018 5029 PDMDevHlpDBGFInfoRegister(pDevIns, "hdastream", "HDA stream info. (hdastream [stream number])", hdaR3DbgInfoStream); 5019 5030 PDMDevHlpDBGFInfoRegister(pDevIns, "hdcnodes", "HDA codec nodes.", hdaR3DbgInfoCodecNodes);
Note:
See TracChangeset
for help on using the changeset viewer.