VirtualBox

source: vbox/trunk/src/VBox/VMM/SSMInternal.h@ 23495

Last change on this file since 23495 was 22884, checked in by vboxsync, 15 years ago

SSM: Added cancellation support (SSMR3Cancel). Needed by the state machinery as well as main.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 10.3 KB
Line 
1/* $Id: SSMInternal.h 22884 2009-09-09 21:55:47Z vboxsync $ */
2/** @file
3 * SSM - Internal header file.
4 */
5
6/*
7 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22#ifndef ___SSMInternal_h
23#define ___SSMInternal_h
24
25#include <VBox/cdefs.h>
26#include <VBox/types.h>
27#include <VBox/ssm.h>
28#include <iprt/critsect.h>
29
30RT_C_DECLS_BEGIN
31
32/** @defgroup grp_ssm_int Internals
33 * @ingroup grp_ssm
34 * @internal
35 * @{
36 */
37
38
39/**
40 * Data unit callback type.
41 */
42typedef enum SSMUNITTYPE
43{
44 /** PDM Device . */
45 SSMUNITTYPE_DEV = 1,
46 /** PDM Driver. */
47 SSMUNITTYPE_DRV,
48 /** VM Internal. */
49 SSMUNITTYPE_INTERNAL,
50 /** External Wrapper. */
51 SSMUNITTYPE_EXTERNAL
52} SSMUNITTYPE;
53
54/** Pointer to a data unit descriptor. */
55typedef struct SSMUNIT *PSSMUNIT;
56
57/**
58 * Data unit descriptor.
59 */
60typedef struct SSMUNIT
61{
62 /** Pointer ot the next one in the list. */
63 PSSMUNIT pNext;
64
65 /** Called in this save/load operation.
66 * The flag is used to determin whether there is need for a call to
67 * done or not. */
68 bool fCalled;
69 /** Callback interface type. */
70 SSMUNITTYPE enmType;
71 /** Type specific data. */
72 union
73 {
74 /** SSMUNITTYPE_DEV. */
75 struct
76 {
77 /** Prepare live save. */
78 PFNSSMDEVLIVEPREP pfnLivePrep;
79 /** Execute live save. */
80 PFNSSMDEVLIVEEXEC pfnLiveExec;
81 /** Vote live save complete. */
82 PFNSSMDEVLIVEVOTE pfnLiveVote;
83 /** Prepare save. */
84 PFNSSMDEVSAVEPREP pfnSavePrep;
85 /** Execute save. */
86 PFNSSMDEVSAVEEXEC pfnSaveExec;
87 /** Done save. */
88 PFNSSMDEVSAVEDONE pfnSaveDone;
89 /** Prepare load. */
90 PFNSSMDEVLOADPREP pfnLoadPrep;
91 /** Execute load. */
92 PFNSSMDEVLOADEXEC pfnLoadExec;
93 /** Done load. */
94 PFNSSMDEVLOADDONE pfnLoadDone;
95 /** Device instance. */
96 PPDMDEVINS pDevIns;
97 } Dev;
98
99 /** SSMUNITTYPE_DRV. */
100 struct
101 {
102 /** Prepare live save. */
103 PFNSSMDRVLIVEPREP pfnLivePrep;
104 /** Execute live save. */
105 PFNSSMDRVLIVEEXEC pfnLiveExec;
106 /** Vote live save complete. */
107 PFNSSMDRVLIVEVOTE pfnLiveVote;
108 /** Prepare save. */
109 PFNSSMDRVSAVEPREP pfnSavePrep;
110 /** Execute save. */
111 PFNSSMDRVSAVEEXEC pfnSaveExec;
112 /** Done save. */
113 PFNSSMDRVSAVEDONE pfnSaveDone;
114 /** Prepare load. */
115 PFNSSMDRVLOADPREP pfnLoadPrep;
116 /** Execute load. */
117 PFNSSMDRVLOADEXEC pfnLoadExec;
118 /** Done load. */
119 PFNSSMDRVLOADDONE pfnLoadDone;
120 /** Driver instance. */
121 PPDMDRVINS pDrvIns;
122 } Drv;
123
124 /** SSMUNITTYPE_INTERNAL. */
125 struct
126 {
127 /** Prepare live save. */
128 PFNSSMINTLIVEPREP pfnLivePrep;
129 /** Execute live save. */
130 PFNSSMINTLIVEEXEC pfnLiveExec;
131 /** Vote live save complete. */
132 PFNSSMINTLIVEVOTE pfnLiveVote;
133 /** Prepare save. */
134 PFNSSMINTSAVEPREP pfnSavePrep;
135 /** Execute save. */
136 PFNSSMINTSAVEEXEC pfnSaveExec;
137 /** Done save. */
138 PFNSSMINTSAVEDONE pfnSaveDone;
139 /** Prepare load. */
140 PFNSSMINTLOADPREP pfnLoadPrep;
141 /** Execute load. */
142 PFNSSMINTLOADEXEC pfnLoadExec;
143 /** Done load. */
144 PFNSSMINTLOADDONE pfnLoadDone;
145 } Internal;
146
147 /** SSMUNITTYPE_EXTERNAL. */
148 struct
149 {
150 /** Prepare live save. */
151 PFNSSMEXTLIVEPREP pfnLivePrep;
152 /** Execute live save. */
153 PFNSSMEXTLIVEEXEC pfnLiveExec;
154 /** Vote live save complete. */
155 PFNSSMEXTLIVEVOTE pfnLiveVote;
156 /** Prepare save. */
157 PFNSSMEXTSAVEPREP pfnSavePrep;
158 /** Execute save. */
159 PFNSSMEXTSAVEEXEC pfnSaveExec;
160 /** Done save. */
161 PFNSSMEXTSAVEDONE pfnSaveDone;
162 /** Prepare load. */
163 PFNSSMEXTLOADPREP pfnLoadPrep;
164 /** Execute load. */
165 PFNSSMEXTLOADEXEC pfnLoadExec;
166 /** Done load. */
167 PFNSSMEXTLOADDONE pfnLoadDone;
168 /** User data. */
169 void *pvUser;
170 } External;
171
172 struct
173 {
174 /** Prepare live save. */
175 PFNRT pfnLivePrep;
176 /** Execute live save. */
177 PFNRT pfnLiveExec;
178 /** Vote live save complete. */
179 PFNRT pfnLiveVote;
180 /** Prepare save. */
181 PFNRT pfnSavePrep;
182 /** Execute save. */
183 PFNRT pfnSaveExec;
184 /** Done save. */
185 PFNRT pfnSaveDone;
186 /** Prepare load. */
187 PFNRT pfnLoadPrep;
188 /** Execute load. */
189 PFNRT pfnLoadExec;
190 /** Done load. */
191 PFNRT pfnLoadDone;
192 /** User data. */
193 void *pvKey;
194 } Common;
195 } u;
196 /** Data layout version. */
197 uint32_t u32Version;
198 /** Instance number. */
199 uint32_t u32Instance;
200 /** The offset of the final data unit.
201 * This is used for constructing the directory. */
202 RTFOFF offStream;
203 /** The guessed size of the data unit - used only for progress indication. */
204 size_t cbGuess;
205 /** Name size. (bytes) */
206 size_t cchName;
207 /** Name of this unit. (extends beyond the defined size) */
208 char szName[1];
209} SSMUNIT;
210
211AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLivePrep, u.Dev.pfnLivePrep);
212AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLiveExec, u.Dev.pfnLiveExec);
213AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLiveVote, u.Dev.pfnLiveVote);
214AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnSavePrep, u.Dev.pfnSavePrep);
215AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnSaveExec, u.Dev.pfnSaveExec);
216AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnSaveDone, u.Dev.pfnSaveDone);
217AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLoadPrep, u.Dev.pfnLoadPrep);
218AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLoadExec, u.Dev.pfnLoadExec);
219AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLoadDone, u.Dev.pfnLoadDone);
220AssertCompile2MemberOffsets(SSMUNIT, u.Common.pvKey, u.Dev.pDevIns);
221
222AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLivePrep, u.Drv.pfnLivePrep);
223AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLiveExec, u.Drv.pfnLiveExec);
224AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLiveVote, u.Drv.pfnLiveVote);
225AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnSavePrep, u.Drv.pfnSavePrep);
226AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnSaveExec, u.Drv.pfnSaveExec);
227AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnSaveDone, u.Drv.pfnSaveDone);
228AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLoadPrep, u.Drv.pfnLoadPrep);
229AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLoadExec, u.Drv.pfnLoadExec);
230AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLoadDone, u.Drv.pfnLoadDone);
231AssertCompile2MemberOffsets(SSMUNIT, u.Common.pvKey, u.Drv.pDrvIns);
232
233AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLivePrep, u.Internal.pfnLivePrep);
234AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLiveExec, u.Internal.pfnLiveExec);
235AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLiveVote, u.Internal.pfnLiveVote);
236AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnSavePrep, u.Internal.pfnSavePrep);
237AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnSaveExec, u.Internal.pfnSaveExec);
238AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnSaveDone, u.Internal.pfnSaveDone);
239AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLoadPrep, u.Internal.pfnLoadPrep);
240AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLoadExec, u.Internal.pfnLoadExec);
241AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLoadDone, u.Internal.pfnLoadDone);
242
243AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLivePrep, u.External.pfnLivePrep);
244AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLiveExec, u.External.pfnLiveExec);
245AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLiveVote, u.External.pfnLiveVote);
246AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnSavePrep, u.External.pfnSavePrep);
247AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnSaveExec, u.External.pfnSaveExec);
248AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnSaveDone, u.External.pfnSaveDone);
249AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLoadPrep, u.External.pfnLoadPrep);
250AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLoadExec, u.External.pfnLoadExec);
251AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLoadDone, u.External.pfnLoadDone);
252AssertCompile2MemberOffsets(SSMUNIT, u.Common.pvKey, u.External.pvUser);
253
254
255/**
256 * SSM VM Instance data.
257 * Changes to this must checked against the padding of the cfgm union in VM!
258 *
259 * @todo Move this to UVM.
260 */
261typedef struct SSM
262{
263 /** FIFO of data entity descriptors. */
264 R3PTRTYPE(PSSMUNIT) pHead;
265 /** The number of register units. */
266 uint32_t cUnits;
267 /** For lazy init. */
268 bool fInitialized;
269 /** Critical section for serializing cancellation. */
270 RTCRITSECT CancelCritSect;
271 /** The handle of the current save or load operation.
272 * This is used by SSMR3Cancel. */
273 PSSMHANDLE volatile pSSM;
274} SSM;
275/** Pointer to SSM VM instance data. */
276typedef SSM *PSSM;
277
278
279
280/** @} */
281
282RT_C_DECLS_END
283
284#endif /* !___SSMInternal_h */
285
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette