VirtualBox

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

Last change on this file since 75142 was 69474, checked in by vboxsync, 7 years ago

*: scm updates - header files should have 'svn:keywords=Id Revision' too (doesn't mean they have to use them).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 12.2 KB
Line 
1/* $Id: SSMInternal.h 69474 2017-10-28 13:12:06Z vboxsync $ */
2/** @file
3 * SSM - Internal header file.
4 */
5
6/*
7 * Copyright (C) 2006-2017 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/vmm/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 /** PDM USB device. */
45 SSMUNITTYPE_USB,
46 /** VM Internal. */
47 SSMUNITTYPE_INTERNAL,
48 /** External Wrapper. */
49 SSMUNITTYPE_EXTERNAL
50} SSMUNITTYPE;
51
52/** Pointer to a data unit descriptor. */
53typedef struct SSMUNIT *PSSMUNIT;
54
55/**
56 * Data unit descriptor.
57 */
58typedef struct SSMUNIT
59{
60 /** Pointer ot the next one in the list. */
61 PSSMUNIT pNext;
62
63 /** Called in this save/load operation.
64 * The flag is used to determine whether there is need for a call to
65 * done or not. */
66 bool fCalled;
67 /** Finished its live part.
68 * This is used to handle VERR_SSM_VOTE_FOR_GIVING_UP. */
69 bool fDoneLive;
70 /** Callback interface type. */
71 SSMUNITTYPE enmType;
72 /** Type specific data. */
73 union
74 {
75 /** SSMUNITTYPE_DEV. */
76 struct
77 {
78 /** Prepare live save. */
79 PFNSSMDEVLIVEPREP pfnLivePrep;
80 /** Execute live save. */
81 PFNSSMDEVLIVEEXEC pfnLiveExec;
82 /** Vote live save complete. */
83 PFNSSMDEVLIVEVOTE pfnLiveVote;
84 /** Prepare save. */
85 PFNSSMDEVSAVEPREP pfnSavePrep;
86 /** Execute save. */
87 PFNSSMDEVSAVEEXEC pfnSaveExec;
88 /** Done save. */
89 PFNSSMDEVSAVEDONE pfnSaveDone;
90 /** Prepare load. */
91 PFNSSMDEVLOADPREP pfnLoadPrep;
92 /** Execute load. */
93 PFNSSMDEVLOADEXEC pfnLoadExec;
94 /** Done load. */
95 PFNSSMDEVLOADDONE pfnLoadDone;
96 /** Device instance. */
97 PPDMDEVINS pDevIns;
98 } Dev;
99
100 /** SSMUNITTYPE_DRV. */
101 struct
102 {
103 /** Prepare live save. */
104 PFNSSMDRVLIVEPREP pfnLivePrep;
105 /** Execute live save. */
106 PFNSSMDRVLIVEEXEC pfnLiveExec;
107 /** Vote live save complete. */
108 PFNSSMDRVLIVEVOTE pfnLiveVote;
109 /** Prepare save. */
110 PFNSSMDRVSAVEPREP pfnSavePrep;
111 /** Execute save. */
112 PFNSSMDRVSAVEEXEC pfnSaveExec;
113 /** Done save. */
114 PFNSSMDRVSAVEDONE pfnSaveDone;
115 /** Prepare load. */
116 PFNSSMDRVLOADPREP pfnLoadPrep;
117 /** Execute load. */
118 PFNSSMDRVLOADEXEC pfnLoadExec;
119 /** Done load. */
120 PFNSSMDRVLOADDONE pfnLoadDone;
121 /** Driver instance. */
122 PPDMDRVINS pDrvIns;
123 } Drv;
124
125 /** SSMUNITTYPE_USB. */
126 struct
127 {
128 /** Prepare live save. */
129 PFNSSMUSBLIVEPREP pfnLivePrep;
130 /** Execute live save. */
131 PFNSSMUSBLIVEEXEC pfnLiveExec;
132 /** Vote live save complete. */
133 PFNSSMUSBLIVEVOTE pfnLiveVote;
134 /** Prepare save. */
135 PFNSSMUSBSAVEPREP pfnSavePrep;
136 /** Execute save. */
137 PFNSSMUSBSAVEEXEC pfnSaveExec;
138 /** Done save. */
139 PFNSSMUSBSAVEDONE pfnSaveDone;
140 /** Prepare load. */
141 PFNSSMUSBLOADPREP pfnLoadPrep;
142 /** Execute load. */
143 PFNSSMUSBLOADEXEC pfnLoadExec;
144 /** Done load. */
145 PFNSSMUSBLOADDONE pfnLoadDone;
146 /** USB instance. */
147 PPDMUSBINS pUsbIns;
148 } Usb;
149
150 /** SSMUNITTYPE_INTERNAL. */
151 struct
152 {
153 /** Prepare live save. */
154 PFNSSMINTLIVEPREP pfnLivePrep;
155 /** Execute live save. */
156 PFNSSMINTLIVEEXEC pfnLiveExec;
157 /** Vote live save complete. */
158 PFNSSMINTLIVEVOTE pfnLiveVote;
159 /** Prepare save. */
160 PFNSSMINTSAVEPREP pfnSavePrep;
161 /** Execute save. */
162 PFNSSMINTSAVEEXEC pfnSaveExec;
163 /** Done save. */
164 PFNSSMINTSAVEDONE pfnSaveDone;
165 /** Prepare load. */
166 PFNSSMINTLOADPREP pfnLoadPrep;
167 /** Execute load. */
168 PFNSSMINTLOADEXEC pfnLoadExec;
169 /** Done load. */
170 PFNSSMINTLOADDONE pfnLoadDone;
171 } Internal;
172
173 /** SSMUNITTYPE_EXTERNAL. */
174 struct
175 {
176 /** Prepare live save. */
177 PFNSSMEXTLIVEPREP pfnLivePrep;
178 /** Execute live save. */
179 PFNSSMEXTLIVEEXEC pfnLiveExec;
180 /** Vote live save complete. */
181 PFNSSMEXTLIVEVOTE pfnLiveVote;
182 /** Prepare save. */
183 PFNSSMEXTSAVEPREP pfnSavePrep;
184 /** Execute save. */
185 PFNSSMEXTSAVEEXEC pfnSaveExec;
186 /** Done save. */
187 PFNSSMEXTSAVEDONE pfnSaveDone;
188 /** Prepare load. */
189 PFNSSMEXTLOADPREP pfnLoadPrep;
190 /** Execute load. */
191 PFNSSMEXTLOADEXEC pfnLoadExec;
192 /** Done load. */
193 PFNSSMEXTLOADDONE pfnLoadDone;
194 /** User data. */
195 void *pvUser;
196 } External;
197
198 struct
199 {
200 /** Prepare live save. */
201 PFNRT pfnLivePrep;
202 /** Execute live save. */
203 PFNRT pfnLiveExec;
204 /** Vote live save complete. */
205 PFNRT pfnLiveVote;
206 /** Prepare save. */
207 PFNRT pfnSavePrep;
208 /** Execute save. */
209 PFNRT pfnSaveExec;
210 /** Done save. */
211 PFNRT pfnSaveDone;
212 /** Prepare load. */
213 PFNRT pfnLoadPrep;
214 /** Execute load. */
215 PFNRT pfnLoadExec;
216 /** Done load. */
217 PFNRT pfnLoadDone;
218 /** User data. */
219 void *pvKey;
220 } Common;
221 } u;
222 /** Data layout version. */
223 uint32_t u32Version;
224 /** Instance number. */
225 uint32_t u32Instance;
226 /** The offset of the final data unit.
227 * This is used for constructing the directory. */
228 RTFOFF offStream;
229 /** Critical section to be taken before working any of the callbacks. */
230 PPDMCRITSECT pCritSect;
231 /** The guessed size of the data unit - used only for progress indication. */
232 size_t cbGuess;
233 /** Name size. (bytes) */
234 size_t cchName;
235 /** Name of this unit. (extends beyond the defined size) */
236 char szName[1];
237} SSMUNIT;
238
239AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLivePrep, u.Dev.pfnLivePrep);
240AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLiveExec, u.Dev.pfnLiveExec);
241AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLiveVote, u.Dev.pfnLiveVote);
242AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnSavePrep, u.Dev.pfnSavePrep);
243AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnSaveExec, u.Dev.pfnSaveExec);
244AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnSaveDone, u.Dev.pfnSaveDone);
245AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLoadPrep, u.Dev.pfnLoadPrep);
246AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLoadExec, u.Dev.pfnLoadExec);
247AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLoadDone, u.Dev.pfnLoadDone);
248AssertCompile2MemberOffsets(SSMUNIT, u.Common.pvKey, u.Dev.pDevIns);
249
250AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLivePrep, u.Drv.pfnLivePrep);
251AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLiveExec, u.Drv.pfnLiveExec);
252AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLiveVote, u.Drv.pfnLiveVote);
253AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnSavePrep, u.Drv.pfnSavePrep);
254AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnSaveExec, u.Drv.pfnSaveExec);
255AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnSaveDone, u.Drv.pfnSaveDone);
256AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLoadPrep, u.Drv.pfnLoadPrep);
257AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLoadExec, u.Drv.pfnLoadExec);
258AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLoadDone, u.Drv.pfnLoadDone);
259AssertCompile2MemberOffsets(SSMUNIT, u.Common.pvKey, u.Drv.pDrvIns);
260
261AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLivePrep, u.Usb.pfnLivePrep);
262AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLiveExec, u.Usb.pfnLiveExec);
263AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLiveVote, u.Usb.pfnLiveVote);
264AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnSavePrep, u.Usb.pfnSavePrep);
265AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnSaveExec, u.Usb.pfnSaveExec);
266AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnSaveDone, u.Usb.pfnSaveDone);
267AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLoadPrep, u.Usb.pfnLoadPrep);
268AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLoadExec, u.Usb.pfnLoadExec);
269AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLoadDone, u.Usb.pfnLoadDone);
270AssertCompile2MemberOffsets(SSMUNIT, u.Common.pvKey, u.Usb.pUsbIns);
271
272AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLivePrep, u.Internal.pfnLivePrep);
273AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLiveExec, u.Internal.pfnLiveExec);
274AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLiveVote, u.Internal.pfnLiveVote);
275AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnSavePrep, u.Internal.pfnSavePrep);
276AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnSaveExec, u.Internal.pfnSaveExec);
277AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnSaveDone, u.Internal.pfnSaveDone);
278AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLoadPrep, u.Internal.pfnLoadPrep);
279AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLoadExec, u.Internal.pfnLoadExec);
280AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLoadDone, u.Internal.pfnLoadDone);
281
282AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLivePrep, u.External.pfnLivePrep);
283AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLiveExec, u.External.pfnLiveExec);
284AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLiveVote, u.External.pfnLiveVote);
285AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnSavePrep, u.External.pfnSavePrep);
286AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnSaveExec, u.External.pfnSaveExec);
287AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnSaveDone, u.External.pfnSaveDone);
288AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLoadPrep, u.External.pfnLoadPrep);
289AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLoadExec, u.External.pfnLoadExec);
290AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLoadDone, u.External.pfnLoadDone);
291AssertCompile2MemberOffsets(SSMUNIT, u.Common.pvKey, u.External.pvUser);
292
293
294/**
295 * SSM VM Instance data.
296 * Changes to this must checked against the padding of the cfgm union in VM!
297 *
298 * @todo Move this to UVM.
299 */
300typedef struct SSM
301{
302 /** Critical section for serializing cancellation (pSSM). */
303 RTCRITSECT CancelCritSect;
304 /** The handle of the current save or load operation.
305 * This is used by SSMR3Cancel. */
306 PSSMHANDLE volatile pSSM;
307
308 /** FIFO of data entity descriptors. */
309 R3PTRTYPE(PSSMUNIT) pHead;
310 /** The number of register units. */
311 uint32_t cUnits;
312 /** For lazy init. */
313 bool fInitialized;
314 /** Current pass (for STAM). */
315 uint32_t uPass;
316 uint32_t u32Alignment;
317} SSM;
318/** Pointer to SSM VM instance data. */
319typedef SSM *PSSM;
320
321
322
323/** @} */
324
325RT_C_DECLS_END
326
327#endif /* !___SSMInternal_h */
328
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