VirtualBox

Changeset 39368 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Nov 18, 2011 3:19:35 PM (13 years ago)
Author:
vboxsync
Message:

VBOX_FULL_VERSION_MAKE: fixed copy & past bug messing up the build part.
SSM: Return VERR_SSM_LOADED_TOO_LITTLE if there is data in the buffer, not only if there are more records before the unit end.
HDA: Fixed the saved state loading stuff again. Canged the saved state to mark up arrays with lengths and serialize using structure puts.

Location:
trunk/src/VBox
Files:
4 edited

Legend:

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

    r37482 r39368  
    55
    66/*
    7  * Copyright (C) 2006-2008 Oracle Corporation
     7 * Copyright (C) 2006-2011 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1515 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
    1616 */
     17
     18
     19/*******************************************************************************
     20*   Header Files                                                               *
     21*******************************************************************************/
    1722#define LOG_GROUP LOG_GROUP_DEV_AUDIO
    1823#include <VBox/vmm/pdmdev.h>
     
    3035#include "DevCodec.h"
    3136
     37
     38/*******************************************************************************
     39*   Structures and Typedefs                                                    *
     40*******************************************************************************/
    3241#define CODECNODE_F0_PARAM_LENGTH 0x14
    3342#define CODECNODE_F02_PARAM_LENGTH 16
     
    3645{
    3746    uint8_t id; /* 7 - bit format */
     47    /** The node name. */
     48    char const *pszName;
    3849    /* RPM 5.3.6 */
    3950    uint32_t au32F00_param[CODECNODE_F0_PARAM_LENGTH];
    4051    uint32_t au32F02_param[CODECNODE_F02_PARAM_LENGTH];
    4152} CODECCOMMONNODE, *PCODECCOMMONNODE;
     53AssertCompile(CODECNODE_F0_PARAM_LENGTH == 20);  /* saved state */
     54AssertCompile(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)))
    4259
    4360typedef struct ROOTCODECNODE
    4461{
    4562    CODECCOMMONNODE node;
    46 }ROOTCODECNODE, *PROOTCODECNODE;
     63} ROOTCODECNODE, *PROOTCODECNODE;
     64AssertNodeSize(ROOTCODECNODE, 0);
    4765
    4866#define AMPLIFIER_SIZE 60
     
    6684
    6785} DACNODE, *PDACNODE;
     86AssertNodeSize(DACNODE, 6 + 60);
    6887
    6988typedef struct ADCNODE
     
    7998    AMPLIFIER   B_params;
    8099} ADCNODE, *PADCNODE;
     100AssertNodeSize(DACNODE, 6 + 60);
    81101
    82102typedef struct SPDIFOUTNODE
     
    91111    AMPLIFIER   B_params;
    92112} SPDIFOUTNODE, *PSPDIFOUTNODE;
     113AssertNodeSize(SPDIFOUTNODE, 5 + 60);
    93114
    94115typedef struct SPDIFINNODE
     
    103124    AMPLIFIER   B_params;
    104125} SPDIFINNODE, *PSPDIFINNODE;
     126AssertNodeSize(SPDIFINNODE, 5 + 60);
    105127
    106128typedef struct AFGCODECNODE
     
    112134    uint32_t  u32F17_param;
    113135} AFGCODECNODE, *PAFGCODECNODE;
     136AssertNodeSize(AFGCODECNODE, 4);
    114137
    115138typedef struct PORTNODE
     
    123146    AMPLIFIER   B_params;
    124147} PORTNODE, *PPORTNODE;
     148AssertNodeSize(PORTNODE, 5 + 60);
    125149
    126150typedef struct DIGOUTNODE
     
    133157    uint32_t u32F1c_param;
    134158} DIGOUTNODE, *PDIGOUTNODE;
     159AssertNodeSize(DIGOUTNODE, 5);
    135160
    136161typedef struct DIGINNODE
     
    145170    uint32_t u32F1e_param;
    146171} DIGINNODE, *PDIGINNODE;
     172AssertNodeSize(DIGINNODE, 7);
    147173
    148174typedef struct ADCMUXNODE
     
    154180    AMPLIFIER   B_params;
    155181} ADCMUXNODE, *PADCMUXNODE;
     182AssertNodeSize(ADCMUXNODE, 2 + 60);
    156183
    157184typedef struct PCBEEPNODE
     
    163190    uint32_t    u32A_param;
    164191    AMPLIFIER   B_params;
    165     uint32_t u32F1c_param;
     192    uint32_t    u32F1c_param;
    166193} PCBEEPNODE, *PPCBEEPNODE;
     194AssertNodeSize(PCBEEPNODE, 3 + 60 + 1);
    167195
    168196typedef struct CDNODE
     
    172200    uint32_t u32F1c_param;
    173201} CDNODE, *PCDNODE;
     202AssertNodeSize(CDNODE, 2);
    174203
    175204typedef struct VOLUMEKNOBNODE
     
    179208    uint32_t    u32F0f_param;
    180209} VOLUMEKNOBNODE, *PVOLUMEKNOBNODE;
     210AssertNodeSize(VOLUMEKNOBNODE, 2);
    181211
    182212typedef struct ADCVOLNODE
     
    188218    AMPLIFIER   B_params;
    189219} ADCVOLNODE, *PADCVOLNODE;
     220AssertNodeSize(ADCVOLNODE, 3 + 60);
    190221
    191222typedef struct RESNODE
     
    197228    uint32_t    u32F1c_param;
    198229} RESNODE, *PRESNODE;
     230AssertNodeSize(RESNODE, 4);
     231
     232/**
     233 * Used for the saved state.
     234 */
     235typedef struct CODECSAVEDSTATENODE
     236{
     237    CODECCOMMONNODE Core;
     238    uint32_t        au32Params[60 + 6];
     239} CODECSAVEDSTATENODE;
     240AssertNodeSize(CODECSAVEDSTATENODE, 60 + 6);
    199241
    200242typedef union CODECNODE
     
    216258    ADCVOLNODE      adcvol;
    217259    RESNODE         reserved;
     260    CODECSAVEDSTATENODE SavedState;
    218261} 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 
     262AssertNodeSize(CODECNODE, 60 + 6);
     263
     264
     265/*******************************************************************************
     266*   Global Variables                                                           *
     267*******************************************************************************/
     268/* STAC9220 - Referenced thru STAC9220WIDGET in the constructor below. */
     269static uint8_t const g_abStac9220Ports[] = { 0xA, 0xB, 0xC, 0xD, 0xE, 0xF, 0};
     270static uint8_t const g_abStac9220Dacs[] = { 0x2, 0x3, 0x4, 0x5, 0};
     271static uint8_t const g_abStac9220Adcs[] = { 0x6, 0x7, 0};
     272static uint8_t const g_abStac9220SpdifOuts[] = { 0x8, 0 };
     273static uint8_t const g_abStac9220SpdifIns[] = { 0x9, 0 };
     274static uint8_t const g_abStac9220DigOutPins[] = { 0x10, 0 };
     275static uint8_t const g_abStac9220DigInPins[] = { 0x11, 0 };
     276static uint8_t const g_abStac9220AdcVols[] = { 0x17, 0x18, 0};
     277static uint8_t const g_abStac9220AdcMuxs[] = { 0x12, 0x13, 0};
     278static uint8_t const g_abStac9220Pcbeeps[] = { 0x14, 0 };
     279static uint8_t const g_abStac9220Cds[] = { 0x15, 0 };
     280static uint8_t const g_abStac9220VolKnobs[] = { 0x16, 0 };
     281static uint8_t const g_abStac9220Reserveds[] = { 0x9, 0x19, 0x1a, 0x1b, 0 };
     282
     283
     284/** SSM description of a CODECNODE. */
     285static 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. */
     296static 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*******************************************************************************/
    235311static int stac9220ResetNode(struct CODECState *pState, uint8_t nodenum, PCODECNODE pNode);
     312
     313
    236314
    237315static int stac9220Construct(CODECState *pState)
     
    245323    pState->pNodes = (PCODECNODE)RTMemAllocZ(sizeof(CODECNODE) * pState->cTotalNodes);
    246324    pState->fInReset = false;
    247 #define STAC9220WIDGET(type) pState->au8##type##s = au8Stac9220##type##s
     325#define STAC9220WIDGET(type) pState->au8##type##s = g_abStac9220##type##s
    248326    STAC9220WIDGET(Port);
    249327    STAC9220WIDGET(Dac);
     
    18241902    return VINF_SUCCESS;
    18251903}
     1904
    18261905int codecDestruct(CODECState *pCodecState)
    18271906{
     
    18301909}
    18311910
    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);
     1911int 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
     1923int 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     */
    18861976    if (codecIsDacNode(pCodecState, pCodecState->u8DacLineOut))
    18871977        codecToAudVolume(&pCodecState->pNodes[pCodecState->u8DacLineOut].dac.B_params, AUD_MIXER_VOLUME);
     
    18891979        codecToAudVolume(&pCodecState->pNodes[pCodecState->u8DacLineOut].spdifout.B_params, AUD_MIXER_VOLUME);
    18901980    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  
    530530int codecOpenVoice(CODECState *pCodecState, ENMSOUNDSOURCE enmSoundSource, audsettings_t *pAudioSettings);
    531531
    532 #define HDA_SSM_VERSION 3
     532#define HDA_SSM_VERSION   4
    533533#define HDA_SSM_VERSION_1 1
    534534#define HDA_SSM_VERSION_2 2
     535#define HDA_SSM_VERSION_3 3
    535536
    536537# ifdef VBOX_WITH_HDA_CODEC_EMU
  • trunk/src/VBox/Devices/Audio/DevIchIntelHDA.cpp

    r39135 r39368  
    2121#define LOG_GROUP LOG_GROUP_DEV_AUDIO
    2222#include <VBox/vmm/pdmdev.h>
     23#include <VBox/version.h>
     24
    2325#include <iprt/assert.h>
    2426#include <iprt/uuid.h>
     
    405407#define SDBDPU(pState, num) HDA_REG((pState), SD(BDPU, num))
    406408
    407 /* Predicates */
    408409
    409410typedef struct HDABDLEDESC
     
    419420} HDABDLEDESC, *PHDABDLEDESC;
    420421
     422
     423/** HDABDLEDESC field descriptors the v3+ saved state. */
    421424static SSMFIELD const g_aHdaBDLEDescFields[] =
    422425{
     
    427430    SSMFIELD_ENTRY(     HDABDLEDESC, u32BdleCviPos),
    428431    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. */
     438static 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),
    429447    SSMFIELD_ENTRY(     HDABDLEDESC, cbUnderFifoW),
    430448    SSMFIELD_ENTRY(     HDABDLEDESC, au8HdaBuffer),
     
    496514
    497515
    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);
     516DECLCALLBACK(int) hdaRegReadUnimplemented(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);
     517DECLCALLBACK(int) hdaRegWriteUnimplemented(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value);
     518DECLCALLBACK(int) hdaRegReadGCTL(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);
     519DECLCALLBACK(int) hdaRegWriteGCTL(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value);
     520DECLCALLBACK(int) hdaRegReadSTATESTS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);
     521DECLCALLBACK(int) hdaRegWriteSTATESTS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value);
     522DECLCALLBACK(int) hdaRegReadGCAP(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);
     523DECLCALLBACK(int) hdaRegReadINTSTS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);
     524DECLCALLBACK(int) hdaRegReadWALCLK(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);
     525DECLCALLBACK(int) hdaRegWriteINTSTS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value);
     526DECLCALLBACK(int) hdaRegWriteCORBWP(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value);
     527DECLCALLBACK(int) hdaRegWriteCORBRP(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);
     528DECLCALLBACK(int) hdaRegWriteCORBCTL(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);
     529DECLCALLBACK(int) hdaRegWriteCORBSTS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);
     530DECLCALLBACK(int) hdaRegWriteRIRBWP(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value);
     531DECLCALLBACK(int) hdaRegWriteRIRBSTS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);
     532DECLCALLBACK(int) hdaRegWriteIRS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);
     533DECLCALLBACK(int) hdaRegReadIRS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);
     534DECLCALLBACK(int) hdaRegWriteSDCTL(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);
     535DECLCALLBACK(int) hdaRegReadSDCTL(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);
     536
     537DECLCALLBACK(int) hdaRegWriteSDSTS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);
     538DECLCALLBACK(int) hdaRegWriteSDLVI(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);
     539DECLCALLBACK(int) hdaRegWriteSDFIFOW(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);
     540DECLCALLBACK(int) hdaRegWriteSDFIFOS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);
     541DECLCALLBACK(int) hdaRegWriteSDFMT(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);
     542DECLCALLBACK(int) hdaRegWriteSDBDPL(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);
     543DECLCALLBACK(int) hdaRegWriteSDBDPU(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);
     544DECLCALLBACK(int) hdaRegWriteBase(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);
     545DECLCALLBACK(int) hdaRegReadU32(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);
     546DECLCALLBACK(int) hdaRegWriteU32(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value);
     547DECLCALLBACK(int) hdaRegReadU24(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);
     548DECLCALLBACK(int) hdaRegWriteU24(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value);
     549DECLCALLBACK(int) hdaRegReadU16(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);
     550DECLCALLBACK(int) hdaRegWriteU16(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value);
     551DECLCALLBACK(int) hdaRegReadU8(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);
     552DECLCALLBACK(int) hdaRegWriteU8(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value);
    535553
    536554static inline void hdaInitTransferDescriptor(PINTELHDLinkState pState, PHDABDLEDESC pBdle, uint8_t u8Strm, PHDASTREAMTRANSFERDESC pStreamDesc);
     
    20312049 * @param   enmType         One of the PCI_ADDRESS_SPACE_* values.
    20322050 */
    2033 static DECLCALLBACK(int) hdaMap (PPCIDEVICE pPciDev, int iRegion,
    2034                                            RTGCPHYS GCPhysAddress, uint32_t cb,
    2035                                            PCIADDRESSSPACE enmType)
     2051static DECLCALLBACK(int) hdaMap(PPCIDEVICE pPciDev, int iRegion,
     2052                                RTGCPHYS GCPhysAddress, uint32_t cb,
     2053                                PCIADDRESSSPACE enmType)
    20362054{
    20372055    int         rc;
     
    20572075 * @returns VBox status code.
    20582076 * @param   pDevIns     The device instance.
    2059  * @param   pSSMHandle  The handle to save the state to.
     2077 * @param   pSSM  The handle to save the state to.
    20602078 */
    2061 static DECLCALLBACK(int) hdaSaveExec (PPDMDEVINS pDevIns, PSSMHANDLE pSSMHandle)
     2079static DECLCALLBACK(int) hdaSaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)
    20622080{
    20632081    PCIINTELHDLinkState *pThis = PDMINS_2_DATA(pDevIns, PCIINTELHDLinkState *);
    20642082    /* Save Codec nodes states */
    2065     codecSaveState(&pThis->hda.Codec, pSSMHandle);
     2083    codecSaveState(&pThis->hda.Codec, pSSM);
     2084
    20662085    /* 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
    20682090    /* 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);
    20722094    return VINF_SUCCESS;
    20732095}
     
    20782100 * @returns VBox status code.
    20792101 * @param   pDevIns     The device instance.
    2080  * @param   pSSMHandle  The handle to the saved state.
     2102 * @param   pSSM  The handle to the saved state.
    20812103 * @param   uVersion    The data unit version number.
    20822104 * @param   uPass       The data pass.
    20832105 */
    2084 static DECLCALLBACK(int) hdaLoadExec (PPDMDEVINS pDevIns, PSSMHANDLE pSSMHandle,
    2085                                           uint32_t uVersion, uint32_t uPass)
     2106static DECLCALLBACK(int) hdaLoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)
    20862107{
    20872108    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)));
    21012161    }
    21022162    else
    21032163    {
    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     */
    21102181    AUD_set_active_in(pThis->hda.Codec.SwVoiceIn, SDCTL(&pThis->hda, 0) & HDA_REG_FIELD_FLAG_MASK(SDCTL, RUN));
    21112182    AUD_set_active_out(pThis->hda.Codec.SwVoiceOut, SDCTL(&pThis->hda, 4) & HDA_REG_FIELD_FLAG_MASK(SDCTL, RUN));
    21122183
    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));
    21192187    return VINF_SUCCESS;
    21202188}
  • trunk/src/VBox/VMM/VMMR3/SSM.cpp

    r39078 r39368  
    56435643        &&  RT_SUCCESS(rc))
    56445644    {
    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)
    56495647            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            }
    56515657        }
    56525658        pSSM->rc = rc;
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