VirtualBox

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

Last change on this file since 33000 was 28800, checked in by vboxsync, 14 years ago

Automated rebranding to Oracle copyright/license strings via filemuncher

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

© 2023 Oracle
ContactPrivacy policyTerms of Use