/* $Id: SSMInternal.h 21798 2009-07-25 23:24:30Z vboxsync $ */ /** @file * SSM - Internal header file. */ /* * Copyright (C) 2006-2007 Sun Microsystems, Inc. * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; * you can redistribute it and/or modify it under the terms of the GNU * General Public License (GPL) as published by the Free Software * Foundation, in version 2 as it comes in the "COPYING" file of the * VirtualBox OSE distribution. VirtualBox OSE is distributed in the * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. * * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa * Clara, CA 95054 USA or visit http://www.sun.com if you need * additional information or have any questions. */ #ifndef ___SSMInternal_h #define ___SSMInternal_h #include #include #include RT_C_DECLS_BEGIN /** @defgroup grp_ssm_int Internals * @ingroup grp_ssm * @internal * @{ */ /** * Data unit callback type. */ typedef enum SSMUNITTYPE { /** PDM Device . */ SSMUNITTYPE_DEV = 1, /** PDM Driver. */ SSMUNITTYPE_DRV, /** VM Internal. */ SSMUNITTYPE_INTERNAL, /** External Wrapper. */ SSMUNITTYPE_EXTERNAL } SSMUNITTYPE; /** Pointer to a data unit descriptor. */ typedef struct SSMUNIT *PSSMUNIT; /** * Data unit descriptor. */ typedef struct SSMUNIT { /** Pointer ot the next one in the list. */ PSSMUNIT pNext; /** Called in this save/load operation. * The flag is used to determin whether there is need for a call to * done or not. */ bool fCalled; /** Callback interface type. */ SSMUNITTYPE enmType; /** Type specific data. */ union { /** SSMUNITTYPE_DEV. */ struct { /** Prepare save. */ PFNSSMDEVSAVEPREP pfnSavePrep; /** Execute save. */ PFNSSMDEVSAVEEXEC pfnSaveExec; /** Done save. */ PFNSSMDEVSAVEDONE pfnSaveDone; /** Prepare load. */ PFNSSMDEVLOADPREP pfnLoadPrep; /** Execute load. */ PFNSSMDEVLOADEXEC pfnLoadExec; /** Done load. */ PFNSSMDEVLOADDONE pfnLoadDone; /** Device instance. */ PPDMDEVINS pDevIns; } Dev; /** SSMUNITTYPE_DRV. */ struct { /** Prepare save. */ PFNSSMDRVSAVEPREP pfnSavePrep; /** Execute save. */ PFNSSMDRVSAVEEXEC pfnSaveExec; /** Done save. */ PFNSSMDRVSAVEDONE pfnSaveDone; /** Prepare load. */ PFNSSMDRVLOADPREP pfnLoadPrep; /** Execute load. */ PFNSSMDRVLOADEXEC pfnLoadExec; /** Done load. */ PFNSSMDRVLOADDONE pfnLoadDone; /** Driver instance. */ PPDMDRVINS pDrvIns; } Drv; /** SSMUNITTYPE_INTERNAL. */ struct { /** Prepare save. */ PFNSSMINTSAVEPREP pfnSavePrep; /** Execute save. */ PFNSSMINTSAVEEXEC pfnSaveExec; /** Done save. */ PFNSSMINTSAVEDONE pfnSaveDone; /** Prepare load. */ PFNSSMINTLOADPREP pfnLoadPrep; /** Execute load. */ PFNSSMINTLOADEXEC pfnLoadExec; /** Done load. */ PFNSSMINTLOADDONE pfnLoadDone; } Internal; /** SSMUNITTYPE_EXTERNAL. */ struct { /** Prepare save. */ PFNSSMEXTSAVEPREP pfnSavePrep; /** Execute save. */ PFNSSMEXTSAVEEXEC pfnSaveExec; /** Done save. */ PFNSSMEXTSAVEDONE pfnSaveDone; /** Prepare load. */ PFNSSMEXTLOADPREP pfnLoadPrep; /** Execute load. */ PFNSSMEXTLOADEXEC pfnLoadExec; /** Done load. */ PFNSSMEXTLOADDONE pfnLoadDone; /** User data. */ void *pvUser; } External; struct { /** Prepare save. */ PFNRT pfnSavePrep; /** Execute save. */ PFNRT pfnSaveExec; /** Done save. */ PFNRT pfnSaveDone; /** Prepare load. */ PFNRT pfnLoadPrep; /** Execute load. */ PFNRT pfnLoadExec; /** Done load. */ PFNRT pfnLoadDone; /** User data. */ void *pvKey; } Common; } u; /** Data layout version. */ uint32_t u32Version; /** Instance number. */ uint32_t u32Instance; /** The offset of the final data unit. * This is used for constructing the directory. */ RTFOFF offStream; /** The guessed size of the data unit - used only for progress indication. */ size_t cbGuess; /** Name size. (bytes) */ size_t cchName; /** Name of this unit. (extends beyond the defined size) */ char szName[1]; } SSMUNIT; AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnSavePrep, u.Dev.pfnSavePrep); AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnSaveExec, u.Dev.pfnSaveExec); AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnSaveDone, u.Dev.pfnSaveDone); AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLoadPrep, u.Dev.pfnLoadPrep); AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLoadExec, u.Dev.pfnLoadExec); AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLoadDone, u.Dev.pfnLoadDone); AssertCompile2MemberOffsets(SSMUNIT, u.Common.pvKey, u.Dev.pDevIns); AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnSavePrep, u.Drv.pfnSavePrep); AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnSaveExec, u.Drv.pfnSaveExec); AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnSaveDone, u.Drv.pfnSaveDone); AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLoadPrep, u.Drv.pfnLoadPrep); AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLoadExec, u.Drv.pfnLoadExec); AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLoadDone, u.Drv.pfnLoadDone); AssertCompile2MemberOffsets(SSMUNIT, u.Common.pvKey, u.Drv.pDrvIns); AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnSavePrep, u.Internal.pfnSavePrep); AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnSaveExec, u.Internal.pfnSaveExec); AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnSaveDone, u.Internal.pfnSaveDone); AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLoadPrep, u.Internal.pfnLoadPrep); AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLoadExec, u.Internal.pfnLoadExec); AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLoadDone, u.Internal.pfnLoadDone); AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnSavePrep, u.External.pfnSavePrep); AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnSaveExec, u.External.pfnSaveExec); AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnSaveDone, u.External.pfnSaveDone); AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLoadPrep, u.External.pfnLoadPrep); AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLoadExec, u.External.pfnLoadExec); AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLoadDone, u.External.pfnLoadDone); AssertCompile2MemberOffsets(SSMUNIT, u.Common.pvKey, u.External.pvUser); /** * SSM VM Instance data. * Changes to this must checked against the padding of the cfgm union in VM! * * @todo Move this to UVM. */ typedef struct SSM { /** FIFO of data entity descriptors. */ R3PTRTYPE(PSSMUNIT) pHead; /** The number of register units. */ uint32_t cUnits; /** For lazy init. */ bool fInitialized; } SSM; /** Pointer to SSM VM instance data. */ typedef SSM *PSSM; /** @} */ RT_C_DECLS_END #endif /* !___SSMInternal_h */