Changeset 39368 in vbox for trunk/src/VBox
- Timestamp:
- Nov 18, 2011 3:19:35 PM (13 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevCodec.cpp
r37482 r39368 5 5 6 6 /* 7 * Copyright (C) 2006-20 08Oracle Corporation7 * Copyright (C) 2006-2011 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 15 15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. 16 16 */ 17 18 19 /******************************************************************************* 20 * Header Files * 21 *******************************************************************************/ 17 22 #define LOG_GROUP LOG_GROUP_DEV_AUDIO 18 23 #include <VBox/vmm/pdmdev.h> … … 30 35 #include "DevCodec.h" 31 36 37 38 /******************************************************************************* 39 * Structures and Typedefs * 40 *******************************************************************************/ 32 41 #define CODECNODE_F0_PARAM_LENGTH 0x14 33 42 #define CODECNODE_F02_PARAM_LENGTH 16 … … 36 45 { 37 46 uint8_t id; /* 7 - bit format */ 47 /** The node name. */ 48 char const *pszName; 38 49 /* RPM 5.3.6 */ 39 50 uint32_t au32F00_param[CODECNODE_F0_PARAM_LENGTH]; 40 51 uint32_t au32F02_param[CODECNODE_F02_PARAM_LENGTH]; 41 52 } CODECCOMMONNODE, *PCODECCOMMONNODE; 53 AssertCompile(CODECNODE_F0_PARAM_LENGTH == 20); /* saved state */ 54 AssertCompile(CODECNODE_F02_PARAM_LENGTH == 16); /* saved state */ 55 56 #define AssertNodeSize(a_Node, a_cParams) \ 57 AssertCompile((a_cParams) <= (60 + 6)); /* the max size - saved state */ \ 58 AssertCompile(sizeof(a_Node) - sizeof(CODECCOMMONNODE) == (((a_cParams) * sizeof(uint32_t) + sizeof(void *) - 1) & ~(sizeof(void *) - 1))) 42 59 43 60 typedef struct ROOTCODECNODE 44 61 { 45 62 CODECCOMMONNODE node; 46 }ROOTCODECNODE, *PROOTCODECNODE; 63 } ROOTCODECNODE, *PROOTCODECNODE; 64 AssertNodeSize(ROOTCODECNODE, 0); 47 65 48 66 #define AMPLIFIER_SIZE 60 … … 66 84 67 85 } DACNODE, *PDACNODE; 86 AssertNodeSize(DACNODE, 6 + 60); 68 87 69 88 typedef struct ADCNODE … … 79 98 AMPLIFIER B_params; 80 99 } ADCNODE, *PADCNODE; 100 AssertNodeSize(DACNODE, 6 + 60); 81 101 82 102 typedef struct SPDIFOUTNODE … … 91 111 AMPLIFIER B_params; 92 112 } SPDIFOUTNODE, *PSPDIFOUTNODE; 113 AssertNodeSize(SPDIFOUTNODE, 5 + 60); 93 114 94 115 typedef struct SPDIFINNODE … … 103 124 AMPLIFIER B_params; 104 125 } SPDIFINNODE, *PSPDIFINNODE; 126 AssertNodeSize(SPDIFINNODE, 5 + 60); 105 127 106 128 typedef struct AFGCODECNODE … … 112 134 uint32_t u32F17_param; 113 135 } AFGCODECNODE, *PAFGCODECNODE; 136 AssertNodeSize(AFGCODECNODE, 4); 114 137 115 138 typedef struct PORTNODE … … 123 146 AMPLIFIER B_params; 124 147 } PORTNODE, *PPORTNODE; 148 AssertNodeSize(PORTNODE, 5 + 60); 125 149 126 150 typedef struct DIGOUTNODE … … 133 157 uint32_t u32F1c_param; 134 158 } DIGOUTNODE, *PDIGOUTNODE; 159 AssertNodeSize(DIGOUTNODE, 5); 135 160 136 161 typedef struct DIGINNODE … … 145 170 uint32_t u32F1e_param; 146 171 } DIGINNODE, *PDIGINNODE; 172 AssertNodeSize(DIGINNODE, 7); 147 173 148 174 typedef struct ADCMUXNODE … … 154 180 AMPLIFIER B_params; 155 181 } ADCMUXNODE, *PADCMUXNODE; 182 AssertNodeSize(ADCMUXNODE, 2 + 60); 156 183 157 184 typedef struct PCBEEPNODE … … 163 190 uint32_t u32A_param; 164 191 AMPLIFIER B_params; 165 uint32_t u32F1c_param;192 uint32_t u32F1c_param; 166 193 } PCBEEPNODE, *PPCBEEPNODE; 194 AssertNodeSize(PCBEEPNODE, 3 + 60 + 1); 167 195 168 196 typedef struct CDNODE … … 172 200 uint32_t u32F1c_param; 173 201 } CDNODE, *PCDNODE; 202 AssertNodeSize(CDNODE, 2); 174 203 175 204 typedef struct VOLUMEKNOBNODE … … 179 208 uint32_t u32F0f_param; 180 209 } VOLUMEKNOBNODE, *PVOLUMEKNOBNODE; 210 AssertNodeSize(VOLUMEKNOBNODE, 2); 181 211 182 212 typedef struct ADCVOLNODE … … 188 218 AMPLIFIER B_params; 189 219 } ADCVOLNODE, *PADCVOLNODE; 220 AssertNodeSize(ADCVOLNODE, 3 + 60); 190 221 191 222 typedef struct RESNODE … … 197 228 uint32_t u32F1c_param; 198 229 } RESNODE, *PRESNODE; 230 AssertNodeSize(RESNODE, 4); 231 232 /** 233 * Used for the saved state. 234 */ 235 typedef struct CODECSAVEDSTATENODE 236 { 237 CODECCOMMONNODE Core; 238 uint32_t au32Params[60 + 6]; 239 } CODECSAVEDSTATENODE; 240 AssertNodeSize(CODECSAVEDSTATENODE, 60 + 6); 199 241 200 242 typedef union CODECNODE … … 216 258 ADCVOLNODE adcvol; 217 259 RESNODE reserved; 260 CODECSAVEDSTATENODE SavedState; 218 261 } CODECNODE, *PCODECNODE; 219 220 /* STAC9220 */ 221 const static uint8_t au8Stac9220Ports[] = { 0xA, 0xB, 0xC, 0xD, 0xE, 0xF, 0}; 222 const static uint8_t au8Stac9220Dacs[] = { 0x2, 0x3, 0x4, 0x5, 0}; 223 const static uint8_t au8Stac9220Adcs[] = { 0x6, 0x7, 0}; 224 const static uint8_t au8Stac9220SpdifOuts[] = { 0x8, 0 }; 225 const static uint8_t au8Stac9220SpdifIns[] = { 0x9, 0 }; 226 const static uint8_t au8Stac9220DigOutPins[] = { 0x10, 0 }; 227 const static uint8_t au8Stac9220DigInPins[] = { 0x11, 0 }; 228 const static uint8_t au8Stac9220AdcVols[] = { 0x17, 0x18, 0}; 229 const static uint8_t au8Stac9220AdcMuxs[] = { 0x12, 0x13, 0}; 230 const static uint8_t au8Stac9220Pcbeeps[] = { 0x14, 0 }; 231 const static uint8_t au8Stac9220Cds[] = { 0x15, 0 }; 232 const static uint8_t au8Stac9220VolKnobs[] = { 0x16, 0 }; 233 const static uint8_t au8Stac9220Reserveds[] = { 0x9, 0x19, 0x1a, 0x1b, 0 }; 234 262 AssertNodeSize(CODECNODE, 60 + 6); 263 264 265 /******************************************************************************* 266 * Global Variables * 267 *******************************************************************************/ 268 /* STAC9220 - Referenced thru STAC9220WIDGET in the constructor below. */ 269 static uint8_t const g_abStac9220Ports[] = { 0xA, 0xB, 0xC, 0xD, 0xE, 0xF, 0}; 270 static uint8_t const g_abStac9220Dacs[] = { 0x2, 0x3, 0x4, 0x5, 0}; 271 static uint8_t const g_abStac9220Adcs[] = { 0x6, 0x7, 0}; 272 static uint8_t const g_abStac9220SpdifOuts[] = { 0x8, 0 }; 273 static uint8_t const g_abStac9220SpdifIns[] = { 0x9, 0 }; 274 static uint8_t const g_abStac9220DigOutPins[] = { 0x10, 0 }; 275 static uint8_t const g_abStac9220DigInPins[] = { 0x11, 0 }; 276 static uint8_t const g_abStac9220AdcVols[] = { 0x17, 0x18, 0}; 277 static uint8_t const g_abStac9220AdcMuxs[] = { 0x12, 0x13, 0}; 278 static uint8_t const g_abStac9220Pcbeeps[] = { 0x14, 0 }; 279 static uint8_t const g_abStac9220Cds[] = { 0x15, 0 }; 280 static uint8_t const g_abStac9220VolKnobs[] = { 0x16, 0 }; 281 static uint8_t const g_abStac9220Reserveds[] = { 0x9, 0x19, 0x1a, 0x1b, 0 }; 282 283 284 /** SSM description of a CODECNODE. */ 285 static SSMFIELD const g_aCodecNodeFields[] = 286 { 287 SSMFIELD_ENTRY( CODECSAVEDSTATENODE, Core.id), 288 SSMFIELD_ENTRY_PAD_HC_AUTO(3, 3), 289 SSMFIELD_ENTRY( CODECSAVEDSTATENODE, Core.au32F00_param), 290 SSMFIELD_ENTRY( CODECSAVEDSTATENODE, Core.au32F02_param), 291 SSMFIELD_ENTRY( CODECSAVEDSTATENODE, au32Params), 292 SSMFIELD_ENTRY_TERM() 293 }; 294 295 /** Backward compatibility with v1 of the CODECNODE. */ 296 static SSMFIELD const g_aCodecNodeFieldsV1[] = 297 { 298 SSMFIELD_ENTRY( CODECSAVEDSTATENODE, Core.id), 299 SSMFIELD_ENTRY_PAD_HC_AUTO(3, 7), 300 SSMFIELD_ENTRY_OLD_HCPTR(Core.name), 301 SSMFIELD_ENTRY( CODECSAVEDSTATENODE, Core.au32F00_param), 302 SSMFIELD_ENTRY( CODECSAVEDSTATENODE, Core.au32F02_param), 303 SSMFIELD_ENTRY( CODECSAVEDSTATENODE, au32Params), 304 SSMFIELD_ENTRY_TERM() 305 }; 306 307 308 /******************************************************************************* 309 * Internal Functions * 310 *******************************************************************************/ 235 311 static int stac9220ResetNode(struct CODECState *pState, uint8_t nodenum, PCODECNODE pNode); 312 313 236 314 237 315 static int stac9220Construct(CODECState *pState) … … 245 323 pState->pNodes = (PCODECNODE)RTMemAllocZ(sizeof(CODECNODE) * pState->cTotalNodes); 246 324 pState->fInReset = false; 247 #define STAC9220WIDGET(type) pState->au8##type##s = au8Stac9220##type##s325 #define STAC9220WIDGET(type) pState->au8##type##s = g_abStac9220##type##s 248 326 STAC9220WIDGET(Port); 249 327 STAC9220WIDGET(Dac); … … 1824 1902 return VINF_SUCCESS; 1825 1903 } 1904 1826 1905 int codecDestruct(CODECState *pCodecState) 1827 1906 { … … 1830 1909 } 1831 1910 1832 int codecSaveState(CODECState *pCodecState, PSSMHANDLE pSSMHandle) 1833 { 1834 SSMR3PutMem (pSSMHandle, pCodecState->pNodes, sizeof(CODECNODE) * pCodecState->cTotalNodes); 1835 return VINF_SUCCESS; 1836 } 1837 1838 static DECLCALLBACK(int)codecLoadV1(PCODECState pCodecState, PSSMHANDLE pSSMHandle, size_t cbOffset, size_t alignment) 1839 { 1840 size_t cbRawNodesV1 = (sizeof(CODECNODE) + cbOffset + alignment) * pCodecState->cTotalNodes; 1841 uint8_t *pu8RawNodesV1 = (uint8_t *)RTMemAlloc(cbRawNodesV1); 1842 uint8_t *pu8NodeV1 = NULL; 1843 int idxNode = 0; 1844 if (!pu8RawNodesV1) 1845 return VERR_NO_MEMORY; 1846 int rc = SSMR3GetMem (pSSMHandle, pu8RawNodesV1, cbRawNodesV1); 1847 1848 if (RT_FAILURE(rc)) 1849 { 1850 RTMemFree(pu8RawNodesV1); 1851 AssertRCReturn(rc, rc); 1852 } 1853 pu8NodeV1 = &pu8RawNodesV1[0]; 1854 for (idxNode = 0; idxNode < pCodecState->cTotalNodes; ++idxNode) 1855 { 1856 pCodecState->pNodes[idxNode].node.id = pu8NodeV1[0]; 1857 memcpy(pCodecState->pNodes[idxNode].node.au32F00_param, 1858 pu8NodeV1 + RT_OFFSETOF(CODECCOMMONNODE, au32F00_param) + alignment, 1859 sizeof(CODECNODE) - RT_OFFSETOF(CODECCOMMONNODE,au32F00_param)); 1860 pu8NodeV1 += sizeof(CODECNODE) + cbOffset; 1861 } 1862 1863 RTMemFree(pu8RawNodesV1); 1864 return rc; 1865 } 1866 1867 int codecLoadState(CODECState *pCodecState, PSSMHANDLE pSSMHandle, uint32_t uVersion) 1868 { 1869 int rc; 1870 if (uVersion == HDA_SSM_VERSION_1) 1871 { 1872 #if RT_ARCH_X86 1873 if (SSMR3HandleHostBits(pSSMHandle) == 32) 1874 rc = codecLoadV1(pCodecState, pSSMHandle, sizeof(long), 0); 1875 else 1876 rc = codecLoadV1(pCodecState, pSSMHandle, sizeof(uint64_t), 4); 1877 #else 1878 if (SSMR3HandleHostBits(pSSMHandle) == 64) 1879 rc = codecLoadV1(pCodecState, pSSMHandle, sizeof(long), 4); 1880 else 1881 rc = codecLoadV1(pCodecState, pSSMHandle, sizeof(uint32_t), 0); 1882 #endif 1883 } 1884 else 1885 rc = SSMR3GetMem (pSSMHandle, pCodecState->pNodes, sizeof(CODECNODE) * pCodecState->cTotalNodes); 1911 int codecSaveState(CODECState *pCodecState, PSSMHANDLE pSSM) 1912 { 1913 AssertLogRelMsgReturn(pCodecState->cTotalNodes == 0x1c, ("cTotalNodes=%#x, should be 0x1c", pCodecState->cTotalNodes), 1914 VERR_INTERNAL_ERROR); 1915 SSMR3PutU32(pSSM, pCodecState->cTotalNodes); 1916 for (unsigned idxNode = 0; idxNode < pCodecState->cTotalNodes; ++idxNode) 1917 SSMR3PutStructEx(pSSM, &pCodecState->pNodes[idxNode].SavedState, sizeof(pCodecState->pNodes[idxNode].SavedState), 1918 0 /*fFlags*/, g_aCodecNodeFields, NULL /*pvUser*/); 1919 return VINF_SUCCESS; 1920 } 1921 1922 1923 int codecLoadState(CODECState *pCodecState, PSSMHANDLE pSSM, uint32_t uVersion) 1924 { 1925 PCSSMFIELD pFields; 1926 uint32_t fFlags; 1927 switch (uVersion) 1928 { 1929 case HDA_SSM_VERSION_1: 1930 AssertReturn(pCodecState->cTotalNodes == 0x1c, VERR_INTERNAL_ERROR); 1931 pFields = g_aCodecNodeFieldsV1; 1932 fFlags = SSMSTRUCT_FLAGS_MEM_BAND_AID_RELAXED; 1933 break; 1934 1935 case HDA_SSM_VERSION_2: 1936 case HDA_SSM_VERSION_3: 1937 AssertReturn(pCodecState->cTotalNodes == 0x1c, VERR_INTERNAL_ERROR); 1938 pFields = g_aCodecNodeFields; 1939 fFlags = SSMSTRUCT_FLAGS_MEM_BAND_AID_RELAXED; 1940 break; 1941 1942 case HDA_SSM_VERSION: 1943 { 1944 uint32_t cNodes; 1945 int rc2 = SSMR3GetU32(pSSM, &cNodes); 1946 AssertRCReturn(rc2, rc2); 1947 if (cNodes != 0x1c) 1948 return VERR_SSM_DATA_UNIT_FORMAT_CHANGED; 1949 AssertReturn(pCodecState->cTotalNodes == 0x1c, VERR_INTERNAL_ERROR); 1950 1951 pFields = g_aCodecNodeFields; 1952 fFlags = 0; 1953 break; 1954 } 1955 1956 default: 1957 return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION; 1958 } 1959 1960 for (unsigned idxNode = 0; idxNode < pCodecState->cTotalNodes; ++idxNode) 1961 { 1962 uint8_t idOld = pCodecState->pNodes[idxNode].SavedState.Core.id; 1963 int rc = SSMR3GetStructEx(pSSM, &pCodecState->pNodes[idxNode].SavedState, 1964 sizeof(pCodecState->pNodes[idxNode].SavedState), 1965 fFlags, pFields, NULL); 1966 if (RT_FAILURE(rc)) 1967 return rc; 1968 AssertLogRelMsgReturn(idOld == pCodecState->pNodes[idxNode].SavedState.Core.id, 1969 ("loaded %#x, expected \n", pCodecState->pNodes[idxNode].SavedState.Core.id, idOld), 1970 VERR_SSM_DATA_UNIT_FORMAT_CHANGED); 1971 } 1972 1973 /* 1974 * Update stuff after changing the state. 1975 */ 1886 1976 if (codecIsDacNode(pCodecState, pCodecState->u8DacLineOut)) 1887 1977 codecToAudVolume(&pCodecState->pNodes[pCodecState->u8DacLineOut].dac.B_params, AUD_MIXER_VOLUME); … … 1889 1979 codecToAudVolume(&pCodecState->pNodes[pCodecState->u8DacLineOut].spdifout.B_params, AUD_MIXER_VOLUME); 1890 1980 codecToAudVolume(&pCodecState->pNodes[pCodecState->u8AdcVolsLineIn].adcvol.B_params, AUD_MIXER_LINE_IN); 1891 return rc; 1892 } 1981 1982 return VINF_SUCCESS; 1983 } 1984 -
trunk/src/VBox/Devices/Audio/DevCodec.h
r37482 r39368 530 530 int codecOpenVoice(CODECState *pCodecState, ENMSOUNDSOURCE enmSoundSource, audsettings_t *pAudioSettings); 531 531 532 #define HDA_SSM_VERSION 3532 #define HDA_SSM_VERSION 4 533 533 #define HDA_SSM_VERSION_1 1 534 534 #define HDA_SSM_VERSION_2 2 535 #define HDA_SSM_VERSION_3 3 535 536 536 537 # ifdef VBOX_WITH_HDA_CODEC_EMU -
trunk/src/VBox/Devices/Audio/DevIchIntelHDA.cpp
r39135 r39368 21 21 #define LOG_GROUP LOG_GROUP_DEV_AUDIO 22 22 #include <VBox/vmm/pdmdev.h> 23 #include <VBox/version.h> 24 23 25 #include <iprt/assert.h> 24 26 #include <iprt/uuid.h> … … 405 407 #define SDBDPU(pState, num) HDA_REG((pState), SD(BDPU, num)) 406 408 407 /* Predicates */408 409 409 410 typedef struct HDABDLEDESC … … 419 420 } HDABDLEDESC, *PHDABDLEDESC; 420 421 422 423 /** HDABDLEDESC field descriptors the v3+ saved state. */ 421 424 static SSMFIELD const g_aHdaBDLEDescFields[] = 422 425 { … … 427 430 SSMFIELD_ENTRY( HDABDLEDESC, u32BdleCviPos), 428 431 SSMFIELD_ENTRY( HDABDLEDESC, fBdleCviIoc), 432 SSMFIELD_ENTRY( HDABDLEDESC, cbUnderFifoW), 433 SSMFIELD_ENTRY( HDABDLEDESC, au8HdaBuffer), 434 SSMFIELD_ENTRY_TERM() 435 }; 436 437 /** HDABDLEDESC field descriptors the v1 and v2 saved state. */ 438 static SSMFIELD const g_aHdaBDLEDescFieldsOld[] = 439 { 440 SSMFIELD_ENTRY( HDABDLEDESC, u64BdleCviAddr), 441 SSMFIELD_ENTRY( HDABDLEDESC, u32BdleMaxCvi), 442 SSMFIELD_ENTRY( HDABDLEDESC, u32BdleCvi), 443 SSMFIELD_ENTRY( HDABDLEDESC, u32BdleCviLen), 444 SSMFIELD_ENTRY( HDABDLEDESC, u32BdleCviPos), 445 SSMFIELD_ENTRY( HDABDLEDESC, fBdleCviIoc), 446 SSMFIELD_ENTRY_PAD_HC_AUTO(3, 3), 429 447 SSMFIELD_ENTRY( HDABDLEDESC, cbUnderFifoW), 430 448 SSMFIELD_ENTRY( HDABDLEDESC, au8HdaBuffer), … … 496 514 497 515 498 DECLCALLBACK(int) hdaRegReadUnimplemented(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);499 DECLCALLBACK(int) hdaRegWriteUnimplemented(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value);500 DECLCALLBACK(int) hdaRegReadGCTL(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);501 DECLCALLBACK(int) hdaRegWriteGCTL(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value);502 DECLCALLBACK(int) hdaRegReadSTATESTS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);503 DECLCALLBACK(int) hdaRegWriteSTATESTS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value);504 DECLCALLBACK(int) hdaRegReadGCAP(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);505 DECLCALLBACK(int) hdaRegReadINTSTS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);506 DECLCALLBACK(int) hdaRegReadWALCLK(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);507 DECLCALLBACK(int) hdaRegWriteINTSTS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value);508 DECLCALLBACK(int) hdaRegWriteCORBWP(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value);509 DECLCALLBACK(int) hdaRegWriteCORBRP(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);510 DECLCALLBACK(int) hdaRegWriteCORBCTL(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);511 DECLCALLBACK(int) hdaRegWriteCORBSTS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);512 DECLCALLBACK(int) hdaRegWriteRIRBWP(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value);513 DECLCALLBACK(int) hdaRegWriteRIRBSTS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);514 DECLCALLBACK(int) hdaRegWriteIRS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);515 DECLCALLBACK(int) hdaRegReadIRS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);516 DECLCALLBACK(int) hdaRegWriteSDCTL(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);517 DECLCALLBACK(int) hdaRegReadSDCTL(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);518 519 DECLCALLBACK(int) hdaRegWriteSDSTS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);520 DECLCALLBACK(int) hdaRegWriteSDLVI(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);521 DECLCALLBACK(int) hdaRegWriteSDFIFOW(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);522 DECLCALLBACK(int) hdaRegWriteSDFIFOS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);523 DECLCALLBACK(int) hdaRegWriteSDFMT(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);524 DECLCALLBACK(int) hdaRegWriteSDBDPL(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);525 DECLCALLBACK(int) hdaRegWriteSDBDPU(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);526 DECLCALLBACK(int) hdaRegWriteBase(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);527 DECLCALLBACK(int) hdaRegReadU32(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);528 DECLCALLBACK(int) hdaRegWriteU32(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value);529 DECLCALLBACK(int) hdaRegReadU24(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);530 DECLCALLBACK(int) hdaRegWriteU24(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value);531 DECLCALLBACK(int) hdaRegReadU16(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);532 DECLCALLBACK(int) hdaRegWriteU16(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value);533 DECLCALLBACK(int) hdaRegReadU8(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);534 DECLCALLBACK(int) hdaRegWriteU8(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value);516 DECLCALLBACK(int) hdaRegReadUnimplemented(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value); 517 DECLCALLBACK(int) hdaRegWriteUnimplemented(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value); 518 DECLCALLBACK(int) hdaRegReadGCTL(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value); 519 DECLCALLBACK(int) hdaRegWriteGCTL(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value); 520 DECLCALLBACK(int) hdaRegReadSTATESTS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value); 521 DECLCALLBACK(int) hdaRegWriteSTATESTS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value); 522 DECLCALLBACK(int) hdaRegReadGCAP(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value); 523 DECLCALLBACK(int) hdaRegReadINTSTS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value); 524 DECLCALLBACK(int) hdaRegReadWALCLK(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value); 525 DECLCALLBACK(int) hdaRegWriteINTSTS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value); 526 DECLCALLBACK(int) hdaRegWriteCORBWP(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value); 527 DECLCALLBACK(int) hdaRegWriteCORBRP(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value); 528 DECLCALLBACK(int) hdaRegWriteCORBCTL(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value); 529 DECLCALLBACK(int) hdaRegWriteCORBSTS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value); 530 DECLCALLBACK(int) hdaRegWriteRIRBWP(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value); 531 DECLCALLBACK(int) hdaRegWriteRIRBSTS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value); 532 DECLCALLBACK(int) hdaRegWriteIRS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value); 533 DECLCALLBACK(int) hdaRegReadIRS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value); 534 DECLCALLBACK(int) hdaRegWriteSDCTL(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value); 535 DECLCALLBACK(int) hdaRegReadSDCTL(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value); 536 537 DECLCALLBACK(int) hdaRegWriteSDSTS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value); 538 DECLCALLBACK(int) hdaRegWriteSDLVI(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value); 539 DECLCALLBACK(int) hdaRegWriteSDFIFOW(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value); 540 DECLCALLBACK(int) hdaRegWriteSDFIFOS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value); 541 DECLCALLBACK(int) hdaRegWriteSDFMT(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value); 542 DECLCALLBACK(int) hdaRegWriteSDBDPL(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value); 543 DECLCALLBACK(int) hdaRegWriteSDBDPU(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value); 544 DECLCALLBACK(int) hdaRegWriteBase(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value); 545 DECLCALLBACK(int) hdaRegReadU32(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value); 546 DECLCALLBACK(int) hdaRegWriteU32(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value); 547 DECLCALLBACK(int) hdaRegReadU24(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value); 548 DECLCALLBACK(int) hdaRegWriteU24(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value); 549 DECLCALLBACK(int) hdaRegReadU16(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value); 550 DECLCALLBACK(int) hdaRegWriteU16(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value); 551 DECLCALLBACK(int) hdaRegReadU8(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value); 552 DECLCALLBACK(int) hdaRegWriteU8(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value); 535 553 536 554 static inline void hdaInitTransferDescriptor(PINTELHDLinkState pState, PHDABDLEDESC pBdle, uint8_t u8Strm, PHDASTREAMTRANSFERDESC pStreamDesc); … … 2031 2049 * @param enmType One of the PCI_ADDRESS_SPACE_* values. 2032 2050 */ 2033 static DECLCALLBACK(int) hdaMap 2034 2035 2051 static DECLCALLBACK(int) hdaMap(PPCIDEVICE pPciDev, int iRegion, 2052 RTGCPHYS GCPhysAddress, uint32_t cb, 2053 PCIADDRESSSPACE enmType) 2036 2054 { 2037 2055 int rc; … … 2057 2075 * @returns VBox status code. 2058 2076 * @param pDevIns The device instance. 2059 * @param pSSM HandleThe handle to save the state to.2077 * @param pSSM The handle to save the state to. 2060 2078 */ 2061 static DECLCALLBACK(int) hdaSaveExec (PPDMDEVINS pDevIns, PSSMHANDLE pSSMHandle)2079 static DECLCALLBACK(int) hdaSaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM) 2062 2080 { 2063 2081 PCIINTELHDLinkState *pThis = PDMINS_2_DATA(pDevIns, PCIINTELHDLinkState *); 2064 2082 /* Save Codec nodes states */ 2065 codecSaveState(&pThis->hda.Codec, pSSMHandle); 2083 codecSaveState(&pThis->hda.Codec, pSSM); 2084 2066 2085 /* Save MMIO registers */ 2067 SSMR3PutMem (pSSMHandle, pThis->hda.au32Regs, sizeof (pThis->hda.au32Regs)); 2086 AssertCompile(RT_ELEMENTS(pThis->hda.au32Regs) == 112); 2087 SSMR3PutU32(pSSM, RT_ELEMENTS(pThis->hda.au32Regs)); 2088 SSMR3PutMem(pSSM, pThis->hda.au32Regs, sizeof(pThis->hda.au32Regs)); 2089 2068 2090 /* Save HDA dma counters */ 2069 SSMR3PutStruct (pSSMHandle, &pThis->hda.stOutBdle, g_aHdaBDLEDescFields);2070 SSMR3PutStruct (pSSMHandle, &pThis->hda.stMicBdle, g_aHdaBDLEDescFields);2071 SSMR3PutStruct (pSSMHandle, &pThis->hda.stInBdle, g_aHdaBDLEDescFields);2091 SSMR3PutStructEx(pSSM, &pThis->hda.stOutBdle, sizeof(pThis->hda.stOutBdle), 0 /*fFlags*/, g_aHdaBDLEDescFields, NULL); 2092 SSMR3PutStructEx(pSSM, &pThis->hda.stMicBdle, sizeof(pThis->hda.stMicBdle), 0 /*fFlags*/, g_aHdaBDLEDescFields, NULL); 2093 SSMR3PutStructEx(pSSM, &pThis->hda.stInBdle, sizeof(pThis->hda.stInBdle), 0 /*fFlags*/, g_aHdaBDLEDescFields, NULL); 2072 2094 return VINF_SUCCESS; 2073 2095 } … … 2078 2100 * @returns VBox status code. 2079 2101 * @param pDevIns The device instance. 2080 * @param pSSM HandleThe handle to the saved state.2102 * @param pSSM The handle to the saved state. 2081 2103 * @param uVersion The data unit version number. 2082 2104 * @param uPass The data pass. 2083 2105 */ 2084 static DECLCALLBACK(int) hdaLoadExec (PPDMDEVINS pDevIns, PSSMHANDLE pSSMHandle, 2085 uint32_t uVersion, uint32_t uPass) 2106 static DECLCALLBACK(int) hdaLoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass) 2086 2107 { 2087 2108 PCIINTELHDLinkState *pThis = PDMINS_2_DATA(pDevIns, PCIINTELHDLinkState *); 2088 /* Load Codec nodes states */ 2089 Assert (uPass == SSM_PASS_FINAL); NOREF(uPass); 2090 2091 codecLoadState(&pThis->hda.Codec, pSSMHandle, uVersion); 2092 /* Load MMIO registers */ 2093 SSMR3GetMem (pSSMHandle, pThis->hda.au32Regs, sizeof (pThis->hda.au32Regs)); 2094 /* Load HDA dma counters */ 2095 if ( uVersion == HDA_SSM_VERSION_1 2096 || uVersion == HDA_SSM_VERSION_2) 2097 { 2098 SSMR3GetMem (pSSMHandle, &pThis->hda.stOutBdle, sizeof (HDABDLEDESC)); 2099 SSMR3GetMem (pSSMHandle, &pThis->hda.stMicBdle, sizeof (HDABDLEDESC)); 2100 SSMR3GetMem (pSSMHandle, &pThis->hda.stInBdle, sizeof (HDABDLEDESC)); 2109 2110 Assert(uPass == SSM_PASS_FINAL); NOREF(uPass); 2111 2112 /* 2113 * Load Codec nodes states. 2114 */ 2115 int rc = codecLoadState(&pThis->hda.Codec, pSSM, uVersion); 2116 if (RT_FAILURE(rc)) 2117 return rc; 2118 2119 /* 2120 * Load MMIO registers. 2121 */ 2122 uint32_t cRegs; 2123 switch (uVersion) 2124 { 2125 case HDA_SSM_VERSION_1: 2126 /* Starting with r71199, we would save 112 instead of 113 2127 registers due to some code cleanups. This only affects trunk 2128 builds in the 4.1 development period. */ 2129 cRegs = 113; 2130 if (SSMR3HandleRevision(pSSM) >= 71199) 2131 { 2132 uint32_t uVer = SSMR3HandleVersion(pSSM); 2133 if ( VBOX_FULL_VERSION_GET_MAJOR(uVer) == 4 2134 && VBOX_FULL_VERSION_GET_MINOR(uVer) == 0 2135 && VBOX_FULL_VERSION_GET_BUILD(uVer) >= 51) 2136 cRegs = 112; 2137 } 2138 break; 2139 2140 case HDA_SSM_VERSION_2: 2141 case HDA_SSM_VERSION_3: 2142 cRegs = 112; 2143 AssertCompile(RT_ELEMENTS(pThis->hda.au32Regs) == 112); 2144 break; 2145 2146 case HDA_SSM_VERSION: 2147 rc = SSMR3GetU32(pSSM, &cRegs); AssertRCReturn(rc, rc); 2148 AssertLogRelMsgReturn(cRegs == RT_ELEMENTS(pThis->hda.au32Regs), 2149 ("cRegs is %d, expected %d\n", cRegs, RT_ELEMENTS(pThis->hda.au32Regs)), 2150 VERR_SSM_DATA_UNIT_FORMAT_CHANGED); 2151 break; 2152 2153 default: 2154 return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION; 2155 } 2156 2157 if (cRegs >= RT_ELEMENTS(pThis->hda.au32Regs)) 2158 { 2159 SSMR3GetMem(pSSM, pThis->hda.au32Regs, sizeof(pThis->hda.au32Regs)); 2160 SSMR3Skip(pSSM, sizeof(uint32_t) * (cRegs - RT_ELEMENTS(pThis->hda.au32Regs))); 2101 2161 } 2102 2162 else 2103 2163 { 2104 SSMR3GetStruct (pSSMHandle, &pThis->hda.stOutBdle, g_aHdaBDLEDescFields); 2105 SSMR3GetStruct (pSSMHandle, &pThis->hda.stMicBdle, g_aHdaBDLEDescFields); 2106 SSMR3GetStruct (pSSMHandle, &pThis->hda.stInBdle, g_aHdaBDLEDescFields); 2107 } 2108 2109 2164 RT_ZERO(pThis->hda.au32Regs); 2165 SSMR3GetMem(pSSM, pThis->hda.au32Regs, sizeof(uint32_t) * cRegs); 2166 } 2167 2168 /* 2169 * Load HDA dma counters. 2170 */ 2171 uint32_t fFlags = uVersion <= HDA_SSM_VERSION_2 ? SSMSTRUCT_FLAGS_MEM_BAND_AID_RELAXED : 0; 2172 PCSSMFIELD paFields = uVersion <= HDA_SSM_VERSION_2 ? g_aHdaBDLEDescFieldsOld : g_aHdaBDLEDescFields; 2173 SSMR3GetStructEx(pSSM, &pThis->hda.stOutBdle, sizeof(pThis->hda.stOutBdle), fFlags, paFields, NULL); 2174 SSMR3GetStructEx(pSSM, &pThis->hda.stMicBdle, sizeof(pThis->hda.stMicBdle), fFlags, paFields, NULL); 2175 rc = SSMR3GetStructEx(pSSM, &pThis->hda.stInBdle, sizeof(pThis->hda.stInBdle), fFlags, paFields, NULL); 2176 AssertRCReturn(rc, rc); 2177 2178 /* 2179 * Update stuff after the state changes. 2180 */ 2110 2181 AUD_set_active_in(pThis->hda.Codec.SwVoiceIn, SDCTL(&pThis->hda, 0) & HDA_REG_FIELD_FLAG_MASK(SDCTL, RUN)); 2111 2182 AUD_set_active_out(pThis->hda.Codec.SwVoiceOut, SDCTL(&pThis->hda, 4) & HDA_REG_FIELD_FLAG_MASK(SDCTL, RUN)); 2112 2183 2113 pThis->hda.u64CORBBase = CORBLBASE(&pThis->hda); 2114 pThis->hda.u64CORBBase |= ((uint64_t)CORBUBASE(&pThis->hda)) << 32; 2115 pThis->hda.u64RIRBBase = RIRLBASE(&pThis->hda); 2116 pThis->hda.u64RIRBBase |= ((uint64_t)RIRUBASE(&pThis->hda)) << 32; 2117 pThis->hda.u64DPBase = DPLBASE(&pThis->hda); 2118 pThis->hda.u64DPBase |= ((uint64_t)DPUBASE(&pThis->hda)) << 32; 2184 pThis->hda.u64CORBBase = RT_MAKE_U64(CORBLBASE(&pThis->hda), CORBUBASE(&pThis->hda)); 2185 pThis->hda.u64RIRBBase = RT_MAKE_U64(RIRLBASE(&pThis->hda), RIRUBASE(&pThis->hda)); 2186 pThis->hda.u64DPBase = RT_MAKE_U64(DPLBASE(&pThis->hda), DPUBASE(&pThis->hda)); 2119 2187 return VINF_SUCCESS; 2120 2188 } -
trunk/src/VBox/VMM/VMMR3/SSM.cpp
r39078 r39368 5643 5643 && RT_SUCCESS(rc)) 5644 5644 { 5645 rc = ssmR3DataReadRecHdrV2(pSSM); 5646 if ( RT_SUCCESS(rc) 5647 && !pSSM->u.Read.fEndOfData) 5648 { 5645 if ( pSSM->u.Read.cbDataBuffer != pSSM->u.Read.offDataBuffer 5646 && pSSM->u.Read.cbDataBuffer > 0) 5649 5647 rc = VERR_SSM_LOADED_TOO_LITTLE; 5650 AssertFailed(); 5648 else 5649 { 5650 rc = ssmR3DataReadRecHdrV2(pSSM); 5651 if ( RT_SUCCESS(rc) 5652 && !pSSM->u.Read.fEndOfData) 5653 { 5654 rc = VERR_SSM_LOADED_TOO_LITTLE; 5655 AssertFailed(); 5656 } 5651 5657 } 5652 5658 pSSM->rc = rc;
Note:
See TracChangeset
for help on using the changeset viewer.